Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/tcpdump/netdissect.h
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | struct tok { | ||||
const char *s; /* string */ | const char *s; /* string */ | ||||
}; | }; | ||||
#define TOKBUFSIZE 128 | #define TOKBUFSIZE 128 | ||||
extern const char *tok2strbuf(const struct tok *, const char *, u_int, | extern const char *tok2strbuf(const struct tok *, const char *, u_int, | ||||
char *buf, size_t bufsize); | char *buf, size_t bufsize); | ||||
/* tok2str is deprecated */ | /* tok2str is deprecated */ | ||||
extern const char *tok2str(const struct tok *, const char *, int); | extern const char *tok2str(const struct tok *, const char *, u_int); | ||||
extern char *bittok2str(const struct tok *, const char *, int); | extern char *bittok2str(const struct tok *, const char *, u_int); | ||||
extern char *bittok2str_nosep(const struct tok *, const char *, int); | extern char *bittok2str_nosep(const struct tok *, const char *, u_int); | ||||
typedef struct netdissect_options netdissect_options; | typedef struct netdissect_options netdissect_options; | ||||
struct netdissect_options { | struct netdissect_options { | ||||
int ndo_aflag; /* translate network and broadcast addresses */ | int ndo_aflag; /* translate network and broadcast addresses */ | ||||
int ndo_bflag; /* print 4 byte ASes in ASDOT notation */ | int ndo_bflag; /* print 4 byte ASes in ASDOT notation */ | ||||
int ndo_eflag; /* print ethernet header */ | int ndo_eflag; /* print ethernet header */ | ||||
Show All 15 Lines | int ndo_Aflag; /* print packet only in ascii observing TAB, | ||||
* LF, CR and SPACE as graphical chars | * LF, CR and SPACE as graphical chars | ||||
*/ | */ | ||||
int ndo_Bflag; /* buffer size */ | int ndo_Bflag; /* buffer size */ | ||||
int ndo_Iflag; /* rfmon (monitor) mode */ | int ndo_Iflag; /* rfmon (monitor) mode */ | ||||
int ndo_Oflag; /* run filter code optimizer */ | int ndo_Oflag; /* run filter code optimizer */ | ||||
int ndo_dlt; /* if != -1, ask libpcap for the DLT it names*/ | int ndo_dlt; /* if != -1, ask libpcap for the DLT it names*/ | ||||
int ndo_jflag; /* packet time stamp source */ | int ndo_jflag; /* packet time stamp source */ | ||||
int ndo_pflag; /* don't go promiscuous */ | int ndo_pflag; /* don't go promiscuous */ | ||||
int ndo_immediate; /* use immediate mode */ | |||||
int ndo_Cflag; /* rotate dump files after this many bytes */ | int ndo_Cflag; /* rotate dump files after this many bytes */ | ||||
int ndo_Cflag_count; /* Keep track of which file number we're writing */ | int ndo_Cflag_count; /* Keep track of which file number we're writing */ | ||||
int ndo_Gflag; /* rotate dump files after this many seconds */ | int ndo_Gflag; /* rotate dump files after this many seconds */ | ||||
int ndo_Gflag_count; /* number of files created with Gflag rotation */ | int ndo_Gflag_count; /* number of files created with Gflag rotation */ | ||||
time_t ndo_Gflag_time; /* The last time_t the dump file was rotated. */ | time_t ndo_Gflag_time; /* The last time_t the dump file was rotated. */ | ||||
int ndo_Wflag; /* recycle output files after this number of files */ | int ndo_Wflag; /* recycle output files after this number of files */ | ||||
int ndo_WflagChars; | int ndo_WflagChars; | ||||
Show All 25 Lines | struct netdissect_options { | ||||
const u_char *ndo_snapend; | const u_char *ndo_snapend; | ||||
/* bookkeeping for ^T output */ | /* bookkeeping for ^T output */ | ||||
int ndo_infodelay; | int ndo_infodelay; | ||||
/* pointer to void function to output stuff */ | /* pointer to void function to output stuff */ | ||||
void (*ndo_default_print)(netdissect_options *, | void (*ndo_default_print)(netdissect_options *, | ||||
register const u_char *bp, register u_int length); | register const u_char *bp, register u_int length); | ||||
/* pointer to function to print ^T output */ | |||||
void (*ndo_info)(netdissect_options *, int verbose); | void (*ndo_info)(netdissect_options *, int verbose); | ||||
/* pointer to function to do regular output */ | |||||
int (*ndo_printf)(netdissect_options *, | int (*ndo_printf)(netdissect_options *, | ||||
const char *fmt, ...) | const char *fmt, ...) | ||||
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS | #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS | ||||
__attribute__ ((format (printf, 2, 3))) | __attribute__ ((format (printf, 2, 3))) | ||||
#endif | #endif | ||||
; | ; | ||||
/* pointer to function to output errors */ | |||||
void (*ndo_error)(netdissect_options *, | void (*ndo_error)(netdissect_options *, | ||||
const char *fmt, ...) | const char *fmt, ...) | ||||
#ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS | #ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS | ||||
__attribute__ ((noreturn)) | __attribute__ ((noreturn)) | ||||
#endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */ | #endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */ | ||||
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS | #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS | ||||
__attribute__ ((format (printf, 2, 3))) | __attribute__ ((format (printf, 2, 3))) | ||||
#endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */ | #endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */ | ||||
; | ; | ||||
/* pointer to function to output warnings */ | |||||
void (*ndo_warning)(netdissect_options *, | void (*ndo_warning)(netdissect_options *, | ||||
const char *fmt, ...) | const char *fmt, ...) | ||||
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS | #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS | ||||
__attribute__ ((format (printf, 2, 3))) | __attribute__ ((format (printf, 2, 3))) | ||||
#endif | #endif | ||||
; | ; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* True if "l" bytes of "var" were captured. | * True if "l" bytes of "var" were captured. | ||||
* | * | ||||
* The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure | * The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure | ||||
* "l" isn't so large that "ndo->ndo_snapend - (l)" underflows. | * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows. | ||||
* | * | ||||
* The check is for <= rather than < because "l" might be 0. | * The check is for <= rather than < because "l" might be 0. | ||||
* | |||||
* We cast the pointers to uintptr_t to make sure that the compiler | |||||
* doesn't optimize away any of these tests (which it is allowed to | |||||
* do, as adding an integer to, or subtracting an integer from, a | |||||
* pointer assumes that the pointer is a pointer to an element of an | |||||
* array and that the result of the addition or subtraction yields a | |||||
* pointer to another member of the array, so that, for example, if | |||||
* you subtract a positive integer from a pointer, the result is | |||||
* guaranteed to be less than the original pointer value). See | |||||
* | |||||
* http://www.kb.cert.org/vuls/id/162289 | |||||
*/ | */ | ||||
#define ND_TTEST2(var, l) (ndo->ndo_snapend - (l) <= ndo->ndo_snapend && \ | #define ND_TTEST2(var, l) \ | ||||
(const u_char *)&(var) <= ndo->ndo_snapend - (l)) | ((l) >= 0 && \ | ||||
((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \ | |||||
(uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l))) | |||||
/* True if "var" was captured */ | /* True if "var" was captured */ | ||||
#define ND_TTEST(var) ND_TTEST2(var, sizeof(var)) | #define ND_TTEST(var) ND_TTEST2(var, sizeof(var)) | ||||
/* Bail if "l" bytes of "var" were not captured */ | /* Bail if "l" bytes of "var" were not captured */ | ||||
#define ND_TCHECK2(var, l) if (!ND_TTEST2(var, l)) goto trunc | #define ND_TCHECK2(var, l) if (!ND_TTEST2(var, l)) goto trunc | ||||
/* Bail if "var" was not captured */ | /* Bail if "var" was not captured */ | ||||
#define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var)) | #define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var)) | ||||
#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF | #define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF | ||||
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length) | #define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length) | ||||
extern void ts_print(netdissect_options *, const struct timeval *); | extern void ts_print(netdissect_options *, const struct timeval *); | ||||
extern void relts_print(netdissect_options *, int); | extern void relts_print(netdissect_options *, int); | ||||
extern int fn_print(netdissect_options *, const u_char *, const u_char *); | extern int fn_print(netdissect_options *, const u_char *, const u_char *); | ||||
extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *); | extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *); | ||||
extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *); | extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *); | ||||
extern const char *tok2str(const struct tok *, const char *, int); | |||||
/* | |||||
* Flags for txtproto_print(). | |||||
*/ | |||||
#define RESP_CODE_SECOND_TOKEN 0x00000001 /* response code is second token in response line */ | |||||
extern void txtproto_print(netdissect_options *, const u_char *, u_int, | |||||
const char *, const char **, u_int); | |||||
#if 0 | #if 0 | ||||
extern char *read_infile(netdissect_options *, char *); | extern char *read_infile(netdissect_options *, char *); | ||||
extern char *copy_argv(netdissect_options *, char **); | extern char *copy_argv(netdissect_options *, char **); | ||||
#endif | #endif | ||||
/* | /* | ||||
* Locale-independent macros for testing character properties and | * Locale-independent macros for testing character properties and | ||||
* stripping the 8th bit from characters. Assumed to be handed | * stripping the 8th bit from characters. Assumed to be handed | ||||
Show All 40 Lines | |||||
extern const char *dnname_string(netdissect_options *, u_short); | extern const char *dnname_string(netdissect_options *, u_short); | ||||
extern const char *dnnum_string(netdissect_options *, u_short); | extern const char *dnnum_string(netdissect_options *, u_short); | ||||
#endif | #endif | ||||
/* The printer routines. */ | /* The printer routines. */ | ||||
#include <pcap.h> | #include <pcap.h> | ||||
extern char *q922_string(netdissect_options *ndo, const u_char *, u_int); | |||||
typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo, | typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo, | ||||
const struct pcap_pkthdr *, const u_char *); | const struct pcap_pkthdr *, const u_char *); | ||||
typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *); | typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *); | ||||
extern if_ndo_printer lookup_ndo_printer(int); | extern if_ndo_printer lookup_ndo_printer(int); | ||||
extern if_printer lookup_printer(int); | extern if_printer lookup_printer(int); | ||||
extern void eap_print(netdissect_options *,const u_char *, u_int); | extern void eap_print(netdissect_options *,const u_char *, u_int); | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | |||||
extern void wb_print(netdissect_options *, const void *, u_int); | extern void wb_print(netdissect_options *, const void *, u_int); | ||||
extern int oam_print(netdissect_options *, const u_char *, u_int, u_int); | extern int oam_print(netdissect_options *, const u_char *, u_int, u_int); | ||||
extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int); | extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int); | ||||
extern u_int sunatm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int sunatm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern void vtp_print(netdissect_options *, const u_char *, u_int); | extern void vtp_print(netdissect_options *, const u_char *, u_int); | ||||
extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char); | extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char); | ||||
extern void ntp_print(netdissect_options *, const u_char *, u_int); | extern void ntp_print(netdissect_options *, const u_char *, u_int); | ||||
extern void cnfp_print(netdissect_options *, const u_char *, const u_char *); | extern void cnfp_print(netdissect_options *, const u_char *); | ||||
extern void dvmrp_print(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); | extern void egp_print(netdissect_options *, const u_char *, u_int); | ||||
extern u_int enc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int enc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int sl_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int sl_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int sl_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int sl_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern void tftp_print(netdissect_options *, const u_char *, u_int); | extern void tftp_print(netdissect_options *, const u_char *, u_int); | ||||
extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int); | extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int); | ||||
extern void pimv1_print(netdissect_options *, const u_char *, u_int); | extern void pimv1_print(netdissect_options *, const u_char *, u_int); | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
extern u_int ppp_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int ppp_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int ppp_hdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int ppp_hdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int ppp_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int ppp_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern void lldp_print(netdissect_options *, const u_char *, u_int); | extern void lldp_print(netdissect_options *, const u_char *, u_int); | ||||
extern void rsvp_print(netdissect_options *, const u_char *, u_int); | extern void rsvp_print(netdissect_options *, const u_char *, u_int); | ||||
extern void timed_print(netdissect_options *, const u_char *); | extern void timed_print(netdissect_options *, const u_char *); | ||||
extern void m3ua_print(netdissect_options *, const u_char *, const u_int); | extern void m3ua_print(netdissect_options *, const u_char *, const u_int); | ||||
extern void aoe_print(netdissect_options *, const u_char *, const u_int); | extern void aoe_print(netdissect_options *, const u_char *, const u_int); | ||||
extern void ftp_print(netdissect_options *, const u_char *, u_int); | |||||
extern void http_print(netdissect_options *, const u_char *, u_int); | |||||
extern void rtsp_print(netdissect_options *, const u_char *, u_int); | |||||
extern void smtp_print(netdissect_options *, const u_char *, u_int); | |||||
extern void geneve_print(netdissect_options *, const u_char *, u_int); | |||||
extern void pfsync_ip_print(netdissect_options *, const u_char *, u_int); | extern void pfsync_ip_print(netdissect_options *, const u_char *, u_int); | ||||
/* stuff that has not yet been rototiled */ | /* stuff that has not yet been rototiled */ | ||||
#if 0 | #if 0 | ||||
extern void ascii_print(netdissect_options *,u_int); | extern void ascii_print(netdissect_options *,u_int); | ||||
extern void default_print(netdissect_options *,const u_char *, u_int); | extern void default_print(netdissect_options *,const u_char *, u_int); | ||||
extern char *smb_errstr(netdissect_options *,int, int); | extern char *smb_errstr(netdissect_options *,int, int); | ||||
extern const char *nt_errstr(netdissect_options *, uint32_t); | extern const char *nt_errstr(netdissect_options *, uint32_t); | ||||
#endif | #endif | ||||
extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | extern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int nflog_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | extern u_int nflog_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int pktap_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | extern u_int pktap_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int ieee802_11_radio_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int ieee802_11_radio_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int ieee802_11_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int ieee802_11_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
extern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | extern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *); | ||||
#ifdef INET6 | |||||
extern void ip6_print(netdissect_options *,const u_char *, u_int); | extern void ip6_print(netdissect_options *,const u_char *, u_int); | ||||
#ifdef INET6 | |||||
extern int frag6_print(netdissect_options *, const u_char *, const u_char *); | extern int frag6_print(netdissect_options *, const u_char *, const u_char *); | ||||
extern int rt6_print(netdissect_options *, const u_char *, const u_char *); | extern int rt6_print(netdissect_options *, const u_char *, const u_char *); | ||||
extern int hbhopt_print(netdissect_options *, const u_char *); | extern int hbhopt_print(netdissect_options *, const u_char *); | ||||
extern int dstopt_print(netdissect_options *, const u_char *); | extern int dstopt_print(netdissect_options *, const u_char *); | ||||
extern void ripng_print(netdissect_options *, const u_char *, unsigned int); | extern void ripng_print(netdissect_options *, const u_char *, unsigned int); | ||||
extern int mobility_print(netdissect_options *, const u_char *, const u_char *); | extern int mobility_print(netdissect_options *, const u_char *, const u_char *); | ||||
extern void dhcp6_print(netdissect_options *, const u_char *, u_int); | extern void dhcp6_print(netdissect_options *, const u_char *, u_int); | ||||
extern void ospf6_print(netdissect_options *, const u_char *, u_int); | extern void ospf6_print(netdissect_options *, const u_char *, u_int); | ||||
Show All 28 Lines |