txtinfo: sgw: show entries without tc too
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 24 Nov 2015 11:18:09 +0000 (12:18 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 24 Nov 2015 11:19:40 +0000 (12:19 +0100)
The tc is only used for the path cost, so simply show that as
ROUTE_COST_BROKEN when there is no tc.

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

index 9070b1f..22732f5 100644 (file)
@@ -567,11 +567,6 @@ static void sgw_ipvx(struct autobuf *abuf, bool ipv6, const char * fmth, const c
         continue;
       }
 
-      tc = olsr_lookup_tc_entry(&gw->originator);
-      if (!tc) {
-        continue;
-      }
-
       selected = current_gw && (current_gw == gw);
       originator = olsr_ip_to_string(&originatorStr, &gw->originator);
       prefixIPStr = olsr_ip_to_string(&prefixIpStr, &gw->external_prefix.prefix);
@@ -585,13 +580,15 @@ static void sgw_ipvx(struct autobuf *abuf, bool ipv6, const char * fmth, const c
         char prefix[strlen(prefixIPStr) + 1 + strlen(prefixMASKStr) + 1];
         snprintf(prefix, sizeof(prefix), "%s/%s", prefixIPStr, prefixMASKStr);
 
+        tc = olsr_lookup_tc_entry(&gw->originator);
+
         abuf_appendf(abuf, fmtv, //
             selected ? "*" : " ", // selected
             originator, // Originator
             prefix, // Prefix IP / Prefix Mask
             gw->uplink, // Uplink
             gw->downlink, // Downlink
-            tc->path_cost, // PathCost
+            !tc ? ROUTE_COST_BROKEN : tc->path_cost, // PathCost
             gw->ipv4 ? "Y" : "N", // IPv4
             gw->ipv4nat ? "Y" : "N", // IPv4-NAT
             gw->ipv6 ? "Y" : "N", // IPv6