Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/tcpdump/interface.h
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* True if "l" bytes of "var" were captured. | * True if "l" bytes of "var" were captured. | ||||
* | * | ||||
* The "snapend - (l) <= snapend" checks to make sure "l" isn't so large | * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large | ||||
* that "snapend - (l)" underflows. | * that "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 TTEST2(var, l) (snapend - (l) <= snapend && \ | #define TTEST2(var, l) \ | ||||
(const u_char *)&(var) <= snapend - (l)) | ((uintptr_t)snapend - (l) <= (uintptr_t)snapend && \ | ||||
(uintptr_t)&(var) <= (uintptr_t)snapend - (l)) | |||||
/* True if "var" was captured */ | /* True if "var" was captured */ | ||||
#define TTEST(var) TTEST2(var, sizeof(var)) | #define TTEST(var) TTEST2(var, sizeof(var)) | ||||
/* Bail if "l" bytes of "var" were not captured */ | /* Bail if "l" bytes of "var" were not captured */ | ||||
#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc | #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc | ||||
/* Bail if "var" was not captured */ | /* Bail if "var" was not captured */ | ||||
Show All 25 Lines | |||||
extern void init_checksum(void); | extern void init_checksum(void); | ||||
extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int); | extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int); | ||||
extern uint16_t create_osi_cksum(const uint8_t *, int, int); | extern uint16_t create_osi_cksum(const uint8_t *, int, int); | ||||
/* The printer routines. */ | /* The printer routines. */ | ||||
#include <pcap.h> | #include <pcap.h> | ||||
extern char *q922_string(const u_char *); | |||||
extern char *smb_errstr(int, int); | extern char *smb_errstr(int, int); | ||||
extern const char *nt_errstr(uint32_t); | extern const char *nt_errstr(uint32_t); | ||||
#ifdef INET6 | #ifdef INET6 | ||||
extern int mask62plen(const u_char *); | extern int mask62plen(const u_char *); | ||||
#endif /*INET6*/ | #endif /*INET6*/ | ||||
struct cksum_vec { | struct cksum_vec { | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |