]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Don't require IPv6 library support in order to support IPv6 addresses.
authorGuy Harris <[email protected]>
Thu, 17 Sep 2015 21:56:44 +0000 (14:56 -0700)
committerGuy Harris <[email protected]>
Thu, 17 Sep 2015 21:56:44 +0000 (14:56 -0700)
Have our own routines to convert between IPv4/IPv6 addresses and
strings; that helps if, for example, we want to build binary versions of
tcpdump for Windows that can run both on NT 5 (W2K/WXP), which doesn't
have inet_ntop() or inet_pton(), and NT 6 (Vista/7/8/10), which do.  It
also means that we don't require IPv6 library support on UN*X to print
addresses (if somebody wants to build tcpdump for older UN*Xes lacking
IPv6 support in the system library or in add-on libraries).

Get rid of files in the missing directory that we don't need, and
various no-longer-necessary autoconf tests.

54 files changed:
Makefile.in
aclocal.m4
addrtoname.c
addrtoname.h
addrtostr.c [moved from missing/inet_ntop.c with 85% similarity]
addrtostr.h [moved from missing/inet_pton.c with 86% similarity]
config.h.in
configure
configure.in
missing/addrinfo.h [deleted file]
missing/getnameinfo.c [deleted file]
missing/inet_aton.c [deleted file]
netdissect-stdinc.h
netdissect.h
print-ahcp.c
print-aodv.c
print-babel.c
print-bgp.c
print-cdp.c
print-cfm.c
print-dccp.c
print-domain.c
print-esp.c
print-frag6.c
print-gre.c
print-icmp6.c
print-ip6.c
print-ip6opts.c
print-isakmp.c
print-isoclns.c
print-juniper.c
print-ldp.c
print-lldp.c
print-lmp.c
print-lspping.c
print-lwres.c
print-mobility.c
print-mptcp.c
print-nflog.c
print-nfs.c
print-olsr.c
print-pgm.c
print-pim.c
print-ripng.c
print-rpki-rtr.c
print-rsvp.c
print-rt6.c
print-sctp.c
print-sunrpc.c
print-tcp.c
print-udp.c
strtoaddr.c [new file with mode: 0644]
strtoaddr.h [new file with mode: 0644]
util-print.c

index 1a6bf410af14fe80aef7aa29fc94b445617e9878..966545e7058214a07bef3dce1795b4261729f494 100644 (file)
@@ -74,6 +74,7 @@ CSRC =        setsignal.c tcpdump.c util.c
 
 LIBNETDISSECT_SRC=\
        addrtoname.c \
+       addrtostr.c \
        af.c \
        ascii_strcasecmp.c \
        checksum.c \
@@ -100,6 +101,7 @@ LIBNETDISSECT_SRC=\
        print-ascii.c \
        print-atalk.c \
        print-atm.c \
+       print-babel.c \
        print-beep.c \
        print-bfd.c \
        print-bgp.c \
@@ -114,6 +116,7 @@ LIBNETDISSECT_SRC=\
        print-cnfp.c \
        print-dccp.c \
        print-decnet.c \
+       print-dhcp6.c \
        print-domain.c \
        print-dtp.c \
        print-dvmrp.c \
@@ -126,6 +129,7 @@ LIBNETDISSECT_SRC=\
        print-fddi.c \
        print-forces.c \
        print-fr.c \
+       print-frag6.c \
        print-ftp.c \
        print-geneve.c \
        print-geonet.c \
@@ -133,10 +137,12 @@ LIBNETDISSECT_SRC=\
        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 \
@@ -158,6 +164,7 @@ LIBNETDISSECT_SRC=\
        print-m3ua.c \
        print-medsa.c \
        print-mobile.c \
+       print-mobility.c \
        print-mpcp.c \
        print-mpls.c \
        print-mptcp.c \
@@ -171,6 +178,7 @@ LIBNETDISSECT_SRC=\
        print-openflow-1.0.c \
        print-openflow.c \
        print-ospf.c \
+       print-ospf6.c \
        print-otv.c \
        print-pgm.c \
        print-pim.c \
@@ -182,9 +190,11 @@ LIBNETDISSECT_SRC=\
        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 \
@@ -218,6 +228,7 @@ LIBNETDISSECT_SRC=\
        print-zephyr.c \
        print-zeromq.c \
        signature.c \
+       strtoaddr.c \
        util-print.c
 
 LOCALSRC = @LOCALSRC@
@@ -235,6 +246,7 @@ SRC =       $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
 OBJ =  $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
 HDR = \
        addrtoname.h \
+       addrtostr.h \
        af.h \
        ah.h \
        appletalk.h \
@@ -275,6 +287,7 @@ HDR = \
        signature.h \
        slcompress.h \
        smb.h \
+       strtoaddr.h \
        tcp.h \
        netdissect-stdinc.h \
        timeval-operations.h \
@@ -319,14 +332,9 @@ EXTRA_DIST = \
        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 \
@@ -335,16 +343,7 @@ EXTRA_DIST = \
        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 \
@@ -372,16 +371,8 @@ datalinks.o: $(srcdir)/missing/datalinks.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
index acb4e7d9b1c2922a08383b2364467e2670aa3a28..6b04a4c4ac914bf609880f3ab93ea158429c4640 100644 (file)
@@ -1149,131 +1149,6 @@ dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 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
index 3f04479c491b7f5ea73a8518120cceb4cb94246a..e49a78d4c6177b5a9e2cab9a653847d8dfd37cfa 100644 (file)
@@ -59,6 +59,7 @@ extern int ether_ntohost(char *, const struct ether_addr *);
 
 #include "netdissect.h"
 #include "addrtoname.h"
+#include "addrtostr.h"
 #include "llc.h"
 #include "setsignal.h"
 #include "extract.h"
@@ -89,7 +90,7 @@ static struct hnamemem eprototable[HASHNAMESIZE];
 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
@@ -127,9 +128,8 @@ win32_gethostbyaddr(const char *addr, int len, int type)
        }
 }
 #define gethostbyaddr win32_gethostbyaddr
-#endif /* INET6 & _WIN32 */
+#endif /* _WIN32 */
 
