diff options
author | David Perry <boolean263@protonmail.com> | 2021-06-16 15:23:40 -0400 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-07-14 04:34:52 +0000 |
commit | 67b54e8b66add38e30f057d5b9421c521d95d4ca (patch) | |
tree | 04106c7c92104c5f6866e923535457b14479399b /capture_opts.c | |
parent | ff60fcf92dfc33f001e990268d060af4e97bfb7a (diff) |
tshark: allow --capture-comment when reading a file
Allows adding one or more capture comments to a new pcapng file when
tshark is reading from a file. Currently, tshark only allows setting one
capture comment, and that only when doing a live capture.
The use case for this feature is given in bug #15005.
I decided to allow multiple capture comments to match the same ability
in `editcap`.
To allow this change, I changed the function signature of
`process_cap_file()` so it takes a `capture_options` struct instead of
individual parameters that affect the capture.
Diffstat (limited to 'capture_opts.c')
-rw-r--r-- | capture_opts.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/capture_opts.c b/capture_opts.c index e4ce3e1bfb..628fe60880 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -147,6 +147,10 @@ capture_opts_cleanup(capture_options *capture_opts) capture_opts->all_ifaces = NULL; } g_free(capture_opts->save_file); + if (capture_opts->capture_comment != NULL) { + g_ptr_array_free(capture_opts->capture_comment, TRUE); + capture_opts->capture_comment = NULL; + } } /* log content of capture_opts */ @@ -800,11 +804,10 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_ switch(opt) { case LONGOPT_NUM_CAP_COMMENT: /* capture comment */ - if (capture_opts->capture_comment) { - cmdarg_err("--capture-comment can be set only once per file"); - return 1; + if (!capture_opts->capture_comment) { + capture_opts->capture_comment = g_ptr_array_new_with_free_func(g_free); } - capture_opts->capture_comment = g_strdup(optarg_str_p); + g_ptr_array_add(capture_opts->capture_comment, g_strdup(optarg_str_p)); break; case 'a': /* autostop criteria */ if (set_autostop_criterion(capture_opts, optarg_str_p) == FALSE) { |