Skip to content

Commit 6324ee5

Browse files
committed
Add autoconf option to enable a stripped down build.
The --enable-minimal option to configure reduces the list of dissectors to a smaller set, needed to bring up an embedded system. This produces a smaller tcpdump binary, something that is very useful on small embedded systems, such as SOHO routers.
1 parent 405beed commit 6324ee5

18 files changed

+250
-201
lines changed

Makefile.in

Lines changed: 3 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -89,157 +89,16 @@ LIBNETDISSECT_SRC=\
8989
oui.c \
9090
parsenfsfh.c \
9191
print.c \
92-
print-802_11.c \
93-
print-802_15_4.c \
94-
print-ah.c \
95-
print-ahcp.c \
96-
print-aodv.c \
97-
print-aoe.c \
98-
print-ap1394.c \
99-
print-arcnet.c \
100-
print-arp.c \
101-
print-ascii.c \
102-
print-atalk.c \
103-
print-atm.c \
104-
print-babel.c \
105-
print-beep.c \
106-
print-bfd.c \
107-
print-bgp.c \
108-
print-bootp.c \
109-
print-bt.c \
110-
print-calm-fast.c \
111-
print-carp.c \
112-
print-cdp.c \
113-
print-cfm.c \
114-
print-chdlc.c \
115-
print-cip.c \
116-
print-cnfp.c \
117-
print-dccp.c \
118-
print-decnet.c \
119-
print-dhcp6.c \
120-
print-domain.c \
121-
print-dtp.c \
122-
print-dvmrp.c \
123-
print-eap.c \
124-
print-egp.c \
125-
print-eigrp.c \
126-
print-enc.c \
127-
print-esp.c \
128-
print-ether.c \
129-
print-fddi.c \
130-
print-forces.c \
131-
print-fr.c \
132-
print-frag6.c \
133-
print-ftp.c \
134-
print-geneve.c \
135-
print-geonet.c \
136-
print-gre.c \
137-
print-hsrp.c \
138-
print-http.c \
139-
print-icmp.c \
140-
print-icmp6.c \
141-
print-igmp.c \
142-
print-igrp.c \
143-
print-ip.c \
144-
print-ip6.c \
145-
print-ip6opts.c \
146-
print-ipcomp.c \
147-
print-ipfc.c \
148-
print-ipnet.c \
149-
print-ipx.c \
150-
print-isakmp.c \
151-
print-isoclns.c \
152-
print-juniper.c \
153-
print-krb.c \
154-
print-l2tp.c \
155-
print-lane.c \
156-
print-ldp.c \
157-
print-lisp.c \
158-
print-llc.c \
159-
print-lldp.c \
160-
print-lmp.c \
161-
print-loopback.c \
162-
print-lspping.c \
163-
print-lwapp.c \
164-
print-lwres.c \
165-
print-m3ua.c \
166-
print-medsa.c \
167-
print-mobile.c \
168-
print-mobility.c \
169-
print-mpcp.c \
170-
print-mpls.c \
171-
print-mptcp.c \
172-
print-msdp.c \
173-
print-msnlb.c \
174-
print-nflog.c \
175-
print-nfs.c \
176-
print-nsh.c \
177-
print-ntp.c \
178-
print-null.c \
179-
print-olsr.c \
180-
print-openflow-1.0.c \
181-
print-openflow.c \
182-
print-ospf.c \
183-
print-ospf6.c \
184-
print-otv.c \
185-
print-pgm.c \
186-
print-pim.c \
187-
print-pktap.c \
188-
print-ppi.c \
189-
print-ppp.c \
190-
print-pppoe.c \
191-
print-pptp.c \
192-
print-radius.c \
193-
print-raw.c \
194-
print-resp.c \
195-
print-rip.c \
196-
print-ripng.c \
197-
print-rpki-rtr.c \
198-
print-rrcp.c \
199-
print-rsvp.c \
200-
print-rt6.c \
201-
print-rtsp.c \
202-
print-rx.c \
203-
print-sctp.c \
204-
print-sflow.c \
205-
print-sip.c \
206-
print-sl.c \
207-
print-sll.c \
208-
print-slow.c \
209-
print-smtp.c \
210-
print-snmp.c \
211-
print-stp.c \
212-
print-sunatm.c \
213-
print-sunrpc.c \
214-
print-symantec.c \
215-
print-syslog.c \
216-
print-tcp.c \
217-
print-telnet.c \
218-
print-tftp.c \
219-
print-timed.c \
220-
print-tipc.c \
221-
print-token.c \
222-
print-udld.c \
223-
print-udp.c \
224-
print-usb.c \
225-
print-vjc.c \
226-
print-vqp.c \
227-
print-vrrp.c \
228-
print-vtp.c \
229-
print-vxlan.c \
230-
print-vxlan-gpe.c \
231-
print-wb.c \
232-
print-zephyr.c \
233-
print-zeromq.c \
23492
signature.c \
23593
strtoaddr.c \
23694
util-print.c
23795

