[Olsr-cvs] olsrd-current/lib/nameservice/src nameservice.h, 1.14, 1.15 nameservice.c, 1.33, 1.34

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


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

Modified Files:
	nameservice.h nameservice.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: nameservice.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** nameservice.h	5 Oct 2007 20:24:47 -0000	1.14
--- nameservice.h	5 Nov 2007 15:32:55 -0000	1.15
***************
*** 139,143 ****
  
  olsr_bool
! allowed_hostname_or_ip_in_service(char *service_line, regmatch_t *hostname_or_ip);
  
  void
--- 139,143 ----
  
  olsr_bool
! allowed_hostname_or_ip_in_service(const char *service_line, const regmatch_t *hostname_or_ip);
  
  void
***************
*** 160,179 ****
  
  olsr_bool
! allowed_ip(union olsr_ip_addr *addr);
  
  olsr_bool
! allowed_service(char *service_line);
  
  olsr_bool
! is_name_wellformed(char *service_line);
  
  olsr_bool
! is_service_wellformed(char *service_line);
  
  olsr_bool
! is_service_wellformed(char *service_line);
  
  olsr_bool
! is_latlon_wellformed(char *latlon_line);
  
  olsr_bool
--- 160,179 ----
  
  olsr_bool
! allowed_ip(const union olsr_ip_addr *addr);
  
  olsr_bool
! allowed_service(const char *service_line);
  
  olsr_bool
! is_name_wellformed(const char *service_line);
  
  olsr_bool
! is_service_wellformed(const char *service_line);
  
  olsr_bool
! is_service_wellformed(const char *service_line);
  
  olsr_bool
! is_latlon_wellformed(const char *latlon_line);
  
  olsr_bool

Index: nameservice.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** nameservice.c	2 Nov 2007 20:58:07 -0000	1.33
--- nameservice.c	5 Nov 2007 15:32:55 -0000	1.34
***************
*** 1239,1246 ****
   */
  olsr_bool
