Example #1
0
        /// <summary>
        /// Send a queue of raw packets to the network.
        /// </summary>
        /// <param name="device">The PcapDevice on which to send the queue</param>
        /// <param name="synchronize">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
        /// <returns></returns>
        public int Transmit(PcapDevice device, bool synchronize)
        {
            if (!device.PcapOpened)
            {
                throw new PcapException("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 = synchronize ? 1 : 0;

            return(SharpPcap.pcap_sendqueue_transmit(device.PcapHandle, m_queue, sync));
        }
Example #2
0
        /// <summary>
        /// Stellt eine Klasse da die das Sniffen von Packets regelt
        /// </summary>
        /// <param name="port">Der Port auf den der TCPStreamAssembler horchen soll</param>
        public L2NetSniffer(PcapDevice device, int dst_port)
        {
            this.dst_port = dst_port;
            this.device = device;

            /*
             * (((ip.src == 192.168.100.150) && (tcp.dstport == 7777) ) || ((ip.src == 78.46.33.43) && (tcp.dstport == 52784)))
             */
            this.tcpDumpFilter = "port " + dst_port;

            this.clientStr = new L2NetStream();
            this.serverStr = new L2NetStream();
            // TODO: wenn keine devices gefunden wurden, Meldung

            this.Init();
        }
Example #3
0
        /// <summary>
        /// Initialisiert die SnifferControll
        /// </summary>
        /// <param name="device">Das PcapDevice mit dem gesnifft werden soll</param>
        /// <param name="filter">Der TCPDumpfilter der angewendet werden soll</param>
        public void Init(PcapDevice device, string filter)
        {
            this.device = device;
            this.tcpDumpFilter = filter;

            //Register our handler function to the 'packet arrival' event
            this.device.PcapOnPacketArrival +=
                new SharpPcap.PacketArrivalEvent(device_PcapOnPacketArrival);

            //Open the device for capturing
            //true -- means promiscuous mode
            //1000 -- means a read wait of 1000ms
            this.device.PcapOpen(false, 100);

            //Associate the filter with this capture
            this.device.PcapSetFilter(this.tcpDumpFilter);
        }
 public void Remove( PcapDevice value )
 {
     List.Remove( value );
 }
 public void Insert( int index, PcapDevice value )
 {
     List.Insert( index, value );
 }
 public int IndexOf( PcapDevice value )
 {
     return( List.IndexOf( value ) );
 }
 public bool Contains( PcapDevice value )
 {
     // If value is not of type PcapDevice, this will return false.
     return( List.Contains( value ) );
 }
 public int Add( PcapDevice value )
 {
     return( List.Add( value ) );
 }
Example #9
0
        /// <summary>
        /// Send a queue of raw packets to the network. 
        /// </summary>
        /// <param name="device">The PcapDevice on which to send the queue</param>
        /// <param name="synchronize">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
        /// <returns></returns>
        public int Transmit( PcapDevice device, bool synchronize)
        {
            if(!device.PcapOpened)
                throw new PcapException("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 = synchronize ? 1 : 0;
            return SharpPcap.pcap_sendqueue_transmit(device.PcapHandle, m_queue, sync);
        }
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     int index = comboBox1.SelectedIndex;
     dev = devices[index];
     this.propertyGrid1.SelectedObject = (dev as NetworkDevice);
 }
Example #11
0
 public bool Contains(PcapDevice value)
 {
     // If value is not of type PcapDevice, this will return false.
     return(List.Contains(value));
 }
Example #12
0
 public void Remove(PcapDevice value)
 {
     List.Remove(value);
 }
Example #13
0
 public void Insert(int index, PcapDevice value)
 {
     List.Insert(index, value);
 }
Example #14
0
 public int IndexOf(PcapDevice value)
 {
     return(List.IndexOf(value));
 }
Example #15
0
 public int Add(PcapDevice value)
 {
     return(List.Add(value));
 }
Example #16
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     this.selectedDevice = this.deviceList[this.comboBoxDevices.SelectedIndex];
     this.port = (int)this.numericUpDown1.Value;
     this.Hide();
 }