diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-11-11 15:49:12 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2018-11-12 23:00:44 +0000 |
commit | 1e76e1355ab2cafba517a1ba556450ded397d885 (patch) | |
tree | 3a5f314fe1170be611080700655a7aab9f42fa17 /ui/tap_export_pdu.c | |
parent | 791a9a9b8e1ad1c5f2ac31fd5fb830f6b4d30135 (diff) |
wiretap: refactor common parameters for pcapng dump routines
Four variants of wtap_dump_open_ng exists, each of them take the same
three parameters for the SHB, IDB and NRB blocks that has to be written
before packets are even written. Similarly, a lot of tools always create
these arguments based on an existing capture file session (wth).
Address the former duplication by creating a new data structure to hold
the arguments. Address the second issue by creating new helper functions
to initialize the parameters based on a wth. This refactoring should
make it easier to add the new Decryption Secrets Block (DSB).
No functional change intended.
Change-Id: I42c019dc1d48a476773459212ca213de91a55684
Reviewed-on: https://code.wireshark.org/review/30578
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'ui/tap_export_pdu.c')
-rw-r--r-- | ui/tap_export_pdu.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c index 05e017f5a0..a6eea7d924 100644 --- a/ui/tap_export_pdu.c +++ b/ui/tap_export_pdu.c @@ -140,14 +140,18 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment) exp_pdu_tap_data->shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_block_t)); g_array_append_val(exp_pdu_tap_data->shb_hdrs, shb_hdr); + const wtapng_dump_params ng_params = { + .shb_hdrs = exp_pdu_tap_data->shb_hdrs, + .idb_inf = exp_pdu_tap_data->idb_inf, + }; if (fd == 1) { exp_pdu_tap_data->wdh = wtap_dump_open_stdout_ng(WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE_STANDARD, FALSE, - exp_pdu_tap_data->shb_hdrs, exp_pdu_tap_data->idb_inf, NULL, &err); + &ng_params, &err); } else { exp_pdu_tap_data->wdh = wtap_dump_fdopen_ng(fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE_STANDARD, FALSE, - exp_pdu_tap_data->shb_hdrs, exp_pdu_tap_data->idb_inf, NULL, &err); + &ng_params, &err); } if (exp_pdu_tap_data->wdh == NULL) { g_assert(err != 0); |