diff options
author | Guy Harris <gharris@sonic.net> | 2021-02-14 00:34:10 -0800 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-02-14 00:58:46 -0800 |
commit | b8b3531883db249be80e217154c7e7fffb86f5bd (patch) | |
tree | becde2c028097baae1b38d8c13b4a9827d0de8b0 /wiretap/peekclassic.c | |
parent | 5b3c3d0682c869e6dd19a5245b1a22c90192e9ae (diff) |
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
Diffstat (limited to 'wiretap/peekclassic.c')
-rw-r--r-- | wiretap/peekclassic.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c index f1e6bb717a..4e6fa88dc9 100644 --- a/wiretap/peekclassic.c +++ b/wiretap/peekclassic.c @@ -151,6 +151,11 @@ static gboolean peekclassic_seek_read_v56(wtap *wth, gint64 seek_off, static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info); +static int peekclassic_v56_file_type_subtype = -1; +static int peekclassic_v7_file_type_subtype = -1; + +void register_peekclassic(void); + wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info) { peekclassic_header_t ep_hdr; @@ -324,13 +329,13 @@ wtap_open_return_val peekclassic_open(wtap *wth, int *err, gchar **err_info) case 5: case 6: - wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PEEKCLASSIC_V56; + wth->file_type_subtype = peekclassic_v56_file_type_subtype; wth->subtype_read = peekclassic_read_v56; wth->subtype_seek_read = peekclassic_seek_read_v56; break; case 7: - wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PEEKCLASSIC_V7; + wth->file_type_subtype = peekclassic_v7_file_type_subtype; wth->subtype_read = peekclassic_read_v7; wth->subtype_seek_read = peekclassic_seek_read_v7; break; @@ -657,6 +662,28 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh, return wtap_read_packet_bytes(fh, buf, sliceLength, err, err_info); } +static const struct file_type_subtype_info peekclassic_v56_info = { + "Savvius classic (V5 and V6)", "peekclassic56", "pkt", "tpc;apc;wpz", + FALSE, FALSE, 0, + NULL, NULL, NULL +}; + +static const struct file_type_subtype_info peekclassic_v7_info = { + "Savvius classic (V7)", "peekclassic7", "pkt", "tpc;apc;wpz", + FALSE, FALSE, 0, + NULL, NULL, NULL +}; + +void register_peekclassic(void) +{ + peekclassic_v56_file_type_subtype = + wtap_register_file_type_subtypes(&peekclassic_v56_info, + WTAP_FILE_TYPE_SUBTYPE_UNKNOWN); + peekclassic_v7_file_type_subtype = + wtap_register_file_type_subtypes(&peekclassic_v7_info, + WTAP_FILE_TYPE_SUBTYPE_UNKNOWN); +} + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * |