renames in the nbr2 code, preparation for neighbor2 refactoring
authorHannes Gredler <hannes@gredler.at>
Wed, 27 May 2009 07:05:07 +0000 (09:05 +0200)
committerHannes Gredler <hannes@gredler.at>
Wed, 27 May 2009 07:05:07 +0000 (09:05 +0200)
lib/httpinfo/src/olsrd_httpinfo.c
src/lq_mpr.c
src/mid_set.c
src/mpr.c
src/neighbor_table.c
src/neighbor_table.h
src/process_package.c
src/two_hop_neighbor_table.c
src/two_hop_neighbor_table.h

index ef348fd..6feb0b1 100644 (file)
@@ -972,7 +972,7 @@ build_neigh_body(struct autobuf *abuf)
     thop_cnt = 0;
     OLSR_FOR_ALL_NBR2_LIST_ENTRIES(neigh, list_2) {
       struct ipaddr_str strbuf;
-      abuf_appendf(abuf, "<option>%s</option>\n", olsr_ip_to_string(&strbuf, &list_2->neighbor_2->neighbor_2_addr));
+      abuf_appendf(abuf, "<option>%s</option>\n", olsr_ip_to_string(&strbuf, &list_2->nbr2->nbr2_addr));
       thop_cnt++;
     } OLSR_FOR_ALL_NBR2_LIST_ENTRIES_END(neigh, list_2);
     abuf_appendf(abuf, "</select> (%d)</td></tr>\n", thop_cnt);
index 0fa4c50..2f02309 100644 (file)
@@ -50,8 +50,8 @@
 void
 olsr_calculate_lq_mpr(void)
 {
-  struct neighbor_2_entry *neigh2;
-  struct neighbor_list_entry *walker;
+  struct nbr2_entry *neigh2;
+  struct nbr_list_entry *walker;
   int i, k;
   struct nbr_entry *neigh;
   olsr_linkcost best, best_1hop;
@@ -90,7 +90,7 @@ olsr_calculate_lq_mpr(void)
 
       /* check whether this 2-hop neighbour is also a neighbour */
 
-      neigh = olsr_lookup_nbr_entry(&neigh2->neighbor_2_addr);
+      neigh = olsr_lookup_nbr_entry(&neigh2->nbr2_addr);
 
       /* if it's a neighbour and also symmetric, then examine
          the link quality */
@@ -111,7 +111,7 @@ olsr_calculate_lq_mpr(void)
 
         /* see wether we find a better route via an MPR */
 
-        for (walker = neigh2->neighbor_2_nblist.next; walker != &neigh2->neighbor_2_nblist; walker = walker->next)
+        for (walker = neigh2->nbr2_nblist.next; walker != &neigh2->nbr2_nblist; walker = walker->next)
           if (walker->path_linkcost < best_1hop)
             break;
 
@@ -119,7 +119,7 @@ olsr_calculate_lq_mpr(void)
          * a better route via an MPR - so, skip MPR selection for
          * this 1-hop neighbor */
 
-        if (walker == &neigh2->neighbor_2_nblist)
+        if (walker == &neigh2->nbr2_nblist)
           continue;
       }
 
@@ -128,7 +128,7 @@ olsr_calculate_lq_mpr(void)
 
       /* mark all 1-hop neighbours as not selected */
 
