X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/f78c60f54a9beb04f1409712ec95b46f2d52a0ab..bc183f0882ee2080e5888a428e5b0823380fc18a:/interface.h diff --git a/interface.h b/interface.h index 47f03500..59c1eefd 100644 --- a/interface.h +++ b/interface.h @@ -104,9 +104,21 @@ extern int32_t thiszone; /* seconds offset from gmt to local time */ * that "snapend - (l)" underflows. * * 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 TTEST2(var, l) (snapend - (l) <= snapend && \ - (const u_char *)&(var) <= snapend - (l)) +#define TTEST2(var, l) \ + ((uintptr_t)snapend - (l) <= (uintptr_t)snapend && \ + (uintptr_t)&(var) <= (uintptr_t)snapend - (l)) /* True if "var" was captured */ #define TTEST(var) TTEST2(var, sizeof(var)) @@ -117,18 +129,10 @@ extern int32_t thiszone; /* seconds offset from gmt to local time */ /* Bail if "var" was not captured */ #define TCHECK(var) TCHECK2(var, sizeof(var)) -extern void ts_print(const struct timeval *); -extern void relts_print(int); - -extern int fn_print(const u_char *, const u_char *); -extern int fn_printn(const u_char *, u_int, const u_char *); -extern int fn_printzp(const u_char *, u_int, const u_char *); -extern int mask2plen(u_int32_t); +extern int mask2plen(uint32_t); extern const char *tok2strary_internal(const char **, int, const char *, int); #define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i) -extern const char *dnaddr_string(u_short); - extern void error(const char *, ...) __attribute__((noreturn)) #ifdef __ATTRIBUTE___FORMAT_OK @@ -144,60 +148,31 @@ extern void warning(const char *, ...) extern char *read_infile(char *); extern char *copy_argv(char **); -extern const char *isonsap_string(const u_char *, register u_int); -extern const char *protoid_string(const u_char *); -extern const char *ipxsap_string(u_short); extern const char *dnname_string(u_short); extern const char *dnnum_string(u_short); /* checksum routines */ extern void init_checksum(void); -extern u_int16_t verify_crc10_cksum(u_int16_t, const u_char *, int); -extern u_int16_t create_osi_cksum(const u_int8_t *, int, int); +extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int); +extern uint16_t create_osi_cksum(const uint8_t *, int, int); /* The printer routines. */ #include -extern void ascii_print(const u_char *, u_int); -extern void decnet_print(const u_char *, u_int, u_int); -extern void default_print(const u_char *, u_int); -extern char *q922_string(const u_char *); -extern void ospf_print(const u_char *, u_int, const u_char *); -extern void rsvp_print(const u_char *, u_int); -extern void lldp_print(const u_char *, u_int); -extern u_int ppp_print(register const u_char *, u_int); -extern u_int ppp_if_print(const struct pcap_pkthdr *, const u_char *); -extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *); -extern u_int ppp_bsdos_if_print(const struct pcap_pkthdr *, const u_char *); -extern void tcp_print(const u_char *, u_int, const u_char *, int); -extern void timed_print(const u_char *); -extern void netbeui_print(u_short, const u_char *, int); -extern void ipx_netbios_print(const u_char *, u_int); -extern void nbt_tcp_print(const u_char *, int); -extern void nbt_udp137_print(const u_char *, int); -extern void nbt_udp138_print(const u_char *, int); -extern void smb_tcp_print(const u_char *, int); extern char *smb_errstr(int, int); -extern const char *nt_errstr(u_int32_t); -extern void print_data(const unsigned char *, int); -extern void cfm_print(const u_char *, u_int); -extern void lwres_print(const u_char *, u_int); -extern void sip_print(const u_char *, u_int); -extern void syslog_print(const u_char *, u_int); - +extern const char *nt_errstr(uint32_t); #ifdef INET6 -extern void babel_print(const u_char *, u_int); extern int mask62plen(const u_char *); #endif /*INET6*/ struct cksum_vec { - const u_int8_t *ptr; + const uint8_t *ptr; int len; }; -extern u_int16_t in_cksum(const struct cksum_vec *, int); -extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t); +extern uint16_t in_cksum(const struct cksum_vec *, int); +extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t); #ifndef HAVE_BPF_DUMP struct bpf_program; @@ -249,4 +224,6 @@ extern netdissect_options *gndo; #define snaplen gndo->ndo_snaplen #define snapend gndo->ndo_snapend +extern void default_print(const u_char *, u_int); + #endif