[Olsr-cvs] olsrd-current/src routing_table.h, 1.24, 1.25 routing_table.c, 1.33, 1.34 process_routes.h, 1.12, 1.13 process_routes.c, 1.38, 1.39 kernel_routes.h, 1.10, 1.11

Bernd Petrovitsch (spam-protected)
Mon Nov 12 00:10:27 CET 2007


Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10534/src

Modified Files:
	routing_table.h routing_table.c process_routes.h 
	process_routes.c kernel_routes.h 
Log Message:
* const'ified olsr_ioctl_{add,del}_route{,6}()
  There are probably a few "const" missing for win32 and BSD.
* const'ified moer parameters in many more functions in the .h and
  .c files
* init-functions with constant or ignored return values are "void"
* created a typedef fro the callback in "struct export_route_entry"
  and using it!
* moved the initilaization of the {add,chg,del}_kernel_list variables
  into process_routes.c. So they are now "static" there.
* olsr_export_{add,del}_route{,6} are now static in process_routes.c
  since they are not used elsewhere.
* olsr_addroute_add_function() and olsr_deldroute_add_function() were
  almost identical - made one function out of it.
  Same for olsr_addroute_del_function() and olsr_deldroute_del_function().
* factored out common code
* fixed the sort order in avl_comp_ipv4_prefix(): We compare now the IPv4
  values in host byte order (and not network byte order). So the route
  list in the e.g. httpinfo plugin is now nicely sorted.


Index: kernel_routes.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/kernel_routes.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** kernel_routes.h	17 Sep 2007 22:55:40 -0000	1.10
--- kernel_routes.h	11 Nov 2007 23:10:25 -0000	1.11
***************
*** 47,60 ****
  
  int
! olsr_ioctl_add_route(struct rt_entry *);
  
  int
! olsr_ioctl_add_route6(struct rt_entry *);
  
  int
! olsr_ioctl_del_route(struct rt_entry *);
  
  int
! olsr_ioctl_del_route6(struct rt_entry *);
  
  #endif
--- 47,60 ----
  
  int
! olsr_ioctl_add_route(const struct rt_entry *);
  
  int
! olsr_ioctl_add_route6(const struct rt_entry *);
  
  int
! olsr_ioctl_del_route(const struct rt_entry *);
  
  int
! olsr_ioctl_del_route6(const struct rt_entry *);
  
  #endif

Index: routing_table.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/routing_table.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** routing_table.h	8 Nov 2007 22:47:41 -0000	1.24
--- routing_table.h	11 Nov 2007 23:10:24 -0000	1.25
***************
*** 145,149 ****
  extern unsigned int routingtree_version;
  
! int
  olsr_init_routing_table(void);
  
--- 145,149 ----
  extern unsigned int routingtree_version;
  
! void
  olsr_init_routing_table(void);
  
***************
*** 154,164 ****
  
  void olsr_rt_best(struct rt_entry *);
! olsr_bool olsr_nh_change(struct rt_nexthop *, struct rt_nexthop *);
! olsr_bool olsr_cmp_rt(struct rt_entry *, struct rt_entry *);
  
  void olsr_calculate_hna_routes(void);
! char *olsr_rt_to_string(struct rt_entry *);
! char *olsr_rtp_to_string(struct rt_path *);
! void olsr_print_routing_table(struct avl_tree *);
  
  const struct rt_nexthop * olsr_get_nh(const struct rt_entry *);
--- 154,164 ----
  
  void olsr_rt_best(struct rt_entry *);
! olsr_bool olsr_nh_change(const struct rt_nexthop *, const struct rt_nexthop *);
! olsr_bool olsr_cmp_rt(const struct rt_entry *, const struct rt_entry *);
  
  void olsr_calculate_hna_routes(void);
! char *olsr_rt_to_string(const struct rt_entry *);
! char *olsr_rtp_to_string(const struct rt_path *);
! void olsr_print_routing_table(const struct avl_tree *);
  
  const struct rt_nexthop * olsr_get_nh(const struct rt_entry *);

Index: process_routes.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** process_routes.c	8 Nov 2007 22:47:41 -0000	1.38
--- process_routes.c	11 Nov 2007 23:10:25 -0000	1.39
***************
*** 59,63 ****
  {
    olsr_u8_t type;       /* AF_INET/AF_INET6 */
!   int (*function)(struct rt_entry*);
    struct export_route_entry *next;
  };