-#ifdef INET6
 struct h6namemem {
        struct in6_addr addr;
        char *name;
@@ -137,7 +137,6 @@ struct h6namemem {
 };
 
 static struct h6namemem h6nametable[HASHNAMESIZE];
-#endif /* INET6 */
 
 struct enamemem {
        u_short e_addr0;
@@ -265,7 +264,6 @@ getname(netdissect_options *ndo, const u_char *ap)
        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.
@@ -315,13 +313,12 @@ getname6(netdissect_options *ndo, const u_char *ap)
                        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";
 
@@ -1225,7 +1222,6 @@ newhnamemem(netdissect_options *ndo)
        return (p);
 }
 
-#ifdef INET6
 /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
 struct h6namemem *
 newh6namemem(netdissect_options *ndo)
@@ -1244,7 +1240,6 @@ newh6namemem(netdissect_options *ndo)
        p = ptr++;
        return (p);
 }
-#endif /* INET6 */
 
 /* Represent TCI part of the 802.1Q 4-octet tag as text. */
 const char *
index 03fb918733e8930c8813434e14851ba55e39a9a3..72e5ef19d54921ad5c9e9772b75853375270a3a0 100644 (file)
  * 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 {
@@ -41,19 +49,13 @@ extern const char *dnaddr_string(netdissect_options *, u_short);
 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
similarity index 85%
rename from missing/inet_ntop.c
rename to addrtostr.c
index 77928db96421a821e1542ff848471fd9901aab58..654f89226d086ec8e00f0028ec7fe95dfa983141 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -17,7 +17,7 @@
  * 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) {
@@ -70,7 +71,7 @@ inet_ntop_v4 (const void *src, char *dst, size_t size)
        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) {
@@ -91,12 +92,11 @@ inet_ntop_v4 (const void *src, char *dst, size_t size)
     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
@@ -105,6 +105,7 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
    * 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 {
@@ -120,7 +121,7 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
    */
   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;
@@ -170,9 +171,10 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
     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);
@@ -192,25 +194,8 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
   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;
-    }
-}
similarity index 86%
rename from missing/inet_pton.c
rename to addrtostr.h
index 66269e228072b2caff2f81eabbf35e28f88f9b4e..2b95a1625573b4593460fd2ee989110192cb3856 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999 Kungliga Tekniska H�gskolan
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -17,7 +17,7 @@
  * 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);
index ee3c1fec10ff965e5fc2fd76c910e01524c52cd6..6699671404ce77ed78f3f1e9dec7f7ad4fdf3113 100644 (file)
@@ -1,8 +1,5 @@
 /* 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
 
@@ -91,6 +82,9 @@
 /* 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
 
index 4b8fcee6bf8b9d1690c6365e929d586d4ed79e83..954f1097d05e9222d356445bacb5cec361e1a921 100755 (executable)
--- a/configure
+++ b/configure
@@ -704,7 +704,6 @@ enable_smb
 with_user
 with_chroot
 with_sandbox_capsicum
-enable_ipv6
 with_system_libpcap
 with_crypto
 with_cap_ng
@@ -1332,8 +1331,6 @@ Optional Features:
   --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]
@@ -4594,9 +4591,9 @@ $as_echo "no" >&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.
 #
 
     # Most operating systems have gethostbyname() in the default searched
@@ -4860,30 +4857,19 @@ fi
 
 
 
-{ $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>
@@ -4900,21 +4886,23 @@ foo(struct in6_addr *addr)
 
 _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
@@ -4935,8 +4923,7 @@ yes
 _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*
 
@@ -4954,8 +4941,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   ipv6type=$i;
                                ipv6lib=inet6;
                                ipv6libdir=/usr/local/v6/lib;
-                               ipv6trylibc=yes;
-                               CFLAGS="-DINET6 $CFLAGS"
+                               ipv6trylibc=yes
 fi
 rm -f conftest*
 
@@ -4970,8 +4956,7 @@ yes
 _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*
 
@@ -4982,7 +4967,7 @@ 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)
@@ -4997,8 +4982,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   $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*
 
@@ -5033,8 +5017,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   $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*
 
@@ -5064,239 +5047,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; 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.
-       #
-       { $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 :
@@ -5324,116 +5074,6 @@ $as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h
 
 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
@@ -6168,114 +5808,6 @@ fi
 # 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.
@@ -6493,44 +6025,6 @@ if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then :
 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 :
 
@@ -8293,42 +7787,6 @@ $as_echo "#define LBL_ALIGN 1" >>confdefs.h
 
     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; }
index 1e87c15163a0c7c896e4b086b7c5aa6477a8040c..d9363af95de1b54fe17acb4982d8c920da34c7f7 100644 (file)
@@ -235,32 +235,24 @@ else
 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>
@@ -273,17 +265,19 @@ foo(struct in6_addr *addr)
 #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
@@ -300,8 +294,7 @@ if test "$ipv6" = "yes"; then
 #ifdef IPV6_INRIA_VERSION
 yes
 #endif],
-                               [ipv6type=$i;
-                               CFLAGS="-DINET6 $CFLAGS"])
+                               [ipv6type=$i])
                        ;;
                kame)
                        dnl http://www.kame.net/
@@ -313,8 +306,7 @@ yes
                                [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/
@@ -323,8 +315,7 @@ yes
 #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/
@@ -337,7 +328,7 @@ yes
                                ipv6lib=inet6
                                ipv6libdir=/usr/inet6/lib
                                ipv6trylibc=yes;
-                               CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+                               CFLAGS="-I/usr/inet6/include $CFLAGS"
                        fi
                        ;;
                toshiba)
@@ -348,8 +339,7 @@ yes
 #endif],
                                [ipv6type=$i;
                                ipv6lib=inet6;
-                               ipv6libdir=/usr/local/v6/lib;
-                               CFLAGS="-DINET6 $CFLAGS"])
+                               ipv6libdir=/usr/local/v6/lib])
                        ;;
                v6d)
                        AC_EGREP_CPP(yes,
@@ -370,8 +360,7 @@ 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
@@ -397,151 +386,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; 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,
@@ -552,27 +396,6 @@ if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
            [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)
@@ -604,43 +427,6 @@ AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
 # 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.
@@ -759,14 +545,6 @@ fi
 # 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
@@ -1091,8 +869,6 @@ AC_LBL_SOCKADDR_SA_LEN
 
 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.
diff --git a/missing/addrinfo.h b/missing/addrinfo.h
deleted file mode 100644 (file)
index bf4bbf6..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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
diff --git a/missing/getnameinfo.c b/missing/getnameinfo.c
deleted file mode 100644 (file)
index 63aba73..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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;
-}
diff --git a/missing/inet_aton.c b/missing/inet_aton.c
deleted file mode 100644 (file)
index 098dc85..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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;
-}
index 093fc0928e881eaf28965c517f4ce38d0dbd954d..449678525ab7a5fe144729a579668aa7d17ce041 100644 (file)
 
 #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);
 
 /*
@@ -171,13 +170,16 @@ typedef char* caddr_t;
 #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>
@@ -241,6 +243,9 @@ typedef char* caddr_t;
 #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"
@@ -253,6 +258,16 @@ typedef char* caddr_t;
   #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
@@ -284,6 +299,30 @@ typedef char* caddr_t;
   }
 #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
index 03555178bd47104958e705b6bb29380c1ed26ed8..2ef9337ec17bf984a1bec4bf424d6d6dceb37c47 100644 (file)
@@ -335,9 +335,7 @@ extern int mask2plen(uint32_t);
 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. */
 
