summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-03-10 13:25:52 -0700
committerGuy Harris <guy@alum.mit.edu>2015-03-10 13:25:52 -0700
commit4405f138044178bf9756cbb8712d086aaaafcaed (patch)
treedee5f82b4d0b63d96f07568dda6cb5a18e5b9096
parentd83a284abc80d3d09f6bddd087760bb1b01d9cc7 (diff)
downloadtcpdump-4405f138044178bf9756cbb8712d086aaaafcaed.tar.gz
Get rid of support for non-NDOified printers.
Remove the TTEST{2}/TCHECK{2} macros. Rename all "ndo_printer" routines, structures, and structure members to just "printer", and get rid of the old routines/structures/structure members with those names.
-rw-r--r--addrtoname.c2
-rw-r--r--interface.h32
-rw-r--r--netdissect.h4
-rw-r--r--print-pktap.c7
-rw-r--r--print-ppi.c7
-rw-r--r--tcpdump.c63
6 files changed, 19 insertions, 96 deletions
diff --git a/addrtoname.c b/addrtoname.c
index d0437fe4..6d957389 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -205,7 +205,7 @@ static uint32_t f_localnet;
*
* NOTE: ap is *NOT* necessarily part of the packet data (not even if
* this is being called with the "ipaddr_string()" macro), so you
- * *CANNOT* use the TCHECK{2}/TTEST{2} macros on it. Furthermore,
+ * *CANNOT* use the ND_TCHECK{2}/ND_TTEST{2} macros on it. Furthermore,
* even in cases where it *is* part of the packet data, the caller
* would still have to check for a null return value, even if it's
* just printing the return value with "%s" - not all versions of
diff --git a/interface.h b/interface.h
index 59c1eefd..2389c2e1 100644
--- a/interface.h
+++ b/interface.h
@@ -97,38 +97,6 @@ extern char *program_name; /* used to generate self-identifying messages */
extern int32_t thiszone; /* seconds offset from gmt to local time */
-/*
- * True if "l" bytes of "var" were captured.
- *
- * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large
- * 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) \
- ((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))
-
-/* Bail if "l" bytes of "var" were not captured */
-#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc
-
-/* Bail if "var" was not captured */
-#define TCHECK(var) TCHECK2(var, sizeof(var))
-
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)
diff --git a/netdissect.h b/netdissect.h
index 4580e73d..b25f4c9f 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -360,11 +360,9 @@ extern const char *dnnum_string(netdissect_options *, u_short);
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_printer)(struct netdissect_options *ndo,
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_printer lookup_printer(int);
extern void eap_print(netdissect_options *,const u_char *, u_int);
diff --git a/print-pktap.c b/print-pktap.c
index 46a187de..e376cc6e 100644
--- a/print-pktap.c
+++ b/print-pktap.c
@@ -99,8 +99,7 @@ pktap_if_print(netdissect_options *ndo,
uint32_t dlt, hdrlen, rectype;
u_int caplen = h->caplen;
u_int length = h->len;
- if_ndo_printer ndo_printer;
- if_printer printer;
+ if_printer printer;
pktap_header_t *hdr;
if (caplen < sizeof(pktap_header_t) || length < sizeof(pktap_header_t)) {
@@ -142,9 +141,7 @@ pktap_if_print(netdissect_options *ndo,
case PKT_REC_PACKET:
if ((printer = lookup_printer(dlt)) != NULL) {
- printer(h, p);
- } else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
- ndo_printer(ndo, h, p);
+ printer(ndo, h, p);
} else {
if (!ndo->ndo_eflag)
pktap_header_print(ndo, (u_char *)hdr,
diff --git a/print-ppi.c b/print-ppi.c
index b4035363..06678b0f 100644
--- a/print-ppi.c
+++ b/print-ppi.c
@@ -49,8 +49,7 @@ static void
ppi_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- if_ndo_printer ndo_printer;
- if_printer printer;
+ if_printer printer;
ppi_header_t *hdr;
u_int caplen = h->caplen;
u_int length = h->len;
@@ -82,9 +81,7 @@ ppi_print(netdissect_options *ndo,
p += len;
if ((printer = lookup_printer(dlt)) != NULL) {
- printer(h, p);
- } else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
- ndo_printer(ndo, h, p);
+ printer(ndo, h, p);
} else {
if (!ndo->ndo_eflag)
ppi_header_print(ndo, (u_char *)hdr, length + len);
diff --git a/tcpdump.c b/tcpdump.c
index 2fd16177..2a32adba 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -193,22 +193,12 @@ static void info(int);
static u_int packets_captured;
struct printer {
- if_printer f;
- int type;
-};
-
-
-struct ndo_printer {
- if_ndo_printer f;
+ if_printer f;
int type;
};
static const struct printer printers[] = {
- { NULL, 0 },
-};
-
-static const struct ndo_printer ndo_printers[] = {
{ ether_if_print, DLT_EN10MB },
#ifdef DLT_IPNET
{ ipnet_if_print, DLT_IPNET },
@@ -408,19 +398,6 @@ lookup_printer(int type)
if (type == p->type)
return p->f;
- return NULL;
- /* NOTREACHED */
-}
-
-if_ndo_printer
-lookup_ndo_printer(int type)
-{
- const struct ndo_printer *p;
-
- for (p = ndo_printers; p->f; ++p)
- if (type == p->type)
- return p->f;
-
#if defined(DLT_USER2) && defined(DLT_PKTAP)
/*
* Apple incorrectly chose to use DLT_USER2 for their PKTAP
@@ -439,7 +416,7 @@ lookup_ndo_printer(int type)
* that.
*/
if (type == DLT_USER2) {
- for (p = ndo_printers; p->f; ++p)
+ for (p = printers; p->f; ++p)
if (DLT_PKTAP == p->type)
return p->f;
}
@@ -459,11 +436,7 @@ extern char *optarg;
struct print_info {
netdissect_options *ndo;
- union {
- if_printer printer;
- if_ndo_printer ndo_printer;
- } p;
- int ndo_type;
+ if_printer printer;
};
struct dump_info {
@@ -548,8 +521,7 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
/*
* OK, does tcpdump handle that type?
*/
- if (lookup_printer(dlts[n_dlts]) == NULL
- && lookup_ndo_printer(dlts[n_dlts]) == NULL)
+ if (lookup_printer(dlts[n_dlts]) == NULL)
(void) fprintf(stderr, " (printing not supported)");
fprintf(stderr, "\n");
} else {
@@ -862,20 +834,15 @@ get_print_info(int type)
{
struct print_info printinfo;
- printinfo.ndo_type = 1;
printinfo.ndo = gndo;
- printinfo.p.ndo_printer = lookup_ndo_printer(type);
- if (printinfo.p.ndo_printer == NULL) {
- printinfo.p.printer = lookup_printer(type);
- printinfo.ndo_type = 0;
- if (printinfo.p.printer == NULL) {
- gndo->ndo_dltname = pcap_datalink_val_to_name(type);
- if (gndo->ndo_dltname != NULL)
- error("packet printing is not supported for link type %s: use -w",
- gndo->ndo_dltname);
- else
- error("packet printing is not supported for link type %d: use -w", type);
- }
+ printinfo.printer = lookup_printer(type);
+ if (printinfo.printer == NULL) {
+ gndo->ndo_dltname = pcap_datalink_val_to_name(type);
+ if (gndo->ndo_dltname != NULL)
+ error("packet printing is not supported for link type %s: use -w",
+ gndo->ndo_dltname);
+ else
+ error("packet printing is not supported for link type %d: use -w", type);
}
return (printinfo);
}
@@ -2465,11 +2432,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
*/
ndo->ndo_snapend = sp + h->caplen;
- if(print_info->ndo_type) {
- hdrlen = (*print_info->p.ndo_printer)(print_info->ndo, h, sp);
- } else {
- hdrlen = (*print_info->p.printer)(h, sp);
- }
+ hdrlen = (*print_info->printer)(print_info->ndo, h, sp);
/*
* Restore the original snapend, as a printer might have