[Olsr-cvs] olsrd-current/lib/dot_draw/src olsrd_dot_draw.c, 1.29, 1.30

Bernd Petrovitsch (spam-protected)
Mon Nov 5 16:32:57 CET 2007


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

Modified Files:
	olsrd_dot_draw.c 
Log Message:
Cleanup:
* Merged "struct hna4_entry" and "struct hna6_entry" into
  "struct local_hna_entry" (as "struct hna_entry" is a different thing)
  Both have almost the same data (IP address + netmask/prefix) so we use
  the quite new "struct olsr_ip_prefix" to store it.
  Also merged the "hna4" and "hna6" pointer in "struct olsr_config" -
  look at the global "olsr_cnf->ip_version".
* const'ified here and there
* added a olsr_ip_prefix_to_string() function


Index: olsrd_dot_draw.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/src/olsrd_dot_draw.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** olsrd_dot_draw.c	3 Nov 2007 23:11:40 -0000	1.29
--- olsrd_dot_draw.c	5 Nov 2007 15:32:55 -0000	1.30
***************
*** 90,94 ****
  
  static char*
! olsr_netmask_to_string(union hna_netmask *mask);
  
  /* Event function to register with the sceduler */
--- 90,94 ----
  
  static char*
! olsr_netmask_to_string(const union hna_netmask *mask);
  
  /* Event function to register with the sceduler */
***************
*** 100,110 ****
  
  static void
! ipc_print_neigh_link(struct neighbor_entry *neighbor);
  
  static void
! ipc_print_tc_link(struct tc_entry *entry, struct tc_edge_entry *dst_entry);
  
  static void
! ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
  
  static int
--- 100,110 ----
  
  static void
! ipc_print_neigh_link(const struct neighbor_entry *neighbor);
  
  static void
! ipc_print_tc_link(const struct tc_entry *entry, const struct tc_edge_entry *dst_entry);
  
  static void
! ipc_print_net(const union olsr_ip_addr *, const union olsr_ip_addr *, const union hna_netmask *);
  
  static int
***************
*** 151,155 ****
  
  static void
