path: root/cfile.c
diff options
authorChristopher Kilgour <techie@whiterocker.com>2014-02-23 17:30:57 -0800
committerAnders Broman <a.broman58@gmail.com>2014-03-20 09:54:01 +0000
commit7b13a3b0f6a5617e0e352f87cc5a20afea226aa8 (patch)
tree774432cd1876744b5038ea291f10b012bd7f8288 /cfile.c
parentf65513291333b5912a16b45bfa09eed05eee3a6d (diff)
Allow pcapng interface options to be available to dissectors.
Interface options[1], and more generally pcapng options[2], are useful information that can provide improved dissector output. Prior to this change, only certain pcapng interface options were interpreted and made available to dissectors, e.g. the interface name or description. This change augments the situation by providing epan_get_interface_option( ), which returns an array of byte arrays if the option code exists (otherwise NULL). Each element of the array is a byte buffer containing the raw data of the option. An array-of-buffers is used because pcapng allows for multiple instances of the same option to be present in the file. All interface options found in a pcapng file are thus made available to the dissector. The implementation also provides infrastructure to collect options from other pcapng blocks such as the section header. Currently these options are discarded, but could be retained in the future to support more features. [1] http://www.winpcap.org/ntar/draft/PCAP-DumpFileFormat.html#sectionidb [2] http://www.winpcap.org/ntar/draft/PCAP-DumpFileFormat.html#sectionopt Change-Id: I944b6f0f03dde9b8e7d1348b76acde6f9d312f37 Reviewed-on: https://code.wireshark.org/review/331 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'cfile.c')
1 files changed, 21 insertions, 2 deletions
diff --git a/cfile.c b/cfile.c
index a689b2e11c..830e871593 100644
--- a/cfile.c
+++ b/cfile.c
@@ -29,8 +29,8 @@
#include "cfile.h"
-const char *
-cap_file_get_interface_name(void *data, guint32 interface_id)
+static const wtapng_if_descr_t *
+cap_file_get_interface_desc(void *data, guint32 interface_id)
capture_file *cf = (capture_file *) data;
wtapng_iface_descriptions_t *idb_info;
@@ -42,6 +42,13 @@ cap_file_get_interface_name(void *data, guint32 interface_id)
wtapng_if_descr = &g_array_index(idb_info->interface_data, wtapng_if_descr_t, interface_id);
+ return wtapng_if_descr;
+const char *
+cap_file_get_interface_name(void *data, guint32 interface_id)
+ const wtapng_if_descr_t *wtapng_if_descr = cap_file_get_interface_desc(data, interface_id);
if (wtapng_if_descr) {
if (wtapng_if_descr->if_name)
@@ -52,6 +59,18 @@ cap_file_get_interface_name(void *data, guint32 interface_id)
return "unknown";
+const GArray *
+cap_file_get_interface_option(void *data, guint32 interface_id, guint16 option_code)
+ const wtapng_if_descr_t *wtapng_if_descr = cap_file_get_interface_desc(data, interface_id);
+ if (wtapng_if_descr && wtapng_if_descr->if_options) {
+ gint code = (gint) option_code;
+ return (const GArray *) g_hash_table_lookup(wtapng_if_descr->if_options, &code);
+ }
+ return NULL;
cap_file_init(capture_file *cf)