[Olsr-cvs] olsrd-current/src process_package.h, 1.14, 1.15 process_package.c, 1.45, 1.46

Bernd Petrovitsch (spam-protected)
Sun Nov 18 23:28:37 CET 2007


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

Modified Files:
	process_package.h process_package.c 
Log Message:
- olsr_process_message_neighbors is now a static function and called process_message_neighbors
- olsr_linking_this_2_entries is now a static function and called  linking_this_2_entries
- lookup_mpr_status() is now a static function
All of them are defined at the to allow automatic inlining.


Index: process_package.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_package.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** process_package.h	16 Nov 2007 21:43:55 -0000	1.14
--- process_package.h	18 Nov 2007 22:28:35 -0000	1.15
***************
*** 63,74 ****
  olsr_process_received_hna(union olsr_message *, struct interface *, union olsr_ip_addr *);
  
- void
- olsr_process_message_neighbors(struct neighbor_entry *,struct hello_message *);
- 
- void
- olsr_linking_this_2_entries(struct neighbor_entry *,struct neighbor_2_entry *, float);
- 
- int
- olsr_lookup_mpr_status(struct hello_message *, struct interface *);
- 
  #endif
--- 63,65 ----

Index: process_package.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_package.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** process_package.c	16 Nov 2007 21:43:55 -0000	1.45
--- process_package.c	18 Nov 2007 22:28:35 -0000	1.46
***************
*** 57,368 ****
  #include "net_olsr.h"
  
  