! ipc_print_neigh_link(struct neighbor_entry *neighbor)
  {
    char buf[256];
--- 151,155 ----
  
  static void
! ipc_print_neigh_link(const struct neighbor_entry *neighbor)
  {
    char buf[256];
***************
*** 297,305 ****
    struct tc_entry *tc;
    struct tc_edge_entry *tc_edge;
-   struct hna_entry *tmp_hna;
-   struct hna_net *tmp_net;
-   struct hna4_entry *hna4;
-   struct hna6_entry *hna6;
-   union hna_netmask hna_msk;
  
    res = 0;
--- 297,300 ----
***************
*** 331,379 ****
  
        /* HNA entries */
!       for(index=0;index<HASHSIZE;index++)
! 	{
! 	  tmp_hna = hna_set[index].next;
  	  /* Check all entrys */
! 	  while(tmp_hna != &hna_set[index])
! 	    {
  	      /* Check all networks */
! 	      tmp_net = tmp_hna->networks.next;
! 	      
! 	      while(tmp_net != &tmp_hna->networks)
! 		{
  		  ipc_print_net(&tmp_hna->A_gateway_addr, 
  				&tmp_net->A_network_addr, 
  				&tmp_net->A_netmask);
! 		  tmp_net = tmp_net->next;
! 		}
! 	      
! 	      tmp_hna = tmp_hna->next;
! 	    }
! 	}
  
        /* Local HNA entries */
!       if (olsr_cnf->ip_version == AF_INET)
!        {
!        hna4 = olsr_cnf->hna4_entries;
!        while(hna4)
!         {
!          hna_msk.v4 = hna4->netmask.v4;
!          ipc_print_net(&olsr_cnf->interfaces->interf->ip_addr,
!                        &hna4->net,
!                        &hna_msk);
!          hna4 = hna4->next;
!         }
!        }
!       else
!        {
!        hna6 = olsr_cnf->hna6_entries;
!        while(hna6)
!         {
!          hna_msk.v6 = hna6->prefix_len;
!          ipc_print_net(&olsr_cnf->interfaces->interf->ip_addr,
!                        &hna6->net,
!                        &hna_msk);
!          hna6 = hna6->next;
!         }
        }
  
--- 326,366 ----
  
        /* HNA entries */
!       for(index=0;index<HASHSIZE;index++) {
!           struct hna_entry *tmp_hna;
  	  /* Check all entrys */
! 	  for (tmp_hna = hna_set[index].next; tmp_hna != &hna_set[index]; tmp_hna = tmp_hna->next) {
  	      /* Check all networks */
!               struct hna_net *tmp_net;
! 	      for (tmp_net = tmp_hna->networks.next; tmp_net != &tmp_hna->networks; tmp_net = tmp_net->next) {
  		  ipc_print_net(&tmp_hna->A_gateway_addr, 
  				&tmp_net->A_network_addr, 
  				&tmp_net->A_netmask);
!               }
!           }
!       }
  
        /* Local HNA entries */
!       if (olsr_cnf->ip_version == AF_INET) {
!           struct local_hna_entry *hna;
!           for (hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
!               union olsr_ip_addr netmask;
!               union hna_netmask hna_msk;
!               //hna_msk.v4 = hna4->netmask.v4;
!               olsr_prefix_to_netmask(&netmask, hna->net.prefix_len);
!               hna_msk.v4 = netmask.v4;
!               ipc_print_net(&olsr_cnf->interfaces->interf->ip_addr,
!                             &hna->net.prefix,
!                             &hna_msk);
!               
!           }
!       } else {
!           struct local_hna_entry *hna;
!           for (hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
!               union hna_netmask hna_msk;
!               hna_msk.v6 = hna->net.prefix_len;
!               ipc_print_net(&olsr_cnf->interfaces->interf->ip_addr,
!                             &hna->net.prefix,
!                             &hna_msk);
!           }
        }
  
***************
*** 391,395 ****
  
  static void
! ipc_print_tc_link(struct tc_entry *entry, struct tc_edge_entry *dst_entry)
  {
    char buf[256];
--- 378,382 ----
  
  static void
! ipc_print_tc_link(const struct tc_entry *entry, const struct tc_edge_entry *dst_entry)
  {
    char buf[256];
***************
*** 404,408 ****
  
  static void
! ipc_print_net(union olsr_ip_addr *gw, union olsr_ip_addr *net, union hna_netmask *mask)
  {
    const char *adr;
--- 391,395 ----
  
  static void
! ipc_print_net(const union olsr_ip_addr *gw, const union olsr_ip_addr *net, const union hna_netmask *mask)
  {
    const char *adr;
***************
*** 460,481 ****
  
  static char*
! olsr_netmask_to_string(union hna_netmask *mask)
  {
    char *ret;
    struct in_addr in;
  
!   if(olsr_cnf->ip_version == AF_INET)
!     {
        in.s_addr = mask->v4;
        ret = inet_ntoa(in);
!     }
!   else
!     {
        /* IPv6 */
        static char netmask[5];
        sprintf(netmask, "%d", mask->v6);
        ret = netmask;
!     }
! 
    return ret;
  }
--- 447,464 ----
  
  static char*
! olsr_netmask_to_string(const union hna_netmask *mask)
  {
    char *ret;
    struct in_addr in;
  
!   if(olsr_cnf->ip_version == AF_INET) {
        in.s_addr = mask->v4;
        ret = inet_ntoa(in);
!   } else {
        /* IPv6 */
        static char netmask[5];
        sprintf(netmask, "%d", mask->v6);
        ret = netmask;
!   }
    return ret;
  }





More information about the Olsr-cvs mailing list