diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-07-07 20:12:42 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-07 20:12:42 +0200 |
commit | 91afb6fae2527174f264c9008569783a79b49dae (patch) | |
tree | 11f8faf598a9dc05bc9429c4c4b57b1c94d3a7d8 /modules | |
parent | f970c485cfb2571dd6d4ee6a1ad36958f1410b6a (diff) |
luci-base: network.js: dynamically calculate IPv4 netmasks
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/network.js | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/network.js b/modules/luci-base/htdocs/luci-static/resources/network.js index 1f66c6ff9..19640604e 100644 --- a/modules/luci-base/htdocs/luci-static/resources/network.js +++ b/modules/luci-base/htdocs/luci-static/resources/network.js @@ -1253,43 +1253,8 @@ Protocol = L.Class.extend({ getNetmask: function() { var addrs = this._ubus('ipv4-address'); - if (Array.isArray(addrs) && addrs.length) { - switch (addrs[0].mask) { - case 0: return '0.0.0.0'; - case 1: return '128.0.0.0'; - case 2: return '192.0.0.0'; - case 3: return '224.0.0.0'; - case 4: return '240.0.0.0'; - case 5: return '248.0.0.0'; - case 6: return '252.0.0.0'; - case 7: return '254.0.0.0'; - case 8: return '255.0.0.0'; - case 9: return '255.128.0.0'; - case 10: return '255.192.0.0'; - case 11: return '255.224.0.0'; - case 12: return '255.240.0.0'; - case 13: return '255.248.0.0'; - case 14: return '255.252.0.0'; - case 15: return '255.254.0.0'; - case 16: return '255.255.0.0'; - case 17: return '255.255.128.0'; - case 18: return '255.255.192.0'; - case 19: return '255.255.224.0'; - case 20: return '255.255.240.0'; - case 21: return '255.255.248.0'; - case 22: return '255.255.252.0'; - case 23: return '255.255.254.0'; - case 24: return '255.255.255.0'; - case 25: return '255.255.255.128'; - case 26: return '255.255.255.192'; - case 27: return '255.255.255.224'; - case 28: return '255.255.255.240'; - case 29: return '255.255.255.248'; - case 30: return '255.255.255.252'; - case 31: return '255.255.255.254'; - case 32: return '255.255.255.255'; - } - } + if (Array.isArray(addrs) && addrs.length) + return prefixToMask(addrs[0].mask, false); }, getGatewayAddr: function() { |