[Olsr-cvs] olsrd-current/src hysteresis.c, 1.17, 1.18 link_set.c, 1.65, 1.66 link_set.h, 1.30, 1.31 local_hna_set.c, 1.11, 1.12 local_hna_set.h, 1.9, 1.10 lq_mpr.c, 1.11, 1.12 mid_set.c, 1.16, 1.17 mid_set.h, 1.13, 1.14 process_package.c, 1.37, 1.38 routing_table.c, 1.24, 1.25

Bernd Petrovitsch (spam-protected)
Sat Feb 10 20:27:35 CET 2007


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

Modified Files:
	hysteresis.c link_set.c link_set.h local_hna_set.c 
	local_hna_set.h lq_mpr.c mid_set.c mid_set.h process_package.c 
	routing_table.c 
Log Message:
* added the rest if the olsrd-fixes-eric patch from Sven-Ola


Index: mid_set.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/mid_set.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** mid_set.h	29 May 2005 12:47:45 -0000	1.13
--- mid_set.h	10 Feb 2007 19:27:32 -0000	1.14
***************
*** 74,77 ****
--- 74,78 ----
  extern struct mid_address reverse_mid_set[HASHSIZE];
  
+ struct mid_alias;
  
  int
***************
*** 96,99 ****
--- 97,103 ----
  olsr_time_out_mid_set(void *);
  
+ void
+ olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases);
+ 
  int
  olsr_update_mid_table(union olsr_ip_addr *, float);

Index: lq_mpr.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_mpr.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** lq_mpr.c	7 Jan 2006 08:16:20 -0000	1.11
--- lq_mpr.c	10 Feb 2007 19:27:32 -0000	1.12
***************
*** 53,57 ****
    int i, k;
    struct neighbor_entry *neigh;
!   double best;
    olsr_bool mpr_changes = OLSR_FALSE;
    struct link_entry *link;
--- 53,57 ----
    int i, k;
    struct neighbor_entry *neigh;
!   double best, best_1hop;
    olsr_bool mpr_changes = OLSR_FALSE;
    struct link_entry *link;
***************
*** 92,95 ****
--- 92,97 ----
             neigh2 = neigh2->next)
          {
+           best_1hop = -1.0;
+ 
            // check whether this 2-hop neighbour is also a neighbour
  
***************
*** 112,116 ****
  		continue;
  
!               best = link->loss_link_quality * link->neigh_link_quality;
  
                // see wether we find a better route via an MPR
--- 114,118 ----
  		continue;
  
!               best_1hop = link->loss_link_quality * link->neigh_link_quality;
  
                // see wether we find a better route via an MPR
***************
*** 119,123 ****
                     walker != &neigh2->neighbor_2_nblist;
                     walker = walker->next)
!                 if (walker->path_link_quality > best)
                    break;
  
--- 121,125 ----
                     walker != &neigh2->neighbor_2_nblist;
                     walker = walker->next)
!                 if (walker->path_link_quality > best_1hop)
                    break;
  
***************
*** 159,163 ****
                    }
  
!               if (neigh != NULL)
                  {
                    neigh->is_mpr = OLSR_TRUE;
--- 161,168 ----
                    }
  
!               // Found a 1-hop neighbor that we haven't previously selected.
!               // Use it as MPR only when the 2-hop path through it is better than
!               // any existing 1-hop path.
!               if ((neigh != NULL) && (best > best_1hop))
                  {
                    neigh->is_mpr = OLSR_TRUE;

Index: mid_set.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/mid_set.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** mid_set.c	14 Dec 2006 11:29:20 -0000	1.16
--- mid_set.c	10 Feb 2007 19:27:32 -0000	1.17
***************
*** 47,50 ****
--- 47,51 ----
  #include "neighbor_table.h"
  #include "link_set.h"
+ #include "packet.h" /* struct mid_alias */
  
  
***************
*** 101,104 ****
--- 102,106 ----
    struct mid_address *tmp_adr;
    olsr_u32_t hash, alias_hash;
+   union olsr_ip_addr *registered_m_addr;
  
    hash = olsr_hashing(m_addr);
***************
*** 112,117 ****
        if(COMP_IP(&tmp->main_addr, m_addr))
  	break;
      }