@@ -567,7 +565,6 @@ extern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pc
 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 *);
@@ -577,7 +574,6 @@ extern int mobility_print(netdissect_options *, const u_char *, 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);
@@ -593,9 +589,7 @@ extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
 
 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,
index 41a1bb0598b896326702aaa37d5bfd003b416407..5a60e4fe33caa02ba5a63a800f43bc2c30d7521c 100644 (file)
@@ -153,11 +153,7 @@ ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
                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 = ", ";
        }
@@ -205,11 +201,7 @@ ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char
                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 = ", ";
        }
index c0c2a6b15f3ec96e249a5bb7313d3a7ec3fb6b99..db293bb6231bfc16c729a78dd1e78193a94bc8c4 100644 (file)
@@ -52,7 +52,6 @@ struct aodv_rreq {
        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 */
@@ -75,7 +74,6 @@ struct aodv_rreq6_draft_01 {
        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 */
@@ -94,7 +92,6 @@ struct aodv_rrep {
        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 */
@@ -115,7 +112,6 @@ struct aodv_rrep6_draft_01 {
        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 */
@@ -126,7 +122,6 @@ struct rerr_unreach {
        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 */
@@ -135,7 +130,6 @@ struct rerr_unreach6_draft_01 {
        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) */
@@ -292,13 +286,8 @@ trunc:
 }
 
 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;
 
@@ -325,19 +314,11 @@ aodv_v6_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 
 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;
 
@@ -361,19 +342,11 @@ aodv_v6_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 
 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;
@@ -399,19 +372,11 @@ aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 
 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;
 
@@ -438,19 +403,11 @@ aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int leng
 
 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;
 
@@ -474,19 +431,11 @@ aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int leng
 
 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;
@@ -512,9 +461,6 @@ aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int leng
 
 trunc:
        ND_PRINT((ndo, "[|rerr]"));
-#else
-       ND_PRINT((ndo, " rerr %u", length));
-#endif
 }
 
 void
index 1d20988c5eaf20369ada553e5483bccfdd04da70..c51473235b1bb66b784d6a5cd31660b9291847a4 100644 (file)
@@ -126,11 +126,7 @@ format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
     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;
 }
@@ -141,11 +137,7 @@ format_address(netdissect_options *ndo, const u_char *prefix)
     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 *
index a55ea7060220b790bd7ed71c2aed03d8b2b3b888..167bb9b42f8fe69ed384232c5e3a1a6b2fe1bb82 100644 (file)
@@ -603,12 +603,10 @@ bgp_vpn_ip_print(netdissect_options *ndo,
         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;
@@ -1071,7 +1069,6 @@ trunc:
         return -2;
 }
 
-#ifdef INET6
 int
 decode_prefix6(netdissect_options *ndo,
                const u_char *pd, u_int itemlen, char *buf, u_int buflen)
@@ -1188,7 +1185,6 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
 trunc:
        return -2;
 }
-#endif
 
 static int
 decode_clnp_prefix(netdissect_options *ndo,
@@ -1520,7 +1516,6 @@ bgp_attr_print(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):
@@ -1528,7 +1523,6 @@ bgp_attr_print(netdissect_options *ndo,
                 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):
@@ -1596,7 +1590,6 @@ bgp_attr_print(netdissect_options *ndo,
                                 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):
@@ -1626,7 +1619,6 @@ bgp_attr_print(netdissect_options *ndo,
                                 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):
@@ -1664,11 +1656,9 @@ bgp_attr_print(netdissect_options *ndo,
                                 /* 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;
                             }
@@ -1769,7 +1759,6 @@ bgp_attr_print(netdissect_options *ndo,
                         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):
@@ -1805,7 +1794,6 @@ bgp_attr_print(netdissect_options *ndo,
                         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):
@@ -1910,7 +1898,6 @@ bgp_attr_print(netdissect_options *ndo,
                         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):
@@ -1946,7 +1933,6 @@ bgp_attr_print(netdissect_options *ndo,
                         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):
@@ -2443,10 +2429,6 @@ bgp_update_print(netdissect_options *ndo,
        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)
@@ -2471,36 +2453,9 @@ bgp_update_print(netdissect_options *ndo,
                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);
index 3065193e2f65f0c04c4ba8779d3aeb9bd3a06279..96ef143b158ec4f2c347a1702290b29e78f042a5 100644 (file)
@@ -277,11 +277,9 @@ cdp_print_addr(netdissect_options *ndo,
 {
        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)
@@ -316,7 +314,6 @@ cdp_print_addr(netdissect_options *ndo,
                        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) {
                        /*
@@ -333,7 +330,6 @@ cdp_print_addr(netdissect_options *ndo,
                        ND_PRINT((ndo, "IPv6 (%u) %s", num, ip6addr_string(ndo, p)));
                        p += al;
                }
-#endif
                else {
                        /*
                         * Generic case: just print raw data
index c48b1a29584039dc48eaa31f6c4c48fac9c3c62f..2d67e84c7000ebf8b8b3b1cb47e1e95ce5bf426c 100644 (file)
@@ -249,11 +249,9 @@ cfm_mgmt_addr_print(netdissect_options *ndo,
         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;
index 5e286c76a44883d6de895052cd6656eb9527016b..f552f0535034372f900154529f12affc0c477402 100644 (file)
@@ -20,9 +20,7 @@
 #include "addrtoname.h"
 #include "extract.h"
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 #include "ipproto.h"
 
 /* RFC4340: Datagram Congestion Control Protocol (DCCP) */
@@ -204,13 +202,11 @@ static int dccp_cksum(netdissect_options *ndo, const struct ip *ip,
                                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)
 {
@@ -271,9 +267,7 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
 {
        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;
@@ -283,12 +277,10 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
        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);
@@ -315,14 +307,11 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
        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));
@@ -352,10 +341,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
                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
index 1d99f14247930da8d1d98f9b2fad6277912f08c0..c3066f7d7d30e75a7ce05ccb0e7feedd768b67bd 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "netdissect.h"
 #include "addrtoname.h"
+#include "addrtostr.h"
 #include "extract.h"
 
 static const char *ns_ops[] = {
@@ -480,17 +481,14 @@ ns_rprint(netdissect_options *ndo,
                        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;
            }
@@ -514,7 +512,7 @@ ns_rprint(netdissect_options *ndo,
                        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, " "));
@@ -523,7 +521,6 @@ ns_rprint(netdissect_options *ndo,
                }
                break;
            }
-#endif /*INET6*/
 
        case T_OPT:
                ND_PRINT((ndo, " UDPsize=%u", class));
index 426aa845eca017fae411488ccdcb0112ef58258d..50cc2d1f7b72a3abfc1e59872134adfdf14022dc 100644 (file)
 #endif
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 
 #include "netdissect.h"
+#include "strtoaddr.h"
 #include "extract.h"
 
 #include "ascii_strcasecmp.h"
@@ -99,9 +98,7 @@ struct newesp {
 #ifdef HAVE_LIBCRYPTO
 union inaddr_u {
        struct in_addr in4;
-#ifdef INET6
        struct in6_addr in6;
-#endif
 };
 struct sa_list {
        struct sa_list  *next;
@@ -478,17 +475,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
 
                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) {
@@ -567,9 +561,7 @@ esp_print(netdissect_options *ndo,
 #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;
@@ -618,7 +610,6 @@ esp_print(netdissect_options *ndo,
 
        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 */
@@ -637,7 +628,6 @@ esp_print(netdissect_options *ndo,
                        }
                }
                break;
-#endif /*INET6*/
        case 4:
                /* nexthdr & padding are in the last fragment */
                if (EXTRACT_16BITS(&ip->ip_off) & IP_MF)
index 967e63737d0cfd4b04bf37149107cb5ef1e6f988..491b07260032a04da95bd649345a4fc7d5a144da 100644 (file)
@@ -23,8 +23,6 @@
 #include "config.h"
 #endif
 
-#ifdef INET6
-
 #include <netdissect-stdinc.h>
 
 #include "ip6.h"
@@ -67,4 +65,3 @@ trunc:
        ND_PRINT((ndo, "[|frag]"));
        return -1;
 }
-#endif /* INET6 */
index 89cbe076c44c35f997b6187b725150dbb0027730..187a5b9f48297a9b260ea4d1e4a3328d01ccc871 100644 (file)
@@ -45,6 +45,7 @@
 #include <string.h>
 
 #include "netdissect.h"
+#include "addrtostr.h"
 #include "extract.h"
 #include "ethertype.h"
 
@@ -330,8 +331,8 @@ static void
 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));
@@ -350,10 +351,9 @@ gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
                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;
index ce4b185609f1b1409de5e01b2b25ec5d8de075f5..56f80bfbb287f0a4ce7f1da9220f15b5a1e594df 100644 (file)
@@ -23,8 +23,6 @@
 #include "config.h"
 #endif
 
-#ifdef INET6
-
 #include <netdissect-stdinc.h>
 
 #include <stdio.h>
@@ -32,6 +30,7 @@
 
 #include "netdissect.h"
 #include "addrtoname.h"
+#include "addrtostr.h"
 #include "extract.h"
 
 #include "ip6.h"
@@ -1903,7 +1902,7 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
                        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));