96+
DISSECTORS = @DISSECTORS@
23897
LOCALSRC = @LOCALSRC@
23998
GENSRC = version.c
24099
LIBOBJS = @LIBOBJS@
241100

242-
LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) ${LOCALSRC:.c=.o} ${LIBOBJS}
101+
LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) ${DISSECTORS:.c=.o} ${LOCALSRC:.c=.o} ${LIBOBJS}
243102
LIBNETDISSECT=libnetdissect.a
244103

245104

@@ -347,6 +206,7 @@ EXTRA_DIST = \
347206
mkdep \
348207
packetdat.awk \
349208
pcap_dump_ftell.c \
209+
@ALL_DISSECTORS@ \
350210
print-pflog.c \
351211
print-smb.c \
352212
send-ack.awk \

addrtoname.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,10 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep,
564564
if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
565565
return (etheraddr_string(ndo, ep));
566566

567+
#ifndef MINIMAL
567568
if (type == LINKADDR_FRELAY)
568569
return (q922_string(ndo, ep, len));
570+
#endif
569571

570572
tp = lookup_bytestring(ndo, ep, len);
571573
if (tp->e_name)
@@ -1200,6 +1202,7 @@ init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
12001202
init_ipxsaparray(ndo);
12011203
}
12021204

1205+
#ifndef MINIMAL
12031206
const char *
12041207
dnaddr_string(netdissect_options *ndo, u_short dnaddr)
12051208
{
@@ -1219,6 +1222,7 @@ dnaddr_string(netdissect_options *ndo, u_short dnaddr)
12191222

12201223
return(tp->name);
12211224
}
1225+
#endif
12221226

12231227
/* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
12241228
struct hnamemem *

config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@
244244
/* if unaligned access fails */
245245
#undef LBL_ALIGN
246246

247+
/* Minimal build */
248+
#undef MINIMAL
249+
247250
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
248251
#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
249252

configure

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,9 @@ ac_subst_vars='LTLIBOBJS
623623
INSTALL_DATA
624624
INSTALL_SCRIPT
625625
INSTALL_PROGRAM
626+
ALL_DISSECTORS
627+
DISSECTORS
628+
MINIMAL
626629
MAN_MISC_INFO
627630
MAN_FILE_FORMATS
628631
LOCALSRC
@@ -704,6 +707,7 @@ enable_smb
704707
with_user
705708
with_chroot
706709
with_sandbox_capsicum
710+
enable_minimal
707711
with_system_libpcap
708712
with_crypto
709713
with_cap_ng
@@ -1331,6 +1335,8 @@ Optional Features:
13311335
--disable-universal don't build universal on OS X
13321336
--enable-smb enable possibly-buggy SMB printer default=yes
13331337
--disable-smb disable possibly-buggy SMB printer
1338+
--enable-minimal Support printing only common protocols, for a
1339+
smaller binary
13341340
13351341
Optional Packages:
13361342
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -4601,6 +4607,41 @@ else
46014607
$as_echo "no" >&6; }
46024608
fi
46034609
4610+
# Check whether --enable-minimal was given.
4611+
if test "${enable_minimal+set}" = set; then :
4612+
enableval=$enable_minimal;
4613+
cat >>confdefs.h <<_ACEOF
4614+
#define MINIMAL $enableval
4615+
_ACEOF
4616+
4617+
4618+
fi
4619+
4620+
for i in `ls print-*.c | grep -v print-smb.c | grep -v print-pflog.c`
4621+
do
4622+
ALL_DISSECTORS="$i $ALL_DISSECTORS"
4623+
done
4624+
if test "x$enable_minimal" = xyes; then :
4625+
4626+
DISSECTORS="\
4627+
print-802_11.c print-aodv.c print-arp.c print-ascii.c \
4628+
print-bgp.c print-bootp.c print-cdp.c print-domain.c print-eap.c \
4629+
print-ether.c print-gre.c print-icmp.c print-igmp.c print-ip.c \
4630+
print-ip6.c print-ip6opts.c print-rt6.c print-frag6.c print-icmp6.c \
4631+
print-l2tp.c print-lldp.c print-llc.c print-nfs.c print-ntp.c \
4632+
print-null.c print-olsr.c print-ospf.c print-ppp.c print-pppoe.c \
4633+
print-pptp.c print-radius.c print-raw.c print-rsvp.c print-sctp.c \
4634+
print-sip.c print-sll.c print-snmp.c print-stp.c print-sunrpc.c \
4635+
print-syslog.c print-tcp.c print-telnet.c print-tftp.c print-udp.c \
4636+
print-ipnet.c print-forces.c"
4637+
4638+
else
4639+
4640+
DISSECTORS=$ALL_DISSECTORS
4641+
4642+
4643+
fi
4644+
46044645
#
46054646
# We must check this before checking whether to check the OS's IPv6,
46064647
# support because, on some platforms (such as SunOS 5.x), the test
@@ -8165,6 +8206,9 @@ fi
81658206
81668207
81678208
8209+
8210+
8211+
81688212
# Find a good install program. We prefer a C program (faster),
81698213
# so one script is as good as another. But avoid the broken or
81708214
# incompatible versions:

