diff options
author | Guy Harris <gharris@sonic.net> | 2021-02-19 14:46:42 -0800 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-02-19 23:20:24 +0000 |
commit | c80c16759ba23e29c70ec8fbe62e0a9870685a66 (patch) | |
tree | 713e51f79d78658eee7ad6eab0614d4627515d79 /wiretap | |
parent | abf9e027fcc43cc9b458fb881f4f615d314ee7f6 (diff) |
wiretap: eliminate two WTAP_FILE_TYPE_SUBTYPE_ values.
Eliminate WTAP_FILE_TYPE_SUBTYPE_ERF and
WTAP_FILE_TYPE_SUBTYPE_SYSTEMD_JOURNAL - instead, fetch the values by
name, using wtap_name_to_file_type_subtype().
This requires that wtap_init() be called before epan_init(); that's
currently the case, but put in comments to indicate why it must continue
to be the case.
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/erf.c | 25 | ||||
-rw-r--r-- | wiretap/file_access.c | 14 | ||||
-rw-r--r-- | wiretap/systemd_journal.c | 24 | ||||
-rw-r--r-- | wiretap/wtap.h | 2 |
4 files changed, 46 insertions, 19 deletions
diff --git a/wiretap/erf.c b/wiretap/erf.c index 0d7245fc3e..6ecf2db74f 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -177,6 +177,10 @@ static gboolean erf_wtap_blocks_to_erf_sections(wtap_block_t block, GPtrArray *s static guint32 erf_meta_read_tag(struct erf_meta_tag*, guint8*, guint32); +static int erf_file_type_subtype = -1; + +void register_erf(void); + static guint erf_anchor_mapping_hash(gconstpointer key) { const struct erf_anchor_mapping *anchor_map = (const struct erf_anchor_mapping*) key; @@ -542,7 +546,7 @@ extern wtap_open_return_val erf_open(wtap *wth, int *err, gchar **err_info) } /* This is an ERF file */ - wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ERF; + wth->file_type_subtype = erf_file_type_subtype; wth->snapshot_length = 0; /* not available in header, only in frame */ /* @@ -707,7 +711,7 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh, { guint64 ts = pletoh64(&erf_header->ts); - /*if ((erf_header->type & 0x7f) != ERF_TYPE_META || wth->file_type_subtype != WTAP_FILE_TYPE_SUBTYPE_ERF) {*/ + /*if ((erf_header->type & 0x7f) != ERF_TYPE_META || wth->file_type_subtype != file_type_subtype_erf) {*/ rec->rec_type = REC_TYPE_PACKET; /* * XXX: ERF_TYPE_META records should ideally be FT_SPECIFIC for display @@ -3391,6 +3395,23 @@ static void erf_close(wtap *wth) wth->priv = NULL; } +static const struct file_type_subtype_info erf_info = { + "Endace ERF capture", "erf", "erf", NULL, + FALSE, TRUE, WTAP_COMMENT_PER_SECTION|WTAP_COMMENT_PER_INTERFACE|WTAP_COMMENT_PER_PACKET, + erf_dump_can_write_encap, erf_dump_open, NULL +}; + +void register_erf(void) +{ + erf_file_type_subtype = wtap_register_file_type_subtypes(&erf_info); + + /* + * Register name for backwards compatibility with the + * wtap_filetypes table in Lua. + */ + wtap_register_backwards_compatibility_lua_name("ERF", erf_file_type_subtype); +} + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 86b92602df..bc5c0bda21 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -1285,16 +1285,6 @@ static const struct file_type_subtype_info file_type_subtype_table_base[] = { { "ASN.1 Basic Encoding Rules", "ber", NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL }, - - /* WTAP_FILE_TYPE_SUBTYPE_ERF */ - { "Endace ERF capture", "erf", "erf", NULL, - FALSE, TRUE, WTAP_COMMENT_PER_SECTION|WTAP_COMMENT_PER_INTERFACE|WTAP_COMMENT_PER_PACKET, - erf_dump_can_write_encap, erf_dump_open, NULL }, - - /* WTAP_FILE_TYPE_SUBTYPE_SYSTEMD_JOURNAL */ - { "systemd journal export", "systemd_journal", NULL, NULL, - FALSE, FALSE, 0, - NULL, NULL, NULL } }; #define N_DUMP_OPEN_TABLE_BASE_ENTRIES (sizeof(file_type_subtype_table_base) / sizeof(struct file_type_subtype_info)) @@ -2841,10 +2831,6 @@ wtap_register_backwards_compatibility_lua_name(const char *name, int ft) WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0); wtap_register_backwards_compatibility_lua_name("BER", WTAP_FILE_TYPE_SUBTYPE_BER); - wtap_register_backwards_compatibility_lua_name("ERF", - WTAP_FILE_TYPE_SUBTYPE_ERF); - wtap_register_backwards_compatibility_lua_name("SYSTEMD_JOURNAL", - WTAP_FILE_TYPE_SUBTYPE_SYSTEMD_JOURNAL); } entry.name = name; entry.ft = ft; diff --git a/wiretap/systemd_journal.c b/wiretap/systemd_journal.c index 4414404199..621241e8f8 100644 --- a/wiretap/systemd_journal.c +++ b/wiretap/systemd_journal.c @@ -62,6 +62,10 @@ static gboolean systemd_journal_read_export_entry(FILE_T fh, wtap_rec *rec, #define FLD__REALTIME_TIMESTAMP "__REALTIME_TIMESTAMP=" #define FLD__MONOTONIC_TIMESTAMP "__MONOTONIC_TIMESTAMP=" +static int systemd_journal_file_type_subtype = -1; + +void register_systemd_journal(void); + wtap_open_return_val systemd_journal_open(wtap *wth, int *err _U_, gchar **err_info _U_) { gchar *entry_buff = (gchar*) g_malloc(MAX_EXPORT_ENTRY_LENGTH); @@ -97,7 +101,7 @@ wtap_open_return_val systemd_journal_open(wtap *wth, int *err _U_, gchar **err_i return WTAP_OPEN_NOT_MINE; } - wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_SYSTEMD_JOURNAL; + wth->file_type_subtype = systemd_journal_file_type_subtype; wth->subtype_read = systemd_journal_read; wth->subtype_seek_read = systemd_journal_seek_read; wth->file_encap = WTAP_ENCAP_SYSTEMD_JOURNAL; @@ -232,6 +236,24 @@ systemd_journal_read_export_entry(FILE_T fh, wtap_rec *rec, Buffer *buf, int *er return TRUE; } +static const struct file_type_subtype_info systemd_journal_info = { + "systemd journal export", "systemd_journal", NULL, NULL, + FALSE, FALSE, 0, + NULL, NULL, NULL +}; + +void register_systemd_journal(void) +{ + systemd_journal_file_type_subtype = wtap_register_file_type_subtypes(&systemd_journal_info); + + /* + * Register name for backwards compatibility with the + * wtap_filetypes table in Lua. + */ + wtap_register_backwards_compatibility_lua_name("SYSTEMD_JOURNAL", + systemd_journal_file_type_subtype); +} + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 2a0ecfb4f8..40006d829f 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -312,8 +312,6 @@ extern "C" { #define WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0 9 #define WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0 10 #define WTAP_FILE_TYPE_SUBTYPE_BER 11 -#define WTAP_FILE_TYPE_SUBTYPE_ERF 12 -#define WTAP_FILE_TYPE_SUBTYPE_SYSTEMD_JOURNAL 13 /* timestamp precision (currently only these values are supported) */ #define WTAP_TSPREC_UNKNOWN -2 |