@@ -1946,8 +1945,7 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
                                        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
@@ -1964,8 +1962,6 @@ trunc:
        ND_PRINT((ndo,"[|icmp6]"));
 }
 
-#endif /* INET6 */
-
 /*
  * Local Variables:
  * c-style: whitesmith
index dda9ba35f259bb8a9908c0178cf3a916be42dcf0..45508ced6cbf11a0ea5eb537f540488c0a3d1d97 100644 (file)
@@ -31,8 +31,6 @@
 #include "addrtoname.h"
 #include "extract.h"
 
-#ifdef INET6
-
 #include "ip6.h"
 #include "ipproto.h"
 
@@ -263,13 +261,3 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
 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 */
index a90ce65b480f108b6703753169bbb24bd5e6eba8..74f6d0e29c0eb2ba9cc9de8930d1f4feceb922ec 100644 (file)
@@ -31,7 +31,6 @@
 #include "config.h"
 #endif
 
-#ifdef INET6
 #include <netdissect-stdinc.h>
 
 #include "ip6.h"
@@ -210,4 +209,3 @@ dstopt_print(netdissect_options *ndo, register const u_char *bp)
     ND_PRINT((ndo, "[|DSTOPT]"));
     return(-1);
 }
-#endif /* INET6 */
index 4b04ccde8119326cc00053cbd9a649510a5a34c3..dcf2ea44705dbaae99df0703cb7694c6a97dc2a8 100644 (file)
@@ -48,9 +48,7 @@
 #include "extract.h"
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 
 /* refer to RFC 2408 */
 