configure.in

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,34 @@ else
234234
AC_MSG_RESULT(no)
235235
fi
236236

237+
AC_ARG_ENABLE(minimal,
238+
AS_HELP_STRING([--enable-minimal], [Support printing only common
239+
protocols, for a smaller binary]),
240+
[AC_DEFINE_UNQUOTED([MINIMAL], [$enableval], [Minimal build])]
241+
)
242+
for i in `ls print-*.c | grep -v print-smb.c | grep -v print-pflog.c`
243+
do
244+
ALL_DISSECTORS="$i $ALL_DISSECTORS"
245+
done
246+
AS_IF([test "x$enable_minimal" = xyes],
247+
[
248+
DISSECTORS="\
249+
print-802_11.c print-aodv.c print-arp.c print-ascii.c \
250+
print-bgp.c print-bootp.c print-cdp.c print-domain.c print-eap.c \
251+
print-ether.c print-gre.c print-icmp.c print-igmp.c print-ip.c \
252+
print-ip6.c print-ip6opts.c print-rt6.c print-frag6.c print-icmp6.c \
253+
print-l2tp.c print-lldp.c print-llc.c print-nfs.c print-ntp.c \
254+
print-null.c print-olsr.c print-ospf.c print-ppp.c print-pppoe.c \
255+
print-pptp.c print-radius.c print-raw.c print-rsvp.c print-sctp.c \
256+
print-sip.c print-sll.c print-snmp.c print-stp.c print-sunrpc.c \
257+
print-syslog.c print-tcp.c print-telnet.c print-tftp.c print-udp.c \
258+
print-ipnet.c print-forces.c"
259+
],
260+
[
261+
DISSECTORS=$ALL_DISSECTORS
262+
]
263+
)
264+
237265
#
238266
# We must check this before checking whether to check the OS's IPv6,
239267
# support because, on some platforms (such as SunOS 5.x), the test
@@ -966,6 +994,9 @@ AC_SUBST(V_PCAPDEP)
966994
AC_SUBST(LOCALSRC)
967995
AC_SUBST(MAN_FILE_FORMATS)
968996
AC_SUBST(MAN_MISC_INFO)
997+
AC_SUBST(MINIMAL)
998+
AC_SUBST(DISSECTORS)
999+
AC_SUBST(ALL_DISSECTORS)
9691000

9701001
AC_PROG_INSTALL
9711002

print-ether.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ ethertype_print(netdissect_options *ndo,
332332
arp_print(ndo, p, length, caplen);
333333
return (1);
334334

335+
#ifndef MINIMAL
335336
case ETHERTYPE_DN:
336337
decnet_print(ndo, p, length, caplen);
337338
return (1);
@@ -354,6 +355,7 @@ ethertype_print(netdissect_options *ndo,
354355
case ETHERTYPE_ISO:
355356
isoclns_print(ndo, p + 1, length - 1, length - 1);
356357
return(1);
358+
#endif
357359

358360
case ETHERTYPE_PPPOED:
359361
case ETHERTYPE_PPPOES:
@@ -366,9 +368,11 @@ ethertype_print(netdissect_options *ndo,
366368
eap_print(ndo, p, length);
367369
return (1);
368370

371+
#ifndef MINIMAL
369372
case ETHERTYPE_RRCP:
370373
rrcp_print(ndo, p - 14 , length + 14);
371374
return (1);
375+
#endif
372376

373377
case ETHERTYPE_PPP:
374378
if (length) {
@@ -377,6 +381,7 @@ ethertype_print(netdissect_options *ndo,
377381
}
378382
return (1);
379383

384+
#ifndef MINIMAL
380385
case ETHERTYPE_MPCP:
381386
mpcp_print(ndo, p, length);
382387
return (1);
@@ -389,11 +394,13 @@ ethertype_print(netdissect_options *ndo,
389394
case ETHERTYPE_CFM_OLD:
390395
cfm_print(ndo, p, length);
391396
return (1);
397+
#endif
392398

393399
case ETHERTYPE_LLDP:
394400
lldp_print(ndo, p, length);
395401
return (1);
396402

403+
#ifndef MINIMAL
397404
case ETHERTYPE_LOOPBACK:
398405
loopback_print(ndo, p, length);
399406
return (1);
@@ -427,6 +434,7 @@ ethertype_print(netdissect_options *ndo,
427434
case ETHERTYPE_MEDSA:
428435
medsa_print(ndo, p, length, caplen);
429436
return (1);
437+
#endif
430438

431439
case ETHERTYPE_LAT:
432440
case ETHERTYPE_SCA:

0 commit comments

Comments
 (0)