#include <time.h>
#include "status-exit-codes.h"
#include "funcattrs.h" /* for PRINTFLIKE_FUNCPTR() */
-#include "diag-control.h" /* for ND_UNREACHABLE */
/*
* Data types corresponding to multi-byte integral values within data
#define FMAXINT (4294967296.0) /* floating point rep. of MAXINT */
+/*
+ * Data types corresponding to multi-byte floating_point values within
+ * data structures. These are defined as arrays of octets, for the
+ * same reason that we do so for integral values.
+ */
+typedef unsigned char nd_float[4];
+typedef unsigned char nd_double[8];
+
/*
* Use this for IPv4 addresses and netmasks.
*
};
/* tok2str is deprecated */
-extern const char *tok2str(const struct tok *, const char *, u_int);
-extern char *bittok2str(const struct tok *, const char *, u_int);
-extern char *bittok2str_nosep(const struct tok *, const char *, u_int);
+extern const char *tok2str(const struct tok *, const char *, const u_int);
+extern char *bittok2str(const struct tok *, const char *, const u_int);
+extern char *bittok2str_nosep(const struct tok *, const char *, const u_int);
/* Initialize netdissect. */
extern int nd_init(char *, size_t);
jmp_buf ndo_early_end; /* jmp_buf for setjmp()/longjmp() */
void *ndo_last_mem_p; /* pointer to the last allocated memory chunk */
int ndo_packet_number; /* print a packet number in the beginning of line */
+ int ndo_lengths; /* print packet header caplen and len */
int ndo_print_sampling; /* print every Nth packet */
int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
int ndo_tstamp_precision; /* requested time stamp precision */
/* Bail out if "l" bytes from "p" were not captured */
#ifdef ND_LONGJMP_FROM_TCHECK
-#define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) nd_trunc_longjmp(ndo)
+#define ND_TCHECK_LEN(p, l) \
+do { \
+if (!ND_TTEST_LEN(p, l)) nd_trunc_longjmp(ndo); \
+} while (0)
#else
-#define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) goto trunc
+#define ND_TCHECK_LEN(p, l) \
+do { \
+if (!ND_TTEST_LEN(p, l)) goto trunc; \
+} while (0)
#endif
/* Bail out if "*(p)" was not captured */
* a custom message, format %u
*/
#define ND_ICHECKMSG_U(message, expression_1, operator, expression_2) \
+do { \
if ((expression_1) operator (expression_2)) { \
ND_PRINT(" [%s %u %s %u]", (message), (expression_1), (#operator), (expression_2)); \
goto invalid; \
-}
+} \
+} while (0)
/*
* Check (expression_1 operator expression_2) for invalid packet with
* a custom message, format %zu
*/
#define ND_ICHECKMSG_ZU(message, expression_1, operator, expression_2) \
+do { \
if ((expression_1) operator (expression_2)) { \
ND_PRINT(" [%s %u %s %zu]", (message), (expression_1), (#operator), (expression_2)); \
goto invalid; \
-}
+} \
+} while (0)
/*
* Check (expression_1 operator expression_2) for invalid packet with
extern int nd_printn(netdissect_options *, const u_char *, u_int, const u_char *);
extern void nd_printjn(netdissect_options *, const u_char *, u_int);
extern void nd_printjnp(netdissect_options *, const u_char *, u_int);
+extern void nd_print_bytes_hex(netdissect_options *, const u_char *, u_int);
/*
* Flags for txtproto_print().
#define PLURAL_SUFFIX(n) \
(((n) != 1) ? "s" : "")
-extern const char *tok2strary_internal(const char **, int, const char *, int);
+extern const char *tok2strary_internal(const char **, int, const char *, const int);
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
struct uint_tokary
extern void pflog_if_print IF_PRINTER_ARGS;
extern void pktap_if_print IF_PRINTER_ARGS;
extern void ppi_if_print IF_PRINTER_ARGS;
-extern void ppp_bsdos_if_print IF_PRINTER_ARGS;
extern void ppp_hdlc_if_print IF_PRINTER_ARGS;
extern void ppp_if_print IF_PRINTER_ARGS;
extern void pppoe_if_print IF_PRINTER_ARGS;
extern void eapol_print(netdissect_options *, const u_char *);
extern void egp_print(netdissect_options *, const u_char *, u_int);
extern void eigrp_print(netdissect_options *, const u_char *, u_int);
-extern void erspan_print(netdissect_options *, uint16_t, const u_char *, u_int);
+extern void erspan_i_ii_print(netdissect_options *, uint16_t, const u_char *, u_int);
+extern void erspan_iii_print(netdissect_options *, const u_char *, u_int);
extern void esp_print(netdissect_options *, const u_char *, u_int, const u_char *, u_int, int, u_int);
extern u_int ether_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), const u_char *);
extern u_int ether_switch_tag_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), u_int);
extern void nd_print_protocol_caps(netdissect_options *);
extern void nd_print_invalid(netdissect_options *);
-extern int mask2plen(uint32_t);
+extern int mask2plen(const uint32_t);
extern int mask62plen(const u_char *);
extern const char *dnnum_string(netdissect_options *, u_short);