! 	 
    /*If the address was registered*/ 
    if(tmp != &mid_set[hash])
--- 114,127 ----
        if(COMP_IP(&tmp->main_addr, m_addr))
  	break;
+      }
+ 
+   /* Check if alias is already registered with m_addr */
+   registered_m_addr = mid_lookup_main_addr(&alias->alias);
+   if (registered_m_addr != NULL && COMP_IP(registered_m_addr, m_addr))
+     {
+       /* Alias is already registered with main address. Nothing to do here. */
+       return;
      }
! 
    /*If the address was registered*/ 
    if(tmp != &mid_set[hash])
***************
*** 350,354 ****
        if(COMP_IP(&tmp_list->main_addr, adr))
  	{
! 	  //printf("Updating timer for node %s\n",ip_to_string(&tmp_list->main_addr));
  	  tmp_list->ass_timer = GET_TIMESTAMP(vtime*1000);
  
--- 360,364 ----
        if(COMP_IP(&tmp_list->main_addr, adr))
  	{
! 	  // printf("MID: Updating timer for node %s\n", olsr_ip_to_string(&tmp_list->main_addr));
  	  tmp_list->ass_timer = GET_TIMESTAMP(vtime*1000);
  
***************
*** 360,363 ****
--- 370,458 ----
  
  
+ /**
+  *Remove aliases from 'entry' which are not listed in 'declared_aliases'.
+  *
+  *@param entry the MID entry
+  *@param declared_aliases the list of declared aliases for the MID entry
+  *
+  *@return nada
+  */
+ void
+ olsr_prune_aliases(union olsr_ip_addr *m_addr, struct mid_alias *declared_aliases)
+ {
+   struct mid_entry *entry;
+   olsr_u32_t hash;
+   struct mid_address *registered_aliases;
+   struct mid_address *previous_alias;
+   struct mid_alias *save_declared_aliases = declared_aliases;
+ 
+   hash = olsr_hashing(m_addr);
+ 
+   /* Check for registered entry */
+   for(entry = mid_set[hash].next;
+       entry != &mid_set[hash];
+       entry = entry->next)
+     {
+       if(COMP_IP(&entry->main_addr, m_addr))
+ 	break;
+     }
+   if(entry == &mid_set[hash])
+     {
+       /* MID entry not found, nothing to prune here */
+       return;
+     }
+ 
+   registered_aliases = entry->aliases;
+   previous_alias = NULL;
+ 
+   while(registered_aliases != 0)
+     {
+       struct mid_address *current_alias = registered_aliases;
+       registered_aliases = registered_aliases->next_alias;
+ 
+       declared_aliases = save_declared_aliases;
+ 
+       /* Go through the list of declared aliases to find the matching current alias */
+       while(declared_aliases != 0 &&
+             ! COMP_IP(&current_alias->alias, &declared_aliases->alias_addr))
+         {
+           declared_aliases = declared_aliases->next;
+         }
+ 
+       if (declared_aliases == 0)
+         {
+           /* Current alias not found in list of declared aliases: free current alias */
+           OLSR_PRINTF(1, "MID remove: (%s, ", olsr_ip_to_string(&entry->main_addr))
+           OLSR_PRINTF(1, "%s)\n", olsr_ip_to_string(&current_alias->alias))
+ 
+           /* Update linked list as seen by 'entry' */
+           if (previous_alias != NULL)
+             {
+               previous_alias->next_alias = current_alias->next_alias;
+             }
+           else
+             {
+               entry->aliases = current_alias->next_alias;
+             }
+ 
+           /* Remove from hash table */
+           DEQUEUE_ELEM(current_alias);
+  
+           free(current_alias);
+ 
+           /*
+            *Recalculate topology
+            */
+           changes_neighborhood = OLSR_TRUE;
+           changes_topology = OLSR_TRUE;
+         }
+       else
+         {
+           previous_alias = current_alias;
+         }
+     }
+ }
+ 
+ 
  
  /**

Index: hysteresis.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/hysteresis.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** hysteresis.c	14 Dec 2006 11:29:19 -0000	1.17
--- hysteresis.c	10 Feb 2007 19:27:32 -0000	1.18
***************
*** 167,171 ****
    struct link_entry *link;
  
!   link = lookup_link_entry(remote, local);
  
    /* Calculate new quality */      
--- 167,171 ----
    struct link_entry *link;
  
!   link = lookup_link_entry(remote, NULL, local);
  
    /* Calculate new quality */      

Index: link_set.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** link_set.h	31 Jan 2007 12:36:50 -0000	1.30
--- link_set.h	10 Feb 2007 19:27:32 -0000	1.31
***************
*** 125,129 ****
  
  struct link_entry *
! lookup_link_entry(union olsr_ip_addr *, struct interface *);
  
  struct link_entry *
--- 125,129 ----
  
  struct link_entry *
! lookup_link_entry(union olsr_ip_addr *, union olsr_ip_addr *remote_main, struct interface *);
  
  struct link_entry *

Index: local_hna_set.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/local_hna_set.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** local_hna_set.c	7 Jan 2006 08:16:20 -0000	1.11
--- local_hna_set.c	10 Feb 2007 19:27:32 -0000	1.12
***************
*** 130,133 ****
--- 130,172 ----
  }
  
+ struct hna4_entry *
+ find_local_hna4_entry(union olsr_ip_addr *net, olsr_u32_t mask)
+ {
+   struct hna4_entry *h4 = olsr_cnf->hna4_entries;
+ 
+   while(h4)
+     {
+       if((net->v4 == h4->net.v4) && 
+ 	 (mask == h4->netmask.v4))
+ 	{
+ 	  return h4;
+ 	}
+       h4 = h4->next;
+     }
+ 
+   return NULL;
+ }
+ 
+ 
+ 
+ struct hna6_entry *
+ find_local_hna6_entry(union olsr_ip_addr *net, olsr_u16_t prefix_len)
+ {
+   struct hna6_entry *h6 = olsr_cnf->hna6_entries;
+ 
+   while(h6)
+     {
+       if((memcmp(net, &h6->net, olsr_cnf->ipsize) == 0) && 
+ 	 (prefix_len == h6->prefix_len))
+ 	{
+ 	  return h6;
+ 	}
+       h6 = h6->next;
+     }
+ 
+   return NULL;
+ }
+ 
+ 
  
  

Index: routing_table.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/routing_table.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** routing_table.c	14 Dec 2006 11:29:20 -0000	1.24
--- routing_table.c	10 Feb 2007 19:27:32 -0000	1.25
***************
*** 66,73 ****
  
  static struct rt_entry *
! olsr_check_for_higher_hopcount(struct rt_entry *, struct hna_net *, olsr_u16_t);
  
  struct rt_entry *
! olsr_check_for_lower_hopcount(struct rt_entry *, struct hna_net *, olsr_u16_t);
  
  static olsr_bool
--- 66,73 ----
  
  static struct rt_entry *
! olsr_check_for_higher_quality(struct rt_entry *, struct hna_net *, float);
  
  struct rt_entry *
! olsr_check_for_lower_quality(struct rt_entry *, struct hna_net *, float);
  
  static olsr_bool
***************
*** 213,217 ****
  
    new_route_entry->rt_metric = metric;
!   new_route_entry->rt_etx = etx;
    
    if(COMP_IP(dst, router))
--- 213,222 ----
  
    new_route_entry->rt_metric = metric;
!   if (etx< 0.0)
!     /* non-LQ case */
!     new_route_entry->rt_etx = (float)metric;
!   else
!     /* LQ case */
!     new_route_entry->rt_etx = etx;
    
    if(COMP_IP(dst, router))
***************
*** 291,295 ****
  						    iface,
  						    1,
! 						    0);
  			}
  		    }
