Class LinuxNetworkIF

java.lang.Object
oshi.hardware.common.AbstractNetworkIF
oshi.hardware.common.platform.linux.LinuxNetworkIF
All Implemented Interfaces:
NetworkIF
Direct Known Subclasses:
LinuxNetworkIfNF

@ThreadSafe public abstract class LinuxNetworkIF extends AbstractNetworkIF
LinuxNetworks class.
  • Constructor Details

  • Method Details

    • queryIfModelFromSysfs

      protected static String queryIfModelFromSysfs(String name)
      Reads vendor/model from the sysfs uevent file.
      Parameters:
      name - the interface name
      Returns:
      vendor + model string, or the interface name if not found
    • getIfType

      public int getIfType()
      Description copied from interface: NetworkIF
      (Windows, macOS) The NDIS Interface Type. NDIS interface types are registered with the Internet Assigned Numbers Authority (IANA), which publishes a list of interface types periodically in the Assigned Numbers RFC, or in a derivative of it that is specific to Internet network management number assignments.

      (Linux) ARP Protocol hardware identifiers defined in include/uapi/linux/if_arp.h

      Returns:
      the ifType
    • isConnectorPresent

      public boolean isConnectorPresent()
      Description copied from interface: NetworkIF
      (Windows Vista and higher) Set if a connector is present on the network interface.

      (Linux) Indicates the current physical link state of the interface.

      Returns:
      true if there is a physical network adapter (Windows) or a connected cable (Linux), false otherwise
    • getIfAlias

      public String getIfAlias()
      Description copied from interface: NetworkIF
      The ifAlias as described in RFC 2863.

      The ifAlias object allows a network manager to give one or more interfaces their own unique names, irrespective of any interface-stack relationship. Further, the ifAlias name is non-volatile, and thus an interface must retain its assigned ifAlias value across reboots, even if an agent chooses a new ifIndex value for the interface.

      Only implemented for Windows (Vista and newer) and Linux.

      Returns:
      The ifAlias of the interface if available, otherwise the empty string.
    • getIfOperStatus

      public NetworkIF.IfOperStatus getIfOperStatus()
      Description copied from interface: NetworkIF
      The ifOperStatus as described in RFC 2863.

      Only implemented for Windows (Vista and newer) and Linux.

      Returns:
      The current operational state of the interface.
    • updateAttributes

      public boolean updateAttributes()
      Description copied from interface: NetworkIF
      Updates interface network statistics on this interface. Statistics include packets and bytes sent and received, and interface speed.

      This method is intended for updating a single interface that is being individually monitored. If you are updating multiple interfaces, it is more efficient to re-query the entire list from HardwareAbstractionLayer.getNetworkIFs() and correlate the results, since on many platforms the full list must be queried to provide any individual result.

      Returns:
      true if the update was successful, false otherwise.
    • parseIfOperStatus

      protected static NetworkIF.IfOperStatus parseIfOperStatus(String operState)
      Parses the operational status from a sysfs operstate string.
      Parameters:
      operState - the operstate string
      Returns:
      the parsed IfOperStatus