! allowed_ip(union olsr_ip_addr *addr)
  {
! 	struct hna4_entry *hna4;
! 	struct hna6_entry *hna6;
  	struct interface *iface;
  	union olsr_ip_addr tmp_ip, tmp_msk;
--- 1239,1245 ----
   */
  olsr_bool
! allowed_ip(const union olsr_ip_addr *addr)
  {
! 	struct local_hna_entry *hna;
  	struct interface *iface;
  	union olsr_ip_addr tmp_ip, tmp_msk;
***************
*** 1258,1269 ****
  	
  	if (olsr_cnf->ip_version == AF_INET) {
! 		for (hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
  		{
! 			OLSR_PRINTF(6, "HNA %s/%s\n", 
! 				olsr_ip_to_string(&hna4->net),
! 				olsr_ip_to_string(&hna4->netmask));
! 	
! 			if ( hna4->netmask.v4 != 0 &&
! 			    (addr->v4 & hna4->netmask.v4) == hna4->net.v4 ) {
  				OLSR_PRINTF(6, "MATCHED\n");
  				return OLSR_TRUE;
--- 1257,1271 ----
  	
  	if (olsr_cnf->ip_version == AF_INET) {
! 		for (hna = olsr_cnf->hna_entries; hna; hna = hna->next)
  		{
!             union olsr_ip_addr netmask;
! 			OLSR_PRINTF(6, "HNA %s/%d\n", 
! 				olsr_ip_to_string(&hna->net.prefix),
! 				hna->net.prefix_len);
! 			if ( hna->net.prefix_len == 0 )
! 				continue;
! 
!             olsr_prefix_to_netmask(&netmask, hna->net.prefix_len);
! 			if ((addr->v4 & netmask.v4) == hna->net.prefix.v4) {
  				OLSR_PRINTF(6, "MATCHED\n");
  				return OLSR_TRUE;
***************
*** 1271,1289 ****
  		}
  	} else {
! 		int i;
! 
! 		for (hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
  		{
  			OLSR_PRINTF(6, "HNA %s/%d\n", 
! 				olsr_ip_to_string(&hna6->net),
! 				hna6->prefix_len);
! 			if ( hna6->prefix_len == 0 )
  				continue;
! 			olsr_prefix_to_netmask(&tmp_msk, hna6->prefix_len);
  			for (i = 0; i < 16; i++) {
! 				tmp_ip.v6.s6_addr[i] = addr->v6.s6_addr[i] &
! 					tmp_msk.v6.s6_addr[i];
  			}
! 			if (COMP_IP(&tmp_ip, &hna6->net)) {
  				OLSR_PRINTF(6, "MATCHED\n");
  				return OLSR_TRUE;
--- 1273,1289 ----
  		}
  	} else {
! 		for (hna = olsr_cnf->hna_entries; hna; hna = hna->next)
  		{
+ 			int i;
  			OLSR_PRINTF(6, "HNA %s/%d\n", 
! 				olsr_ip_to_string(&hna->net.prefix),
! 				hna->net.prefix_len);
! 			if ( hna->net.prefix_len == 0 )
  				continue;
! 			olsr_prefix_to_netmask(&tmp_msk, hna->net.prefix_len);
  			for (i = 0; i < 16; i++) {
! 				tmp_ip.v6.s6_addr[i] = addr->v6.s6_addr[i] & tmp_msk.v6.s6_addr[i];
  			}
! 			if (COMP_IP(&tmp_ip, &hna->net)) {
  				OLSR_PRINTF(6, "MATCHED\n");
  				return OLSR_TRUE;
***************
*** 1299,1303 ****
   */
  olsr_bool
! is_name_wellformed(char *name) {
  	return regexec(&regex_t_name, name, 1, &regmatch_t_name, 0) == 0 ;
  }
--- 1299,1303 ----
   */
  olsr_bool
! is_name_wellformed(const char *name) {
  	return regexec(&regex_t_name, name, 1, &regmatch_t_name, 0) == 0 ;
  }
***************
*** 1309,1313 ****
   */
  olsr_bool
! allowed_service(char *service_line)
  {
  	/* the call of is_service_wellformed generates the submatches stored in regmatch_t_service
--- 1309,1313 ----
   */
  olsr_bool
! allowed_service(const char *service_line)
  {
  	/* the call of is_service_wellformed generates the submatches stored in regmatch_t_service
***************
*** 1324,1328 ****
  
  olsr_bool
! allowed_hostname_or_ip_in_service(char *service_line, regmatch_t *hostname_or_ip_match) 
  {
  	char *hostname_or_ip;
--- 1324,1328 ----
  
  olsr_bool
! allowed_hostname_or_ip_in_service(const char *service_line, const regmatch_t *hostname_or_ip_match) 
  {
  	char *hostname_or_ip;
***************
*** 1367,1371 ****
   */
  olsr_bool
! is_service_wellformed(char *service_line)
  {
  	return regexec(&regex_t_service, service_line, pmatch_service, regmatch_t_service, 0) == 0;
--- 1367,1371 ----
   */
  olsr_bool
! is_service_wellformed(const char *service_line)
  {
  	return regexec(&regex_t_service, service_line, pmatch_service, regmatch_t_service, 0) == 0;
***************
*** 1376,1380 ****
   */
  olsr_bool
! is_latlon_wellformed(char *latlon_line)
  {
  	int hna = -1;
--- 1376,1380 ----
   */
  olsr_bool
! is_latlon_wellformed(const char *latlon_line)
  {
  	int hna = -1;
***************
*** 1389,1410 ****
  olsr_bool get_isdefhna_latlon(void)
  {
! 	olsr_bool ret = OLSR_FALSE;
! 	if (AF_INET == olsr_cnf->ip_version)
! 	{
! 		struct hna4_entry *hna4;
! 		for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
! 		{
! 			if (0 == hna4->netmask.v4) ret = OLSR_TRUE;
! 		}
! 	}
! 	else
  	{
! 		struct hna6_entry *hna6;
! 		for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
! 		{
! 			if (0 == hna6->prefix_len) ret = OLSR_TRUE;
! 		}
  	}
! 	return ret;
  }
  
--- 1389,1400 ----
  olsr_bool get_isdefhna_latlon(void)
  {
!     struct local_hna_entry *hna;
!     for(hna = olsr_cnf->hna_entries; hna; hna = hna->next)
  	{
! 		if (0 == hna->net.prefix_len) {
!             return OLSR_TRUE;
!         }
  	}
! 	return OLSR_FALSE;
  }
  





More information about the Olsr-cvs mailing list