Package jpcap

Examples of jpcap.NetworkInterface


      System.out.println("Usage: java Traceroute <device index (e.g., 0, 1..)> <target host address>");
      System.exit(0);
    }
   
    //initialize Jpcap
    NetworkInterface device=JpcapCaptor.getDeviceList()[Integer.parseInt(args[0])];
    JpcapCaptor captor=JpcapCaptor.openDevice(device,2000,false,5000);
    InetAddress thisIP=null;
    for(NetworkInterfaceAddress addr:device.addresses)
      if(addr.address instanceof Inet4Address){
        thisIP=addr.address;
View Full Code Here


    if (networkInterfacesAll == null || networkInterfacesAll.length == 0) {
      throw new RuntimeException("No network interfaces found");
    }
    selectNICComboBox = new JComboBox();

    NetworkInterface tunnelInterface = null;
    for (NetworkInterface intf : networkInterfacesAll) {
      if (!ON_WINDOWS && intf.name.equals("lo")) {
        loopbackInterface = intf;
      }
      if ((intf.name != null && intf.name.equals("tap0")) ||
          (intf.description != null && intf.description.contains("VMware Virtual Ethernet Adapter"))) {
        tunnelInterface = intf;
      }

      selectNICComboBox.addItem(intf.description + " (" + intf.name + ")");
    }
    selectNICComboBox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
        if (e.getStateChange() != ItemEvent.SELECTED) {
          return;
        }

        /* Detect selected network interface */
        String descr = (String) ((JComboBox)e.getSource()).getSelectedItem();
        NetworkInterface selected = null;
        for (NetworkInterface networkInterface2 : networkInterfacesAll) {
          String label = networkInterface2.description + " (" + networkInterface2.name + ")";
          if (label.equals(descr)) {
            selected = networkInterface2;
            break;
View Full Code Here

TOP

Related Classes of jpcap.NetworkInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.