[Olsr-cvs] olsrd-current/src defs.h, 1.54, 1.55 duplicate_set.c, 1.12, 1.13 hashing.c, 1.9, 1.10 hashing.h, 1.8, 1.9 link_set.c, 1.64, 1.65 link_set.h, 1.29, 1.30 lq_avl.c, 1.1, 1.2 lq_avl.h, 1.2, 1.3 lq_list.c, 1.3, 1.4 lq_list.h, 1.3, 1.4 lq_packet.c, 1.21, 1.22 lq_route.c, 1.42, 1.43 main.c, 1.89, 1.90 net_olsr.h, 1.5, 1.6 olsr.c, 1.48, 1.49 olsr.h, 1.24, 1.25 olsr_types.h, 1.4, 1.5 parser.c, 1.31, 1.32 process_routes.c, 1.29, 1.30 process_routes.h, 1.9, 1.10 scheduler.c, 1.36, 1.37

Bernd Petrovitsch (spam-protected)
Wed Jan 31 13:36:52 CET 2007


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

Modified Files:
	defs.h duplicate_set.c hashing.c hashing.h link_set.c 
	link_set.h lq_avl.c lq_avl.h lq_list.c lq_list.h lq_packet.c 
	lq_route.c main.c net_olsr.h olsr.c olsr.h olsr_types.h 
	parser.c process_routes.c process_routes.h scheduler.c 
Log Message:
* applied patches from the most recent FreiFunkFirmware (and fixed compile errors) according
  to http://www.olsr.org/pipermail/olsr-dev/2006-December/254036.html:
  - olsrd-libsmake.patch
  - olsrd-dyngwplain.patch
  - olsrd-txtinfo.patch
  - olsrd-quagga.patch
  - olsrd-quagga-routehandler.patch
  - olsrd-optimize.patch
  - olsrd-bmf-fixes.patch
  - olsrd-fixes-sven-ola.patch
  - olsrd-fixes-jhay-bsd.patch
  - olsrd-fixes-backport.patch
  - olsrd-fixes-routedel.patch
  - olsrd-cpu-overload.patch
  - olsrd-secure_key_path.patch
  - olsrd-hna_ip_fix.patch
  Not applied:
  - olsrd-nameservice+services.patch: This patch produced too many rejects to fix easily.
  - olsrd-fixes-eric.patch: This was not found on the webserver.
  - olsrd-bmf.patch: We had already a "bmf" plug-in in there.
* made the checksum type in the olsrd_secure plug-in "olsr_u8_t" (instead
   of a wild "char *" and "unsigned char *" mix) everywhere. It killed
   lots of warnings.
* localized the checksum_cache array in olsrd_secure.c.


Index: lq_route.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_route.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** lq_route.c	14 Dec 2006 11:29:20 -0000	1.42
--- lq_route.c	31 Jan 2007 12:36:50 -0000	1.43
***************
*** 78,81 ****
--- 78,82 ----
  }
  
+ #ifdef DISABLE_SVEN_OLA
  static int avl_comp_ipv4(void *ip1, void *ip2)
  {
***************
*** 88,91 ****
--- 89,93 ----
    return 1;
  }
+ #endif
  
  static int (*avl_comp)(void *, void *);
***************
*** 205,209 ****
  
    // add the vertex to the list, if it's not us
