188a191fsam/*
288a191fsam * Copyright (c) 1988-1997
388a191fsam *	The Regents of the University of California.  All rights reserved.
488a191fsam *
5a765887delphij * Copyright (c) 1998-2012  Michael Richardson <mcr@tcpdump.org>
688a191fsam *      The TCPDUMP project
788a191fsam *
888a191fsam * Redistribution and use in source and binary forms, with or without
988a191fsam * modification, are permitted provided that: (1) source code distributions
1088a191fsam * retain the above copyright notice and this paragraph in its entirety, (2)
1188a191fsam * distributions including binary code include the above copyright notice and
1288a191fsam * this paragraph in its entirety in the documentation or other materials
1388a191fsam * provided with the distribution, and (3) all advertising materials mentioning
1488a191fsam * features or use of this software display the following acknowledgement:
1588a191fsam * ``This product includes software developed by the University of California,
1688a191fsam * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1788a191fsam * the University nor the names of its contributors may be used to endorse
1888a191fsam * or promote products derived from this software without specific prior
1988a191fsam * written permission.
2088a191fsam * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
2188a191fsam * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
2288a191fsam * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2388a191fsam */
2488a191fsam
2588a191fsam#ifndef netdissect_h
2688a191fsam#define netdissect_h
2788a191fsam
2888a191fsam#ifdef HAVE_OS_PROTO_H
2988a191fsam#include "os-proto.h"
3088a191fsam#endif
3188a191fsam#include <sys/types.h>
3288a191fsam
3388a191fsam#ifndef HAVE___ATTRIBUTE__
3488a191fsam#define __attribute__(x)
3588a191fsam#endif
3688a191fsam
37af736e6glebius/*
38af736e6glebius * Data types corresponding to multi-byte integral values within data
39af736e6glebius * structures.  These are defined as arrays of octets, so that they're
40af736e6glebius * not aligned on their "natural" boundaries, and so that you *must*
41af736e6glebius * use the EXTRACT_ macros to extract them (which you should be doing
42af736e6glebius * *anyway*, so as not to assume a particular byte order or alignment
43af736e6glebius * in your code).
44af736e6glebius */
45af736e6glebiustypedef unsigned char nd_uint16_t[2];
46af736e6glebiustypedef unsigned char nd_uint24_t[3];
47af736e6glebiustypedef unsigned char nd_uint32_t[4];
48af736e6glebiustypedef unsigned char nd_uint40_t[5];
49af736e6glebiustypedef unsigned char nd_uint48_t[6];
50af736e6glebiustypedef unsigned char nd_uint56_t[7];
51af736e6glebiustypedef unsigned char nd_uint64_t[8];
52af736e6glebius
53af736e6glebius/*
54af736e6glebius * Use this for IPv4 addresses.  It's defined as an array of octets, so
55af736e6glebius * that it's not aligned on its "natural" boundary, and it's defined as
56af736e6glebius * a structure in the hopes that this makes it harder to naively use
57af736e6glebius * EXTRACT_32BITS() to extract the value - in many cases you just want
58af736e6glebius * to use UNALIGNED_MEMCPY() to copy its value, so that it remains in
59af736e6glebius * network byte order.
60af736e6glebius */
61af736e6glebiustypedef struct {
62af736e6glebius	unsigned char bytes[4];
63af736e6glebius} nd_ipv4;
64af736e6glebius
65af736e6glebius/*
66af736e6glebius * Data types corresponding to single-byte integral values, for
67af736e6glebius * completeness.
68af736e6glebius */
69af736e6glebiustypedef unsigned char nd_uint8_t;
70af736e6glebiustypedef signed char nd_int8_t;
71af736e6glebius
7288a191fsam/* snprintf et al */
7388a191fsam
7488a191fsam#include <stdarg.h>
75af736e6glebius#include <pcap.h>
7688a191fsam
7708263d1delphij#include "ip.h" /* struct ip for nextproto4_cksum() */
78af736e6glebius#include "ip6.h" /* struct ip6 for nextproto6_cksum() */
79af736e6glebius
80af736e6glebiusextern int32_t thiszone;	/* seconds offset from gmt to local time */
81af736e6glebius/* invalid string to print '(invalid)' for malformed or corrupted packets */
82af736e6glebiusextern const char istr[];
8308263d1delphij
8488a191fsam#if !defined(HAVE_SNPRINTF)
854eec411gordonint snprintf (char *str, size_t sz, FORMAT_STRING(const char *format), ...)
864eec411gordon     PRINTFLIKE(3, 4);
8708263d1delphij#endif /* !defined(HAVE_SNPRINTF) */
8888a191fsam
8988a191fsam#if !defined(HAVE_VSNPRINTF)
904eec411gordonint vsnprintf (char *str, size_t sz, FORMAT_STRING(const char *format),
914eec411gordon     va_list ap) PRINTFLIKE(3, 0);
92af736e6glebius#endif /* !defined(HAVE_VSNPRINTF) */
9388a191fsam
9488a191fsam#ifndef HAVE_STRLCAT
9588a191fsamextern size_t strlcat (char *, const char *, size_t);
9688a191fsam#endif
9788a191fsam#ifndef HAVE_STRLCPY
9888a191fsamextern size_t strlcpy (char *, const char *, size_t);
9988a191fsam#endif
10088a191fsam
10188a191fsam#ifndef HAVE_STRDUP
10288a191fsamextern char *strdup (const char *str);
10388a191fsam#endif
10488a191fsam
10588a191fsam#ifndef HAVE_STRSEP
10688a191fsamextern char *strsep(char **, const char *);
10788a191fsam#endif
10888a191fsam
10988a191fsamstruct tok {
11008263d1delphij	u_int v;		/* value */
11188a191fsam	const char *s;		/* string */
11288a191fsam};
11388a191fsam
11408263d1delphijextern const char *tok2strbuf(const struct tok *, const char *, u_int,
11588a191fsam			      char *buf, size_t bufsize);
11688a191fsam
11788a191fsam/* tok2str is deprecated */
118c2704d8pkelseyextern const char *tok2str(const struct tok *, const char *, u_int);
119c2704d8pkelseyextern char *bittok2str(const struct tok *, const char *, u_int);
120c2704d8pkelseyextern char *bittok2str_nosep(const struct tok *, const char *, u_int);
12188a191fsam
122af736e6glebius/* Initialize netdissect. */
123af736e6glebiusextern int nd_init(char *, size_t);
124af736e6glebius/* Clean up netdissect. */
125af736e6glebiusextern void nd_cleanup(void);
126af736e6glebius
127af736e6glebius/* Do we have libsmi support? */
128af736e6glebiusextern int nd_have_smi_support(void);
129af736e6glebius/* Load an SMI module. */
130af736e6glebiusextern int nd_load_smi_module(const char *, char *, size_t);
131af736e6glebius/* Flag indicating whether an SMI module has been loaded. */
132af736e6glebiusextern int nd_smi_module_loaded;
133af736e6glebius/* Version number of the SMI library, or NULL if we don't have libsmi support. */
134af736e6glebiusextern const char *nd_smi_version_string(void);
13588a191fsam
13688a191fsamtypedef struct netdissect_options netdissect_options;
13788a191fsam
138af736e6glebius#define IF_PRINTER_ARGS (netdissect_options *, const struct pcap_pkthdr *, const u_char *)
139af736e6glebius
140af736e6glebiustypedef u_int (*if_printer) IF_PRINTER_ARGS;
141af736e6glebius
14288a191fsamstruct netdissect_options {
1435f4de8erpaulo  int ndo_bflag;		/* print 4 byte ASes in ASDOT notation */
14488a191fsam  int ndo_eflag;		/* print ethernet header */
14588a191fsam  int ndo_fflag;		/* don't translate "foreign" IP address */
14610d55b9rpaulo  int ndo_Kflag;		/* don't check TCP checksums */
14788a191fsam  int ndo_nflag;		/* leave addresses as numbers */
14888a191fsam  int ndo_Nflag;		/* remove domains from printed host names */
14988a191fsam  int ndo_qflag;		/* quick (shorter) output */
15088a191fsam  int ndo_Sflag;		/* print raw TCP sequence numbers */
15188a191fsam  int ndo_tflag;		/* print packet arrival time */
15288a191fsam  int ndo_uflag;		/* Print undecoded NFS handles */
153af736e6glebius  int ndo_vflag;		/* verbosity level */
15488a191fsam  int ndo_xflag;		/* print packet in hex */
15588a191fsam  int ndo_Xflag;		/* print packet in hex/ascii */
15688a191fsam  int ndo_Aflag;		/* print packet only in ascii observing TAB,
15788a191fsam				 * LF, CR and SPACE as graphical chars
15888a191fsam				 */
159d36dcecdelphij  int ndo_Hflag;		/* dissect 802.11s draft mesh standard */
16008263d1delphij  int ndo_packet_number;	/* print a packet number in the beginning of line */
161498672dsam  int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
162af736e6glebius  int ndo_tstamp_precision;	/* requested time stamp precision */
163af736e6glebius  const char *program_name;	/* Name of the program using the library */
16488a191fsam
16588a191fsam  char *ndo_espsecret;
16688a191fsam  struct sa_list *ndo_sa_list_head;  /* used by print-esp.c */
16788a191fsam  struct sa_list *ndo_sa_default;
16888a191fsam
169af736e6glebius  char *ndo_sigsecret;		/* Signature verification secret key */
17088a191fsam
17188a191fsam  int   ndo_packettype;	/* as specified by -T */
17288a191fsam
17388a191fsam  int   ndo_snaplen;
17488a191fsam
17588a191fsam  /*global pointers to beginning and end of current packet (during printing) */
17688a191fsam  const u_char *ndo_packetp;
17788a191fsam  const u_char *ndo_snapend;
17888a191fsam
179af736e6glebius  /* pointer to the if_printer function */
180af736e6glebius  if_printer ndo_if_printer;
18188a191fsam
18288a191fsam  /* pointer to void function to output stuff */
18388a191fsam  void (*ndo_default_print)(netdissect_options *,
184af736e6glebius			    register const u_char *bp, register u_int length);
18588a191fsam
186c2704d8pkelsey  /* pointer to function to do regular output */
18788a191fsam  int  (*ndo_printf)(netdissect_options *,
1885f4de8erpaulo		     const char *fmt, ...)
1895f4de8erpaulo#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
1905f4de8erpaulo		     __attribute__ ((format (printf, 2, 3)))
1915f4de8erpaulo#endif
1925f4de8erpaulo		     ;
193c2704d8pkelsey  /* pointer to function to output errors */
19488a191fsam  void (*ndo_error)(netdissect_options *,
1955f4de8erpaulo		    const char *fmt, ...)
19608263d1delphij#ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
19708263d1delphij		     __attribute__ ((noreturn))
19808263d1delphij#endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */
1995f4de8erpaulo#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
20008263d1delphij		     __attribute__ ((format (printf, 2, 3)))
20108263d1delphij#endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
2025f4de8erpaulo		     ;
203c2704d8pkelsey  /* pointer to function to output warnings */
20488a191fsam  void (*ndo_warning)(netdissect_options *,
2055f4de8erpaulo		      const char *fmt, ...)
2065f4de8erpaulo#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
2075f4de8erpaulo		     __attribute__ ((format (printf, 2, 3)))
2085f4de8erpaulo#endif
2095f4de8erpaulo		     ;
21088a191fsam};
21188a191fsam
21288a191fsam#define PT_VAT		1	/* Visual Audio Tool */
21388a191fsam#define PT_WB		2	/* distributed White Board */
21488a191fsam#define PT_RPC		3	/* Remote Procedure Call */
21588a191fsam#define PT_RTP		4	/* Real-Time Applications protocol */
21688a191fsam#define PT_RTCP		5	/* Real-Time Applications control protocol */
21788a191fsam#define PT_SNMP		6	/* Simple Network Management Protocol */
21888a191fsam#define PT_CNFP		7	/* Cisco NetFlow protocol */
219a765887delphij#define PT_TFTP		8	/* trivial file transfer protocol */
220a765887delphij#define PT_AODV		9	/* Ad-hoc On-demand Distance Vector Protocol */
221a765887delphij#define PT_CARP		10	/* Common Address Redundancy Protocol */
222a765887delphij#define PT_RADIUS	11	/* RADIUS authentication Protocol */
223a765887delphij#define PT_ZMTP1	12	/* ZeroMQ Message Transport Protocol 1.0 */
224a765887delphij#define PT_VXLAN	13	/* Virtual eXtensible Local Area Network */
22508263d1delphij#define PT_PGM		14	/* [UDP-encapsulated] Pragmatic General Multicast */
22608263d1delphij#define PT_PGM_ZMTP1	15	/* ZMTP/1.0 inside PGM (native or UDP-encapsulated) */
22708263d1delphij#define PT_LMP		16	/* Link Management Protocol */
228af736e6glebius#define PT_RESP		17	/* RESP */
22988a191fsam
23088a191fsam#ifndef min
23188a191fsam#define min(a,b) ((a)>(b)?(b):(a))
23288a191fsam#endif
23388a191fsam#ifndef max
23488a191fsam#define max(a,b) ((b)>(a)?(b):(a))
23588a191fsam#endif
23688a191fsam
237af736e6glebius/* For source or destination ports tests (UDP, TCP, ...) */
238af736e6glebius#define IS_SRC_OR_DST_PORT(p) (sport == (p) || dport == (p))
239af736e6glebius
24088a191fsam/*
2415f4de8erpaulo * Maximum snapshot length.  This should be enough to capture the full
2425f4de8erpaulo * packet on most network interfaces.
2435f4de8erpaulo *
24408263d1delphij *
24508263d1delphij * Somewhat arbitrary, but chosen to be:
24608263d1delphij *
24708263d1delphij *    1) big enough for maximum-size Linux loopback packets (65549)
24808263d1delphij *       and some USB packets captured with USBPcap:
24908263d1delphij *
25008263d1delphij *           http://desowin.org/usbpcap/
25108263d1delphij *
25208263d1delphij *       (> 131072, < 262144)
25308263d1delphij *
25408263d1delphij * and
25508263d1delphij *
25608263d1delphij *    2) small enough not to cause attempts to allocate huge amounts of
25708263d1delphij *       memory; some applications might use the snapshot length in a
25808263d1delphij *       savefile header to control the size of the buffer they allocate,
25908263d1delphij *       so a size of, say, 2^31-1 might not work well.
26008263d1delphij *
26108263d1delphij * XXX - does it need to be bigger still?
26288a191fsam */
26308263d1delphij#define MAXIMUM_SNAPLEN	262144
26488a191fsam
2655f4de8erpaulo/*
2665f4de8erpaulo * The default snapshot length is the maximum.
2675f4de8erpaulo */
2685f4de8erpaulo#define DEFAULT_SNAPLEN	MAXIMUM_SNAPLEN
26988a191fsam
27088a191fsam#define ESRC(ep) ((ep)->ether_shost)
27188a191fsam#define EDST(ep) ((ep)->ether_dhost)
27288a191fsam
27388a191fsam#ifndef NTOHL
27488a191fsam#define NTOHL(x)	(x) = ntohl(x)
27588a191fsam#define NTOHS(x)	(x) = ntohs(x)
27688a191fsam#define HTONL(x)	(x) = htonl(x)
27788a191fsam#define HTONS(x)	(x) = htons(x)
27888a191fsam#endif
27988a191fsam
28088a191fsam/*
28188a191fsam * True if "l" bytes of "var" were captured.
28288a191fsam *
28388a191fsam * The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure
28488a191fsam * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows.
28588a191fsam *
28688a191fsam * The check is for <= rather than < because "l" might be 0.
287c2704d8pkelsey *
288c2704d8pkelsey * We cast the pointers to uintptr_t to make sure that the compiler
289c2704d8pkelsey * doesn't optimize away any of these tests (which it is allowed to
290c2704d8pkelsey * do, as adding an integer to, or subtracting an integer from, a
291c2704d8pkelsey * pointer assumes that the pointer is a pointer to an element of an
292c2704d8pkelsey * array and that the result of the addition or subtraction yields a
293c2704d8pkelsey * pointer to another member of the array, so that, for example, if
294c2704d8pkelsey * you subtract a positive integer from a pointer, the result is
295c2704d8pkelsey * guaranteed to be less than the original pointer value). See
296c2704d8pkelsey *
297c2704d8pkelsey *	http://www.kb.cert.org/vuls/id/162289
29888a191fsam */
299b23b1a1pkelsey
300af736e6glebius/*
301af736e6glebius * Test in two parts to avoid these warnings:
302af736e6glebius * comparison of unsigned expression >= 0 is always true [-Wtype-limits],
303af736e6glebius * comparison is always true due to limited range of data type [-Wtype-limits].
304af736e6glebius */
305b23b1a1pkelsey#define IS_NOT_NEGATIVE(x) (((x) > 0) || ((x) == 0))
306b23b1a1pkelsey
307c2704d8pkelsey#define ND_TTEST2(var, l) \
308b23b1a1pkelsey  (IS_NOT_NEGATIVE(l) && \
309c2704d8pkelsey	((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \
310c2704d8pkelsey         (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
31188a191fsam
31288a191fsam/* True if "var" was captured */
31388a191fsam#define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
31488a191fsam
31588a191fsam/* Bail if "l" bytes of "var" were not captured */
31688a191fsam#define ND_TCHECK2(var, l) if (!ND_TTEST2(var, l)) goto trunc
31788a191fsam
31888a191fsam/* Bail if "var" was not captured */
31988a191fsam#define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var))
32088a191fsam
32188a191fsam#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
32288a191fsam#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
32388a191fsam
32408263d1delphijextern void ts_print(netdissect_options *, const struct timeval *);
325af736e6glebiusextern void signed_relts_print(netdissect_options *, int32_t);
326af736e6glebiusextern void unsigned_relts_print(netdissect_options *, uint32_t);
32788a191fsam
328af736e6glebiusextern void fn_print_char(netdissect_options *, u_char);
32908263d1delphijextern int fn_print(netdissect_options *, const u_char *, const u_char *);
330af736e6glebiusextern u_int fn_printztn(netdissect_options *ndo, const u_char *, u_int, const u_char *);
33108263d1delphijextern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *);
33208263d1delphijextern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
333c2704d8pkelsey
334c2704d8pkelsey/*
335c2704d8pkelsey * Flags for txtproto_print().
336c2704d8pkelsey */
337c2704d8pkelsey#define RESP_CODE_SECOND_TOKEN	0x00000001	/* response code is second token in response line */
338c2704d8pkelsey
339c2704d8pkelseyextern void txtproto_print(netdissect_options *, const u_char *, u_int,
340c2704d8pkelsey    const char *, const char **, u_int);
34188a191fsam
34208263d1delphij/*
34308263d1delphij * Locale-independent macros for testing character properties and
34408263d1delphij * stripping the 8th bit from characters.  Assumed to be handed
34508263d1delphij * a value between 0 and 255, i.e. don't hand them a char, as
34608263d1delphij * those might be in the range -128 to 127.
34708263d1delphij */
34808263d1delphij#define ND_ISASCII(c)	(!((c) & 0x80))	/* value is an ASCII code point */
34908263d1delphij#define ND_ISPRINT(c)	((c) >= 0x20 && (c) <= 0x7E)
35008263d1delphij#define ND_ISGRAPH(c)	((c) > 0x20 && (c) <= 0x7E)
35108263d1delphij#define ND_TOASCII(c)	((c) & 0x7F)
35208263d1delphij
35308263d1delphijextern void safeputchar(netdissect_options *, const u_char);
35408263d1delphijextern void safeputs(netdissect_options *, const u_char *, const u_int);
35508263d1delphij
35608263d1delphij#ifdef LBL_ALIGN
35708263d1delphij/*
35808263d1delphij * The processor doesn't natively handle unaligned loads,
35908263d1delphij * and the compiler might "helpfully" optimize memcpy()
36008263d1delphij * and memcmp(), when handed pointers that would normally
36108263d1delphij * be properly aligned, into sequences that assume proper
36208263d1delphij * alignment.
36308263d1delphij *
36408263d1delphij * Do copies and compares of possibly-unaligned data by
36508263d1delphij * calling routines that wrap memcpy() and memcmp(), to
36608263d1delphij * prevent that optimization.
36708263d1delphij */
36808263d1delphijextern void unaligned_memcpy(void *, const void *, size_t);
36908263d1delphijextern int unaligned_memcmp(const void *, const void *, size_t);
37008263d1delphij#define UNALIGNED_MEMCPY(p, q, l)	unaligned_memcpy((p), (q), (l))
37108263d1delphij#define UNALIGNED_MEMCMP(p, q, l)	unaligned_memcmp((p), (q), (l))
37208263d1delphij#else
37308263d1delphij/*
37408263d1delphij * The procesor natively handles unaligned loads, so just use memcpy()
37508263d1delphij * and memcmp(), to enable those optimizations.
37608263d1delphij */
37708263d1delphij#define UNALIGNED_MEMCPY(p, q, l)	memcpy((p), (q), (l))
37808263d1delphij#define UNALIGNED_MEMCMP(p, q, l)	memcmp((p), (q), (l))
37908263d1delphij#endif
38088a191fsam
381d36dcecdelphij#define PLURAL_SUFFIX(n) \
382d36dcecdelphij	(((n) != 1) ? "s" : "")
383d36dcecdelphij
384af736e6glebiusextern const char *tok2strary_internal(const char **, int, const char *, int);
385af736e6glebius#define	tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
386d36dcecdelphij
387d36dcecdelphijextern if_printer lookup_printer(int);
38888a191fsam
389af736e6glebius/* The DLT printer routines */
390af736e6glebius
391af736e6glebiusextern u_int ap1394_if_print IF_PRINTER_ARGS;
392af736e6glebiusextern u_int arcnet_if_print IF_PRINTER_ARGS;
393af736e6glebiusextern u_int arcnet_linux_if_print IF_PRINTER_ARGS;
394af736e6glebiusextern u_int atm_if_print IF_PRINTER_ARGS;
395af736e6glebiusextern u_int bt_if_print IF_PRINTER_ARGS;
396af736e6glebiusextern u_int chdlc_if_print IF_PRINTER_ARGS;
397af736e6glebiusextern u_int cip_if_print IF_PRINTER_ARGS;
398af736e6glebiusextern u_int enc_if_print IF_PRINTER_ARGS;
399af736e6glebiusextern u_int ether_if_print IF_PRINTER_ARGS;
400af736e6glebiusextern u_int fddi_if_print IF_PRINTER_ARGS;
401af736e6glebiusextern u_int fr_if_print IF_PRINTER_ARGS;
402af736e6glebiusextern u_int ieee802_11_if_print IF_PRINTER_ARGS;
403af736e6glebiusextern u_int ieee802_11_radio_avs_if_print IF_PRINTER_ARGS;
404af736e6glebiusextern u_int ieee802_11_radio_if_print IF_PRINTER_ARGS;
405af736e6glebiusextern u_int ieee802_15_4_if_print IF_PRINTER_ARGS;
406af736e6glebiusextern u_int ipfc_if_print IF_PRINTER_ARGS;
407af736e6glebiusextern u_int ipnet_if_print IF_PRINTER_ARGS;
408af736e6glebiusextern u_int juniper_atm1_print IF_PRINTER_ARGS;
409af736e6glebiusextern u_int juniper_atm2_print IF_PRINTER_ARGS;
410af736e6glebiusextern u_int juniper_chdlc_print IF_PRINTER_ARGS;
411af736e6glebiusextern u_int juniper_es_print IF_PRINTER_ARGS;
412af736e6glebiusextern u_int juniper_ether_print IF_PRINTER_ARGS;
413af736e6glebiusextern u_int juniper_frelay_print IF_PRINTER_ARGS;
414af736e6glebiusextern u_int juniper_ggsn_print IF_PRINTER_ARGS;
415af736e6glebiusextern u_int juniper_mfr_print IF_PRINTER_ARGS;
416af736e6glebiusextern u_int juniper_mlfr_print IF_PRINTER_ARGS;
417af736e6glebiusextern u_int juniper_mlppp_print IF_PRINTER_ARGS;
418af736e6glebiusextern u_int juniper_monitor_print IF_PRINTER_ARGS;
419af736e6glebiusextern u_int juniper_ppp_print IF_PRINTER_ARGS;
420af736e6glebiusextern u_int juniper_pppoe_atm_print IF_PRINTER_ARGS;
421af736e6glebiusextern u_int juniper_pppoe_print IF_PRINTER_ARGS;
422af736e6glebiusextern u_int juniper_services_print IF_PRINTER_ARGS;
423af736e6glebiusextern u_int lane_if_print IF_PRINTER_ARGS;
424af736e6glebiusextern u_int ltalk_if_print IF_PRINTER_ARGS;
425af736e6glebiusextern u_int mfr_if_print IF_PRINTER_ARGS;
426af736e6glebiusextern u_int netanalyzer_if_print IF_PRINTER_ARGS;
427af736e6glebiusextern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS;
428af736e6glebiusextern u_int nflog_if_print IF_PRINTER_ARGS;
429af736e6glebiusextern u_int null_if_print IF_PRINTER_ARGS;
430af736e6glebiusextern u_int pflog_if_print IF_PRINTER_ARGS;
431af736e6glebiusextern u_int pktap_if_print IF_PRINTER_ARGS;
432af736e6glebiusextern u_int ppi_if_print IF_PRINTER_ARGS;
433af736e6glebiusextern u_int ppp_bsdos_if_print IF_PRINTER_ARGS;
434af736e6glebiusextern u_int ppp_hdlc_if_print IF_PRINTER_ARGS;
435af736e6glebiusextern u_int ppp_if_print IF_PRINTER_ARGS;
436af736e6glebiusextern u_int pppoe_if_print IF_PRINTER_ARGS;
437af736e6glebiusextern u_int prism_if_print IF_PRINTER_ARGS;
438af736e6glebiusextern u_int raw_if_print IF_PRINTER_ARGS;
439af736e6glebiusextern u_int sl_bsdos_if_print IF_PRINTER_ARGS;
440af736e6glebiusextern u_int sl_if_print IF_PRINTER_ARGS;
441af736e6glebiusextern u_int sll_if_print IF_PRINTER_ARGS;
442af736e6glebiusextern u_int sunatm_if_print IF_PRINTER_ARGS;
443af736e6glebiusextern u_int symantec_if_print IF_PRINTER_ARGS;
444af736e6glebiusextern u_int token_if_print IF_PRINTER_ARGS;
445af736e6glebiusextern u_int usb_linux_48_byte_print IF_PRINTER_ARGS;
446af736e6glebiusextern u_int usb_linux_64_byte_print IF_PRINTER_ARGS;
44788a191fsam
448af736e6glebius/*
449af736e6glebius * Structure passed to some printers to allow them to print
450af736e6glebius * link-layer address information if ndo_eflag isn't set
451af736e6glebius * (because they are for protocols that don't have their
452af736e6glebius * own addresses, so that we'd want to report link-layer
453af736e6glebius * address information).
454af736e6glebius *
455af736e6glebius * This contains a pointer to an address and a pointer to a routine
456af736e6glebius * to which we pass that pointer in order to get a string.
457af736e6glebius */
458af736e6glebiusstruct lladdr_info {
459af736e6glebius	const char *(*addr_string)(netdissect_options *, const u_char *);
460af736e6glebius	const u_char *addr;
461af736e6glebius};
462d36dcecdelphij
463af736e6glebius/* The printer routines. */
46408263d1delphij
465af736e6glebiusextern void aarp_print(netdissect_options *, const u_char *, u_int);
46608263d1delphijextern int ah_print(netdissect_options *, register const u_char *);
46708263d1delphijextern void ahcp_print(netdissect_options *, const u_char *, const u_int);
468af736e6glebiusextern void aodv_print(netdissect_options *, const u_char *, u_int, int);
469af736e6glebiusextern void aoe_print(netdissect_options *, const u_char *, const u_int);
470af736e6glebiusextern void arp_print(netdissect_options *, const u_char *, u_int, u_int);
471af736e6glebiusextern void ascii_print(netdissect_options *, const u_char *, u_int);
472af736e6glebiusextern void atalk_print(netdissect_options *, const u_char *, u_int);
473af736e6glebiusextern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
474af736e6glebiusextern void babel_print(netdissect_options *, const u_char *, u_int);
475af736e6glebiusextern void beep_print(netdissect_options *, const u_char *, u_int);
47608263d1delphijextern void bfd_print(netdissect_options *, const u_char *, u_int, u_int);
477af736e6glebiusextern void bgp_print(netdissect_options *, const u_char *, int);
478af736e6glebiusextern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
479af736e6glebiusextern void bootp_print(netdissect_options *, const u_char *, u_int);
480af736e6glebiusextern void calm_fast_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *);
481af736e6glebiusextern void carp_print(netdissect_options *, const u_char *, u_int, int);
482af736e6glebiusextern void cdp_print(netdissect_options *, const u_char *, u_int, u_int);
483af736e6glebiusextern void cfm_print(netdissect_options *, const u_char *, u_int);
48408263d1delphijextern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
485af736e6glebiusextern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
486c2704d8pkelseyextern void cnfp_print(netdissect_options *, const u_char *);
487af736e6glebiusextern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
488af736e6glebiusextern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
489af736e6glebiusextern void dhcp6_print(netdissect_options *, const u_char *, u_int);
490af736e6glebiusextern int dstopt_print(netdissect_options *, const u_char *);
491af736e6glebiusextern void dtp_print(netdissect_options *, const u_char *, u_int);
49208263d1delphijextern void dvmrp_print(netdissect_options *, const u_char *, u_int);
493af736e6glebiusextern void eap_print(netdissect_options *, const u_char *, u_int);
49408263d1delphijextern void egp_print(netdissect_options *, const u_char *, u_int);
495af736e6glebiusextern void eigrp_print(netdissect_options *, const u_char *, u_int);
496af736e6glebiusextern int esp_print(netdissect_options *, const u_char *, const int, const u_char *, int *, int *);
497af736e6glebiusextern u_int ether_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), const u_char *);
498af736e6glebiusextern int ethertype_print(netdissect_options *, u_short, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
499af736e6glebiusextern u_int fddi_print(netdissect_options *, const u_char *, u_int, u_int);
50008263d1delphijextern void forces_print(netdissect_options *, const u_char *, u_int);
501af736e6glebiusextern u_int fr_print(netdissect_options *, register const u_char *, u_int);
502af736e6glebiusextern int frag6_print(netdissect_options *, const u_char *, const u_char *);
503af736e6glebiusextern void ftp_print(netdissect_options *, const u_char *, u_int);
504af736e6glebiusextern void geneve_print(netdissect_options *, const u_char *, u_int);
505af736e6glebiusextern void geonet_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *);
506af736e6glebiusextern void gre_print(netdissect_options *, const u_char *, u_int);
507af736e6glebiusextern int hbhopt_print(netdissect_options *, const u_char *);
508af736e6glebiusextern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
509af736e6glebiusextern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
510af736e6glebiusextern void hex_print(netdissect_options *, const char *ident, const u_char *cp, u_int);
511af736e6glebiusextern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp, u_int, u_int);
512af736e6glebiusextern void hncp_print(netdissect_options *, const u_char *, u_int);
513af736e6glebiusextern void hsrp_print(netdissect_options *, const u_char *, u_int);
514af736e6glebiusextern void http_print(netdissect_options *, const u_char *, u_int);
515af736e6glebiusextern void icmp6_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
516af736e6glebiusextern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
517072d451philipextern u_int ieee802_11_radio_print(netdissect_options *, const u_char *, u_int, u_int);
518af736e6glebiusextern void igmp_print(netdissect_options *, const u_char *, u_int);
519af736e6glebiusextern void igrp_print(netdissect_options *, const u_char *, u_int);
520af736e6glebiusextern void ip6_print(netdissect_options *, const u_char *, u_int);
521af736e6glebiusextern void ipN_print(netdissect_options *, const u_char *, u_int);
522af736e6glebiusextern void ip_print(netdissect_options *, const u_char *, u_int);
523af736e6glebiusextern void ip_print_inner(netdissect_options *, const u_char *, u_int, u_int nh, const u_char *);
524af736e6glebiusextern void ipcomp_print(netdissect_options *, register const u_char *);
525af736e6glebiusextern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
526af736e6glebiusextern void ipx_print(netdissect_options *, const u_char *, u_int);
527af736e6glebiusextern void isakmp_print(netdissect_options *, const u_char *, u_int, const u_char *);
528af736e6glebiusextern void isakmp_rfc3948_print(netdissect_options *, const u_char *, u_int, const u_char *);
5294eec411gordonextern void isoclns_print(netdissect_options *, const u_char *, u_int);
53008263d1delphijextern void krb_print(netdissect_options *, const u_char *);
531af736e6glebiusextern void l2tp_print(netdissect_options *, const u_char *, u_int);
532af736e6glebiusextern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
533af736e6glebiusextern void ldp_print(netdissect_options *, const u_char *, u_int);
534af736e6glebiusextern void lisp_print(netdissect_options *, const u_char *, u_int);
53508263d1delphijextern u_int llap_print(netdissect_options *, const u_char *, u_int);
536af736e6glebiusextern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
537af736e6glebiusextern void lldp_print(netdissect_options *, const u_char *, u_int);
538af736e6glebiusextern void lmp_print(netdissect_options *, const u_char *, u_int);
539af736e6glebiusextern void loopback_print(netdissect_options *, const u_char *, const u_int);
540af736e6glebiusextern void lspping_print(netdissect_options *, const u_char *, u_int);
541af736e6glebiusextern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int);
542af736e6glebiusextern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
54308263d1delphijextern void lwres_print(netdissect_options *, const u_char *, u_int);
544af736e6glebiusextern void m3ua_print(netdissect_options *, const u_char *, const u_int);
545af736e6glebiusextern void medsa_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
546af736e6glebiusextern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
547af736e6glebiusextern void mobile_print(netdissect_options *, const u_char *, u_int);
548af736e6glebiusextern int mobility_print(netdissect_options *, const u_char *, const u_char *);
549af736e6glebiusextern void mpcp_print(netdissect_options *, const u_char *, u_int);
550af736e6glebiusextern void mpls_print(netdissect_options *, const u_char *, u_int);
551af736e6glebiusextern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
552af736e6glebiusextern void msdp_print(netdissect_options *, const u_char *, u_int);
553af736e6glebiusextern void msnlb_print(netdissect_options *, const u_char *);
55408263d1delphijextern void nbt_tcp_print(netdissect_options *, const u_char *, int);
55508263d1delphijextern void nbt_udp137_print(netdissect_options *, const u_char *, int);
55608263d1delphijextern void nbt_udp138_print(netdissect_options *, const u_char *, int);
55708263d1delphijextern void netbeui_print(netdissect_options *, u_short, const u_char *, int);
558af736e6glebiusextern void nfsreply_print(netdissect_options *, const u_char *, u_int, const u_char *);
559af736e6glebiusextern void nfsreply_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
560af736e6glebiusextern void nfsreq_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
561af736e6glebiusextern const u_char * ns_nprint (netdissect_options *, register const u_char *, register const u_char *);
562af736e6glebiusextern void ns_print(netdissect_options *, const u_char *, u_int, int);
563af736e6glebiusextern void nsh_print(netdissect_options *ndo, const u_char *bp, u_int len);
564af736e6glebiusextern void ntp_print(netdissect_options *, const u_char *, u_int);
565af736e6glebiusextern void oam_print(netdissect_options *, const u_char *, u_int, u_int);
566af736e6glebiusextern void olsr_print(netdissect_options *, const u_char *, u_int, int);
567af736e6glebiusextern void openflow_print(netdissect_options *, const u_char *, const u_int);
568af736e6glebiusextern void ospf6_print(netdissect_options *, const u_char *, u_int);
56908263d1delphijextern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
57008263d1delphijextern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
571af736e6glebiusextern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
572af736e6glebiusextern void otv_print(netdissect_options *, const u_char *, u_int);
573640e6f3glebiusextern void pfsync_ip_print(netdissect_options *, const u_char *, u_int);
574af736e6glebiusextern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
575af736e6glebiusextern void pim_print(netdissect_options *, const u_char *, u_int, const u_char *);
576af736e6glebiusextern void pimv1_print(netdissect_options *, const u_char *, u_int);
57708263d1delphijextern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
578af736e6glebiusextern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
579af736e6glebiusextern void pptp_print(netdissect_options *, const u_char *);
580af736e6glebiusextern int print_unknown_data(netdissect_options *, const u_char *, const char *, int);
581af736e6glebiusextern char *q922_string(netdissect_options *, const u_char *, u_int);
582af736e6glebiusextern void q933_print(netdissect_options *, const u_char *, u_int);
583af736e6glebiusextern void radius_print(netdissect_options *, const u_char *, u_int);
584af736e6glebiusextern void resp_print(netdissect_options *, const u_char *, u_int);
585af736e6glebiusextern void rip_print(netdissect_options *, const u_char *, u_int);
586af736e6glebiusextern void ripng_print(netdissect_options *, const u_char *, unsigned int);
587af736e6glebiusextern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
588af736e6glebiusextern void rrcp_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *, const struct lladdr_info *);
58908263d1delphijextern void rsvp_print(netdissect_options *, const u_char *, u_int);
590af736e6glebiusextern int rt6_print(netdissect_options *, const u_char *, const u_char *);
591c2704d8pkelseyextern void rtsp_print(netdissect_options *, const u_char *, u_int);
592af736e6glebiusextern void rx_print(netdissect_options *, register const u_char *, int, int, int, const u_char *);
593af736e6glebiusextern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
594af736e6glebiusextern void sflow_print(netdissect_options *, const u_char *, u_int);
595af736e6glebiusextern void sip_print(netdissect_options *, const u_char *, u_int);
596af736e6glebiusextern void slow_print(netdissect_options *, const u_char *, u_int);
597af736e6glebiusextern void smb_print_data(netdissect_options *, const unsigned char *, int);
598af736e6glebiusextern void smb_tcp_print(netdissect_options *, const u_char *, int);
599c2704d8pkelseyextern void smtp_print(netdissect_options *, const u_char *, u_int);
600af736e6glebiusextern int snap_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *, u_int);
601af736e6glebiusextern void snmp_print(netdissect_options *, const u_char *, u_int);
602af736e6glebiusextern void stp_print(netdissect_options *, const u_char *, u_int);
603af736e6glebiusextern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
604af736e6glebiusextern void syslog_print(netdissect_options *, const u_char *, u_int);
605af736e6glebiusextern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
606af736e6glebiusextern void telnet_print(netdissect_options *, const u_char *, u_int);
607af736e6glebiusextern void tftp_print(netdissect_options *, const u_char *, u_int);
608af736e6glebiusextern void timed_print(netdissect_options *, const u_char *);
609af736e6glebiusextern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
610af736e6glebiusextern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
611af736e6glebiusextern void udld_print(netdissect_options *, const u_char *, u_int);
612af736e6glebiusextern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
613af736e6glebiusextern int vjc_print(netdissect_options *, register const char *, u_short);
614af736e6glebiusextern void vqp_print(netdissect_options *, register const u_char *, register u_int);
615af736e6glebiusextern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
616af736e6glebiusextern void vtp_print(netdissect_options *, const u_char *, u_int);
617af736e6glebiusextern void vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len);
618af736e6glebiusextern void vxlan_print(netdissect_options *, const u_char *, u_int);
619af736e6glebiusextern void wb_print(netdissect_options *, const void *, u_int);
620af736e6glebiusextern void zephyr_print(netdissect_options *, const u_char *, int);
621af736e6glebiusextern void zmtp1_print(netdissect_options *, const u_char *, u_int);
622af736e6glebiusextern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
62388a191fsam
624af736e6glebius/* checksum routines */
625af736e6glebiusextern void init_checksum(void);
626af736e6glebiusextern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int);
627af736e6glebiusextern uint16_t create_osi_cksum(const uint8_t *, int, int);
62888a191fsam
629d36dcecdelphijstruct cksum_vec {
63008263d1delphij	const uint8_t	*ptr;
631d36dcecdelphij	int		len;
632d36dcecdelphij};
63308263d1delphijextern uint16_t in_cksum(const struct cksum_vec *, int);
63408263d1delphijextern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
63588a191fsam
636af736e6glebiusextern int nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, u_int);
637af736e6glebius
638af736e6glebius/* in print-ip6.c */
639af736e6glebiusextern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int);
640af736e6glebius
641af736e6glebius/* Utilities */
642af736e6glebiusextern int mask2plen(uint32_t);
643af736e6glebiusextern int mask62plen(const u_char *);
644af736e6glebius
645af736e6glebiusextern const char *dnnum_string(netdissect_options *, u_short);
6465f4de8erpaulo
647af736e6glebiusextern char *smb_errstr(int, int);
648af736e6glebiusextern const char *nt_errstr(uint32_t);
6495f4de8erpaulo
650af736e6glebiusextern int decode_prefix4(netdissect_options *, const u_char *, u_int, char *, u_int);
651af736e6glebiusextern int decode_prefix6(netdissect_options *, const u_char *, u_int, char *, u_int);
652af736e6glebius
653af736e6glebiusextern void esp_print_decodesecret(netdissect_options *);
654af736e6glebiusextern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *, int,
655af736e6glebius					     u_char spii[8], u_char spir[8],
656af736e6glebius					     const u_char *, const u_char *);
65708263d1delphij
65888a191fsam#endif  /* netdissect_h */
659