Export smartgw netmask refresh as function
authorHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 17 Mar 2010 07:00:33 +0000 (08:00 +0100)
committerHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 17 Mar 2010 07:00:33 +0000 (08:00 +0100)
src/gateway.c
src/gateway.h

index 410b560..f528586 100644 (file)
@@ -78,7 +78,6 @@ serialize_gw_speed(uint32_t speed) {
  */
 int
 olsr_init_gateways(void) {
-  uint8_t *ip;
   gw_mem_cookie = olsr_alloc_cookie("Gateway cookie", OLSR_COOKIE_TYPE_MEMORY);
   olsr_cookie_set_memory_size(gw_mem_cookie, sizeof(struct gateway_entry));
 
@@ -89,6 +88,21 @@ olsr_init_gateways(void) {
   v4gw_tunnel = NULL;
   v6gw_tunnel = NULL;
 
+  refresh_smartgw_netmask();
+
+  if (olsr_os_init_iptunnel()) {
+    return 1;
+  }
+  /*
+   * initialize default gateway handler,
+   * can be overwritten with olsr_set_inetgw_handler
+   */
+  olsr_gw_default_init();
+  return 0;
+}
+
+void refresh_smartgw_netmask(void) {
+  uint8_t *ip;
   memset(&smart_gateway_netmask, 0, sizeof(smart_gateway_netmask));
 
   if (olsr_cnf->smart_gw_active) {
@@ -108,15 +122,6 @@ olsr_init_gateways(void) {
       memcpy(&ip[GW_HNA_V6PREFIX], &olsr_cnf->smart_gw_prefix.prefix, 8);
     }
   }
-  if (olsr_os_init_iptunnel()) {
-    return 1;
-  }
-  /*
-   * initialize default gateway handler,
-   * can be overwritten with olsr_set_inetgw_handler
-   */
-  olsr_gw_default_init();
-  return 0;
 }
 
 /**
index 9f554f1..727b3bd 100644 (file)
@@ -67,6 +67,7 @@ extern struct avl_tree gateway_tree;
 
 int olsr_init_gateways(void);
 void olsr_cleanup_gateways(void);
+void refresh_smartgw_netmask(void);
 void olsr_trigger_inetgw_startup(void);
 int olsr_trigger_inetgw_selection(bool ipv4, bool ipv6);
 void olsr_trigger_gatewayloss_check(void);