1146773Ssam/*
2146773Ssam * Copyright (c) 1988-1997
3146773Ssam *	The Regents of the University of California.  All rights reserved.
4146773Ssam *
5251158Sdelphij * Copyright (c) 1998-2012  Michael Richardson <mcr@tcpdump.org>
6146773Ssam *      The TCPDUMP project
7146773Ssam *
8146773Ssam * Redistribution and use in source and binary forms, with or without
9146773Ssam * modification, are permitted provided that: (1) source code distributions
10146773Ssam * retain the above copyright notice and this paragraph in its entirety, (2)
11146773Ssam * distributions including binary code include the above copyright notice and
12146773Ssam * this paragraph in its entirety in the documentation or other materials
13146773Ssam * provided with the distribution, and (3) all advertising materials mentioning
14146773Ssam * features or use of this software display the following acknowledgement:
15146773Ssam * ``This product includes software developed by the University of California,
16146773Ssam * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
17146773Ssam * the University nor the names of its contributors may be used to endorse
18146773Ssam * or promote products derived from this software without specific prior
19146773Ssam * written permission.
20146773Ssam * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
21146773Ssam * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
22146773Ssam * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23146773Ssam */
24146773Ssam
25146773Ssam#ifndef netdissect_h
26146773Ssam#define netdissect_h
27146773Ssam
28146773Ssam#ifdef HAVE_OS_PROTO_H
29146773Ssam#include "os-proto.h"
30146773Ssam#endif
31146773Ssam#include <sys/types.h>
32146773Ssam
33146773Ssam#ifndef HAVE___ATTRIBUTE__
34146773Ssam#define __attribute__(x)
35146773Ssam#endif
36146773Ssam
37146773Ssam/* snprintf et al */
38146773Ssam
39146773Ssam#include <stdarg.h>
40146773Ssam
41276788Sdelphij#include "ip.h" /* struct ip for nextproto4_cksum() */
42276788Sdelphij
43146773Ssam#if !defined(HAVE_SNPRINTF)
44146773Ssamint snprintf (char *str, size_t sz, const char *format, ...)
45276788Sdelphij#ifdef __ATTRIBUTE___FORMAT_OK
46276788Sdelphij     __attribute__((format (printf, 3, 4)))
47276788Sdelphij#endif /* __ATTRIBUTE___FORMAT_OK */
48276788Sdelphij     ;
49276788Sdelphij#endif /* !defined(HAVE_SNPRINTF) */
50146773Ssam
51146773Ssam#if !defined(HAVE_VSNPRINTF)
52146773Ssamint vsnprintf (char *str, size_t sz, const char *format, va_list ap)
53276788Sdelphij#ifdef __ATTRIBUTE___FORMAT_OK
54276788Sdelphij     __attribute__((format (printf, 3, 0)))
55276788Sdelphij#endif /* __ATTRIBUTE___FORMAT_OK */
56276788Sdelphij     ;
57276788Sdelphij#endif /* !defined(HAVE_SNPRINTF) */
58146773Ssam
59146773Ssam#ifndef HAVE_STRLCAT
60146773Ssamextern size_t strlcat (char *, const char *, size_t);
61146773Ssam#endif
62146773Ssam#ifndef HAVE_STRLCPY
63146773Ssamextern size_t strlcpy (char *, const char *, size_t);
64146773Ssam#endif
65146773Ssam
66146773Ssam#ifndef HAVE_STRDUP
67146773Ssamextern char *strdup (const char *str);
68146773Ssam#endif
69146773Ssam
70146773Ssam#ifndef HAVE_STRSEP
71146773Ssamextern char *strsep(char **, const char *);
72146773Ssam#endif
73146773Ssam
74146773Ssamstruct tok {
75276788Sdelphij	u_int v;		/* value */
76146773Ssam	const char *s;		/* string */
77146773Ssam};
78146773Ssam
79146773Ssam#define TOKBUFSIZE 128
80276788Sdelphijextern const char *tok2strbuf(const struct tok *, const char *, u_int,
81146773Ssam			      char *buf, size_t bufsize);
82146773Ssam
83146773Ssam/* tok2str is deprecated */
84285275Spkelseyextern const char *tok2str(const struct tok *, const char *, u_int);
85285275Spkelseyextern char *bittok2str(const struct tok *, const char *, u_int);
86285275Spkelseyextern char *bittok2str_nosep(const struct tok *, const char *, u_int);
87146773Ssam
88146773Ssam
89146773Ssamtypedef struct netdissect_options netdissect_options;
90146773Ssam
91146773Ssamstruct netdissect_options {
92146773Ssam  int ndo_aflag;		/* translate network and broadcast addresses */
93214478Srpaulo  int ndo_bflag;		/* print 4 byte ASes in ASDOT notation */
94146773Ssam  int ndo_eflag;		/* print ethernet header */
95146773Ssam  int ndo_fflag;		/* don't translate "foreign" IP address */
96190207Srpaulo  int ndo_Kflag;		/* don't check TCP checksums */
97146773Ssam  int ndo_nflag;		/* leave addresses as numbers */
98146773Ssam  int ndo_Nflag;		/* remove domains from printed host names */
99146773Ssam  int ndo_qflag;		/* quick (shorter) output */
100146773Ssam  int ndo_Rflag;		/* print sequence # field in AH/ESP*/
101146773Ssam  int ndo_sflag;		/* use the libsmi to translate OIDs */
102146773Ssam  int ndo_Sflag;		/* print raw TCP sequence numbers */
103146773Ssam  int ndo_tflag;		/* print packet arrival time */
104146773Ssam  int ndo_Uflag;		/* "unbuffered" output of dump files */
105146773Ssam  int ndo_uflag;		/* Print undecoded NFS handles */
106146773Ssam  int ndo_vflag;		/* verbose */
107146773Ssam  int ndo_xflag;		/* print packet in hex */
108146773Ssam  int ndo_Xflag;		/* print packet in hex/ascii */
109146773Ssam  int ndo_Aflag;		/* print packet only in ascii observing TAB,
110146773Ssam				 * LF, CR and SPACE as graphical chars
111146773Ssam				 */
112190207Srpaulo  int ndo_Bflag;		/* buffer size */
113190207Srpaulo  int ndo_Iflag;		/* rfmon (monitor) mode */
114146773Ssam  int ndo_Oflag;                /* run filter code optimizer */
115146773Ssam  int ndo_dlt;                  /* if != -1, ask libpcap for the DLT it names*/
116235530Sdelphij  int ndo_jflag;                /* packet time stamp source */
117146773Ssam  int ndo_pflag;                /* don't go promiscuous */
118285275Spkelsey  int ndo_immediate;            /* use immediate mode */
119146773Ssam
120251158Sdelphij  int ndo_Cflag;                /* rotate dump files after this many bytes */
121146773Ssam  int ndo_Cflag_count;      /* Keep track of which file number we're writing */
122190207Srpaulo  int ndo_Gflag;            /* rotate dump files after this many seconds */
123190207Srpaulo  int ndo_Gflag_count;      /* number of files created with Gflag rotation */
124190207Srpaulo  time_t ndo_Gflag_time;    /* The last time_t the dump file was rotated. */
125146773Ssam  int ndo_Wflag;          /* recycle output files after this number of files */
126162017Ssam  int ndo_WflagChars;
127235530Sdelphij  int ndo_Hflag;		/* dissect 802.11s draft mesh standard */
128276788Sdelphij  int ndo_packet_number;	/* print a packet number in the beginning of line */
129162017Ssam  int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
130276788Sdelphij  int ndo_tstamp_precision;   /* requested time stamp precision */
131146773Ssam  const char *ndo_dltname;
132146773Ssam
133146773Ssam  char *ndo_espsecret;
134146773Ssam  struct sa_list *ndo_sa_list_head;  /* used by print-esp.c */
135146773Ssam  struct sa_list *ndo_sa_default;
136146773Ssam
137214478Srpaulo  char *ndo_sigsecret;     	/* Signature verification secret key */
138146773Ssam
139146773Ssam  struct esp_algorithm *ndo_espsecret_xform;   /* cache of decoded  */
140146773Ssam  char                 *ndo_espsecret_key;
141146773Ssam
142146773Ssam  int   ndo_packettype;	/* as specified by -T */
143146773Ssam
144146773Ssam  char *ndo_program_name;	/*used to generate self-identifying messages */
145146773Ssam
146146773Ssam  int32_t ndo_thiszone;	/* seconds offset from gmt to local time */
147146773Ssam
148146773Ssam  int   ndo_snaplen;
149146773Ssam
150146773Ssam  /*global pointers to beginning and end of current packet (during printing) */
151146773Ssam  const u_char *ndo_packetp;
152146773Ssam  const u_char *ndo_snapend;
153146773Ssam
154146773Ssam  /* bookkeeping for ^T output */
155146773Ssam  int ndo_infodelay;
156146773Ssam
157146773Ssam  /* pointer to void function to output stuff */
158146773Ssam  void (*ndo_default_print)(netdissect_options *,
159146773Ssam  		      register const u_char *bp, register u_int length);
160285275Spkelsey
161285275Spkelsey  /* pointer to function to print ^T output */
162146773Ssam  void (*ndo_info)(netdissect_options *, int verbose);
163146773Ssam
164285275Spkelsey  /* pointer to function to do regular output */
165146773Ssam  int  (*ndo_printf)(netdissect_options *,
166214478Srpaulo		     const char *fmt, ...)
167214478Srpaulo#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
168214478Srpaulo		     __attribute__ ((format (printf, 2, 3)))
169214478Srpaulo#endif
170214478Srpaulo		     ;
171285275Spkelsey  /* pointer to function to output errors */
172146773Ssam  void (*ndo_error)(netdissect_options *,
173214478Srpaulo		    const char *fmt, ...)
174276788Sdelphij#ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
175276788Sdelphij		     __attribute__ ((noreturn))
176276788Sdelphij#endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */
177214478Srpaulo#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
178276788Sdelphij		     __attribute__ ((format (printf, 2, 3)))
179276788Sdelphij#endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
180214478Srpaulo		     ;
181285275Spkelsey  /* pointer to function to output warnings */
182146773Ssam  void (*ndo_warning)(netdissect_options *,
183214478Srpaulo		      const char *fmt, ...)
184214478Srpaulo#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
185214478Srpaulo		     __attribute__ ((format (printf, 2, 3)))
186214478Srpaulo#endif
187214478Srpaulo		     ;
188146773Ssam};
189146773Ssam
190146773Ssam#define PT_VAT		1	/* Visual Audio Tool */
191146773Ssam#define PT_WB		2	/* distributed White Board */
192146773Ssam#define PT_RPC		3	/* Remote Procedure Call */
193146773Ssam#define PT_RTP		4	/* Real-Time Applications protocol */
194146773Ssam#define PT_RTCP		5	/* Real-Time Applications control protocol */
195146773Ssam#define PT_SNMP		6	/* Simple Network Management Protocol */
196146773Ssam#define PT_CNFP		7	/* Cisco NetFlow protocol */
197251158Sdelphij#define PT_TFTP		8	/* trivial file transfer protocol */
198251158Sdelphij#define PT_AODV		9	/* Ad-hoc On-demand Distance Vector Protocol */
199251158Sdelphij#define PT_CARP		10	/* Common Address Redundancy Protocol */
200251158Sdelphij#define PT_RADIUS	11	/* RADIUS authentication Protocol */
201251158Sdelphij#define PT_ZMTP1	12	/* ZeroMQ Message Transport Protocol 1.0 */
202251158Sdelphij#define PT_VXLAN	13	/* Virtual eXtensible Local Area Network */
203276788Sdelphij#define PT_PGM		14	/* [UDP-encapsulated] Pragmatic General Multicast */
204276788Sdelphij#define PT_PGM_ZMTP1	15	/* ZMTP/1.0 inside PGM (native or UDP-encapsulated) */
205276788Sdelphij#define PT_LMP		16	/* Link Management Protocol */
206146773Ssam
207146773Ssam#ifndef min
208146773Ssam#define min(a,b) ((a)>(b)?(b):(a))
209146773Ssam#endif
210146773Ssam#ifndef max
211146773Ssam#define max(a,b) ((b)>(a)?(b):(a))
212146773Ssam#endif
213146773Ssam
214146773Ssam/*
215214478Srpaulo * Maximum snapshot length.  This should be enough to capture the full
216214478Srpaulo * packet on most network interfaces.
217214478Srpaulo *
218276788Sdelphij *
219276788Sdelphij * Somewhat arbitrary, but chosen to be:
220276788Sdelphij *
221276788Sdelphij *    1) big enough for maximum-size Linux loopback packets (65549)
222276788Sdelphij *       and some USB packets captured with USBPcap:
223276788Sdelphij *
224276788Sdelphij *           http://desowin.org/usbpcap/
225276788Sdelphij *
226276788Sdelphij *       (> 131072, < 262144)
227276788Sdelphij *
228276788Sdelphij * and
229276788Sdelphij *
230276788Sdelphij *    2) small enough not to cause attempts to allocate huge amounts of
231276788Sdelphij *       memory; some applications might use the snapshot length in a
232276788Sdelphij *       savefile header to control the size of the buffer they allocate,
233276788Sdelphij *       so a size of, say, 2^31-1 might not work well.
234276788Sdelphij *
235276788Sdelphij * XXX - does it need to be bigger still?
236146773Ssam */
237276788Sdelphij#define MAXIMUM_SNAPLEN	262144
238146773Ssam
239214478Srpaulo/*
240214478Srpaulo * The default snapshot length is the maximum.
241214478Srpaulo */
242214478Srpaulo#define DEFAULT_SNAPLEN	MAXIMUM_SNAPLEN
243146773Ssam
244146773Ssam#define ESRC(ep) ((ep)->ether_shost)
245146773Ssam#define EDST(ep) ((ep)->ether_dhost)
246146773Ssam
247146773Ssam#ifndef NTOHL
248146773Ssam#define NTOHL(x)	(x) = ntohl(x)
249146773Ssam#define NTOHS(x)	(x) = ntohs(x)
250146773Ssam#define HTONL(x)	(x) = htonl(x)
251146773Ssam#define HTONS(x)	(x) = htons(x)
252146773Ssam#endif
253146773Ssam
254146773Ssam/*
255146773Ssam * True if "l" bytes of "var" were captured.
256146773Ssam *
257146773Ssam * The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure
258146773Ssam * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows.
259146773Ssam *
260146773Ssam * The check is for <= rather than < because "l" might be 0.
261285275Spkelsey *
262285275Spkelsey * We cast the pointers to uintptr_t to make sure that the compiler
263285275Spkelsey * doesn't optimize away any of these tests (which it is allowed to
264285275Spkelsey * do, as adding an integer to, or subtracting an integer from, a
265285275Spkelsey * pointer assumes that the pointer is a pointer to an element of an
266285275Spkelsey * array and that the result of the addition or subtraction yields a
267285275Spkelsey * pointer to another member of the array, so that, for example, if
268285275Spkelsey * you subtract a positive integer from a pointer, the result is
269285275Spkelsey * guaranteed to be less than the original pointer value). See
270285275Spkelsey *
271285275Spkelsey *	http://www.kb.cert.org/vuls/id/162289
272146773Ssam */
273285299Spkelsey
274285299Spkelsey#define IS_NOT_NEGATIVE(x) (((x) > 0) || ((x) == 0))
275285299Spkelsey
276285275Spkelsey#define ND_TTEST2(var, l) \
277285299Spkelsey  (IS_NOT_NEGATIVE(l) && \
278285275Spkelsey	((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \
279285275Spkelsey         (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
280146773Ssam
281146773Ssam/* True if "var" was captured */
282146773Ssam#define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
283146773Ssam
284146773Ssam/* Bail if "l" bytes of "var" were not captured */
285146773Ssam#define ND_TCHECK2(var, l) if (!ND_TTEST2(var, l)) goto trunc
286146773Ssam
287146773Ssam/* Bail if "var" was not captured */
288146773Ssam#define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var))
289146773Ssam
290146773Ssam#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
291146773Ssam#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
292146773Ssam
293276788Sdelphijextern void ts_print(netdissect_options *, const struct timeval *);
294276788Sdelphijextern void relts_print(netdissect_options *, int);
295146773Ssam
296276788Sdelphijextern int fn_print(netdissect_options *, const u_char *, const u_char *);
297276788Sdelphijextern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *);
298276788Sdelphijextern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
299146773Ssam
300285275Spkelsey/*
301285275Spkelsey * Flags for txtproto_print().
302285275Spkelsey */
303285275Spkelsey#define RESP_CODE_SECOND_TOKEN	0x00000001	/* response code is second token in response line */
304285275Spkelsey
305285275Spkelseyextern void txtproto_print(netdissect_options *, const u_char *, u_int,
306285275Spkelsey    const char *, const char **, u_int);
307285275Spkelsey
308146773Ssam#if 0
309146773Ssamextern char *read_infile(netdissect_options *, char *);
310146773Ssamextern char *copy_argv(netdissect_options *, char **);
311146773Ssam#endif
312146773Ssam
313276788Sdelphij/*
314276788Sdelphij * Locale-independent macros for testing character properties and
315276788Sdelphij * stripping the 8th bit from characters.  Assumed to be handed
316276788Sdelphij * a value between 0 and 255, i.e. don't hand them a char, as
317276788Sdelphij * those might be in the range -128 to 127.
318276788Sdelphij */
319276788Sdelphij#define ND_ISASCII(c)	(!((c) & 0x80))	/* value is an ASCII code point */
320276788Sdelphij#define ND_ISPRINT(c)	((c) >= 0x20 && (c) <= 0x7E)
321276788Sdelphij#define ND_ISGRAPH(c)	((c) > 0x20 && (c) <= 0x7E)
322276788Sdelphij#define ND_TOASCII(c)	((c) & 0x7F)
323146773Ssam
324276788Sdelphijextern void safeputchar(netdissect_options *, const u_char);
325276788Sdelphijextern void safeputs(netdissect_options *, const u_char *, const u_int);
326276788Sdelphij
327276788Sdelphij#ifdef LBL_ALIGN
328276788Sdelphij/*
329276788Sdelphij * The processor doesn't natively handle unaligned loads,
330276788Sdelphij * and the compiler might "helpfully" optimize memcpy()
331276788Sdelphij * and memcmp(), when handed pointers that would normally
332276788Sdelphij * be properly aligned, into sequences that assume proper
333276788Sdelphij * alignment.
334276788Sdelphij *
335276788Sdelphij * Do copies and compares of possibly-unaligned data by
336276788Sdelphij * calling routines that wrap memcpy() and memcmp(), to
337276788Sdelphij * prevent that optimization.
338276788Sdelphij */
339276788Sdelphijextern void unaligned_memcpy(void *, const void *, size_t);
340276788Sdelphijextern int unaligned_memcmp(const void *, const void *, size_t);
341276788Sdelphij#define UNALIGNED_MEMCPY(p, q, l)	unaligned_memcpy((p), (q), (l))
342276788Sdelphij#define UNALIGNED_MEMCMP(p, q, l)	unaligned_memcmp((p), (q), (l))
343276788Sdelphij#else
344276788Sdelphij/*
345276788Sdelphij * The procesor natively handles unaligned loads, so just use memcpy()
346276788Sdelphij * and memcmp(), to enable those optimizations.
347276788Sdelphij */
348276788Sdelphij#define UNALIGNED_MEMCPY(p, q, l)	memcpy((p), (q), (l))
349276788Sdelphij#define UNALIGNED_MEMCMP(p, q, l)	memcmp((p), (q), (l))
350276788Sdelphij#endif
351276788Sdelphij
352235530Sdelphij#define PLURAL_SUFFIX(n) \
353235530Sdelphij	(((n) != 1) ? "s" : "")
354235530Sdelphij
355146773Ssam#if 0
356146773Ssamextern const char *dnname_string(netdissect_options *, u_short);
357146773Ssamextern const char *dnnum_string(netdissect_options *, u_short);
358146773Ssam#endif
359146773Ssam
360146773Ssam/* The printer routines. */
361146773Ssam
362146773Ssam#include <pcap.h>
363146773Ssam
364285275Spkelseyextern char *q922_string(netdissect_options *ndo, const u_char *, u_int);
365285275Spkelsey
366235530Sdelphijtypedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
367235530Sdelphij				const struct pcap_pkthdr *, const u_char *);
368235530Sdelphijtypedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
369146773Ssam
370235530Sdelphijextern if_ndo_printer lookup_ndo_printer(int);
371235530Sdelphijextern if_printer lookup_printer(int);
372235530Sdelphij
373190207Srpauloextern void eap_print(netdissect_options *,const u_char *, u_int);
374146773Ssamextern int esp_print(netdissect_options *,
375276788Sdelphij		     const u_char *bp, const int length, const u_char *bp2,
376146773Ssam		     int *nhdr, int *padlen);
377146773Ssamextern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
378241235Sdelphijextern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
379276788Sdelphijextern void msnlb_print(netdissect_options *, const u_char *);
380214478Srpauloextern void icmp6_print(netdissect_options *ndo, const u_char *,
381214478Srpaulo                        u_int, const u_char *, int);
382146773Ssamextern void isakmp_print(netdissect_options *,const u_char *,
383146773Ssam			 u_int, const u_char *);
384146773Ssamextern void isakmp_rfc3948_print(netdissect_options *,const u_char *,
385146773Ssam				 u_int, const u_char *);
386146773Ssamextern void ip_print(netdissect_options *,const u_char *, u_int);
387146773Ssamextern void ip_print_inner(netdissect_options *ndo,
388146773Ssam			   const u_char *bp, u_int length, u_int nh,
389146773Ssam			   const u_char *bp2);
390190207Srpauloextern void rrcp_print(netdissect_options *,const u_char *, u_int);
391276788Sdelphijextern void loopback_print(netdissect_options *, const u_char *, const u_int);
392276788Sdelphijextern void carp_print(netdissect_options *, const u_char *, u_int, int);
393146773Ssam
394235530Sdelphijextern void ether_print(netdissect_options *,
395235530Sdelphij                        const u_char *, u_int, u_int,
396235530Sdelphij                        void (*)(netdissect_options *, const u_char *),
397235530Sdelphij                        const u_char *);
398235530Sdelphij
399251158Sdelphijextern u_int ether_if_print(netdissect_options *,
400235530Sdelphij                            const struct pcap_pkthdr *,const u_char *);
401251158Sdelphijextern u_int netanalyzer_if_print(netdissect_options *,
402235530Sdelphij                                  const struct pcap_pkthdr *,const u_char *);
403251158Sdelphijextern u_int netanalyzer_transparent_if_print(netdissect_options *,
404235530Sdelphij                                              const struct pcap_pkthdr *,
405235530Sdelphij                                              const u_char *);
406235530Sdelphij
407235530Sdelphijextern int ethertype_print(netdissect_options *,u_short, const u_char *,
408235530Sdelphij			     u_int, u_int);
409235530Sdelphij
410276788Sdelphijextern int print_unknown_data(netdissect_options *,const u_char *, const char *,int);
411276788Sdelphijextern void ascii_print(netdissect_options *, const u_char *, u_int);
412276788Sdelphijextern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp,
413276788Sdelphij				  u_int, u_int);
414276788Sdelphijextern void hex_print(netdissect_options *,const char *ident, const u_char *cp,u_int);
415276788Sdelphijextern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
416276788Sdelphijextern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
417276788Sdelphij
418276788Sdelphijextern int ah_print(netdissect_options *, register const u_char *);
419276788Sdelphijextern void beep_print(netdissect_options *, const u_char *, u_int);
420276788Sdelphijextern void dtp_print(netdissect_options *, const u_char *, u_int);
421276788Sdelphijextern u_int cip_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
422276788Sdelphijextern int ipcomp_print(netdissect_options *, register const u_char *, int *);
423276788Sdelphijextern u_int ipfc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
424276788Sdelphijextern void udld_print(netdissect_options *, const u_char *, u_int);
425276788Sdelphijextern void hsrp_print(netdissect_options *, const u_char *, u_int);
426276788Sdelphijextern void igrp_print(netdissect_options *, const u_char *, u_int);
427276788Sdelphijextern void msdp_print(netdissect_options *, const u_char *, u_int);
428276788Sdelphijextern u_int null_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
429276788Sdelphijextern void mobile_print(netdissect_options *, const u_char *, u_int);
430276788Sdelphijextern u_int ap1394_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
431276788Sdelphijextern u_int bt_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
432276788Sdelphijextern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
433276788Sdelphijextern u_int lane_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
434276788Sdelphijextern void otv_print(netdissect_options *, const u_char *, u_int);
435276788Sdelphijextern void ahcp_print(netdissect_options *, const u_char *, const u_int);
436276788Sdelphijextern void vxlan_print(netdissect_options *, const u_char *, u_int);
437276788Sdelphijextern u_int arcnet_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
438276788Sdelphijextern u_int arcnet_linux_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
439276788Sdelphijextern void bfd_print(netdissect_options *, const u_char *, u_int, u_int);
440276788Sdelphijextern void gre_print(netdissect_options *, const u_char *, u_int);
441276788Sdelphijextern int vjc_print(netdissect_options *, register const char *, u_short);
442276788Sdelphijextern void ipN_print(netdissect_options *, const u_char *, u_int);
443276788Sdelphijextern u_int raw_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
444276788Sdelphijextern u_int usb_linux_48_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
445276788Sdelphijextern u_int usb_linux_64_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
446276788Sdelphijextern u_int symantec_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
447276788Sdelphijextern u_int chdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
448276788Sdelphijextern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
449276788Sdelphijextern void zmtp1_print(netdissect_options *, const u_char *, u_int);
450276788Sdelphijextern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
451276788Sdelphijextern void ipx_print(netdissect_options *, const u_char *, u_int);
452276788Sdelphijextern void mpls_print(netdissect_options *, const u_char *, u_int);
453276788Sdelphijextern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
454276788Sdelphijextern u_int pppoe_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
455276788Sdelphijextern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
456276788Sdelphijextern u_int pflog_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
457276788Sdelphijextern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
458276788Sdelphijextern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
459276788Sdelphijextern void vqp_print(netdissect_options *, register const u_char *, register u_int);
460276788Sdelphijextern void zephyr_print(netdissect_options *, const u_char *, int);
461276788Sdelphijextern void fddi_print(netdissect_options *, const u_char *, u_int, u_int);
462276788Sdelphijextern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
463276788Sdelphijextern void mpcp_print(netdissect_options *, const u_char *, u_int);
464276788Sdelphijextern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
465276788Sdelphijextern u_int sll_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
466276788Sdelphijextern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
467276788Sdelphijextern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *, u_short *);
468276788Sdelphijextern int snap_print(netdissect_options *, const u_char *, u_int, u_int, u_int);
469276788Sdelphijextern void eigrp_print(netdissect_options *, const u_char *, u_int);
470276788Sdelphijextern void stp_print(netdissect_options *, const u_char *, u_int);
471276788Sdelphijextern void l2tp_print(netdissect_options *, const u_char *, u_int);
472276788Sdelphijextern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
473276788Sdelphijextern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
474276788Sdelphijextern void openflow_print(netdissect_options *, const u_char *, const u_int);
475276788Sdelphijextern void telnet_print(netdissect_options *, const u_char *, u_int);
476276788Sdelphijextern void slow_print(netdissect_options *, const u_char *, u_int);
477276788Sdelphijextern void radius_print(netdissect_options *, const u_char *, u_int);
478276788Sdelphijextern void lmp_print(netdissect_options *, const u_char *, u_int);
479276788Sdelphijextern u_int fr_print(netdissect_options *, register const u_char *, u_int);
480276788Sdelphijextern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
481276788Sdelphijextern u_int fr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
482276788Sdelphijextern u_int mfr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
483276788Sdelphijextern void q933_print(netdissect_options *, const u_char *, u_int);
484276788Sdelphijextern void igmp_print(netdissect_options *, const u_char *, u_int);
485276788Sdelphijextern void rip_print(netdissect_options *, const u_char *, u_int);
486276788Sdelphijextern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int);
487276788Sdelphijextern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
488276788Sdelphijextern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
489276788Sdelphijextern void pptp_print(netdissect_options *, const u_char *);
490276788Sdelphijextern void ldp_print(netdissect_options *, const u_char *, u_int);
491276788Sdelphijextern void wb_print(netdissect_options *, const void *, u_int);
492276788Sdelphijextern int oam_print(netdissect_options *, const u_char *, u_int, u_int);
493276788Sdelphijextern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
494276788Sdelphijextern u_int sunatm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
495276788Sdelphijextern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
496276788Sdelphijextern void vtp_print(netdissect_options *, const u_char *, u_int);
497276788Sdelphijextern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
498276788Sdelphijextern void ntp_print(netdissect_options *, const u_char *, u_int);
499285275Spkelseyextern void cnfp_print(netdissect_options *, const u_char *);
500276788Sdelphijextern void dvmrp_print(netdissect_options *, const u_char *, u_int);
501276788Sdelphijextern void egp_print(netdissect_options *, const u_char *, u_int);
502276788Sdelphijextern u_int enc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
503276788Sdelphijextern u_int sl_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
504276788Sdelphijextern u_int sl_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
505276788Sdelphijextern void tftp_print(netdissect_options *, const u_char *, u_int);
506276788Sdelphijextern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
507276788Sdelphijextern void pimv1_print(netdissect_options *, const u_char *, u_int);
508276788Sdelphijextern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
509276788Sdelphijextern void pim_print(netdissect_options *, const u_char *, u_int, u_int);
510276788Sdelphijextern const u_char * ns_nprint (netdissect_options *, register const u_char *, register const u_char *);
511276788Sdelphijextern void ns_print(netdissect_options *, const u_char *, u_int, int);
512276788Sdelphijextern void bootp_print(netdissect_options *, const u_char *, u_int);
513276788Sdelphijextern void sflow_print(netdissect_options *, const u_char *, u_int);
514276788Sdelphijextern void aodv_print(netdissect_options *, const u_char *, u_int, int);
515276788Sdelphijextern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
516276788Sdelphijextern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
517276788Sdelphijextern void bgp_print(netdissect_options *, const u_char *, int);
518276788Sdelphijextern void olsr_print(netdissect_options *, const u_char *, u_int, int);
519276788Sdelphijextern void forces_print(netdissect_options *, const u_char *, u_int);
520276788Sdelphijextern void lspping_print(netdissect_options *, const u_char *, u_int);
521276788Sdelphijextern void isoclns_print(netdissect_options *, const u_char *, u_int, u_int);
522276788Sdelphijextern void krb_print(netdissect_options *, const u_char *);
523276788Sdelphijextern void cdp_print(netdissect_options *, const u_char *, u_int, u_int);
524276788Sdelphijextern void atalk_print(netdissect_options *, const u_char *, u_int);
525276788Sdelphijextern u_int ltalk_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
526276788Sdelphijextern u_int llap_print(netdissect_options *, const u_char *, u_int);
527276788Sdelphijextern void aarp_print(netdissect_options *, const u_char *, u_int);
528276788Sdelphijextern u_int juniper_atm1_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
529276788Sdelphijextern u_int juniper_atm2_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
530276788Sdelphijextern u_int juniper_mfr_print(netdissect_options *, const struct pcap_pkthdr *, register const u_char *);
531276788Sdelphijextern u_int juniper_mlfr_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
532276788Sdelphijextern u_int juniper_mlppp_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
533276788Sdelphijextern u_int juniper_pppoe_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
534276788Sdelphijextern u_int juniper_pppoe_atm_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
535276788Sdelphijextern u_int juniper_ggsn_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
536276788Sdelphijextern u_int juniper_es_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
537276788Sdelphijextern u_int juniper_monitor_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
538276788Sdelphijextern u_int juniper_services_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
539276788Sdelphijextern u_int juniper_ether_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
540276788Sdelphijextern u_int juniper_ppp_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
541276788Sdelphijextern u_int juniper_frelay_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
542276788Sdelphijextern u_int juniper_chdlc_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
543276788Sdelphijextern void snmp_print(netdissect_options *, const u_char *, u_int);
544276788Sdelphijextern void rx_print(netdissect_options *, register const u_char *, int, int, int, u_char *);
545276788Sdelphijextern void nfsreply_print(netdissect_options *, const u_char *, u_int, const u_char *);
546276788Sdelphijextern void nfsreply_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
547276788Sdelphijextern void nfsreq_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
548276788Sdelphijextern void sip_print(netdissect_options *, const u_char *, u_int);
549276788Sdelphijextern void syslog_print(netdissect_options *, const u_char *, u_int);
550276788Sdelphijextern void lwres_print(netdissect_options *, const u_char *, u_int);
551276788Sdelphijextern void cfm_print(netdissect_options *, const u_char *, u_int);
552276788Sdelphijextern void nbt_tcp_print(netdissect_options *, const u_char *, int);
553276788Sdelphijextern void nbt_udp137_print(netdissect_options *, const u_char *, int);
554276788Sdelphijextern void nbt_udp138_print(netdissect_options *, const u_char *, int);
555276788Sdelphijextern void smb_tcp_print(netdissect_options *, const u_char *, int);
556276788Sdelphijextern void netbeui_print(netdissect_options *, u_short, const u_char *, int);
557276788Sdelphijextern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
558276788Sdelphijextern void print_data(netdissect_options *, const unsigned char *, int);
559276788Sdelphijextern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
560276788Sdelphijextern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
561276788Sdelphijextern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
562276788Sdelphijextern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
563276788Sdelphijextern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
564276788Sdelphijextern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
565276788Sdelphijextern u_int ppp_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
566276788Sdelphijextern u_int ppp_hdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
567276788Sdelphijextern u_int ppp_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
568276788Sdelphijextern void lldp_print(netdissect_options *, const u_char *, u_int);
569276788Sdelphijextern void rsvp_print(netdissect_options *, const u_char *, u_int);
570276788Sdelphijextern void timed_print(netdissect_options *, const u_char *);
571276788Sdelphijextern void m3ua_print(netdissect_options *, const u_char *, const u_int);
572276788Sdelphijextern void aoe_print(netdissect_options *, const u_char *, const u_int);
573285275Spkelseyextern void ftp_print(netdissect_options *, const u_char *, u_int);
574285275Spkelseyextern void http_print(netdissect_options *, const u_char *, u_int);
575285275Spkelseyextern void rtsp_print(netdissect_options *, const u_char *, u_int);
576285275Spkelseyextern void smtp_print(netdissect_options *, const u_char *, u_int);
577285275Spkelseyextern void geneve_print(netdissect_options *, const u_char *, u_int);
578276788Sdelphij
579281938Sbrooksextern void pfsync_ip_print(netdissect_options *, const u_char *, u_int);
580281938Sbrooks
581146773Ssam/* stuff that has not yet been rototiled */
582276788Sdelphij
583146773Ssam#if 0
584162017Ssamextern void ascii_print(netdissect_options *,u_int);
585146773Ssamextern void default_print(netdissect_options *,const u_char *, u_int);
586146773Ssamextern char *smb_errstr(netdissect_options *,int, int);
587276788Sdelphijextern const char *nt_errstr(netdissect_options *, uint32_t);
588214478Srpaulo#endif
589146773Ssam
590214478Srpauloextern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
591235530Sdelphijextern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
592276788Sdelphijextern u_int nflog_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
593235530Sdelphijextern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
594276788Sdelphijextern u_int pktap_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
595276788Sdelphijextern u_int ieee802_11_radio_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
596276788Sdelphijextern u_int ieee802_11_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
597276788Sdelphijextern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
598276788Sdelphijextern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
599235530Sdelphij
600285275Spkelseyextern void ip6_print(netdissect_options *,const u_char *, u_int);
601146773Ssam#ifdef INET6
602276788Sdelphijextern int frag6_print(netdissect_options *, const u_char *, const u_char *);
603276788Sdelphijextern int rt6_print(netdissect_options *, const u_char *, const u_char *);
604276788Sdelphijextern int hbhopt_print(netdissect_options *, const u_char *);
605276788Sdelphijextern int dstopt_print(netdissect_options *, const u_char *);
606276788Sdelphijextern void ripng_print(netdissect_options *, const u_char *, unsigned int);
607276788Sdelphijextern int mobility_print(netdissect_options *, const u_char *, const u_char *);
608276788Sdelphijextern void dhcp6_print(netdissect_options *, const u_char *, u_int);
609276788Sdelphijextern void ospf6_print(netdissect_options *, const u_char *, u_int);
610276788Sdelphijextern void babel_print(netdissect_options *, const u_char *, u_int);
611146773Ssam#endif /*INET6*/
612146773Ssam
613235530Sdelphij#if 0
614235530Sdelphijstruct cksum_vec {
615276788Sdelphij	const uint8_t	*ptr;
616235530Sdelphij	int		len;
617235530Sdelphij};
618276788Sdelphijextern uint16_t in_cksum(const struct cksum_vec *, int);
619276788Sdelphijextern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
620146773Ssam#endif
621276788Sdelphijextern int nextproto4_cksum(netdissect_options *ndo, const struct ip *, const uint8_t *, u_int, u_int, u_int);
622276788Sdelphijextern int decode_prefix4(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
623276788Sdelphij#ifdef INET6
624276788Sdelphijextern int decode_prefix6(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
625276788Sdelphij#endif
626146773Ssam
627214478Srpauloextern void esp_print_decodesecret(netdissect_options *ndo);
628214478Srpauloextern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
629214478Srpaulo					     int initiator,
630214478Srpaulo					     u_char spii[8], u_char spir[8],
631214478Srpaulo					     u_char *buf, u_char *end);
632214478Srpaulo
633214478Srpaulo
634276788Sdelphijextern void geonet_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *geo_pck, u_int len);
635276788Sdelphijextern void calm_fast_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *calm_pck, u_int len);
636276788Sdelphij
637146773Ssam#endif  /* netdissect_h */
638