[Olsr-cvs] olsrd-current/src net_olsr.c,1.27,1.28

Bernd Petrovitsch (spam-protected)
Tue Aug 28 22:10:19 CEST 2007


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

Modified Files:
	net_olsr.c 
Log Message:
* reduced duplicated code

Index: net_olsr.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** net_olsr.c	20 Aug 2007 18:46:03 -0000	1.27
--- net_olsr.c	28 Aug 2007 20:10:16 -0000	1.28
***************
*** 103,140 ****
  init_net(void)
  {
!   /* Block invalid addresses */
!   if(olsr_cnf->ip_version == AF_INET)
!     {
!       union olsr_ip_addr addr;
!       int i;
!       /* IPv4 */
!       for(i = 0; deny_ipv4_defaults[i] != NULL; i++)
! 	{
! 	  if(inet_pton(olsr_cnf->ip_version, deny_ipv4_defaults[i], &addr) <= 0)
! 	    {
! 	      fprintf(stderr, "Error converting fixed IP %s for deny rule!!\n",
! 		      deny_ipv4_defaults[i]);
! 	      continue;
! 	    }
! 	  olsr_add_invalid_address(&addr);
! 	}
!     }
!   else 
!     {
!       union olsr_ip_addr addr;
!       int i;
!       /* IPv6 */
!       for(i = 0; deny_ipv6_defaults[i] != NULL; i++)
! 	{
! 	  if(inet_pton(olsr_cnf->ip_version, deny_ipv6_defaults[i], &addr) <= 0)
! 	    {
! 	      fprintf(stderr, "Error converting fixed IP %s for deny rule!!\n",
! 		      deny_ipv6_defaults[i]);
! 	      continue;
! 	    }
! 	  olsr_add_invalid_address(&addr);
! 	}
! 
      }
  }
  
--- 103,116 ----
  init_net(void)
  {
!   const char * const *defaults = olsr_cnf->ip_version == AF_INET ? deny_ipv4_defaults : deny_ipv6_defaults;
!   
!   for (; *defaults != NULL; defaults++) {
!     union olsr_ip_addr addr;
!     if(inet_pton(olsr_cnf->ip_version, *defaults, &addr) <= 0){
!       fprintf(stderr, "Error converting fixed IP %s for deny rule!!\n", *defaults);
!       continue;
      }
+     olsr_add_invalid_address(&addr);
+   }
  }
  





More information about the Olsr-cvs mailing list