diff options
author | Christopher Kilgour <techie@whiterocker.com> | 2014-02-23 17:30:57 -0800 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-03-20 09:54:01 +0000 |
commit | 7b13a3b0f6a5617e0e352f87cc5a20afea226aa8 (patch) | |
tree | 774432cd1876744b5038ea291f10b012bd7f8288 /cfile.c | |
parent | f65513291333b5912a16b45bfa09eed05eee3a6d (diff) | |
download | wireshark-7b13a3b0f6a5617e0e352f87cc5a20afea226aa8.tar.gz wireshark-7b13a3b0f6a5617e0e352f87cc5a20afea226aa8.tar.bz2 wireshark-7b13a3b0f6a5617e0e352f87cc5a20afea226aa8.zip |
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')
-rw-r--r-- | cfile.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -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); g_free(idb_info); + 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; +} + void cap_file_init(capture_file *cf) { |