Added some sanity checking on route addittion and deletion functions
authorAndreas Tonnesen <andreto@olsr.org>
Mon, 28 Feb 2005 09:52:13 +0000 (09:52 +0000)
committerAndreas Tonnesen <andreto@olsr.org>
Mon, 28 Feb 2005 09:52:13 +0000 (09:52 +0000)
src/defs.h
src/process_routes.c

index 3b91d92..096af73 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: defs.h,v 1.40 2005/02/27 18:39:43 kattemat Exp $
+ * $Id: defs.h,v 1.41 2005/02/28 09:52:13 kattemat Exp $
  */
 
 #ifndef OLSR_PLUGIN
@@ -67,7 +67,7 @@
 #define OLSRD_CONF_FILE_NAME "olsrd.conf"
 #define OLSRD_GLOBAL_CONF_FILE "/etc/" OLSRD_CONF_FILE_NAME
 
-#define        HOPCNT_MAX              16      /* maximum hops number */
+#define        HOPCNT_MAX              32      /* maximum hops number */
 #define        MAXMESSAGESIZE          1500    /* max broadcast size */
 #define UDP_IP_HDRSIZE          28
 #define MAX_IFS                 16
index daca109..a6966a1 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: process_routes.c,v 1.22 2005/02/27 18:39:43 kattemat Exp $
+ * $Id: process_routes.c,v 1.23 2005/02/28 09:52:13 kattemat Exp $
  */
 
 
@@ -44,6 +44,7 @@
 #include "olsr.h"
 #include "log.h"
 #include "kernel_routes.h"
+#include <assert.h>
 
 #ifdef WIN32
 #undef strerror
@@ -364,10 +365,15 @@ olsr_delete_routes_from_kernel(struct destination_n *delete_kernel_list)
                
        }
       if((metric_counter == 1) && !last_run)
-       last_run = OLSR_TRUE;
+        {
+         last_run = OLSR_TRUE;
+        }
       else
-       metric_counter--;
-      
+        {
+         metric_counter--;
+        }
+
+      assert(metric_counter);
     }
  
 }
@@ -443,9 +449,15 @@ olsr_add_routes_in_kernel(struct destination_n *add_kernel_list)
                
        }
       if(first_run)
-       first_run = OLSR_FALSE;
+        {
+         first_run = OLSR_FALSE;
+        }
       else
-       metric_counter++;
+        {
+         metric_counter++;
+        }
+
+      assert(metric_counter < HOPCNT_MAX);
     }
        
 }