Beispiel #1
0
 public Form1()
 {
     InitializeComponent();
     System.Reflection.PropertyInfo controlProperty = typeof(System.Windows.Forms.Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
     controlProperty.SetValue(PacketStreamView, true, null);
     MySniffer            = new Sniffer(NetworkInstruments.getAnyAdaptor(), ErrorHandler);
     AdapterLab.Text      = MySniffer.Adapter.Name;
     ScrollToLast         = true;
     UpdateTimer          = new Timer();
     UpdateTimer.Tick    += UpdateData;
     UpdateTimer.Interval = 500;
 }
Beispiel #2
0
 private void InitSocket()
 {
     Listener = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
     Listener.Bind(new IPEndPoint(NetworkInstruments.getAdapterIPAddress(Adapter), 0));
     Listener.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
     Listener.IOControl(IOControlCode.ReceiveAll, new byte[4] {
         1, 0, 0, 0
     }, new byte[4] {
         1, 0, 0, 0
     });
     Listener.ReceiveBufferSize = 2147483647; // 2^31
     Listener.SendBufferSize    = 2147483647;
     Listener.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
 }
Beispiel #3
0
 private void AdapterBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     IpLab.Text  = NetworkInstruments.getAdapterIPAddress(Adapters[AdapterBox.SelectedIndex]).ToString();
     MacLab.Text = Adapters[AdapterBox.SelectedIndex].GetPhysicalAddress().ToString();
 }
Beispiel #4
0
 public AdapterChoosingForm(NetworkInterface OldAdapter, AdapterCallBack SetAdapter)
 {
     InitializeComponent();
     this.SetAdapter = SetAdapter;
     NetworkInterface[] AdaptersRange = NetworkInterface.GetAllNetworkInterfaces();
     Adapters = new List <NetworkInterface>();
     for (int i = 0; i < AdaptersRange.Length; ++i)
     {
         if (AdaptersRange[i].OperationalStatus == OperationalStatus.Up && AdaptersRange[i].NetworkInterfaceType != NetworkInterfaceType.Loopback && NetworkInstruments.getAdapterIPAddress(AdaptersRange[i]) != IPAddress.Any)
         {
             Adapters.Add(AdaptersRange[i]);
             AdapterBox.Items.Add(AdaptersRange[i].Name + " Status: " + AdaptersRange[i].OperationalStatus.ToString() + " Type: " + AdaptersRange[i].NetworkInterfaceType);
             if (AdaptersRange[i].Id == OldAdapter.Id)
             {
                 AdapterBox.SelectedIndex = AdapterBox.Items.Count - 1;
                 CurAdapterLab.Text       = AdaptersRange[i].Name + " Status: " + AdaptersRange[i].OperationalStatus.ToString() + " Type: " + AdaptersRange[i].NetworkInterfaceType;
             }
         }
     }
     if (AdapterBox.SelectedIndex == -1 && AdapterBox.Items.Count != 0)
     {
         AdapterBox.SelectedIndex = 0;
     }
 }