LIBNETDISSECT_SRC=\
addrtoname.c \
+ addrtostr.c \
af.c \
ascii_strcasecmp.c \
checksum.c \
print-ascii.c \
print-atalk.c \
print-atm.c \
+ print-babel.c \
print-beep.c \
print-bfd.c \
print-bgp.c \
print-cnfp.c \
print-dccp.c \
print-decnet.c \
+ print-dhcp6.c \
print-domain.c \
print-dtp.c \
print-dvmrp.c \
print-fddi.c \
print-forces.c \
print-fr.c \
+ print-frag6.c \
print-ftp.c \
print-geneve.c \
print-geonet.c \
print-hsrp.c \
print-http.c \
print-icmp.c \
+ print-icmp6.c \
print-igmp.c \
print-igrp.c \
print-ip.c \
print-ip6.c \
+ print-ip6opts.c \
print-ipcomp.c \
print-ipfc.c \
print-ipnet.c \
print-m3ua.c \
print-medsa.c \
print-mobile.c \
+ print-mobility.c \
print-mpcp.c \
print-mpls.c \
print-mptcp.c \
print-openflow-1.0.c \
print-openflow.c \
print-ospf.c \
+ print-ospf6.c \
print-otv.c \
print-pgm.c \
print-pim.c \
print-radius.c \
print-raw.c \
print-rip.c \
+ print-ripng.c \
print-rpki-rtr.c \
print-rrcp.c \
print-rsvp.c \
+ print-rt6.c \
print-rtsp.c \
print-rx.c \
print-sctp.c \
print-zephyr.c \
print-zeromq.c \
signature.c \
+ strtoaddr.c \
util-print.c
LOCALSRC = @LOCALSRC@
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
HDR = \
addrtoname.h \
+ addrtostr.h \
af.h \
ah.h \
appletalk.h \
signature.h \
slcompress.h \
smb.h \
+ strtoaddr.h \
tcp.h \
netdissect-stdinc.h \
timeval-operations.h \
lbl/os-sunos4.h \
lbl/os-ultrix4.h \
makemib \
- missing/addrinfo.h \
missing/dlnames.c \
missing/datalinks.c \
- missing/getnameinfo.c \
missing/getopt_long.c \
- missing/inet_aton.c \
- missing/inet_ntop.c \
- missing/inet_pton.c \
missing/snprintf.c \
missing/strdup.c \
missing/strlcat.c \
mkdep \
packetdat.awk \
pcap_dump_ftell.c \
- print-babel.c \
- print-dhcp6.c \
- print-frag6.c \
- print-icmp6.c \
- print-ip6opts.c \
- print-mobility.c \
- print-ospf6.c \
print-pflog.c \
- print-ripng.c \
- print-rt6.c \
print-smb.c \
send-ack.awk \
smbutil.c \
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
dlnames.o: $(srcdir)/missing/dlnames.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
-getnameinfo.o: $(srcdir)/missing/getnameinfo.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
getopt_long.o: $(srcdir)/missing/getopt_long.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c
-inet_pton.o: $(srcdir)/missing/inet_pton.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
-inet_ntop.o: $(srcdir)/missing/inet_ntop.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
-inet_aton.o: $(srcdir)/missing/inet_aton.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
snprintf.o: $(srcdir)/missing/snprintf.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
strdup.o: $(srcdir)/missing/strdup.c
dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl SUCH DAMAGE.
-dnl
-dnl Checks to see if AF_INET6 is defined
-AC_DEFUN(AC_CHECK_AF_INET6, [
- AC_MSG_CHECKING(for AF_INET6)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [int a = AF_INET6],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes ; then
- AC_DEFINE(HAVE_AF_INET6)
- fi
-])
-
-dnl
-dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
-dnl borrowed from LBL libpcap
-AC_DEFUN(AC_CHECK_SA_LEN, [
- AC_MSG_CHECKING(if sockaddr struct has sa_len member)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes ; then
- AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
- fi
-])
-
-dnl
-dnl Checks for addrinfo structure
-AC_DEFUN(AC_STRUCT_ADDRINFO, [
- AC_MSG_CHECKING(for addrinfo)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <netdb.h>],
- [struct addrinfo a],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes; then
- AC_DEFINE(HAVE_ADDRINFO, 1,
- [define if you have the addrinfo function])
- else
- AC_DEFINE(NEED_ADDRINFO_H, 1,
- [define if you need to include missing/addrinfo.h])
- fi
-])
-
-dnl
-dnl Checks for NI_MAXSERV
-AC_DEFUN(AC_NI_MAXSERV, [
- AC_MSG_CHECKING(for NI_MAXSERV)
- AC_CACHE_VAL($1,
- AC_EGREP_CPP(yes, [#include <netdb.h>
-#ifdef NI_MAXSERV
-yes
-#endif],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 != yes; then
- AC_DEFINE(NEED_ADDRINFO_H)
- fi
-])
-
-dnl
-dnl Checks for NI_NAMEREQD
-AC_DEFUN(AC_NI_NAMEREQD, [
- AC_MSG_CHECKING(for NI_NAMEREQD)
- AC_CACHE_VAL($1,
- AC_EGREP_CPP(yes, [#include <netdb.h>
-#ifdef NI_NOFQDN
-yes
-#endif],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 != yes; then
- AC_DEFINE(NEED_ADDRINFO_H)
- fi
-])
-
-dnl
-dnl Checks for sockaddr_storage structure
-AC_DEFUN(AC_STRUCT_SA_STORAGE, [
- AC_MSG_CHECKING(for sockaddr_storage)
- AC_CACHE_VAL($1,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [struct sockaddr_storage s],
- $1=yes,
- $1=no))
- AC_MSG_RESULT($$1)
- if test $$1 = yes; then
- AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
- [define if you have struct sockaddr_storage])
- fi
-])
-
-dnl
-dnl check for h_errno
-AC_DEFUN(AC_VAR_H_ERRNO, [
- AC_MSG_CHECKING(for h_errno)
- AC_CACHE_VAL(ac_cv_var_h_errno,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <netdb.h>],
- [int foo = h_errno;],
- ac_cv_var_h_errno=yes,
- ac_cv_var_h_errno=no))
- AC_MSG_RESULT($ac_cv_var_h_errno)
- if test "$ac_cv_var_h_errno" = "yes"; then
- AC_DEFINE(HAVE_H_ERRNO, 1,
- [define if you have the h_errno variable])
- fi
-])
-
dnl
dnl Test for __attribute__
dnl
#include "netdissect.h"
#include "addrtoname.h"
+#include "addrtostr.h"
#include "llc.h"
#include "setsignal.h"
#include "extract.h"
static struct hnamemem dnaddrtable[HASHNAMESIZE];
static struct hnamemem ipxsaptable[HASHNAMESIZE];
-#if defined(INET6) && defined(_WIN32)
+#ifdef _WIN32
/*
* fake gethostbyaddr for Win2k/XP
* gethostbyaddr() returns incorrect value when AF_INET6 is passed
}
}
#define gethostbyaddr win32_gethostbyaddr
-#endif /* INET6 & _WIN32 */
+#endif /* _WIN32 */
-#ifdef INET6
struct h6namemem {
struct in6_addr addr;
char *name;
};
static struct h6namemem h6nametable[HASHNAMESIZE];
-#endif /* INET6 */
struct enamemem {
u_short e_addr0;
return (p->name);
}
-#ifdef INET6
/*
* Return a name for the IP6 address pointed to by ap. This address
* is assumed to be in network byte order.
return (p->name);
}
}
- cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
+ cp = addrtostr6(ap, ntop_buf, sizeof(ntop_buf));
p->name = strdup(cp);
if (p->name == NULL)
(*ndo->ndo_error)(ndo, "getname6: strdup(cp)");
return (p->name);
}
-#endif /* INET6 */
static const char hex[] = "0123456789abcdef";
return (p);
}
-#ifdef INET6
/* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
struct h6namemem *
newh6namemem(netdissect_options *ndo)
p = ptr++;
return (p);
}
-#endif /* INET6 */
/* Represent TCI part of the 802.1Q 4-octet tag as text. */
const char *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/*
+ * Definitions to let us compile most of the IPv6 code even on systems
+ * without IPv6 support.
+ */
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
+
/* Name to address translation routines. */
enum {
extern const char *protoid_string(netdissect_options *, const u_char *);
extern const char *ipxsap_string(netdissect_options *, u_short);
extern const char *getname(netdissect_options *, const u_char *);
-#ifdef INET6
extern const char *getname6(netdissect_options *, const u_char *);
-#endif
extern const char *intoa(uint32_t);
extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
extern struct hnamemem *newhnamemem(netdissect_options *);
-#ifdef INET6
extern struct h6namemem *newh6namemem(netdissect_options *);
-#endif
extern const char * ieee8021q_tci_string(const uint16_t);
#define ipaddr_string(ndo, p) getname(ndo, (const u_char *)(p))
-#ifdef INET6
#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
-#endif
/*
- * Copyright (c) 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
- * Högskolan and its contributors.
+ * Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
#endif
#include <netdissect-stdinc.h>
+#include "addrtostr.h"
#include <stdio.h>
+#include <string.h>
/*
*
#define INT16SZ 2 /* word size */
#endif
-static const char *
-inet_ntop_v4 (const void *src, char *dst, size_t size)
+const char *
+addrtostr (const void *src, char *dst, size_t size)
{
+ const u_char *srcaddr = (const u_char *)src;
const char digits[] = "0123456789";
int i;
- struct in_addr *addr = (struct in_addr *)src;
- u_long a = ntohl(addr->s_addr);
const char *orig_dst = dst;
if (size < INET_ADDRSTRLEN) {
return NULL;
}
for (i = 0; i < 4; ++i) {
- int n = (a >> (24 - i * 8)) & 0xFF;
+ int n = *srcaddr++;
int non_zerop = 0;
if (non_zerop || n / 100 > 0) {
return orig_dst;
}
-#ifdef INET6
/*
* Convert IPv6 binary address into presentation (printable) format.
*/
-static const char *
-inet_ntop_v6 (const u_char *src, char *dst, size_t size)
+const char *
+addrtostr6 (const void *src, char *dst, size_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
+ const u_char *srcaddr = (const u_char *)src;
char tmp [INET6_ADDRSTRLEN+1];
char *tp;
struct {
*/
memset (words, 0, sizeof(words));
for (i = 0; i < IN6ADDRSZ; i++)
- words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));
+ words[i/2] |= (srcaddr[i] << ((1 - (i % 2)) << 3));
best.len = 0;
best.base = -1;
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
- if (!inet_ntop_v4(src+12, tp, sizeof(tmp) - (tp - tmp)))
+ if (!addrtostr(srcaddr+12, tp, sizeof(tmp) - (tp - tmp)))
{
errno = ENOSPC;
+fprintf(stderr, "Bleah 1\n");
return (NULL);
}
tp += strlen(tp);
if ((size_t)(tp - tmp) > size)
{
errno = ENOSPC;
+fprintf(stderr, "Bleah 2\n");
return (NULL);
}
return strcpy (dst, tmp);
}
-#endif /* INET6 */
-
-
-const char *
-inet_ntop(int af, const void *src, char *dst, size_t size)
-{
- switch (af) {
- case AF_INET :
- return inet_ntop_v4 (src, dst, size);
-#ifdef INET6
- case AF_INET6:
- return inet_ntop_v6 ((const u_char*)src, dst, size);
-#endif
- default :
- errno = EAFNOSUPPORT;
- return NULL;
- }
-}
/*
- * Copyright (c) 1999 Kungliga Tekniska H�gskolan
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Kungliga Tekniska
- * H�gskolan and its contributors.
+ * Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* SUCH DAMAGE.
*/
-#include <netdissect-stdinc.h>
+/* Address to printable string translation routines. */
-int
-inet_pton(int af, const char *src, void *dst)
-{
- if (af != AF_INET) {
- errno = EAFNOSUPPORT;
- return -1;
- }
- return inet_aton (src, dst);
-}
+extern const char *addrtostr(const void *src, char *dst, size_t size);
+extern const char *addrtostr6(const void *src, char *dst, size_t size);
/* config.h.in. Generated from configure.in by autoheader. */
-/* define if you have the addrinfo function */
-#undef HAVE_ADDRINFO
-
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
-/* Define to 1 if you have the `getnameinfo' function. */
-#undef HAVE_GETNAMEINFO
-
/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
/* define if you have getrpcbynumber() */
#undef HAVE_GETRPCBYNUMBER
-/* define if you have the h_errno variable */
-#undef HAVE_H_ERRNO
-
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <openssl/evp.h> header file. */
#undef HAVE_OPENSSL_EVP_H
+/* define if the OS provides AF_INET6 and struct in6_addr */
+#undef HAVE_OS_IPV6_SUPPORT
+
/* if there's an os_proto.h for this platform, to use additional prototypes */
#undef HAVE_OS_PROTO_H
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
-/* Define if you enable IPv6 support */
-#undef INET6
-
/* if unaligned access fails */
#undef LBL_ALIGN
-/* define if you need to include missing/addrinfo.h */
-#undef NEED_ADDRINFO_H
-
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
with_user
with_chroot
with_sandbox_capsicum
-enable_ipv6
with_system_libpcap
with_crypto
with_cap_ng
--disable-universal don't build universal on OS X
--enable-smb enable possibly-buggy SMB printer default=yes
--disable-smb disable possibly-buggy SMB printer
- --enable-ipv6 enable ipv6 (with ipv4) support
- --disable-ipv6 disable ipv6 support
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
fi
#
-# We must check this before checking whether to enable IPv6, because,
-# on some platforms (such as SunOS 5.x), the test program requires
-# the extra networking libraries.
+# We must check this before checking whether to check the OS's IPv6,
+# support because, on some platforms (such as SunOS 5.x), the test
+# program requires the extra networking libraries.
#
# Most operating systems have gethostbyname() in the default searched
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable ipv6" >&5
-$as_echo_n "checking whether to enable ipv6... " >&6; }
-# Check whether --enable-ipv6 was given.
-if test "${enable_ipv6+set}" = set; then :
- enableval=$enable_ipv6; case "$enableval" in
-yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
- LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
-
-$as_echo "#define INET6 1" >>confdefs.h
-
- ipv6=yes
- ;;
-*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- ipv6=no
- ;;
- esac
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+#
+# Check whether AF_INET6 and struct in6_addr are defined.
+# If they aren't both defined, we don't have sufficient OS
+# support for IPv6, so we don't look for IPv6 support libraries,
+# and we define AF_INET6 and struct in6_addr ourselves.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the operating system supports IPv6" >&5
+$as_echo_n "checking whether the operating system supports IPv6... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- /* AF_INET6 available check */
+
+/* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
-$as_echo "#define INET6 1" >>confdefs.h
+$as_echo "#define HAVE_OS_IPV6_SUPPORT 1" >>confdefs.h
+
+ ipv6=yes
- ipv6=yes
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- ipv6=no
+ ipv6=no
+
+
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
ipv6type=unknown
ipv6lib=none
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
- ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6type=$i
fi
rm -f conftest*
ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
- ipv6trylibc=yes;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6trylibc=yes
fi
rm -f conftest*
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
- ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6type=$i
fi
rm -f conftest*
ipv6lib=inet6
ipv6libdir=/usr/inet6/lib
ipv6trylibc=yes;
- CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+ CFLAGS="-I/usr/inet6/include $CFLAGS"
fi
;;
toshiba)
$EGREP "yes" >/dev/null 2>&1; then :
ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6libdir=/usr/local/v6/lib
fi
rm -f conftest*
$EGREP "yes" >/dev/null 2>&1; then :
ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6libdir=/usr/local/v6/lib
fi
rm -f conftest*
fi
fi
-
-if test "$ipv6" = "yes"; then
- #
- # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
- # function in libc; there are "ngetaddrinfo()" and
- # "ogetaddrinfo()" functions, and <netdb.h> #defines
- # "getaddrinfo" to be either "ngetaddrinfo" or
- # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
- # or _XOPEN_SOURCE_EXTENDED are defined or not.
- #
- # So this test doesn't work on Tru64 5.1, and possibly
- # on other 5.x releases. This causes the configure
- # script to become confused, and results in libpcap
- # being unbuildable.
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo" >&5
-$as_echo_n "checking for library containing getaddrinfo... " >&6; }
-if ${ac_cv_search_getaddrinfo+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char getaddrinfo ();
-int
-main ()
-{
-return getaddrinfo ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' socket; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_getaddrinfo=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_getaddrinfo+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_getaddrinfo+:} false; then :
-
-else
- ac_cv_search_getaddrinfo=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getaddrinfo" >&5
-$as_echo "$ac_cv_search_getaddrinfo" >&6; }
-ac_res=$ac_cv_search_getaddrinfo
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking getaddrinfo bug" >&5
-$as_echo_n "checking getaddrinfo bug... " >&6; }
- if ${td_cv_buggygetaddrinfo+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "$cross_compiling" = yes; then :
- td_cv_buggygetaddrinfo=unknown
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include <sys/types.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-main()
-{
- int passive, gaierr, inet4 = 0, inet6 = 0;
- struct addrinfo hints, *ai, *aitop;
- char straddr[INET6_ADDRSTRLEN], strport[16];
-
- for (passive = 0; passive <= 1; passive++) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_flags = passive ? AI_PASSIVE : 0;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
- (void)gai_strerror(gaierr);
- goto bad;
- }
- for (ai = aitop; ai; ai = ai->ai_next) {
- if (ai->ai_addr == NULL ||
- ai->ai_addrlen == 0 ||
- getnameinfo(ai->ai_addr, ai->ai_addrlen,
- straddr, sizeof(straddr), strport, sizeof(strport),
- NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
- goto bad;
- }
- switch (ai->ai_family) {
- case AF_INET:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "0.0.0.0") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "127.0.0.1") != 0) {
- goto bad;
- }
- }
- inet4++;
- break;
- case AF_INET6:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "::") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "::1") != 0) {
- goto bad;
- }
- }
- inet6++;
- break;
- case AF_UNSPEC:
- goto bad;
- break;
-#ifdef AF_UNIX
- case AF_UNIX:
-#else
-#ifdef AF_LOCAL
- case AF_LOCAL:
-#endif
-#endif
- default:
- /* another family support? */
- break;
- }
- }
- }
-
- /* supported family should be 2, unsupported family should be 0 */
- if (!(inet4 == 0 || inet4 == 2))
- goto bad;
- if (!(inet6 == 0 || inet6 == 2))
- goto bad;
-
- if (aitop)
- freeaddrinfo(aitop);
- exit(0);
-
- bad:
- if (aitop)
- freeaddrinfo(aitop);
- exit(1);
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- td_cv_buggygetaddrinfo=no
-else
- td_cv_buggygetaddrinfo=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-
- if test "$td_cv_buggygetaddrinfo" = no; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: good" >&5
-$as_echo "good" >&6; }
- elif test "$td_cv_buggygetaddrinfo" = unknown; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown (cross-compiling)" >&5
-$as_echo "unknown (cross-compiling)" >&6; }
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy" >&5
-$as_echo "buggy" >&6; }
- fi
-
- if test "$td_cv_buggygetaddrinfo" = "yes"; then
- #
- # XXX - it doesn't appear that "ipv6type" can ever be
- # set to "linux". Should this be testing for
- # "linux-glibc", or for that *or* "linux-libinet6"?
- # If the latter, note that "linux-libinet6" is also
- # the type given to some non-Linux OSes.
- #
- if test "$ipv6type" != "linux"; then
- echo 'Fatal: You must get working getaddrinfo() function.'
- echo ' or you can specify "--disable-ipv6"'.
- exit 1
- else
- echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
- echo ' Better upgrade your system library to newest version'
- echo ' of GNU C library (aka glibc).'
- fi
- fi
-
-fi
-
- ac_fn_c_check_func "$LINENO" "getnameinfo" "ac_cv_func_getnameinfo"
-if test "x$ac_cv_func_getnameinfo" = xyes; then :
- $as_echo "#define HAVE_GETNAMEINFO 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" getnameinfo.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS getnameinfo.$ac_objext"
- ;;
-esac
-
-fi
-
-
-fi
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_htoa declaration in netdnet/dnetdb.h" >&5
$as_echo_n "checking for dnet_htoa declaration in netdnet/dnetdb.h... " >&6; }
if ${td_cv_decl_netdnet_dnetdb_h_dnet_htoa+:} false; then :
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for addrinfo" >&5
-$as_echo_n "checking for addrinfo... " >&6; }
- if ${ac_cv_addrinfo+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <netdb.h>
-int
-main ()
-{
-struct addrinfo a
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_addrinfo=yes
-else
- ac_cv_addrinfo=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_addrinfo" >&5
-$as_echo "$ac_cv_addrinfo" >&6; }
- if test $ac_cv_addrinfo = yes; then
-
-$as_echo "#define HAVE_ADDRINFO 1" >>confdefs.h
-
- else
-
-$as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_addrinfo" = no; then
- missing_includes=yes
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NI_MAXSERV" >&5
-$as_echo_n "checking for NI_MAXSERV... " >&6; }
- if ${ac_cv_maxserv+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <netdb.h>
-#ifdef NI_MAXSERV
-yes
-#endif
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "yes" >/dev/null 2>&1; then :
- ac_cv_maxserv=yes
-else
- ac_cv_maxserv=no
-fi
-rm -f conftest*
-
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_maxserv" >&5
-$as_echo "$ac_cv_maxserv" >&6; }
- if test $ac_cv_maxserv != yes; then
- $as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_maxserv" = no; then
- missing_includes=yes
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NI_NAMEREQD" >&5
-$as_echo_n "checking for NI_NAMEREQD... " >&6; }
- if ${ac_cv_namereqd+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <netdb.h>
-#ifdef NI_NOFQDN
-yes
-#endif
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "yes" >/dev/null 2>&1; then :
- ac_cv_namereqd=yes
-else
- ac_cv_namereqd=no
-fi
-rm -f conftest*
-
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_namereqd" >&5
-$as_echo "$ac_cv_namereqd" >&6; }
- if test $ac_cv_namereqd != yes; then
- $as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_namereqd" = no; then
- missing_includes=yes
-fi
-
ac_fn_c_check_func "$LINENO" "vfprintf" "ac_cv_func_vfprintf"
if test "x$ac_cv_func_vfprintf" = xyes; then :
$as_echo "#define HAVE_VFPRINTF 1" >>confdefs.h
# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
# libraries (e.g., "-lsocket -lnsl" on Solaris).
#
-# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
-# use AC_CHECK_FUNC which doesn't let us specify the right #includes
-# to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
-# resolver, and the way it defines inet_{ntop,pton} is rather strange;
-# it does not ship with a libc symbol "inet_ntop()", it ships with
-# "_inet_ntop()", and has a #define macro in one of the system headers
-# to rename it.
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntop" >&5
-$as_echo_n "checking for inet_ntop... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[4], dst[128];
-inet_ntop(AF_INET, src, dst, sizeof(dst));
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- case " $LIBOBJS " in
- *" inet_ntop.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_pton" >&5
-$as_echo_n "checking for inet_pton... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[128], dst[4];
-inet_pton(AF_INET, src, dst);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- case " $LIBOBJS " in
- *" inet_pton.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton" >&5
-$as_echo_n "checking for inet_aton... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[128];
-struct in_addr dst;
-inet_aton(src, &dst);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- case " $LIBOBJS " in
- *" inet_aton.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_aton.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-#
-# Check for these after AC_LBL_LIBPCAP, for the same reason.
-#
# You are in a twisty little maze of UN*Xes, all different.
# Some might not have ether_ntohost().
# Some might have it, but not declare it in any header file.
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr struct has sa_len member" >&5
-$as_echo_n "checking if sockaddr struct has sa_len member... " >&6; }
- if ${ac_cv_sockaddr_has_sa_len+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <sys/types.h>
-# include <sys/socket.h>
-int
-main ()
-{
-u_int i = sizeof(((struct sockaddr *)0)->sa_len)
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sockaddr_has_sa_len=yes
-else
- ac_cv_sockaddr_has_sa_len=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sockaddr_has_sa_len" >&5
-$as_echo "$ac_cv_sockaddr_has_sa_len" >&6; }
- if test $ac_cv_sockaddr_has_sa_len = yes ; then
- $as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_sockaddr_has_sa_len" = no; then
- missing_includes=yes
-fi
-
ac_fn_c_check_func "$LINENO" "pcap_list_datalinks" "ac_cv_func_pcap_list_datalinks"
if test "x$ac_cv_func_pcap_list_datalinks" = xyes; then :
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for h_errno" >&5
-$as_echo_n "checking for h_errno... " >&6; }
- if ${ac_cv_var_h_errno+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <sys/types.h>
-# include <netdb.h>
-int
-main ()
-{
-int foo = h_errno;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_var_h_errno=yes
-else
- ac_cv_var_h_errno=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_h_errno" >&5
-$as_echo "$ac_cv_var_h_errno" >&6; }
- if test "$ac_cv_var_h_errno" = "yes"; then
-
-$as_echo "#define HAVE_H_ERRNO 1" >>confdefs.h
-
- fi
-
-
# Check for OpenSSL libcrypto
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use OpenSSL libcrypto" >&5
$as_echo_n "checking whether to use OpenSSL libcrypto... " >&6; }
fi
#
-# We must check this before checking whether to enable IPv6, because,
-# on some platforms (such as SunOS 5.x), the test program requires
-# the extra networking libraries.
+# We must check this before checking whether to check the OS's IPv6,
+# support because, on some platforms (such as SunOS 5.x), the test
+# program requires the extra networking libraries.
#
AC_LBL_LIBRARY_NET
-AC_MSG_CHECKING([whether to enable ipv6])
-AC_ARG_ENABLE(ipv6,
-[ --enable-ipv6 enable ipv6 (with ipv4) support
- --disable-ipv6 disable ipv6 support],
-[ case "$enableval" in
-yes) AC_MSG_RESULT(yes)
- LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
- AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
- ipv6=yes
- ;;
-*)
- AC_MSG_RESULT(no)
- ipv6=no
- ;;
- esac ],
-
- AC_COMPILE_IFELSE(
+#
+# Check whether AF_INET6 and struct in6_addr are defined.
+# If they aren't both defined, we don't have sufficient OS
+# support for IPv6, so we don't look for IPv6 support libraries,
+# and we define AF_INET6 and struct in6_addr ourselves.
+#
+AC_MSG_CHECKING([whether the operating system supports IPv6])
+AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE(
- [[/* AF_INET6 available check */
+ [[
+/* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#else
#error "AF_INET6 not defined"
#endif
- ]])
+ ]])
],
-[ AC_MSG_RESULT(yes)
- LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
- AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
- ipv6=yes],
-[ AC_MSG_RESULT(no)
- ipv6=no],
-[ AC_MSG_RESULT(no)
- ipv6=no]
-))
+ [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
+ [define if the OS provides AF_INET6 and struct in6_addr])
+ ipv6=yes
+ ],
+ [
+ AC_MSG_RESULT(no)
+ ipv6=no
+ ]
+)
ipv6type=unknown
ipv6lib=none
#ifdef IPV6_INRIA_VERSION
yes
#endif],
- [ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"])
+ [ipv6type=$i])
;;
kame)
dnl http://www.kame.net/
[ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
- ipv6trylibc=yes;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6trylibc=yes])
;;
linux-glibc)
dnl http://www.v6.linux.or.jp/
#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
yes
#endif],
- [ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"])
+ [ipv6type=$i])
;;
linux-libinet6)
dnl http://www.v6.linux.or.jp/
ipv6lib=inet6
ipv6libdir=/usr/inet6/lib
ipv6trylibc=yes;
- CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+ CFLAGS="-I/usr/inet6/include $CFLAGS"
fi
;;
toshiba)
#endif],
[ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6libdir=/usr/local/v6/lib])
;;
v6d)
AC_EGREP_CPP(yes,
#endif],
[ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6libdir=/usr/local/v6/lib])
;;
esac
if test "$ipv6type" != "unknown"; then
fi
fi
-
-if test "$ipv6" = "yes"; then
- #
- # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
- # function in libc; there are "ngetaddrinfo()" and
- # "ogetaddrinfo()" functions, and <netdb.h> #defines
- # "getaddrinfo" to be either "ngetaddrinfo" or
- # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
- # or _XOPEN_SOURCE_EXTENDED are defined or not.
- #
- # So this test doesn't work on Tru64 5.1, and possibly
- # on other 5.x releases. This causes the configure
- # script to become confused, and results in libpcap
- # being unbuildable.
- #
- AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
- AC_MSG_CHECKING(getaddrinfo bug)
- AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
-#include <sys/types.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-main()
-{
- int passive, gaierr, inet4 = 0, inet6 = 0;
- struct addrinfo hints, *ai, *aitop;
- char straddr[INET6_ADDRSTRLEN], strport[16];
-
- for (passive = 0; passive <= 1; passive++) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_flags = passive ? AI_PASSIVE : 0;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
- (void)gai_strerror(gaierr);
- goto bad;
- }
- for (ai = aitop; ai; ai = ai->ai_next) {
- if (ai->ai_addr == NULL ||
- ai->ai_addrlen == 0 ||
- getnameinfo(ai->ai_addr, ai->ai_addrlen,
- straddr, sizeof(straddr), strport, sizeof(strport),
- NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
- goto bad;
- }
- switch (ai->ai_family) {
- case AF_INET:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "0.0.0.0") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "127.0.0.1") != 0) {
- goto bad;
- }
- }
- inet4++;
- break;
- case AF_INET6:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "::") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "::1") != 0) {
- goto bad;
- }
- }
- inet6++;
- break;
- case AF_UNSPEC:
- goto bad;
- break;
-#ifdef AF_UNIX
- case AF_UNIX:
-#else
-#ifdef AF_LOCAL
- case AF_LOCAL:
-#endif
-#endif
- default:
- /* another family support? */
- break;
- }
- }
- }
-
- /* supported family should be 2, unsupported family should be 0 */
- if (!(inet4 == 0 || inet4 == 2))
- goto bad;
- if (!(inet6 == 0 || inet6 == 2))
- goto bad;
-
- if (aitop)
- freeaddrinfo(aitop);
- exit(0);
-
- bad:
- if (aitop)
- freeaddrinfo(aitop);
- exit(1);
-}
-],
- td_cv_buggygetaddrinfo=no,
- td_cv_buggygetaddrinfo=yes,
- td_cv_buggygetaddrinfo=unknown)])
- if test "$td_cv_buggygetaddrinfo" = no; then
- AC_MSG_RESULT(good)
- elif test "$td_cv_buggygetaddrinfo" = unknown; then
- AC_MSG_RESULT([unknown (cross-compiling)])
- else
- AC_MSG_RESULT(buggy)
- fi
-
- if test "$td_cv_buggygetaddrinfo" = "yes"; then
- #
- # XXX - it doesn't appear that "ipv6type" can ever be
- # set to "linux". Should this be testing for
- # "linux-glibc", or for that *or* "linux-libinet6"?
- # If the latter, note that "linux-libinet6" is also
- # the type given to some non-Linux OSes.
- #
- if test "$ipv6type" != "linux"; then
- echo 'Fatal: You must get working getaddrinfo() function.'
- echo ' or you can specify "--disable-ipv6"'.
- exit 1
- else
- echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
- echo ' Better upgrade your system library to newest version'
- echo ' of GNU C library (aka glibc).'
- fi
- fi
- ])
- AC_REPLACE_FUNCS(getnameinfo)
-fi
-
AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
[td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
[define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
fi
-dnl
-dnl Checks for addrinfo structure
-AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
-if test "$ac_cv_addrinfo" = no; then
- missing_includes=yes
-fi
-
-dnl
-dnl Checks for NI_MAXSERV
-AC_NI_MAXSERV(ac_cv_maxserv)
-if test "$ac_cv_maxserv" = no; then
- missing_includes=yes
-fi
-
-dnl
-dnl Checks for NI_NAMEREQD
-AC_NI_NAMEREQD(ac_cv_namereqd)
-if test "$ac_cv_namereqd" = no; then
- missing_includes=yes
-fi
-
AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
AC_CHECK_FUNCS(fork vfork strftime)
AC_CHECK_FUNCS(setlinebuf alarm)
# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
# libraries (e.g., "-lsocket -lnsl" on Solaris).
#
-# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
-# use AC_CHECK_FUNC which doesn't let us specify the right #includes
-# to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
-# resolver, and the way it defines inet_{ntop,pton} is rather strange;
-# it does not ship with a libc symbol "inet_ntop()", it ships with
-# "_inet_ntop()", and has a #define macro in one of the system headers
-# to rename it.
-#
-dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
-AC_MSG_CHECKING(for inet_ntop)
-AC_TRY_LINK([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[4], dst[128];
-inet_ntop(AF_INET, src, dst, sizeof(dst));],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_ntop)])
-AC_MSG_CHECKING(for inet_pton)
-AC_TRY_LINK([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[128], dst[4];
-inet_pton(AF_INET, src, dst);],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_pton)])
-AC_MSG_CHECKING(for inet_aton)
-AC_TRY_LINK([#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[128];
-struct in_addr dst;
-inet_aton(src, &dst);],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_aton)])
-
-#
-# Check for these after AC_LBL_LIBPCAP, for the same reason.
-#
# You are in a twisty little maze of UN*Xes, all different.
# Some might not have ether_ntohost().
# Some might have it, but not declare it in any header file.
# libdlpi is needed for Solaris 11 and later.
AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
-dnl portability macros for getaddrinfo/getnameinfo
-dnl
-dnl Check for sa_len
-AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
-if test "$ac_cv_sockaddr_has_sa_len" = no; then
- missing_includes=yes
-fi
-
dnl
dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
dnl and "pcap_datalink_name_to_val()", and use substitute versions
AC_LBL_UNALIGNED_ACCESS
-AC_VAR_H_ERRNO
-
# Check for OpenSSL libcrypto
AC_MSG_CHECKING(whether to use OpenSSL libcrypto)
# Specify location for both includes and libraries.
+++ /dev/null
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef HAVE_ADDRINFO
-
-/*
- * Error return codes from getaddrinfo()
- */
-#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
-#define EAI_AGAIN 2 /* temporary failure in name resolution */
-#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
-#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
-#define EAI_FAMILY 5 /* ai_family not supported */
-#define EAI_MEMORY 6 /* memory allocation failure */
-#define EAI_NODATA 7 /* no address associated with hostname */
-#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
-#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
-#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
-#define EAI_SYSTEM 11 /* system error returned in errno */
-#define EAI_BADHINTS 12
-#define EAI_PROTOCOL 13
-#define EAI_MAX 14
-
-/* internal error */
-#define NETDB_INTERNAL -1 /* see errno */
-
-/*
- * Flag values for getaddrinfo()
- */
-#define AI_PASSIVE 0x00000001 /* get address to use bind() */
-#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
-#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
-/* valid flags for addrinfo */
-#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
-
-#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
-#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
-#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
-#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
-/* special recommended flags for getipnodebyname */
-#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
-
-struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for hostname */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
-};
-
-extern void freeaddrinfo (struct addrinfo *);
-extern void freehostent (struct hostent *);
-extern int getnameinfo (const struct sockaddr *, size_t, char *,
- size_t, char *, size_t, int);
-extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
-extern struct hostent *getipnodebyname (const char *, int, int, int *);
-extern int inet_pton (int, const char *, void *);
-extern const char *inet_ntop (int, const void *, char *, size_t);
-#endif /* HAVE_ADDRINFO */
-
-/*
- * Constants for getnameinfo()
- */
-#ifndef NI_MAXHOST
-#define NI_MAXHOST 1025
-#endif
-#ifndef NI_MAXSERV
-#define NI_MAXSERV 32
-#endif
-
-/*
- * Flag values for getnameinfo()
- */
-#ifndef NI_NOFQDN
-#define NI_NOFQDN 0x00000001
-#endif
-#ifndef NI_NUMERICHOST
-#define NI_NUMERICHOST 0x00000002
-#endif
-#ifndef NI_NAMEREQD
-#define NI_NAMEREQD 0x00000004
-#endif
-#ifndef NI_NUMERICSERV
-#define NI_NUMERICSERV 0x00000008
-#endif
-#ifndef NI_DGRAM
-#define NI_DGRAM 0x00000010
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Issues to be discussed:
- * - Thread safe-ness must be checked
- * - Return values. There seems to be no standard for return value (RFC2553)
- * but INRIA implementation returns EAI_xxx defined for getaddrinfo().
- * - RFC2553 says that we should raise error on short buffer. X/Open says
- * we need to truncate the result. We obey RFC2553 (and X/Open should be
- * modified).
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-#include <netdb.h>
-#include <resolv.h>
-#include <string.h>
-#include <stddef.h>
-#include <errno.h>
-
-#ifdef NEED_ADDRINFO_H
-#include "addrinfo.h"
-#endif
-
-#define SUCCESS 0
-#define ANY 0
-#define YES 1
-#define NO 0
-
-static struct afd {
- int a_af;
- int a_addrlen;
- int a_socklen;
- int a_off;
-} afdl [] = {
-#ifdef INET6
- {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
- offsetof(struct sockaddr_in6, sin6_addr)},
-#endif
- {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr)},
- {0, 0, 0},
-};
-
-struct sockinet {
- u_char si_len;
- u_char si_family;
- u_short si_port;
-};
-
-#define ENI_NOSOCKET 0
-#define ENI_NOSERVNAME 1
-#define ENI_NOHOSTNAME 2
-#define ENI_MEMORY 3
-#define ENI_SYSTEM 4
-#define ENI_FAMILY 5
-#define ENI_SALEN 6
-
-int
-getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
- const struct sockaddr *sa;
- size_t salen;
- char *host;
- size_t hostlen;
- char *serv;
- size_t servlen;
- int flags;
-{
- struct afd *afd;
- struct servent *sp;
- struct hostent *hp;
- u_short port;
- int family, i;
- char *addr, *p;
- uint32_t v4a;
- int h_error;
- char numserv[512];
- char numaddr[512];
-
- if (sa == NULL)
- return ENI_NOSOCKET;
-
-#ifdef HAVE_SA_LEN /*XXX*/
- if (sa->sa_len != salen)
- return ENI_SALEN;
-#endif
-
- family = sa->sa_family;
- for (i = 0; afdl[i].a_af; i++)
- if (afdl[i].a_af == family) {
- afd = &afdl[i];
- goto found;
- }
- return ENI_FAMILY;
-
- found:
- if (salen != afd->a_socklen)
- return ENI_SALEN;
-
- port = ((struct sockinet *)sa)->si_port; /* network byte order */
- addr = (char *)sa + afd->a_off;
-
- if (serv == NULL || servlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC2553 says that serv == NULL OR servlen == 0
- * means that the caller does not want the result.
- */
- } else {
- if (flags & NI_NUMERICSERV)
- sp = NULL;
- else {
- sp = getservbyport(port,
- (flags & NI_DGRAM) ? "udp" : "tcp");
- }
- if (sp) {
- if (strlen(sp->s_name) + 1 > servlen)
- return ENI_MEMORY;
- strcpy(serv, sp->s_name);
- } else {
- snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
- if (strlen(numserv) + 1 > servlen)
- return ENI_MEMORY;
- strcpy(serv, numserv);
- }
- }
-
- switch (sa->sa_family) {
- case AF_INET:
- v4a = (uint32_t)
- ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
- if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
- flags |= NI_NUMERICHOST;
- v4a >>= IN_CLASSA_NSHIFT;
- if (v4a == 0)
- flags |= NI_NUMERICHOST;
- break;
-#ifdef INET6
- case AF_INET6:
- {
- struct sockaddr_in6 *sin6;
- sin6 = (struct sockaddr_in6 *)sa;
- switch (sin6->sin6_addr.s6_addr[0]) {
- case 0x00:
- if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
- ;
- else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
- ;
- else
- flags |= NI_NUMERICHOST;
- break;
- default:
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- flags |= NI_NUMERICHOST;
- }
- else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
- flags |= NI_NUMERICHOST;
- break;
- }
- }
- break;
-#endif
- }
- if (host == NULL || hostlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC2553 says that host == NULL OR hostlen == 0
- * means that the caller does not want the result.
- */
- } else if (flags & NI_NUMERICHOST) {
- /* NUMERICHOST and NAMEREQD conflicts with each other */
- if (flags & NI_NAMEREQD)
- return ENI_NOHOSTNAME;
- if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
- == NULL)
- return ENI_SYSTEM;
- if (strlen(numaddr) + 1 > hostlen)
- return ENI_MEMORY;
- strcpy(host, numaddr);
-#if defined(INET6) && defined(NI_WITHSCOPEID)
- if (afd->a_af == AF_INET6 &&
- (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
- IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
- ((struct sockaddr_in6 *)sa)->sin6_scope_id) {
-#ifndef ALWAYS_WITHSCOPE
- if (flags & NI_WITHSCOPEID)
-#endif /* !ALWAYS_WITHSCOPE */
- {
- char *ep = strchr(host, '\0');
- unsigned int ifindex =
- ((struct sockaddr_in6 *)sa)->sin6_scope_id;
-
- *ep = SCOPE_DELIMITER;
- if ((if_indextoname(ifindex, ep + 1)) == NULL)
- /* XXX what should we do? */
- strncpy(ep + 1, "???", 3);
- }
- }
-#endif /* INET6 */
- } else {
-#ifdef USE_GETIPNODEBY
- hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
-#else
- hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-#ifdef HAVE_H_ERRNO
- h_error = h_errno;
-#else
- h_error = EINVAL;
-#endif
-#endif
-
- if (hp) {
- if (flags & NI_NOFQDN) {
- p = strchr(hp->h_name, '.');
- if (p) *p = '\0';
- }
- if (strlen(hp->h_name) + 1 > hostlen) {
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- return ENI_MEMORY;
- }
- strcpy(host, hp->h_name);
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- } else {
- if (flags & NI_NAMEREQD)
- return ENI_NOHOSTNAME;
- if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
- == NULL)
- return ENI_NOHOSTNAME;
- if (strlen(numaddr) + 1 > hostlen)
- return ENI_MEMORY;
- strcpy(host, numaddr);
- }
- }
- return SUCCESS;
-}
+++ /dev/null
-/*
- * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
- * (Royal Institute of Technology, Stockholm, Sweden).
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Kungliga Tekniska
- * Högskolan and its contributors.
- *
- * 4. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <netdissect-stdinc.h>
-
-/* Minimal implementation of inet_aton.
- * Cannot distinguish between failure and a local broadcast address. */
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-int
-inet_aton(const char *cp, struct in_addr *addr)
-{
- addr->s_addr = inet_addr(cp);
- return (addr->s_addr == INADDR_NONE) ? 0 : 1;
-}
#ifdef _WIN32
+/*
+ * Includes and definitions for Windows.
+ */
+
#include <stdint.h>
#include <stdio.h>
#include <winsock2.h>
#define O_RDONLY _O_RDONLY
#endif /* _MSC_VER */
-/* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
- * should be used, but it clashes with <ws2tcpip.h>).
- */
-extern const char *inet_ntop (int, const void *, char *, size_t);
-extern int inet_pton (int, const char *, void *);
extern int inet_aton (const char *cp, struct in_addr *addr);
/*
#endif /* caddr_t */
#define MAXHOSTNAMELEN 64
-#define NI_MAXHOST 1025
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define RETSIGTYPE void
#else /* _WIN32 */
+/*
+ * Includes and definitions for various flavors of UN*X.
+ */
+
#include <ctype.h>
#include <unistd.h>
#include <netdb.h>
#define UNALIGNED __attribute__((packed))
#endif
+/*
+ * fopen() read and write modes for text files and binary files.
+ */
#if defined(_WIN32) || defined(MSDOS)
#define FOPEN_READ_TXT "rt"
#define FOPEN_READ_BIN "rb"
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
#endif
+/*
+ * Inline x86 assembler-language versions of ntoh[ls]() and hton[ls](),
+ * defined if the OS doesn't provide them. These assume no more than
+ * an 80386, so, for example, it avoids the bswap instruction added in
+ * the 80486.
+ *
+ * (We don't use them on OS X; Apple provides their own, which *doesn't*
+ * avoid the bswap instruction, as OS X only supports machines that
+ * have it.)
+ */
#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
#undef ntohl
#undef ntohs
}
#endif
+/*
+ * If the OS doesn't define AF_INET6 and struct in6_addr:
+ *
+ * define AF_INET6, so we can use it internally as a "this is an
+ * IPv6 address" indication;
+ *
+ * define struct in6_addr so that we can use it for IPv6 addresses.
+ */
+#ifndef HAVE_OS_IPV6_SUPPORT
+#define AF_INET6 24
+
+struct in6_addr {
+ union {
+ __uint8_t __u6_addr8[16];
+ __uint16_t __u6_addr16[8];
+ __uint32_t __u6_addr32[4];
+ } __u6_addr; /* 128-bit IP6 address */
+};
+#endif
+
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#endif
+
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
extern const char *tok2strary_internal(const char **, int, const char *, int);
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
-#ifdef INET6
extern int mask62plen(const u_char *);
-#endif /*INET6*/
/* The printer routines. */
extern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void ip6_print(netdissect_options *,const u_char *, u_int);
-#ifdef INET6
extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
extern int hbhopt_print(netdissect_options *, const u_char *);
extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
extern void ospf6_print(netdissect_options *, const u_char *, u_int);
extern void babel_print(netdissect_options *, const u_char *, u_int);
-#endif /*INET6*/
/* checksum routines */
extern void init_checksum(void);
extern int nextproto4_cksum(netdissect_options *ndo, const struct ip *, const uint8_t *, u_int, u_int, u_int);
extern int decode_prefix4(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
-#ifdef INET6
extern int decode_prefix6(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
-#endif
extern void esp_print_decodesecret(netdissect_options *ndo);
extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
if (cp + 16 > ep)
goto invalid;
ND_TCHECK2(*cp, 16);
-#ifdef INET6
ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
-#else
- ND_PRINT((ndo, "%s(compiled w/o IPv6)", sep));
-#endif /* INET6 */
cp += 16;
sep = ", ";
}
if (cp + 17 > ep)
goto invalid;
ND_TCHECK2(*cp, 17);
-#ifdef INET6
ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(ndo, cp), *(cp + 16)));
-#else
- ND_PRINT((ndo, "%s(compiled w/o IPv6)/%u", sep, *(cp + 16)));
-#endif /* INET6 */
cp += 17;
sep = ", ";
}
uint32_t rreq_oa; /* originator IPv4 address */
uint32_t rreq_os; /* originator sequence number */
};
-#ifdef INET6
struct aodv_rreq6 {
uint8_t rreq_type; /* AODV message type (1) */
uint8_t rreq_flags; /* various flags */
struct in6_addr rreq_da; /* destination IPv6 address */
struct in6_addr rreq_oa; /* originator IPv6 address */
};
-#endif
#define RREQ_JOIN 0x80 /* join (reserved for multicast */
#define RREQ_REPAIR 0x40 /* repair (reserved for multicast */
uint32_t rrep_oa; /* originator IPv4 address */
uint32_t rrep_life; /* lifetime of this route */
};
-#ifdef INET6
struct aodv_rrep6 {
uint8_t rrep_type; /* AODV message type (2) */
uint8_t rrep_flags; /* various flags */
struct in6_addr rrep_oa; /* originator IPv6 address */
uint32_t rrep_life; /* lifetime of this route */
};
-#endif
#define RREP_REPAIR 0x80 /* repair (reserved for multicast */
#define RREP_ACK 0x40 /* acknowledgement required */
uint32_t u_da; /* IPv4 address */
uint32_t u_ds; /* sequence number */
};
-#ifdef INET6
struct rerr_unreach6 {
struct in6_addr u_da; /* IPv6 address */
uint32_t u_ds; /* sequence number */
struct in6_addr u_da; /* IPv6 address */
uint32_t u_ds; /* sequence number */
};
-#endif
struct aodv_rerr {
uint8_t rerr_type; /* AODV message type (3 or 18) */
}
static void
-#ifdef INET6
aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " v6 rreq %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rrep %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i, dc;
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6 *dp6;
trunc:
ND_PRINT((ndo, "[|rerr]"));
-#else
- ND_PRINT((ndo, " rerr %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rreq6_draft_01 *ap = (const struct aodv_rreq6_draft_01 *)dat;
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rreq %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rrep %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i, dc;
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6_draft_01 *dp6;
trunc:
ND_PRINT((ndo, "[|rerr]"));
-#else
- ND_PRINT((ndo, " rerr %u", length));
-#endif
}
void
if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
else
-#ifdef INET6
snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
-#else
- snprintf(buf, 50, "IPv6 addresses not supported");
-#endif
buf[49] = '\0';
return buf;
}
if(memcmp(prefix, v4prefix, 12) == 0)
return ipaddr_string(ndo, prefix + 12);
else
-#ifdef INET6
return ip6addr_string(ndo, prefix);
-#else
- return "IPv6 addresses not supported";
-#endif
}
static const char *
ND_TCHECK2(pptr[0], sizeof(struct in_addr));
snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr));
break;
-#ifdef INET6
case (sizeof(struct in6_addr) << 3): /* 128 */
ND_TCHECK2(pptr[0], sizeof(struct in6_addr));
snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
break;
-#endif
default:
snprintf(pos, sizeof(addr), "bogus address length %u", addr_length);
break;
return -2;
}
-#ifdef INET6
int
decode_prefix6(netdissect_options *ndo,
const u_char *pd, u_int itemlen, char *buf, u_int buflen)
trunc:
return -2;
}
-#endif
static int
decode_clnp_prefix(netdissect_options *ndo,
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
case (AFNUM_INET<<8 | SAFNUM_MDT):
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
-#endif
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
}
break;
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
}
break;
-#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
/* rfc986 mapped IPv4 address ? */
if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601)
ND_PRINT((ndo, " = %s", getname(ndo, tptr+BGP_VPN_RD_LEN+4)));
-#ifdef INET6
/* rfc1888 mapped IPv6 address ? */
else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000)
ND_PRINT((ndo, " = %s", getname6(ndo, tptr+BGP_VPN_RD_LEN+3)));
-#endif
tptr += tlen;
tlen = 0;
}
else
ND_PRINT((ndo, "\n\t %s", buf));
break;
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
else
ND_PRINT((ndo, "\n\t %s", buf));
break;
-#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
else
ND_PRINT((ndo, "\n\t %s", buf));
break;
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
else
ND_PRINT((ndo, "\n\t %s", buf));
break;
-#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
int withdrawn_routes_len;
int len;
int i;
-#ifndef INET6
- char buf[MAXHOSTNAMELEN + 100];
- int wpfx;
-#endif
ND_TCHECK2(dat[0], BGP_SIZE);
if (length < BGP_SIZE)
ND_TCHECK2(p[0], withdrawn_routes_len);
if (length < withdrawn_routes_len)
goto trunc;
-#ifdef INET6
ND_PRINT((ndo, "\n\t Withdrawn routes: %d bytes", withdrawn_routes_len));
p += withdrawn_routes_len;
length -= withdrawn_routes_len;
-#else
- if (withdrawn_routes_len < 2)
- goto trunc;
- length -= 2;
- withdrawn_routes_len -= 2;
-
-
- ND_PRINT((ndo, "\n\t Withdrawn routes:"));
-
- while(withdrawn_routes_len > 0) {
- wpfx = decode_prefix4(ndo, p, withdrawn_routes_len, buf, sizeof(buf));
- if (wpfx == -1) {
- ND_PRINT((ndo, "\n\t (illegal prefix length)"));
- break;
- } else if (wpfx == -2)
- goto trunc;
- else if (wpfx == -3)
- goto trunc; /* bytes left, but not enough */
- else {
- ND_PRINT((ndo, "\n\t %s", buf));
- p += wpfx;
- length -= wpfx;
- withdrawn_routes_len -= wpfx;
- }
- }
-#endif
}
ND_TCHECK2(p[0], 2);
{
int pt, pl, al, num;
const u_char *endp = p + l;
-#ifdef INET6
static const u_char prot_ipv6[] = {
0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
};
-#endif
ND_TCHECK2(*p, 4);
if (p + 4 > endp)
ND_PRINT((ndo, "IPv4 (%u) %s", num, ipaddr_string(ndo, p)));
p += 4;
}
-#ifdef INET6
else if (pt == PT_IEEE_802_2 && pl == 8 &&
memcmp(p, prot_ipv6, 8) == 0 && al == 16) {
/*
ND_PRINT((ndo, "IPv6 (%u) %s", num, ip6addr_string(ndo, p)));
p += al;
}
-#endif
else {
/*
* Generic case: just print raw data
ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
break;
-#ifdef INET6
case AFNUM_INET6:
ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
break;
-#endif
default:
hexdump = TRUE;
#include "addrtoname.h"
#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
/* RFC4340: Datagram Congestion Control Protocol (DCCP) */
dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
-#ifdef INET6
static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len)
{
return nextproto6_cksum(ip6, (const uint8_t *)(const void *)dh, len,
dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
-#endif
static const char *dccp_reset_code(uint8_t code)
{
{
const struct dccp_hdr *dh;
const struct ip *ip;
-#ifdef INET6
const struct ip6_hdr *ip6;
-#endif
const u_char *cp;
u_short sport, dport;
u_int hlen;
dh = (const struct dccp_hdr *)bp;
ip = (const struct ip *)data2;
-#ifdef INET6
if (IP_V(ip) == 6)
ip6 = (const struct ip6_hdr *)data2;
else
ip6 = NULL;
-#endif /*INET6*/
/* make sure we have enough data to look at the X bit */
cp = (const u_char *)(dh + 1);
dport = EXTRACT_16BITS(&dh->dccph_dport);
hlen = dh->dccph_doff * 4;
-#ifdef INET6
if (ip6) {
ND_PRINT((ndo, "%s.%d > %s.%d: ",
ip6addr_string(ndo, &ip6->ip6_src), sport,
ip6addr_string(ndo, &ip6->ip6_dst), dport));
- } else
-#endif /*INET6*/
- {
+ } else {
ND_PRINT((ndo, "%s.%d > %s.%d: ",
ipaddr_string(ndo, &ip->ip_src), sport,
ipaddr_string(ndo, &ip->ip_dst), dport));
ND_PRINT((ndo, "cksum 0x%04x ", dccp_sum));
if (IP_V(ip) == 4)
sum = dccp_cksum(ndo, ip, dh, len);
-#ifdef INET6
else if (IP_V(ip) == 6)
sum = dccp6_cksum(ip6, dh, len);
-#endif
if (sum != 0)
ND_PRINT((ndo, "(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum)));
else
#include "netdissect.h"
#include "addrtoname.h"
+#include "addrtostr.h"
#include "extract.h"
static const char *ns_ops[] = {
EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2)));
break;
-#ifdef INET6
case T_AAAA:
{
- struct in6_addr addr;
char ntop_buf[INET6_ADDRSTRLEN];
if (!ND_TTEST2(*cp, sizeof(struct in6_addr)))
return(NULL);
- memcpy(&addr, cp, sizeof(struct in6_addr));
ND_PRINT((ndo, " %s",
- inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf))));
+ addrtostr6(cp, ntop_buf, sizeof(ntop_buf))));
break;
}
memset(&a, 0, sizeof(a));
memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
ND_PRINT((ndo, " %u %s", pbit,
- inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf))));
+ addrtostr6(&a, ntop_buf, sizeof(ntop_buf))));
}
if (pbit > 0) {
ND_PRINT((ndo, " "));
}
break;
}
-#endif /*INET6*/
case T_OPT:
ND_PRINT((ndo, " UDPsize=%u", class));
#endif
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "netdissect.h"
+#include "strtoaddr.h"
#include "extract.h"
#include "ascii_strcasecmp.h"
#ifdef HAVE_LIBCRYPTO
union inaddr_u {
struct in_addr in4;
-#ifdef INET6
struct in6_addr in6;
-#endif
};
struct sa_list {
struct sa_list *next;
sa1.spi = spino;
-#ifdef INET6
- if (inet_pton(AF_INET6, spikey, &sa1.daddr.in6) == 1) {
+ if (strtoaddr6(spikey, &sa1.daddr.in6) == 1) {
sa1.daddr_version = 6;
- } else
-#endif
- if (inet_pton(AF_INET, spikey, &sa1.daddr.in4) == 1) {
- sa1.daddr_version = 4;
- } else {
- (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
- return;
- }
+ } else if (strtoaddr(spikey, &sa1.daddr.in4) == 1) {
+ sa1.daddr_version = 4;
+ } else {
+ (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
+ return;
+ }
}
if (decode) {
#ifdef HAVE_LIBCRYPTO
const struct ip *ip;
struct sa_list *sa = NULL;
-#ifdef INET6
const struct ip6_hdr *ip6 = NULL;
-#endif
int advance;
int len;
u_char *secret;
ip = (const struct ip *)bp2;
switch (IP_V(ip)) {
-#ifdef INET6
case 6:
ip6 = (const struct ip6_hdr *)bp2;
/* we do not attempt to decrypt jumbograms */
}
}
break;
-#endif /*INET6*/
case 4:
/* nexthdr & padding are in the last fragment */
if (EXTRACT_16BITS(&ip->ip_off) & IP_MF)
#include "config.h"
#endif
-#ifdef INET6
-
#include <netdissect-stdinc.h>
#include "ip6.h"
ND_PRINT((ndo, "[|frag]"));
return -1;
}
-#endif /* INET6 */
#include <string.h>
#include "netdissect.h"
+#include "addrtostr.h"
#include "extract.h"
#include "ethertype.h"
gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
const u_char *bp, u_int len)
{
- struct in_addr a;
const u_char *up = bp;
+ char buf[INET_ADDRSTRLEN];
if (sreoff & 3) {
ND_PRINT((ndo, ", badoffset=%u", sreoff));
if (len < 4 || srelen == 0)
return;
- memcpy(&a, bp, sizeof(a));
+ addrtostr(bp, buf, sizeof(buf));
ND_PRINT((ndo, " %s%s",
- ((bp - up) == sreoff) ? "*" : "",
- inet_ntoa(a)));
+ ((bp - up) == sreoff) ? "*" : "", buf));
bp += 4;
len -= 4;
#include "config.h"
#endif
-#ifdef INET6
-
#include <netdissect-stdinc.h>
#include <stdio.h>
#include "netdissect.h"
#include "addrtoname.h"
+#include "addrtostr.h"
#include "extract.h"
#include "ip6.h"
ND_PRINT((ndo,",min=%u", match->rpm_minlen));
ND_PRINT((ndo,",max=%u", match->rpm_maxlen));
}
- if (inet_ntop(AF_INET6, &match->rpm_prefix, hbuf, sizeof(hbuf)))
+ if (addrtostr6(&match->rpm_prefix, hbuf, sizeof(hbuf)))
ND_PRINT((ndo,",%s/%u", hbuf, match->rpm_matchlen));
else
ND_PRINT((ndo,",?/%u", match->rpm_matchlen));
ND_PRINT((ndo,"pltime=%u,",
EXTRACT_32BITS(&use->rpu_pltime)));
}
- if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf,
- sizeof(hbuf)))
+ if (addrtostr6(&use->rpu_prefix, hbuf, sizeof(hbuf)))
ND_PRINT((ndo,"%s/%u/%u", hbuf, use->rpu_uselen,
use->rpu_keeplen));
else
ND_PRINT((ndo,"[|icmp6]"));
}
-#endif /* INET6 */
-
/*
* Local Variables:
* c-style: whitesmith
#include "addrtoname.h"
#include "extract.h"
-#ifdef INET6
-
#include "ip6.h"
#include "ipproto.h"
trunc:
ND_PRINT((ndo, "[|ip6]"));
}
-
-#else /* INET6 */
-
-void
-ip6_print(netdissect_options *ndo, const u_char *bp _U_, u_int length)
-{
- ND_PRINT((ndo, "IP6, length: %u (printing not supported)", length));
-}
-
-#endif /* INET6 */
#include "config.h"
#endif
-#ifdef INET6
#include <netdissect-stdinc.h>
#include "ip6.h"
ND_PRINT((ndo, "[|DSTOPT]"));
return(-1);
}
-#endif /* INET6 */
#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
/* refer to RFC 2408 */
int ninitiator = 0;
union inaddr_u {
struct in_addr in4;
-#ifdef INET6
struct in6_addr in6;
-#endif
};
struct {
cookie_t initiator;
{
int i;
const struct ip *ip;
-#ifdef INET6
const struct ip6_hdr *ip6;
-#endif
i = cookie_find(in);
if (0 <= i) {
UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in4, &ip->ip_src, sizeof(struct in_addr));
UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in4, &ip->ip_dst, sizeof(struct in_addr));
break;
-#ifdef INET6
case 6:
ip6 = (const struct ip6_hdr *)bp2;
cookiecache[ninitiator].version = 6;
UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in6, &ip6->ip6_src, sizeof(struct in6_addr));
UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in6, &ip6->ip6_dst, sizeof(struct in6_addr));
break;
-#endif
default:
return;
}
cookie_sidecheck(int i, const u_char *bp2, int initiator)
{
const struct ip *ip;
-#ifdef INET6
const struct ip6_hdr *ip6;
-#endif
ip = (const struct ip *)bp2;
switch (IP_V(ip)) {
return 1;
}
break;
-#ifdef INET6
case 6:
if (cookiecache[i].version != 6)
return 0;
return 1;
}
break;
-#endif /* INET6 */
default:
break;
}
len = 0;
break;
}
-#ifdef INET6
case IPSECDOI_ID_IPV6_ADDR:
if (len < 16)
ND_PRINT((ndo," len=%d [bad: < 16]", len));
len = 0;
break;
}
-#endif /*INET6*/
case IPSECDOI_ID_IPV4_ADDR_RANGE:
if (len < 8)
ND_PRINT((ndo," len=%d [bad: < 8]", len));
}
len = 0;
break;
-#ifdef INET6
case IPSECDOI_ID_IPV6_ADDR_RANGE:
if (len < 32)
ND_PRINT((ndo," len=%d [bad: < 32]", len));
}
len = 0;
break;
-#endif /*INET6*/
case IPSECDOI_ID_DER_ASN1_DN:
case IPSECDOI_ID_DER_ASN1_GN:
case IPSECDOI_ID_KEY_ID:
const uint8_t *tptr, const char *ident, uint16_t afi)
{
char ident_buffer[20];
-#ifdef INET6
uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
-#else
- uint8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */
-#endif
u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
if (!ND_TTEST2(*tptr, 4))
return (0);
}
processed++;
-#ifdef INET6
} else if (afi == AF_INET6) {
if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
return (0);
return (0);
}
processed+=2;
-#endif
} else
return (0); /* somebody is fooling us */
ident,
ipaddr_string(ndo, prefix),
bit_length));
-#ifdef INET6
- if (afi == AF_INET6)
+ else if (afi == AF_INET6)
ND_PRINT((ndo, "%sIPv6 prefix: %s/%u",
ident,
ip6addr_string(ndo, prefix),
bit_length));
-#endif
ND_PRINT((ndo, ", Distribution: %s, Metric: %u",
ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
ND_PRINT((ndo, ", sub-TLVs present"));
-#ifdef INET6
- if (afi == AF_INET6)
+ else if (afi == AF_INET6)
ND_PRINT((ndo, ", %s%s",
ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""));
-#endif
if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
-#ifdef INET6
|| (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte))
-#endif
) {
/* assume that one prefix can hold more
than one subTLV - therefore the first byte must reflect
}
break;
-#ifdef INET6
case ISIS_TLV_IP6_REACH:
while (tmp>0) {
ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
tmp -= sizeof(struct in6_addr);
}
break;
-#endif
case ISIS_TLV_AUTH:
if (!ND_TTEST2(*tptr, 1))
goto trunctlv;
case PPP_PAP :
case PPP_CHAP :
case PPP_ML :
-#ifdef INET6
case PPP_IPV6 :
case PPP_IPV6CP :
-#endif
ppp_print(ndo, p, length);
break;
TLV_TCHECK(4);
ND_PRINT((ndo, "\n\t IPv4 Transport Address: %s", ipaddr_string(ndo, tptr)));
break;
-#ifdef INET6
case LDP_TLV_IPV6_TRANSPORT_ADDR:
TLV_TCHECK(16);
ND_PRINT((ndo, "\n\t IPv6 Transport Address: %s", ip6addr_string(ndo, tptr)));
break;
-#endif
case LDP_TLV_CONFIG_SEQ_NUMBER:
TLV_TCHECK(4);
ND_PRINT((ndo, "\n\t Sequence Number: %u", EXTRACT_32BITS(tptr)));
tptr+=sizeof(struct in_addr);
}
break;
-#ifdef INET6
case AFNUM_INET6:
while(tlv_tlen >= sizeof(struct in6_addr)) {
ND_TCHECK2(*tptr, sizeof(struct in6_addr));
tptr+=sizeof(struct in6_addr);
}
break;
-#endif
default:
/* unknown AF */
break;
else
ND_PRINT((ndo, ": IPv4 prefix %s", buf));
}
-#ifdef INET6
else if (af == AFNUM_INET6) {
i=decode_prefix6(ndo, tptr, tlv_tlen, buf, sizeof(buf));
if (i == -2)
else
ND_PRINT((ndo, ": IPv6 prefix %s", buf));
}
-#endif
else
ND_PRINT((ndo, ": Address family %u prefix", af));
break;
return NULL;
pfunc = getname;
break;
-#ifdef INET6
case AFNUM_INET6:
if (len < 16)
return NULL;
pfunc = getname6;
break;
-#endif
case AFNUM_802:
if (len < 6)
return NULL;
ipaddr_string(ndo, obj_tptr),
EXTRACT_32BITS(obj_tptr)));
break;
-#ifdef INET6
case LMP_CTYPE_IPV6_LOC:
case LMP_CTYPE_IPV6_RMT:
ND_PRINT((ndo, "\n\t IPv6 Link ID: %s (0x%08x)",
ip6addr_string(ndo, obj_tptr),
EXTRACT_32BITS(obj_tptr)));
break;
-#endif
case LMP_CTYPE_UNMD_LOC:
case LMP_CTYPE_UNMD_RMT:
ND_PRINT((ndo, "\n\t Link ID: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr+8)));
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
case LMP_CTYPE_UNMD:
default:
hexdump=TRUE;
}
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
offset+=8;
}
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
offset+=4;
}
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
break;
-#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
(const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
break;
-#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)));
break;
-#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
(const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)));
break;
-#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)));
break;
-#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
(const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)));
break;
-#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
break;
-#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
(const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
break;
-#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
break;
-#ifdef INET6
case LSPPING_AFI_IPV6:
ND_PRINT((ndo, "\n\t Downstream IP: %s" \
"\n\t Downstream Interface IP: %s",
tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
break;
-#endif
case LSPPING_AFI_UNMB:
ND_PRINT((ndo, "\n\t Downstream IP: %s" \
"\n\t Downstream Interface Index: 0x%08x",
ND_PRINT((ndo, " %s", ipaddr_string(ndo, p)));
p += sizeof(struct in_addr);
break;
-#ifdef INET6
case 2: /* IPv6 */
if (l < 16)
return -1;
ND_PRINT((ndo, " %s", ip6addr_string(ndo, p)));
p += sizeof(struct in6_addr);
break;
-#endif
default:
ND_PRINT((ndo, " %u/", EXTRACT_32BITS(&ap->family)));
for (i = 0; i < l; i++)
#include "config.h"
#endif
-#ifdef INET6
#include <netdissect-stdinc.h>
#include "ip6.h"
ND_PRINT((ndo, "[|MOBILITY]"));
return(mhlen);
}
-#endif /* INET6 */
ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v4.port)));
break;
case 6:
-#ifdef INET6
ND_PRINT((ndo, " %s", ip6addr_string(ndo, add_addr->u.v6.addr)));
-#endif
if (opt_len == 22)
ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v6.port)));
break;
static const struct tok nflog_values[] = {
{ AF_INET, "IPv4" },
-#ifdef INET6
+#ifdef AF_INET6
{ AF_INET6, "IPv6" },
-#endif /*INET6*/
+#endif /*AF_INET6*/
{ 0, NULL }
};
#include "nfsfh.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "rpc_auth.h"
#include "rpc_msg.h"
const u_char *bp, const char *s, const char *d)
{
const struct ip *ip;
-#ifdef INET6
const struct ip6_hdr *ip6;
char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN];
-#else
-#ifndef INET_ADDRSTRLEN
-#define INET_ADDRSTRLEN 16
-#endif
- char srcaddr[INET_ADDRSTRLEN], dstaddr[INET_ADDRSTRLEN];
-#endif
srcaddr[0] = dstaddr[0] = '\0';
switch (IP_V((const struct ip *)bp)) {
strlcpy(srcaddr, ipaddr_string(ndo, &ip->ip_src), sizeof(srcaddr));
strlcpy(dstaddr, ipaddr_string(ndo, &ip->ip_dst), sizeof(dstaddr));
break;
-#ifdef INET6
case 6:
ip6 = (const struct ip6_hdr *)bp;
strlcpy(srcaddr, ip6addr_string(ndo, &ip6->ip6_src),
strlcpy(dstaddr, ip6addr_string(ndo, &ip6->ip6_dst),
sizeof(dstaddr));
break;
-#endif
default:
strlcpy(srcaddr, "?", sizeof(srcaddr));
strlcpy(dstaddr, "?", sizeof(dstaddr));
struct xid_map_entry {
uint32_t xid; /* transaction ID (net order) */
int ipver; /* IP version (4 or 6) */
-#ifdef INET6
struct in6_addr client; /* client IP address (net order) */
struct in6_addr server; /* server IP address (net order) */
-#else
- struct in_addr client; /* client IP address (net order) */
- struct in_addr server; /* server IP address (net order) */
-#endif
uint32_t proc; /* call proc number (host order) */
uint32_t vers; /* program version (host order) */
};
const struct sunrpc_msg *rp, const u_char *bp)
{
const struct ip *ip = NULL;
-#ifdef INET6
const struct ip6_hdr *ip6 = NULL;
-#endif
struct xid_map_entry *xmep;
if (!ND_TTEST(rp->rm_call.cb_vers))
case 4:
ip = (const struct ip *)bp;
break;
-#ifdef INET6
case 6:
ip6 = (const struct ip6_hdr *)bp;
break;
-#endif
default:
return (1);
}
UNALIGNED_MEMCPY(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
UNALIGNED_MEMCPY(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));
}
-#ifdef INET6
else if (ip6) {
xmep->ipver = 6;
UNALIGNED_MEMCPY(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));
UNALIGNED_MEMCPY(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
}
-#endif
xmep->proc = EXTRACT_32BITS(&rp->rm_call.cb_proc);
xmep->vers = EXTRACT_32BITS(&rp->rm_call.cb_vers);
return (1);
struct xid_map_entry *xmep;
uint32_t xid;
const struct ip *ip = (const struct ip *)bp;
-#ifdef INET6
const struct ip6_hdr *ip6 = (const struct ip6_hdr *)bp;
-#endif
int cmp;
UNALIGNED_MEMCPY(&xid, &rp->rm_xid, sizeof(xmep->xid));
cmp = 0;
}
break;
-#ifdef INET6
case 6:
if (UNALIGNED_MEMCMP(&ip6->ip6_src, &xmep->server,
sizeof(ip6->ip6_src)) != 0 ||
cmp = 0;
}
break;
-#endif
default:
cmp = 0;
break;
return (0);
}
-#if INET6
static int
olsr_print_lq_neighbor6(netdissect_options *ndo,
const u_char *msg_data, u_int hello_len)
}
return (0);
}
-#endif /* INET6 */
/*
* print a neighbor list.
ND_TCHECK2(*tptr, sizeof(struct olsr_msg4));
-#if INET6
if (is_ipv6)
{
msgptr.v6 = (const struct olsr_msg6 *) tptr;
msg_data = tptr + sizeof(struct olsr_msg6);
}
else /* (!is_ipv6) */
-#endif /* INET6 */
{
msgptr.v4 = (const struct olsr_msg4 *) tptr;
msg_type = msgptr.v4->msg_type;
if (olsr_print_neighbor(ndo, msg_data, hello_len) == -1)
goto trunc;
} else {
-#if INET6
if (is_ipv6) {
if (olsr_print_lq_neighbor6(ndo, msg_data, hello_len) == -1)
goto trunc;
- } else
-#endif
- {
+ } else {
if (olsr_print_lq_neighbor4(ndo, msg_data, hello_len) == -1)
goto trunc;
}
if (olsr_print_neighbor(ndo, msg_data, msg_tlen) == -1)
goto trunc;
} else {
-#if INET6
if (is_ipv6) {
if (olsr_print_lq_neighbor6(ndo, msg_data, msg_tlen) == -1)
goto trunc;
- } else
-#endif
- {
+ } else {
if (olsr_print_lq_neighbor4(ndo, msg_data, msg_tlen) == -1)
goto trunc;
}
{
size_t addr_size = sizeof(struct in_addr);
-#if INET6
if (is_ipv6)
addr_size = sizeof(struct in6_addr);
-#endif
while (msg_tlen >= addr_size) {
ND_TCHECK2(*msg_data, addr_size);
-#if INET6
ND_PRINT((ndo, "\n\t interface address %s",
is_ipv6 ? ip6addr_string(ndo, msg_data) :
ipaddr_string(ndo, msg_data)));
-#else
- ND_PRINT((ndo, "\n\t interface address %s",
- ipaddr_string(ndo, msg_data)));
-#endif
msg_data += addr_size;
msg_tlen -= addr_size;
}
case OLSR_HNA_MSG:
-#if INET6
if (is_ipv6)
{
int i = 0;
}
}
else
-#endif
{
int col = 0;
ND_TCHECK2(*msg_data, addr_size + name_entry_len + name_entry_padding);
-#if INET6
if (is_ipv6)
ND_PRINT((ndo, ", address %s, name \"",
ip6addr_string(ndo, msg_data)));
else
-#endif
ND_PRINT((ndo, ", address %s, name \"",
ipaddr_string(ndo, msg_data)));
(void)fn_printn(ndo, msg_data + addr_size, name_entry_len, NULL);
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
+#include "addrtostr.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
#include "af.h"
register const struct ip *ip;
register char ch;
uint16_t sport, dport;
- int addr_size;
- const void *nla;
- int nla_af;
-#ifdef INET6
+ u_int nla_afnum;
char nla_buf[INET6_ADDRSTRLEN];
register const struct ip6_hdr *ip6;
-#else
- char nla_buf[INET_ADDRSTRLEN];
-#endif
uint8_t opt_type, opt_len;
uint32_t seq, opts_len, len, offset;
pgm = (const struct pgm_header *)bp;
ip = (const struct ip *)bp2;
-#ifdef INET6
if (IP_V(ip) == 6)
ip6 = (const struct ip6_hdr *)bp2;
else
ip6 = NULL;
-#else /* INET6 */
- if (IP_V(ip) == 6) {
- ND_PRINT((ndo, "Can't handle IPv6"));
- return;
- }
-#endif /* INET6 */
ch = '\0';
if (!ND_TTEST(pgm->pgm_dport)) {
-#ifdef INET6
if (ip6) {
ND_PRINT((ndo, "%s > %s: [|pgm]",
ip6addr_string(ndo, &ip6->ip6_src),
ip6addr_string(ndo, &ip6->ip6_dst)));
return;
- } else
-#endif /* INET6 */
- {
+ } else {
ND_PRINT((ndo, "%s > %s: [|pgm]",
ipaddr_string(ndo, &ip->ip_src),
ipaddr_string(ndo, &ip->ip_dst)));
sport = EXTRACT_16BITS(&pgm->pgm_sport);
dport = EXTRACT_16BITS(&pgm->pgm_dport);
-#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_PGM) {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ND_PRINT((ndo, "%s > %s: ",
tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_PGM) {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ipaddr_string(ndo, &ip->ip_src),
spm = (const struct pgm_spm *)(pgm + 1);
ND_TCHECK(*spm);
+ bp = (const u_char *) (spm + 1);
switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp = (const u_char *) (spm + 1);
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s",
EXTRACT_32BITS(&spm->pgms_seq),
EXTRACT_32BITS(&spm->pgms_trailseq),
polr = (const struct pgm_polr *)(pgm + 1);
ND_TCHECK(*polr);
+ bp = (const u_char *) (polr + 1);
switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp = (const u_char *) (polr + 1);
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
-
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
ND_TCHECK2(*bp, sizeof(uint32_t));
ivl = EXTRACT_32BITS(bp);
case PGM_NULLNAK:
case PGM_NCF: {
const struct pgm_nak *nak;
- const void *source, *group;
- int source_af, group_af;
-#ifdef INET6
char source_buf[INET6_ADDRSTRLEN], group_buf[INET6_ADDRSTRLEN];
-#else
- char source_buf[INET_ADDRSTRLEN], group_buf[INET_ADDRSTRLEN];
-#endif
nak = (const struct pgm_nak *)(pgm + 1);
ND_TCHECK(*nak);
+ bp = (const u_char *) (nak + 1);
/*
* Skip past the source, saving info along the way
*/
switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- source_af = AF_INET;
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, source_buf, sizeof(source_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- source_af = AF_INET6;
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, source_buf, sizeof(source_buf));
+ bp += sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp = (const u_char *) (nak + 1);
- ND_TCHECK2(*bp, addr_size);
- source = bp;
- bp += addr_size;
/*
* Skip past the group, saving info along the way
* and stopping if we don't have enough.
*/
+ bp += (2 * sizeof(uint16_t));
switch (EXTRACT_16BITS(bp)) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- group_af = AF_INET;
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, group_buf, sizeof(group_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- group_af = AF_INET6;
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, group_buf, sizeof(group_buf));
+ bp += sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp += (2 * sizeof(uint16_t));
- ND_TCHECK2(*bp, addr_size);
- group = bp;
- bp += addr_size;
/*
* Options decoding can go here.
*/
- inet_ntop(source_af, source, source_buf, sizeof(source_buf));
- inet_ntop(group_af, group, group_buf, sizeof(group_buf));
switch (pgm->pgm_type) {
case PGM_NAK:
ND_PRINT((ndo, "NAK "));
case PGM_OPT_REDIRECT:
bp += 2;
- switch (EXTRACT_16BITS(bp)) {
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ if (opt_len != 4 + sizeof(struct in_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
+ opts_len -= 4 + sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ if (opt_len != 4 + sizeof(struct in6_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
+ opts_len -= 4 + sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp += (2 * sizeof(uint16_t));
- if (opt_len != 4 + addr_size) {
- ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
- return;
- }
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
ND_PRINT((ndo, " REDIRECT %s", nla_buf));
- opts_len -= 4 + addr_size;
break;
case PGM_OPT_PARITY_PRM:
bp += 2;
offset = EXTRACT_32BITS(bp);
bp += sizeof(uint32_t);
- switch (EXTRACT_16BITS(bp)) {
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ if (opt_len != 12 + sizeof(struct in_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
+ opts_len -= 12 + sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ if (opt_len != 12 + sizeof(struct in6_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
+ opts_len -= 12 + sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp += (2 * sizeof(uint16_t));
- if (opt_len != 12 + addr_size) {
- ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
- return;
- }
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
ND_PRINT((ndo, " PGMCC DATA %u %s", offset, nla_buf));
- opts_len -= 16;
break;
case PGM_OPT_PGMCC_FEEDBACK:
bp += 2;
offset = EXTRACT_32BITS(bp);
bp += sizeof(uint32_t);
- switch (EXTRACT_16BITS(bp)) {
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ if (opt_len != 12 + sizeof(struct in_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
+ opts_len -= 12 + sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ if (opt_len != 12 + sizeof(struct in6_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
+ opts_len -= 12 + sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp += (2 * sizeof(uint16_t));
- if (opt_len != 12 + addr_size) {
- ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len));
- return;
- }
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, nla_buf));
- opts_len -= 16;
break;
default:
af = AF_INET;
len = sizeof(struct in_addr);
break;
-#ifdef INET6
case 2:
af = AF_INET6;
len = sizeof(struct in6_addr);
break;
-#endif
default:
return -1;
}
case sizeof(struct in_addr):
af = AF_INET;
break;
-#ifdef INET6
case sizeof(struct in6_addr):
af = AF_INET6;
break;
-#endif
default:
return -1;
break;
if (!silent)
ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp)));
}
-#ifdef INET6
else if (af == AF_INET6) {
if (!silent)
ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp)));
}
-#endif
return hdrlen + len;
case pimv2_group:
case pimv2_source:
ND_PRINT((ndo, "/%u", bp[1]));
}
}
-#ifdef INET6
else if (af == AF_INET6) {
if (!silent) {
ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
ND_PRINT((ndo, "/%u", bp[1]));
}
}
-#endif
if (bp[0] && !silent) {
if (at == pimv2_group) {
ND_PRINT((ndo, "(0x%02x)", bp[0]));
vec[0].len = len;
cksum = in_cksum(vec, 1);
return (cksum ? INCORRECT : CORRECT);
-#ifdef INET6
} else if (IP_V(ip) == 6) {
const struct ip6_hdr *ip6;
ip6 = (const struct ip6_hdr *)bp2;
cksum = nextproto6_cksum(ip6, bp, len, len, IPPROTO_PIM);
return (cksum ? INCORRECT : CORRECT);
-#endif
} else {
return (UNVERIFIED);
}
#include "config.h"
#endif
-#ifdef INET6
-
#include <netdissect-stdinc.h>
#include "netdissect.h"
if (rp->rip6_vers != RIP6_VERSION)
ND_PRINT((ndo, " [vers %d]", rp->rip6_vers));
}
-#endif /* INET6 */
}
break;
-#ifdef INET6
case RPKI_RTR_IPV6_PREFIX_PDU:
{
const rpki_rtr_pdu_ipv6_prefix *pdu;
EXTRACT_32BITS(pdu->as), pdu->flags));
}
break;
-#endif
case RPKI_RTR_ERROR_REPORT_PDU:
{
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return -1;
obj_tlen-=26;
obj_tptr+=26;
break;
-#endif
case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
if (obj_tlen < 12)
return -1;
obj_tlen-=sizeof(struct in_addr);
obj_tptr+=sizeof(struct in_addr);
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < sizeof(struct in6_addr))
return -1;
obj_tlen-=sizeof(struct in6_addr);
obj_tptr+=sizeof(struct in6_addr);
break;
-#endif
default:
hexdump=TRUE;
}
obj_tlen-=sizeof(struct in_addr);
obj_tptr+=sizeof(struct in_addr);
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < sizeof(struct in6_addr))
return-1;
obj_tlen-=sizeof(struct in6_addr);
obj_tptr+=sizeof(struct in6_addr);
break;
-#endif
default:
hexdump=TRUE;
}
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
obj_tlen-=40;
obj_tptr+=40;
break;
-#endif
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
return-1;
ND_PRINT((ndo, "%s UNI IPv4 TNA address: %s",
ident, ipaddr_string(ndo, obj_tptr + 4)));
break;
-#ifdef INET6
case AFNUM_INET6:
if (subobj_len < 20)
return -1;
ND_PRINT((ndo, "%s UNI IPv6 TNA address: %s",
ident, ip6addr_string(ndo, obj_tptr + 4)));
break;
-#endif
case AFNUM_NSAP:
if (subobj_len) {
/* unless we have a TLV parser lets just hexdump */
if (obj_tlen)
hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
break;
-#ifdef INET6
case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
obj_tptr+=20;
hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
break;
-#endif
default:
hexdump=TRUE;
}
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
obj_tlen-=40;
obj_tptr+=40;
break;
-#endif
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
return-1;
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
obj_tlen-=20;
obj_tptr+=20;
break;
-#endif
default:
hexdump=TRUE;
}
obj_tlen-=4;
obj_tptr+=4;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 16)
return-1;
obj_tlen-=16;
obj_tptr+=16;
break;
-#endif
default:
hexdump=TRUE;
}
#include "config.h"
#endif
-#ifdef INET6
-
#include <netdissect-stdinc.h>
#include <string.h>
ND_PRINT((ndo, "[|srcrt]"));
return -1;
}
-#endif /* INET6 */
#include "addrtoname.h"
#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
/* Definitions from:
*
{
const struct sctpHeader *sctpPktHdr;
const struct ip *ip;
-#ifdef INET6
const struct ip6_hdr *ip6;
-#endif
const void *endPacketPtr;
u_short sourcePort, destPort;
int chunkCount;
if( (u_long) endPacketPtr > (u_long) ndo->ndo_snapend)
endPacketPtr = (const void *) ndo->ndo_snapend;
ip = (const struct ip *)bp2;
-#ifdef INET6
if (IP_V(ip) == 6)
ip6 = (const struct ip6_hdr *)bp2;
else
ip6 = NULL;
-#endif /*INET6*/
ND_TCHECK(*sctpPktHdr);
if (sctpPacketLength < sizeof(struct sctpHeader))
sourcePort = EXTRACT_16BITS(&sctpPktHdr->source);
destPort = EXTRACT_16BITS(&sctpPktHdr->destination);
-#ifdef INET6
if (ip6) {
ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
ip6addr_string(ndo, &ip6->ip6_src),
ip6addr_string(ndo, &ip6->ip6_dst),
destPort));
} else
-#endif /*INET6*/
{
ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
ipaddr_string(ndo, &ip->ip_src),
#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "rpc_auth.h"
#include "rpc_msg.h"
{
register const struct sunrpc_msg *rp;
register const struct ip *ip;
-#ifdef INET6
register const struct ip6_hdr *ip6;
-#endif
uint32_t x;
char srcid[20], dstid[20]; /*fits 32bit*/
ipaddr_string(ndo, &ip->ip_src), srcid,
ipaddr_string(ndo, &ip->ip_dst), dstid, length));
break;
-#ifdef INET6
case 6:
ip6 = (const struct ip6_hdr *)bp2;
ND_PRINT((ndo, "%s.%s > %s.%s: %d",
ip6addr_string(ndo, &ip6->ip6_src), srcid,
ip6addr_string(ndo, &ip6->ip6_dst), dstid, length));
break;
-#endif
default:
ND_PRINT((ndo, "%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length));
break;
#include "tcp.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
#include "rpc_auth.h"
#include "rpc_msg.h"
tcp_seq ack;
};
-#ifdef INET6
struct tha6 {
struct in6_addr src;
struct in6_addr dst;
tcp_seq seq;
tcp_seq ack;
};
-#endif
#define TSEQ_HASHSIZE 919
#define ZEROLENOPT(o) ((o) == TCPOPT_EOL || (o) == TCPOPT_NOP)
static struct tcp_seq_hash tcp_seq_hash4[TSEQ_HASHSIZE];
-#ifdef INET6
static struct tcp_seq_hash6 tcp_seq_hash6[TSEQ_HASHSIZE];
-#endif
static const struct tok tcp_flag_values[] = {
{ TH_FIN, "F" },
u_int utoval;
uint16_t magic;
register int rev;
-#ifdef INET6
register const struct ip6_hdr *ip6;
-#endif
tp = (const struct tcphdr *)bp;
ip = (const struct ip *)bp2;
-#ifdef INET6
if (IP_V(ip) == 6)
ip6 = (const struct ip6_hdr *)bp2;
else
ip6 = NULL;
-#endif /*INET6*/
ch = '\0';
if (!ND_TTEST(tp->th_dport)) {
ND_PRINT((ndo, "%s > %s: [|tcp]",
hlen = TH_OFF(tp) * 4;
-#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_TCP) {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ND_PRINT((ndo, "%s > %s: ",
tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_TCP) {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ipaddr_string(ndo, &ip->ip_src),
* both directions).
*/
rev = 0;
-#ifdef INET6
if (ip6) {
register struct tcp_seq_hash6 *th;
struct tcp_seq_hash6 *tcp_seq_hash;
thseq = th->seq;
thack = th->ack;
} else {
-#else /*INET6*/
- {
-#endif /*INET6*/
register struct tcp_seq_hash *th;
struct tcp_seq_hash *tcp_seq_hash;
const struct in_addr *src, *dst;
else
ND_PRINT((ndo, " (correct)"));
}
- }
-#ifdef INET6
- else if (IP_V(ip) == 6 && ip6->ip6_plen) {
+ } else if (IP_V(ip) == 6 && ip6->ip6_plen) {
if (ND_TTEST2(tp->th_sport, length)) {
sum = nextproto6_cksum(ip6, (const uint8_t *)tp,
length, length, IPPROTO_TCP);
}
}
-#endif
}
length -= hlen;
char zero_proto = 0;
MD5_CTX ctx;
uint16_t savecsum, tlen;
-#ifdef INET6
const struct ip6_hdr *ip6;
uint32_t len32;
uint8_t nxt;
-#endif
if (data + length > ndo->ndo_snapend) {
ND_PRINT((ndo, "snaplen too short, "));
tlen = EXTRACT_16BITS(&ip->ip_len) - IP_HL(ip) * 4;
tlen = htons(tlen);
MD5_Update(&ctx, (const char *)&tlen, sizeof(tlen));
-#ifdef INET6
} else if (IP_V(ip) == 6) {
ip6 = (const struct ip6_hdr *)ip;
MD5_Update(&ctx, (const char *)&ip6->ip6_src, sizeof(ip6->ip6_src));
MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt));
nxt = IPPROTO_TCP;
MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt));
-#endif
} else {
-#ifdef INET6
ND_PRINT((ndo, "IP version not 4 or 6, "));
-#else
- ND_PRINT((ndo, "IP version not 4, "));
-#endif
return (CANT_CHECK_SIGNATURE);
}
#include "udp.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
#include "rpc_auth.h"
#include "rpc_msg.h"
IPPROTO_UDP);
}
-#ifdef INET6
static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
u_int len)
{
return nextproto6_cksum(ip6, (const uint8_t *)(const void *)up, len, len,
IPPROTO_UDP);
}
-#endif
static void
udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dport)
{
-#ifdef INET6
const struct ip6_hdr *ip6;
if (IP_V(ip) == 6)
udpport_string(ndo, dport)));
}
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_UDP) {
if (sport == -1) {
ND_PRINT((ndo, "%s > %s: ",
register const u_char *cp;
register const u_char *ep = bp + length;
uint16_t sport, dport, ulen;
-#ifdef INET6
register const struct ip6_hdr *ip6;
-#endif
if (ep > ndo->ndo_snapend)
ep = ndo->ndo_snapend;
up = (const struct udphdr *)bp;
ip = (const struct ip *)bp2;
-#ifdef INET6
if (IP_V(ip) == 6)
ip6 = (const struct ip6_hdr *)bp2;
else
ip6 = NULL;
-#endif /*INET6*/
if (!ND_TTEST(up->uh_dport)) {
udpipaddr_print(ndo, ip, -1, -1);
ND_PRINT((ndo, "[|udp]"));
case PT_AODV:
udpipaddr_print(ndo, ip, sport, dport);
aodv_print(ndo, (const u_char *)(up + 1), length,
-#ifdef INET6
ip6 != NULL);
-#else
- 0);
-#endif
break;
case PT_RADIUS:
ND_PRINT((ndo, "[udp sum ok] "));
}
}
-#ifdef INET6
else if (IP_V(ip) == 6 && ip6->ip6_plen) {
/* for IPv6, UDP checksum is mandatory */
if (ND_TTEST2(cp[0], length)) {
ND_PRINT((ndo, "[udp sum ok] "));
}
}
-#endif
}
if (!ndo->ndo_qflag) {
rip_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(AODV_PORT))
aodv_print(ndo, (const u_char *)(up + 1), length,
-#ifdef INET6
ip6 != NULL);
-#else
- 0);
-#endif
else if (ISPORT(ISAKMP_PORT))
isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
else if (ISPORT(ISAKMP_PORT_NATT))
(dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
rx_print(ndo, (const void *)(up + 1), length, sport, dport,
(const u_char *) ip);
-#ifdef INET6
else if (ISPORT(RIPNG_PORT))
ripng_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
ahcp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
babel_print(ndo, (const u_char *)(up + 1), length);
-#endif /*INET6*/
/*
* Kludge in test for whiteboard packets.
*/
ldp_print(ndo, (const u_char *)(up + 1), length);
else if (ISPORT(OLSR_PORT))
olsr_print(ndo, (const u_char *)(up + 1), length,
-#if INET6
(IP_V(ip) == 6) ? 1 : 0);
-#else
- 0);
-#endif
else if (ISPORT(MPLS_LSP_PING_PORT))
lspping_print(ndo, (const u_char *)(up + 1), length);
else if (dport == BFD_CONTROL_PORT ||
--- /dev/null
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "strtoaddr.h"
+
+#ifndef NS_INADDRSZ
+#define NS_INADDRSZ 4 /* IPv4 T_A */
+#endif
+
+#ifndef NS_IN6ADDRSZ
+#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
+#endif
+
+#ifndef NS_INT16SZ
+#define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */
+#endif
+
+/*%
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+#ifndef NS_IN6ADDRSZ
+#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
+#endif
+
+/* int
+ * strtoaddr(src, dst)
+ * convert presentation level IPv4 address to network order binary form.
+ * return:
+ * 1 if `src' is a valid input, else 0.
+ * notice:
+ * does not touch `dst' unless it's returning 1.
+ * author:
+ * Paul Vixie, 1996.
+ */
+int
+strtoaddr(const char *src, void *dst)
+{
+ uint32_t val;
+ u_int digit;
+ ptrdiff_t n;
+ unsigned char c;
+ u_int parts[4];
+ u_int *pp = parts;
+
+ c = *src;
+ for (;;) {
+ /*
+ * Collect number up to ``.''.
+ * Values are specified as for C:
+ * 0x=hex, 0=octal, isdigit=decimal.
+ */
+ if (!isdigit(c))
+ return (0);
+ val = 0;
+ if (c == '0') {
+ c = *++src;
+ if (c == 'x' || c == 'X')
+ return (0);
+ else if (isdigit(c) && c != '9')
+ return (0);
+ }
+ for (;;) {
+ if (isdigit(c)) {
+ digit = c - '0';
+ if (digit >= 10)
+ break;
+ val = (val * 10) + digit;
+ c = *++src;
+ } else
+ break;
+ }
+ if (c == '.') {
+ /*
+ * Internet format:
+ * a.b.c.d
+ * a.b.c (with c treated as 16 bits)
+ * a.b (with b treated as 24 bits)
+ * a (with a treated as 32 bits)
+ */
+ if (pp >= parts + 3)
+ return (0);
+ *pp++ = val;
+ c = *++src;
+ } else
+ break;
+ }
+ /*
+ * Check for trailing characters.
+ */
+ if (c != '\0' && !isspace(c))
+ return (0);
+ /*
+ * Concoct the address according to
+ * the number of parts specified.
+ */
+ n = pp - parts + 1;
+ /* Takes dotted-quad only. it does not take shorthand. */
+ if (n != 4)
+ return (0);
+ switch (n) {
+
+ case 0:
+ return (0); /* initial nondigit */
+
+ case 1: /* a -- 32 bits */
+ break;
+
+ case 2: /* a.b -- 8.24 bits */
+ if (parts[0] > 0xff || val > 0xffffff)
+ return (0);
+ val |= parts[0] << 24;
+ break;
+
+ case 3: /* a.b.c -- 8.8.16 bits */
+ if ((parts[0] | parts[1]) > 0xff || val > 0xffff)
+ return (0);
+ val |= (parts[0] << 24) | (parts[1] << 16);
+ break;
+
+ case 4: /* a.b.c.d -- 8.8.8.8 bits */
+ if ((parts[0] | parts[1] | parts[2] | val) > 0xff)
+ return (0);
+ val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+ break;
+ }
+ if (dst) {
+ val = htonl(val);
+ memcpy(dst, &val, NS_INADDRSZ);
+ }
+ return (1);
+}
+
+/* int
+ * strtoaddr6(src, dst)
+ * convert presentation level IPv6 address to network order binary form.
+ * return:
+ * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ * (1) does not touch `dst' unless it's returning 1.
+ * (2) :: in a full address is silently ignored.
+ * credit:
+ * inspired by Mark Andrews.
+ * author:
+ * Paul Vixie, 1996.
+ */
+int
+strtoaddr6(const char *src, void *dst)
+{
+ static const char xdigits_l[] = "0123456789abcdef",
+ xdigits_u[] = "0123456789ABCDEF";
+ u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
+ const char *xdigits, *curtok;
+ int ch, seen_xdigits;
+ u_int val;
+
+ memset((tp = tmp), '\0', NS_IN6ADDRSZ);
+ endp = tp + NS_IN6ADDRSZ;
+ colonp = NULL;
+ /* Leading :: requires some special handling. */
+ if (*src == ':')
+ if (*++src != ':')
+ return (0);
+ curtok = src;
+ seen_xdigits = 0;
+ val = 0;
+ while ((ch = *src++) != '\0') {
+ const char *pch;
+
+ if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
+ pch = strchr((xdigits = xdigits_u), ch);
+ if (pch != NULL) {
+ val <<= 4;
+ val |= (int)(pch - xdigits);
+ if (++seen_xdigits > 4)
+ return (0);
+ continue;
+ }
+ if (ch == ':') {
+ curtok = src;
+ if (!seen_xdigits) {
+ if (colonp)
+ return (0);
+ colonp = tp;
+ continue;
+ } else if (*src == '\0')
+ return (0);
+ if (tp + NS_INT16SZ > endp)
+ return (0);
+ *tp++ = (u_char) (val >> 8) & 0xff;
+ *tp++ = (u_char) val & 0xff;
+ seen_xdigits = 0;
+ val = 0;
+ continue;
+ }
+ if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
+ strtoaddr(curtok, tp) > 0) {
+ tp += NS_INADDRSZ;
+ seen_xdigits = 0;
+ break; /*%< '\\0' was seen by strtoaddr(). */
+ }
+ return (0);
+ }
+ if (seen_xdigits) {
+ if (tp + NS_INT16SZ > endp)
+ return (0);
+ *tp++ = (u_char) (val >> 8) & 0xff;
+ *tp++ = (u_char) val & 0xff;
+ }
+ if (colonp != NULL) {
+ /*
+ * Since some memmove()'s erroneously fail to handle
+ * overlapping regions, we'll do the shift by hand.
+ */
+ const ptrdiff_t n = tp - colonp;
+ int i;
+
+ if (tp == endp)
+ return (0);
+ for (i = 1; i <= n; i++) {
+ endp[- i] = colonp[n - i];
+ colonp[n - i] = 0;
+ }
+ tp = endp;
+ }
+ if (tp != endp)
+ return (0);
+ memcpy(dst, tmp, NS_IN6ADDRSZ);
+ return (1);
+}
--- /dev/null
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Text string to address translation routines. */
+
+int strtoaddr(const char *src, void *dst);
+int strtoaddr6(const char *src, void *dst);
+
+
return (prefix_len);
}
-#ifdef INET6
int
mask62plen(const u_char *mask)
{
}
return (cidr_len);
}
-#endif /* INET6 */
/*
* Routine to print out information for text-based protocols such as FTP,