@Deprecated
public class NetworkDeviceManager
extends java.lang.Object
or # at the begining indicates comment.
where type is one of Type.*.getValue() and if multiple types exist they are separated by a semicolon ;
Additionally, if a gateway is set, this will become the default route for the system. Currently, the network configuration is not advanced enough to deal with static routing tables. The short term use case assumes at most one routable network and several non-routable (flat) networks.
The NetworkDeviceManager can be used in an enabled or disabled state. In the case that the NetworkDeviceManager is enabled, the network.map file will be loaded and utilized to describe how to use the network interfaces.
Modifier and Type | Class and Description |
---|---|
static class |
NetworkDeviceManager.NetworkDevice
Deprecated.
The network device is described by its macaddress, label, type and the preferred network configuration,
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONFIG_ALTERED
Deprecated.
|
static java.lang.String |
TAG
Deprecated.
|
Constructor and Description |
---|
NetworkDeviceManager()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
addNetworkDevice(NetworkDeviceManager.NetworkDevice nd,
java.io.File directory)
Deprecated.
add a discovered networkDevice to the list
|
static java.lang.String |
byteToMac(byte[] mac)
Deprecated.
Creates a stringified mac address in pseudo human readable form.
|
static void |
configure(NetworkDeviceManager.NetworkDevice nd)
Deprecated.
Configure an interface just given the mac address.
|
static boolean |
configure(java.lang.String ifaceNameRaw)
Deprecated.
Given the interfacename switches to the root user and configures the network.
|
static boolean |
configure(java.lang.String ifaceNameRaw,
java.lang.String addressRaw,
java.lang.String netmaskRaw,
java.lang.String gatewayRaw,
boolean createDefaultRoute,
java.lang.String dnsRaw)
Deprecated.
Given the interfacename and the address, netmask, gateway this method switches to the root
user and configures the network.
|
static void |
enable(boolean state)
Deprecated.
Initializes the network mappings.
|
static java.lang.String |
getAddress(java.net.NetworkInterface ni)
Deprecated.
Gets the ip address of an interface that is up, return null if interface is not up or has no
address.
|
static NetworkDeviceManager.NetworkDevice |
getDevice(java.lang.String macaddr)
Deprecated.
Finds a network device in the network map specified by the macaddres.
|
static java.net.NetworkInterface |
getInterface(java.lang.String macaddr)
Deprecated.
|
static java.net.NetworkInterface |
getInterface(java.lang.String macaddr,
boolean clean)
Deprecated.
Get the network interface of the device described in the network map file.
|
static java.lang.String |
getIPv4Address(java.lang.String macaddr)
Deprecated.
|
static java.lang.String |
getMacAddress(java.net.NetworkInterface ni)
Deprecated.
Given a NetworkInterface, return the MAC address in the XX:XX:XX:XX:XX:XX format
if no HardwareAddress is available, use a synthetically generated address based on the
device name.
|
static java.util.List<NetworkDeviceManager.NetworkDevice> |
getNetworkDevices()
Deprecated.
Returns an unmodifiable list of network devices read from the network.map file.
|
static java.util.Collection<java.net.NetworkInterface> |
getUnmanagedInterfaces()
Deprecated.
Returns a list of unmanaged network devices constructed by scanning the list of managed
network devices and the list of NetworkInterfaces from Android and returns the difference.
|
static java.lang.String |
getUnmanagedIPv4Address(java.lang.String macaddr)
Deprecated.
Given a mac address, get the ip address for any unmanaged interfaces
|
static boolean |
removeNetworkDevice(java.lang.String macaddr,
java.io.File directory)
Deprecated.
remove a device with the given mac address from the device list
|
static void |
setContext(android.content.Context c)
Deprecated.
|
static void |
setDirectory(java.io.File dir)
Deprecated.
Sets the directory for the network mapping.
|
static boolean |
unconfigure(NetworkDeviceManager.NetworkDevice nd)
Deprecated.
|
static boolean |
unconfigure(java.lang.String ifaceNameRaw)
Deprecated.
|
public static final java.lang.String TAG
public static final java.lang.String CONFIG_ALTERED
public static void setDirectory(java.io.File dir)
dir
- if the location does not exist, or the location is null
Environment.getExternalStorageDirectory(), "atak") is used when the NetworkDeviceManager
is enabled.public static void enable(boolean state)
public static void setContext(android.content.Context c)
public static boolean removeNetworkDevice(java.lang.String macaddr, java.io.File directory)
macaddr
- the mac of the device to remove in the format XX:XX:XX:XX:XX:XXdirectory
- should be consistent with FileSystemUtils.getRoot()public static boolean addNetworkDevice(NetworkDeviceManager.NetworkDevice nd, java.io.File directory)
nd
- the NetworkDevice to be addeddirectory
- should be consistent with FileSystemUtils.getRoot()public static java.util.List<NetworkDeviceManager.NetworkDevice> getNetworkDevices()
public static java.util.Collection<java.net.NetworkInterface> getUnmanagedInterfaces()
public static NetworkDeviceManager.NetworkDevice getDevice(java.lang.String macaddr)
macaddr
- is in the format XX:XX:XX:XX:XX:XX@Deprecated public static java.lang.String getIPv4Address(java.lang.String macaddr)
macaddr
- is in the format XX:XX:XX:XX:XX:XXpublic static java.lang.String getUnmanagedIPv4Address(java.lang.String macaddr)
@Deprecated public static java.net.NetworkInterface getInterface(java.lang.String macaddr)
public static java.net.NetworkInterface getInterface(java.lang.String macaddr, boolean clean)
macaddr
- is in the format XX:XX:XX:XX:XX:XX
If for any reason rhe Network Interface is believed to be bad, a call *MUST* be made to request a clean interface.
Currently, we are observing a case where the NetworkInteface seems perfectly fine and will work for most things, but a call to joinAddress will FAIL.
public static boolean unconfigure(NetworkDeviceManager.NetworkDevice nd)
public static void configure(NetworkDeviceManager.NetworkDevice nd)
public static java.lang.String byteToMac(byte[] mac)
public static java.lang.String getMacAddress(java.net.NetworkInterface ni)
public static java.lang.String getAddress(java.net.NetworkInterface ni)
ni
- the interface to get the ip address of.public static boolean unconfigure(java.lang.String ifaceNameRaw)
public static boolean configure(java.lang.String ifaceNameRaw, java.lang.String addressRaw, java.lang.String netmaskRaw, java.lang.String gatewayRaw, boolean createDefaultRoute, java.lang.String dnsRaw)
ifaceNameRaw
- the name of the interface to configureaddressRaw
- in IPv4 notation.netmaskRaw
- in long form.gatewayRaw
- in IPv4 notation, can be null or the empty string to denote no gateway exists.
if no gateway exists, do not set the default route.createDefaultRoute
- create a default routednsRaw
- the dns server, not set if dns is the empty string or null.public static boolean configure(java.lang.String ifaceNameRaw)