Package oshi.hardware.common
Class AbstractNetworkIF
java.lang.Object
oshi.hardware.common.AbstractNetworkIF
- All Implemented Interfaces:
NetworkIF
- Direct Known Subclasses:
AixNetworkIF
,FreeBsdNetworkIF
,LinuxNetworkIF
,MacNetworkIF
,SolarisNetworkIF
,WindowsNetworkIF
@ThreadSafe public abstract class AbstractNetworkIF extends java.lang.Object implements NetworkIF
Network interfaces implementation.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNetworkIF(java.net.NetworkInterface netint)
Construct aNetworkIF
object backed by the specifiedNetworkInterface
. -
Method Summary
Modifier and Type Method Description java.lang.String
getDisplayName()
Interface description.int
getIfType()
(Windows, macOS) The NDIS Interface Type.java.lang.String[]
getIPv4addr()
The Internet Protocol (IP) v4 address.java.lang.String[]
getIPv6addr()
The Internet Protocol (IP) v6 address.java.lang.String
getMacaddr()
The Media Access Control (MAC) address.int
getMTU()
The interface Maximum Transmission Unit (MTU).java.lang.String
getName()
Interface name.int
getNdisPhysicalMediumType()
(Windows Vista and higher only) The NDIS physical medium type.protected static java.util.List<java.net.NetworkInterface>
getNetworkInterfaces()
Returns network interfaces that are not Loopback, and have a hardware address.java.lang.Short[]
getPrefixLengths()
The Internet Protocol (IP) v6 address.java.lang.Short[]
getSubnetMasks()
The Internet Protocol (IP) v4 subnet masks.boolean
isConnectorPresent()
(Windows Vista and higher) Set if a connector is present on the network interface.boolean
isKnownVmMacAddr()
Determines if the MAC address on this interface corresponds to a known Virtual Machine.java.net.NetworkInterface
queryNetworkInterface()
Gets theNetworkInterface
object.java.lang.String
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface oshi.hardware.NetworkIF
getBytesRecv, getBytesSent, getCollisions, getInDrops, getInErrors, getOutErrors, getPacketsRecv, getPacketsSent, getSpeed, getTimeStamp, updateAttributes
-
Constructor Details
-
AbstractNetworkIF
protected AbstractNetworkIF(java.net.NetworkInterface netint)Construct aNetworkIF
object backed by the specifiedNetworkInterface
.- Parameters:
netint
- The core javaNetworkInterface
backing this object.
-
-
Method Details
-
getNetworkInterfaces
protected static java.util.List<java.net.NetworkInterface> getNetworkInterfaces()Returns network interfaces that are not Loopback, and have a hardware address.- Returns:
- A list of network interfaces
-
queryNetworkInterface
public java.net.NetworkInterface queryNetworkInterface()Description copied from interface:NetworkIF
Gets theNetworkInterface
object.- Specified by:
queryNetworkInterface
in interfaceNetworkIF
- Returns:
- the network interface, an instance of
NetworkInterface
.
-
getName
public java.lang.String getName()Description copied from interface:NetworkIF
Interface name. -
getDisplayName
public java.lang.String getDisplayName()Description copied from interface:NetworkIF
Interface description.- Specified by:
getDisplayName
in interfaceNetworkIF
- Returns:
- The description of the network interface. On some platforms, this is identical to the name.
-
getMTU
public int getMTU()Description copied from interface:NetworkIF
The interface Maximum Transmission Unit (MTU). -
getMacaddr
public java.lang.String getMacaddr()Description copied from interface:NetworkIF
The Media Access Control (MAC) address.- Specified by:
getMacaddr
in interfaceNetworkIF
- Returns:
- The MAC Address.
This value is set when the
NetworkIF
is instantiated and may not be up to date.
-
getIPv4addr
public java.lang.String[] getIPv4addr()Description copied from interface:NetworkIF
The Internet Protocol (IP) v4 address.- Specified by:
getIPv4addr
in interfaceNetworkIF
- Returns:
- An array of IPv4 Addresses.
This value is set when the
NetworkIF
is instantiated and may not be up to date.
-
getSubnetMasks
public java.lang.Short[] getSubnetMasks()Description copied from interface:NetworkIF
The Internet Protocol (IP) v4 subnet masks.- Specified by:
getSubnetMasks
in interfaceNetworkIF
- 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 java.lang.String[] getIPv6addr()Description copied from interface:NetworkIF
The Internet Protocol (IP) v6 address.- Specified by:
getIPv6addr
in interfaceNetworkIF
- Returns:
- An array of IPv6 Addresses.
This value is set when the
NetworkIF
is instantiated and may not be up to date.
-
getPrefixLengths
public java.lang.Short[] getPrefixLengths()Description copied from interface:NetworkIF
The Internet Protocol (IP) v6 address.- Specified by:
getPrefixLengths
in interfaceNetworkIF
- 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 interfaceNetworkIF
- Returns:
true
if the MAC address corresponds to a known virtual machine.
-
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
-
getNdisPhysicalMediumType
public int getNdisPhysicalMediumType()Description copied from interface:NetworkIF
(Windows Vista and higher only) The NDIS physical medium type. This member can be one of the values from theNDIS_PHYSICAL_MEDIUM
enumeration type defined in theNtddndis.h
header file.- Specified by:
getNdisPhysicalMediumType
in interfaceNetworkIF
- Returns:
- the ndisPhysicalMediumType
-
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.
- Specified by:
isConnectorPresent
in interfaceNetworkIF
- Returns:
true
if there is a physical network adapter (Windows) or a connected cable (Linux), false otherwise
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-