! 
    if ((*comp)(&olsr_cnf->main_addr, node->key) != 0)
    {
--- 207,220 ----
  
    // add the vertex to the list, if it's not us
! #ifndef DISABLE_SVEN_OLA
!   if (NULL == comp) {
!     if (svenola_avl_comp_ipv4(&olsr_cnf->main_addr, node->key) != 0)
!     {
!       vert->node.data = vert;
!       list_add_tail(vertex_list, &vert->node);
!     }
!   }
!   else
! #endif
    if ((*comp)(&olsr_cnf->main_addr, node->key) != 0)
    {
***************
*** 267,270 ****
--- 278,431 ----
  
  // XXX - bad complexity
+ #define SVEN_OPT
+ #undef SVEN_OPT_DBG
+ 
+ /*
+  * The function extract_best() is most expensive (>50% CPU in profiling).
+  * It is called in two modes: while doing Dijkstra route calculation and
+  * while searching for a direct route/hna. The latter can be optimized
+  * because the stored verices do not change from call to call and it is
+  * more sufficient to have them sorted/popped from a list rather than 
+  * searching the complete list by every call. (spam-protected), 11/2006
+  */
+  
+ #ifdef SVEN_OPT
+ static struct dijk_vertex **etx_cache = 0;
+ static int etx_cache_count;
+ static int etx_cache_get;
+ #ifdef SVEN_OPT_DBG
+ static int etx_cache_saved = 0;
+ #endif
+ 
+ static int etx_cache_compare(const void *a, const void *b)
+ {
+   // Oh jeah. I love this macro assembler :)
+   
+   if ((*(struct dijk_vertex **)a)->path_etx > (*(struct dijk_vertex **)b)->path_etx) return 1;
+   if ((*(struct dijk_vertex **)a)->path_etx < (*(struct dijk_vertex **)b)->path_etx) return -1;
+   
+   // This is for debugging only: etx==etx then compare pointers
+   // to make it possible to compare to the original search algo.
+   if (*(struct dijk_vertex **)a > *(struct dijk_vertex **)b) return 1;
+   if (*(struct dijk_vertex **)a < *(struct dijk_vertex **)b) return -1;
+   
+   return 0;
+ }
+ 
+ static struct dijk_vertex *extract_best_route(struct list *vertex_list)
+ {
+ #ifdef SVEN_OPT_DBG
+   float best_etx = INFINITE_ETX + 1.0;
+ #endif
+   struct list_node *node;
+   struct dijk_vertex *vert;
+   struct dijk_vertex *res = NULL;
+ 
+ #ifdef SVEN_OPT_DBG
+   node = list_get_head(vertex_list);
+ 
+   // loop through all vertices
+   
+   while (node != NULL)
+   {
+     vert = node->data;
+ 
+     // see whether the current vertex is better than what we have
+ 
+     if (!vert->done && vert->path_etx < best_etx)
+     {
+       best_etx = vert->path_etx;
+       res = vert;
+     }
+     else if (!vert->done && vert->path_etx == best_etx && vert < res)
+     {
+       // Otherwise order is undefined if etx==etx and debug will complain
+       best_etx = vert->path_etx;
+       res = vert;
+     }
+ 
+     node = list_get_next(node);
+   }
+ #endif
+   if (NULL == etx_cache)
+   {
+     int count = 0;
+     node = list_get_head(vertex_list);
+     while (node != NULL)
+     {
+       vert = node->data;
+       if (!vert->done && vert->path_etx < INFINITE_ETX) count++;
+       node = list_get_next(node);
+     }
+     if (0 < count)
+     {
+       etx_cache = olsr_malloc(sizeof(etx_cache[0]) * count, "ETX Cache");
+ #ifdef SVEN_OPT_DBG
+       printf("count=%d, Malloc(%d)=%p\n", count, sizeof(etx_cache[0]) * count, etx_cache);
+ #endif
+       node = list_get_head(vertex_list);
+       etx_cache_count = 0;
+       etx_cache_get = 0;
+       while (node != NULL)
+       {
+         vert = node->data;
+         if (!vert->done && vert->path_etx < INFINITE_ETX)
+         {
+           etx_cache[etx_cache_count] = vert;
+           etx_cache_count++;
+         }
+         node = list_get_next(node);
+       }
+ #ifdef SVEN_OPT_DBG
+       printf("qsort(etx_cache_count=%d)\n", etx_cache_count);
+ #endif
+       qsort(etx_cache, etx_cache_count, sizeof(etx_cache[0]), etx_cache_compare);
+ #ifdef SVEN_OPT_DBG
+       if (0 < etx_cache_count)
+       {
+         int i = 0; 
+         while(i < etx_cache_count && i < 10)
+         {
+           printf("%d: %p=%f\n", i, etx_cache[i], etx_cache[i]->path_etx);
+           i++;
+         }
+       }
+ #endif
+     }
+   }
+ 
+ #ifdef SVEN_OPT_DBG
+   if (NULL != etx_cache)
+   {
+     struct dijk_vertex *rescache = NULL;
+     if (etx_cache_get < etx_cache_count)
+     {
+       rescache = etx_cache[etx_cache_get++];
+     }
+     if (res != rescache)
+     {
+       printf("miss: etx_cache_get=%d, res=%p,%f != rescache=%p,%f\n",
+         etx_cache_get, res, (NULL != res ? res->path_etx : -1), rescache, (NULL != rescache ? rescache->path_etx : -1));
+     }
+     else
+     {
+       etx_cache_saved++;
+     }
+   }
+ #else
+   if (NULL != etx_cache && etx_cache_get < etx_cache_count)
+   {
+     res = etx_cache[etx_cache_get++];
+   }
+ #endif
+ 
+   // if we've found a vertex, remove it from the set
+ 
+   if (res != NULL)
+     res->done = OLSR_TRUE;
+ 
+   return res;
+ }
+ #endif // SVEN_OPT
  
  static struct dijk_vertex *extract_best(struct list *vertex_list)
***************
*** 372,377 ****
  
    if (olsr_cnf->ipsize == 4)
      avl_comp = avl_comp_ipv4;
! 
    else
      avl_comp = avl_comp_ipv6;
--- 533,541 ----
  
    if (olsr_cnf->ipsize == 4)
+ #ifndef DISABLE_SVEN_OLA
+     avl_comp = 0;
+ #else
      avl_comp = avl_comp_ipv4;
! #endif
    else
      avl_comp = avl_comp_ipv6;
***************
*** 615,618 ****
--- 779,792 ----
    // add HNA routes - the set of unprocessed network nodes contains
    // all reachable network nodes
+ #ifdef SVEN_OPT
+ #ifdef SVEN_OPT_DBG
+   printf("free etx_cache, saved compares=%d, etx_cache=%p\n", etx_cache_saved, etx_cache);
+   etx_cache_saved = 0;
+ #endif
+   if (NULL != etx_cache) {
+     free(etx_cache);
+     etx_cache = NULL;
+   }
+ #endif
  
    for (;;)
***************
*** 621,625 ****
--- 795,803 ----
      // from the set of unprocessed network nodes
  
+ #ifdef SVEN_OPT
+     vert = extract_best_route(&vertex_list);
+ #else
      vert = extract_best(&vertex_list);
+ #endif
  
      // no more nodes left

Index: duplicate_set.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/duplicate_set.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** duplicate_set.c	27 Feb 2005 18:39:43 -0000	1.12
--- duplicate_set.c	31 Jan 2007 12:36:50 -0000	1.13
***************
*** 94,98 ****
  
    /* Hash the senders address */
!   hash = olsr_hashing(originator);
  
    new_dup_entry = olsr_malloc(sizeof(struct dup_entry), "New dup entry");
--- 94,98 ----
  
    /* Hash the senders address */
!   hash = HASHMASK & seqno;
  
    new_dup_entry = olsr_malloc(sizeof(struct dup_entry), "New dup entry");
***************
*** 132,136 ****
  
    /* Hash the senders address */
!   hash = olsr_hashing(originator);
  
    /* Check for entry */
--- 132,136 ----
  
    /* Hash the senders address */
!   hash = HASHMASK & seqno;
  
    /* Check for entry */
***************
*** 164,168 ****
  
    /* Hash the senders address */
!   hash = olsr_hashing(originator);
  
    /* Check for entry */
--- 164,168 ----
  
    /* Hash the senders address */
!   hash = HASHMASK & seqno;
  
    /* Check for entry */
***************
*** 269,273 ****
  
    /* Hash the senders address */
!   hash = olsr_hashing(originator);
  
  
--- 269,273 ----
  
    /* Hash the senders address */
!   hash = HASHMASK & seqno;
  
  
***************
*** 314,318 ****
  
    /* Hash the senders address */
!   hash = olsr_hashing(originator);
  
    /* Check for entry */
--- 314,318 ----
  
    /* Hash the senders address */
!   hash = HASHMASK & seqno;
  
    /* Check for entry */

Index: lq_list.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_list.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** lq_list.h	20 Feb 2005 18:52:18 -0000	1.3
--- lq_list.h	31 Jan 2007 12:36:50 -0000	1.4
***************
*** 59,62 ****
--- 59,68 ----
  void list_init(struct list *list);
  
+ #ifndef DISABLE_SVEN_OLA
+ #define list_get_head(node) (node)->head
+ #define list_get_tail(node) (node)->tail
+ #define list_get_next(node) (node)->next
+ #define list_get_prev(node) (node)->prev
+ #else
  struct list_node *list_get_head(struct list *list);
  struct list_node *list_get_tail(struct list *list);
***************
*** 64,67 ****
--- 70,74 ----
  struct list_node *list_get_next(struct list_node *node);
  struct list_node *list_get_prev(struct list_node *node);
+ #endif
  
  void list_add_head(struct list *list, struct list_node *node);

Index: process_routes.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** process_routes.h	29 May 2005 12:47:45 -0000	1.9
--- process_routes.h	31 Jan 2007 12:36:50 -0000	1.10
***************
*** 51,54 ****
--- 51,82 ----
  extern struct rt_entry old_hna[HASHSIZE];
  
+ void
+ olsr_init_export_route(void);
+ 
+ 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*); 
+ 
+ 
  int
  olsr_init_old_table(void);

Index: net_olsr.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** net_olsr.h	15 Nov 2006 21:13:52 -0000	1.5
--- net_olsr.h	31 Jan 2007 12:36:50 -0000	1.6
***************
*** 50,54 ****
  #include <net/if.h>
  
! typedef int (*packet_transform_function)(char *, int *);
  
  #ifdef USE_LIBNET
--- 50,54 ----
  #include <net/if.h>
  
! typedef int (*packet_transform_function)(olsr_u8_t *, int *);
  
  #ifdef USE_LIBNET

Index: lq_list.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_list.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** lq_list.c	4 Dec 2004 17:06:57 -0000	1.3
--- lq_list.c	31 Jan 2007 12:36:50 -0000	1.4
***************
*** 49,52 ****
--- 49,53 ----
  }
  
