Class AbstractNetworkIF

java.lang.Object
oshi.hardware.common.AbstractNetworkIF
All Implemented Interfaces:
NetworkIF
Direct Known Subclasses:
AixNetworkIF, BsdNetworkIF, LinuxNetworkIF, MacNetworkIF, SolarisNetworkIF, WindowsNetworkIF

@ThreadSafe public abstract class AbstractNetworkIF extends Object implements NetworkIF
Network interfaces implementation.
  • Constructor Details

  • Method Details

    • getNetworkInterfaces

      protected static List<NetworkInterface> getNetworkInterfaces(boolean includeLocalInterfaces)
      Returns network interfaces on this machine.
      Parameters:
      includeLocalInterfaces - include local interfaces in the result
      Returns:
      A list of network interfaces
    • queryNetworkInterface

      public NetworkInterface queryNetworkInterface()
      Description copied from interface: NetworkIF
      Gets the NetworkInterface object.
      Specified by:
      queryNetworkInterface in interface NetworkIF
      Returns:
      the network interface, an instance of NetworkInterface.
    • getName

      public String getName()
      Description copied from interface: NetworkIF
      Interface name.
      Specified by:
      getName in interface NetworkIF
      Returns:
      The interface name.
    • getIndex

      public int getIndex()
      Description copied from interface: NetworkIF
      Interface index.
      Specified by:
      getIndex in interface NetworkIF
      Returns:
      The index of the network interface.
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: NetworkIF
      Interface description.
      Specified by:
      getDisplayName in interface NetworkIF
      Returns:
      The description of the network interface. On some platforms, this is identical to the name.
    • getMTU

      public long getMTU()
      Description copied from interface: NetworkIF
      The interface Maximum Transmission Unit (MTU).
      Specified by:
      getMTU in interface NetworkIF
      Returns:
      The MTU of the network interface.

      The value is a 32-bit integer which may be unsigned on some operating systems. On Windows, some non-physical interfaces (e.g., loopback) may return a value of -1 which is equivalent to the maximum unsigned integer value.

      This value is set when the NetworkIF is instantiated and may not be up to date.

    • getMacaddr

      public String getMacaddr()
      Description copied from interface: NetworkIF
      The Media Access Control (MAC) address.
      Specified by:
      getMacaddr in interface NetworkIF
      Returns:
      The MAC Address.

      This value is set when the NetworkIF is instantiated and may not be up to date.

    • getIPv4addr

      public String[] getIPv4addr()
      Description copied from interface: NetworkIF
      The Internet Protocol (IP) v4 address.
      Specified by:
      getIPv4addr in interface NetworkIF
      Returns:
      An array of IPv4 Addresses.

      This value is set when the NetworkIF is instantiated and may not be up to date.

    • getSubnetMasks

      public Short[] getSubnetMasks()
      Description copied from interface: NetworkIF
      The Internet Protocol (IP) v4 subnet masks.
      Specified by:
      getSubnetMasks in interface NetworkIF
      Returns:
      An array of IPv4 subnet mask lengths, corresponding to the IPv4 addresses from NetworkIF.getIPv4addr(). Ranges between 0-32.

      This value is set when the NetworkIF is instantiated and may not be up to date.

    • getIPv6addr

      public String[] getIPv6addr()
      Description copied from interface: NetworkIF
      The Internet Protocol (IP) v6 address.
      Specified by:
      getIPv6addr in interface NetworkIF
      Returns:
      An array of IPv6 Addresses.

      This value is set when the NetworkIF is instantiated and may not be up to date.

    • getPrefixLengths

      public Short[] getPrefixLengths()
      Description copied from interface: NetworkIF
      The Internet Protocol (IP) v6 address.
      Specified by:
      getPrefixLengths in interface NetworkIF
      Returns:
      The IPv6 address prefix lengths, corresponding to the IPv6 addresses from NetworkIF.getIPv6addr(). Ranges between 0-128.

      This value is set when the NetworkIF is instantiated and may not be up to date.

    • isKnownVmMacAddr

      public boolean isKnownVmMacAddr()
      Description copied from interface: NetworkIF
      Determines if the MAC address on this interface corresponds to a known Virtual Machine.
      Specified by:
      isKnownVmMacAddr in interface NetworkIF
      Returns:
      true if the MAC address corresponds to a known virtual machine.
    • toString

      public String toString()
      Overrides:
      toString in class Object