--- 59,63 ----
  {
    olsr_u8_t type;       /* AF_INET/AF_INET6 */
!   export_route_function function;
    struct export_route_entry *next;
  };
***************
*** 67,73 ****
  static struct export_route_entry *del_routes;
  
! struct list_node add_kernel_list;
! struct list_node chg_kernel_list;
! struct list_node del_kernel_list;
  
  /**
--- 67,74 ----
  static struct export_route_entry *del_routes;
  
! static struct list_node add_kernel_list;
! static struct list_node chg_kernel_list;
! static struct list_node del_kernel_list;
! 
  
  /**
***************
*** 81,87 ****
  {
    const struct rt_nexthop *nh;
!   olsr_u8_t flags;
! 
!   flags = (RTF_UP);
  
    if (rt->rt_dst.prefix_len == olsr_cnf->maxplen) {
--- 82,86 ----
  {
    const struct rt_nexthop *nh;
!   olsr_u8_t flags = RTF_UP;
  
    if (rt->rt_dst.prefix_len == olsr_cnf->maxplen) {
***************
*** 98,238 ****
  }
  
! void 
! olsr_addroute_add_function(int (*function)(struct rt_entry*), olsr_u8_t type) 
  {
!   struct export_route_entry *tmp;
!   tmp = olsr_malloc(sizeof *tmp, "olsr_addroute_add_function");
    tmp->type = type;
    tmp->function = function;
!   tmp->next = add_routes;
!   add_routes = tmp;
  }
  
  void 
! olsr_delroute_add_function(int (*function) (struct rt_entry*), olsr_u8_t type)
  {
!   struct export_route_entry *tmp;
!   tmp = olsr_malloc(sizeof *tmp, "olsr_delroute_add_function");
!   tmp->type = type;
!   tmp->function = function;
!   tmp->next = del_routes;
!   del_routes = tmp;
  }
  
! 
! int 
! olsr_addroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type)
  {
!   struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */; 
!   tmp = add_routes;
!   while (tmp) 
!     {
!       if (function == tmp->function && type == tmp->type) 
! 	{
! 	  if (tmp == add_routes) 
! 	    {
! 	      add_routes = add_routes->next;
! 	      free (tmp);
! 	      return 1;
! 	    }
! 	  else 
! 	    {
! 	      prev->next = tmp->next;
! 	      free (tmp);
! 	      return 1;
! 	    }
! 	}
!       prev = tmp;
!       tmp = tmp->next;
!     }
!   return 0;
  }
  
! int
! olsr_delroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type)
  {
!   struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */;
!   tmp = del_routes;
!   while (tmp) 
!     {
!       if (function == tmp->function && type == tmp->type) 
! 	{
! 	  if (tmp == del_routes) 
! 	    {
! 	      del_routes = del_routes->next;
! 	      free (tmp);
! 	      return 1;
! 	    }
! 	  else 
! 	    {
! 	      prev->next = tmp->next;
! 	      free (tmp);
! 	      return 1; 
! 	    }
! 	}
!       prev = tmp;
!       tmp = tmp->next;
      }
    return 0;
  }
  
! void 
! olsr_init_export_route(void)
  {
!   olsr_addroute_add_function(&olsr_ioctl_add_route, AF_INET);
!   olsr_addroute_add_function(&olsr_ioctl_add_route6, AF_INET6);
!   olsr_delroute_add_function(&olsr_ioctl_del_route, AF_INET);
!   olsr_delroute_add_function(&olsr_ioctl_del_route6, AF_INET6);
  }
  
  int
! olsr_export_add_route (struct rt_entry *rt) 
  {
!   int retval = 0;
!   struct export_route_entry *tmp;
!   for (tmp = add_routes; tmp; tmp = tmp->next)
!     {
!       if (tmp->type == AF_INET)
! 	retval = tmp->function(rt);
!     }
!   return retval;
  }
  
- int
- olsr_export_add_route6 (struct rt_entry *rt) 
- {
-   int retval = 0;
-   struct export_route_entry *tmp;
-   for (tmp = add_routes; tmp; tmp = tmp->next)
-     {
-       if (tmp->type == AF_INET6)
- 	retval = tmp->function(rt);
-     }
-   return retval;
- }
  