! /**
!  *Initializing the parser functions we are using
!  */
! void
! olsr_init_package_process(void)
! {
!   if (olsr_cnf->lq_level == 0)
!     {
!       olsr_parser_add_function(&olsr_process_received_hello, HELLO_MESSAGE, 1);
!       olsr_parser_add_function(&olsr_input_tc, TC_MESSAGE, 1);
!     }
!   else
!     {
!       olsr_parser_add_function(&olsr_input_lq_hello, LQ_HELLO_MESSAGE, 1);
!       olsr_parser_add_function(&olsr_input_tc, LQ_TC_MESSAGE, 1);
!     }
! 
!   olsr_parser_add_function(&olsr_process_received_mid, MID_MESSAGE, 1);
!   olsr_parser_add_function(&olsr_process_received_hna, HNA_MESSAGE, 1);
! }
! 
! void
! olsr_hello_tap(struct hello_message *message,
!                struct interface *in_if,
!                const union olsr_ip_addr *from_addr)
! {
!   struct neighbor_entry     *neighbor;
! 
!   /*
!    * Update link status
!    */
!   struct link_entry *lnk = update_link_entry(&in_if->ip_addr, from_addr, message, in_if);
! 
!   if (olsr_cnf->lq_level > 0)
!     {
!       double saved_lq;
!       double rel_lq;
!       struct hello_neighbor *walker;
!       // just in case our neighbor has changed its HELLO interval
!       olsr_update_packet_loss_hello_int(lnk, message->htime);
! 
!       // find the input interface in the list of neighbor interfaces
! 
!       for (walker = message->neighbors; walker != NULL; walker = walker->next)
!         if (ipequal(&walker->address, &in_if->ip_addr))
!           break;
! 
!       // the current reference link quality
! 
!       saved_lq = lnk->saved_neigh_link_quality;
! 
!       if (saved_lq == 0.0)
!         saved_lq = -1.0;
! 
!       // memorize our neighbour's idea of the link quality, so that we
!       // know the link quality in both directions
! 
!       if (walker != NULL)
!         lnk->neigh_link_quality = walker->link_quality;
! 
!       else
!         lnk->neigh_link_quality = 0.0;
! 
!       // if the link quality has changed by more than 10 percent,
!       // print the new link quality table
! 
!       rel_lq = lnk->neigh_link_quality / saved_lq;
! 
!       if (rel_lq > 1.1 || rel_lq < 0.9)
!         {
!           lnk->saved_neigh_link_quality = lnk->neigh_link_quality;
! 
!           if (olsr_cnf->lq_dlimit > 0)
!           {
!             changes_neighborhood = OLSR_TRUE;
!             changes_topology = OLSR_TRUE;
!           }
! 
!           else
!             OLSR_PRINTF(3, "Skipping Dijkstra (2)\n");
! 
!           // create a new ANSN
! 
!           // XXX - we should check whether we actually
!           // announce this neighbour
! 
! 	  signal_link_changes(OLSR_TRUE);
!         }
!     }
!   
!   neighbor = lnk->neighbor;
! 
!   /*
!    * Hysteresis
!    */
!   if(olsr_cnf->use_hysteresis)
!     {
!       /* Update HELLO timeout */
!       //printf("MESSAGE HTIME: %f\n", message->htime);
!       olsr_update_hysteresis_hello(lnk, message->htime);
!     }
! 
!   /* Check if we are chosen as MPR */
!   if(olsr_lookup_mpr_status(message, in_if))
!     /* source_addr is always the main addr of a node! */
!     olsr_update_mprs_set(&message->source_addr, message->vtime);
! 
! 
! 
!   /* Check willingness */
!   if(neighbor->willingness != message->willingness)
!     {
! #ifndef NODEBUG
!       struct ipaddr_str buf;
! #endif
!       OLSR_PRINTF(1, "Willingness for %s changed from %d to %d - UPDATING\n", 
! 		  olsr_ip_to_string(&buf, &neighbor->neighbor_main_addr),
! 		  neighbor->willingness,
! 		  message->willingness);
!       /*
!        *If willingness changed - recalculate
!        */
!       neighbor->willingness = message->willingness;
!       changes_neighborhood = OLSR_TRUE;
!       changes_topology = OLSR_TRUE;
!     }
! 
! 
!   /* Don't register neighbors of neighbors that announces WILL_NEVER */
!   if(neighbor->willingness != WILL_NEVER)
!     olsr_process_message_neighbors(neighbor, message);
! 
!   /* Process changes immedeatly in case of MPR updates */
!   olsr_process_changes();
! 
!   olsr_free_hello_packet(message);
! 
!   return;
! }
! 
! /**
!  *Processes a received HELLO message. 
!  *
!  *@param m the incoming OLSR message
!  *@return 0 on sucess
!  */
! 
! void
! olsr_process_received_hello(union olsr_message *m,
!                             struct interface *in_if,
!                             union olsr_ip_addr *from_addr)
! {
!   struct hello_message      message;
! 
!   hello_chgestruct(&message, m);
! 
!   if(!olsr_validate_address(&message.source_addr))
!     {
!       olsr_free_hello_packet(&message);
!       return;
!     }
! 
!   olsr_hello_tap(&message, in_if, from_addr);
! }
! 
! /**
!  *Process a received(and parsed) MID message
!  *For every address check if there is a topology node
!  *registered with it and update its addresses.
!  *
!  *@param m the OLSR message received.
!  *@return 1 on success
!  */
! 
! void
! olsr_process_received_mid(union olsr_message *m,
!                           struct interface *in_if,
!                           union olsr_ip_addr *from_addr)
! {
! #if !defined(NODEBUG) && defined(DEBUG)
!   struct ipaddr_str buf;
! #endif
!   struct mid_alias *tmp_adr;
!   struct mid_message message;
! 
!   mid_chgestruct(&message, m);
! 
!   if (!olsr_validate_address(&message.mid_origaddr)) {
!     olsr_free_mid_packet(&message);
!     return;
!   }
! 
!   if (olsr_check_dup_table_proc(&message.mid_origaddr, 
!                                 message.mid_seqno)) {
! 
! #ifdef DEBUG
!     OLSR_PRINTF(5, "Processing MID from %s...\n", olsr_ip_to_string(&buf, &message.mid_origaddr));
! #endif
!     tmp_adr = message.mid_addr;
! 
!     /*
!      *      If the sender interface (NB: not originator) of this message
!      *      is not in the symmetric 1-hop neighborhood of this node, the
!      *      message MUST be discarded.
!      */
! 
!     if(check_neighbor_link(from_addr) != SYM_LINK) {
! #ifndef NODEBUG
!       struct ipaddr_str buf;
! #endif
!       OLSR_PRINTF(2, "Received MID from NON SYM neighbor %s\n", olsr_ip_to_string(&buf, from_addr));
!       olsr_free_mid_packet(&message);
!       return;
!     }
! 
!     /* Update the timeout of the MID */
!     olsr_update_mid_table(&message.mid_origaddr, (float)message.vtime);
! 
!     while (tmp_adr) {
!       if (!mid_lookup_main_addr(&tmp_adr->alias_addr)){
! #ifndef NODEBUG
!         struct ipaddr_str buf;
! #endif
!         OLSR_PRINTF(1, "MID new: (%s, ", olsr_ip_to_string(&buf, &message.mid_origaddr));
!         OLSR_PRINTF(1, "%s)\n", olsr_ip_to_string(&buf, &tmp_adr->alias_addr));
!         insert_mid_alias(&message.mid_origaddr, &tmp_adr->alias_addr, (float)message.vtime);
!       }
!       tmp_adr = tmp_adr->next;
!     } 
!   
!     olsr_prune_aliases(&message.mid_origaddr, message.mid_addr);
!   }
! 
!   olsr_forward_message(m, 
! 		       &message.mid_origaddr, 
! 		       message.mid_seqno, 
! 		       in_if,
! 		       from_addr);
!   olsr_free_mid_packet(&message);
! }
! 
! 
! /**
!  *Process incoming HNA message.
!  *Forwards the message if that is to be done.
!  *
!  *@param m the incoming OLSR message
!  *the OLSR message.
!  *@return 1 on success
!  */
! 
! void
! olsr_process_received_hna(union olsr_message *m,
!                           struct interface *in_if,
!                           union olsr_ip_addr *from_addr)
! {
!   struct hna_net_addr  *hna_tmp;
!   struct  hna_message message;
! 
! #ifdef DEBUG
!   OLSR_PRINTF(5, "Processing HNA\n");
! #endif
! 
!   hna_chgestruct(&message, m);
! 
!   if(!olsr_validate_address(&message.originator)) {
!     olsr_free_hna_packet(&message);
!     return;
!   }
! 
!   if (olsr_check_dup_table_proc(&message.originator, 
!                                 message.packet_seq_number)) {
! 
!     hna_tmp = message.hna_net;
! 
!     /*
!      *      If the sender interface (NB: not originator) of this message
!      *      is not in the symmetric 1-hop neighborhood of this node, the
!      *      message MUST be discarded.
!      */
!     if(check_neighbor_link(from_addr) != SYM_LINK) {
! #ifndef NODEBUG
!       struct ipaddr_str buf;
! #endif
!       OLSR_PRINTF(2, "Received HNA from NON SYM neighbor %s\n", olsr_ip_to_string(&buf, from_addr));
!       olsr_free_hna_packet(&message);
!       return;
!     }
  
!     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;
-     }
-   }
- 
-   olsr_forward_message(m, 
- 		       &message.originator, 
- 		       message.packet_seq_number, 
- 		       in_if,
- 		       from_addr);
-   olsr_free_hna_packet(&message);
- }
  
  /**
--- 57,66 ----
  #include "net_olsr.h"
  
+ static void process_message_neighbors(struct neighbor_entry *, const struct hello_message *);
  
! static void linking_this_2_entries(struct neighbor_entry *, struct neighbor_2_entry *, float);
  
! static int lookup_mpr_status(const struct hello_message *, const struct interface *);
  
  
  /**
***************
*** 372,378 ****
   *@return nada
   */
