diff options
author | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2019-12-26 22:08:03 +0100 |
---|---|---|
committer | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2020-02-02 14:15:24 +0100 |
commit | 757e793ca521cbfdc4a6104c9a2a920f5538d195 (patch) | |
tree | 1cb5d5a01cc7d82363e0db3b6d52c56a326a6175 /print-pktap.c | |
parent | 4addcceb8068eacc3c69bdad6ba18ad58353c3a3 (diff) | |
download | tcpdump-757e793ca521cbfdc4a6104c9a2a920f5538d195.tar.gz |
Apply the first step of the new way to update the link-layer header length
Currently the return value of link-layer dissectors is supposed to be
the length of the link-layer header, so that it can be skipped for -x
and -X.
If a link-layer dissector or a called function throws an exception, it
returns no value, so that length isn't available.
The goal is to change all the link-layer dissectors to be void functions
and dissectors should update a new field of the netdissect_options
structure "link-layer header length" rather than returning it as a value.
In this transition process, the link-layer dissectors will be moved, when
updated, from the uint_printers[] array (named before printers[]) to the
void_printers[] array.
In this transition process, a new field of the netdissect_options
structure, ndo_void_printer (TRUE/FALSE), set in the updated function
lookup_printer(), will permit to choose between the old and new way to
update the link-layer header length.
Diffstat (limited to 'print-pktap.c')
-rw-r--r-- | print-pktap.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/print-pktap.c b/print-pktap.c index af3b3973..182378ef 100644 --- a/print-pktap.c +++ b/print-pktap.c @@ -102,7 +102,7 @@ pktap_if_print(netdissect_options *ndo, uint32_t dlt, hdrlen, rectype; u_int caplen = h->caplen; u_int length = h->len; - if_printer printer; + if_printer_t printer; const pktap_header_t *hdr; struct pcap_pkthdr nhdr; @@ -145,11 +145,16 @@ pktap_if_print(netdissect_options *ndo, break; case PKT_REC_PACKET: - if ((printer = lookup_printer(dlt)) != NULL) { + printer = lookup_printer(ndo, dlt); + if (printer.printer != NULL) { nhdr = *h; nhdr.caplen = caplen; nhdr.len = length; - hdrlen += printer(ndo, &nhdr, p); + if (ndo->ndo_void_printer == TRUE) { + printer.void_printer(ndo, &nhdr, p); + hdrlen += ndo->ndo_ll_header_length; + } else + hdrlen += printer.uint_printer(ndo, &nhdr, p); } else { if (!ndo->ndo_eflag) pktap_header_print(ndo, (const u_char *)hdr, |