@@ -647,9 +645,7 @@ ikev1_print(netdissect_options *ndo,
 int ninitiator = 0;
 union inaddr_u {
        struct in_addr in4;
-#ifdef INET6
        struct in6_addr in6;
-#endif
 };
 struct {
        cookie_t initiator;
@@ -781,9 +777,7 @@ cookie_record(cookie_t *in, const u_char *bp2)
 {
        int i;
        const struct ip *ip;
-#ifdef INET6
        const struct ip6_hdr *ip6;
-#endif
 
        i = cookie_find(in);
        if (0 <= i) {
@@ -798,14 +792,12 @@ cookie_record(cookie_t *in, const u_char *bp2)
                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;
        }
@@ -819,9 +811,7 @@ static int
 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)) {
@@ -836,7 +826,6 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
                                return 1;
                }
                break;
-#ifdef INET6
        case 6:
                if (cookiecache[i].version != 6)
                        return 0;
@@ -849,7 +838,6 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
                                return 1;
                }
                break;
-#endif /* INET6 */
        default:
                break;
        }
@@ -1406,7 +1394,6 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
                        len = 0;
                        break;
                    }
-#ifdef INET6
                case IPSECDOI_ID_IPV6_ADDR:
                        if (len < 16)
                                ND_PRINT((ndo," len=%d [bad: < 16]", len));
@@ -1432,7 +1419,6 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
                        len = 0;
                        break;
                    }
-#endif /*INET6*/
                case IPSECDOI_ID_IPV4_ADDR_RANGE:
                        if (len < 8)
                                ND_PRINT((ndo," len=%d [bad: < 8]", len));
@@ -1443,7 +1429,6 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
                        }
                        len = 0;
                        break;
-#ifdef INET6
                case IPSECDOI_ID_IPV6_ADDR_RANGE:
                        if (len < 32)
                                ND_PRINT((ndo," len=%d [bad: < 32]", len));
@@ -1454,7 +1439,6 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
                        }
                        len = 0;
                        break;
-#endif /*INET6*/
                case IPSECDOI_ID_DER_ASN1_DN:
                case IPSECDOI_ID_DER_ASN1_GN:
                case IPSECDOI_ID_KEY_ID:
index 59a72f15b2774d4b6b20026e39c2e60b1da1d57c..2d5ac4591e0c619f2e9e1efb49e7bd58cf6a3f2b 100644 (file)
@@ -1949,11 +1949,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
                          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))
@@ -1974,7 +1970,6 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
             return (0);
         }
         processed++;
-#ifdef INET6
     } else if (afi == AF_INET6) {
         if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
             return (0);
@@ -1987,7 +1982,6 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
             return (0);
         }
         processed+=2;
-#endif
     } else
         return (0); /* somebody is fooling us */
 
@@ -2005,13 +1999,11 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
                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",
@@ -2019,17 +2011,13 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
 
     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
@@ -2605,7 +2593,6 @@ isis_print(netdissect_options *ndo,
            }
            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);
@@ -2645,7 +2632,6 @@ isis_print(netdissect_options *ndo,
                tmp -= sizeof(struct in6_addr);
            }
            break;
-#endif
        case ISIS_TLV_AUTH:
            if (!ND_TTEST2(*tptr, 1))
                goto trunctlv;
index 9eafd515d560fac82ba87c8a10662a6e2fcf8954..94151c812fe967694abc76e965f51d4be0fcc122 100644 (file)
@@ -1032,10 +1032,8 @@ juniper_ppp_heuristic_guess(netdissect_options *ndo,
     case PPP_PAP :
     case PPP_CHAP :
     case PPP_ML :
-#ifdef INET6
     case PPP_IPV6 :
     case PPP_IPV6CP :
-#endif
         ppp_print(ndo, p, length);
         break;
 
index ceaca150171299ae021cf03c34748fb5b10948b3..45a23fe0c79976bcde813d4886b4c0038a0bb175 100644 (file)
@@ -283,12 +283,10 @@ ldp_tlv_print(netdissect_options *ndo,
         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)));
@@ -310,7 +308,6 @@ ldp_tlv_print(netdissect_options *ndo,
                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));
@@ -319,7 +316,6 @@ ldp_tlv_print(netdissect_options *ndo,
                tptr+=sizeof(struct in6_addr);
            }
             break;
-#endif
         default:
             /* unknown AF */
             break;
@@ -364,7 +360,6 @@ ldp_tlv_print(netdissect_options *ndo,
                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)
@@ -376,7 +371,6 @@ ldp_tlv_print(netdissect_options *ndo,
                else
                    ND_PRINT((ndo, ": IPv6 prefix %s", buf));
            }
-#endif
            else
                ND_PRINT((ndo, ": Address family %u prefix", af));
            break;
index ac58198f951336b59ea0c553d800b60be0730c86..82b7ebec1508e2cf727151c70bf732e1725feae9 100644 (file)
@@ -1280,13 +1280,11 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
           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;
index 53e62d18b34c122831c786c619df67362a7534b9..30edfc7437d222cb0f1298b767786ec5faba3486 100644 (file)
@@ -458,14 +458,12 @@ lmp_print(netdissect_options *ndo,
                        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)",
@@ -550,9 +548,7 @@ lmp_print(netdissect_options *ndo,
                        EXTRACT_32BITS(obj_tptr+8)));
                break;
 
-#ifdef INET6
            case LMP_CTYPE_IPV6:
-#endif
            case LMP_CTYPE_UNMD:
             default:
                 hexdump=TRUE;
@@ -619,9 +615,7 @@ lmp_print(netdissect_options *ndo,
                }
 
                break;
-#ifdef INET6
            case LMP_CTYPE_IPV6:
-#endif
             default:
                 hexdump=TRUE;
             }
@@ -708,9 +702,7 @@ lmp_print(netdissect_options *ndo,
                        offset+=8;
                }
                 break;
-#ifdef INET6
            case LMP_CTYPE_IPV6:
-#endif
             default:
                 hexdump=TRUE;
             }
@@ -728,9 +720,7 @@ lmp_print(netdissect_options *ndo,
                        offset+=4;
                }
                 break;
-#ifdef INET6
            case LMP_CTYPE_IPV6:
-#endif
            default:
                 hexdump=TRUE;
             }
