aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-01-20 11:05:06 +0000
committerGuy Harris <guy@alum.mit.edu>2005-01-20 11:05:06 +0000
commit588631b328fef5049aba59001ff215d28b4cc081 (patch)
treefda5fc7fbbe1c6d2a1f7cd68dceab9a5bf96df3d
parentb6f063232337d5e1de54f818122e484b532b9fb5 (diff)
downloadwireshark-588631b328fef5049aba59001ff215d28b4cc081.tar.gz
wireshark-588631b328fef5049aba59001ff215d28b4cc081.tar.bz2
wireshark-588631b328fef5049aba59001ff215d28b4cc081.zip
From Julien Leproust: add heuristic dissectors' protocol names to the
layers string. Remove protocol names from the layer names string if the dissector rejects the frame. svn path=/trunk/; revision=13135
-rw-r--r--AUTHORS1
-rw-r--r--epan/packet.c46
2 files changed, 46 insertions, 1 deletions
diff --git a/AUTHORS b/AUTHORS
index f80e073fdb..5e0f6c1426 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -2372,6 +2372,7 @@ Brett Kuskie <mstrprgmmr [AT] chek.com>
Brian Caswell <bmc [AT] sourcefire.com>
Yann <yann_eads [AT] hotmail.com>
Jon Ringle <ml-ethereal [AT] ringle.org>
+Julien Leproust <julien.leproust [AT] ercom.fr>
Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c.
diff --git a/epan/packet.c b/epan/packet.c
index f6c67e9541..770baa2875 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -403,6 +403,7 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb,
volatile address save_net_dst;
volatile address save_src;
volatile address save_dst;
+ gint saved_layer_names_len = 0;
if (handle->protocol != NULL &&
!proto_is_protocol_enabled(handle->protocol)) {
@@ -415,6 +416,9 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb,
saved_proto = pinfo->current_proto;
saved_can_desegment = pinfo->can_desegment;
+ if (pinfo->layer_names != NULL)
+ saved_layer_names_len = pinfo->layer_names->len;
+
/*
* can_desegment is set to 2 by anyone which offers the
* desegmentation api/service.
@@ -440,7 +444,7 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb,
if (pinfo->layer_names->len > 0)
g_string_append(pinfo->layer_names, ":");
g_string_append(pinfo->layer_names,
- proto_get_protocol_filter_name(proto_get_id(handle->protocol)));
+ proto_get_protocol_filter_name(proto_get_id(handle->protocol)));
}
}
@@ -536,6 +540,18 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb,
*/
ret = call_dissector_through_handle(handle, tvb, pinfo, tree);
}
+
+ if (ret == 0) {
+ /*
+ * That dissector didn't accept the packet, so
+ * remove its protocol's name from the list
+ * of protocols.
+ */
+ if (pinfo->layer_names != NULL) {
+ g_string_truncate(pinfo->layer_names,
+ saved_layer_names_len);
+ }
+ }
pinfo->current_proto = saved_proto;
pinfo->can_desegment = saved_can_desegment;
return ret;
@@ -1437,6 +1453,7 @@ dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
GSList *entry;
heur_dtbl_entry_t *dtbl_entry;
guint16 saved_can_desegment;
+ gint saved_layer_names_len = 0;
/* can_desegment is set to 2 by anyone which offers this api/service.
then everytime a subdissector is called it is decremented by one.
@@ -1453,10 +1470,15 @@ dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
status = FALSE;
saved_proto = pinfo->current_proto;
+
+ if (pinfo->layer_names != NULL)
+ saved_layer_names_len = pinfo->layer_names->len;
+
for (entry = sub_dissectors; entry != NULL; entry = g_slist_next(entry)) {
/* XXX - why set this now and above? */
pinfo->can_desegment = saved_can_desegment-(saved_can_desegment>0);
dtbl_entry = (heur_dtbl_entry_t *)entry->data;
+
if (dtbl_entry->protocol != NULL &&
!proto_is_protocol_enabled(dtbl_entry->protocol)) {
/*
@@ -1469,9 +1491,31 @@ dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
pinfo->current_proto =
proto_get_protocol_short_name(dtbl_entry->protocol);
}
+
+ /*
+ * Add the protocol name to the layers; we'll remove it
+ * if the dissector fails.
+ */
+ if (pinfo->layer_names) {
+ if (pinfo->layer_names->len > 0)
+ g_string_append(pinfo->layer_names, ":");
+ g_string_append(pinfo->layer_names,
+ proto_get_protocol_filter_name(proto_get_id(dtbl_entry->protocol)));
+ }
+
if ((*dtbl_entry->dissector)(tvb, pinfo, tree)) {
status = TRUE;
break;
+ } else {
+ /*
+ * That dissector didn't accept the packet, so
+ * remove its protocol's name from the list
+ * of protocols.
+ */
+ if (pinfo->layer_names != NULL) {
+ g_string_truncate(pinfo->layer_names,
+ saved_layer_names_len);
+ }
}
}
pinfo->current_proto = saved_proto;