Re: [Ipsec-tools-devel] splitnet_list_2str improvement
Brought to you by:
mit_warlord,
netbsd
From: VANHULLEBUS Y. <va...@fr...> - 2012-01-04 14:08:19
|
On Tue, Jan 03, 2012 at 01:23:58PM +0200, Timo Ters wrote: > Hi > > On 01/02/2012 08:08 PM, Rainer Weikusat wrote: > > In order to support older BSDs, it would probably make sense to do an > > AC_CHECK_HEADER for strings.h somewhere in configure.ac and include > > this header based on the results of this check. But this means > > somebody needs to make a descision where in configure.ac this should > > be done. My suggestion would be to put this among the 'basic toolchain > > checks'. > > > > Updated patch which conditionally includes strings.h when available: > > Fair enough. Looks good to me. Will commit later this week to cvs head > unless someone complains. Sounds ok for me. Yvan. > > -------------------------- > > diff -prNu ipsec-tools-0.8.0/configure.ac ipsec-tools-0.8.0.patched//configure.ac > > --- ipsec-tools-0.8.0/configure.ac 2012-01-02 18:01:47.934431388 +0000 > > +++ ipsec-tools-0.8.0.patched//configure.ac 2012-01-02 18:02:22.304304220 +0000 > > @@ -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 > > diff -prNu ipsec-tools-0.8.0/src/racoon/isakmp_unity.c ipsec-tools-0.8.0.patched//src/racoon/isakmp_unity.c > > --- ipsec-tools-0.8.0/src/racoon/isakmp_unity.c 2012-01-02 17:37:05.114807283 +0000 > > +++ ipsec-tools-0.8.0.patched//src/racoon/isakmp_unity.c 2012-01-02 18:02:55.314418214 +0000 > > @@ -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" > > @@ -398,16 +401,17 @@ char * splitnet_list_2str(list, splitnet > > 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); > > } > > > > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Ipsec-tools-devel mailing list > Ips...@li... > https://lists.sourceforge.net/lists/listinfo/ipsec-tools-devel |