! int
! olsr_export_del_route (struct rt_entry *rt) 
  {
!   int retval = 0;
!   struct export_route_entry *tmp;
!   for (tmp = del_routes; tmp; tmp = tmp->next)
!     {
!       if (tmp->type == AF_INET)
! 	retval = tmp->function(rt);
!     }
!   return retval;
  }
  
! int
! olsr_export_del_route6 (struct rt_entry *rt) 
  {
    int retval = 0;
    struct export_route_entry *tmp;
!   for (tmp = del_routes; tmp; tmp = tmp->next)
!     {
!       if (tmp->type == AF_INET6)
! 	retval = tmp->function(rt);
      }
    return retval;
  }
--- 97,179 ----
  }
  
! 
! static void 
! olsr_route_add_function(struct export_route_entry **routes, export_route_function function, olsr_u8_t type)
  {
!   struct export_route_entry *tmp = olsr_malloc(sizeof(*tmp), __func__);
    tmp->type = type;
    tmp->function = function;
!   tmp->next = *routes;
!   *routes = tmp;
  }
  
  void 
! olsr_addroute_add_function(export_route_function function, olsr_u8_t type)
  {
!   olsr_route_add_function(&add_routes, function, type);
  }
  
! void 
! olsr_delroute_add_function(export_route_function function, olsr_u8_t type)
  {
!   olsr_route_add_function(&del_routes, function, type);
  }
  
! 
! static int
! olsr_route_remove_function(struct export_route_entry **routes, export_route_function function, olsr_u8_t type)
  {
!   struct export_route_entry *tmp, *prev;
!   for (tmp = *routes, prev = NULL; tmp != NULL; prev = tmp, tmp = tmp->next) {
!     if (function == tmp->function && type == tmp->type) {
!       if (prev == NULL) { /* i.e. tmp == *routes */
!         *routes = (*routes)->next;
!       } else {
!         prev->next = tmp->next;
!       }
!       free(tmp);
!       return 1; 
      }
+   }
    return 0;
  }
  
! int 
! olsr_addroute_remove_function(export_route_function function, olsr_u8_t type)
  {
!   return olsr_route_remove_function(&add_routes, function, type);
  }
  
  int
! olsr_delroute_remove_function(export_route_function function, olsr_u8_t type)
  {
!   return olsr_route_remove_function(&del_routes, function, type);
  }
  
  
! void 
! olsr_init_export_route(void)
  {
!   /* the add/chg/del kernel queues */
!   list_head_init(&add_kernel_list);
!   list_head_init(&chg_kernel_list);
!   list_head_init(&del_kernel_list);
! 
!   olsr_addroute_add_function(&olsr_ioctl_add_route, AF_INET);
!   olsr_addroute_add_function(&olsr_ioctl_add_route6, AF_INET6);
!   olsr_delroute_add_function(&olsr_ioctl_del_route, AF_INET);
!   olsr_delroute_add_function(&olsr_ioctl_del_route6, AF_INET6);
  }
  
! static int
! olsr_export_route(struct export_route_entry *routes, const struct rt_entry *rt, int ip_version)
  {
    int retval = 0;
    struct export_route_entry *tmp;
!   for (tmp = routes; tmp != NULL; tmp = tmp->next) {
!     if (tmp->type == ip_version) {
!       retval = tmp->function(rt);
      }
+   }
    return retval;
  }
***************
*** 247,251 ****
   *@return 1
   */