-      for (walker = neigh2->neighbor_2_nblist.next; walker != &neigh2->neighbor_2_nblist; walker = walker->next)
+      for (walker = neigh2->nbr2_nblist.next; walker != &neigh2->nbr2_nblist; walker = walker->next)
         walker->neighbor->skip = false;
 
       for (k = 0; k < olsr_cnf->mpr_coverage; k++) {
@@ -138,7 +138,7 @@ olsr_calculate_lq_mpr(void)
         neigh = NULL;
         best = LINK_COST_BROKEN;
 
-        for (walker = neigh2->neighbor_2_nblist.next; walker != &neigh2->neighbor_2_nblist; walker = walker->next)
+        for (walker = neigh2->nbr2_nblist.next; walker != &neigh2->nbr2_nblist; walker = walker->next)
           if (walker->neighbor->status == SYM && !walker->neighbor->skip && walker->path_linkcost < best) {
             neigh = walker->neighbor;
             best = walker->path_linkcost;
index 55d0853..890ecb6 100644 (file)
@@ -128,7 +128,7 @@ olsr_flush_nbr2_duplicates(struct mid_entry *alias)
 
   OLSR_FOR_ALL_TC_MID_ENTRIES(tc, alias) {
     struct nbr_entry *nbr;
-    struct neighbor_2_entry *nbr2 = olsr_lookup_two_hop_neighbor_table_mid(&alias->mid_alias_addr);
+    struct nbr2_entry *nbr2 = olsr_lookup_two_hop_neighbor_table_mid(&alias->mid_alias_addr);
 
     /* Delete possible 2 hop neighbor */
     if (nbr2) {
index 40b32c0..c5ddf87 100644 (file)
--- a/src/mpr.c
+++ b/src/mpr.c
@@ -76,7 +76,7 @@ static int olsr_chosen_mpr(struct nbr_entry *, uint16_t *);
 static int
 olsr_chosen_mpr(struct nbr_entry *one_hop_neighbor, uint16_t * two_hop_covered_count)
 {
-  struct neighbor_list_entry *the_one_hop_list;
+  struct nbr_list_entry *the_one_hop_list;
   struct nbr2_list_entry *second_hop_entries;
   struct nbr_entry *dup_neighbor;
   uint16_t count;
@@ -93,34 +93,34 @@ olsr_chosen_mpr(struct nbr_entry *one_hop_neighbor, uint16_t * two_hop_covered_c
 
   OLSR_FOR_ALL_NBR2_LIST_ENTRIES(one_hop_neighbor, second_hop_entries) {
 
-    dup_neighbor = olsr_lookup_nbr_entry(&second_hop_entries->neighbor_2->neighbor_2_addr);
+    dup_neighbor = olsr_lookup_nbr_entry(&second_hop_entries->nbr2->nbr2_addr);
 
     if ((dup_neighbor != NULL) && (dup_neighbor->status == SYM)) {
       OLSR_DEBUG(LOG_MPR, "(2)Skipping 2h neighbor %s - already 1hop\n",
-                 olsr_ip_to_string(&buf, &second_hop_entries->neighbor_2->neighbor_2_addr));
+                 olsr_ip_to_string(&buf, &second_hop_entries->nbr2->nbr2_addr));
       continue;
     }
-    //      if(!second_hop_entries->neighbor_2->neighbor_2_state)
-    //if(second_hop_entries->neighbor_2->mpr_covered_count < olsr_cnf->mpr_coverage)
+    //      if(!second_hop_entries->nbr2->nbr2_state)
+    //if(second_hop_entries->nbr2->mpr_covered_count < olsr_cnf->mpr_coverage)
     //{
     /*
        Now the neighbor is covered by this mpr
      */
-    second_hop_entries->neighbor_2->mpr_covered_count++;
-    the_one_hop_list = second_hop_entries->neighbor_2->neighbor_2_nblist.next;
+    second_hop_entries->nbr2->mpr_covered_count++;
+    the_one_hop_list = second_hop_entries->nbr2->nbr2_nblist.next;
 
     OLSR_DEBUG(LOG_MPR, "[%s] has coverage %d\n",
-               olsr_ip_to_string(&buf, &second_hop_entries->neighbor_2->neighbor_2_addr),
-               second_hop_entries->neighbor_2->mpr_covered_count);
+               olsr_ip_to_string(&buf, &second_hop_entries->nbr2->nbr2_addr),
+               second_hop_entries->nbr2->mpr_covered_count);
 
-    if (second_hop_entries->neighbor_2->mpr_covered_count >= olsr_cnf->mpr_coverage)
+    if (second_hop_entries->nbr2->mpr_covered_count >= olsr_cnf->mpr_coverage)
       count++;
 
-    while (the_one_hop_list != &second_hop_entries->neighbor_2->neighbor_2_nblist) {
+    while (the_one_hop_list != &second_hop_entries->nbr2->nbr2_nblist) {
 
       if ((the_one_hop_list->neighbor->status == SYM)) {
-        if (second_hop_entries->neighbor_2->mpr_covered_count >= olsr_cnf->mpr_coverage) {
-          the_one_hop_list->neighbor->neighbor_2_nocov--;
+        if (second_hop_entries->nbr2->mpr_covered_count >= olsr_cnf->mpr_coverage) {
+          the_one_hop_list->neighbor->nbr2_nocov--;
         }
       }
       the_one_hop_list = the_one_hop_list->next;
@@ -156,11 +156,11 @@ olsr_find_maximum_covered(int willingness)
 
     OLSR_DEBUG(LOG_MPR, "[%s] nocov: %d mpr: %d will: %d max: %d\n\n",
                olsr_ip_to_string(&buf, &a_neighbor->neighbor_main_addr),
-               a_neighbor->neighbor_2_nocov, a_neighbor->is_mpr, a_neighbor->willingness, maximum);
+               a_neighbor->nbr2_nocov, a_neighbor->is_mpr, a_neighbor->willingness, maximum);
 
-    if ((!a_neighbor->is_mpr) && (a_neighbor->willingness == willingness) && (maximum < a_neighbor->neighbor_2_nocov)) {
+    if ((!a_neighbor->is_mpr) && (a_neighbor->willingness == willingness) && (maximum < a_neighbor->nbr2_nocov)) {
 
-      maximum = a_neighbor->neighbor_2_nocov;
+      maximum = a_neighbor->nbr2_nocov;
       mpr_candidate = a_neighbor;
     }
   } OLSR_FOR_ALL_NBR_ENTRIES_END(a_neighbor);
@@ -188,7 +188,7 @@ olsr_clear_mprs(void)
 
     /* Clear two hop neighbors coverage count/ */
     OLSR_FOR_ALL_NBR2_LIST_ENTRIES(a_neighbor, two_hop_list) {
-      two_hop_list->neighbor_2->mpr_covered_count = 0;
+      two_hop_list->nbr2->mpr_covered_count = 0;
     } OLSR_FOR_ALL_NBR2_LIST_ENTRIES_END(a_neighbor, two_hop_list);
   } OLSR_FOR_ALL_NBR_ENTRIES_END(a_neighbor);
 }
@@ -232,10 +232,10 @@ olsr_clear_two_hop_processed(void)
   int idx;
 
   for (idx = 0; idx < HASHSIZE; idx++) {
-    struct neighbor_2_entry *neighbor_2;
-    for (neighbor_2 = two_hop_neighbortable[idx].next; neighbor_2 != &two_hop_neighbortable[idx]; neighbor_2 = neighbor_2->next) {
+    struct nbr2_entry *nbr2;
+    for (nbr2 = two_hop_neighbortable[idx].next; nbr2 != &two_hop_neighbortable[idx]; nbr2 = nbr2->next) {
       /* Clear */
-      neighbor_2->processed = 0;
+      nbr2->processed = 0;
     }
   }
 
@@ -260,22 +260,22 @@ olsr_calculate_two_hop_neighbors(void)
   OLSR_FOR_ALL_NBR_ENTRIES(a_neighbor) {
 
     if (a_neighbor->status == NOT_SYM) {
-      a_neighbor->neighbor_2_nocov = count;
+      a_neighbor->nbr2_nocov = count;
       continue;
     }
 
     OLSR_FOR_ALL_NBR2_LIST_ENTRIES(a_neighbor, twohop_neighbors) {
-      dup_neighbor = olsr_lookup_nbr_entry(&twohop_neighbors->neighbor_2->neighbor_2_addr);
+      dup_neighbor = olsr_lookup_nbr_entry(&twohop_neighbors->nbr2->nbr2_addr);
 
       if ((dup_neighbor == NULL) || (dup_neighbor->status != SYM)) {
         n_count++;
-        if (!twohop_neighbors->neighbor_2->processed) {
+        if (!twohop_neighbors->nbr2->processed) {
           count++;
-          twohop_neighbors->neighbor_2->processed = 1;
+          twohop_neighbors->nbr2->processed = 1;
         }
       }
     } OLSR_FOR_ALL_NBR2_LIST_ENTRIES_END(a_neighbor, twohop_neighbors);
-    a_neighbor->neighbor_2_nocov = n_count;
+    a_neighbor->nbr2_nocov = n_count;
 
     /* Add the two hop count */
     sum += count;
@@ -324,7 +324,7 @@ olsr_calculate_mpr(void)
   struct ipaddr_str buf;
 #endif
 
-  struct neighbor_2_entry *nbr2;
+  struct nbr2_entry *nbr2;
   struct nbr_entry *nbr;
   struct nbr_entry *mprs;
   uint16_t two_hop_covered_count;
@@ -350,28 +350,28 @@ olsr_calculate_mpr(void)
       /*
        * Eliminate 2 hop neighbors which already are in our 1 hop neighborhood.
        */
-      nbr = olsr_lookup_nbr_entry(&nbr2->neighbor_2_addr);
+      nbr = olsr_lookup_nbr_entry(&nbr2->nbr2_addr);
       if (nbr && (nbr->status != NOT_SYM)) {
         OLSR_DEBUG(LOG_MPR, "Skipping 2-hop neighbor2 %s - already 1hop\n",
-                   olsr_ip_to_string(&buf, &nbr2->neighbor_2_addr));
+                   olsr_ip_to_string(&buf, &nbr2->nbr2_addr));
         continue;
       }
 
       /*
        * Eliminate 2 hop neighbors which are not single link.
        */
-      if (nbr2->neighbor_2_pointer != 1) {
+      if (nbr2->nbr2_pointer != 1) {
         OLSR_DEBUG(LOG_MPR, "Skipping 2-hop neighbor %s - not single link\n",
-                   olsr_ip_to_string(&buf, &nbr2->neighbor_2_addr));
+                   olsr_ip_to_string(&buf, &nbr2->nbr2_addr));
         continue;
       }
 
-      nbr = nbr2->neighbor_2_nblist.next->neighbor;
+      nbr = nbr2->nbr2_nblist.next->neighbor;
 
       /* Already an elected MPR ? */
       if (nbr->is_mpr) {
         OLSR_DEBUG(LOG_MPR, "Skipping 2-hop neighbor %s - already MPR\n",
-                   olsr_ip_to_string(&buf, &nbr2->neighbor_2_addr));
+                   olsr_ip_to_string(&buf, &nbr2->nbr2_addr));
         continue;
       }
 
@@ -388,7 +388,7 @@ olsr_calculate_mpr(void)
       /*
        * This 2 hop neighbor is good enough.
        */
-      OLSR_DEBUG(LOG_MPR, "One link adding %s\n", olsr_ip_to_string(&buf, &nbr2->neighbor_2_addr));
+      OLSR_DEBUG(LOG_MPR, "One link adding %s\n", olsr_ip_to_string(&buf, &nbr2->nbr2_addr));
       olsr_chosen_mpr(nbr, &two_hop_covered_count);
 
     } OLSR_FOR_ALL_NBR2_ENTRIES_END(nbr2);
@@ -454,16 +454,16 @@ olsr_optimize_mpr_set(void)
         int remove_it = 1;
 
         OLSR_FOR_ALL_NBR2_LIST_ENTRIES(a_neighbor, two_hop_list) {
-          const struct nbr_entry *dup_neighbor = olsr_lookup_nbr_entry(&two_hop_list->neighbor_2->neighbor_2_addr);
+          const struct nbr_entry *dup_neighbor = olsr_lookup_nbr_entry(&two_hop_list->nbr2->nbr2_addr);
 
           if ((dup_neighbor != NULL) && (dup_neighbor->status != NOT_SYM)) {
             continue;
           }
 
-          OLSR_DEBUG(LOG_MPR, "\t[%s] coverage %d\n", olsr_ip_to_string(&buf, &two_hop_list->neighbor_2->neighbor_2_addr),
-                     two_hop_list->neighbor_2->mpr_covered_count);
+          OLSR_DEBUG(LOG_MPR, "\t[%s] coverage %d\n", olsr_ip_to_string(&buf, &two_hop_list->nbr2->nbr2_addr),
+                     two_hop_list->nbr2->mpr_covered_count);
           /* Do not remove if we find a entry which need this MPR */
-          if (two_hop_list->neighbor_2->mpr_covered_count <= olsr_cnf->mpr_coverage) {
+          if (two_hop_list->nbr2->mpr_covered_count <= olsr_cnf->mpr_coverage) {
             remove_it = 0;
             break;
           }
index df94a23..2b6a079 100644 (file)
@@ -85,20 +85,20 @@ olsr_init_neighbor_table(void)
  * Add a neighbor 2 reference to a neighbor.
  */
 struct nbr2_list_entry *
-olsr_add_nbr2_list_entry(struct nbr_entry *nbr, struct neighbor_2_entry *nbr2, float vtime)
+olsr_add_nbr2_list_entry(struct nbr_entry *nbr, struct nbr2_entry *nbr2, float vtime)
 {
   struct nbr2_list_entry *nbr2_list;
 
   /*
    * check first if the entry exists.
    */
-  nbr2_list = olsr_lookup_nbr2_list_entry(nbr, &nbr2->neighbor_2_addr);
+  nbr2_list = olsr_lookup_nbr2_list_entry(nbr, &nbr2->nbr2_addr);
   if (nbr2_list) {
 
     /*
      * Refresh timer.
      */
-    olsr_change_timer(nbr2_list->neighbor_2->nbr2_list_timer, vtime, OLSR_NBR2_LIST_JITTER, OLSR_TIMER_ONESHOT);
+    olsr_change_timer(nbr2_list->nbr2->nbr2_list_timer, vtime, OLSR_NBR2_LIST_JITTER, OLSR_TIMER_ONESHOT);
     return nbr2_list;
   }
 
@@ -107,8 +107,8 @@ olsr_add_nbr2_list_entry(struct nbr_entry *nbr, struct neighbor_2_entry *nbr2, f
    */
   nbr2_list = olsr_cookie_malloc(nbr2_list_mem_cookie);
 
-  nbr2_list->neighbor_2 = nbr2;
-  nbr2->neighbor_2_pointer++;   /* XXX move to olsr_lock_nbr2 () */
+  nbr2_list->nbr2 = nbr2;
+  nbr2->nbr2_pointer++;   /* XXX move to olsr_lock_nbr2 () */
   nbr2_list->nbr2_nbr = nbr;    /* XXX nbr needs refcount protection as well */
 
   /*
@@ -118,7 +118,7 @@ olsr_add_nbr2_list_entry(struct nbr_entry *nbr, struct neighbor_2_entry *nbr2, f
                    &olsr_expire_nbr2_list, nbr2_list, nbr2_list_timer_cookie->ci_id);
 
   /* Add to the nbr2 reference subtree */
-  nbr2_list->nbr2_list_node.key = &nbr2->neighbor_2_addr;
+  nbr2_list->nbr2_list_node.key = &nbr2->nbr2_addr;
   avl_insert(&nbr->nbr2_list_tree, &nbr2_list->nbr2_list_node, AVL_DUP_NO);
 
   return nbr2_list;
@@ -131,14 +131,14 @@ olsr_add_nbr2_list_entry(struct nbr_entry *nbr, struct neighbor_2_entry *nbr2, f
 static void
 olsr_delete_nbr2_list_entry(struct nbr2_list_entry *nbr2_list)
 {
-  struct neighbor_2_entry *nbr2;
+  struct nbr2_entry *nbr2;
   struct nbr_entry *nbr;
 
-  nbr2 = nbr2_list->neighbor_2;
+  nbr2 = nbr2_list->nbr2;
   nbr = nbr2_list->nbr2_nbr;
 
   /* XXX move to olsr_unlock_nbr2() */
-  if (nbr2->neighbor_2_pointer < 1) {
+  if (nbr2->nbr2_pointer < 1) {
     DEQUEUE_ELEM(nbr2);
     free(nbr2);
   }
@@ -146,8 +146,8 @@ olsr_delete_nbr2_list_entry(struct nbr2_list_entry *nbr2_list)
   /*
    * Kill running timers.
    */
-  olsr_stop_timer(nbr2_list->neighbor_2->nbr2_list_timer);
-  nbr2_list->neighbor_2->nbr2_list_timer = NULL;
+  olsr_stop_timer(nbr2_list->nbr2->nbr2_list_timer);
+  nbr2_list->nbr2->nbr2_list_timer = NULL;
 
   /* Remove from neighbor2 reference subtree */
   avl_delete(&nbr->nbr2_list_tree, &nbr2_list->nbr2_list_node);
@@ -235,8 +235,8 @@ olsr_delete_nbr_entry(const union olsr_ip_addr * addr)
   OLSR_DEBUG(LOG_NEIGHTABLE, "Delete 1-hop neighbor: %s\n", olsr_ip_to_string(&buf, addr));
 
   OLSR_FOR_ALL_NBR2_LIST_ENTRIES(nbr, nbr2_list) {
-    nbr2_list->neighbor_2->neighbor_2_pointer--;        /* XXX move to olsr_nbr2_unlock() */
-    olsr_delete_neighbor_pointer(nbr2_list->neighbor_2, nbr);
+    nbr2_list->nbr2->nbr2_pointer--;        /* XXX move to olsr_nbr2_unlock() */
+    olsr_delete_neighbor_pointer(nbr2_list->nbr2, nbr);
     olsr_delete_nbr2_list_entry(nbr2_list);
   } OLSR_FOR_ALL_NBR2_LIST_ENTRIES_END(nbr, nbr2_list);
 
@@ -355,7 +355,7 @@ olsr_update_nbr_status(struct nbr_entry *entry, int lnk)
   if (lnk == SYM_LINK) {
     /* N_status is set to SYM */
     if (entry->status == NOT_SYM) {
-      struct neighbor_2_entry *two_hop_neighbor;
+      struct nbr2_entry *two_hop_neighbor;
 
       /* Delete posible 2 hop entry on this neighbor */
       if ((two_hop_neighbor = olsr_lookup_two_hop_neighbor_table(&entry->neighbor_main_addr)) != NULL) {
@@ -392,15 +392,15 @@ olsr_expire_nbr2_list(void *context)
 {
   struct nbr2_list_entry *nbr2_list;
   struct nbr_entry *nbr;
-  struct neighbor_2_entry *nbr2;
+  struct nbr2_entry *nbr2;
 
   nbr2_list = (struct nbr2_list_entry *)context;
-  nbr2_list->neighbor_2->nbr2_list_timer = NULL;
+  nbr2_list->nbr2->nbr2_list_timer = NULL;
 
   nbr = nbr2_list->nbr2_nbr;
-  nbr2 = nbr2_list->neighbor_2;
+  nbr2 = nbr2_list->nbr2;
 
-  nbr2->neighbor_2_pointer--;   /* XXX move to olsr_unlock_nbr2() */
+  nbr2->nbr2_pointer--;   /* XXX move to olsr_unlock_nbr2() */
   olsr_delete_neighbor_pointer(nbr2, nbr);
 
   olsr_delete_nbr2_list_entry(nbr2_list);
index c1345e0..d948fb5 100644 (file)
@@ -55,7 +55,7 @@
 struct nbr2_list_entry {
   struct avl_node nbr2_list_node;
   struct nbr_entry *nbr2_nbr;          /* backpointer to owning nbr entry */
-  struct neighbor_2_entry *neighbor_2;
+  struct nbr2_entry *nbr2;
 };
 
 AVLNODE2STRUCT(nbr2_list_node_to_nbr2_list, struct nbr2_list_entry, nbr2_list_node);
@@ -70,7 +70,7 @@ struct nbr_entry {
   unsigned int is_mpr:1;
   unsigned int was_mpr:1;              /* Used to detect changes in MPR */
   unsigned int skip:1;
-  int neighbor_2_nocov;
+  int nbr2_nocov;
   unsigned int linkcount;
   struct avl_tree nbr2_list_tree;      /* subtree for nbr2 pointers */
 } __attribute__ ((packed));
@@ -112,9 +112,9 @@ extern struct olsr_cookie_info *nbr2_list_timer_cookie;
 void olsr_init_neighbor_table(void);
 bool olsr_delete_nbr2_list_entry_by_addr(struct nbr_entry *, union olsr_ip_addr *);
 struct nbr2_list_entry *olsr_lookup_nbr2_list_entry(struct nbr_entry *, const union olsr_ip_addr *);
-struct nbr2_list_entry *olsr_add_nbr2_list_entry(struct nbr_entry *, struct neighbor_2_entry *, float);
+struct nbr2_list_entry *olsr_add_nbr2_list_entry(struct nbr_entry *, struct nbr2_entry *, float);
 bool olsr_delete_nbr_entry(const union olsr_ip_addr *);
-void olsr_link_nbr_nbr2(struct nbr_entry *, struct neighbor_2_entry *, float);
+void olsr_link_nbr_nbr2(struct nbr_entry *, struct nbr2_entry *, float);
 struct nbr_entry *olsr_add_nbr_entry(const union olsr_ip_addr *);
 struct nbr_entry *olsr_lookup_nbr_entry(const union olsr_ip_addr *);
 struct nbr_entry *olsr_lookup_nbr_entry_alias(const union olsr_ip_addr *);
index a5d3cf3..4fc18d7 100644 (file)
@@ -96,10 +96,10 @@ process_message_neighbors(struct nbr_entry *neighbor, const struct lq_hello_mess
     if (message_neighbors->neigh_type == SYM_NEIGH || message_neighbors->neigh_type == MPR_NEIGH) {
       struct nbr2_list_entry *two_hop_neighbor_yet = olsr_lookup_nbr2_list_entry(neighbor, &message_neighbors->addr);
       if (two_hop_neighbor_yet != NULL) {
-        struct neighbor_list_entry *walker;
+        struct nbr_list_entry *walker;
 
         /* Updating the holding time for this neighbor */
-        olsr_set_timer(&two_hop_neighbor_yet->neighbor_2->nbr2_list_timer,
+        olsr_set_timer(&two_hop_neighbor_yet->nbr2->nbr2_list_timer,
                        message->comm.vtime, OLSR_NBR2_LIST_JITTER,
                        OLSR_TIMER_ONESHOT, &olsr_expire_nbr2_list, two_hop_neighbor_yet, nbr2_list_timer_cookie->ci_id);
 
@@ -113,8 +113,8 @@ process_message_neighbors(struct nbr_entry *neighbor, const struct lq_hello_mess
          * loop through the one-hop neighbors that see this
          * 'two_hop_neighbor'
          */
-        for (walker = two_hop_neighbor_yet->neighbor_2->neighbor_2_nblist.next;
-             walker != &two_hop_neighbor_yet->neighbor_2->neighbor_2_nblist; walker = walker->next) {
+        for (walker = two_hop_neighbor_yet->nbr2->nbr2_nblist.next;
+             walker != &two_hop_neighbor_yet->nbr2->nbr2_nblist; walker = walker->next) {
           /*
            * have we found the one-hop neighbor that sent the
            * HELLO message that we're current processing?
@@ -124,14 +124,14 @@ process_message_neighbors(struct nbr_entry *neighbor, const struct lq_hello_mess
           }
         }
       } else {
-        struct neighbor_2_entry *two_hop_neighbor = olsr_lookup_two_hop_neighbor_table(&message_neighbors->addr);
+        struct nbr2_entry *two_hop_neighbor = olsr_lookup_two_hop_neighbor_table(&message_neighbors->addr);
         if (two_hop_neighbor == NULL) {
           OLSR_DEBUG(LOG_LINKS, "Adding 2 hop neighbor %s\n\n", olsr_ip_to_string(&buf, &message_neighbors->addr));
           two_hop_neighbor = olsr_malloc(sizeof(*two_hop_neighbor), "Process HELLO");
-          two_hop_neighbor->neighbor_2_nblist.next = &two_hop_neighbor->neighbor_2_nblist;
-          two_hop_neighbor->neighbor_2_nblist.prev = &two_hop_neighbor->neighbor_2_nblist;
-          two_hop_neighbor->neighbor_2_pointer = 0;
-          two_hop_neighbor->neighbor_2_addr = message_neighbors->addr;
+          two_hop_neighbor->nbr2_nblist.next = &two_hop_neighbor->nbr2_nblist;
+          two_hop_neighbor->nbr2_nblist.prev = &two_hop_neighbor->nbr2_nblist;
+          two_hop_neighbor->nbr2_pointer = 0;
+          two_hop_neighbor->nbr2_addr = message_neighbors->addr;
           olsr_insert_two_hop_neighbor_table(two_hop_neighbor);
         }
         /*
@@ -165,7 +165,7 @@ process_message_neighbors(struct nbr_entry *neighbor, const struct lq_hello_mess
       continue;
     }
     if (message_neighbors->neigh_type == SYM_NEIGH || message_neighbors->neigh_type == MPR_NEIGH) {
-      struct neighbor_list_entry *walker;
+      struct nbr_list_entry *walker;
       struct nbr2_list_entry *two_hop_neighbor_yet = olsr_lookup_nbr2_list_entry(neighbor, &message_neighbors->addr);
 
       if (!two_hop_neighbor_yet) {
@@ -174,10 +174,10 @@ process_message_neighbors(struct nbr_entry *neighbor, const struct lq_hello_mess
 
       /*
        *  loop through the one-hop neighbors that see this
-       * 'two_hop_neighbor_yet->neighbor_2'
+       * 'two_hop_neighbor_yet->nbr2'
        */
-      for (walker = two_hop_neighbor_yet->neighbor_2->neighbor_2_nblist.next;
-           walker != &two_hop_neighbor_yet->neighbor_2->neighbor_2_nblist; walker = walker->next) {
+      for (walker = two_hop_neighbor_yet->nbr2->nbr2_nblist.next;
+           walker != &two_hop_neighbor_yet->nbr2->nbr2_nblist; walker = walker->next) {
         /*
          * have we found the one-hop neighbor that sent the
          * HELLO message that we're current processing?
index 1b2a83e..1fff863 100644 (file)
@@ -50,7 +50,7 @@
 
 #include <stdlib.h>
 
-struct neighbor_2_entry two_hop_neighbortable[HASHSIZE];
+struct nbr2_entry two_hop_neighbortable[HASHSIZE];
 
 /**
  *Initialize 2 hop neighbor table
@@ -79,12 +79,12 @@ olsr_init_two_hop_table(void)
  *@return nada
  */
 void
-olsr_delete_neighbor_pointer(struct neighbor_2_entry *two_hop_entry, struct nbr_entry *neigh)
+olsr_delete_neighbor_pointer(struct nbr2_entry *two_hop_entry, struct nbr_entry *neigh)
 {
-  struct neighbor_list_entry *entry = two_hop_entry->neighbor_2_nblist.next;
-  while (entry != &two_hop_entry->neighbor_2_nblist) {
+  struct nbr_list_entry *entry = two_hop_entry->nbr2_nblist.next;
+  while (entry != &two_hop_entry->nbr2_nblist) {
     if (entry->neighbor == neigh) {
-      struct neighbor_list_entry *entry_to_delete = entry;
+      struct nbr_list_entry *entry_to_delete = entry;
       entry = entry->next;
 
       /* dequeue */
@@ -105,18 +105,18 @@ olsr_delete_neighbor_pointer(struct neighbor_2_entry *two_hop_entry, struct nbr_
  *@return nada
  */
 void
-olsr_delete_two_hop_neighbor_table(struct neighbor_2_entry *two_hop_neighbor)
+olsr_delete_two_hop_neighbor_table(struct nbr2_entry *two_hop_neighbor)
 {
-  struct neighbor_list_entry *one_hop_list;
+  struct nbr_list_entry *one_hop_list;
 
-  one_hop_list = two_hop_neighbor->neighbor_2_nblist.next;
+  one_hop_list = two_hop_neighbor->nbr2_nblist.next;
 
   /* Delete one hop links */
-  while (one_hop_list != &two_hop_neighbor->neighbor_2_nblist) {
+  while (one_hop_list != &two_hop_neighbor->nbr2_nblist) {
     struct nbr_entry *one_hop_entry = one_hop_list->neighbor;
-    struct neighbor_list_entry *entry_to_delete = one_hop_list;
+    struct nbr_list_entry *entry_to_delete = one_hop_list;
 
-    olsr_delete_nbr2_list_entry_by_addr(one_hop_entry, &two_hop_neighbor->neighbor_2_addr);
+    olsr_delete_nbr2_list_entry_by_addr(one_hop_entry, &two_hop_neighbor->nbr2_addr);
     one_hop_list = one_hop_list->next;
     /* no need to dequeue */
     free(entry_to_delete);
@@ -135,14 +135,14 @@ olsr_delete_two_hop_neighbor_table(struct neighbor_2_entry *two_hop_neighbor)
  *@return nada
  */
 void
-olsr_insert_two_hop_neighbor_table(struct neighbor_2_entry *two_hop_neighbor)
+olsr_insert_two_hop_neighbor_table(struct nbr2_entry *two_hop_neighbor)
 {
 #if !defined REMOVE_LOG_DEBUG
   struct ipaddr_str buf;
 #endif
-  uint32_t hash = olsr_ip_hashing(&two_hop_neighbor->neighbor_2_addr);
+  uint32_t hash = olsr_ip_hashing(&two_hop_neighbor->nbr2_addr);
 
-  OLSR_DEBUG(LOG_2NEIGH, "Adding 2 hop neighbor %s\n", olsr_ip_to_string(&buf, &two_hop_neighbor->neighbor_2_addr));
+  OLSR_DEBUG(LOG_2NEIGH, "Adding 2 hop neighbor %s\n", olsr_ip_to_string(&buf, &two_hop_neighbor->nbr2_addr));
 
   /* Queue */
   QUEUE_ELEM(two_hop_neighbortable[hash], two_hop_neighbor);
@@ -153,27 +153,27 @@ olsr_insert_two_hop_neighbor_table(struct neighbor_2_entry *two_hop_neighbor)
  *
  *@param dest the IP address of the entry to find
  *
- *@return a pointer to a neighbor_2_entry struct
+ *@return a pointer to a nbr2_entry struct
  *representing the two hop neighbor
  */
-struct neighbor_2_entry *
+struct nbr2_entry *
 olsr_lookup_two_hop_neighbor_table(const union olsr_ip_addr *dest)
 {
-  struct neighbor_2_entry *neighbor_2;
+  struct nbr2_entry *nbr2;
   uint32_t hash = olsr_ip_hashing(dest);
 
-  for (neighbor_2 = two_hop_neighbortable[hash].next; neighbor_2 != &two_hop_neighbortable[hash]; neighbor_2 = neighbor_2->next) {
+  for (nbr2 = two_hop_neighbortable[hash].next; nbr2 != &two_hop_neighbortable[hash]; nbr2 = nbr2->next) {
     struct tc_entry *tc;
 
-    if (olsr_ipcmp(&neighbor_2->neighbor_2_addr, dest) == 0) {
-      return neighbor_2;
+    if (olsr_ipcmp(&nbr2->nbr2_addr, dest) == 0) {
+      return nbr2;
     }
     /*
      * Locate the hookup point and check if this is a registered alias.
      */
-    tc = olsr_locate_tc_entry(&neighbor_2->neighbor_2_addr);
+    tc = olsr_locate_tc_entry(&nbr2->nbr2_addr);
     if (olsr_lookup_tc_mid_entry(tc, dest)) {
-      return neighbor_2;
+      return nbr2;
     }
   }
   return NULL;
@@ -185,18 +185,18 @@ olsr_lookup_two_hop_neighbor_table(const union olsr_ip_addr *dest)
  *
  *@param dest the IP address of the entry to find
  *
- *@return a pointer to a neighbor_2_entry struct
+ *@return a pointer to a nbr2_entry struct
  *representing the two hop neighbor
  */
-struct neighbor_2_entry *
+struct nbr2_entry *
 olsr_lookup_two_hop_neighbor_table_mid(const union olsr_ip_addr *dest)
 {
-  struct neighbor_2_entry *neighbor_2;
+  struct nbr2_entry *nbr2;
   uint32_t hash = olsr_ip_hashing(dest);
 
-  for (neighbor_2 = two_hop_neighbortable[hash].next; neighbor_2 != &two_hop_neighbortable[hash]; neighbor_2 = neighbor_2->next) {
-    if (olsr_ipcmp(&neighbor_2->neighbor_2_addr, dest) == 0)
-      return neighbor_2;
+  for (nbr2 = two_hop_neighbortable[hash].next; nbr2 != &two_hop_neighbortable[hash]; nbr2 = nbr2->next) {
+    if (olsr_ipcmp(&nbr2->nbr2_addr, dest) == 0)
+      return nbr2;
   }
   return NULL;
 }
@@ -210,11 +210,11 @@ olsr_lookup_two_hop_neighbor_table_mid(const union olsr_ip_addr *dest)
  * @return nada
  */
 void
-olsr_link_nbr_nbr2(struct nbr_entry *nbr, struct neighbor_2_entry *nbr2, float vtime)
+olsr_link_nbr_nbr2(struct nbr_entry *nbr, struct nbr2_entry *nbr2, float vtime)
 {
-  struct neighbor_list_entry *nbr_list;
+  struct nbr_list_entry *nbr_list;
 
-  nbr_list = olsr_malloc(sizeof(struct neighbor_list_entry), "Link entries 1");
+  nbr_list = olsr_malloc(sizeof(struct nbr_list_entry), "Link entries 1");
 
   nbr_list->neighbor = nbr;
 
@@ -223,10 +223,10 @@ olsr_link_nbr_nbr2(struct nbr_entry *nbr, struct neighbor_2_entry *nbr2, float v
   nbr_list->saved_path_linkcost = LINK_COST_BROKEN;
 
   /* Add nbr_list to nbr2 */
-  nbr2->neighbor_2_nblist.next->prev = nbr_list;
-  nbr_list->next = nbr2->neighbor_2_nblist.next;
-  nbr2->neighbor_2_nblist.next = nbr_list;
-  nbr_list->prev = &nbr2->neighbor_2_nblist;
+  nbr2->nbr2_nblist.next->prev = nbr_list;
+  nbr_list->next = nbr2->nbr2_nblist.next;
+  nbr2->nbr2_nblist.next = nbr_list;
+  nbr_list->prev = &nbr2->nbr2_nblist;
 
   olsr_add_nbr2_list_entry(nbr, nbr2, vtime);
 }
@@ -248,17 +248,17 @@ olsr_print_two_hop_neighbor_table(void)
             "IP addr (2-hop)  IP addr (1-hop)  Total cost\n", olsr_wallclock_string());
 
   for (i = 0; i < HASHSIZE; i++) {
-    struct neighbor_2_entry *neigh2;
+    struct nbr2_entry *neigh2;
     for (neigh2 = two_hop_neighbortable[i].next; neigh2 != &two_hop_neighbortable[i]; neigh2 = neigh2->next) {
-      struct neighbor_list_entry *entry;
+      struct nbr_list_entry *entry;
       bool first = true;
 
-      for (entry = neigh2->neighbor_2_nblist.next; entry != &neigh2->neighbor_2_nblist; entry = entry->next) {
+      for (entry = neigh2->nbr2_nblist.next; entry != &neigh2->nbr2_nblist; entry = entry->next) {
         struct ipaddr_str buf;
         struct lqtextbuffer lqbuffer;
 
         OLSR_INFO_NH(LOG_2NEIGH, "%-15s  %-15s  %s\n",
-                     first ? olsr_ip_to_string(&buf, &neigh2->neighbor_2_addr) : "",
+                     first ? olsr_ip_to_string(&buf, &neigh2->nbr2_addr) : "",
                      olsr_ip_to_string(&buf, &entry->neighbor->neighbor_main_addr),
                      get_linkcost_text(entry->path_linkcost, false, &lqbuffer));
 
index b040b8a..2df7cd9 100644 (file)
 #define        NB2S_COVERED    0x1     /* node has been covered by a MPR */
 
 
-struct neighbor_list_entry {
-  struct nbr_entry *neighbor;
+struct nbr_list_entry {
+  struct nbr_entry *neighbor;          /* backpointer to owning nbr entry */
   olsr_linkcost second_hop_linkcost;
   olsr_linkcost path_linkcost;
   olsr_linkcost saved_path_linkcost;
-  struct neighbor_list_entry *next;
-  struct neighbor_list_entry *prev;
+  struct nbr_list_entry *next;
+  struct nbr_list_entry *prev;
 };
 
 
-struct neighbor_2_entry {
-  union olsr_ip_addr neighbor_2_addr;
-  uint8_t mpr_covered_count;           /*used in mpr calculation */
-  uint8_t processed;                   /*used in mpr calculation */
-  int16_t neighbor_2_pointer;          /* Neighbor count */
+struct nbr2_entry {
+  union olsr_ip_addr nbr2_addr;
+  struct nbr2_entry *prev;
+  struct nbr2_entry *next;
+  unsigned int mpr_covered_count;      /* Used in mpr calculation */
+  unsigned int processed:1;            /* Used in mpr calculation */
+  unsigned int nbr2_pointer;           /* Neighbor count */
   struct timer_entry *nbr2_list_timer;
-  struct neighbor_list_entry neighbor_2_nblist;
-  struct neighbor_2_entry *prev;
-  struct neighbor_2_entry *next;
-};
+  struct nbr_list_entry nbr2_nblist;
+} __attribute__ ((packed));;
 
 /*
- * macros for traversing two-hop neighbors lists.
+ * macros for traversing two-hop neighbors.
  * it is recommended to use this because it hides all the internal
  * datastructure from the callers.
  *
@@ -88,15 +88,15 @@ struct neighbor_2_entry {
   nbr2 = nbr2->next)
 #define OLSR_FOR_ALL_NBR2_ENTRIES_END(nbr2) }}
 
-extern struct neighbor_2_entry two_hop_neighbortable[HASHSIZE];
+extern struct nbr2_entry two_hop_neighbortable[HASHSIZE];
 
 void olsr_init_two_hop_table(void);
-void olsr_delete_neighbor_pointer(struct neighbor_2_entry *, struct nbr_entry *);
-void olsr_delete_two_hop_neighbor_table(struct neighbor_2_entry *);
-void olsr_insert_two_hop_neighbor_table(struct neighbor_2_entry *);
-struct neighbor_2_entry *olsr_lookup_two_hop_neighbor_table(const union olsr_ip_addr *);
-struct neighbor_2_entry *olsr_lookup_two_hop_neighbor_table_mid(const union olsr_ip_addr *);
-void olsr_link_nbr_nbr2(struct nbr_entry *, struct neighbor_2_entry *, float);
+void olsr_delete_neighbor_pointer(struct nbr2_entry *, struct nbr_entry *);
+void olsr_delete_two_hop_neighbor_table(struct nbr2_entry *);
+void olsr_insert_two_hop_neighbor_table(struct nbr2_entry *);
+struct nbr2_entry *olsr_lookup_two_hop_neighbor_table(const union olsr_ip_addr *);
+struct nbr2_entry *olsr_lookup_two_hop_neighbor_table_mid(const union olsr_ip_addr *);
+void olsr_link_nbr_nbr2(struct nbr_entry *, struct nbr2_entry *, float);
 void olsr_print_two_hop_neighbor_table(void);
 
 #endif