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 ea60a57826)
This commit is contained in:
John Thacker 2021-03-12 22:12:40 -05:00 committed by Guy Harris
parent 53a7984431
commit 4482949ddc
1 changed files with 3 additions and 3 deletions

View File

@ -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 */