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>
This commit is contained in:
parent
d1cacbb146
commit
4a6dde12d6
@ -379,16 +379,15 @@ QStringList CaptureFileDialog::buildFileOpenTypeList() {
|
||||
filters << QString(tr("All Files (" ALL_FILES_WILDCARD ")"));
|
||||
|
||||
/*
|
||||
* Add an "All Capture Files" entry, with all the extensions we
|
||||
* know about.
|
||||
* Add an "All Capture Files" entry, with all the capture file
|
||||
* extensions we know about.
|
||||
*/
|
||||
filter = tr("All Capture Files");
|
||||
|
||||
/*
|
||||
* Construct its list of patterns from a list of all extensions
|
||||
* we support.
|
||||
* Construct its list of patterns.
|
||||
*/
|
||||
extensions_list = wtap_get_all_file_extensions_list();
|
||||
extensions_list = wtap_get_all_capture_file_extensions_list();
|
||||
sep = " (";
|
||||
for (extension = extensions_list; extension != NULL;
|
||||
extension = g_slist_next(extension)) {
|
||||
|
@ -1488,19 +1488,18 @@ build_file_open_type_list(void) {
|
||||
sa = g_array_append_val(sa, zero);
|
||||
|
||||
/*
|
||||
* Add an "All Capture Files" entry, with all the extensions we
|
||||
* know about.
|
||||
* Add an "All Capture Files" entry, with all the capture file
|
||||
* extensions we know about.
|
||||
*/
|
||||
str16 = utf_8to16("All Capture Files");
|
||||
sa = g_array_append_vals(sa, str16, (guint) strlen("All Capture Files"));
|
||||
sa = g_array_append_val(sa, zero);
|
||||
|
||||
/*
|
||||
* Construct its list of patterns from a list of all extensions
|
||||
* we support.
|
||||
* Construct its list of patterns.
|
||||
*/
|
||||
pattern_str = g_string_new("");
|
||||
extensions_list = wtap_get_all_file_extensions_list();
|
||||
extensions_list = wtap_get_all_capture_file_extensions_list();
|
||||
sep = '\0';
|
||||
for (extension = extensions_list; extension != NULL;
|
||||
extension = g_slist_next(extension)) {
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user