diff options
author | Guy Harris <gharris@sonic.net> | 2021-02-23 01:18:31 -0800 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-02-23 21:56:20 +0000 |
commit | 166159f15d24cea75934b9e435e925254d141ae9 (patch) | |
tree | f95f098cb6d119d2e2481223bab2a1db449ec7ba /extcap | |
parent | 3742f921b2e54373483df1e9e78b7421bd32bd69 (diff) | |
download | wireshark-166159f15d24cea75934b9e435e925254d141ae9.tar.gz wireshark-166159f15d24cea75934b9e435e925254d141ae9.tar.bz2 wireshark-166159f15d24cea75934b9e435e925254d141ae9.zip |
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 'extcap')
-rw-r--r-- | extcap/androiddump.c | 16 | ||||
-rw-r--r-- | extcap/etl.c | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/extcap/androiddump.c b/extcap/androiddump.c index f6ed468365..f999161aef 100644 --- a/extcap/androiddump.c +++ b/extcap/androiddump.c @@ -448,6 +448,7 @@ static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) { } #else wtap_dump_params params = WTAP_DUMP_PARAMS_INIT; + int file_type_subtype; int err = 0; gchar *err_info = NULL; @@ -455,14 +456,15 @@ static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) { params.encap = encap; params.snaplen = PACKET_LENGTH; - extcap_dumper.dumper.wtap = wtap_dump_open(fifo, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC, WTAP_UNCOMPRESSED, ¶ms, &err, &err_info); + file_type_subtype = wtap_pcap_nsec_file_type_subtype(); + extcap_dumper.dumper.wtap = wtap_dump_open(fifo, file_type_subtype, WTAP_UNCOMPRESSED, ¶ms, &err, &err_info); if (!extcap_dumper.dumper.wtap) { - cfile_dump_open_failure_message("androiddump", fifo, err, err_info, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC); + cfile_dump_open_failure_message("androiddump", fifo, err, err_info, file_type_subtype); exit(EXIT_CODE_CANNOT_SAVE_WIRETAP_DUMP); } extcap_dumper.encap = encap; if (!wtap_dump_flush(extcap_dumper.dumper.wtap, &err)) { - cfile_dump_open_failure_message("androiddump", fifo, err, NULL, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC); + cfile_dump_open_failure_message("androiddump", fifo, err, NULL, file_type_subtype); exit(EXIT_CODE_CANNOT_SAVE_WIRETAP_DUMP); } #endif @@ -520,14 +522,14 @@ static gboolean extcap_dumper_dump(struct extcap_dumper extcap_dumper, rec.rec_header.packet_header.pkt_encap = extcap_dumper.encap; if (!wtap_dump(extcap_dumper.dumper.wtap, &rec, (const guint8 *) buffer, &err, &err_info)) { - cfile_write_failure_message("androiddump", NULL, fifo, err, err_info, - 0, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC); + cfile_write_failure_message("androiddump", NULL, fifo, err, err_info, 0, + wtap_dump_file_type_subtype(extcap_dumper.dumper.wtap)); return FALSE; } if (!wtap_dump_flush(extcap_dumper.dumper.wtap, &err)) { - cfile_write_failure_message("androiddump", NULL, fifo, err, NULL, - 0, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC); + cfile_write_failure_message("androiddump", NULL, fifo, err, NULL, 0, + wtap_dump_file_type_subtype(extcap_dumper.dumper.wtap)); return FALSE; } #endif diff --git a/extcap/etl.c b/extcap/etl.c index a1725f3b96..36bdc4b749 100644 --- a/extcap/etl.c +++ b/extcap/etl.c @@ -192,7 +192,7 @@ wtap_dumper* etw_dump_open(const char* pcapng_filename, int* err, gchar** err_in params.shb_hdrs = shb_hdrs; params.idb_inf = idb_info; - pdh = wtap_dump_open(pcapng_filename, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_UNCOMPRESSED, ¶ms, err, err_info); + pdh = wtap_dump_open(pcapng_filename, wtap_pcapng_file_type_subtype(), WTAP_UNCOMPRESSED, ¶ms, err, err_info); if (shb_hdrs) { |