diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2015-08-07 16:29:50 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-08-10 08:32:17 +0000 |
commit | e1003ee753be7523b2b62e0bd9d196fae1b4fa6b (patch) | |
tree | 461d282fdfb3344286a20c7b931b6012b108cef3 /wiretap/file_access.c | |
parent | 7fb514fe4d2da9a3898c27a2d689baf3ae4136df (diff) |
editcap: fix -T <encapsulation type> option when output format is pcapng
Right now the output encapsulation type is ignored if the output (default) format is set to pcapng.
Change-Id: Ibffaaed5979bf63ed4e3fa3b1f859a82b401d80b
Reviewed-on: https://code.wireshark.org/review/9911
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap/file_access.c')
-rw-r--r-- | wiretap/file_access.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 527fa34574..09567ba715 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -2152,6 +2152,7 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co wtapng_name_res_t *nrb_hdr, int *err) { wtap_dumper *wdh; + wtapng_if_descr_t descr, *file_int_data; /* Allocate a data structure for the output stream. */ wdh = wtap_dump_alloc_wdh(file_type_subtype, encap, snaplen, compressed, err); @@ -2164,10 +2165,21 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co wdh->nrb_hdr = nrb_hdr; /* Set Interface Description Block data */ if ((idb_inf != NULL) && (idb_inf->interface_data->len > 0)) { - wdh->interface_data = idb_inf->interface_data; - } else { - wtapng_if_descr_t descr; + guint itf_count; + wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t)); + for (itf_count = 0; itf_count < idb_inf->interface_data->len; itf_count++) { + file_int_data = &g_array_index(idb_inf->interface_data, wtapng_if_descr_t, itf_count); + if ((encap != WTAP_ENCAP_PER_PACKET) && (encap != file_int_data->wtap_encap)) { + memcpy(&descr, file_int_data, sizeof(wtapng_if_descr_t)); + descr.wtap_encap = encap; + descr.link_type = wtap_wtap_encap_to_pcap_encap(encap); + g_array_append_val(wdh->interface_data, descr); + } else { + g_array_append_val(wdh->interface_data, *file_int_data); + } + } + } else { descr.wtap_encap = encap; descr.time_units_per_second = 1000000; /* default microsecond resolution */ descr.link_type = wtap_wtap_encap_to_pcap_encap(encap); |