Skip to content

Commit 11f73ad

Browse files
committed
Don't require IPv6 library support in order to support IPv6 addresses.
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.
1 parent 2a85a1b commit 11f73ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+547
-2046
lines changed

Makefile.in

+13-22
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ CSRC = setsignal.c tcpdump.c util.c
7474

7575
LIBNETDISSECT_SRC=\
7676
addrtoname.c \
77+
addrtostr.c \
7778
af.c \
7879
ascii_strcasecmp.c \
7980
checksum.c \
@@ -100,6 +101,7 @@ LIBNETDISSECT_SRC=\
100101
print-ascii.c \
101102
print-atalk.c \
102103
print-atm.c \
104+
print-babel.c \
103105
print-beep.c \
104106
print-bfd.c \
105107
print-bgp.c \
@@ -114,6 +116,7 @@ LIBNETDISSECT_SRC=\
114116
print-cnfp.c \
115117
print-dccp.c \
116118
print-decnet.c \
119+
print-dhcp6.c \
117120
print-domain.c \
118121
print-dtp.c \
119122
print-dvmrp.c \
@@ -126,17 +129,20 @@ LIBNETDISSECT_SRC=\
126129
print-fddi.c \
127130
print-forces.c \
128131
print-fr.c \
132+
print-frag6.c \
129133
print-ftp.c \
130134
print-geneve.c \
131135
print-geonet.c \
132136
print-gre.c \
133137
print-hsrp.c \
134138
print-http.c \
135139
print-icmp.c \
140+
print-icmp6.c \
136141
print-igmp.c \
137142
print-igrp.c \
138143
print-ip.c \
139144
print-ip6.c \
145+
print-ip6opts.c \
140146
print-ipcomp.c \
141147
print-ipfc.c \
142148
print-ipnet.c \
@@ -158,6 +164,7 @@ LIBNETDISSECT_SRC=\
158164
print-m3ua.c \
159165
print-medsa.c \
160166
print-mobile.c \
167+
print-mobility.c \
161168
print-mpcp.c \
162169
print-mpls.c \
163170
print-mptcp.c \
@@ -171,6 +178,7 @@ LIBNETDISSECT_SRC=\
171178
print-openflow-1.0.c \
172179
print-openflow.c \
173180
print-ospf.c \
181+
print-ospf6.c \
174182
print-otv.c \
175183
print-pgm.c \
176184
print-pim.c \
@@ -182,9 +190,11 @@ LIBNETDISSECT_SRC=\
182190
print-radius.c \
183191
print-raw.c \
184192
print-rip.c \
193+
print-ripng.c \
185194
print-rpki-rtr.c \
186195
print-rrcp.c \
187196
print-rsvp.c \
197+
print-rt6.c \
188198
print-rtsp.c \
189199
print-rx.c \
190200
print-sctp.c \
@@ -218,6 +228,7 @@ LIBNETDISSECT_SRC=\
218228
print-zephyr.c \
219229
print-zeromq.c \
220230
signature.c \
231+
strtoaddr.c \
221232
util-print.c
222233

223234
LOCALSRC = @LOCALSRC@
@@ -235,6 +246,7 @@ SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
235246
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
236247
HDR = \
237248
addrtoname.h \
249+
addrtostr.h \
238250
af.h \
239251
ah.h \
240252
appletalk.h \
@@ -275,6 +287,7 @@ HDR = \
275287
signature.h \
276288
slcompress.h \
277289
smb.h \
290+
strtoaddr.h \
278291
tcp.h \
279292
netdissect-stdinc.h \
280293
timeval-operations.h \
@@ -319,14 +332,9 @@ EXTRA_DIST = \
319332
lbl/os-sunos4.h \
320333
lbl/os-ultrix4.h \
321334
makemib \
322-
missing/addrinfo.h \
323335
missing/dlnames.c \
324336
missing/datalinks.c \
325-
missing/getnameinfo.c \
326337
missing/getopt_long.c \
327-
missing/inet_aton.c \
328-
missing/inet_ntop.c \
329-
missing/inet_pton.c \
330338
missing/snprintf.c \
331339
missing/strdup.c \
332340
missing/strlcat.c \
@@ -335,16 +343,7 @@ EXTRA_DIST = \
335343
mkdep \
336344
packetdat.awk \
337345
pcap_dump_ftell.c \
338-
print-babel.c \
339-
print-dhcp6.c \
340-
print-frag6.c \
341-
print-icmp6.c \
342-
print-ip6opts.c \
343-
print-mobility.c \
344-
print-ospf6.c \
345346
print-pflog.c \
346-
print-ripng.c \
347-
print-rt6.c \
348347
print-smb.c \
349348
send-ack.awk \
350349
smbutil.c \
@@ -372,16 +371,8 @@ datalinks.o: $(srcdir)/missing/datalinks.c
372371
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
373372
dlnames.o: $(srcdir)/missing/dlnames.c
374373
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
375-
getnameinfo.o: $(srcdir)/missing/getnameinfo.c
376-
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
377374
getopt_long.o: $(srcdir)/missing/getopt_long.c
378375
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c
379-
inet_pton.o: $(srcdir)/missing/inet_pton.c
380-
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
381-
inet_ntop.o: $(srcdir)/missing/inet_ntop.c
382-
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
383-
inet_aton.o: $(srcdir)/missing/inet_aton.c
384-
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
385376
snprintf.o: $(srcdir)/missing/snprintf.c
386377
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
387378
strdup.o: $(srcdir)/missing/strdup.c

