summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorJim Young <jyoung@gsu.edu>2017-01-30 02:45:15 -0500
committerAnders Broman <a.broman58@gmail.com>2017-02-09 11:31:59 +0000
commit520a1b20660f6ce071d8b4e535f12c93a5699d6f (patch)
tree35caae71ed8b96b055aa13ed060230e0ee33c8d1 /epan
parent9e2366a2e505791a5dde59f5563aaad68af71885 (diff)
downloadwireshark-520a1b20660f6ce071d8b4e535f12c93a5699d6f.tar.gz
Make the capture file's interface description filterable
This patch introduces the frame.interface_description field. While testing this new functionality it became obvious that we have a non-optimal interaction between the existing cfile.c's cap_file_get_interface_name(), the recently added frame.interface_name field and this new frame.interface_description field. The string returned from cap_file_get_interface_name() may in fact come from one of three different sources: the idb's interface name (if it exists) or the idb's interface description (if that exists) or a default text of "unknown". The string ultimately becomes the rame.interface_name whether or not the idb had an interface name option to begin with. This behavior does not allow one to test for the simple presence of frame.interface_name. The new peer function cap_file_get_interface_description() added by this patch returns NULL instead of "unknown" if the idb does not have an interface description. Should cap_file_get_interface_name() be similarly modified to return NULL if the idb does not have an interface name? Bug: 9781 Change-Id: Ie479f373c5080c004dd22bd88919838feca71e95 Reviewed-on: https://code.wireshark.org/review/19861 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-frame.c21
-rw-r--r--epan/epan-int.h1
-rw-r--r--epan/epan.c9
-rw-r--r--epan/epan.h4
4 files changed, 29 insertions, 6 deletions
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index d5c793404f..b4f17367b4 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -75,6 +75,7 @@ static int hf_frame_color_filter_name = -1;
static int hf_frame_color_filter_text = -1;
static int hf_frame_interface_id = -1;
static int hf_frame_interface_name = -1;
+static int hf_frame_interface_description = -1;
static int hf_frame_pack_flags = -1;
static int hf_frame_pack_direction = -1;
static int hf_frame_pack_reception_type = -1;
@@ -342,21 +343,26 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
fh_tree = proto_item_add_subtree(ti, ett_frame);
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID &&
- (proto_field_is_referenced(tree, hf_frame_interface_id) ||
- proto_field_is_referenced(tree, hf_frame_interface_name))) {
+ (proto_field_is_referenced(tree, hf_frame_interface_id) || proto_field_is_referenced(tree, hf_frame_interface_name) || proto_field_is_referenced(tree, hf_frame_interface_description))) {
const char *interface_name = epan_get_interface_name(pinfo->epan, pinfo->phdr->interface_id);
+ const char *interface_description = epan_get_interface_description(pinfo->epan, pinfo->phdr->interface_id);
+ proto_tree *if_tree;
+ proto_item *if_item;
if (interface_name) {
- proto_tree *if_tree;
- proto_item *if_item;
if_item = proto_tree_add_uint_format_value(fh_tree, hf_frame_interface_id, tvb, 0, 0,
pinfo->phdr->interface_id, "%u (%s)",
pinfo->phdr->interface_id, interface_name);
if_tree = proto_item_add_subtree(if_item, ett_ifname);
proto_tree_add_string(if_tree, hf_frame_interface_name, tvb, 0, 0, interface_name);
} else {
- proto_tree_add_uint(fh_tree, hf_frame_interface_id, tvb, 0, 0, pinfo->phdr->interface_id);
+ if_item = proto_tree_add_uint(fh_tree, hf_frame_interface_id, tvb, 0, 0, pinfo->phdr->interface_id);
}
+
+ if (interface_description) {
+ if_tree = proto_item_add_subtree(if_item, ett_ifname);
+ proto_tree_add_string(if_tree, hf_frame_interface_description, tvb, 0, 0, interface_description);
+ }
}
if (pinfo->phdr->presence_flags & WTAP_HAS_PACK_FLAGS) {
@@ -816,6 +822,11 @@ proto_register_frame(void)
FT_STRING, BASE_NONE, NULL, 0x0,
"The friendly name for this interface", HFILL }},
+ { &hf_frame_interface_description,
+ { "Interface description", "frame.interface_description",
+ FT_STRING, BASE_NONE, NULL, 0x0,
+ "The descriptionfor this interface", HFILL }},
+
{ &hf_frame_pack_flags,
{ "Packet flags", "frame.packet_flags",
FT_UINT32, BASE_HEX, NULL, 0x0,
diff --git a/epan/epan-int.h b/epan/epan-int.h
index 35e91975be..15b059f388 100644
--- a/epan/epan-int.h
+++ b/epan/epan-int.h
@@ -30,6 +30,7 @@ struct epan_session {
const nstime_t *(*get_frame_ts)(void *data, guint32 frame_num);
const char *(*get_interface_name)(void *data, guint32 interface_id);
+ const char *(*get_interface_description)(void *data, guint32 interface_id);
const char *(*get_user_comment)(void *data, const frame_data *fd);
};
diff --git a/epan/epan.c b/epan/epan.c
index 54d5292fe8..e0ebd5b215 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -271,6 +271,15 @@ epan_get_interface_name(const epan_t *session, guint32 interface_id)
return NULL;
}
+const char *
+epan_get_interface_description(const epan_t *session, guint32 interface_id)
+{
+ if (session->get_interface_description)
+ return session->get_interface_description(session->data, interface_id);
+
+ return NULL;
+}
+
const nstime_t *
epan_get_frame_ts(const epan_t *session, guint32 frame_num)
{
diff --git a/epan/epan.h b/epan/epan.h
index e1dacdc390..3a1e742d14 100644
--- a/epan/epan.h
+++ b/epan/epan.h
@@ -131,7 +131,7 @@ void epan_circuit_cleanup(void);
/** A client will create one epan_t for an entire dissection session.
* A single epan_t will be used to analyze the entire sequence of packets,
* sequentially, in a single session. A session corresponds to a single
- * packet trace file. The reaons epan_t exists is that some packets in
+ * packet trace file. The reasons epan_t exists is that some packets in
* some protocols cannot be decoded without knowledge of previous packets.
* This inter-packet "state" is stored in the epan_t.
*/
@@ -143,6 +143,8 @@ WS_DLL_PUBLIC const char *epan_get_user_comment(const epan_t *session, const fra
WS_DLL_PUBLIC const char *epan_get_interface_name(const epan_t *session, guint32 interface_id);
+WS_DLL_PUBLIC const char *epan_get_interface_description(const epan_t *session, guint32 interface_id);
+
const nstime_t *epan_get_frame_ts(const epan_t *session, guint32 frame_num);
WS_DLL_PUBLIC void epan_free(epan_t *session);