/// <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 winpcap WinPcapDevice.ThrowIfNotWinPcap(); m_queue = WinPcap.SafeNativeMethods.pcap_sendqueue_alloc(memSize); if (m_queue == IntPtr.Zero) { throw new PcapException("Error creating PcapSendQueue"); } }
/// <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(WinPcapDevice 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(WinPcap.SafeNativeMethods.pcap_sendqueue_transmit(device.PcapHandle, m_queue, sync)); }
/// <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(WinPcapDevice 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 WinPcap.SafeNativeMethods.pcap_sendqueue_transmit(device.PcapHandle, m_queue, sync); }