! void
! olsr_process_message_neighbors(struct neighbor_entry *neighbor,
!                                struct hello_message *message)
  {
    struct hello_neighbor        *message_neighbors;
--- 70,75 ----
   *@return nada
   */
! static void
! process_message_neighbors(struct neighbor_entry *neighbor, const struct hello_message *message)
  {
    struct hello_neighbor        *message_neighbors;
***************
*** 474,478 ****
                    olsr_insert_two_hop_neighbor_table(two_hop_neighbor);
  
!                   olsr_linking_this_2_entries(neighbor, two_hop_neighbor, (float)message->vtime);
                  }
                else
--- 171,175 ----
                    olsr_insert_two_hop_neighbor_table(two_hop_neighbor);
  
!                   linking_this_2_entries(neighbor, two_hop_neighbor, message->vtime);
                  }
                else
***************
*** 484,488 ****
                    changes_topology = OLSR_TRUE;
  		  
!                   olsr_linking_this_2_entries(neighbor, two_hop_neighbor, (float)message->vtime); 
                  }
              }
--- 181,185 ----
                    changes_topology = OLSR_TRUE;
  		  
!                   linking_this_2_entries(neighbor, two_hop_neighbor, message->vtime); 
                  }
              }
***************
*** 650,660 ****
  }
  
