From 08d49ff2e06cb35dc9084735aa60c83686afdd9c Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Mon, 25 Jan 2016 20:17:21 -0500 Subject: Making wiretap option blocks more generic. This was inspired by https://code.wireshark.org/review/9729/, but takes it in a different direction where all options are put into an array, regardless of whether they are "standard" or "custom". It should be easier to add "custom" options in this design. Some, but not all blocks have been converted. Descriptions of some of the block options have been moved from wtap.h to pcapng.h as it seems to be the one that implements the description of the blocks. Also what could be added/refactored is registering block behavior. Change-Id: I3dffa38f0bb088f98749a4f97a3b7655baa4aa6a Reviewed-on: https://code.wireshark.org/review/13667 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- editcap.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'editcap.c') diff --git a/editcap.c b/editcap.c index fdb80c8d09..d6c2392c56 100644 --- a/editcap.c +++ b/editcap.c @@ -89,6 +89,8 @@ #include #include #include +#include +#include #include "ringbuffer.h" /* For RINGBUFFER_MAX_NUM_FILES */ @@ -936,9 +938,9 @@ get_editcap_runtime_info(GString *str) static wtap_dumper * editcap_dump_open(const char *filename, guint32 snaplen, - wtapng_section_t *shb_hdr, + wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf, - wtapng_name_res_t *nrb_hdr, int *write_err) + wtap_optionblock_t nrb_hdr, int *write_err) { wtap_dumper *pdh; @@ -998,8 +1000,9 @@ main(int argc, char *argv[]) const struct wtap_pkthdr *phdr; struct wtap_pkthdr temp_phdr; wtapng_iface_descriptions_t *idb_inf = NULL; - wtapng_section_t *shb_hdr = NULL; - wtapng_name_res_t *nrb_hdr = NULL; + wtap_optionblock_t shb_hdr = NULL; + wtap_optionblock_t nrb_hdr = NULL; + char *shb_user_appl; #ifdef HAVE_PLUGINS char* init_progfile_dir_error; @@ -1410,8 +1413,11 @@ main(int argc, char *argv[]) g_assert(filename); /* If we don't have an application name add Editcap */ - if (shb_hdr->shb_user_appl == NULL) { - shb_hdr->shb_user_appl = g_strdup("Editcap " VERSION); + wtap_optionblock_get_option_string(shb_hdr, OPT_SHB_USERAPPL, &shb_user_appl); + if (shb_user_appl == NULL) { + shb_user_appl = g_strdup("Editcap " VERSION); + wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, shb_user_appl); + g_free(shb_user_appl); } pdh = editcap_dump_open(filename, @@ -1873,9 +1879,9 @@ main(int argc, char *argv[]) wtap_strerror(write_err)); goto error_on_exit; } - wtap_free_shb(shb_hdr); + wtap_optionblock_free(shb_hdr); shb_hdr = NULL; - wtap_free_nrb(nrb_hdr); + wtap_optionblock_free(nrb_hdr); nrb_hdr = NULL; g_free(filename); @@ -1899,8 +1905,8 @@ main(int argc, char *argv[]) return 0; error_on_exit: - wtap_free_shb(shb_hdr); - wtap_free_nrb(nrb_hdr); + wtap_optionblock_free(shb_hdr); + wtap_optionblock_free(nrb_hdr); g_free(idb_inf); exit(2); } -- cgit v1.2.1