Create multiple dissection functions if packet_info->ipproto is used to distinguish behavior.
svn path=/trunk/; revision=53504
This commit is contained in:
parent
237c580bd7
commit
9ba190f2a5
|
@ -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)",
|
||||
|
@ -575,6 +575,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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -87,8 +87,6 @@
|
|||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
#include <epan/ipproto.h>
|
||||
|
||||
/* buffer lengths */
|
||||
#define BUFLS 32
|
||||
#define BUFLM 64
|
||||
|
@ -732,8 +730,7 @@ static guint decode_asn1_sequence(tvbuff_t *tvb, guint offset, guint len, proto_
|
|||
static void PDUreset(int count, int counr2);
|
||||
|
||||
static int
|
||||
dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) {
|
||||
|
||||
dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, struct tcpinfo *info, gboolean is_tcp) {
|
||||
ASN1_SCK asn1;
|
||||
guint cls, con, tag, len, offset, reassembled;
|
||||
gboolean def;
|
||||
|
@ -748,15 +745,13 @@ dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) {
|
|||
proto_item *hidden_item;
|
||||
PDUprops props;
|
||||
static guint lastseq;
|
||||
struct tcpinfo *info;
|
||||
gint delta;
|
||||
|
||||
pcount++;
|
||||
boffset = 0;
|
||||
|
||||
reassembled = 1; /* UDP is not a stream, and thus always reassembled .... */
|
||||
if (pinfo->ipproto == IP_PROTO_TCP) { /* we have tcpinfo */
|
||||
info = (struct tcpinfo *)data;
|
||||
if (is_tcp) { /* we have tcpinfo */
|
||||
delta = info->seq - lastseq;
|
||||
reassembled = info->is_reassembled;
|
||||
lastseq = info->seq;
|
||||
|
@ -1035,6 +1030,16 @@ dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) {
|
|||
return tvb_length(tvb);
|
||||
}
|
||||
|
||||
static int
|
||||
dissect_asn1_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) {
|
||||
return dissect_asn1(tvb, pinfo, tree, (struct tcpinfo*)data, TRUE);
|
||||
}
|
||||
|
||||
static int
|
||||
dissect_asn1_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
|
||||
return dissect_asn1(tvb, pinfo, tree, NULL, FALSE);
|
||||
}
|
||||
|
||||
/* decode an ASN.1 sequence, until we have consumed the specified length */
|
||||
static guint
|
||||
decode_asn1_sequence(tvbuff_t *tvb, guint offset, guint tlen, proto_tree *pt, int level)
|
||||
|
@ -5379,48 +5384,49 @@ proto_register_asn1(void) {
|
|||
|
||||
/* The registration hand-off routing */
|
||||
|
||||
static dissector_handle_t asn1_handle;
|
||||
static dissector_handle_t asn1_tcp_handle;
|
||||
static dissector_handle_t asn1_udp_handle;
|
||||
|
||||
static void
|
||||
register_tcp_port(guint32 port)
|
||||
{
|
||||
if (port != 0)
|
||||
dissector_add_uint("tcp.port", port, asn1_handle);
|
||||
dissector_add_uint("tcp.port", port, asn1_tcp_handle);
|
||||
}
|
||||
|
||||
static void
|
||||
unregister_tcp_port(guint32 port)
|
||||
{
|
||||
if (port != 0)
|
||||
dissector_delete_uint("tcp.port", port, asn1_handle);
|
||||
dissector_delete_uint("tcp.port", port, asn1_tcp_handle);
|
||||
}
|
||||
|
||||
static void
|
||||
register_udp_port(guint32 port)
|
||||
{
|
||||
if (port != 0)
|
||||
dissector_add_uint("udp.port", port, asn1_handle);
|
||||
dissector_add_uint("udp.port", port, asn1_udp_handle);
|
||||
}
|
||||
|
||||
static void
|
||||
unregister_udp_port(guint32 port)
|
||||
{
|
||||
if (port != 0)
|
||||
dissector_delete_uint("udp.port", port, asn1_handle);
|
||||
dissector_delete_uint("udp.port", port, asn1_udp_handle);
|
||||
}
|
||||
|
||||
static void
|
||||
register_sctp_port(guint32 port)
|
||||
{
|
||||
if (port != 0)
|
||||
dissector_add_uint("sctp.port", port, asn1_handle);
|
||||
dissector_add_uint("sctp.port", port, asn1_udp_handle);
|
||||
}
|
||||
|
||||
static void
|
||||
unregister_sctp_port(guint32 port)
|
||||
{
|
||||
if (port != 0)
|
||||
dissector_delete_uint("sctp.port", port, asn1_handle);
|
||||
dissector_delete_uint("sctp.port", port, asn1_udp_handle);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5459,7 +5465,8 @@ proto_reg_handoff_asn1(void) {
|
|||
#endif /* JUST_ONE_PORT */
|
||||
|
||||
if(!asn1_initialized) {
|
||||
asn1_handle = new_create_dissector_handle(dissect_asn1,proto_asn1);
|
||||
asn1_tcp_handle = new_create_dissector_handle(dissect_asn1_tcp,proto_asn1);
|
||||
asn1_udp_handle = new_create_dissector_handle(dissect_asn1_udp,proto_asn1);
|
||||
asn1_initialized = TRUE;
|
||||
} else { /* clean up ports and their lists */
|
||||
#ifdef JUST_ONE_PORT
|
||||
|
|
Loading…
Reference in New Issue