aclocal.m4

-125
Original file line numberDiff line numberDiff line change
@@ -1149,131 +1149,6 @@ dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
11491149
dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
11501150
dnl SUCH DAMAGE.
11511151

1152-
dnl
1153-
dnl Checks to see if AF_INET6 is defined
1154-
AC_DEFUN(AC_CHECK_AF_INET6, [
1155-
AC_MSG_CHECKING(for AF_INET6)
1156-
AC_CACHE_VAL($1,
1157-
AC_TRY_COMPILE([
1158-
# include <sys/types.h>
1159-
# include <sys/socket.h>],
1160-
[int a = AF_INET6],
1161-
$1=yes,
1162-
$1=no))
1163-
AC_MSG_RESULT($$1)
1164-
if test $$1 = yes ; then
1165-
AC_DEFINE(HAVE_AF_INET6)
1166-
fi
1167-
])
1168-
1169-
dnl
1170-
dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
1171-
dnl borrowed from LBL libpcap
1172-
AC_DEFUN(AC_CHECK_SA_LEN, [
1173-
AC_MSG_CHECKING(if sockaddr struct has sa_len member)
1174-
AC_CACHE_VAL($1,
1175-
AC_TRY_COMPILE([
1176-
# include <sys/types.h>
1177-
# include <sys/socket.h>],
1178-
[u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
1179-
$1=yes,
1180-
$1=no))
1181-
AC_MSG_RESULT($$1)
1182-
if test $$1 = yes ; then
1183-
AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
1184-
fi
1185-
])
1186-
1187-
dnl
1188-
dnl Checks for addrinfo structure
1189-
AC_DEFUN(AC_STRUCT_ADDRINFO, [
1190-
AC_MSG_CHECKING(for addrinfo)
1191-
AC_CACHE_VAL($1,
1192-
AC_TRY_COMPILE([
1193-
# include <netdb.h>],
1194-
[struct addrinfo a],
1195-
$1=yes,
1196-
$1=no))
1197-
AC_MSG_RESULT($$1)
1198-
if test $$1 = yes; then
1199-
AC_DEFINE(HAVE_ADDRINFO, 1,
1200-
[define if you have the addrinfo function])
1201-
else
1202-
AC_DEFINE(NEED_ADDRINFO_H, 1,
1203-
[define if you need to include missing/addrinfo.h])
1204-
fi
1205-
])
1206-
1207-
dnl
1208-
dnl Checks for NI_MAXSERV
1209-
AC_DEFUN(AC_NI_MAXSERV, [
1210-
AC_MSG_CHECKING(for NI_MAXSERV)
1211-
AC_CACHE_VAL($1,
1212-
AC_EGREP_CPP(yes, [#include <netdb.h>
1213-
#ifdef NI_MAXSERV
1214-
yes
1215-
#endif],
1216-
$1=yes,
1217-
$1=no))
1218-
AC_MSG_RESULT($$1)
1219-
if test $$1 != yes; then
1220-
AC_DEFINE(NEED_ADDRINFO_H)
1221-
fi
1222-
])
1223-
1224-
dnl
1225-
dnl Checks for NI_NAMEREQD
1226-
AC_DEFUN(AC_NI_NAMEREQD, [
1227-
AC_MSG_CHECKING(for NI_NAMEREQD)
1228-
AC_CACHE_VAL($1,
1229-
AC_EGREP_CPP(yes, [#include <netdb.h>
1230-
#ifdef NI_NOFQDN
1231-
yes
1232-
#endif],
1233-
$1=yes,
1234-
$1=no))
1235-
AC_MSG_RESULT($$1)
1236-
if test $$1 != yes; then
1237-
AC_DEFINE(NEED_ADDRINFO_H)
1238-
fi
1239-
])
1240-
1241-
dnl
1242-
dnl Checks for sockaddr_storage structure
1243-
AC_DEFUN(AC_STRUCT_SA_STORAGE, [
1244-
AC_MSG_CHECKING(for sockaddr_storage)
1245-
AC_CACHE_VAL($1,
1246-
AC_TRY_COMPILE([
1247-
# include <sys/types.h>
1248-
# include <sys/socket.h>],
1249-
[struct sockaddr_storage s],
1250-
$1=yes,
1251-
$1=no))
1252-
AC_MSG_RESULT($$1)
1253-
if test $$1 = yes; then
1254-
AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
1255-
[define if you have struct sockaddr_storage])
1256-
fi
1257-
])
1258-
1259-
dnl
1260-
dnl check for h_errno
1261-
AC_DEFUN(AC_VAR_H_ERRNO, [
1262-
AC_MSG_CHECKING(for h_errno)
1263-
AC_CACHE_VAL(ac_cv_var_h_errno,
1264-
AC_TRY_COMPILE([
1265-
# include <sys/types.h>
1266-
# include <netdb.h>],
1267-
[int foo = h_errno;],
1268-
ac_cv_var_h_errno=yes,
1269-
ac_cv_var_h_errno=no))
1270-
AC_MSG_RESULT($ac_cv_var_h_errno)
1271-
if test "$ac_cv_var_h_errno" = "yes"; then
1272-
AC_DEFINE(HAVE_H_ERRNO, 1,
1273-
[define if you have the h_errno variable])
1274-
fi
1275-
])
1276-
12771152
dnl
12781153
dnl Test for __attribute__
12791154
dnl

addrtoname.c

+4-9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern int ether_ntohost(char *, const struct ether_addr *);
5959

6060
#include "netdissect.h"
6161
#include "addrtoname.h"
62+
#include "addrtostr.h"
6263
#include "llc.h"
6364
#include "setsignal.h"
6465
#include "extract.h"
@@ -89,7 +90,7 @@ static struct hnamemem eprototable[HASHNAMESIZE];
8990
static struct hnamemem dnaddrtable[HASHNAMESIZE];
9091
static struct hnamemem ipxsaptable[HASHNAMESIZE];
9192

92-
#if defined(INET6) && defined(_WIN32)
93+
#ifdef _WIN32
9394
/*
9495
* fake gethostbyaddr for Win2k/XP
9596
* gethostbyaddr() returns incorrect value when AF_INET6 is passed
@@ -127,17 +128,15 @@ win32_gethostbyaddr(const char *addr, int len, int type)
127128
}
128129
}
129130
#define gethostbyaddr win32_gethostbyaddr
130-
#endif /* INET6 & _WIN32 */
131+
#endif /* _WIN32 */
131132

132-
#ifdef INET6
133133
struct h6namemem {
134134
struct in6_addr addr;
135135
char *name;
136136
struct h6namemem *nxt;
137137
};
138138

139139
static struct h6namemem h6nametable[HASHNAMESIZE];
140-
#endif /* INET6 */
141140

142141
struct enamemem {
143142
u_short e_addr0;
@@ -265,7 +264,6 @@ getname(netdissect_options *ndo, const u_char *ap)
265264
return (p->name);
266265
}
267266

268-
#ifdef INET6
269267
/*
270268
* Return a name for the IP6 address pointed to by ap. This address
271269
* is assumed to be in network byte order.
@@ -315,13 +313,12 @@ getname6(netdissect_options *ndo, const u_char *ap)
315313
return (p->name);
316314
}
317315
}
318-
cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
316+
cp = addrtostr6(ap, ntop_buf, sizeof(ntop_buf));
319317
p->name = strdup(cp);
320318
if (p->name == NULL)
321319
(*ndo->ndo_error)(ndo, "getname6: strdup(cp)");
322320
return (p->name);
323321
}
324-
#endif /* INET6 */
325322

326323
static const char hex[] = "0123456789abcdef";
327324

@@ -1225,7 +1222,6 @@ newhnamemem(netdissect_options *ndo)
12251222
return (p);
12261223
}
12271224

1228-
#ifdef INET6
12291225
/* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
12301226
struct h6namemem *
12311227
newh6namemem(netdissect_options *ndo)
@@ -1244,7 +1240,6 @@ newh6namemem(netdissect_options *ndo)
12441240
p = ptr++;
12451241
return (p);
12461242
}
1247-
#endif /* INET6 */
12481243

12491244
/* Represent TCI part of the 802.1Q 4-octet tag as text. */
12501245
const char *

addrtoname.h

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2020
*/
2121

22+
/*
23+
* Definitions to let us compile most of the IPv6 code even on systems
24+
* without IPv6 support.
25+
*/
26+
#ifndef INET6_ADDRSTRLEN
27+
#define INET6_ADDRSTRLEN 46
28+
#endif
29+
2230
/* Name to address translation routines. */
2331

2432
enum {
@@ -41,19 +49,13 @@ extern const char *dnaddr_string(netdissect_options *, u_short);
4149
extern const char *protoid_string(netdissect_options *, const u_char *);
4250
extern const char *ipxsap_string(netdissect_options *, u_short);
4351
extern const char *getname(netdissect_options *, const u_char *);
44-
#ifdef INET6
4552
extern const char *getname6(netdissect_options *, const u_char *);
46-
#endif
4753
extern const char *intoa(uint32_t);
4854

4955
extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
5056
extern struct hnamemem *newhnamemem(netdissect_options *);
51-
#ifdef INET6
5257
extern struct h6namemem *newh6namemem(netdissect_options *);
53-
#endif
5458
extern const char * ieee8021q_tci_string(const uint16_t);
5559

5660
#define ipaddr_string(ndo, p) getname(ndo, (const u_char *)(p))
57-
#ifdef INET6
5861
#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
59-
#endif

0 commit comments

Comments
 (0)