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/nettrace_3gpp_32_423.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/nettrace_3gpp_32_423.c')
-rw-r--r-- | wiretap/nettrace_3gpp_32_423.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c index 6fa13b7f62..a64162e6cd 100644 --- a/wiretap/nettrace_3gpp_32_423.c +++ b/wiretap/nettrace_3gpp_32_423.c @@ -111,6 +111,10 @@ typedef struct exported_pdu_info { #define EXP_PDU_TAG_COL_PROT_BIT 0x0200 +static int nettrace_3gpp_32_423_file_type_subtype = -1; + +void register_nettrace_3gpp_32_423(void); + /* Parse a string IPv4 or IPv6 address into bytes for exported_pdu_info. * Also parses the port pairs and transport layer type. */ @@ -815,7 +819,7 @@ nettrace_3gpp_32_423_file_open(wtap *wth, int *err, gchar **err_info) file_info->buffer = g_byte_array_sized_new(RINGBUFFER_START_SIZE); g_byte_array_append(file_info->buffer, curr_pos, (guint)(bytes_read - (curr_pos - magic_buf))); - wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NETTRACE_3GPP_32_423; + wth->file_type_subtype = nettrace_3gpp_32_423_file_type_subtype; wth->file_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU; wth->file_tsprec = WTAP_TSPREC_MSEC; wth->subtype_read = nettrace_read; @@ -827,6 +831,20 @@ nettrace_3gpp_32_423_file_open(wtap *wth, int *err, gchar **err_info) return WTAP_OPEN_MINE; } +static const struct file_type_subtype_info nettrace_3gpp_32_423_info = { + /* WTAP_FILE_TYPE_SUBTYPE_NETTRACE_3GPP_32_423 */ + "3GPP TS 32.423 Trace", "3gpp32423", NULL, NULL, + FALSE, FALSE, 0, + NULL, NULL, NULL +}; + +void register_nettrace_3gpp_32_423(void) +{ + nettrace_3gpp_32_423_file_type_subtype = + wtap_register_file_type_subtypes(&nettrace_3gpp_32_423_info, + WTAP_FILE_TYPE_SUBTYPE_UNKNOWN); +} + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * |