# Class: Device

## LuCI .network. Device

A `Network.Device` class instance represents an underlying Linux network device and allows querying device details such as packet statistics or MTU.

#### new LuCI.network.Device()

network.js, line 2857

### Methods

#### getBridgeID(){null|string}

network.js, line 3078

  Get the bridge ID

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the ID of this network bridge or `null` if this network device is not a Linux bridge.

#### getBridgeSTP(){boolean}

network.js, line 3090

  Get the bridge STP setting

  ##### Returns:

  Type | Description
  --- | ---
  boolean | Returns `true` when this device is a Linux bridge and has `stp` enabled, else `false`.

#### getCarrier(){boolean}

network.js, line 3184

  Get the carrier state of the network device.

  ##### Returns:

  Type | Description
  --- | ---
  boolean | Returns true if the device has a carrier, e.g. when a cable is inserted into an Ethernet port of false if there is none.

#### getDuplex(){string|null}

network.js, line 3211

  Get the current duplex mode of the network device if available.

  ##### Returns:

  Type | Description
  --- | ---
  string | null | Returns the current duplex mode of the network device. Returns either "full" or "half" if the device supports duplex modes or null if the duplex mode is unknown or unsupported.

#### getI18n(){string}

network.js, line 3004

  Get a long description string for the device.

  ##### Returns:

  Type | Description
  --- | ---
  string | Returns a string containing the type description and device name for non-WiFi devices or operation mode and SSID for WiFi ones.

#### getIP6Addrs(){Array.<string>}

network.js, line 2944

  Get the IPv6 addresses configured on the device.

  ##### Returns:

  Type | Description
  --- | ---
  Array.<string> | Returns an array of IPv6 address strings.

#### getIPAddrs(){Array.<string>}

network.js, line 2933

  Get the IPv4 addresses configured on the device.

  ##### Returns:

  Type | Description
  --- | ---
  Array.<string> | Returns an array of IPv4 address strings.

#### getMAC(){null|string}

network.js, line 2912

  Get the MAC address of the device.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the MAC address of the device or `null` if not applicable, e.g. for non-Ethernet tunnel devices.

#### getMTU(){number}

network.js, line 2923

  Get the MTU of the device.

  ##### Returns:

  Type | Description
  --- | ---
  number | Returns the MTU of the device.

#### getName(){string}

network.js, line 2901

  Get the name of the network device.

  ##### Returns:

  Type | Description
  --- | ---
  string | Returns the name of the device, e.g. `eth0` or `wlan0`.

#### getNetwork(){null|LuCI.network.Protocol}

network.js, line 3226

  Get the primary logical interface this device is assigned to.

  ##### Returns:

  Type | Description
  --- | ---
  null | LuCI.network.Protocol | Returns a `Network.Protocol` instance representing the logical interface this device is attached to or `null` if it is not assigned to any logical interface.

#### getNetworks(){Array.<LuCI.network.Protocol>}

network.js, line 3237

  Get the logical interfaces this device is assigned to.

  ##### Returns:

  Type | Description
  --- | ---
  Array.<LuCI.network.Protocol> | Returns an array of `Network.Protocol` instances representing the logical interfaces this device is assigned to.

#### getParent(){null|LuCI.network.Device}

network.js, line 3277

  Get the logical parent device of this device.

  In case of DSA switch ports, the parent device will be the DSA switch device itself, for VLAN devices, the parent refers to the base device etc.

  ##### Returns:

  Type | Description
  --- | ---
  null | LuCI.network.Device | Returns a `Network.Device` instance representing the parent device or `null` when this device has no parent, as it is the case for e.g. ordinary Ethernet interfaces.

#### getPorts(){null|Array.<LuCI.network.Device>}

network.js, line 3056

  Get the associated bridge ports of the device.

  ##### Returns:

  Type | Description
  --- | ---
  null | Array.<LuCI.network.Device> | Returns an array of `Network.Device` instances representing the ports (slave interfaces) of the bridge or `null` when this device isn't a Linux bridge.

#### getRXBytes(){number}

network.js, line 3150

  Get the amount of received bytes.

  ##### Returns:

  Type | Description
  --- | ---
  number | Returns the amount of bytes received by the network device.

#### getRXPackets(){number}

network.js, line 3172

  Get the amount of received packets.

  ##### Returns:

  Type | Description
  --- | ---
  number | Returns the amount of packets received by the network device.

#### getShortName(){string}

network.js, line 2990

  Get a short description string for the device.

  ##### Returns:

  Type | Description
  --- | ---
  string | Returns the device name for non-WiFi devices or a string containing the operation mode and SSID for WiFi devices.

#### getSpeed(){number|null}

network.js, line 3198

  Get the current link speed of the network device if available.

  ##### Returns:

  Type | Description
  --- | ---
  number | null | Returns the current speed of the network device in Mbps. If the device supports no Ethernet speed levels, null is returned. If the device supports Ethernet speeds but has no carrier, -1 is returned.

#### getTXBytes(){number}

network.js, line 3139

  Get the amount of transmitted bytes.

  ##### Returns:

  Type | Description
  --- | ---
  number | Returns the amount of bytes transmitted by the network device.

#### getTXPackets(){number}

network.js, line 3161

  Get the amount of transmitted packets.

  ##### Returns:

  Type | Description
  --- | ---
  number | Returns the amount of packets transmitted by the network device.

#### getType(){string}

network.js, line 2962

  Get the type of the device.

  ##### Returns:

  Type | Description
  --- | ---

  string

  Returns a string describing the type of the network device:
  - `alias` if it is an abstract alias device (`@` notation)
  - `wifi` if it is a wireless interface (e.g. `wlan0`)
  - `bridge` if it is a bridge device (e.g. `br-lan`)
  - `tunnel` if it is a tun or tap device (e.g. `tun0`)
  - `vlan` if it is a vlan device (e.g. `eth0.1`)
  - `switch` if it is a switch device (e.g.`eth1` connected to switch0)
  - `ethernet` for all other device types

#### getTypeI18n(){string}

network.js, line 3022

  Get a string describing the device type.

  ##### Returns:

  Type | Description
  --- | ---
  string | Returns a string describing the type, e.g. "Wireless Adapter" or "Bridge".

#### getWifiNetwork(){null|LuCI.network.WifiNetwork}

network.js, line 3261

  Get the related wireless network this device is related to.

  ##### Returns:

  Type | Description
  --- | ---
  null | LuCI.network.WifiNetwork | Returns a `Network.WifiNetwork` instance representing the wireless network corresponding to this network device or `null` if this device is not a wireless device.

#### isBridge(){boolean}

network.js, line 3118

  Checks whether this device is a Linux bridge.

  ##### Returns:

  Type | Description
  --- | ---
  boolean | Returns `true` when the network device is present and a Linux bridge, else `false`.

#### isBridgePort(){boolean}

network.js, line 3129

  Checks whether this device is part of a Linux bridge.

  ##### Returns:

  Type | Description
  --- | ---
  boolean | Returns `true` when this network device is part of a bridge, else `false`.

#### isUp(){boolean}

network.js, line 3102

  Checks whether this device is up.

  ##### Returns:

  Type | Description
  --- | ---
  boolean | Returns `true` when the associated device is running pr `false` when it is down or absent.