Beispiel #1
0
        protected unsafe int NativeTransmit(PcapDevice device, bool synchronized)
        {
            int sync = synchronized ? 1 : 0;

            fixed(byte *buf = buffer)
            {
                var pcap_queue = new pcap_send_queue
                {
                    maxlen  = (uint)buffer.Length,
                    len     = (uint)CurrentLength,
                    ptrBuff = new IntPtr(buf)
                };

                return(LibPcapSafeNativeMethods.pcap_sendqueue_transmit(device.PcapHandle, ref pcap_queue, sync));
            }
        }
Beispiel #2
0
 private static bool GetIsHardwareAccelerated()
 {
     using (var handle = LibPcapSafeNativeMethods.pcap_open_dead(1, 60))
     {
         try
         {
             pcap_send_queue queue = default;
             LibPcapSafeNativeMethods.pcap_sendqueue_transmit(handle, ref queue, 0);
             return(true);
         }
         catch (TypeLoadException)
         {
             // Function pcap_sendqueue_transmit not found
             return(false);
         }
     }
 }
Beispiel #3
0
        protected unsafe int NativeTransmit(PcapDevice device, SendQueueTransmitModes transmitMode)
        {
            if (CurrentLength == 0)
            {
                // Npcap does not properly check for 0 packets queue
                // See https://github.com/nmap/npcap/issues/287
                return(0);
            }
            int sync = (transmitMode == SendQueueTransmitModes.Synchronized) ? 1 : 0;

            fixed(byte *buf = buffer)
            {
                var pcap_queue = new pcap_send_queue
                {
                    maxlen  = (uint)buffer.Length,
                    len     = (uint)CurrentLength,
                    ptrBuff = new IntPtr(buf)
                };

                return(LibPcapSafeNativeMethods.pcap_sendqueue_transmit(device.PcapHandle, ref pcap_queue, sync));
            }
        }