public class NetworkInterfaceManager extends Object
Constructor and Description |
---|
NetworkInterfaceManager() |
Modifier and Type | Method and Description |
---|---|
static void |
configure(NetworkInterface netif,
IPConfiguration conf)
Sets the IP configuration of a network interface.
|
static void |
disable(NetworkInterface netif)
Disables a network interface (software side).
|
static void |
enable(NetworkInterface netif)
Enables a network interface (software side).
|
static IPConfiguration |
getIPConfiguration(NetworkInterface netif)
Gets the current IP configuration of a network interface.
|
static boolean |
isEnabled(NetworkInterface netif)
Tells whether a network interface is enabled or not.
|
static boolean |
isStarted(NetworkInterface netif)
Tells whether a network interface is started or not.
|
static void |
setDefault(NetworkInterface netif)
Set a network interface as default.
|
static void |
start(NetworkInterface netif)
Starts a network interface (hardware side).
|
static void |
stop(NetworkInterface netif)
Stops a network interface (hardware side).
|
public static void configure(NetworkInterface netif, IPConfiguration conf) throws IOException
null
and relevant fields are applied. For instance, static
IP address is ignored if DHCP is to be used.
When the configuration is applied, be aware that:
IOException
,
netif
- the network interface.conf
- the network interface IP configuration.IOException
- if it is not possible to reconfigure the interface.IllegalArgumentException
- if netif or conf is null
.public static void disable(NetworkInterface netif) throws IllegalStateException, IOException
IOException
.netif
- the network interface to disable.IllegalStateException
- if the network interface is currently stopped.IOException
- if an I/O error occurs.IllegalArgumentException
- if netif is null
.public static void enable(NetworkInterface netif) throws IllegalStateException, IOException
start(NetworkInterface)
has
been called beforehand.netif
- the network interface to enable.IllegalStateException
- if the interface is currently stopped.IOException
- if an I/O error occurs.IllegalArgumentException
- if netif is null
.public static IPConfiguration getIPConfiguration(NetworkInterface netif) throws IOException
netif
- the network interface.IOException
- if an I/O error occurs.IllegalArgumentException
- if netif is null
.public static boolean isEnabled(NetworkInterface netif)
netif
- the network interface.true
if enabled, false
otherwiseIllegalArgumentException
- if netif is null
.public static boolean isStarted(NetworkInterface netif)
netif
- the network interface.true
if started, false
otherwise.IllegalArgumentException
- if netif is null
.public static void setDefault(NetworkInterface netif) throws IOException
netif
- the network interface to use as the default one.IOException
- if an I/O error occurs.IllegalArgumentException
- if netif is null
.public static void start(NetworkInterface netif) throws IOException
enable(NetworkInterface)
has to
be called after this method.netif
- the network interface to start.IOException
- if an I/O error occurs.IllegalArgumentException
- if netif is null
.public static void stop(NetworkInterface netif) throws IOException
netif
- the interface to stop.IOException
- if an I/O error occurs.IllegalArgumentException
- if netif is null
.