From Rainer Weikusat <rweikusat@mobileactivedefense.com>: Enhance splitnet

environment variable string value generation.
This commit is contained in:
tteras 2012-01-10 12:07:30 +00:00
parent b008bd8cf7
commit aa9b8479a9
2 changed files with 9 additions and 5 deletions

View File

@ -112,7 +112,7 @@ esac
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(limits.h sys/time.h unistd.h stdarg.h varargs.h)
AC_CHECK_HEADERS(shadow.h)
AC_CHECK_HEADERS(shadow.h strings.h)
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

View File

@ -1,4 +1,4 @@
/* $NetBSD: isakmp_unity.c,v 1.10 2012/01/01 17:31:42 tteras Exp $ */
/* $NetBSD: isakmp_unity.c,v 1.11 2012/01/10 12:07:30 tteras Exp $ */
/* Id: isakmp_unity.c,v 1.10 2006/07/31 04:49:23 manubsd Exp */
@ -62,6 +62,9 @@
#endif
#include <ctype.h>
#include <resolv.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "var.h"
#include "misc.h"
@ -399,16 +402,17 @@ char * splitnet_list_2str(list, splitnet_ipaddr)
while (netentry != NULL) {
inet_ntop(AF_INET, &netentry->network.addr4, tmp1, 40);
inet_ntop(AF_INET, &netentry->network.mask4, tmp2, 40);
if (splitnet_ipaddr == CIDR) {
uint32_t tmp3;
int cidrmask;
tmp3 = ntohl(netentry->network.mask4.s_addr);
for (cidrmask = 0; tmp3 != 0; cidrmask++)
tmp3 <<= 1;
cidrmask = 33 - ffs(tmp3);
if (cidrmask == 33) cidrmask = 0;
len += sprintf(str+len, "%s/%d ", tmp1, cidrmask);
} else {
inet_ntop(AF_INET, &netentry->network.mask4, tmp2, 40);
len += sprintf(str+len, "%s/%s ", tmp1, tmp2);
}