jsoninfo: add 'selectable' field to /sgw
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 3 Dec 2015 14:44:21 +0000 (15:44 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 3 Dec 2015 15:43:34 +0000 (16:43 +0100)
Like /gateways has (there it's called 'u')

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/jsoninfo/src/olsrd_jsoninfo.c

index 51eb19b..fc29b58 100644 (file)
@@ -445,8 +445,20 @@ static void sgw_ipvx(struct autobuf *abuf, bool ipv6) {
       abuf_json_mark_array_entry(true, abuf);
       {
         struct tc_entry* tc = olsr_lookup_tc_entry(&gw->originator);
+        bool selectable;
+        if (!ipv6) {
+          selectable = gw->ipv4 //
+              && ((olsr_cnf->ip_version == AF_INET) //
+                  || olsr_cnf->use_niit) //
+              && (olsr_cnf->smart_gw_allow_nat //
+                  || !gw->ipv4nat);
+        } else {
+          selectable = gw->ipv6 //
+              && (olsr_cnf->ip_version == AF_INET6);
+        }
 
         abuf_json_boolean(abuf, "selected", current_gw && (current_gw == gw));
+        abuf_json_boolean(abuf, "selectable", selectable);
         abuf_json_ip_address(abuf, "originator", &gw->originator);
         abuf_json_ip_address(abuf, "prefix", &gw->external_prefix.prefix);
         abuf_json_int(abuf, "prefixLen", gw->external_prefix.prefix_len);