diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-07-31 20:01:11 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-08-14 22:58:15 +0200 |
commit | f7a3546989d09b3a780a337a2b4126848ad432df (patch) | |
tree | 536a5921b93c5bd03aadc01f6244e83c11260148 /modules/luci-base/htdocs/luci-static | |
parent | d528a96947f4f83cf121094c5570e4397fc02958 (diff) |
luci-base: network.js: add getL2Device(), getMTU() helpers
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/network.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/network.js b/modules/luci-base/htdocs/luci-static/resources/network.js index 61fdafb9a0..86e6ea5744 100644 --- a/modules/luci-base/htdocs/luci-static/resources/network.js +++ b/modules/luci-base/htdocs/luci-static/resources/network.js @@ -517,6 +517,15 @@ function initNetworkState() { s.bridges[devname] = b; } + + if (s.interfaces.hasOwnProperty(devname)) { + Object.assign(s.interfaces[devname], { + macaddr: dev.mac, + type: dev.type, + mtu: dev.mtu, + qlen: dev.qlen + }); + } } if (L.isObject(board.switch)) { @@ -1546,6 +1555,11 @@ Protocol = L.Class.extend({ } }, + getL2Device: function() { + var ifname = this._ubus('device'); + return (ifname != null ? L.network.instantiateDevice(ifname, this) : null); + }, + getDevices: function() { var rv = []; @@ -1647,10 +1661,17 @@ Device = L.Class.extend({ }, getMAC: function() { - var mac = this._ubus('macaddr'); + var mac = (this.dev != null ? this.dev.macaddr : null); + if (mac == null) + mac = this._ubus('macaddr'); + return mac ? mac.toUpperCase() : null; }, + getMTU: function() { + return this.dev ? this.dev.mtu : null; + }, + getIPAddrs: function() { var addrs = (this.dev != null ? this.dev.ipaddrs : null); return (Array.isArray(addrs) ? addrs : []); |