From 4482949ddc5c12af591491ac51bdad201d14d353 Mon Sep 17 00:00:00 2001 From: John Thacker Date: Fri, 12 Mar 2021 22:12:40 -0500 Subject: [PATCH] export_pdu: set pkt_encap to a WTAP_ENCAP value, not a pcap LINKTYPE_ value. rec.rec_header.packet_header.pkt_encap expects WTAP encapsulation types, not PCAP encapsulation types, so don't call wtap_wtap_encap_to_pcap_encap(). Also, set the output file encapsulation, and the link-layer type of the fake interface, to exp_pdu_tap_data->pkt_encap rather than wiring it to WTAP_ENCAP_WIRESHARK_UPPER_PDU (we set exp_pdu_tap_data->pkt_encap to WTAP_ENCAP_WIRESHARK_UPPER_PDU, but this is a bit cleaner). (backported from commit ea60a57826624bcdf8f955af85af7130c8864018) --- ui/tap_export_pdu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c index 0b54cdff5c..c3c00188db 100644 --- a/ui/tap_export_pdu.c +++ b/ui/tap_export_pdu.c @@ -128,7 +128,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, const char *comment, int *err, /* create the fake interface data */ int_data = wtap_block_create(WTAP_BLOCK_IF_DESCR); int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data); - int_data_mand->wtap_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU; + int_data_mand->wtap_encap = exp_pdu_tap_data->pkt_encap; int_data_mand->time_units_per_second = 1000000000; /* default nanosecond resolution */ int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE_STANDARD; @@ -141,7 +141,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, const char *comment, int *err, g_array_append_val(exp_pdu_tap_data->shb_hdrs, shb_hdr); const wtap_dump_params params = { - .encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU, + .encap = exp_pdu_tap_data->pkt_encap, .snaplen = WTAP_MAX_PACKET_SIZE_STANDARD, .shb_hdrs = exp_pdu_tap_data->shb_hdrs, .idb_inf = exp_pdu_tap_data->idb_inf, @@ -180,7 +180,7 @@ exp_pdu_pre_open(const char *tap_name, const char *filter, exp_pdu_t *exp_pdu_ta GString *error_string; /* XXX: can we always assume WTAP_ENCAP_WIRESHARK_UPPER_PDU? */ - exp_pdu_tap_data->pkt_encap = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_WIRESHARK_UPPER_PDU); + exp_pdu_tap_data->pkt_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU; /* Register this tap listener now */ error_string = register_tap_listener(tap_name, /* The name of the tap we want to listen to */