aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/vwr.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-02-14 00:34:10 -0800
committerGuy Harris <gharris@sonic.net>2021-02-14 00:58:46 -0800
commitb8b3531883db249be80e217154c7e7fffb86f5bd (patch)
treebecde2c028097baae1b38d8c13b4a9827d0de8b0 /wiretap/vwr.c
parent5b3c3d0682c869e6dd19a5245b1a22c90192e9ae (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/vwr.c')
-rw-r--r--wiretap/vwr.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/wiretap/vwr.c b/wiretap/vwr.c
index a316020a89..aec1f7c3c8 100644
--- a/wiretap/vwr.c
+++ b/wiretap/vwr.c
@@ -802,6 +802,11 @@ static float get_legacy_rate(guint8);
static float get_ht_rate(guint8, guint16);
static float get_vht_rate(guint8, guint16, guint8);
+static int vwr_80211_file_type_subtype = -1;
+static int vwr_eth_file_type_subtype = -1;
+
+void register_vwr(void);
+
/* Open a .vwr file for reading */
/* This does very little, except setting the wiretap header for a VWR file type */
/* and setting the timestamp precision to microseconds. */
@@ -836,9 +841,9 @@ wtap_open_return_val vwr_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_IXVERIWAVE;
if (fpgaVer == S2_W_FPGA || fpgaVer == S1_W_FPGA || fpgaVer == S3_W_FPGA)
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_VWR_80211;
+ wth->file_type_subtype = vwr_80211_file_type_subtype;
else if (fpgaVer == vVW510012_E_FPGA || fpgaVer == vVW510024_E_FPGA)
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_VWR_ETH;
+ wth->file_type_subtype = vwr_eth_file_type_subtype;
/*
* Add an IDB; we don't know how many interfaces were
@@ -3365,6 +3370,26 @@ vwr_process_rec_data(FILE_T fh, int rec_size,
return ret;
}
+static const struct file_type_subtype_info vwr_80211_info = {
+ "Ixia IxVeriWave .vwr Raw 802.11 Capture", "vwr80211", "vwr", NULL,
+ FALSE, FALSE, 0,
+ NULL, NULL, NULL
+};
+
+static const struct file_type_subtype_info vwr_eth_info = {
+ "Ixia IxVeriWave .vwr Raw Ethernet Capture", "vwreth", "vwr", NULL,
+ FALSE, FALSE, 0,
+ NULL, NULL, NULL
+};
+
+void register_vwr(void)
+{
+ vwr_80211_file_type_subtype = wtap_register_file_type_subtypes(&vwr_80211_info,
+ WTAP_FILE_TYPE_SUBTYPE_UNKNOWN);
+ vwr_eth_file_type_subtype = wtap_register_file_type_subtypes(&vwr_eth_info,
+ WTAP_FILE_TYPE_SUBTYPE_UNKNOWN);
+}
+
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*