From 757e793ca521cbfdc4a6104c9a2a920f5538d195 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Thu, 26 Dec 2019 22:08:03 +0100 Subject: 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. --- print-pktap.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'print-pktap.c') 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, -- cgit v1.2.1