aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-07-14 22:16:30 -0700
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-07-15 05:43:36 +0000
commit0a9ef601d201f87ff3effb8aca62c61184fd6146 (patch)
treece64e2ddc50cdf76bbc4dc785e069a50a820c7b4 /text2pcap.c
parent94ac641efabc9830bc91db1c793bf0ba42f1e46c (diff)
Clean up handling of --capture-comment.
Don't store the comments in a capture_options structure, because that's available only if we're being built with capture support, and --capture-comment can be used in TShark when reading a capture file and writing another capture file, with no live capture taking place. This means we don't handle that option in capture_opts_add_opt(); handle it in the programs that support it. Support writing multiple comments in dumpcap when capturing. These changes also fix builds without pcap, and makes --capture-comment work in Wireshark when a capture is started from the command line with -k. Update the help messages to indicate that --capture-comment adds a capture comment, it doesn't change any comment (much less "the" comment, as there isn't necessarily a single comment). Update the man pages: - not to presume that only pcapng files support file comments (even if that's true now, it might not be true in the future); - to note that multiple instances of --capture-comment are supported, and that multiple comments will be written, whether capturing or reading one file and writing another; - clarify that Wireshark doesn't *discard* SHB comments other than the first one, even though it only displays the first one;
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/text2pcap.c b/text2pcap.c
index a706027a86..2b2471f079 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -883,17 +883,20 @@ write_file_header (void)
if (use_pcapng) {
char *comment;
+ GPtrArray *comments;
comment = g_strdup_printf("Generated from input file %s.", input_filename);
+ comments = g_ptr_array_new_with_free_func(g_free);
+ g_ptr_array_add(comments, comment);
success = pcapng_write_section_header_block(output_file,
- comment,
+ comments,
NULL, /* HW */
NULL, /* OS */
get_appname_and_version(),
-1, /* section_length */
&bytes_written,
&err);
- g_free(comment);
+ g_ptr_array_free(comments, TRUE);
if (success) {
success = pcapng_write_interface_description_block(output_file,
NULL,