X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/33fee60fe09285b92531e3e6b635759a8e7f9093..1ee09c1510704191a14df4eb914dba3d5dc9ab58:/netdissect.h diff --git a/netdissect.h b/netdissect.h index 1a38d38e..c4e34eed 100644 --- a/netdissect.h +++ b/netdissect.h @@ -21,7 +21,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.2 2004-03-25 03:29:53 mcr Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.16 2005-04-07 00:28:17 mcr Exp $ (LBL) */ #ifndef netdissect_h @@ -31,7 +31,6 @@ #include "os-proto.h" #endif #include -#include #ifndef HAVE___ATTRIBUTE__ #define __attribute__(x) @@ -62,11 +61,20 @@ extern size_t strlcpy (char *, const char *, size_t); extern char *strdup (const char *str); #endif +#ifndef HAVE_STRSEP +extern char *strsep(char **, const char *); +#endif + struct tok { int v; /* value */ const char *s; /* string */ }; +#define TOKBUFSIZE 128 +extern const char *tok2strbuf(const struct tok *, const char *, int, + char *buf, size_t bufsize); + +/* tok2str is deprecated */ extern const char *tok2str(const struct tok *, const char *, int); extern char *bittok2str(const struct tok *, const char *, int); @@ -75,7 +83,6 @@ typedef struct netdissect_options netdissect_options; struct netdissect_options { int ndo_aflag; /* translate network and broadcast addresses */ - int ndo_dflag; /* print filter code */ int ndo_eflag; /* print ethernet header */ int ndo_fflag; /* don't translate "foreign" IP address */ int ndo_nflag; /* leave addresses as numbers */ @@ -85,6 +92,7 @@ struct netdissect_options { int ndo_sflag; /* use the libsmi to translate OIDs */ int ndo_Sflag; /* print raw TCP sequence numbers */ int ndo_tflag; /* print packet arrival time */ + int ndo_Uflag; /* "unbuffered" output of dump files */ int ndo_uflag; /* Print undecoded NFS handles */ int ndo_vflag; /* verbose */ int ndo_xflag; /* print packet in hex */ @@ -100,9 +108,12 @@ struct netdissect_options { int ndo_Cflag_count; /* Keep track of which file number we're writing */ int ndo_Wflag; /* recycle output files after this number of files */ int ndo_WflagChars; - char *ndo_dltname; + const char *ndo_dltname; char *ndo_espsecret; + struct sa_list *ndo_sa_list_head; /* used by print-esp.c */ + struct sa_list *ndo_sa_default; + char *ndo_tcpmd5secret; /* TCP-MD5 secret key */ struct esp_algorithm *ndo_espsecret_xform; /* cache of decoded */ @@ -126,12 +137,14 @@ struct netdissect_options { /* pointer to void function to output stuff */ void (*ndo_default_print)(netdissect_options *, register const u_char *bp, register u_int length); - void (*ndo_default_print_unaligned)(netdissect_options *, - register const u_char *bp, register u_int length); void (*ndo_info)(netdissect_options *, int verbose); int (*ndo_printf)(netdissect_options *, const char *fmt, ...); + void (*ndo_error)(netdissect_options *, + const char *fmt, ...); + void (*ndo_warning)(netdissect_options *, + const char *fmt, ...); }; #define PT_VAT 1 /* Visual Audio Tool */ @@ -176,8 +189,16 @@ struct netdissect_options { #define HTONS(x) (x) = htons(x) #endif -/* True if "l" bytes of "var" were captured */ -#define ND_TTEST2(var, l) ((u_char *)&(var) <= ndo->ndo_snapend - (l)) +/* + * True if "l" bytes of "var" were captured. + * + * The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure + * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows. + * + * The check is for <= rather than < because "l" might be 0. + */ +#define ND_TTEST2(var, l) (ndo->ndo_snapend - (l) <= ndo->ndo_snapend && \ + (const u_char *)&(var) <= ndo->ndo_snapend - (l)) /* True if "var" was captured */ #define ND_TTEST(var) ND_TTEST2(var, sizeof(var)) @@ -188,7 +209,8 @@ struct netdissect_options { /* Bail if "var" was not captured */ #define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var)) -#define ND_PRINT(fmt, args...) (*ndo->ndo_printf)(ndo, fmt, ##args) +#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF +#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length) #if 0 extern void ts_print(netdissect_options *ipdo, @@ -203,11 +225,6 @@ extern const char *tok2str(const struct tok *, const char *, int); extern void wrapup(int); #if 0 -extern void error(netdissect_options *, const char *, ...) - __attribute__((noreturn, format (printf, 2, 3))); -extern void warning(netdissect_options *, const char *, ...) - __attribute__ ((format (printf, 2, 3))); - extern char *read_infile(netdissect_options *, char *); extern char *copy_argv(netdissect_options *, char **); #endif @@ -229,22 +246,34 @@ extern const char *dnnum_string(netdissect_options *, u_short); extern void eap_print(netdissect_options *,const u_char *, u_int); +extern int esp_print(netdissect_options *, + register const u_char *bp, int len, register const u_char *bp2, + int *nhdr, int *padlen); +extern void arp_print(netdissect_options *,const u_char *, u_int, u_int); +extern void isakmp_print(netdissect_options *,const u_char *, + u_int, const u_char *); +extern void isakmp_rfc3948_print(netdissect_options *,const u_char *, + u_int, const u_char *); +extern void ip_print(netdissect_options *,const u_char *, u_int); +extern void ip_print_inner(netdissect_options *ndo, + const u_char *bp, u_int length, u_int nh, + const u_char *bp2); +/* stuff that has not yet been rototiled */ #if 0 -extern void ascii_print_with_offset(netdissect_options *, const u_char *, +extern void ascii_print_with_offset(netdissect_options *, const char *, u_int, u_int); -extern void ascii_print(netdissect_options *,const u_char *, u_int); -extern void hex_print_with_offset(netdissect_options *,const u_char *, +extern void ascii_print(netdissect_options *,const char *, u_int); +extern void hex_print_with_offset(netdissect_options *,const char *, u_int, u_int); extern void telnet_print(netdissect_options *,const u_char *, u_int); -extern void hex_print(netdissect_options *,const u_char *, u_int); +extern void hex_print(netdissect_options *,const char *, u_int); extern int ether_encap_print(netdissect_options *,u_short, const u_char *, u_int, u_int, u_short *); extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *, u_short *); extern void aarp_print(netdissect_options *,const u_char *, u_int); -extern void arp_print(netdissect_options *,const u_char *, u_int, u_int); extern void atalk_print(netdissect_options *,const u_char *, u_int); extern void atm_if_print(u_char *,const struct pcap_pkthdr *, const u_char *); extern void bootp_print(netdissect_options *,const u_char *, @@ -262,8 +291,6 @@ extern void cnfp_print(netdissect_options *,const u_char *cp, extern void decnet_print(netdissect_options *,const u_char *, u_int, u_int); extern void default_print(netdissect_options *,const u_char *, u_int); -extern void default_print_unaligned(netdissect_options *,const u_char *, - u_int); extern void dvmrp_print(netdissect_options *,const u_char *, u_int); extern void egp_print(netdissect_options *,const u_char *, u_int, const u_char *); @@ -283,7 +310,6 @@ extern void igmp_print(netdissect_options *, register const u_char *, u_int); extern void igrp_print(netdissect_options *,const u_char *, u_int, const u_char *); -extern void ip_print(netdissect_options *,const u_char *, u_int); extern void ipN_print(netdissect_options *,const u_char *, u_int); extern void ipx_print(netdissect_options *,const u_char *, u_int); extern void isoclns_print(netdissect_options *,const u_char *, @@ -355,12 +381,7 @@ extern void udp_print(netdissect_options *,const u_char *, u_int, extern void wb_print(netdissect_options *,const void *, u_int); extern int ah_print(netdissect_options *,register const u_char *, register const u_char *); -extern int esp_print(netdissect_options *, - register const u_char *bp, register const u_char *bp2, - int *nhdr, int *padlen); extern void esp_print_decodesecret(netdissect_options *ndo); -extern void isakmp_print(netdissect_options *,const u_char *, - u_int, const u_char *); extern int ipcomp_print(netdissect_options *,register const u_char *, register const u_char *, int *); extern void rx_print(netdissect_options *,register const u_char *, @@ -374,6 +395,7 @@ extern void nbt_udp137_print(netdissect_options *, extern void nbt_udp138_print(netdissect_options *, const u_char *data, int); extern char *smb_errstr(netdissect_options *,int, int); +extern const char *nt_errstr(netdissect_options *, u_int32_t); extern void print_data(netdissect_options *,const unsigned char *, int); extern void l2tp_print(netdissect_options *,const u_char *, u_int); extern void lcp_print(netdissect_options *,const u_char *, u_int); @@ -411,4 +433,3 @@ extern u_short in_cksum(const u_short *, #endif #endif /* netdissect_h */ -\