A general cleanup[tm] performed by your favorite code cleaner. I guess this is my...
authorAndreas Tonnesen <andreto@olsr.org>
Mon, 17 Jan 2005 20:18:22 +0000 (20:18 +0000)
committerAndreas Tonnesen <andreto@olsr.org>
Mon, 17 Jan 2005 20:18:22 +0000 (20:18 +0000)
13 files changed:
src/duplicate_set.c
src/hna_set.c
src/hna_set.h
src/link_set.c
src/main.c
src/mid_set.c
src/mpr_selector_set.c
src/neighbor_table.c
src/process_package.c
src/process_routes.c
src/routing_table.c
src/scheduler.c
src/two_hop_neighbor_table.c

index 54e0b3c..68ffd31 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: duplicate_set.c,v 1.8 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: duplicate_set.c,v 1.9 2005/01/17 20:18:18 kattemat Exp $
  */
 
 
@@ -156,7 +156,6 @@ olsr_check_dup_table_fwd(union olsr_ip_addr *originator,
 {
   olsr_u32_t hash;
   struct dup_entry *tmp_dup_table;
-  struct dup_iface *tmp_dup_iface;
 
   /* Hash the senders address */
   hash = olsr_hashing(originator);
@@ -169,6 +168,7 @@ olsr_check_dup_table_fwd(union olsr_ip_addr *originator,
       if(COMP_IP(&tmp_dup_table->addr, originator) &&
         (tmp_dup_table->seqno == seqno))
        {
+         struct dup_iface *tmp_dup_iface;
          /* Check retransmitted */
          if(tmp_dup_table->forwarded)
            return 0;
@@ -214,12 +214,7 @@ olsr_del_dup_entry(struct dup_entry *entry)
 
   /* Dequeue */
   DEQUEUE_ELEM(entry);
-  //entry->prev->next = entry->next;
-  //entry->next->prev = entry->prev;
-
-  /* Free entry */
   free(entry);
-
 }
 
 
@@ -228,26 +223,23 @@ void
 olsr_time_out_duplicate_table(void *foo)
 {
   int i;
-  struct dup_entry *tmp_dup_table, *entry_to_delete;
 
   for(i = 0; i < HASHSIZE; i++)
     {      
+      struct dup_entry *tmp_dup_table;
       tmp_dup_table = dup_set[i].next;
 
       while(tmp_dup_table != &dup_set[i])
        {
          if(TIMED_OUT(tmp_dup_table->timer))
            {
-
+             struct dup_entry *entry_to_delete = tmp_dup_table;
 #ifdef DEBUG
              olsr_printf(5, "DUP TIMEOUT[%s] s: %d\n", 
                          olsr_ip_to_string(&tmp_dup_table->addr),
                          tmp_dup_table->seqno);
 #endif
-
-             entry_to_delete = tmp_dup_table;
              tmp_dup_table = tmp_dup_table->next;
-
              olsr_del_dup_entry(entry_to_delete);
            }
          else
@@ -357,13 +349,12 @@ void
 olsr_print_duplicate_table()
 {
   int i;
-  struct dup_entry *tmp_dup_table;
 
   printf("\nDUP TABLE:\n");
 
   for(i = 0; i < HASHSIZE; i++)
     {      
-      tmp_dup_table = dup_set[i].next;
+      struct dup_entry *tmp_dup_table = dup_set[i].next;
       
       //printf("Timeout %d %d\n", i, j);
       while(tmp_dup_table != &dup_set[i])
index 8907ee5..ab91aa6 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: hna_set.c,v 1.14 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: hna_set.c,v 1.15 2005/01/17 20:18:20 kattemat Exp $
  */
 
 #include "defs.h"
@@ -264,25 +264,24 @@ void
 olsr_time_out_hna_set(void *foo)
 {
   int index;
-  struct hna_entry *tmp_hna, *hna_to_delete;
-  struct hna_net *tmp_net, *net_to_delete;
 
   for(index=0;index<HASHSIZE;index++)
     {
-      tmp_hna = hna_set[index].next;
+      struct hna_entry *tmp_hna = hna_set[index].next;
       /* Check all entrys */
       while(tmp_hna != &hna_set[index])
        {
          /* Check all networks */
-         tmp_net = tmp_hna->networks.next;
+         struct hna_net *tmp_net = tmp_hna->networks.next;
 
          while(tmp_net != &tmp_hna->networks)
            {
              if(TIMED_OUT(tmp_net->A_time))
                {
-                 net_to_delete = tmp_net;
+                 struct hna_net *net_to_delete = tmp_net;
                  tmp_net = tmp_net->next;
-                 delete_hna_net(net_to_delete);
+                 DEQUEUE_ELEM(net_to_delete);
+                 free(net_to_delete);
                  changes_hna = OLSR_TRUE;
                }
              else
@@ -292,9 +291,13 @@ olsr_time_out_hna_set(void *foo)
          /* Delete gw entry if empty */
          if(tmp_hna->networks.next == &tmp_hna->networks)
            {
-             hna_to_delete = tmp_hna;
+             struct hna_entry *hna_to_delete = tmp_hna;
              tmp_hna = tmp_hna->next;
-             delete_hna_entry(hna_to_delete);
+
+             /* Dequeue */
+             DEQUEUE_ELEM(hna_to_delete);
+             /* Delete */
+             free(hna_to_delete);
            }
          else
            tmp_hna = tmp_hna->next;
@@ -315,8 +318,6 @@ void
 olsr_print_hna_set()
 {
   int index;
-  struct hna_entry *tmp_hna;
-  struct hna_net *tmp_net;
 
   olsr_printf(1, "\n--- %02d:%02d:%02d.%02d ------------------------------------------------- HNA SET\n\n",
               nowtm->tm_hour,
@@ -331,12 +332,12 @@ olsr_print_hna_set()
 
   for(index=0;index<HASHSIZE;index++)
     {
-      tmp_hna = hna_set[index].next;
+      struct hna_entry *tmp_hna = hna_set[index].next;
       /* Check all entrys */
       while(tmp_hna != &hna_set[index])
        {
          /* Check all networks */
-         tmp_net = tmp_hna->networks.next;
+         struct hna_net *tmp_net = tmp_hna->networks.next;
 
          while(tmp_net != &tmp_hna->networks)
            {
@@ -361,48 +362,3 @@ olsr_print_hna_set()
 }
 
 
-
-
-
-/**
- *Deletes and dequeues a HNA network entry
- *
- *@param net the entry to delete
- */
-void
-delete_hna_net(struct hna_net *net)
-{
-
-  /* Dequeue */
-  net->prev->next = net->next;
-  net->next->prev = net->prev;
-
-  /* Delete */
-  free(net);
-
-}
-
-
-
-
-/**
- *Deletes and dequeues a hna gw entry
- *NETWORKS MUST BE DELETED FIRST!
- *
- *@param entry the entry to delete
- */
-void
-delete_hna_entry(struct hna_entry *entry)
-{
-  /* Dequeue */
-  entry->prev->next = entry->next;
-  entry->next->prev = entry->prev;
-
-  /* Delete */
-  free(entry);
-}
-
-
-
-
-
index 2911449..7518938 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: hna_set.h,v 1.10 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: hna_set.h,v 1.11 2005/01/17 20:18:20 kattemat Exp $
  */
 
 
@@ -72,39 +72,24 @@ size_t netmask_size;
 int
 olsr_init_hna_set(void);
 
-
 struct hna_net *
 olsr_lookup_hna_net(struct hna_net *, union olsr_ip_addr *, union hna_netmask *);
 
-
 struct hna_entry *
 olsr_lookup_hna_gw(union olsr_ip_addr *);
 
-
-
 struct hna_entry *
 olsr_add_hna_entry(union olsr_ip_addr *);
 
-
 struct hna_net *
 olsr_add_hna_net(struct hna_entry *, union olsr_ip_addr *, union hna_netmask *);
 
-
 void
 olsr_update_hna_entry(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *, float);
 
-
 void
 olsr_time_out_hna_set(void *);
 
-
-void
-delete_hna_net(struct hna_net *);
-
-
-void
-delete_hna_entry(struct hna_entry *);
-
 void
 olsr_print_hna_set(void);
 
index 2df56ed..62e7a44 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: link_set.c,v 1.39 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: link_set.c,v 1.40 2005/01/17 20:18:20 kattemat Exp $
  */
 
 
@@ -168,8 +168,6 @@ static int
 get_neighbor_status(union olsr_ip_addr *address)
 {
   union olsr_ip_addr *main_addr;
-  struct addresses   *aliases;
-  struct link_entry  *link;
   struct interface   *ifs;
 
   //printf("GET_NEIGHBOR_STATUS\n");
@@ -183,6 +181,9 @@ get_neighbor_status(union olsr_ip_addr *address)
   /* Loop trough local interfaces to check all possebilities */
   for(ifs = ifnet; ifs != NULL; ifs = ifs->int_next)
     {
+      struct addresses   *aliases;
+      struct link_entry  *link;
+
       //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->ip_addr)) != NULL)
@@ -226,8 +227,6 @@ union olsr_ip_addr *
 get_neighbor_nexthop(union olsr_ip_addr *address)
 {
   union olsr_ip_addr *main_addr;
-  struct addresses   *aliases;
-  struct link_entry  *link;
   struct interface   *ifs;
 
   //printf("GET_NEIGHBOR_NEXTHOP\n");
@@ -241,6 +240,8 @@ get_neighbor_nexthop(union olsr_ip_addr *address)
   /* Loop trough local interfaces to check all possebilities */
   for(ifs = ifnet; ifs != NULL; ifs = ifs->int_next)
     {
+      struct addresses   *aliases;
+      struct link_entry  *link;
       //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->ip_addr)) != NULL)
@@ -298,8 +299,8 @@ get_interface_link_set(union olsr_ip_addr *remote)
 {
   struct link_entry *tmp_link_set;
   union olsr_ip_addr *remote_addr;
-  struct interface *if_to_use, *tmp_if, *backup_if;
-  float link_quality, backup_link_quality, curr;
+  struct interface *if_to_use, *backup_if;
+  float link_quality, backup_link_quality;
 
   if_to_use = NULL;
   backup_if = NULL;
@@ -321,6 +322,8 @@ get_interface_link_set(union olsr_ip_addr *remote)
   
   while(tmp_link_set)
     {
+      struct interface *tmp_if;
+      float curr;
       //printf("Checking %s vs ", olsr_ip_to_string(&tmp_link_set->neighbor_iface_addr));
       //printf("%s\n", olsr_ip_to_string(addr));
       
@@ -706,7 +709,7 @@ int
 replace_neighbor_link_set(struct neighbor_entry *old,
                          struct neighbor_entry *new)
 {
-  struct link_entry *tmp_link_set, *last_link_entry;
+  struct link_entry *tmp_link_set;
   int retval;
 
   retval = 0;
@@ -715,7 +718,6 @@ replace_neighbor_link_set(struct neighbor_entry *old,
     return retval;
       
   tmp_link_set = link_set;
-  last_link_entry = NULL;
 
   while(tmp_link_set)
     {
@@ -744,14 +746,13 @@ replace_neighbor_link_set(struct neighbor_entry *old,
 static int
 check_link_status(struct hello_message *message)
 {
-
   struct hello_neighbor  *neighbors;
-  struct interface *ifd;
 
   neighbors = message->neighbors;
   
   while(neighbors!=NULL)
     {  
+      struct interface *ifd;
       //printf("(linkstatus)Checking %s ",olsr_ip_to_string(&neighbors->address));
       //printf("against %s\n",olsr_ip_to_string(&main_addr));
 
@@ -852,7 +853,6 @@ olsr_time_out_hysteresis()
 {
 
   struct link_entry *tmp_link_set;
-  int status;
 
   if(link_set == NULL)
     return;
@@ -863,6 +863,8 @@ olsr_time_out_hysteresis()
     {
       if(TIMED_OUT(tmp_link_set->hello_timeout))
        {
+         int status;
+
          tmp_link_set->L_link_quality = olsr_hyst_calc_instability(tmp_link_set->L_link_quality);
          olsr_printf(1, "HYST[%s] HELLO timeout %0.3f\n", olsr_ip_to_string(&tmp_link_set->neighbor_iface_addr), tmp_link_set->L_link_quality);
          /* Update hello_timeout - NO SLACK THIS TIME */
@@ -891,7 +893,6 @@ void olsr_print_link_set(void)
 {
   struct link_entry *walker;
   char *fstr;
-  float etx;
 
   olsr_printf(1, "\n--- %02d:%02d:%02d.%02d ---------------------------------------------------- LINKS\n\n",
               nowtm->tm_hour,
@@ -913,6 +914,8 @@ void olsr_print_link_set(void)
 
   for (walker = link_set; walker != NULL; walker = walker->next)
   {
+    float etx;
+
     if (walker->loss_link_quality < MIN_LINK_QUALITY ||
         walker->neigh_link_quality < MIN_LINK_QUALITY)
       etx = 0.0;
index cd6fc60..39d770c 100644 (file)
@@ -37,7 +37,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: main.c,v 1.54 2005/01/17 10:58:48 tlopatic Exp $
+ * $Id: main.c,v 1.55 2005/01/17 20:18:20 kattemat Exp $
  */
 
 #include <unistd.h>
@@ -92,13 +92,7 @@ static char copyright_string[] = "The olsr.org Optimized Link-State Routing daem
 int
 main(int argc, char *argv[])
 {
-  /* For address convertions */
-  struct in_addr in;
-  struct in6_addr in6;
-
   struct if_config_options *default_ifcnf;
-
-  struct stat statbuf;
   char conf_file_name[FILENAME_MAX];
   
   olsr_argv = argv;
@@ -176,6 +170,8 @@ main(int argc, char *argv[])
 
   if ((argc > 1) && (strcmp(argv[1], "-f") == 0)) 
     {
+      struct stat statbuf;
+
       argv++; argc--;
       if(argc == 1)
        {
@@ -250,6 +246,8 @@ main(int argc, char *argv[])
        */
       if(strcmp(*argv, "-bcast") == 0) 
        {
+         struct in_addr in;
+
          argv++; argc--;
          if(!argc)
            {
@@ -425,6 +423,8 @@ main(int argc, char *argv[])
        */
       if (strcmp(*argv, "-multi") == 0) 
        {
+         struct in6_addr in6;
+
          argv++; argc--;
          if(inet_pton(AF_INET6, *argv, &in6) < 0)
            {
index f6a66b8..d3528ea 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: mid_set.c,v 1.10 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: mid_set.c,v 1.11 2005/01/17 20:18:21 kattemat Exp $
  */
 
 #include "defs.h"
@@ -90,16 +90,10 @@ insert_mid_tuple(union olsr_ip_addr *m_addr, struct addresses *alias, float vtim
 {
   struct mid_entry *tmp;
   struct addresses *tmp_adr;
-  struct neighbor_2_entry *tmp_2_neighbor;
   olsr_u32_t hash;
-  struct neighbor_entry *tmp_neigh, *real_neigh;
-
-  //olsr_printf(5, "TC: lookup entry\n");
 
   hash = olsr_hashing(m_addr);
 
-
-
   /* Check for registered entry */
   for(tmp = mid_set[hash].next;
       tmp != &mid_set[hash];
@@ -142,13 +136,15 @@ insert_mid_tuple(union olsr_ip_addr *m_addr, struct addresses *alias, float vtim
    * and delete duplicate neighbor entries. Redirect
    * link entries to the correct neighbor entry.
    *
-   *THIS OPTIMALIZATION IS NOT SPECIFIED IN RFC3626
+   *THIS OPTIMIZATION IS NOT SPECIFIED IN RFC3626
    */
 
   tmp_adr = alias;
 
   while(tmp_adr)
     {
+      struct neighbor_2_entry *tmp_2_neighbor;
+      struct neighbor_entry *tmp_neigh, *real_neigh;
 
       /* Delete possible 2 hop neighbor */
       if((tmp_2_neighbor = olsr_lookup_two_hop_neighbor_table_mid(&tmp_adr->address)) != NULL)
@@ -171,11 +167,8 @@ insert_mid_tuple(union olsr_ip_addr *m_addr, struct addresses *alias, float vtim
 
          replace_neighbor_link_set(tmp_neigh, real_neigh);
 
-         /* Delete the neighbor */
          /* Dequeue */
          DEQUEUE_ELEM(tmp_neigh);
-         //tmp_neigh->prev->next = tmp_neigh->next;
-         //tmp_neigh->next->prev = tmp_neigh->prev;
          /* Delete */
          free(tmp_neigh);
 
@@ -238,18 +231,16 @@ insert_mid_alias(union olsr_ip_addr *main_add, union olsr_ip_addr *alias, float
 union olsr_ip_addr *
 mid_lookup_main_addr(union olsr_ip_addr *adr)
 {
-
-  struct mid_entry *tmp_list;
-  struct addresses *tmp_addr;
   int index;
 
-
   for(index=0;index<HASHSIZE;index++)
     {
-      tmp_list = mid_set[index].next;
+      struct mid_entry *tmp_list = mid_set[index].next;
       /*Traverse MID list*/
       while(tmp_list != &mid_set[index])
        {
+         struct addresses *tmp_addr;
+
          if(COMP_IP(&tmp_list->main_addr, adr))
            return NULL;
 
@@ -346,21 +337,19 @@ olsr_update_mid_table(union olsr_ip_addr *adr, float vtime)
 void
 olsr_time_out_mid_set(void *foo)
 {
-  struct mid_entry *tmp_list;
-  struct mid_entry *entry_to_delete;
   int index;
 
 
   for(index=0;index<HASHSIZE;index++)
     {
-      tmp_list = mid_set[index].next;
+      struct mid_entry *tmp_list = mid_set[index].next;
       /*Traverse MID list*/
       while(tmp_list != &mid_set[index])
        {
          /*Check if the entry is timed out*/
          if(TIMED_OUT(tmp_list->ass_timer))
            {
-             entry_to_delete = tmp_list;
+             struct mid_entry *entry_to_delete = tmp_list;
              tmp_list = tmp_list->next;
 #ifdef DEBUG
              olsr_printf(1, "MID info for %s timed out.. deleting it\n", 
@@ -388,21 +377,18 @@ olsr_time_out_mid_set(void *foo)
 int
 mid_delete_node(struct mid_entry *entry)
 {
-  struct addresses *aliases, *tmp_aliases;
+  struct addresses *aliases;
 
   /* Free aliases */
   aliases = entry->aliases;
   while(aliases)
     {
-      tmp_aliases = aliases;
+      struct addresses *tmp_aliases = aliases;
       aliases = aliases->next;
       free(tmp_aliases);
     }
   /* Dequeue */
   DEQUEUE_ELEM(entry);
-  //entry->prev->next = entry->next;
-  //entry->next->prev = entry->prev;
-
   free(entry);
   
   return 0;
@@ -417,24 +403,21 @@ void
 olsr_print_mid_set()
 {
 
-  struct mid_entry *tmp_list;
-  struct addresses *tmp_addr;
   int index;
 
   olsr_printf(1, "mid set: %02d:%02d:%02d.%06lu\n",nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec, now.tv_usec);
 
   for(index=0;index<HASHSIZE;index++)
     {
-      tmp_list = mid_set[index].next;
+      struct mid_entry *tmp_list = mid_set[index].next;
       /*Traverse MID list*/
       for(tmp_list = mid_set[index].next;
          tmp_list != &mid_set[index];
          tmp_list = tmp_list->next)
        {
-         olsr_printf(1, "%s: ", olsr_ip_to_string(&tmp_list->main_addr));
-         
-         tmp_addr = tmp_list->aliases;
-         
+         struct addresses *tmp_addr = tmp_list->aliases;
+
+         olsr_printf(1, "%s: ", olsr_ip_to_string(&tmp_list->main_addr));        
          while(tmp_addr)
            {
              olsr_printf(1, " %s ", olsr_ip_to_string(&tmp_addr->address));
index 6dc4511..0cd52e6 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: mpr_selector_set.c,v 1.9 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: mpr_selector_set.c,v 1.10 2005/01/17 20:18:21 kattemat Exp $
  */
 
 
@@ -183,7 +183,7 @@ olsr_update_mprs_set(union olsr_ip_addr *addr, float vtime)
 void
 olsr_time_out_mprs_set()
 {
-  struct mpr_selector *mprs, *mprs_to_delete;
+  struct mpr_selector *mprs;
 
   mprs = mprs_list.next;
 
@@ -193,7 +193,7 @@ olsr_time_out_mprs_set()
       if(TIMED_OUT(mprs->MS_time))
        {
          /* Dequeue */
-         mprs_to_delete = mprs;
+         struct mpr_selector *mprs_to_delete = mprs;
          mprs = mprs->next;
 
          olsr_printf(1, "MPRS: Timing out %s\n", olsr_ip_to_string(&mprs_to_delete->MS_main_addr));
index 47e2346..71f4bd0 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: neighbor_table.c,v 1.22 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: neighbor_table.c,v 1.23 2005/01/17 20:18:21 kattemat Exp $
  */
 
 
@@ -146,7 +146,6 @@ int
 olsr_delete_neighbor_table(union olsr_ip_addr *neighbor_addr)
 {  
   struct  neighbor_2_list_entry *two_hop_list, *two_hop_to_delete;
-  struct  neighbor_2_entry      *two_hop_entry;
   olsr_u32_t                    hash;
   struct neighbor_entry         *entry;
 
@@ -175,6 +174,8 @@ olsr_delete_neighbor_table(union olsr_ip_addr *neighbor_addr)
 
   while(two_hop_list != &entry->neighbor_2_list)
     {
+      struct  neighbor_2_entry *two_hop_entry;
+
       two_hop_entry = two_hop_list->neighbor_2;
       
       two_hop_entry->neighbor_2_pointer--;
@@ -340,8 +341,6 @@ olsr_lookup_neighbor_table_alias(union olsr_ip_addr *dst)
 int
 update_neighbor_status(struct neighbor_entry *entry, int link)
 {
-  struct neighbor_2_entry *two_hop_neighbor;
-
   /*
    * Update neighbor entry
    */
@@ -351,6 +350,7 @@ update_neighbor_status(struct neighbor_entry *entry, int link)
       /* N_status is set to SYM */
       if(entry->status == NOT_SYM)
        {
+         struct neighbor_2_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)
@@ -395,34 +395,32 @@ update_neighbor_status(struct neighbor_entry *entry, int link)
 void
 olsr_time_out_two_hop_neighbors(struct neighbor_entry  *neighbor)
 {
-  struct  neighbor_2_list_entry *two_hop_list, *two_hop_to_delete;
-  struct  neighbor_2_entry      *two_hop_entry;
-
+  struct neighbor_2_list_entry *two_hop_list;
 
   two_hop_list = neighbor->neighbor_2_list.next;
 
-  //neighbor->neighbor_2_list = NULL;
-
   while(two_hop_list != &neighbor->neighbor_2_list)
     {
       if(TIMED_OUT(two_hop_list->neighbor_2_timer))
        {
-         two_hop_entry = two_hop_list->neighbor_2;
+         struct neighbor_2_list_entry *two_hop_to_delete;
+         struct neighbor_2_entry      *two_hop_entry = two_hop_list->neighbor_2;
+
          two_hop_entry->neighbor_2_pointer--;
          olsr_delete_neighbor_pointer(two_hop_entry, &neighbor->neighbor_main_addr);
-
+         
          if(two_hop_entry->neighbor_2_pointer < 1)
            {
              DEQUEUE_ELEM(two_hop_entry);
              free((void *)two_hop_entry);
            }
-
+         
          two_hop_to_delete = two_hop_list;
          two_hop_list = two_hop_list->next;
-
+         
          /* Dequeue */
          DEQUEUE_ELEM(two_hop_to_delete);
-
+         
          free(two_hop_to_delete);
 
          /* This flag is set to OLSR_TRUE to recalculate the MPR set and the routing table*/
@@ -444,16 +442,14 @@ void
 olsr_time_out_neighborhood_tables()
 {
   olsr_u8_t              index;
-  struct neighbor_entry  *entry;
   
   for(index=0;index<HASHSIZE;index++)
     {
-      entry = neighbortable[index].next;
+      struct neighbor_entry *entry = neighbortable[index].next;
 
       while(entry != &neighbortable[index])
        {         
          olsr_time_out_two_hop_neighbors(entry);
-
          entry = entry->next;
        }
     }
@@ -473,9 +469,6 @@ void
 olsr_print_neighbor_table()
 {
   int i;
-  struct neighbor_entry *neigh;
-  struct link_entry *link;
-  double best_lq, inv_best_lq;
   char *fstr;
 
   olsr_printf(1, "\n--- %02d:%02d:%02d.%02d ------------------------------------------------ NEIGHBORS\n\n",
@@ -498,13 +491,13 @@ olsr_print_neighbor_table()
 
   for (i = 0; i < HASHSIZE; i++)
     {
+      struct neighbor_entry *neigh;
       for(neigh = neighbortable[i].next; neigh != &neighbortable[i];
          neigh = neigh->next)
        {
-          link = olsr_neighbor_best_link(&neigh->neighbor_main_addr);
-
-          best_lq = link->neigh_link_quality;
-          inv_best_lq = link->loss_link_quality;
+         struct link_entry *link = olsr_neighbor_best_link(&neigh->neighbor_main_addr);
+         double best_lq = link->neigh_link_quality;
+         double inv_best_lq = link->loss_link_quality;
 
           olsr_printf(1, fstr, olsr_ip_to_string(&neigh->neighbor_main_addr),
                       inv_best_lq, best_lq,
index 6e4c566..5cb081f 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: process_package.c,v 1.25 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: process_package.c,v 1.26 2005/01/17 20:18:21 kattemat Exp $
  */
 
 
@@ -339,27 +339,19 @@ olsr_process_received_mid(union olsr_message *m, struct interface *in_if, union
   struct mid_alias *tmp_adr;
   struct mid_message message;
 
-
   mid_chgestruct(&message, m);
 
-  /*
-  if(COMP_IP(&message.mid_origaddr, &main_addr))
-    {
-      goto forward;  
-    }
-  */
-
   if(!olsr_check_dup_table_proc(&message.mid_origaddr, 
                                message.mid_seqno))
     {
       goto forward;
     }
-  
-  olsr_printf(5, "Processing MID from %s...\n", olsr_ip_to_string(&message.mid_origaddr));
 
+#ifdef DEBUG
+  olsr_printf(5, "Processing MID from %s...\n", olsr_ip_to_string(&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
@@ -373,8 +365,6 @@ olsr_process_received_mid(union olsr_message *m, struct interface *in_if, union
       return;
     }
 
-
-
   /* Update the timeout of the MID */
   olsr_update_mid_table(&message.mid_origaddr, (float)message.vtime);
 
@@ -391,11 +381,7 @@ olsr_process_received_mid(union olsr_message *m, struct interface *in_if, union
       tmp_adr = tmp_adr->next;
     } 
   
-  /*Update topology if neccesary*/
-  //olsr_process_changes();
-
- forward:
-  
+ forward:  
   olsr_forward_message(m, 
                       &message.mid_origaddr, 
                       message.mid_seqno, 
@@ -425,18 +411,11 @@ olsr_process_received_hna(union olsr_message *m, struct interface *in_if, union
   struct hna_net_addr  *hna_tmp;
   struct  hna_message message;
 
-  //printf("Processing HNA\n");
+#ifdef DEBUG
+  olsr_printf(5, "Processing HNA\n");
+#endif
 
   hna_chgestruct(&message, m);
-  
-
-  /* Process message */          
-  /*
-  if(COMP_IP(&message.originator, &main_addr)) 
-    {
-      goto forward;
-    }
-  */
 
   if(!olsr_check_dup_table_proc(&message.originator, 
                                message.packet_seq_number))
@@ -444,20 +423,13 @@ olsr_process_received_hna(union olsr_message *m, struct interface *in_if, union
       goto forward;
     }
 
-
-
-
   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)
     {
       olsr_printf(2, "Received HNA from NON SYM neighbor %s\n", olsr_ip_to_string(from_addr));
@@ -471,9 +443,6 @@ olsr_process_received_hna(union olsr_message *m, struct interface *in_if, union
       
       hna_tmp = hna_tmp->next;
     }
-  
-  /*Update topology if neccesary*/
-  //olsr_process_changes();
 
  forward:
   olsr_forward_message(m, 
@@ -503,16 +472,14 @@ olsr_process_message_neighbors(struct neighbor_entry *neighbor,
                                struct hello_message *message)
 {
   struct hello_neighbor        *message_neighbors;
-  struct neighbor_2_list_entry *two_hop_neighbor_yet;
-  struct neighbor_2_entry      *two_hop_neighbor;
-  union olsr_ip_addr           *neigh_addr;
-  struct neighbor_list_entry *walker;
-  struct link_entry *link;
 
   for(message_neighbors = message->neighbors;
       message_neighbors != NULL;
       message_neighbors = message_neighbors->next)
     {
+      union olsr_ip_addr      *neigh_addr;
+      struct neighbor_2_entry *two_hop_neighbor;
+
       /*
        *check all interfaces
        *so that we don't add ourselves to the
@@ -523,7 +490,6 @@ olsr_process_message_neighbors(struct neighbor_entry *neighbor,
         continue;
 
       /* Get the main address */
-
       neigh_addr = mid_lookup_main_addr(&message_neighbors->address);
 
       if (neigh_addr != NULL)
@@ -532,13 +498,12 @@ olsr_process_message_neighbors(struct neighbor_entry *neighbor,
       if(((message_neighbors->status == SYM_NEIGH) ||
           (message_neighbors->status == MPR_NEIGH)))
         {
-          //printf("\tProcessing %s\n", olsr_ip_to_string(&message_neighbors->address));
-          //printf("\tMain addr: %s\n", olsr_ip_to_string(neigh_addr));
-         
-          two_hop_neighbor_yet =
-            olsr_lookup_my_neighbors(neighbor,
-                                     &message_neighbors->address);
-
+         struct neighbor_2_list_entry *two_hop_neighbor_yet =
+            olsr_lookup_my_neighbors(neighbor, &message_neighbors->address);
+#ifdef DEBUG
+          olsr_printf(7, "\tProcessing %s\n", olsr_ip_to_string(&message_neighbors->address));
+          olsr_printf(7, "\tMain addr: %s\n", olsr_ip_to_string(neigh_addr));
+#endif
           if (two_hop_neighbor_yet != NULL)
             {
               /* Updating the holding time for this neighbor */
@@ -551,8 +516,11 @@ olsr_process_message_neighbors(struct neighbor_entry *neighbor,
                 olsr_lookup_two_hop_neighbor_table(&message_neighbors->address);
               if (two_hop_neighbor == NULL)
                 {
-                  //printf("Adding 2 hop neighbor %s\n\n", olsr_ip_to_string(&message_neighbors->address)); 
-
+#ifdef DEBUG
+                  olsr_printf(5, 
+                             "Adding 2 hop neighbor %s\n\n", 
+                             olsr_ip_to_string(&message_neighbors->address)); 
+#endif
                   changes_neighborhood = OLSR_TRUE;
                   changes_topology = OLSR_TRUE;
 
@@ -591,8 +559,10 @@ olsr_process_message_neighbors(struct neighbor_entry *neighbor,
 
           if (olsr_cnf->lq_level > 0)
             {
-              link = olsr_neighbor_best_link(&neighbor->neighbor_main_addr);
+             struct neighbor_list_entry *walker;
+             struct link_entry *link;
 
+              link = olsr_neighbor_best_link(&neighbor->neighbor_main_addr);
               // loop through the one-hop neighbors that see this
               // two hop neighbour
 
index 91cad13..6505359 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: process_routes.c,v 1.15 2004/12/03 18:43:34 tlopatic Exp $
+ * $Id: process_routes.c,v 1.16 2005/01/17 20:18:22 kattemat Exp $
  */
 
 
@@ -123,7 +123,6 @@ struct destination_n *
 olsr_build_update_list(struct rt_entry *from_table,struct rt_entry *in_table)
 {
   struct destination_n *kernel_route_list = NULL;
-  struct destination_n *route_list = NULL;
   struct rt_entry      *destination;
   olsr_u8_t            index;
   
@@ -135,7 +134,7 @@ olsr_build_update_list(struct rt_entry *from_table,struct rt_entry *in_table)
        {
          if (!olsr_find_up_route(destination, in_table))
            {
-             
+             struct destination_n *route_list;
              route_list = olsr_malloc(sizeof(struct destination_n), "create route tmp list");
              
              route_list->destination = destination;
@@ -162,8 +161,8 @@ olsr_build_update_list(struct rt_entry *from_table,struct rt_entry *in_table)
 int
 olsr_delete_all_kernel_routes()
 { 
-  struct destination_n *delete_kernel_list=NULL;
-  struct destination_n *tmp=NULL;
+  struct destination_n *delete_kernel_list = NULL;
+  struct destination_n *tmp = NULL;
   union olsr_ip_addr *tmp_addr;
 
   olsr_printf(1, "Deleting all routes...\n");
@@ -299,10 +298,10 @@ void
 olsr_delete_routes_from_kernel(struct destination_n *delete_kernel_list)
 {
   struct destination_n *destination_kernel;
-  olsr_16_t error;
 
   while(delete_kernel_list!=NULL)
     {
+      olsr_16_t error;
       if(olsr_cnf->ip_version == AF_INET)
        {
          /* IPv4 */
@@ -343,16 +342,14 @@ olsr_delete_routes_from_kernel(struct destination_n *delete_kernel_list)
 void 
 olsr_add_routes_in_kernel(struct destination_n *add_kernel_list)
 {
-  struct destination_n *destination_kernel = NULL;
-  struct destination_n *previous_node = add_kernel_list;
-  olsr_16_t error;
-  int metric_counter = 0, first_run = 1;
-  //char str[46];
-  
-  //printf("Calculating routes\n");
+  int metric_counter = 0;
+  olsr_bool first_run = OLSR_TRUE;
   
   while(add_kernel_list != NULL)
     {
+      struct destination_n *destination_kernel = NULL;
+      struct destination_n *previous_node = add_kernel_list;
+
       //searching for all the items with metric equal to n
       for(destination_kernel = add_kernel_list; destination_kernel != NULL; )
        {
@@ -360,19 +357,20 @@ olsr_add_routes_in_kernel(struct destination_n *add_kernel_list)
             ((first_run && 
               COMP_IP(&destination_kernel->destination->rt_dst, &destination_kernel->destination->rt_router)) || !first_run))
            {
+             olsr_16_t error;
              /* First add all 1-hop routes that has themselves as GW */
-
+             
              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) //print the error msg
                {
                  olsr_printf(1, "Add route(%s): %s\n", olsr_ip_to_string(&destination_kernel->destination->rt_dst), strerror(errno));
                  olsr_syslog(OLSR_LOG_ERR, "Add route:%m");
                }
-                   
+             
              //getting rid of this node and hooking up the broken point
              if(destination_kernel == add_kernel_list) 
                {
@@ -396,9 +394,9 @@ olsr_add_routes_in_kernel(struct destination_n *add_kernel_list)
                
        }
       if(first_run)
-       first_run = 0;
+       first_run = OLSR_FALSE;
       else
-       ++metric_counter;
+       metric_counter++;
     }
        
 }
index 6fb48f5..b59acfa 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: routing_table.c,v 1.11 2004/11/21 11:28:56 kattemat Exp $
+ * $Id: routing_table.c,v 1.12 2005/01/17 20:18:22 kattemat Exp $
  */
 
 
@@ -142,23 +142,18 @@ olsr_lookup_routing_table(union olsr_ip_addr *dst)
 void
 olsr_free_routing_table(struct rt_entry *table)
 {
-  struct rt_entry *destination;
-  struct rt_entry *dst_to_delete;
   olsr_u8_t       index;
   
-
   for(index=0;index<HASHSIZE;index++)
     {
-      destination = table[index].next;
+      struct rt_entry *destination = table[index].next;
 
       while(destination != &table[index])
        {
-         dst_to_delete = destination;
+         struct rt_entry *dst_to_delete = destination;
          destination = destination->next;
 
-         dst_to_delete->next->prev = dst_to_delete->prev;
-         dst_to_delete->prev->next = dst_to_delete->next;
-
+         DEQUEUE_ELEM(dst_to_delete);
          free(dst_to_delete);
        }
     }
@@ -227,23 +222,22 @@ olsr_insert_routing_table(union olsr_ip_addr *dst, union olsr_ip_addr *router, i
 /**
  *Insert all the one hop neighbors in the routing table.
  *
- *@return a pointer to a destination_n linked-list of the neighbors.
+ *@return
  */
 static int
 olsr_fill_routing_table_with_neighbors()
 {
   olsr_u8_t              index;
-  struct neighbor_entry  *neighbor;
   struct rt_entry        *new_route_entry=NULL;
 
-  struct addresses *addrs=NULL, *addrs2;
-
 #ifdef DEBUG
   olsr_printf(7, "FILL ROUTING TABLE WITH NEIGHBORS\n");
 #endif
 
   for(index=0;index<HASHSIZE;index++)
     {
+      struct neighbor_entry *neighbor;
+
       for(neighbor = neighbortable[index].next;
          neighbor != &neighbortable[index];
          neighbor=neighbor->next)     
@@ -251,26 +245,27 @@ olsr_fill_routing_table_with_neighbors()
 
          if(neighbor->status == SYM)
            {
+             static struct addresses addrs;
+             struct addresses *addrs2;
+
              /*
               *Insert all the neighbors addresses
               */
-             addrs = olsr_malloc(sizeof(struct addresses), "Fill routing table with neighbors");
 
-             COPY_IP(&addrs->address, &neighbor->neighbor_main_addr);
-             addrs->next = mid_lookup_aliases(&neighbor->neighbor_main_addr);
-             addrs2 = addrs;
+             COPY_IP(&addrs.address, &neighbor->neighbor_main_addr);
+             addrs.next = mid_lookup_aliases(&neighbor->neighbor_main_addr);
+             addrs2 = &addrs;
 
-             while(addrs!=NULL)
+             while(addrs2!=NULL)
                {
 #ifdef DEBUG
                  olsr_printf(7, "(ROUTE)Adding neighbor %s\n", olsr_ip_to_string(&addrs->address));
 #endif
                  /* New in 0.4.6 */
-                 new_route_entry = olsr_insert_routing_table(&addrs->address, get_neighbor_nexthop(&addrs->address), 1);
+                 new_route_entry = olsr_insert_routing_table(&addrs2->address, get_neighbor_nexthop(&addrs2->address), 1);
              
-                 addrs = addrs->next;
+                 addrs2 = addrs2->next;
                }
-             free(addrs2);
            }
        }
     }
@@ -290,26 +285,21 @@ olsr_fill_routing_table_with_neighbors()
 static struct destination_n *
 olsr_fill_routing_table_with_two_hop_neighbors()
 {
-  struct destination_n         *list_destination_n=NULL;
-  struct destination_n         *list_destination_tmp=NULL;
-  olsr_u8_t                    index;
-  struct neighbor_entry        *neighbor;
-  struct rt_entry              *new_route_entry=NULL;
-  struct neighbor_2_list_entry *neigh_2_list; 
-  union olsr_ip_addr           *n2_addr;
-  struct addresses *addrs=NULL, *addrs2;
-  struct neighbor_list_entry   *neighbors;
-  int                          neighbor_ok;
+  struct destination_n *list_destination_n=NULL;
+  olsr_u8_t            index;
 
   //printf("FILL ROUTING TABLE WITH TWO HOP NEIGHBORS\n");
 
   for(index=0;index<HASHSIZE;index++)
     {
+      struct neighbor_entry *neighbor;
+
       for(neighbor = neighbortable[index].next;
          neighbor != &neighbortable[index];
          neighbor=neighbor->next)     
        {
-         
+         struct neighbor_2_list_entry *neigh_2_list; 
+
          if(neighbor->status != SYM)
            continue;
          
@@ -320,6 +310,11 @@ olsr_fill_routing_table_with_two_hop_neighbors()
              neigh_2_list != &neighbor->neighbor_2_list;
              neigh_2_list = neigh_2_list->next)
            {
+             olsr_bool neighbor_ok;
+             union olsr_ip_addr *n2_addr;
+             static struct addresses addrs;
+             struct addresses *addrsp;
+             struct neighbor_list_entry *neighbors;
              
              n2_addr = &neigh_2_list->neighbor_2->neighbor_2_addr;
              
@@ -335,7 +330,7 @@ olsr_fill_routing_table_with_two_hop_neighbors()
               * Neighbor is only added if avalible trough
               * a 1 hop neighbor with willingness != WILL_NEVER
               */
-             neighbor_ok = 0;
+             neighbor_ok = OLSR_FALSE;
 
              for(neighbors = neigh_2_list->neighbor_2->neighbor_2_nblist.next;
                  neighbors != &neigh_2_list->neighbor_2->neighbor_2_nblist;
@@ -343,7 +338,7 @@ olsr_fill_routing_table_with_two_hop_neighbors()
                {
                  if((neighbors->neighbor->status != NOT_NEIGH) &&
                     (neighbors->neighbor->willingness != WILL_NEVER))
-                   neighbor_ok = 1;
+                   neighbor_ok = OLSR_TRUE;
                }
 
              if(!neighbor_ok)
@@ -353,31 +348,34 @@ olsr_fill_routing_table_with_two_hop_neighbors()
                  continue;
                }
 
-             addrs = olsr_malloc(sizeof(struct addresses), "Fill rt table 2 hop neighbors");
-             
-             COPY_IP(&addrs->address, n2_addr);
-             addrs->next = mid_lookup_aliases(n2_addr);
-             addrs2 = addrs;
+             COPY_IP(&addrs.address, n2_addr);
+             addrs.next = mid_lookup_aliases(n2_addr);
+             addrsp = &addrs;
 
-             while(addrs!=NULL)
+             while(addrsp!=NULL)
                {
+                 struct rt_entry *new_route_entry = NULL;
 #ifdef DEBUG
-                 olsr_printf(7, "(ROUTE)Adding neighbor %s\n", olsr_ip_to_string(&addrs->address));
+                 olsr_printf(7, "(ROUTE)Adding neighbor %s\n", olsr_ip_to_string(&addrsp->address));
 #endif
                  /* New in 0.4.6 */
-                 new_route_entry = olsr_insert_routing_table(&addrs->address, get_neighbor_nexthop(&neighbor->neighbor_main_addr), 2);
+                 new_route_entry = 
+                   olsr_insert_routing_table(&addrsp->address, 
+                                             get_neighbor_nexthop(&neighbor->neighbor_main_addr), 
+                                             2);
 
                  if(new_route_entry != NULL)
                    {
-                     list_destination_tmp = olsr_malloc(sizeof(struct destination_n), "Fill rt table 2 hop tmp");
+                     struct destination_n *list_destination_tmp;
+                     list_destination_tmp = olsr_malloc(sizeof(struct destination_n), 
+                                                        "Fill rt table 2 hop tmp");
                      
                      list_destination_tmp->destination = new_route_entry;
                      list_destination_tmp->next = list_destination_n;
                      list_destination_n = list_destination_tmp;
                    }
-                 addrs = addrs->next; 
+                 addrsp = addrsp->next; 
                }
-             free(addrs2);
            }
        }
 
@@ -396,44 +394,38 @@ olsr_fill_routing_table_with_two_hop_neighbors()
  */
 void 
 olsr_calculate_routing_table()
-
 {
-  struct destination_n               *list_destination_n=NULL;
-  struct destination_n               *list_destination_n_1=NULL;
-  struct destination_n               *destination_n_1=NULL;
-  //struct topology_last_entry         *topo_last;
-  struct tc_entry                    *topo_entry;
-  struct topo_dst                    *topo_dest;
-  struct addresses                   *tmp_addrs, *tmp2_addrs;
-  int                                add_dest;
+  struct destination_n *list_destination_n_1 = NULL;
 
   olsr_move_route_table(routingtable, old_routes);
 
-
   /* Add neighbors */
   olsr_fill_routing_table_with_neighbors();
   /* Add two hop enighbors - now they are the "outer rim" */
   list_destination_n_1 = olsr_fill_routing_table_with_two_hop_neighbors();
 
-  /* List_destination_n_1 holds the "outer rim" */
-  list_destination_n = list_destination_n_1;
-
   while(list_destination_n_1!=NULL)
     {
+      /* List_destination_n_1 holds the "outer rim" */
+      struct destination_n *list_destination_n = list_destination_n_1;
+
       list_destination_n_1=NULL;
 
       /* Next "outer rim" */
       while(list_destination_n!=NULL)
        {
+         struct destination_n *destination_n_1=NULL;
+         struct tc_entry      *topo_entry;
+
          if((topo_entry = olsr_lookup_tc_entry(&list_destination_n->destination->rt_dst)) != NULL)
            {
-             topo_dest = topo_entry->destinations.next;
+             struct topo_dst *topo_dest = topo_entry->destinations.next;
 
              /* Loop trough this nodes MPR selectors */
              while(topo_dest != &topo_entry->destinations)
                {
-                 /* Check if dest is ourselves!! */
-                 add_dest = 1;
+                 static struct addresses tmp_addrs;
+                 struct addresses *tmp_addrsp;
                  
                  /* Do not add ourselves */
                  if(if_ifwithaddr(&topo_dest->T_dest_addr))
@@ -442,27 +434,26 @@ olsr_calculate_routing_table()
                      continue;
                    }
                  
-                 /* Find mid nodes */
-                 tmp_addrs = olsr_malloc(sizeof(struct addresses), "Calculate routing table MID");
-                 
-                 COPY_IP(&tmp_addrs->address, &topo_dest->T_dest_addr);
-                 tmp_addrs->next = mid_lookup_aliases(&topo_dest->T_dest_addr);
-                 tmp2_addrs = tmp_addrs;
+                 /* Find mid nodes */            
+                 COPY_IP(&tmp_addrs.address, &topo_dest->T_dest_addr);
+                 tmp_addrs.next = mid_lookup_aliases(&topo_dest->T_dest_addr);
+                 tmp_addrsp = &tmp_addrs;
                  
-                 while(tmp_addrs!=NULL)
+                 while(tmp_addrsp!=NULL)
                    {
-                     if(NULL==olsr_lookup_routing_table(&tmp_addrs->address))
+                     if(NULL==olsr_lookup_routing_table(&tmp_addrsp->address))
                        {
                          /* PRINT OUT: Last Hop to Final Destination */
                          /* The function ip_to_string has to be seperately */
                          olsr_printf(3, "%s -> ", olsr_ip_to_string(&list_destination_n->destination->rt_dst));
-                         olsr_printf(3, "%s\n", olsr_ip_to_string(&tmp_addrs->address) );
+                         olsr_printf(3, "%s\n", olsr_ip_to_string(&tmp_addrsp->address) );
                          
-                         destination_n_1 = olsr_malloc(sizeof(struct destination_n), "Calculate routing table 2");
+                         destination_n_1 = olsr_malloc(sizeof(struct destination_n), 
+                                                       "Calculate routing table 2");
                          
                          /* Add this entry to the "outer rim" */
                          destination_n_1->destination = 
-                           olsr_insert_routing_table(&tmp_addrs->address, 
+                           olsr_insert_routing_table(&tmp_addrsp->address, 
                                                      &list_destination_n->destination->rt_router, 
                                                      list_destination_n->destination->rt_metric+1);
                          if(destination_n_1->destination != NULL)
@@ -471,9 +462,8 @@ olsr_calculate_routing_table()
                              list_destination_n_1=destination_n_1;
                            }
                        }
-                     tmp_addrs = tmp_addrs->next;
+                     tmp_addrsp = tmp_addrsp->next;
                    }
-                 free(tmp2_addrs);
                  
                  /* Next MPR selector */
                  topo_dest=topo_dest->next;
@@ -483,14 +473,12 @@ olsr_calculate_routing_table()
            } /* End check if already added */
          
          /* Delete this entry - do next */ 
-         destination_n_1=list_destination_n;
-         list_destination_n=list_destination_n->next;
+         destination_n_1 = list_destination_n;
+         list_destination_n = list_destination_n->next;
          free(destination_n_1);
          
        }
 
-      /* New "outer rim" */
-      list_destination_n=list_destination_n_1;
     }
 
 
@@ -528,10 +516,10 @@ static struct rt_entry *
 olsr_check_for_higher_hopcount(struct rt_entry *routes, struct hna_net *net, olsr_u16_t metric)
 {
   int index;
-  struct rt_entry *tmp_routes;
 
   for(index=0;index<HASHSIZE;index++)
     {
+      struct rt_entry *tmp_routes;
       /* All entries */
       for(tmp_routes = routes[index].next;
          tmp_routes != &routes[index];
@@ -568,10 +556,10 @@ struct rt_entry *
 olsr_check_for_lower_hopcount(struct rt_entry *routes, struct hna_net *net, olsr_u16_t metric)
 {
   int index;
-  struct rt_entry *tmp_routes;
 
   for(index=0;index<HASHSIZE;index++)
     {
+      struct rt_entry *tmp_routes;
       /* All entries */
       for(tmp_routes = routes[index].next;
          tmp_routes != &routes[index];
@@ -604,10 +592,7 @@ olsr_check_for_lower_hopcount(struct rt_entry *routes, struct hna_net *net, olsr
 void
 olsr_calculate_hna_routes()
 {
-  olsr_u32_t index, hna_hash;
-  struct hna_entry *tmp_hna;
-  struct hna_net *tmp_net;
-  struct rt_entry *tmp_rt, *new_rt;
+  olsr_u32_t index;
 
 #ifdef DEBUG
   olsr_printf(3, "Calculating HNA routes\n");
@@ -618,17 +603,19 @@ olsr_calculate_hna_routes()
   
   for(index=0;index<HASHSIZE;index++)
     {
+      struct hna_entry *tmp_hna;
       /* All entries */
       for(tmp_hna = hna_set[index].next;
          tmp_hna != &hna_set[index];
          tmp_hna = tmp_hna->next)
        {
-
+         struct hna_net *tmp_net;
          /* All networks */
          for(tmp_net = tmp_hna->networks.next;
              tmp_net != &tmp_hna->networks;
              tmp_net = tmp_net->next)
            {
+             struct rt_entry *tmp_rt, *new_rt;
              //printf("HNA: checking %s -> ", olsr_ip_to_string(&tmp_hna->A_gateway_addr));
              //printf("%s", olsr_ip_to_string(&tmp_net->A_network_addr));
 
@@ -685,6 +672,8 @@ olsr_calculate_hna_routes()
                    }
                  else
                    {
+                     olsr_u32_t  hna_hash;
+
                      /* Queue HASH will almost always be 0 */
                      hna_hash = olsr_hashing(&tmp_net->A_network_addr);
                      hna_routes[hna_hash].next->prev = new_rt;
@@ -723,13 +712,13 @@ void
 olsr_print_routing_table(struct rt_entry *table)
 {
 
-  struct rt_entry     *destination;
-  olsr_u8_t           index;
+  olsr_u8_t index;
 
   printf("ROUTING TABLE\n");
   printf("DESTINATION\tNEXT HOP\n");
   for(index=0;index<HASHSIZE;index++)
     {
+      struct rt_entry *destination;
       for(destination = table[index].next;
          destination != &table[index];
          destination = destination->next)
index a73b8a1..06f50d6 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: scheduler.c,v 1.23 2005/01/16 19:49:28 kattemat Exp $
+ * $Id: scheduler.c,v 1.24 2005/01/17 20:18:22 kattemat Exp $
  */
 
 
@@ -91,20 +91,15 @@ scheduler()
   struct tms tms_buf;
  
   pollrate = olsr_cnf->pollrate;
-
   interval_usec = (olsr_u32_t)(pollrate * 1000000);
 
   interval.tv_sec = interval_usec / 1000000;
   interval.tv_usec = interval_usec % 1000000;
 
   olsr_printf(1, "Scheduler started - polling every %0.2f seconds\n", pollrate);
-
   olsr_printf(3, "Max jitter is %f\n\n", max_jitter);
 
-
-
   /* Main scheduler event loop */
-
   for(;;)
     {
 
@@ -149,13 +144,11 @@ scheduler()
         {
          olsr_printf(3, "ANSN UPDATED %d\n\n", ansn);
          ansn++;
-#warning changes is set to OLSR_FALSE in scheduler now
           changes = OLSR_FALSE;
        }
 
 
       /* Check scheduled events */
-
       entry = event_functions;
 
       /* UPDATED - resets timer upon triggered execution */
index a31b30b..a6f0ff6 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: two_hop_neighbor_table.c,v 1.11 2004/12/04 17:06:57 tlopatic Exp $
+ * $Id: two_hop_neighbor_table.c,v 1.12 2005/01/17 20:18:22 kattemat Exp $
  */
 
 
@@ -78,27 +78,28 @@ olsr_init_two_hop_table()
 void
 olsr_delete_neighbor_pointer(struct neighbor_2_entry *two_hop_entry, union olsr_ip_addr *address)
 {
- struct        neighbor_list_entry *entry, *entry_to_delete;
-
- entry = two_hop_entry->neighbor_2_nblist.next;
-
-
- while(entry != &two_hop_entry->neighbor_2_nblist)
-   {
-     if(COMP_IP(&entry->neighbor->neighbor_main_addr, address))
-       {
-        entry_to_delete = entry;
-        entry = entry->next;
-
-        /* dequeue */
-        DEQUEUE_ELEM(entry_to_delete);
-
-        free(entry_to_delete);
-       }
-     else
-       entry = entry->next;
-     
-   }
+  struct neighbor_list_entry *entry;
+  
+  entry = two_hop_entry->neighbor_2_nblist.next;
+  
+  
+  while(entry != &two_hop_entry->neighbor_2_nblist)
+    {
+      if(COMP_IP(&entry->neighbor->neighbor_main_addr, address))
+       {
+         struct neighbor_list_entry *entry_to_delete = entry;
+         entry = entry->next;
+         
+         /* dequeue */
+         DEQUEUE_ELEM(entry_to_delete);
+         
+         free(entry_to_delete);
+       }
+      else
+       {
+         entry = entry->next;
+       }
+    }
 }
 
 
@@ -113,29 +114,24 @@ olsr_delete_neighbor_pointer(struct neighbor_2_entry *two_hop_entry, union olsr_
 void
 olsr_delete_two_hop_neighbor_table(struct neighbor_2_entry *two_hop_neighbor)
 {
-  struct neighbor_list_entry *one_hop_list, *entry_to_delete;
-  struct neighbor_entry      *one_hop_entry;
+  struct neighbor_list_entry *one_hop_list;
   
   one_hop_list = two_hop_neighbor->neighbor_2_nblist.next;
   
   /* Delete one hop links */
   while(one_hop_list != &two_hop_neighbor->neighbor_2_nblist)
     {
-      one_hop_entry = one_hop_list->neighbor;
+      struct neighbor_entry *one_hop_entry = one_hop_list->neighbor;
+      struct neighbor_list_entry *entry_to_delete = one_hop_list;
+
       olsr_delete_neighbor_2_pointer(one_hop_entry, &two_hop_neighbor->neighbor_2_addr);
-      
-      entry_to_delete = one_hop_list;
-      
       one_hop_list = one_hop_list->next;
-      
       /* no need to dequeue */
-
       free(entry_to_delete);
     }
   
   /* dequeue */
   DEQUEUE_ELEM(two_hop_neighbor);
-  
   free(two_hop_neighbor);
 }
 
@@ -176,7 +172,6 @@ olsr_lookup_two_hop_neighbor_table(union olsr_ip_addr *dest)
 
   struct neighbor_2_entry  *neighbor_2;
   olsr_u32_t               hash;
-  struct addresses *adr;
 
   //printf("LOOKING FOR %s\n", olsr_ip_to_string(dest));
   hash = olsr_hashing(dest);
@@ -186,6 +181,8 @@ olsr_lookup_two_hop_neighbor_table(union olsr_ip_addr *dest)
       neighbor_2 != &two_hop_neighbortable[hash];
       neighbor_2 = neighbor_2->next)
     {
+      struct addresses *adr;
+
       //printf("Checking %s\n", olsr_ip_to_string(dest));
       if (COMP_IP(&neighbor_2->neighbor_2_addr, dest))
        return neighbor_2;
@@ -245,11 +242,6 @@ void
 olsr_print_two_hop_neighbor_table()
 {
   int i;
-  struct neighbor_2_entry *neigh2;
-  struct neighbor_list_entry *entry;
-  struct neighbor_entry *neigh;
-  olsr_bool first;
-  double total_lq;
 
   olsr_printf(1, "\n--- %02d:%02d:%02d -------------------------- TWO-HOP NEIGHBORS\n\n",
               nowtm->tm_hour,
@@ -261,15 +253,18 @@ olsr_print_two_hop_neighbor_table()
 
   for (i = 0; i < HASHSIZE; i++)
     {
+      struct neighbor_2_entry *neigh2;
       for (neigh2 = two_hop_neighbortable[i].next;
            neigh2 != &two_hop_neighbortable[i]; neigh2 = neigh2->next)
        {
-          first = OLSR_TRUE;
+         struct neighbor_list_entry *entry;
+         olsr_bool first = OLSR_TRUE;
 
          for (entry = neigh2->neighbor_2_nblist.next;
                entry != &neigh2->neighbor_2_nblist; entry = entry->next)
            {
-              neigh = entry->neighbor;
+             double total_lq;
+             struct neighbor_entry *neigh = entry->neighbor;
 
               if (first)
                 {