Class MacNetworks

java.lang.Object
oshi.hardware.common.Networks
oshi.hardware.platform.mac.MacNetworks

@ThreadSafe
public final class MacNetworks
extends Networks
MacNetworks class.
  • Constructor Summary

    Constructors 
    Constructor Description
    MacNetworks()  
  • Method Summary

    Modifier and Type Method Description
    NetworkIF[] getNetworks()
    Gets the network interfaces on this machine
    static java.util.Map<java.lang.Integer,​oshi.hardware.platform.mac.MacNetworks.IFdata> queryIFdata​(int index)
    Map all network interfaces.
    static boolean updateNetworkStats​(NetworkIF netIF)
    Updates interface network statistics on the given interface.

    Methods inherited from class oshi.hardware.common.Networks

    getNetworkInterfaces

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getNetworks

      public NetworkIF[] getNetworks()
      Description copied from class: Networks
      Gets the network interfaces on this machine
      Overrides:
      getNetworks in class Networks
      Returns:
      An array of NetworkIF objects representing the interfaces
    • queryIFdata

      public static java.util.Map<java.lang.Integer,​oshi.hardware.platform.mac.MacNetworks.IFdata> queryIFdata​(int index)
      Map all network interfaces. Ported from source code of "netstat -ir". See http://opensource.apple.com/source/network_cmds/network_cmds-457/ netstat.tproj/if.c
      Parameters:
      index - If nonnegative, returns results for only that index
      Returns:
      a map of MacNetworks.IFdata object indexed by the interface index, encapsulating the stats, or null if the query failed.
    • updateNetworkStats

      public static boolean updateNetworkStats​(NetworkIF netIF)
      Updates interface network statistics on the given interface. Statistics include packets and bytes sent and received, and interface speed.
      Parameters:
      netIF - The interface on which to update statistics
      Returns:
      true if the update was successful, false otherwise.