aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-09-09 23:44:25 -0700
committerGuy Harris <guy@alum.mit.edu>2016-09-10 06:45:08 +0000
commit4a6dde12d6fe6af05b05d4c06b10056f6508711a (patch)
tree0ec3e0c7fb77dc645366d6f7f02a2b77ef886cd4 /wiretap
parentd1cacbb1463503999981637314310a0824d9f3fe (diff)
Have "All Capture Files" match only capture files.
We support reading some types of files that aren't capture files, in case we have a dissector for that file format (because, for example, it's often transported over HTTP). Don't include them in the set of files "All Capture Files" matches; you can still look for them as they have individual entries in the drop-down menu of file type patterns. Ultimately, there should be Fileshark/TFileshark programs to read those files - and other file types, and even capture files if the goal is to look at the file structure rather than at the packets - and *that's* the program that should offer the ability to load JPEGs and so on. (No, this does not reduce the "All Capture Files" list down to a level that makes the problem in bug 12837 go away. The right way to fix *that* is to arrange, somehow, that the "All Capture Files" entry not actually list all the suffixes it matches.) Change-Id: I705bff5fcd0694c6c6a11892621a195aa7cd0264 Reviewed-on: https://code.wireshark.org/review/17619 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file_access.c95
-rw-r--r--wiretap/wtap.h22
2 files changed, 70 insertions, 47 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 1466f562ff..434ec12490 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -124,36 +124,36 @@ add_extensions(GSList *extensions, const gchar *extension,
* extension used by a number of capture file types.
*/
static const struct file_extension_info file_type_extensions_base[] = {
- { "Wireshark/tcpdump/... - pcap", "pcap;cap;dmp" },
- { "Wireshark/... - pcapng", "pcapng;ntar" },
- { "Network Monitor, Surveyor, NetScaler", "cap" },
- { "InfoVista 5View capture", "5vw" },
- { "Sniffer (DOS)", "cap;enc;trc;fdc;syc" },
- { "Cinco NetXRay, Sniffer (Windows)", "cap;caz" },
- { "Endace ERF capture", "erf" },
- { "EyeSDN USB S0/E1 ISDN trace format", "trc" },
- { "HP-UX nettl trace", "trc0;trc1" },
- { "Network Instruments Observer", "bfr" },
- { "Colasoft Capsa", "cscpkt" },
- { "Novell LANalyzer", "tr1" },
- { "Tektronix K12xx 32-bit .rf5 format", "rf5" },
- { "Savvius *Peek", "pkt;tpc;apc;wpz" },
- { "Catapult DCT2000 trace (.out format)", "out" },
- { "Micropross mplog", "mplog" },
- { "MPEG files", "mpg;mp3" },
- { "TamoSoft CommView", "ncf" },
- { "Symbian OS btsnoop", "log" },
- { "Transport-Neutral Encapsulation Format", "tnef" },
- { "XML files (including Gammu DCT3 traces)", "xml" },
- { "OS X PacketLogger", "pklg" },
- { "Daintree SNA", "dcf" },
- { "JPEG/JFIF files", "jpg;jpeg;jfif" },
- { "IPFIX File Format", "pfx;ipfix" },
- { "Aethra .aps file", "aps" },
- { "MPEG2 transport stream", "mp2t;ts;mpg" },
- { "Ixia IxVeriWave .vwr Raw 802.11 Capture", "vwr" },
- { "CAM Inspector file", "camins" },
- { "JavaScript Object Notation file", "json" }
+ { "Wireshark/tcpdump/... - pcap", TRUE, "pcap;cap;dmp" },
+ { "Wireshark/... - pcapng", TRUE, "pcapng;ntar" },
+ { "Network Monitor, Surveyor, NetScaler", TRUE, "cap" },
+ { "InfoVista 5View capture", TRUE, "5vw" },
+ { "Sniffer (DOS)", TRUE, "cap;enc;trc;fdc;syc" },
+ { "Cinco NetXRay, Sniffer (Windows)", TRUE, "cap;caz" },
+ { "Endace ERF capture", TRUE, "erf" },
+ { "EyeSDN USB S0/E1 ISDN trace format", TRUE, "trc" },
+ { "HP-UX nettl trace", TRUE, "trc0;trc1" },
+ { "Network Instruments Observer", TRUE, "bfr" },
+ { "Colasoft Capsa", TRUE, "cscpkt" },
+ { "Novell LANalyzer", TRUE, "tr1" },
+ { "Tektronix K12xx 32-bit .rf5 format", TRUE, "rf5" },
+ { "Savvius *Peek", TRUE, "pkt;tpc;apc;wpz" },
+ { "Catapult DCT2000 trace (.out format)", TRUE, "out" },
+ { "Micropross mplog", TRUE, "mplog" },
+ { "TamoSoft CommView", TRUE, "ncf" },
+ { "Symbian OS btsnoop", TRUE, "log" },
+ { "XML files (including Gammu DCT3 traces)", TRUE, "xml" },
+ { "OS X PacketLogger", TRUE, "pklg" },
+ { "Daintree SNA", TRUE, "dcf" },
+ { "IPFIX File Format", TRUE, "pfx;ipfix" },
+ { "Aethra .aps file", TRUE, "aps" },
+ { "MPEG2 transport stream", TRUE, "mp2t;ts;mpg" },
+ { "Ixia IxVeriWave .vwr Raw 802.11 Capture", TRUE, "vwr" },
+ { "CAM Inspector file", TRUE, "camins" },
+ { "MPEG files", FALSE, "mpg;mp3" },
+ { "Transport-Neutral Encapsulation Format", FALSE, "tnef" },
+ { "JPEG/JFIF files", FALSE, "jpg;jpeg;jfif" },
+ { "JavaScript Object Notation file", FALSE, "json" }
};
#define N_FILE_TYPE_EXTENSIONS (sizeof file_type_extensions_base / sizeof file_type_extensions_base[0])
@@ -253,14 +253,24 @@ wtap_get_file_extension_type_extensions(guint extension_type)
return extensions;
}
-/* Return a list of all extensions that are used by all file types,
- including compressed extensions, e.g. not just "pcap" but also
- "pcap.gz" if we can read gzipped files.
+/* Return a list of all extensions that are used by all capture file
+ types, including compressed extensions, e.g. not just "pcap" but
+ also "pcap.gz" if we can read gzipped files.
+
+ "Capture files" means "include file types that correspond to
+ collections of network packets, but not file types that
+ store data that just happens to be transported over protocols
+ such as HTTP but that aren't collections of network packets",
+ so that it could be used for "All Capture Files" without picking
+ up JPEG files or files such as that - those aren't capture files,
+ and we *do* have them listed in the long list of individual file
+ types, so omitting them from "All Capture Files" is the right
+ thing to do.
All strings in the list are allocated with g_malloc() and must be freed
with g_free(). */
GSList *
-wtap_get_all_file_extensions_list(void)
+wtap_get_all_capture_file_extensions_list(void)
{
GSList *extensions;
unsigned int i;
@@ -271,11 +281,17 @@ wtap_get_all_file_extensions_list(void)
for (i = 0; i < file_type_extensions_arr->len; i++) {
/*
- * Add all this file extension type's extensions, with
- * compressed variants.
+ * Is this a capture file, rather than one of the
+ * other random file types we can read?
*/
- extensions = add_extensions_for_file_extensions_type(i,
- extensions, compressed_file_extension_table);
+ if (file_type_extensions[i].is_capture_file) {
+ /*
+ * Yes. Add all this file extension type's
+ * extensions, with compressed variants.
+ */
+ extensions = add_extensions_for_file_extensions_type(i,
+ extensions, compressed_file_extension_table);
+ }
}
return extensions;
@@ -2068,7 +2084,8 @@ wtap_get_file_extensions_list(int file_type_subtype, gboolean include_compressed
/*
* Free a list returned by wtap_get_file_extension_type_extensions(),
- * wtap_get_all_file_extensions_list, or wtap_get_file_extensions_list().
+ * wtap_get_all_capture_file_extensions_list, or
+ * wtap_get_file_extensions_list().
*/
void
wtap_free_extensions_list(GSList *extensions)
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 20a3b188f3..7a8b1d94c2 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1359,23 +1359,29 @@ typedef struct wtap_wslua_file_info {
} wtap_wslua_file_info_t;
/*
- * For registering extensions used for capture file formats.
+ * For registering extensions used for file formats.
*
* These items are used in dialogs for opening files, so that
* the user can ask to see all capture files (as identified
* by file extension) or particular types of capture files.
*
- * Each file type has a description and a list of extensions the file
- * might have. Some file types aren't real file types, they're
- * just generic types, such as "text file" or "XML file", that can
- * be used for, among other things, captures we can read, or for
- * extensions such as ".cap" that were unimaginatively chosen by
- * several different sniffers for their file formats.
+ * Each file type has a description, a flag indicating whether it's
+ * a capture file or just some file whose contents we can dissect,
+ * and a list of extensions the file might have.
+ *
+ * Some file types aren't real file types, they're just generic types,
+ * such as "text file" or "XML file", that can be used for, among other
+ * things, captures we can read, or for extensions such as ".cap" that
+ * were unimaginatively chosen by several different sniffers for their
+ * file formats.
*/
struct file_extension_info {
/* the file type name */
const char *name;
+ /* TRUE if this is a capture file type */
+ gboolean is_capture_file;
+
/* a semicolon-separated list of file extensions used for this type */
const char *extensions;
};
@@ -1897,7 +1903,7 @@ int wtap_short_string_to_file_type_subtype(const char *short_name);
/*** various file extension functions ***/
WS_DLL_PUBLIC
-GSList *wtap_get_all_file_extensions_list(void);
+GSList *wtap_get_all_capture_file_extensions_list(void);
WS_DLL_PUBLIC
const char *wtap_default_file_extension(int filetype);
WS_DLL_PUBLIC