- 
- 
- 
- 
- 
- 
- 
  /**
   *Links a one-hop neighbor with a 2-hop neighbor.
--- 347,350 ----
***************
*** 664,676 ****
   *@return nada
   */
! void
! olsr_linking_this_2_entries(struct neighbor_entry *neighbor,struct neighbor_2_entry *two_hop_neighbor, float vtime)
  {
!   struct neighbor_list_entry    *list_of_1_neighbors;
!   struct neighbor_2_list_entry  *list_of_2_neighbors;
! 
!   list_of_1_neighbors = olsr_malloc(sizeof(struct neighbor_list_entry), "Link entries 1");
! 
!   list_of_2_neighbors = olsr_malloc(sizeof(struct neighbor_2_list_entry), "Link entries 2");
  
    list_of_1_neighbors->neighbor = neighbor;
--- 354,362 ----
   *@return nada
   */
! static void
! linking_this_2_entries(struct neighbor_entry *neighbor, struct neighbor_2_entry *two_hop_neighbor, float vtime)
  {
!   struct neighbor_list_entry    *list_of_1_neighbors = olsr_malloc(sizeof(struct neighbor_list_entry), "Link entries 1");
!   struct neighbor_2_list_entry  *list_of_2_neighbors = olsr_malloc(sizeof(struct neighbor_2_list_entry), "Link entries 2");
  
    list_of_1_neighbors->neighbor = neighbor;
***************
*** 683,690 ****
    two_hop_neighbor->neighbor_2_nblist.next->prev = list_of_1_neighbors;
    list_of_1_neighbors->next = two_hop_neighbor->neighbor_2_nblist.next;
    two_hop_neighbor->neighbor_2_nblist.next = list_of_1_neighbors;
    list_of_1_neighbors->prev = &two_hop_neighbor->neighbor_2_nblist;
- 
- 
    list_of_2_neighbors->neighbor_2 = two_hop_neighbor;
    
--- 369,375 ----
    two_hop_neighbor->neighbor_2_nblist.next->prev = list_of_1_neighbors;
    list_of_1_neighbors->next = two_hop_neighbor->neighbor_2_nblist.next;
+ 
    two_hop_neighbor->neighbor_2_nblist.next = list_of_1_neighbors;
    list_of_1_neighbors->prev = &two_hop_neighbor->neighbor_2_nblist;
    list_of_2_neighbors->neighbor_2 = two_hop_neighbor;
    
***************
*** 701,709 ****
  }
  
- 
- 
- 
- 
- 
  /**
   *Check if a hello message states this node as a MPR.
--- 386,389 ----
***************
*** 715,759 ****
   *@return 1 if we are selected as MPR 0 if not
   */
! int
! olsr_lookup_mpr_status(struct hello_message *message, struct interface *in_if)
  {
    
!   struct hello_neighbor  *neighbors = message->neighbors;
!   
!   while(neighbors!=NULL)
!     {  
!       //printf("(linkstatus)Checking %s ",olsr_ip_to_string(&buf, &neighbors->address));
!       //printf("against %s\n",olsr_ip_to_string(&buf, &main_addr));
  
  
!     if(olsr_cnf->ip_version == AF_INET)
!       {	
! 	/* IPv4 */  
! 	if(ip4equal(&neighbors->address.v4, &in_if->ip_addr.v4))
! 	  {
! 	    //printf("ok");
! 	    if((neighbors->link == SYM_LINK) && (neighbors->status == MPR_NEIGH))
! 	      return 1;
! 	    
! 	    return 0;
! 	  }
        }
!     else
!       {	
! 	/* IPv6 */  
! 	if(ip6equal(&neighbors->address.v6, &in_if->int6_addr.sin6_addr))
! 	  {
! 	    //printf("ok");
! 	    if((neighbors->link == SYM_LINK) && (neighbors->status == MPR_NEIGH))
! 	      return 1;
! 	    
! 	    return 0;
! 	  }
        }
!  
!       neighbors = neighbors->next; 
      }
  
!   /* Not found */
!   return 0;
  }
--- 395,726 ----
   *@return 1 if we are selected as MPR 0 if not
   */
! static int
! lookup_mpr_status(const struct hello_message *message, const struct interface *in_if)
! {  
!   struct hello_neighbor  *neighbors; 
!   for (neighbors = message->neighbors; neighbors != NULL; neighbors = neighbors->next) {
!     //printf("(linkstatus)Checking %s ",olsr_ip_to_string(&buf, &neighbors->address));
!     //printf("against %s\n",olsr_ip_to_string(&buf, &main_addr));
! 
!     if (olsr_cnf->ip_version == AF_INET
!               ? /* IPv4 */ ip4equal(&neighbors->address.v4, &in_if->ip_addr.v4)
!               : /* IPv6 */ ip6equal(&neighbors->address.v6, &in_if->int6_addr.sin6_addr)) {
!       //printf("ok");
!       if (neighbors->link == SYM_LINK && neighbors->status == MPR_NEIGH) {
!         return 1;
!       }
!       break;
!     }
!   }
!   /* Not found */
!   return 0;
! }
! 
! 
! /**
!  *Initializing the parser functions we are using
!  */
! void
! olsr_init_package_process(void)
  {
+   if (olsr_cnf->lq_level == 0)
+     {
+       olsr_parser_add_function(&olsr_process_received_hello, HELLO_MESSAGE, 1);
+       olsr_parser_add_function(&olsr_input_tc, TC_MESSAGE, 1);
+     }
+   else
+     {
+       olsr_parser_add_function(&olsr_input_lq_hello, LQ_HELLO_MESSAGE, 1);
+       olsr_parser_add_function(&olsr_input_tc, LQ_TC_MESSAGE, 1);
+     }
+ 
+   olsr_parser_add_function(&olsr_process_received_mid, MID_MESSAGE, 1);
+   olsr_parser_add_function(&olsr_process_received_hna, HNA_MESSAGE, 1);
+ }
+ 
+ void
+ olsr_hello_tap(struct hello_message *message,
+                struct interface *in_if,
+                const union olsr_ip_addr *from_addr)
+ {
+   struct neighbor_entry     *neighbor;
+ 
+   /*
+    * Update link status
+    */
+   struct link_entry *lnk = update_link_entry(&in_if->ip_addr, from_addr, message, in_if);
+ 
+   if (olsr_cnf->lq_level > 0)
+     {
+       double saved_lq;
+       double rel_lq;
+       struct hello_neighbor *walker;
+       // just in case our neighbor has changed its HELLO interval
+       olsr_update_packet_loss_hello_int(lnk, message->htime);
+ 
+       // find the input interface in the list of neighbor interfaces
+ 
+       for (walker = message->neighbors; walker != NULL; walker = walker->next)
+         if (ipequal(&walker->address, &in_if->ip_addr))
+           break;
+ 
+       // the current reference link quality
+ 
+       saved_lq = lnk->saved_neigh_link_quality;
+ 
+       if (saved_lq == 0.0)
+         saved_lq = -1.0;
+ 
+       // memorize our neighbour's idea of the link quality, so that we
+       // know the link quality in both directions
+ 
+       if (walker != NULL)
+         lnk->neigh_link_quality = walker->link_quality;
+ 
+       else
+         lnk->neigh_link_quality = 0.0;
+ 
+       // if the link quality has changed by more than 10 percent,
+       // print the new link quality table
+ 
+       rel_lq = lnk->neigh_link_quality / saved_lq;
+ 
+       if (rel_lq > 1.1 || rel_lq < 0.9)
+         {
+           lnk->saved_neigh_link_quality = lnk->neigh_link_quality;
+ 
+           if (olsr_cnf->lq_dlimit > 0)
+           {
+             changes_neighborhood = OLSR_TRUE;
+             changes_topology = OLSR_TRUE;
+           }
+ 
+           else
+             OLSR_PRINTF(3, "Skipping Dijkstra (2)\n");
+ 
+           // create a new ANSN
+ 
+           // XXX - we should check whether we actually
+           // announce this neighbour
+ 
+ 	  signal_link_changes(OLSR_TRUE);
+         }
+     }
    
!   neighbor = lnk->neighbor;
  
+   /*
+    * Hysteresis
+    */
+   if(olsr_cnf->use_hysteresis)
+     {
+       /* Update HELLO timeout */
+       //printf("MESSAGE HTIME: %f\n", message->htime);
+       olsr_update_hysteresis_hello(lnk, message->htime);
+     }
  
!   /* Check if we are chosen as MPR */
!   if(lookup_mpr_status(message, in_if))
!     /* source_addr is always the main addr of a node! */
!     olsr_update_mprs_set(&message->source_addr, message->vtime);
! 
! 
! 
!   /* Check willingness */
!   if(neighbor->willingness != message->willingness)
!     {
! #ifndef NODEBUG
!       struct ipaddr_str buf;
! #endif
!       OLSR_PRINTF(1, "Willingness for %s changed from %d to %d - UPDATING\n", 
! 		  olsr_ip_to_string(&buf, &neighbor->neighbor_main_addr),
! 		  neighbor->willingness,
! 		  message->willingness);
!       /*
!        *If willingness changed - recalculate
!        */
!       neighbor->willingness = message->willingness;
!       changes_neighborhood = OLSR_TRUE;
!       changes_topology = OLSR_TRUE;
!     }
! 
! 
!   /* Don't register neighbors of neighbors that announces WILL_NEVER */
!   if(neighbor->willingness != WILL_NEVER)
!     process_message_neighbors(neighbor, message);
! 
!   /* Process changes immedeatly in case of MPR updates */
!   olsr_process_changes();
! 
!   olsr_free_hello_packet(message);
! 
!   return;
! }
! 
! /**
!  *Processes a received HELLO message. 
!  *
!  *@param m the incoming OLSR message
!  *@return 0 on sucess
!  */
! 
! void
! olsr_process_received_hello(union olsr_message *m,
!                             struct interface *in_if,
!                             union olsr_ip_addr *from_addr)
! {
!   struct hello_message      message;
! 
!   hello_chgestruct(&message, m);
! 
!   if(!olsr_validate_address(&message.source_addr))
!     {
!       olsr_free_hello_packet(&message);
!       return;
!     }
! 
!   olsr_hello_tap(&message, in_if, from_addr);
! }
! 
! /**
!  *Process a received(and parsed) MID message
!  *For every address check if there is a topology node
!  *registered with it and update its addresses.
!  *
!  *@param m the OLSR message received.
!  *@return 1 on success
!  */
! 
! void
! olsr_process_received_mid(union olsr_message *m,
!                           struct interface *in_if,
!                           union olsr_ip_addr *from_addr)
! {
! #if !defined(NODEBUG) && defined(DEBUG)
!   struct ipaddr_str buf;
! #endif
!   struct mid_alias *tmp_adr;
!   struct mid_message message;
! 
!   mid_chgestruct(&message, m);
! 
!   if (!olsr_validate_address(&message.mid_origaddr)) {
!     olsr_free_mid_packet(&message);
!     return;
!   }
! 
!   if (olsr_check_dup_table_proc(&message.mid_origaddr, 
!                                 message.mid_seqno)) {
! 
! #ifdef DEBUG
!     OLSR_PRINTF(5, "Processing MID from %s...\n", olsr_ip_to_string(&buf, &message.mid_origaddr));
! #endif
!     tmp_adr = message.mid_addr;
! 
!     /*
!      *      If the sender interface (NB: not originator) of this message
!      *      is not in the symmetric 1-hop neighborhood of this node, the
!      *      message MUST be discarded.
!      */
! 
!     if(check_neighbor_link(from_addr) != SYM_LINK) {
! #ifndef NODEBUG
!       struct ipaddr_str buf;
! #endif
!       OLSR_PRINTF(2, "Received MID from NON SYM neighbor %s\n", olsr_ip_to_string(&buf, from_addr));
!       olsr_free_mid_packet(&message);
!       return;
!     }
! 
!     /* Update the timeout of the MID */
!     olsr_update_mid_table(&message.mid_origaddr, (float)message.vtime);
! 
!     while (tmp_adr) {
!       if (!mid_lookup_main_addr(&tmp_adr->alias_addr)){
! #ifndef NODEBUG
!         struct ipaddr_str buf;
! #endif
!         OLSR_PRINTF(1, "MID new: (%s, ", olsr_ip_to_string(&buf, &message.mid_origaddr));
!         OLSR_PRINTF(1, "%s)\n", olsr_ip_to_string(&buf, &tmp_adr->alias_addr));
!         insert_mid_alias(&message.mid_origaddr, &tmp_adr->alias_addr, (float)message.vtime);
        }
!       tmp_adr = tmp_adr->next;
!     } 
!   
!     olsr_prune_aliases(&message.mid_origaddr, message.mid_addr);
!   }
! 
!   olsr_forward_message(m, 
! 		       &message.mid_origaddr, 
! 		       message.mid_seqno, 
! 		       in_if,
! 		       from_addr);
!   olsr_free_mid_packet(&message);
! }
! 
! 
! /**
!  *Process incoming HNA message.
!  *Forwards the message if that is to be done.
!  *
!  *@param m the incoming OLSR message
!  *the OLSR message.
!  *@return 1 on success
!  */
! 
! void
! olsr_process_received_hna(union olsr_message *m,
!                           struct interface *in_if,
!                           union olsr_ip_addr *from_addr)
! {
!   struct hna_net_addr  *hna_tmp;
!   struct  hna_message message;
! 
! #ifdef DEBUG
!   OLSR_PRINTF(5, "Processing HNA\n");
! #endif
! 
!   hna_chgestruct(&message, m);
! 
!   if(!olsr_validate_address(&message.originator)) {
!     olsr_free_hna_packet(&message);
!     return;
!   }
! 
!   if (olsr_check_dup_table_proc(&message.originator, 
!                                 message.packet_seq_number)) {
! 
!     hna_tmp = message.hna_net;
! 
!     /*
!      *      If the sender interface (NB: not originator) of this message
!      *      is not in the symmetric 1-hop neighborhood of this node, the
!      *      message MUST be discarded.
!      */
!     if(check_neighbor_link(from_addr) != SYM_LINK) {
! #ifndef NODEBUG
!       struct ipaddr_str buf;
! #endif
!       OLSR_PRINTF(2, "Received HNA from NON SYM neighbor %s\n", olsr_ip_to_string(&buf, from_addr));
!       olsr_free_hna_packet(&message);
!       return;
!     }
! 
!     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;
      }
+   }
  
!   olsr_forward_message(m, 
! 		       &message.originator, 
! 		       message.packet_seq_number, 
! 		       in_if,
! 		       from_addr);
!   olsr_free_hna_packet(&message);
  }





More information about the Olsr-cvs mailing list