sgw: add isEgressSelected function
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 29 Mar 2016 07:47:07 +0000 (09:47 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 29 Mar 2016 07:47:57 +0000 (09:47 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/gateway.c
src/gateway.h

index 560b73f..4a56e61 100644 (file)
@@ -2089,6 +2089,10 @@ static void printDate(FILE * f) {
   fprintf(f, "%s", buffer);
 }
 
+bool isEgressSelected(struct sgw_egress_if * egress_if) {
+  return bestOverallLink.valid && !bestOverallLink.isOlsr && (bestOverallLink.link.egress == egress_if);
+}
+
 /**
  * Write multi-smart-gateway status file
  *
@@ -2140,10 +2144,9 @@ static void writeProgramStatusFile(enum sgw_multi_change_phase phase) {
     while (egress_if) {
       struct ipaddr_str gwStr;
       const char * gw = !egress_if->bwCurrent.gatewaySet ? IPNONE : olsr_ip_to_string(&gwStr, &egress_if->bwCurrent.gateway);
-      bool selected = bestOverallLink.valid && !bestOverallLink.isOlsr && (bestOverallLink.link.egress == egress_if);
 
       fprintf(fp, fmt_values, //
-          selected ? "*" : " ", //selected
+          isEgressSelected(egress_if) ? "*" : " ", //selected
           IPLOCAL, // Originator
           MASKLOCAL, // Prefix
           egress_if->bwCurrent.egressUk, // Uplink
index f547896..6101f03 100644 (file)
@@ -15,6 +15,7 @@
 #include "scheduler.h"
 #include "gateway_list.h"
 #include <net/if.h>
+#include <stdbool.h>
 
 /** used to signal to olsr_delete_gateway_entry to force deletion */
 #define FORCE_DELETE_GW_ENTRY 255
@@ -215,5 +216,6 @@ struct gateway_entry *olsr_get_inet_gateway(bool ipv6);
  */
 
 void doRoutesMultiGw(bool egressChanged, bool olsrChanged, enum sgw_multi_change_phase phase);
+bool isEgressSelected(struct sgw_egress_if * egress_if);
 
 #endif /* GATEWAY_H_ */