index 064243ed6879a7d505679d716b98367ef89f2bb2..3e48504963e096f70208787e18f62616cc8aa685 100644 (file)
@@ -629,7 +629,6 @@ lspping_print(netdissect_options *ndo,
                            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;
@@ -637,7 +636,6 @@ lspping_print(netdissect_options *ndo,
                            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 = \
@@ -648,7 +646,6 @@ lspping_print(netdissect_options *ndo,
                            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;
@@ -657,7 +654,6 @@ lspping_print(netdissect_options *ndo,
                            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 = \
@@ -671,7 +667,6 @@ lspping_print(netdissect_options *ndo,
                            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;
@@ -683,7 +678,6 @@ lspping_print(netdissect_options *ndo,
                            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 = \
@@ -694,7 +688,6 @@ lspping_print(netdissect_options *ndo,
                            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;
@@ -703,7 +696,6 @@ lspping_print(netdissect_options *ndo,
                            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 = \
@@ -791,7 +783,6 @@ lspping_print(netdissect_options *ndo,
                 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",
@@ -800,7 +791,6 @@ lspping_print(netdissect_options *ndo,
                 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",
index f6252cbaf1f34963e9c78919a8a3cffaee8102ea..7dea033556e1445e8535f3d8f8c5e9169cf16165 100644 (file)
@@ -268,14 +268,12 @@ lwres_printaddr(netdissect_options *ndo,
                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++)
index 37410373b0012696ed8d4b970bc0ee5460e3e925..85aa5bb98b9d31ba5d8380119d197f4c97629e12 100644 (file)
@@ -31,7 +31,6 @@
 #include "config.h"
 #endif
 
-#ifdef INET6
 #include <netdissect-stdinc.h>
 
 #include "ip6.h"
@@ -330,4 +329,3 @@ mobility_print(netdissect_options *ndo,
        ND_PRINT((ndo, "[|MOBILITY]"));
        return(mhlen);
 }
-#endif /* INET6 */
index 95402ef614e77494516a3c69430cbd8b28e1eb5b..c711754f714bc0147dea9986404a04754b2c6acb 100644 (file)
@@ -324,9 +324,7 @@ add_addr_print(netdissect_options *ndo,
                         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;
index 222d5c3f3044cac65a8404079d5c3c8c1e38f75c..2a42f537c78da879cf204235ba72cebf4af95b45 100644 (file)
@@ -38,9 +38,9 @@
 
 static const struct tok nflog_values[] = {
        { AF_INET,              "IPv4" },
-#ifdef INET6
+#ifdef AF_INET6
        { AF_INET6,             "IPv6" },
-#endif /*INET6*/
+#endif /*AF_INET6*/
        { 0,                    NULL }
 };
 
index 87b6f5a4f341c7e8ef7bd9a26bf9b82fa7a09adc..84884aa5a1f439320e231b0abbcb3ae58ac936c7 100644 (file)
@@ -36,9 +36,7 @@
 #include "nfsfh.h"
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 #include "rpc_auth.h"
 #include "rpc_msg.h"
 
@@ -203,15 +201,8 @@ print_nfsaddr(netdissect_options *ndo,
               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)) {
@@ -220,7 +211,6 @@ print_nfsaddr(netdissect_options *ndo,
                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),
@@ -228,7 +218,6 @@ print_nfsaddr(netdissect_options *ndo,
                strlcpy(dstaddr, ip6addr_string(ndo, &ip6->ip6_dst),
                    sizeof(dstaddr));
                break;
-#endif
        default:
                strlcpy(srcaddr, "?", sizeof(srcaddr));
                strlcpy(dstaddr, "?", sizeof(dstaddr));
@@ -850,13 +839,8 @@ nfs_printfh(netdissect_options *ndo,
 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) */
 };
@@ -879,9 +863,7 @@ xid_map_enter(netdissect_options *ndo,
               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))
@@ -890,11 +872,9 @@ xid_map_enter(netdissect_options *ndo,
        case 4:
                ip = (const struct ip *)bp;
                break;
-#ifdef INET6
        case 6:
                ip6 = (const struct ip6_hdr *)bp;
                break;
-#endif
        default:
                return (1);
        }
@@ -910,13 +890,11 @@ xid_map_enter(netdissect_options *ndo,
                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);
@@ -934,9 +912,7 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
        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));
@@ -956,7 +932,6 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
                                cmp = 0;
                        }
                        break;
-#ifdef INET6
                case 6:
                        if (UNALIGNED_MEMCMP(&ip6->ip6_src, &xmep->server,
                                   sizeof(ip6->ip6_src)) != 0 ||
@@ -965,7 +940,6 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
                                cmp = 0;
                        }
                        break;
-#endif
                default:
                        cmp = 0;
                        break;
index 97cf59b52fc48736992f8967a84e69806f2a2c79..2473dfed3f355b640651748a00f949b54b0be302 100644 (file)
@@ -252,7 +252,6 @@ olsr_print_lq_neighbor4(netdissect_options *ndo,
     return (0);
 }
 
-#if INET6
 static int
 olsr_print_lq_neighbor6(netdissect_options *ndo,
                         const u_char *msg_data, u_int hello_len)
@@ -276,7 +275,6 @@ olsr_print_lq_neighbor6(netdissect_options *ndo,
     }
     return (0);
 }
-#endif /* INET6 */
 
 /*
  * print a neighbor list.
@@ -361,7 +359,6 @@ olsr_print(netdissect_options *ndo,
 
         ND_TCHECK2(*tptr, sizeof(struct olsr_msg4));
 
-#if INET6
         if (is_ipv6)
         {
             msgptr.v6 = (const struct olsr_msg6 *) tptr;
@@ -393,7 +390,6 @@ olsr_print(netdissect_options *ndo,
             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;
@@ -473,13 +469,10 @@ olsr_print(netdissect_options *ndo,
                     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;
                     }
@@ -506,13 +499,10 @@ olsr_print(netdissect_options *ndo,
                 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;
                 }
@@ -523,21 +513,14 @@ olsr_print(netdissect_options *ndo,
         {
             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;
@@ -546,7 +529,6 @@ olsr_print(netdissect_options *ndo,
         }
 
         case OLSR_HNA_MSG:
-#if INET6
             if (is_ipv6)
             {
                 int i = 0;
@@ -570,7 +552,6 @@ olsr_print(netdissect_options *ndo,
                 }
             }
             else
-#endif
             {
                 int col = 0;
 
@@ -692,12 +673,10 @@ olsr_print(netdissect_options *ndo,
 
                 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);
index ddba527ff95d77e04446e6cbbc65ff58b6d0f214..0d5685d9e42abdcf10d1c2c558d2ff51d4413748 100644 (file)
 #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"
 
@@ -150,42 +149,26 @@ pgm_print(netdissect_options *ndo,
        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)));
@@ -196,7 +179,6 @@ pgm_print(netdissect_options *ndo,
        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: ",
@@ -208,9 +190,7 @@ pgm_print(netdissect_options *ndo,
                        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),
@@ -243,28 +223,24 @@ pgm_print(netdissect_options *ndo,
 
            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),
@@ -290,28 +266,23 @@ pgm_print(netdissect_options *ndo,
 
            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);
@@ -358,16 +329,11 @@ pgm_print(netdissect_options *ndo,
        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
@@ -375,53 +341,44 @@ pgm_print(netdissect_options *ndo,
             */
            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 "));
@@ -600,33 +557,35 @@ pgm_print(netdissect_options *ndo,
 
                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:
@@ -731,66 +690,70 @@ pgm_print(netdissect_options *ndo,
                    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:
index 46398152611ececdc7c0f4c28e1d618c185511d2..ce4b2afd5228df258266550cf881b6baf8782712 100644 (file)
@@ -535,12 +535,10 @@ pimv2_addr_print(netdissect_options *ndo,
                        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;
                }
@@ -552,11 +550,9 @@ pimv2_addr_print(netdissect_options *ndo,
                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;
@@ -573,12 +569,10 @@ pimv2_addr_print(netdissect_options *ndo,
                        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:
@@ -590,7 +584,6 @@ pimv2_addr_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, "/%u", bp[1]));
                        }
                }
-#ifdef INET6
                else if (af == AF_INET6) {
                        if (!silent) {
                                ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
@@ -598,7 +591,6 @@ pimv2_addr_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, "/%u", bp[1]));
                        }
                }
-#endif
                if (bp[0] && !silent) {
                        if (at == pimv2_group) {
                                ND_PRINT((ndo, "(0x%02x)", bp[0]));
@@ -641,14 +633,12 @@ pimv2_check_checksum(const u_char *bp, const u_char *bp2, u_int len)
                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);
        }
index a9edfb489a200af9d90d89da8fae5aa0d6055322..9bda0fd38e283f2ae948b0ad0d337107b76bf2ec 100644 (file)
@@ -23,8 +23,6 @@
 #include "config.h"
 #endif
 
-#ifdef INET6
-
 #include <netdissect-stdinc.h>
 
 #include "netdissect.h"
@@ -172,4 +170,3 @@ ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
        if (rp->rip6_vers != RIP6_VERSION)
                ND_PRINT((ndo, " [vers %d]", rp->rip6_vers));
 }
-#endif /* INET6 */
index d4fd60d87e673a58f3acddd346953d5d83833065..3d2f383cd47f8c64eb12da55f51dfa77f99765ba 100644 (file)
@@ -231,7 +231,6 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
        }
        break;
 
-#ifdef INET6
     case RPKI_RTR_IPV6_PREFIX_PDU:
        {
            const rpki_rtr_pdu_ipv6_prefix *pdu;
@@ -244,7 +243,6 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
                   EXTRACT_32BITS(pdu->as), pdu->flags));
        }
        break;
