luci-base: network; implement getIP6Prefixes()
authorPaul Donald <newtwen+github@gmail.com>
Tue, 5 Nov 2024 17:33:05 +0000 (18:33 +0100)
committerPaul Donald <newtwen+github@gmail.com>
Tue, 5 Nov 2024 17:33:29 +0000 (18:33 +0100)
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
modules/luci-base/htdocs/luci-static/resources/network.js

index 3bd344a61ebf6373dd45a6bbf9cfebe15b18f76b..d9a0ef24c068a586feb1bd467822f3533d6b893b 100644 (file)
@@ -2387,6 +2387,25 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
                return null;
        },
 
+       /**
+        * Query the routed IPv6 prefixes associated with the logical interface.
+        *
+        * @returns {null|string[]}
+        * Returns an array of the routed IPv6 prefixes registered by the remote 
+        * protocol handler or `null` if no prefixes are present.
+        */
+       getIP6Prefixes: function() {
+               var prefixes = this._ubus('ipv6-prefix');
+               var rv = [];
+
+               if (Array.isArray(prefixes))
+                       for (var i = 0; i < prefixes.length; i++)
+                               if (L.isObject(prefixes[i]))
+                                       rv.push('%s/%d'.format(prefixes[i].address, prefixes[i].mask));
+
+               return rv.length > 0 ? rv: null;
+       },
+
        /**
         * Query interface error messages published in `ubus` runtime state.
         *