aboutsummaryrefslogtreecommitdiffstats
path: root/mergecap.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-02-23 01:18:31 -0800
committerGuy Harris <gharris@sonic.net>2021-02-23 21:56:20 +0000
commit166159f15d24cea75934b9e435e925254d141ae9 (patch)
treef95f098cb6d119d2e2481223bab2a1db449ec7ba /mergecap.c
parent3742f921b2e54373483df1e9e78b7421bd32bd69 (diff)
wiretap: eliminate the pcap/nspcap/pcapng WTAP_FILE_TYPE_SUBTYPE_ values.
Register the pcap and pcapng file types/subtypes rather than hardwiring them into the table. Call the registration routines for them directly, rather than through a generated table; they're always supposed to be there, as some code in Wireshark either writes only one of those formats or defaults to writing one of those formats. Don't run their source code through the registration-routine-finder script. Have the file type/subtype codes for them be directly exported to the libwiretap core, and provide routines to return each of them, to be used by the aforementioned code. When reporting errors with cfile_write_failure_message(), use wtap_dump_file_type_subtype() to get the file type/subtype value for the wtap_dumper to which we're writing, rather than hardcoding it. Have the "export PDU" code capable of supporting arbitrary file types/subtypes, although we currently only use pcapng. Get rid of declarations of now-static can_write_encap and dump_open routines in various headers.
Diffstat (limited to 'mergecap.c')
-rw-r--r--mergecap.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mergecap.c b/mergecap.c
index de1dc965bf..085bc1f021 100644
--- a/mergecap.c
+++ b/mergecap.c
@@ -216,7 +216,7 @@ main(int argc, char *argv[])
gboolean verbose = FALSE;
int in_file_count = 0;
guint32 snaplen = 0;
- int file_type = WTAP_FILE_TYPE_SUBTYPE_PCAPNG; /* default to pcapng format */
+ int file_type = WTAP_FILE_TYPE_SUBTYPE_UNKNOWN;
int err = 0;
gchar *err_info = NULL;
int err_fileno;
@@ -327,6 +327,10 @@ main(int argc, char *argv[])
}
}
+ /* Default to pcapng when writing. */
+ if (file_type == WTAP_FILE_TYPE_SUBTYPE_UNKNOWN)
+ file_type = wtap_pcapng_file_type_subtype();
+
cb.callback_func = merge_callback;
cb.data = NULL;
@@ -345,9 +349,13 @@ main(int argc, char *argv[])
return 1;
}
- /* setting IDB merge mode must use PCAPNG output */
- if (mode != IDB_MERGE_MODE_MAX && file_type != WTAP_FILE_TYPE_SUBTYPE_PCAPNG) {
- fprintf(stderr, "The IDB merge mode can only be used with PCAPNG output format\n");
+ /*
+ * Setting IDB merge mode must use a file format that supports
+ * (and thus requires) interface ID and information blocks.
+ */
+ if (mode != IDB_MERGE_MODE_MAX &&
+ wtap_file_type_subtype_supports_block(file_type, WTAP_BLOCK_IF_ID_AND_INFO) == BLOCK_NOT_SUPPORTED) {
+ fprintf(stderr, "The IDB merge mode can only be used with an output format that identifies interfaces\n");
status = MERGE_ERR_INVALID_OPTION;
goto clean_exit;
}