-#endif
 
     case RPKI_RTR_ERROR_REPORT_PDU:
        {
index 74b6358b3b04bc15ee08658677bf1d88669a75e5..6c807fe71b865e36d6053c4a3febd0cd2ed11531 100644 (file)
@@ -722,7 +722,6 @@ _U_
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
-#ifdef INET6
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 20)
                     return -1;
@@ -761,7 +760,6 @@ _U_
                 obj_tlen-=26;
                 obj_tptr+=26;
                 break;
-#endif
             case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
                 if (obj_tlen < 12)
                     return -1;
@@ -801,7 +799,6 @@ _U_
                 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;
@@ -811,7 +808,6 @@ _U_
                 obj_tlen-=sizeof(struct in6_addr);
                 obj_tptr+=sizeof(struct in6_addr);
                 break;
-#endif
             default:
                 hexdump=TRUE;
             }
@@ -828,7 +824,6 @@ _U_
                 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;
@@ -838,7 +833,6 @@ _U_
                 obj_tlen-=sizeof(struct in6_addr);
                 obj_tptr+=sizeof(struct in6_addr);
                 break;
-#endif
             default:
                 hexdump=TRUE;
             }
@@ -913,7 +907,6 @@ _U_
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
-#ifdef INET6
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 20)
                     return-1;
@@ -938,7 +931,6 @@ _U_
                 obj_tlen-=40;
                 obj_tptr+=40;
                 break;
-#endif
             case RSVP_CTYPE_TUNNEL_IPV4:
                 if (obj_tlen < 8)
                     return-1;
@@ -1189,14 +1181,12 @@ _U_
                             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 */
@@ -1270,7 +1260,6 @@ _U_
                 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)
@@ -1283,7 +1272,6 @@ _U_
                 obj_tptr+=20;
                 hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
                 break;
-#endif
             default:
                 hexdump=TRUE;
             }
@@ -1359,7 +1347,6 @@ _U_
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
-#ifdef INET6
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 20)
                     return-1;
@@ -1404,7 +1391,6 @@ _U_
                 obj_tlen-=40;
                 obj_tptr+=40;
                 break;
-#endif
             case RSVP_CTYPE_TUNNEL_IPV4:
                 if (obj_tlen < 8)
                     return-1;
@@ -1546,7 +1532,6 @@ _U_
                 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)
@@ -1573,7 +1558,6 @@ _U_
                 obj_tlen-=20;
                 obj_tptr+=20;
                 break;
-#endif
             default:
                 hexdump=TRUE;
             }
@@ -1749,7 +1733,6 @@ _U_
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
-#ifdef INET6
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 16)
                     return-1;
@@ -1759,7 +1742,6 @@ _U_
                 obj_tlen-=16;
                 obj_tptr+=16;
                 break;
-#endif
             default:
                 hexdump=TRUE;
             }