+ #ifdef DISABLE_SVEN_OLA
  struct list_node *list_get_head(struct list *list)
  {
***************
*** 68,71 ****
--- 69,73 ----
    return node->prev;
  }
+ #endif
  
  void list_add_head(struct list *list, struct list_node *node)

Index: lq_packet.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_packet.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** lq_packet.c	11 Oct 2006 20:58:45 -0000	1.21
--- lq_packet.c	31 Jan 2007 12:36:50 -0000	1.22
***************
*** 151,155 ****
    struct neighbor_entry *walker;
    struct link_entry *link;
!   static int ttl_list[] = { MAX_TTL, 3, 2, 1, 2, 1, 1, 3, 2, 1, 2, 1, 1, 0 };
  
    // remember that we have generated an LQ TC message; this is
--- 151,155 ----
    struct neighbor_entry *walker;
    struct link_entry *link;
!   static int ttl_list[] = { 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, MAX_TTL-1, 0};
  
    // remember that we have generated an LQ TC message; this is
***************
*** 168,174 ****
    if (olsr_cnf->lq_fish > 0)
    {
      if (ttl_list[outif->ttl_index] == 0)
        outif->ttl_index = 0;
! 
      lq_tc->comm.ttl = ttl_list[outif->ttl_index++];
  
--- 168,178 ----
    if (olsr_cnf->lq_fish > 0)
    {
+     // SVEN_OLA: Too lazy to find the different iface inits. This will do it too.
+     if (outif->ttl_index >= (int)(sizeof(ttl_list) / sizeof(ttl_list[0])))
+       outif->ttl_index = 0;
+     
      if (ttl_list[outif->ttl_index] == 0)
        outif->ttl_index = 0;
!   
      lq_tc->comm.ttl = ttl_list[outif->ttl_index++];
  
***************
*** 224,229 ****
            link = get_best_link_to_neighbor(&neigh->main);
  
!           neigh->link_quality = link->loss_link_quality;
!           neigh->neigh_link_quality = link->neigh_link_quality;
  
            // queue the neighbour entry
--- 228,235 ----
            link = get_best_link_to_neighbor(&neigh->main);
  
!           if (link) {
!             neigh->link_quality = link->loss_link_quality;
!             neigh->neigh_link_quality = link->neigh_link_quality;
!           }
  
            // queue the neighbour entry

Index: olsr_types.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/olsr_types.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** olsr_types.h	15 May 2005 12:57:24 -0000	1.4
--- olsr_types.h	31 Jan 2007 12:36:50 -0000	1.5
***************
*** 94,97 ****
--- 94,98 ----
  {
    olsr_u32_t v4;
+   olsr_u8_t v4x[4];
    struct in6_addr v6;
  };

Index: olsr.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/olsr.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** olsr.c	7 Jan 2006 08:16:20 -0000	1.48
--- olsr.c	31 Jan 2007 12:36:50 -0000	1.49
***************
*** 69,72 ****
--- 69,73 ----
  olsr_bool changes_neighborhood;
  olsr_bool changes_hna;
+ olsr_bool changes_force;
  
  /**
***************
*** 143,146 ****
--- 144,152 ----
  #endif
    
+   if(!changes_force &&
+      2 <= olsr_cnf->lq_level &&
+      0 >= olsr_cnf->lq_dlimit)
+     return;
+     
    if(!changes_neighborhood &&
       !changes_topology &&
***************
*** 172,180 ****
            olsr_calculate_hna_routes();
          }
- 
-       else
-         {
-           olsr_calculate_lq_routing_table();
-         }
      }
    
--- 178,181 ----
***************
*** 188,196 ****
            olsr_calculate_hna_routes();
          }
- 
-       else
-         {
-           olsr_calculate_lq_routing_table();
-         }
      }
  
--- 189,192 ----
***************
*** 203,211 ****
            olsr_calculate_hna_routes();
          }
! 
!       else
!         {
!           olsr_calculate_lq_routing_table();
!         }
      }
    
--- 199,207 ----
            olsr_calculate_hna_routes();
          }
!     }
!   
!   if (olsr_cnf->lq_level >= 2)
!     {
!       olsr_calculate_lq_routing_table();
      }
    
***************
*** 240,243 ****
--- 236,240 ----
    changes_topology = OLSR_FALSE;
    changes_hna = OLSR_FALSE;
+   changes_force = OLSR_FALSE;
  
  

Index: parser.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/parser.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** parser.c	14 Dec 2006 11:29:20 -0000	1.31
--- parser.c	31 Jan 2007 12:36:50 -0000	1.32
***************
*** 62,65 ****
--- 62,73 ----
  #endif
  
+ /* Sven-Ola: On very slow devices used in huge networks
+  * the amount of lq_tc messages is so high, that the 
+  * recv() loop never ends. This is a small hack to end
+  * the loop in this cases
+  */
+  
+ unsigned int cpu_overload_exit = 0;
+ 
  struct parse_function_entry *parse_functions;
  
***************
*** 356,362 ****
    struct interface *olsr_in_if;
    union olsr_ip_addr from_addr;
! 
    for (;;) 
      {
        fromlen = sizeof(struct sockaddr_storage);
  
--- 364,377 ----
    struct interface *olsr_in_if;
    union olsr_ip_addr from_addr;
!   cpu_overload_exit = 0;
!   
    for (;;) 
      {
+       if (32 < ++cpu_overload_exit)
+       {
+         OLSR_PRINTF(1, "CPU overload detected, ending olsr_input() loop\n")
+       	break;
+       }
+       
        fromlen = sizeof(struct sockaddr_storage);
  

Index: scheduler.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/scheduler.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** scheduler.c	27 Jul 2006 15:53:16 -0000	1.36
--- scheduler.c	31 Jan 2007 12:36:50 -0000	1.37
***************
*** 84,87 ****
--- 84,88 ----
    changes_neighborhood = OLSR_TRUE;
    changes_topology = OLSR_TRUE;
+   changes_force = OLSR_TRUE;
  }
  

Index: hashing.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/hashing.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** hashing.c	20 Feb 2005 18:52:18 -0000	1.9
--- hashing.c	31 Jan 2007 12:36:50 -0000	1.10
***************
*** 59,63 ****
    if(olsr_cnf->ip_version == AF_INET)
      /* IPv4 */  
!     hash = (ntohl(address->v4));
    else
      {
--- 59,63 ----
    if(olsr_cnf->ip_version == AF_INET)
      /* IPv4 */  
!     hash = address->v4x[0] ^ address->v4x[1] ^ address->v4x[2] ^ address->v4x[3];
    else
      {

Index: hashing.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/hashing.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** hashing.h	20 Feb 2005 18:52:18 -0000	1.8
--- hashing.h	31 Jan 2007 12:36:50 -0000	1.9
***************
*** 44,48 ****
  #define _OLSR_HASHING
  
! #define	HASHSIZE	32
  #define	HASHMASK	(HASHSIZE - 1)
  
--- 44,48 ----
  #define _OLSR_HASHING
  
! #define	HASHSIZE	128
  #define	HASHMASK	(HASHSIZE - 1)
  

Index: defs.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/defs.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** defs.h	15 Nov 2006 23:07:59 -0000	1.54
--- defs.h	31 Jan 2007 12:36:50 -0000	1.55
***************
*** 71,75 ****
  #define	MAXMESSAGESIZE		1500	/* max broadcast size */
  #define UDP_IPV4_HDRSIZE        28
! #define UDP_IPV6_HDRSIZE        48
  
  #define MIN_PACKET_SIZE(ver)  (int)(sizeof(olsr_u8_t) * ((ver == AF_INET) ? 4 : 7))
--- 71,75 ----
  #define	MAXMESSAGESIZE		1500	/* max broadcast size */
  #define UDP_IPV4_HDRSIZE        28
! #define UDP_IPV6_HDRSIZE        62
  
  #define MIN_PACKET_SIZE(ver)  (int)(sizeof(olsr_u8_t) * ((ver == AF_INET) ? 4 : 7))

Index: lq_avl.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_avl.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lq_avl.c	22 Jan 2005 14:30:57 -0000	1.1
--- lq_avl.c	31 Jan 2007 12:36:50 -0000	1.2
***************
*** 41,44 ****
--- 41,47 ----
  
  #include <stddef.h>
+ #ifndef DISABLE_SVEN_OLA
+ #include <time.h>
+ #endif
  
  #include "lq_avl.h"
***************
*** 53,56 ****
--- 56,76 ----
  }
  
+ #ifndef DISABLE_SVEN_OLA
+ static struct avl_node *avl_find_rec_ipv4(struct avl_node *node, void *key)
+ {
+   if (*(unsigned int *)key < *(unsigned int *)node->key) {
+     if (node->left != NULL) {
+       return avl_find_rec_ipv4(node->left, key);
+     }
+   }
+   else if (*(unsigned int *)key > *(unsigned int *)node->key) {
+     if (node->right != NULL) {
+       return avl_find_rec_ipv4(node->right, key);
+     }
+   }
+   return node;
+ }
+ #endif
+ 
  static struct avl_node *avl_find_rec(struct avl_node *node, void *key,
                                       int (*comp)(void *, void *))
***************
*** 58,61 ****
--- 78,86 ----
    int diff;
  
+ #ifndef DISABLE_SVEN_OLA
+   if (0 == comp) {
+     return avl_find_rec_ipv4(node, key);
+   }
+ #endif
    diff = (*comp)(key, node->key);
  
***************
*** 88,91 ****
--- 113,123 ----
    node = avl_find_rec(tree->root, key, tree->comp);
  
+ #ifndef DISABLE_SVEN_OLA
+   if (0 == tree->comp) {
+     if (0 != svenola_avl_comp_ipv4(node->key, key))
+       return NULL;
+   }
+   else
+ #endif
    if ((*tree->comp)(node->key, key) != 0)
      return NULL;
***************
*** 229,232 ****
--- 261,270 ----
    node = avl_find_rec(tree->root, new->key, tree->comp);
  
+ #ifndef DISABLE_SVEN_OLA
+   if (0 == tree->comp) {
+     diff = svenola_avl_comp_ipv4(new->key, node->key);
+   }
+   else
+ #endif
    diff = (*tree->comp)(new->key, node->key);
  

Index: olsr.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/olsr.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** olsr.h	29 May 2005 12:47:45 -0000	1.24
--- olsr.h	31 Jan 2007 12:36:50 -0000	1.25
***************
*** 50,53 ****
--- 50,54 ----
  extern olsr_bool changes_neighborhood;
  extern olsr_bool changes_hna;
+ extern olsr_bool changes_force;
  
  void

Index: link_set.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** link_set.h	14 Dec 2006 11:29:19 -0000	1.29
--- link_set.h	31 Jan 2007 12:36:50 -0000	1.30
***************
*** 118,121 ****
--- 118,124 ----
  olsr_init_link_set(void);
  
+ void
+ del_if_link_entries(union olsr_ip_addr *);
+ 
  struct link_entry *
  get_best_link_to_neighbor(union olsr_ip_addr *);

Index: link_set.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** link_set.c	14 Dec 2006 11:29:19 -0000	1.64
--- link_set.c	31 Jan 2007 12:36:50 -0000	1.65
***************
*** 383,386 ****
--- 383,449 ----
  
  /**
+  *Delete all interface link entries
+  *
+  *@param interface ip address
+  */
+ 
+ void
+ del_if_link_entries(union olsr_ip_addr *int_addr)
+ {
+   struct link_entry *tmp_link_set, *last_link_entry;
+ 
+   if(link_set == NULL)
+     return;
+ 
+   tmp_link_set = link_set;
+   last_link_entry = NULL;
+ 
+   while(tmp_link_set)
+     {
+ 
+       if(COMP_IP(int_addr, &tmp_link_set->local_iface_addr))
+         {
+           if(last_link_entry != NULL)
+             {
+               last_link_entry->next = tmp_link_set->next;
+ 
+               /* Delete neighbor entry */
+               if(tmp_link_set->neighbor->linkcount == 1)
+                 olsr_delete_neighbor_table(&tmp_link_set->neighbor->neighbor_main_addr);
+               else
+                 tmp_link_set->neighbor->linkcount--;
+ 
+               //olsr_delete_neighbor_if_no_link(&tmp_link_set->neighbor->neighbor_main_addr);
+               changes_neighborhood = OLSR_TRUE;
+ 
+               free(tmp_link_set);
+               tmp_link_set = last_link_entry;
+             }
+           else
+             {
+               link_set = tmp_link_set->next; /* CHANGED */
+ 
+               /* Delete neighbor entry */
+               if(tmp_link_set->neighbor->linkcount == 1)
+                 olsr_delete_neighbor_table(&tmp_link_set->neighbor->neighbor_main_addr);
+               else
+                 tmp_link_set->neighbor->linkcount--;
+ 
+               changes_neighborhood = OLSR_TRUE;
+ 
+               free(tmp_link_set);
+               tmp_link_set = link_set;
+               continue;
+             }
+         }
+ 
+       last_link_entry = tmp_link_set;
+       tmp_link_set = tmp_link_set->next;
+     }
+ 
+   return;
+ }
+ 
+ /**
   *Nothing mysterious here.
   *Adding a new link entry to the link set.
***************
*** 960,965 ****
    entry->loss_link_quality =
      (float)(entry->total_packets - entry->lost_packets) /
!     (float)(entry->loss_window_size);
! 
    // multiply the calculated link quality with the user-specified multiplier
  
--- 1023,1029 ----
    entry->loss_link_quality =
      (float)(entry->total_packets - entry->lost_packets) /
!     (float)(entry->loss_window_size < (2 * 4) ? entry->loss_window_size: 
!     4 * ((entry->loss_window_size / 4 - 1) * entry->total_packets + entry->loss_window_size) / entry->loss_window_size);
!     
    // multiply the calculated link quality with the user-specified multiplier
  

Index: main.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/main.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -C2 -d -r1.89 -r1.90
*** main.c	14 Apr 2006 05:04:16 -0000	1.89
--- main.c	31 Jan 2007 12:36:50 -0000	1.90
***************
*** 283,286 ****
--- 283,289 ----
    olsr_init_parser();
  
+   /* Initialize route-exporter */
+   olsr_init_export_route();
+ 
    /* Initialize message sequencnumber */
    init_msg_seqno();
***************
*** 511,515 ****
    fprintf(stderr, "  [-midint <mid interval (secs)>] [-hnaint <hna interval (secs)>]\n");
    fprintf(stderr, "  [-T <Polling Rate (secs)>] [-nofork] [-hemu <ip_address>] \n"); 
! 
  }
  
--- 514,518 ----
    fprintf(stderr, "  [-midint <mid interval (secs)>] [-hnaint <hna interval (secs)>]\n");
    fprintf(stderr, "  [-T <Polling Rate (secs)>] [-nofork] [-hemu <ip_address>] \n"); 
!   fprintf(stderr, "  [-lql <LQ level>] [-lqw <LQ winsize>]\n");
  }
  

Index: process_routes.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** process_routes.c	14 Dec 2006 11:29:20 -0000	1.29
--- process_routes.c	31 Jan 2007 12:36:50 -0000	1.30
***************
*** 4,7 ****
--- 4,10 ----
   * All rights reserved.
   *
+  * export_route_entry interface added by Immo 'FaUl Wehrenberg 
+  * <(spam-protected)>
+  *
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
***************
*** 40,44 ****
   */
  
- 
  #include "defs.h"
  #include "olsr.h"
--- 43,46 ----
***************
*** 52,59 ****
--- 54,213 ----
  #endif
  
+ struct export_route_entry
+ {
+   olsr_u8_t type;       /* AF_INET/AF_INET6 */
+   int (*function)(struct rt_entry*);
+   struct export_route_entry *next;
+ };
+ 
+ 
+ static struct export_route_entry *add_routes;
+ static struct export_route_entry *del_routes;
+ 
  
  struct rt_entry old_routes[HASHSIZE];
  struct rt_entry old_hna[HASHSIZE];
  
+ 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() 
+ {
+   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 *e) 
+ {
+   int retval = 0;
+   struct export_route_entry *tmp;
+   for (tmp = add_routes; tmp; tmp = tmp->next)
+     {
+       if (tmp->type == AF_INET)
+ 	retval = tmp->function(e);
+     }
+   return retval;
+ }
+ 
+ int
+ olsr_export_add_route6 (struct rt_entry *e) 
+ {
+   int retval = 0;
+   struct export_route_entry *tmp;
+   for (tmp = add_routes; tmp; tmp = tmp->next)
+     {
+       if (tmp->type == AF_INET6)
+ 	retval = tmp->function(e);
+     }
+   return retval;
+ }
+ 
+ int
+ olsr_export_del_route (struct rt_entry *e) 
+ {
+   int retval = 0;
+   struct export_route_entry *tmp;
+   for (tmp = del_routes; tmp; tmp = tmp->next)
+     {
+       if (tmp->type == AF_INET)
+ 	retval = tmp->function(e);
+     }
+   return retval;
+ }
+ 
+ int
+ olsr_export_del_route6 (struct rt_entry *e) 
+ {
+   int retval = 0;
+   struct export_route_entry *tmp;
+   for (tmp = del_routes; tmp; tmp = tmp->next)
+     {
+       if (tmp->type == AF_INET6)
+ 	retval = tmp->function(e);
+     }
+   return retval;
+ }
+ 
+ 
  
  int
***************
*** 349,355 ****
  		      {
  			if(olsr_cnf->ip_version == AF_INET)
! 			  error = olsr_ioctl_del_route(destination_ptr->destination);
  			else
! 			  error = olsr_ioctl_del_route6(destination_ptr->destination);
  			
  			if(error < 0)
--- 503,509 ----
  		      {
  			if(olsr_cnf->ip_version == AF_INET)
! 			  error = olsr_export_del_route(destination_ptr->destination);
  			else
! 			  error = olsr_export_del_route6(destination_ptr->destination);
  			
  			if(error < 0)
***************
*** 435,441 ****
  		  {
  		    if(olsr_cnf->ip_version == AF_INET)
! 		      error=olsr_ioctl_add_route(destination_kernel->destination);
  		    else
! 		      error=olsr_ioctl_add_route6(destination_kernel->destination);
  		    
  		    if(error < 0)
--- 589,595 ----
  		  {
  		    if(olsr_cnf->ip_version == AF_INET)
! 		      error=olsr_export_add_route(destination_kernel->destination);
  		    else
! 		      error=olsr_export_add_route6(destination_kernel->destination);
  		    
  		    if(error < 0)

Index: lq_avl.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_avl.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** lq_avl.h	20 Feb 2005 18:52:18 -0000	1.2
--- lq_avl.h	31 Jan 2007 12:36:50 -0000	1.3
***************
*** 63,65 ****
--- 63,70 ----
  int avl_insert(struct avl_tree *, struct avl_node *);
  
+ #ifndef DISABLE_SVEN_OLA
+ #define svenola_avl_comp_ipv4(ip1, ip2) \
+   (*(unsigned int *)ip1 == *(unsigned int *)ip2 ? 0 : \
+   *(unsigned int *)ip1 < *(unsigned int *)ip2 ? -1 : +1)
+ #endif
  #endif





More information about the Olsr-cvs mailing list