[Olsr-dev] [PATCH v1 04/19] gateway: remove 'unused' v{4, 6}gw_choosen_external

Ferry Huberts (spam-protected)
Thu Aug 23 15:12:28 CEST 2012


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/jsoninfo/src/olsrd_jsoninfo.c |  4 ++--
 lib/pud/src/uplinkGateway.c       |  4 ++--
 lib/txtinfo/src/olsrd_txtinfo.c   |  4 ++--
 src/gateway.c                     | 30 +++++-------------------------
 src/gateway.h                     |  6 +++---
 src/gateway_default_handler.c     | 16 ++++++++--------
 6 files changed, 22 insertions(+), 42 deletions(-)

diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.c b/lib/jsoninfo/src/olsrd_jsoninfo.c
index 1deba79..e577d63 100644
--- a/lib/jsoninfo/src/olsrd_jsoninfo.c
+++ b/lib/jsoninfo/src/olsrd_jsoninfo.c
@@ -771,14 +771,14 @@ ipc_print_gateways(struct autobuf *abuf)
       continue;
     }
 
-    if (gw == olsr_get_ipv4_inet_gateway(&autoV4)) {
+    if (gw == olsr_get_ipv4_inet_gateway()) {
       v4 = autoV4 ? "auto" : "s";
     } else if (gw->ipv4 && (olsr_cnf->ip_version == AF_INET || olsr_cnf->use_niit)
                && (olsr_cnf->smart_gw_allow_nat || !gw->ipv4nat)) {
       v4 = "u";
     }
 
-    if (gw == olsr_get_ipv6_inet_gateway(&autoV6)) {
+    if (gw == olsr_get_ipv6_inet_gateway()) {
       v6 = autoV6 ? "auto" : "s";
     } else if (gw->ipv6 && olsr_cnf->ip_version == AF_INET6) {
       v6 = "u";
diff --git a/lib/pud/src/uplinkGateway.c b/lib/pud/src/uplinkGateway.c
index 9ff91f2..4a3296b 100644
--- a/lib/pud/src/uplinkGateway.c
+++ b/lib/pud/src/uplinkGateway.c
@@ -60,7 +60,7 @@ void getBestUplinkGateway(union olsr_ip_addr * bestGateway) {
 			continue;
 		}
 
-		if (gw == olsr_get_ipv4_inet_gateway(NULL)) {
+		if (gw == olsr_get_ipv4_inet_gateway()) {
 			eval4 = true;
 		} else if (gw->ipv4
 				&& (olsr_cnf->ip_version == AF_INET || olsr_cnf->use_niit)
@@ -68,7 +68,7 @@ void getBestUplinkGateway(union olsr_ip_addr * bestGateway) {
 			eval4 = true;
 		}
 
-		if (gw == olsr_get_ipv6_inet_gateway(NULL)) {
+		if (gw == olsr_get_ipv6_inet_gateway()) {
 			eval6 = true;
 		} else if (gw->ipv6 && olsr_cnf->ip_version == AF_INET6) {
 			eval6 = true;
diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
index 07fad39..56eb8ad 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ b/lib/txtinfo/src/olsrd_txtinfo.c
@@ -579,7 +579,7 @@ ipc_print_gateway(struct autobuf *abuf)
       continue;
     }
 
-    if (gw == olsr_get_ipv4_inet_gateway(&autoV4)) {
+    if (gw == olsr_get_ipv4_inet_gateway()) {
       v4 = autoV4 ? 'a' : 's';
     }
     else if (gw->ipv4 && (olsr_cnf->ip_version == AF_INET || olsr_cnf->use_niit)
@@ -587,7 +587,7 @@ ipc_print_gateway(struct autobuf *abuf)
       v4 = 'u';
     }
 
-    if (gw == olsr_get_ipv6_inet_gateway(&autoV6)) {
+    if (gw == olsr_get_ipv6_inet_gateway()) {
       v6 = autoV6 ? 'a' : 's';
     }
     else if (gw->ipv6 && olsr_cnf->ip_version == AF_INET6) {
diff --git a/src/gateway.c b/src/gateway.c
index 1e57ae6..127e9d8 100644
--- a/src/gateway.c
+++ b/src/gateway.c
@@ -43,18 +43,12 @@ static struct gateway_entry *current_ipv4_gw;
 /** the tunnel of the current IPv4  gateway */
 static struct olsr_iptunnel_entry *v4gw_tunnel;
 
-/** true if a change of the IPv4 gateway was triggered directly by a user */
-static bool v4gw_choosen_external;
-
 /** the current IPv6 gateway */
 static struct gateway_entry *current_ipv6_gw;
 
 /** the tunnel of the current IPv6  gateway */
 static struct olsr_iptunnel_entry *v6gw_tunnel;
 
-/** true if a change of the IPv6 gateway was triggered directly by a user */
-static bool v6gw_choosen_external;
-
 /*
  * Helper Functions
  */
@@ -181,11 +175,9 @@ int olsr_init_gateways(void) {
 
   current_ipv4_gw = NULL;
   v4gw_tunnel = NULL;
-  v4gw_choosen_external = false;
 
   current_ipv6_gw = NULL;
   v6gw_tunnel = NULL;
-  v6gw_choosen_external = false;
 
   gw_handler = NULL;
 
@@ -506,11 +498,9 @@ void olsr_set_inetgw_handler(struct olsr_gw_handler *h) {
  * @param originator ip address of the node with the new gateway
  * @param ipv4 set ipv4 gateway
  * @param ipv6 set ipv6 gateway
- * @param external true if change was triggered directly by an user,
- *   false if triggered by automatic lookup.
  * @return true if an error happened, false otherwise
  */
-bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6, bool external) {
+bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6) {
   struct gateway_entry *entry;
   struct gateway_entry *oldV4 = current_ipv4_gw;
   struct gateway_entry *oldV6 = current_ipv6_gw;
@@ -543,7 +533,6 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6,
   if (oldV4 != current_ipv4_gw) {
     if ((v4gw_tunnel = olsr_os_add_ipip_tunnel(&current_ipv4_gw->originator, true)) != NULL) {
       olsr_os_inetgw_tunnel_route(v4gw_tunnel->if_index, true, true);
-      v4gw_choosen_external = external;
     } else {
       /* adding the tunnel failed, we try again in the next cycle */
       current_ipv4_gw = NULL;
@@ -556,7 +545,6 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6,
   if (oldV6 != current_ipv6_gw) {
     if ((v6gw_tunnel = olsr_os_add_ipip_tunnel(&current_ipv6_gw->originator, false)) != NULL) {
       olsr_os_inetgw_tunnel_route(v6gw_tunnel->if_index, false, true);
-      v6gw_choosen_external = external;
     } else {
       /* adding the tunnel failed, we try again in the next cycle */
       current_ipv6_gw = NULL;
@@ -570,25 +558,17 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6,
 
 /**
  * @return a pointer to the gateway_entry of the current ipv4 internet gw or
- * NULL if not set. Also updates *ext (if not NULL) to indicate whether or not
- * the gw was chosen externally.
+ * NULL if not set.
  */
-struct gateway_entry *olsr_get_ipv4_inet_gateway(bool *ext) {
-  if (ext) {
-    *ext = v4gw_choosen_external;
-  }
+struct gateway_entry *olsr_get_ipv4_inet_gateway(void) {
   return current_ipv4_gw;
 }
 
 /**
  * @return a pointer to the gateway_entry of the current ipv4 internet gw or
- * NULL if not set. Also updates *ext (if not NULL) to indicate whether or not
- * the gw was chosen externally.
+ * NULL if not set.
  */
-struct gateway_entry *olsr_get_ipv6_inet_gateway(bool *ext) {
-  if (ext) {
-    *ext = v6gw_choosen_external;
-  }
+struct gateway_entry *olsr_get_ipv6_inet_gateway(void) {
   return current_ipv6_gw;
 }
 
diff --git a/src/gateway.h b/src/gateway.h
index 5b84149..91e8d45 100644
--- a/src/gateway.h
+++ b/src/gateway.h
@@ -128,8 +128,8 @@ void olsr_trigger_gatewayloss_check(void);
  */
 
 void olsr_set_inetgw_handler(struct olsr_gw_handler *l);
-bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6, bool external);
-struct gateway_entry *olsr_get_ipv4_inet_gateway(bool *);
-struct gateway_entry *olsr_get_ipv6_inet_gateway(bool *);
+bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6);
+struct gateway_entry *olsr_get_ipv4_inet_gateway(void);
+struct gateway_entry *olsr_get_ipv6_inet_gateway(void);
 
 #endif /* GATEWAY_H_ */
diff --git a/src/gateway_default_handler.c b/src/gateway_default_handler.c
index c729e5a..35462a7 100644
--- a/src/gateway_default_handler.c
+++ b/src/gateway_default_handler.c
@@ -166,7 +166,7 @@ static void gw_default_choose_gateway(void) {
   if (olsr_cnf->smart_gw_thresh) {
     /* determine the path cost thresholds */
 
-    gw = olsr_get_ipv4_inet_gateway(NULL);
+    gw = olsr_get_ipv4_inet_gateway();
     if (gw) {
       tc = olsr_lookup_tc_entry(&gw->originator);
       if (tc) {
@@ -175,7 +175,7 @@ static void gw_default_choose_gateway(void) {
         eval_cost_ipv4_threshold = true;
       }
     }
-    gw = olsr_get_ipv6_inet_gateway(NULL);
+    gw = olsr_get_ipv6_inet_gateway();
     if (gw) {
       tc = olsr_lookup_tc_entry(&gw->originator);
       if (tc) {
@@ -229,11 +229,11 @@ static void gw_default_choose_gateway(void) {
 
   if (inet_ipv4) {
     /* we are dealing with an IPv4 or dual stack gateway */
-    olsr_set_inet_gateway(&inet_ipv4->originator, true, dual, false);
+    olsr_set_inet_gateway(&inet_ipv4->originator, true, dual);
   }
   if (inet_ipv6 && !dual) {
     /* we are dealing with an IPv6-only gateway */
-    olsr_set_inet_gateway(&inet_ipv6->originator, false, true, false);
+    olsr_set_inet_gateway(&inet_ipv6->originator, false, true);
   }
 
   if ((olsr_cnf->smart_gw_thresh == 0) && gw_def_finished_ipv4 && gw_def_finished_ipv6) {
@@ -355,9 +355,9 @@ static void gw_default_choosegw_handler(bool ipv4, bool ipv6) {
  * @param gw the gateway entry
  */
 static void gw_default_update_handler(struct gateway_entry *gw) {
-  bool v4changed = gw && (gw == olsr_get_ipv4_inet_gateway(NULL))
+  bool v4changed = gw && (gw == olsr_get_ipv4_inet_gateway())
       && (!gw->ipv4 || (gw->ipv4nat && !olsr_cnf->smart_gw_allow_nat));
-  bool v6changed = gw && (gw == olsr_get_ipv6_inet_gateway(NULL)) && !gw->ipv6;
+  bool v6changed = gw && (gw == olsr_get_ipv6_inet_gateway()) && !gw->ipv6;
 
   if (v4changed || v6changed) {
     olsr_gw_default_lookup_gateway(v4changed, v6changed);
@@ -370,8 +370,8 @@ static void gw_default_update_handler(struct gateway_entry *gw) {
  * @param gw the gateway entry
  */
 static void gw_default_delete_handler(struct gateway_entry *gw) {
-  bool isv4 = gw && (gw == olsr_get_ipv4_inet_gateway(NULL));
-  bool isv6 = gw && (gw == olsr_get_ipv6_inet_gateway(NULL));
+  bool isv4 = gw && (gw == olsr_get_ipv4_inet_gateway());
+  bool isv6 = gw && (gw == olsr_get_ipv6_inet_gateway());
 
   if (isv4 || isv6) {
     olsr_gw_default_lookup_gateway(isv4, isv6);
-- 
1.7.11.4





More information about the Olsr-dev mailing list