index 9b87777f8a823447189f1c2843bceae8e57beee1..231f5ff4ce42150041aa5f4cc10225d38d20600f 100644 (file)
@@ -23,8 +23,6 @@
 #include "config.h"
 #endif
 
-#ifdef INET6
-
 #include <netdissect-stdinc.h>
 
 #include <string.h>
@@ -107,4 +105,3 @@ rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2
        ND_PRINT((ndo, "[|srcrt]"));
        return -1;
 }
-#endif /* INET6 */
index aebd3c22714eb1dc696487709bfb2dec42e97290..49d1cbba789a14b15496f707a083f1f5e2be70a1 100644 (file)
@@ -43,9 +43,7 @@
 #include "addrtoname.h"
 #include "extract.h"
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 
 /* Definitions from:
  *
@@ -497,9 +495,7 @@ void sctp_print(netdissect_options *ndo,
 {
   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;
@@ -515,12 +511,10 @@ void sctp_print(netdissect_options *ndo,
   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))
@@ -536,7 +530,6 @@ void sctp_print(netdissect_options *ndo,
   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),
@@ -544,7 +537,6 @@ void sctp_print(netdissect_options *ndo,
       ip6addr_string(ndo, &ip6->ip6_dst),
       destPort));
   } else
-#endif /*INET6*/
   {
     ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
       ipaddr_string(ndo, &ip->ip_src),
index 771602d2918d5c67b6e82c451fc8bfbb61acd31c..2394dd03320cd8039e486ebc68c02ceea6c557b3 100644 (file)
@@ -55,9 +55,7 @@
 #include "extract.h"
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 
 #include "rpc_auth.h"
 #include "rpc_msg.h"
@@ -170,9 +168,7 @@ sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
 {
        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*/
 
@@ -195,14 +191,12 @@ sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
                    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;
index a97fc1ca2e36ae79a53e750636d3c127a796c4fe..76811532390335247e948705df4d31f76da04189 100644 (file)
@@ -44,9 +44,7 @@ __RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
 #include "tcp.h"
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 #include "ipproto.h"
 #include "rpc_auth.h"
 #include "rpc_msg.h"
@@ -80,7 +78,6 @@ struct tcp_seq_hash {
         tcp_seq ack;
 };
 
-#ifdef INET6
 struct tha6 {
         struct in6_addr src;
         struct in6_addr dst;
@@ -93,7 +90,6 @@ struct tcp_seq_hash6 {
         tcp_seq seq;
         tcp_seq ack;
 };
-#endif
 
 #define TSEQ_HASHSIZE 919
 
@@ -101,9 +97,7 @@ struct tcp_seq_hash6 {
 #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" },
@@ -164,18 +158,14 @@ tcp_print(netdissect_options *ndo,
         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]",
@@ -189,7 +179,6 @@ tcp_print(netdissect_options *ndo,
 
         hlen = TH_OFF(tp) * 4;
 
-#ifdef INET6
         if (ip6) {
                 if (ip6->ip6_nxt == IPPROTO_TCP) {
                         ND_PRINT((ndo, "%s.%s > %s.%s: ",
@@ -201,9 +190,7 @@ tcp_print(netdissect_options *ndo,
                         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),
@@ -249,7 +236,6 @@ tcp_print(netdissect_options *ndo,
                  * both directions).
                  */
                 rev = 0;
-#ifdef INET6
                 if (ip6) {
                         register struct tcp_seq_hash6 *th;
                         struct tcp_seq_hash6 *tcp_seq_hash;
@@ -305,9 +291,6 @@ tcp_print(netdissect_options *ndo,
                         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;
@@ -388,9 +371,7 @@ tcp_print(netdissect_options *ndo,
                                 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);
@@ -405,7 +386,6 @@ tcp_print(netdissect_options *ndo,
 
                         }
                 }
-#endif
         }
 
         length -= hlen;
@@ -827,11 +807,9 @@ tcp_verify_signature(netdissect_options *ndo,
         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, "));
@@ -857,7 +835,6 @@ tcp_verify_signature(netdissect_options *ndo,
                 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));
@@ -870,13 +847,8 @@ tcp_verify_signature(netdissect_options *ndo,
                 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);
         }
 
index 21102391f20364e8421bb9702c66ec1d95e99745..cc6b275e8d12c5dcd5e56ad8ff44792f7b9985cc 100644 (file)
@@ -33,9 +33,7 @@
 #include "udp.h"
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 #include "ipproto.h"
 #include "rpc_auth.h"
 #include "rpc_msg.h"
@@ -277,19 +275,16 @@ static int udp_cksum(netdissect_options *ndo, register const struct ip *ip,
                                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)
@@ -317,9 +312,7 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo
                                        udpport_string(ndo, dport)));
                        }
                }
-       } else
-#endif /*INET6*/
-       {
+       } else {
                if (ip->ip_p == IPPROTO_UDP) {
                        if (sport == -1) {
                                ND_PRINT((ndo, "%s > %s: ",
@@ -351,20 +344,16 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
        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]"));
@@ -453,11 +442,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                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:
@@ -543,7 +528,6 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                                        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)) {
@@ -558,7 +542,6 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                                        ND_PRINT((ndo, "[udp sum ok] "));
                        }
                }
-#endif
        }
 
        if (!ndo->ndo_qflag) {
@@ -577,11 +560,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                        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))
@@ -616,7 +595,6 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                         (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))
@@ -625,7 +603,6 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                        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.
                 */
@@ -647,11 +624,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                        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 ||
diff --git a/strtoaddr.c b/strtoaddr.c
new file mode 100644 (file)
index 0000000..2c37061
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * 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);
+}
diff --git a/strtoaddr.h b/strtoaddr.h
new file mode 100644 (file)
index 0000000..8bd22c7
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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);
+
+
index b481e9e6d8d6396325038793157dcd5aafdf9ab6..f11155ad2eb42664887546c78ae56441346ba781 100644 (file)
@@ -525,7 +525,6 @@ mask2plen(uint32_t mask)
        return (prefix_len);
 }
 
-#ifdef INET6
 int
 mask62plen(const u_char *mask)
 {
@@ -552,7 +551,6 @@ mask62plen(const u_char *mask)
        }
        return (cidr_len);
 }
-#endif /* INET6 */
 
 /*
  * Routine to print out information for text-based protocols such as FTP,