! int
  olsr_delete_all_kernel_routes(void)
  { 
--- 188,192 ----
   *@return 1
   */
! void
  olsr_delete_all_kernel_routes(void)
  { 
***************
*** 254,259 ****
    olsr_bump_routingtree_version();
    olsr_update_kernel_routes();
- 
-   return 1;
  }
  
--- 195,198 ----
***************
*** 294,306 ****
  olsr_delete_kernel_route(struct rt_entry *rt)
  {
-   olsr_16_t error;		  
- 
    if(!olsr_cnf->host_emul) {
! 
!     if(olsr_cnf->ip_version == AF_INET) {
!       error = olsr_export_del_route(rt);
!     } else {
!       error = olsr_export_del_route6(rt);
!     }
  
      if(error < 0) {
--- 233,238 ----
  olsr_delete_kernel_route(struct rt_entry *rt)
  {
    if(!olsr_cnf->host_emul) {
!     olsr_16_t error = olsr_export_route(del_routes, rt, olsr_cnf->ip_version);
  
      if(error < 0) {
***************
*** 324,337 ****
  olsr_add_kernel_route(struct rt_entry *rt)
  {
-   olsr_16_t error;		  
  
    if(!olsr_cnf->host_emul) {
  
-     if(olsr_cnf->ip_version == AF_INET) {
-       error = olsr_export_add_route(rt);
-     } else {
-       error = olsr_export_add_route6(rt);
-     }
-     
      if(error < 0) {
        const char * const err_msg = strerror(errno);
--- 256,263 ----
  olsr_add_kernel_route(struct rt_entry *rt)
  {
  
    if(!olsr_cnf->host_emul) {
+     olsr_16_t error = olsr_export_route(add_routes, rt, olsr_cnf->ip_version);
  
      if(error < 0) {
        const char * const err_msg = strerror(errno);
***************
*** 360,368 ****
  olsr_add_kernel_routes(struct list_node *head_node)
  {
-   struct rt_entry *rt;
- 
    while (!list_is_empty(head_node)) {
! 
!     rt = head_node->next->data;
      olsr_add_kernel_route(rt);
  
--- 286,291 ----
  olsr_add_kernel_routes(struct list_node *head_node)
  {
    while (!list_is_empty(head_node)) {
!     struct rt_entry *rt = head_node->next->data;
      olsr_add_kernel_route(rt);
  
***************
*** 381,385 ****
  olsr_chg_kernel_routes(struct list_node *head_node)
  {
-   struct rt_entry *rt;
    struct list_node *node;
  
--- 304,307 ----
***************
*** 394,399 ****
     */
    for (node = head_node->prev; head_node != node; node = node->prev) {
! 
!     rt = node->data;
      olsr_delete_kernel_route(rt);
    }
--- 316,320 ----
     */
    for (node = head_node->prev; head_node != node; node = node->prev) {
!     struct rt_entry *rt = node->data;
      olsr_delete_kernel_route(rt);
    }
***************
*** 405,410 ****
     */
    while (!list_is_empty(head_node)) {
! 
!     rt = head_node->next->data;
      olsr_add_kernel_route(rt);
  
--- 326,330 ----
     */
    while (!list_is_empty(head_node)) {
!     struct rt_entry *rt = head_node->next->data;
      olsr_add_kernel_route(rt);
  
***************
*** 423,431 ****
  olsr_del_kernel_routes(struct list_node *head_node)
  {
-   struct rt_entry *rt;
- 
    while (!list_is_empty(head_node)) {
! 
!     rt = head_node->prev->data;
      olsr_delete_kernel_route(rt);
  
--- 343,348 ----
  olsr_del_kernel_routes(struct list_node *head_node)
  {
    while (!list_is_empty(head_node)) {
!     struct rt_entry *rt = head_node->prev->data;
      olsr_delete_kernel_route(rt);
  
***************
*** 447,451 ****
  
    for (rtp_tree_node = avl_walk_first(&rt->rt_path_tree);
!        rtp_tree_node;
         rtp_tree_node = next_rtp_tree_node) {
  
--- 364,368 ----
  
    for (rtp_tree_node = avl_walk_first(&rt->rt_path_tree);
!        rtp_tree_node != NULL;
         rtp_tree_node = next_rtp_tree_node) {
  

Index: process_routes.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** process_routes.h	16 Sep 2007 21:14:25 -0000	1.12
--- process_routes.h	11 Nov 2007 23:10:25 -0000	1.13
***************
*** 40,54 ****
   */
  
- #include "routing_table.h"
-  
- 
  #ifndef _OLSR_PROCESS_RT
  #define _OLSR_PROCESS_RT
  
  #include <sys/ioctl.h>
  
! extern struct list_node add_kernel_list;
! extern struct list_node chg_kernel_list;
! extern struct list_node del_kernel_list;
  
  void
--- 40,50 ----
   */
  
  #ifndef _OLSR_PROCESS_RT
  #define _OLSR_PROCESS_RT
  
+ #include "routing_table.h"
  #include <sys/ioctl.h>
  
! typedef int (*export_route_function)(const struct rt_entry*);
  
  void
***************
*** 56,86 ****
  
  void
! olsr_addroute_add_function(int (*)(struct rt_entry*), olsr_u8_t);
  
  int
! olsr_addroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t);
  
  void
! olsr_delroute_add_function(int (*)(struct rt_entry*), olsr_u8_t);
! 
! int
! olsr_delroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t);
! 
! int
! olsr_export_add_route (struct rt_entry*); 
! 
! int
! olsr_export_del_route (struct rt_entry*); 
! 
! int
! olsr_export_add_route6 (struct rt_entry*); 
  
  int
! olsr_export_del_route6 (struct rt_entry*); 
  
  void
  olsr_update_kernel_routes(void);
  
! int
  olsr_delete_all_kernel_routes(void);
  
--- 52,70 ----
  
  void
! olsr_addroute_add_function(export_route_function, olsr_u8_t);
  
  int
! olsr_addroute_remove_function(export_route_function, olsr_u8_t);
  
  void
! olsr_delroute_add_function(export_route_function, olsr_u8_t);
  
  int
! olsr_delroute_remove_function(export_route_function, olsr_u8_t);
  
  void
  olsr_update_kernel_routes(void);
  
! void
  olsr_delete_all_kernel_routes(void);
  

Index: routing_table.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/routing_table.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** routing_table.c	8 Nov 2007 22:47:41 -0000	1.33
--- routing_table.c	11 Nov 2007 23:10:24 -0000	1.34
***************
*** 69,73 ****
  olsr_bump_routingtree_version(void)
  {
!   return(routingtree_version++);
  }
  
--- 69,73 ----
  olsr_bump_routingtree_version(void)
  {
!   return routingtree_version++;
  }
  
***************
*** 87,96 ****
    const struct olsr_ip_prefix *pfx1 = prefix1;
    const struct olsr_ip_prefix *pfx2 = prefix2;
  
    /* prefix */
!   if (pfx1->prefix.v4.s_addr < pfx2->prefix.v4.s_addr) {
      return -1;
    }
!   if (pfx1->prefix.v4.s_addr > pfx2->prefix.v4.s_addr) {
      return +1;
    }
--- 87,98 ----
    const struct olsr_ip_prefix *pfx1 = prefix1;
    const struct olsr_ip_prefix *pfx2 = prefix2;
+   const olsr_u32_t addr1 = ntohl(pfx1->prefix.v4.s_addr);
+   const olsr_u32_t addr2 = ntohl(pfx2->prefix.v4.s_addr);
  
    /* prefix */
!   if (addr1 < addr2) {
      return -1;
    }
!   if (addr1 > addr2) {
      return +1;
    }
***************
*** 143,147 ****
   * Initialize the routingtree and kernel change queues.
   */
! int
  olsr_init_routing_table(void)
  {
--- 145,149 ----
   * Initialize the routingtree and kernel change queues.
   */
! void
  olsr_init_routing_table(void)
  {
***************
*** 149,159 ****
    avl_init(&routingtree, avl_comp_prefix_default);
    routingtree_version = 0;
- 
-   /* the add/chg/del kernel queues */
-   list_head_init(&add_kernel_list);
-   list_head_init(&chg_kernel_list);
-   list_head_init(&del_kernel_list);
- 
-   return 1;
  }
  
--- 151,154 ----
***************
*** 177,181 ****
    rt_tree_node = avl_find(&routingtree, &prefix);
  
!   return (rt_tree_node ? rt_tree_node->data : NULL);
  }
  
--- 172,176 ----
    rt_tree_node = avl_find(&routingtree, &prefix);
  
!   return rt_tree_node ? rt_tree_node->data : NULL;
  }
  
***************
*** 215,227 ****
  olsr_alloc_rt_entry(struct olsr_ip_prefix *prefix)
  {
!   struct rt_entry *rt;
! 
!   rt = olsr_malloc(sizeof(struct rt_entry), __FUNCTION__);
! 
    if (!rt) {
      return NULL;
    }
  
!   memset(rt, 0, sizeof(struct rt_entry));
    
    /* Mark this entry as fresh (see process_routes.c:512) */
--- 210,219 ----
  olsr_alloc_rt_entry(struct olsr_ip_prefix *prefix)
  {
!   struct rt_entry *rt = olsr_malloc(sizeof(struct rt_entry), __FUNCTION__);
    if (!rt) {
      return NULL;
    }
  
!   memset(rt, 0, sizeof(*rt));
    
    /* Mark this entry as fresh (see process_routes.c:512) */
***************
*** 249,255 ****
                     union olsr_ip_addr *originator)
  {
!   struct rt_path *rtp;
! 
!   rtp = olsr_malloc(sizeof(struct rt_path), __FUNCTION__);
  
    if (!rtp) {
--- 241,245 ----
                     union olsr_ip_addr *originator)
  {
!   struct rt_path *rtp = olsr_malloc(sizeof(struct rt_path), __FUNCTION__);
  
    if (!rtp) {
***************
*** 257,261 ****
    }
  
!   memset(rtp, 0, sizeof(struct rt_path));
  
    //COPY_IP(&rtp->rtp_originator, originator);
--- 247,251 ----
    }
  
!   memset(rtp, 0, sizeof(*rtp));
  
    //COPY_IP(&rtp->rtp_originator, originator);
***************
*** 279,283 ****
   */
  olsr_bool
! olsr_nh_change(struct rt_nexthop *nh1, struct rt_nexthop *nh2)
  {
    if (!ipequal(&nh1->gateway, &nh2->gateway) ||
--- 269,273 ----
   */
  olsr_bool
! olsr_nh_change(const struct rt_nexthop *nh1, const struct rt_nexthop *nh2)
  {
    if (!ipequal(&nh1->gateway, &nh2->gateway) ||
***************
*** 313,317 ****
   */
  static olsr_bool
! olsr_cmp_rtp(struct rt_path *rtp1, struct rt_path *rtp2)
  {
     /* etx comes first */
--- 303,307 ----
   */
  static olsr_bool
! olsr_cmp_rtp(const struct rt_path *rtp1, const struct rt_path *rtp2)
  {
     /* etx comes first */
***************
*** 343,349 ****
   */
  olsr_bool
! olsr_cmp_rt(struct rt_entry *rt1, struct rt_entry *rt2)
  {
!   return(olsr_cmp_rtp(rt1->rt_best, rt2->rt_best));
  }
  
--- 333,339 ----
   */
  olsr_bool
! olsr_cmp_rt(const struct rt_entry *rt1, const struct rt_entry *rt2)
  {
!   return olsr_cmp_rtp(rt1->rt_best, rt2->rt_best);
  }
  
***************
*** 355,363 ****
  olsr_rt_best(struct rt_entry *rt)
  {
-   struct rt_path *rtp;
-   struct avl_node *node;
- 
    /* grab the first entry */
!   node = avl_walk_first(&rt->rt_path_tree);
  
    assert(node != 0); /* should not happen */
--- 345,350 ----
  olsr_rt_best(struct rt_entry *rt)
  {
    /* grab the first entry */
!   struct avl_node *node = avl_walk_first(&rt->rt_path_tree);
  
    assert(node != 0); /* should not happen */
***************
*** 367,372 ****
    /* walk all remaining originator entries */
    while ((node = avl_walk_next(node))) {
! 
!     rtp = node->data;
  
      if (olsr_cmp_rtp(rtp, rt->rt_best)) {
--- 354,358 ----
    /* walk all remaining originator entries */
    while ((node = avl_walk_next(node))) {
!     struct rt_path *rtp = node->data;
  
      if (olsr_cmp_rtp(rtp, rt->rt_best)) {
***************
*** 466,470 ****
   */
  char *
! olsr_rt_to_string(struct rt_entry *rt)
  {
    static char buff[128];
--- 452,456 ----
   */
  char *
! olsr_rt_to_string(const struct rt_entry *rt)
  {
    static char buff[128];
***************
*** 484,488 ****
   */
  char *
! olsr_rtp_to_string(struct rt_path *rtp)
  {
    static char buff[128];
--- 470,474 ----
   */
  char *
! olsr_rtp_to_string(const struct rt_path *rtp)
  {
    static char buff[128];
***************
*** 511,516 ****
  olsr_calculate_hna_routes(void)
  {
!   int index, plen;
!   struct rt_entry *rt;
  
  #ifdef DEBUG
--- 497,501 ----
  olsr_calculate_hna_routes(void)
  {
!   int idx;
  
  #ifdef DEBUG
***************
*** 518,548 ****
  #endif
  
!   for(index=0;index<HASHSIZE;index++)
!   {
      struct hna_entry *tmp_hna;
      /* All entries */
!     for(tmp_hna = hna_set[index].next;
!         tmp_hna != &hna_set[index];
!         tmp_hna = tmp_hna->next)
!     {
        struct hna_net *tmp_net;
        /* All networks */
!       for(tmp_net = tmp_hna->networks.next;
!           tmp_net != &tmp_hna->networks;
!           tmp_net = tmp_net->next) {
! 
          /* If no route to gateway - skip */
!         if((rt = olsr_lookup_routing_table(&tmp_hna->A_gateway_addr)) == NULL)
!           continue;
! 
!         /* update if better */
!         plen = olsr_get_hna_prefix_len(tmp_net);
!         olsr_insert_routing_table(&tmp_net->A_network_addr, plen,
!                                   &tmp_hna->A_gateway_addr,
!                                   &rt->rt_best->rtp_nexthop.gateway,
!                                   rt->rt_best->rtp_nexthop.iif_index,
!                                   rt->rt_best->rtp_metric.hops,
!                                   rt->rt_best->rtp_metric.etx);
! 
        }
      }
--- 503,525 ----
  #endif
  
!   for (idx = 0; idx < HASHSIZE; idx++) {
      struct hna_entry *tmp_hna;
      /* All entries */
!     for (tmp_hna = hna_set[idx].next; tmp_hna != &hna_set[idx]; tmp_hna = tmp_hna->next) {
        struct hna_net *tmp_net;
        /* All networks */
!       for (tmp_net = tmp_hna->networks.next; tmp_net != &tmp_hna->networks; tmp_net = tmp_net->next) {
          /* If no route to gateway - skip */
!         struct rt_entry *rt = olsr_lookup_routing_table(&tmp_hna->A_gateway_addr);
!         if (rt != NULL) {
!           /* update if better */
!           olsr_insert_routing_table(&tmp_net->A_network_addr,
!                                     olsr_get_hna_prefix_len(tmp_net),
!                                     &tmp_hna->A_gateway_addr,
!                                     &rt->rt_best->rtp_nexthop.gateway,
!                                     rt->rt_best->rtp_nexthop.iif_index,
!                                     rt->rt_best->rtp_metric.hops,
!                                     rt->rt_best->rtp_metric.etx);
!         }
        }
      }
***************
*** 558,573 ****
   */
  void
! olsr_print_routing_table(struct avl_tree *tree)
  {
!   struct avl_node *rt_tree_node;
  
    printf("ROUTING TABLE\n");
  
!   for (rt_tree_node = avl_walk_first(tree);
!        rt_tree_node;
!        rt_tree_node = avl_walk_next(rt_tree_node)) {
!     struct avl_node *rtp_tree_node;
      struct ipaddr_str prefixstr, origstr, gwstr;
!     struct rt_entry * const rt = rt_tree_node->data;
  
      /* first the route entry */
--- 535,550 ----
   */
  void
! olsr_print_routing_table(const struct avl_tree *tree)
  {
!   const struct avl_node *rt_tree_node;
  
    printf("ROUTING TABLE\n");
  
!   for (rt_tree_node = avl_walk_first_c(tree);
!        rt_tree_node != NULL;
!        rt_tree_node = avl_walk_next_c(rt_tree_node)) {
!     const struct avl_node *rtp_tree_node;
      struct ipaddr_str prefixstr, origstr, gwstr;
!     const struct rt_entry * const rt = rt_tree_node->data;
  
      /* first the route entry */
***************
*** 579,586 ****
  
      /* walk the per-originator path tree of routes */
!     for (rtp_tree_node = avl_walk_first(&rt->rt_path_tree);
!          rtp_tree_node;
!          rtp_tree_node = avl_walk_next(rtp_tree_node)) {
! 
        const struct rt_path * const rtp = rtp_tree_node->data;
        printf("\tfrom %s, etx %.3f, metric %u, via %s, %s, v %u\n",
--- 556,562 ----
  
      /* walk the per-originator path tree of routes */
!     for (rtp_tree_node = avl_walk_first_c(&rt->rt_path_tree);
!          rtp_tree_node != NULL;
!          rtp_tree_node = avl_walk_next_c(rtp_tree_node)) {
        const struct rt_path * const rtp = rtp_tree_node->data;
        printf("\tfrom %s, etx %.3f, metric %u, via %s, %s, v %u\n",





More information about the Olsr-cvs mailing list