Exemple #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));
            }
        }
Exemple #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);
         }
     }
 }
Exemple #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));
            }
        }
 internal extern static int pcap_sendqueue_transmit(IntPtr /*pcap_t * */ p, ref pcap_send_queue queue, int sync);
Exemple #5
0
 /// <summary>
 /// Send a queue of raw packets to the network.
 /// </summary>
 /// <param name="p"></param>
 /// <param name="queue"></param>
 /// <param name="sync">determines if the send operation must be synchronized:
 /// if it is non-zero, the packets are sent respecting the timestamps,
 /// otherwise they are sent as fast as possible</param>
 /// <returns>The amount of bytes actually sent.
 /// If it is smaller than the size parameter, an error occurred
 /// during the send. The error can be caused by a driver/adapter
 /// problem or by an inconsistent/bogus send queue.</returns>
 internal static int pcap_sendqueue_transmit(IntPtr /*pcap_t * */ p, ref pcap_send_queue queue, int sync)
 {
     return(UseWindows
         ? Windows.pcap_sendqueue_transmit(p, ref queue, sync)
         : Unix.pcap_sendqueue_transmit(p, ref queue, sync));
 }
 internal extern static int pcap_sendqueue_transmit(PcapHandle /*pcap_t * */ p, ref pcap_send_queue queue, int sync);