--- 296,300 ----
  						    iface,
  						    1,
! 						    -1.0);
  			}
  		    }
***************
*** 407,411 ****
  						      iface,
  						      2,
! 						      0);
  			  
  			  if(new_route_entry != NULL)
--- 412,416 ----
  						      iface,
  						      2,
! 						      -1.0);
  			  
  			  if(new_route_entry != NULL)
***************
*** 504,508 ****
  						      list_destination_n->destination->rt_if,
  						      list_destination_n->destination->rt_metric+1,
! 						      0);
  			  if(destination_n_1->destination != NULL)
  			    {
--- 509,513 ----
  						      list_destination_n->destination->rt_if,
  						      list_destination_n->destination->rt_metric+1,
! 						      -1.0);
  			  if(destination_n_1->destination != NULL)
  			    {
***************
*** 552,566 ****
  
  /**
!  *Check for a entry with a higher hopcount than
   *a given value in a routing table
   *
   *@param routes the routingtable to look in
   *@param net the network entry to look for
!  *@param metric the metric to check for
   *
!  *@return the localted entry if found. NULL if not
   */
  static struct rt_entry *
! olsr_check_for_higher_hopcount(struct rt_entry *routes, struct hna_net *net, olsr_u16_t metric)
  {
    int index;
--- 557,571 ----
  
  /**
!  *Check for an entry with a higher quality (lower etx) than
   *a given value in a routing table
   *
   *@param routes the routingtable to look in
   *@param net the network entry to look for
!  *@param etx the metric to check for
   *
!  *@return the located entry if found. NULL if not
   */
  static struct rt_entry *
! olsr_check_for_higher_quality(struct rt_entry *routes, struct hna_net *net, float etx)
  {
    int index;
***************
*** 577,582 ****
  	     (memcmp(&tmp_routes->rt_mask, &net->A_netmask, netmask_size) == 0))
  	    {
! 	      /* Found a entry */
! 	      if(tmp_routes->rt_metric > metric)
  		return tmp_routes;
  	      else
--- 582,587 ----
  	     (memcmp(&tmp_routes->rt_mask, &net->A_netmask, netmask_size) == 0))
  	    {
! 	      /* Found an entry */
! 	      if(tmp_routes->rt_etx < etx)
  		return tmp_routes;
  	      else
***************
*** 592,606 ****
  
  /**
!  *Check for a entry with a lower or equal hopcount than
   *a given value in a routing table
   *
   *@param routes the routingtable to look in
   *@param net the network entry to look for
!  *@param metric the metric to check for
   *
!  *@return the localted entry if found. NULL if not
   */
  struct rt_entry *
! olsr_check_for_lower_hopcount(struct rt_entry *routes, struct hna_net *net, olsr_u16_t metric)
  {
    int index;
--- 597,611 ----
  
  /**
!  *Check for an entry with a lower or equal quality (higher or equal etx) than
   *a given value in a routing table
   *
   *@param routes the routingtable to look in
   *@param net the network entry to look for
!  *@param etx the metric to check for
   *
!  *@return the located entry if found. NULL if not
   */
  struct rt_entry *
! olsr_check_for_lower_quality(struct rt_entry *routes, struct hna_net *net, float etx)
  {
    int index;
***************
*** 617,622 ****
  	     (memcmp(&tmp_routes->rt_mask, &net->A_netmask, netmask_size) == 0))
  	    {
! 	      /* Found a entry */
! 	      if(tmp_routes->rt_metric <= metric)
  		return tmp_routes;
  	      else
--- 622,627 ----
  	     (memcmp(&tmp_routes->rt_mask, &net->A_netmask, netmask_size) == 0))
  	    {
! 	      /* Found an entry */
! 	      if(tmp_routes->rt_etx >= etx)
  		return tmp_routes;
  	      else
***************
*** 675,685 ****
  
  	      /* If there exists a better or equal entry - skip */
! 	      if(olsr_check_for_lower_hopcount(hna_routes, tmp_net, tmp_rt->rt_metric) != NULL)
  		{
  		  continue;
  		}
  
! 	      /* If we find an entry with higher hopcount we just edit it */
! 	      if((new_rt = olsr_check_for_higher_hopcount(hna_routes, tmp_net, tmp_rt->rt_metric)) != NULL)
  		{
  		  /* Fill struct */
--- 680,690 ----
  
  	      /* If there exists a better or equal entry - skip */
! 	      if(olsr_check_for_higher_quality(hna_routes, tmp_net, tmp_rt->rt_etx) != NULL)
  		{
  		  continue;
  		}
  
! 	      /* If we find an entry with lower quality we just edit it */
! 	      if((new_rt = olsr_check_for_lower_quality(hna_routes, tmp_net, tmp_rt->rt_etx)) != NULL)
  		{
  		  /* Fill struct */
***************
*** 690,693 ****
--- 695,699 ----
  		  COPY_IP(&new_rt->rt_router, &tmp_rt->rt_router);
  		  /* Metric */
+ 		  new_rt->rt_etx = tmp_rt->rt_etx;
  		  new_rt->rt_metric = tmp_rt->rt_metric;
  		  /* Flags */
***************
*** 710,713 ****
--- 716,720 ----
  		  COPY_IP(&new_rt->rt_router, &tmp_rt->rt_router);
  		  /* Metric */
+ 		  new_rt->rt_etx = tmp_rt->rt_etx;
  		  new_rt->rt_metric = tmp_rt->rt_metric;
  		  /* Flags */

Index: link_set.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** link_set.c	31 Jan 2007 12:36:50 -0000	1.65
--- link_set.c	10 Feb 2007 19:27:32 -0000	1.66
***************
*** 203,207 ****
        //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr));
        //printf("%s : ", olsr_ip_to_string(main_addr)); 
!       if((link = lookup_link_entry(main_addr, ifs)) != NULL)
  	{
  	  //printf("%d\n", lookup_link_status(link));
--- 203,207 ----
        //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr));
        //printf("%s : ", olsr_ip_to_string(main_addr)); 
!       if((link = lookup_link_entry(main_addr, NULL, ifs)) != NULL)
  	{
  	  //printf("%d\n", lookup_link_status(link));
***************
*** 216,220 ****
  	  //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr));
  	  //printf("%s : ", olsr_ip_to_string(&aliases->address)); 
! 	  if((link = lookup_link_entry(&aliases->alias, ifs)) != NULL)
  	    {
  	      //printf("%d\n", lookup_link_status(link));
--- 216,220 ----
  	  //printf("\tChecking %s->", olsr_ip_to_string(&ifs->ip_addr));
  	  //printf("%s : ", olsr_ip_to_string(&aliases->address)); 
!             if((link = lookup_link_entry(&aliases->alias, NULL, ifs)) != NULL)
  	    {
  	      //printf("%d\n", lookup_link_status(link));
***************
*** 264,268 ****
        continue;
  
!     // handle the non-LQ case
  
      if (olsr_cnf->lq_level == 0)
--- 264,268 ----
        continue;
  
!     // handle the non-LQ, RFC-compliant case
  
      if (olsr_cnf->lq_level == 0)
***************
*** 299,303 ****
      }
  
!     // handle the LQ case
  
      else
--- 299,303 ----
      }
  
!     // handle the LQ, non-RFC compliant case
  
      else
***************
*** 451,455 ****
   *@param local the local IP address
   *@param remote the remote IP address
!  *@param remote_main teh remote nodes main address
   *@param vtime the validity time of the entry
   *@param htime the HELLO interval of the remote node
--- 451,455 ----
   *@param local the local IP address
   *@param remote the remote IP address
!  *@param remote_main the remote nodes main address
   *@param vtime the validity time of the entry
   *@param htime the HELLO interval of the remote node
***************
*** 463,467 ****
    struct neighbor_entry *neighbor;
  
!   if((tmp_link_set = lookup_link_entry(remote, local_if))) return tmp_link_set;
  
    /*
--- 463,467 ----
    struct neighbor_entry *neighbor;
  
!   if((tmp_link_set = lookup_link_entry(remote, remote_main, local_if))) return tmp_link_set;
  
    /*
***************
*** 568,572 ****
    /* Copy the main address - make sure this is done every time
     * as neighbors might change main address */
!   COPY_IP(&neighbor->neighbor_main_addr, remote_main);
  
    neighbor->linkcount++;
--- 568,577 ----
    /* Copy the main address - make sure this is done every time
     * as neighbors might change main address */
!   /* Erik Tromp - OOPS! Don't do this! Neighbor entries are hashed through their
!    * neighbor_main_addr field, and when that field is changed, their position
!    * in the hash table is no longer correct, so that the function
!    * olsr_lookup_neighbor_table() can no longer find the neighbor
!    * entry. */
!   /*COPY_IP(&neighbor->neighbor_main_addr, remote_main);*/
  
    neighbor->linkcount++;
***************
*** 583,589 ****
         * enough in most cases. 10 seconds
         */
!       OLSR_PRINTF(1, "Adding MID alias main %s ", olsr_ip_to_string(remote_main))
!       OLSR_PRINTF(1, "-> %s based on HELLO\n\n", olsr_ip_to_string(remote))
!       insert_mid_alias(remote_main, remote, MID_ALIAS_HACK_VTIME);
      }
  
--- 588,599 ----
         * enough in most cases. 10 seconds
         */
!     /* Erik Tromp - commented out. It is not RFC-compliant. Also, MID aliases
!      * that are not explicitly declared by a node will be removed as soon as
!      * the olsr_prune_aliases(...) function is called.
!      *
!      * OLSR_PRINTF(1, "Adding MID alias main %s ", olsr_ip_to_string(remote_main))
!      * OLSR_PRINTF(1, "-> %s based on HELLO\n\n", olsr_ip_to_string(remote))
!      * insert_mid_alias(remote_main, remote, MID_ALIAS_HACK_VTIME);
!      */
      }
  
***************
*** 621,624 ****
--- 631,635 ----
   *
   *@param remote the remote interface address
+  *@param remote_main the remote nodes main address
   *@param local the local interface address
   *
***************
*** 626,630 ****
   */
  struct link_entry *
! lookup_link_entry(union olsr_ip_addr *remote, struct interface *local)
  {
    struct link_entry *tmp_link_set;
--- 637,641 ----
   */
  struct link_entry *
! lookup_link_entry(union olsr_ip_addr *remote, union olsr_ip_addr *remote_main, struct interface *local)
  {
    struct link_entry *tmp_link_set;
***************
*** 635,642 ****
      {
        if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) &&
! 	 (tmp_link_set->if_name ?
! 	  !strcmp(tmp_link_set->if_name, local->int_name) :
! 	  COMP_IP(&local->ip_addr, &tmp_link_set->local_iface_addr)
! 	 ))
  	return tmp_link_set;
        tmp_link_set = tmp_link_set->next;
--- 646,656 ----
      {
        if(COMP_IP(remote, &tmp_link_set->neighbor_iface_addr) &&
! 	 (tmp_link_set->if_name
!           ? !strcmp(tmp_link_set->if_name, local->int_name)
!           : COMP_IP(&local->ip_addr, &tmp_link_set->local_iface_addr)
!           ) &&
!          /* check the remote-main address only if there is one given */
!          (remote_main == NULL || COMP_IP(remote_main, &tmp_link_set->neighbor->neighbor_main_addr))
!          )
  	return tmp_link_set;
        tmp_link_set = tmp_link_set->next;
***************
*** 1073,1077 ****
    // called for every OLSR packet
  
!   entry = lookup_link_entry(rem, loc);
  
    // it's the very first LQ HELLO message - we do not yet have a link
--- 1087,1091 ----
    // called for every OLSR packet
  
!   entry = lookup_link_entry(rem, NULL, loc);
  
    // it's the very first LQ HELLO message - we do not yet have a link

Index: process_package.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_package.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** process_package.c	7 Jan 2006 08:16:20 -0000	1.37
--- process_package.c	10 Feb 2007 19:27:32 -0000	1.38
***************
*** 54,57 ****
--- 54,58 ----
  #include "rebuild_packet.h"
  #include "scheduler.h"
+ #include "local_hna_set.h"
  
  
***************
*** 67,71 ****
        olsr_parser_add_function(&olsr_process_received_tc, TC_MESSAGE, 1);
      }
- 
    else
      {
--- 68,71 ----
***************
*** 408,411 ****
--- 408,413 ----
      } 
    
+   olsr_prune_aliases(&message.mid_origaddr, message.mid_addr);
+ 
   forward:  
    olsr_forward_message(m, 
***************
*** 472,477 ****
    while(hna_tmp)
      {
!       olsr_update_hna_entry(&message.originator, &hna_tmp->net, &hna_tmp->netmask, (float)message.vtime); 
!       
        hna_tmp = hna_tmp->next;
      }
--- 474,484 ----
    while(hna_tmp)
      {
!       /* Don't add an HNA entry that we are advertising ourselves. */
!       if (!find_local_hna4_entry(&hna_tmp->net, hna_tmp->netmask.v4) &&
!           !find_local_hna6_entry(&hna_tmp->net, hna_tmp->netmask.v6))
!         {
!           olsr_update_hna_entry(&message.originator, &hna_tmp->net, &hna_tmp->netmask, (float)message.vtime);
!         } 
! 
        hna_tmp = hna_tmp->next;
      }
***************
*** 496,500 ****
  /**
   *Processes an list of neighbors from an incoming HELLO message.
!  *@param neighbor the neighbor who sendt the message.
   *@param message the HELLO message
   *@return nada
--- 503,507 ----
  /**
   *Processes an list of neighbors from an incoming HELLO message.
!  *@param neighbor the neighbor who sent the message.
   *@param message the HELLO message
   *@return nada
***************
*** 541,544 ****
--- 548,576 ----
                two_hop_neighbor_yet->neighbor_2_timer = GET_TIMESTAMP(message->vtime*1000);
                two_hop_neighbor = two_hop_neighbor_yet->neighbor_2;
+ 
+               // For link quality OLSR, reset the path link quality here.
+               // The path link quality will be calculated in the second pass, below.
+               // Keep the saved_path_link_quality for reference.
+ 
+               if (olsr_cnf->lq_level > 0)
+                 {
+                   // loop through the one-hop neighbors that see this
+                   // 'two_hop_neighbor'
+ 
+                   struct neighbor_list_entry *walker;
+ 
+                   for (walker = two_hop_neighbor->neighbor_2_nblist.next;
+                        walker != &two_hop_neighbor->neighbor_2_nblist;
+                        walker = walker->next)
+                     {
+                       // have we found the one-hop neighbor that sent the
+                       // HELLO message that we're current processing?
+ 
+                       if (walker->neighbor == neighbor)
+                         {
+                           walker->path_link_quality = 0.0;
+                         }
+                     }
+                 }
              }
            else
***************
*** 588,604 ****
                  }
              }
  
!           if (olsr_cnf->lq_level > 0)
              {
! 	      struct neighbor_list_entry *walker;
! 	      struct link_entry *link;
  
!               link = get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
  
! 	      if(!link)
! 		continue;
  
                // loop through the one-hop neighbors that see this
!               // two hop neighbour
  
                for (walker = two_hop_neighbor->neighbor_2_nblist.next;
--- 620,665 ----
                  }
              }
+         }
+     }
  
!   // Separate, second and third pass for link quality OLSR
! 
!   if (olsr_cnf->lq_level > 0)
!     {
!       struct link_entry *link =
!         get_best_link_to_neighbor(&neighbor->neighbor_main_addr);
! 
!       if(!link)
! 	return;
! 
!       // Second pass for link quality OLSR: calculate the best 2-hop
!       // path costs to all the 2-hop neighbors indicated in the
!       // HELLO message. Since the same 2-hop neighbor may be listed
!       // more than once in the same HELLO message (each at a possibly
!       // different quality) we want to select only the best one, not just
!       // the last one listed in the HELLO message.
! 
!       for(message_neighbors = message->neighbors;
!           message_neighbors != NULL;
!           message_neighbors = message_neighbors->next)
!         {
!           if(if_ifwithaddr(&message_neighbors->address) != NULL)
!             continue;
! 
!           if(((message_neighbors->status == SYM_NEIGH) ||
!               (message_neighbors->status == MPR_NEIGH)))
              {
!               struct neighbor_list_entry *walker;
!               struct neighbor_2_entry *two_hop_neighbor;
!               struct neighbor_2_list_entry *two_hop_neighbor_yet =
!                 olsr_lookup_my_neighbors(neighbor, &message_neighbors->address);
  
!               if(!two_hop_neighbor_yet)
!                 continue;
  
!               two_hop_neighbor = two_hop_neighbor_yet->neighbor_2;
  
                // loop through the one-hop neighbors that see this
!               // 'two_hop_neighbor'
  
                for (walker = two_hop_neighbor->neighbor_2_nblist.next;
***************
*** 611,622 ****
                    if (walker->neighbor == neighbor)
                      {
!                       double saved_lq, rel_lq;
! 
!                       // saved previous total link quality
! 
!                       saved_lq = walker->saved_path_link_quality;
! 
!                       if (saved_lq == 0.0)
!                         saved_lq = -1.0;
  
                        // path link quality = link quality between us
--- 672,676 ----
                    if (walker->neighbor == neighbor)
                      {
!                       double new_second_hop_link_quality, new_path_link_quality;
  
                        // path link quality = link quality between us
***************
*** 635,639 ****
                        // 2-hop neighbour
  
!                       walker->second_hop_link_quality =
                          message_neighbors->link_quality *
                          message_neighbors->neigh_link_quality;
--- 689,693 ----
                        // 2-hop neighbour
  
!                       new_second_hop_link_quality = 
                          message_neighbors->link_quality *
                          message_neighbors->neigh_link_quality;
***************
*** 642,650 ****
                        // "us --- 1-hop --- 2-hop"
  
!                       walker->path_link_quality =
!                         walker->second_hop_link_quality *
                          link->loss_link_quality * link->neigh_link_quality;
  
!                       // if the link quality has changed by more than 10
                        // percent, signal
  
--- 696,761 ----
                        // "us --- 1-hop --- 2-hop"
  
!                       new_path_link_quality =
!                         new_second_hop_link_quality *
                          link->loss_link_quality * link->neigh_link_quality;
  
!                       // Only copy the link quality if it is better than what we have
!                       // for this 2-hop neighbor
!                       if (new_path_link_quality > walker->path_link_quality)
!                         {
!                           walker->second_hop_link_quality = new_second_hop_link_quality;
!                           walker->path_link_quality = new_path_link_quality;
!                         }
!                     }
!                 }
!             }
!         }
! 
!       // Third pass for link quality OLSR: check if the 2-hop path qualities have
!       // actually changed. If so, signal this through the 'changes_neighborhood'
!       // and 'changes_topology' booleans. Keep a 'saved_path_link_quality' for
!       // later reference.
!       for(message_neighbors = message->neighbors;
!           message_neighbors != NULL;
!           message_neighbors = message_neighbors->next)
!         {
!           if(if_ifwithaddr(&message_neighbors->address) != NULL)
!             continue;
! 
!           if(((message_neighbors->status == SYM_NEIGH) ||
!               (message_neighbors->status == MPR_NEIGH)))
!             {
!               struct neighbor_list_entry *walker;
!               struct neighbor_2_entry *two_hop_neighbor;
!               struct neighbor_2_list_entry *two_hop_neighbor_yet =
!                 olsr_lookup_my_neighbors(neighbor, &message_neighbors->address);
! 
!               if(!two_hop_neighbor_yet)
!                 continue;
! 
!               two_hop_neighbor = two_hop_neighbor_yet->neighbor_2;
! 
!               // loop through the one-hop neighbors that see this
!               // 'two_hop_neighbor'
! 
!               for (walker = two_hop_neighbor->neighbor_2_nblist.next;
!                    walker != &two_hop_neighbor->neighbor_2_nblist;
!                    walker = walker->next)
!                 {
!                   // have we found the one-hop neighbor that sent the
!                   // HELLO message that we're current processing?
! 
!                   if (walker->neighbor == neighbor)
!                     {
!                       double saved_lq, rel_lq;
! 
!                       // saved previous total link quality
! 
!                       saved_lq = walker->saved_path_link_quality;
! 
!                       if (saved_lq == 0.0)
!                         saved_lq = -1.0;
! 
!                       // if the link cost has changed by more than 10
                        // percent, signal
  

Index: local_hna_set.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/local_hna_set.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** local_hna_set.h	20 Feb 2005 18:52:18 -0000	1.9
--- local_hna_set.h	10 Feb 2007 19:27:32 -0000	1.10
***************
*** 59,62 ****
--- 59,68 ----
  remove_local_hna6_entry(union olsr_ip_addr *, olsr_u16_t);
  
+ struct hna4_entry *
+ find_local_hna4_entry(union olsr_ip_addr *net, olsr_u32_t mask);
+ 
+ struct hna6_entry *
+ find_local_hna6_entry(union olsr_ip_addr *net, olsr_u16_t prefix_len);
+ 
  int
  check_inet_gw(void);





More information about the Olsr-cvs mailing list