Пример #1
0
        /// <summary>
        /// Creates and allocates a new SendQueue
        /// </summary>
        /// <param name="memSize">
        /// The maximun amount of memory (in bytes)
        /// to allocate for the queue</param>
        public SendQueue(int memSize)
        {
            // ensure that we are running under npcap
            NpcapDevice.ThrowIfNotNpcap();

            m_queue = SafeNativeMethods.pcap_sendqueue_alloc(memSize);
            if (m_queue == IntPtr.Zero)
            {
                throw new PcapException("Error creating PcapSendQueue");
            }
        }
Пример #2
0
        /// <summary>
        /// Send a queue of raw packets to the network.
        /// </summary>
        /// <param name="device">
        /// The device on which to send the queue
        /// A <see cref="PcapDevice"/>
        /// </param>
        /// <param name="transmitMode">
        /// A <see cref="SendQueueTransmitModes"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Int32"/>
        /// </returns>
        public int Transmit(NpcapDevice device, SendQueueTransmitModes transmitMode)
        {
            if (!device.Opened)
            {
                throw new DeviceNotReadyException("Can't transmit queue, the pcap device is closed");
            }

            if (m_queue == IntPtr.Zero)
            {
                throw new PcapException("Can't transmit queue, this queue is disposed");
            }

            int sync = (transmitMode == SendQueueTransmitModes.Synchronized) ? 1 : 0;

            return(SafeNativeMethods.pcap_sendqueue_transmit(device.PcapHandle, m_queue, sync));
        }
Пример #3
0
 /// <summary>
 /// Send a queue of raw packets to the network.
 /// </summary>
 /// <param name="device">
 /// The device on which to send the queue
 /// A <see cref="PcapDevice"/>
 /// </param>
 /// <param name="transmitMode">
 /// A <see cref="SendQueueTransmitModes"/>
 /// </param>
 /// <returns>
 /// A <see cref="int"/>
 /// </returns>
 public int Transmit(NpcapDevice device, SendQueueTransmitModes transmitMode)
 {
     return(Transmit(device, transmitMode == SendQueueTransmitModes.Synchronized));
 }