aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-11-22 02:52:41 +0000
committerMichael Mann <mmann78@netscape.net>2013-11-22 02:52:41 +0000
commit9ba190f2a58d862ddb5aea542d86c61f3e072097 (patch)
tree67cad714b4e582eb39ab90a8094426aa0f5077c9 /epan/dissectors
parent237c580bd74a60f9f5b8e291f747c4671076b137 (diff)
Create multiple dissection functions if packet_info->ipproto is used to distinguish behavior.
svn path=/trunk/; revision=53504
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-hip.c12
-rw-r--r--epan/dissectors/packet-rsvp.c39
-rw-r--r--epan/dissectors/packet-tivoconnect.c27
3 files changed, 55 insertions, 23 deletions
diff --git a/epan/dissectors/packet-hip.c b/epan/dissectors/packet-hip.c
index aed38fc9c0..de9fbbd4aa 100644
--- a/epan/dissectors/packet-hip.c
+++ b/epan/dissectors/packet-hip.c
@@ -408,7 +408,7 @@ static gint ett_hip_locator_data = -1;
/* Dissect the HIP packet */
static void
-dissect_hip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_hip_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp)
{
proto_tree *hip_tree, *hip_tlv_tree=NULL;
proto_item *ti, *ti_tlv;
@@ -511,7 +511,7 @@ dissect_hip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
"0x%04x (correct)",
checksum_h);
} else {
- if (checksum_h == 0 && pinfo->ipproto == IP_PROTO_UDP) {
+ if (checksum_h == 0 && udp) {
proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
offset+4, 2, checksum_h,
"0x%04x (correct)",
@@ -576,6 +576,12 @@ dissect_hip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
static void
+dissect_hip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ dissect_hip_common(tvb, pinfo, tree, FALSE);
+}
+
+static void
dissect_hip_in_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
guint32 nullbytes;
@@ -583,7 +589,7 @@ dissect_hip_in_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (nullbytes == 0)
{
tvbuff_t *newtvb = tvb_new_subset_remaining(tvb, 4);
- dissect_hip(newtvb, pinfo, tree);
+ dissect_hip_common(newtvb, pinfo, tree, TRUE);
}
}
diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c
index 70ec152e87..1d86809b5b 100644
--- a/epan/dissectors/packet-rsvp.c
+++ b/epan/dissectors/packet-rsvp.c
@@ -7176,7 +7176,7 @@ dissect_rsvp_unknown(proto_tree *ti _U_,
*------------------------------------------------------------------------------*/
static void
dissect_rsvp_msg_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- int tree_mode, rsvp_conversation_info *rsvph)
+ int tree_mode, rsvp_conversation_info *rsvph, gboolean e2ei)
{
proto_tree *rsvp_tree;
proto_tree *rsvp_header_tree;
@@ -7201,7 +7201,7 @@ dissect_rsvp_msg_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
ti = proto_tree_add_item(tree, proto_rsvp, tvb, offset, msg_length,
ENC_NA);
rsvp_tree = proto_item_add_subtree(ti, tree_mode);
- if (pinfo->ipproto == IP_PROTO_RSVPE2EI)
+ if (e2ei)
proto_item_append_text(rsvp_tree, " (E2E-IGNORE)");
proto_item_append_text(rsvp_tree, ": ");
proto_item_append_text(rsvp_tree, "%s", val_to_str_ext(message_type, &message_type_vals_ext,
@@ -7215,7 +7215,7 @@ dissect_rsvp_msg_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
ti = proto_tree_add_text(rsvp_tree, tvb, offset, 8, "RSVP Header. %s",
val_to_str_ext(message_type, &message_type_vals_ext,
"Unknown Message (%u). "));
- if (pinfo->ipproto == IP_PROTO_RSVPE2EI)
+ if (e2ei)
proto_item_append_text(ti, " (E2E-IGNORE)");
rsvp_header_tree = proto_item_add_subtree(ti, TREE(TT_HDR));
@@ -7286,7 +7286,7 @@ dissect_rsvp_msg_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
tvbuff_t *tvb_sub;
sub_len = tvb_get_ntohs(tvb, len2+6);
tvb_sub = tvb_new_subset(tvb, len2, sub_len, sub_len);
- dissect_rsvp_msg_tree(tvb_sub, pinfo, rsvp_tree, TREE(TT_BUNDLE_COMPMSG), rsvph);
+ dissect_rsvp_msg_tree(tvb_sub, pinfo, rsvp_tree, TREE(TT_BUNDLE_COMPMSG), rsvph, e2ei);
len2 += sub_len;
}
} else {
@@ -7513,7 +7513,7 @@ dissect_rsvp_msg_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
* The main loop
*------------------------------------------------------------------------------*/
static void
-dissect_rsvp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_rsvp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean e2ei)
{
guint8 message_type;
int session_off, tempfilt_off;
@@ -7523,8 +7523,6 @@ dissect_rsvp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
struct rsvp_request_key request_key, *new_request_key;
struct rsvp_request_val *request_val;
- col_set_str(pinfo->cinfo, COL_PROTOCOL,
- (pinfo->ipproto == IP_PROTO_RSVPE2EI) ? "RSVP-E2EI" : "RSVP");
col_clear(pinfo->cinfo, COL_INFO);
message_type = tvb_get_guint8(tvb, 1);
@@ -7552,7 +7550,7 @@ dissect_rsvp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
if (tree) {
- dissect_rsvp_msg_tree(tvb, pinfo, tree, TREE(TT_RSVP), rsvph);
+ dissect_rsvp_msg_tree(tvb, pinfo, tree, TREE(TT_RSVP), rsvph, e2ei);
}
/* ACK, SREFRESH and HELLO messages don't have any associated SESSION and,
@@ -7643,6 +7641,24 @@ dissect_rsvp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
tap_queue_packet(rsvp_tap, pinfo, rsvph);
}
+static int
+dissect_rsvp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
+{
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSVP");
+
+ dissect_rsvp_common(tvb, pinfo, tree, FALSE);
+ return tvb_length(tvb);
+}
+
+static int
+dissect_rsvp_e2ei(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
+{
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSVP-E2EI");
+
+ dissect_rsvp_common(tvb, pinfo, tree, TRUE);
+ return tvb_length(tvb);
+}
+
static void
register_rsvp_prefs(void)
{
@@ -9251,11 +9267,12 @@ proto_register_rsvp(void)
void
proto_reg_handoff_rsvp(void)
{
- dissector_handle_t rsvp_handle;
+ dissector_handle_t rsvp_handle, rsvpe2ei_handle;
- rsvp_handle = create_dissector_handle(dissect_rsvp, proto_rsvp);
+ rsvp_handle = new_create_dissector_handle(dissect_rsvp, proto_rsvp);
+ rsvpe2ei_handle = new_create_dissector_handle(dissect_rsvp_e2ei, proto_rsvp);
dissector_add_uint("ip.proto", IP_PROTO_RSVP, rsvp_handle);
- dissector_add_uint("ip.proto", IP_PROTO_RSVPE2EI, rsvp_handle);
+ dissector_add_uint("ip.proto", IP_PROTO_RSVPE2EI, rsvpe2ei_handle);
dissector_add_uint("udp.port", UDP_PORT_PRSVP, rsvp_handle);
rsvp_tap = register_tap("rsvp");
}
diff --git a/epan/dissectors/packet-tivoconnect.c b/epan/dissectors/packet-tivoconnect.c
index 7afb981ff8..434319df3d 100644
--- a/epan/dissectors/packet-tivoconnect.c
+++ b/epan/dissectors/packet-tivoconnect.c
@@ -44,7 +44,6 @@
#include <glib.h>
#include <epan/packet.h>
-#include <epan/ipproto.h>
/* Forward declaration we need below */
void proto_reg_handoff_tivoconnect(void);
@@ -64,7 +63,7 @@ static gint ett_tivoconnect = -1;
/* Code to actually dissect the packets */
static int
-dissect_tivoconnect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+dissect_tivoconnect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_tcp)
{
/* parsing variables */
gchar * string = NULL;
@@ -86,9 +85,7 @@ dissect_tivoconnect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d
col_set_str(pinfo->cinfo, COL_PROTOCOL, "TiVoConnect");
/* make a distinction between UDP and TCP packets */
- proto_name = pinfo->ipproto == IP_PROTO_TCP ?
- "Discovery Connection" :
- "Discovery Beacon";
+ proto_name = is_tcp ? "Discovery Connection" : "Discovery Beacon";
col_set_str(pinfo->cinfo, COL_INFO, proto_name);
@@ -191,6 +188,17 @@ dissect_tivoconnect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d
return tvb_length(tvb);
}
+static int
+dissect_tivoconnect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ return dissect_tivoconnect(tvb, pinfo, tree, TRUE);
+}
+
+static int
+dissect_tivoconnect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ return dissect_tivoconnect(tvb, pinfo, tree, FALSE);
+}
/* Register the protocol with Wireshark */
@@ -251,9 +259,10 @@ proto_register_tivoconnect(void)
void
proto_reg_handoff_tivoconnect(void)
{
- dissector_handle_t tivoconnect_handle;
+ dissector_handle_t tivoconnect_tcp_handle, tivoconnect_udp_handle;
- tivoconnect_handle = new_create_dissector_handle(dissect_tivoconnect, proto_tivoconnect);
- dissector_add_uint("udp.port", 2190, tivoconnect_handle);
- dissector_add_uint("tcp.port", 2190, tivoconnect_handle);
+ tivoconnect_tcp_handle = new_create_dissector_handle(dissect_tivoconnect_tcp, proto_tivoconnect);
+ tivoconnect_udp_handle = new_create_dissector_handle(dissect_tivoconnect_udp, proto_tivoconnect);
+ dissector_add_uint("udp.port", 2190, tivoconnect_udp_handle);
+ dissector_add_uint("tcp.port", 2190, tivoconnect_tcp_handle);
}