aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2015-10-28 22:32:17 +0100
committerPascal Quantin <pascal.quantin@gmail.com>2015-10-30 18:08:06 +0000
commit9e54fcee5224aef800155514cac5e40d9e38a23e (patch)
tree15c31219710aa882d6d4a1b5404f46ea31e22cb6 /epan
parentd6dd50b1e33de97ed540efdf984ac1564b9c84ef (diff)
STUN: register a new conversation dissector after receiving a ConnectionBind Success Response message
According to RFC 6062, once the connection is established, data is sent as-is To stop the STUN dissector from interfering, add the ability to specify a starting frame for a conversation dissector and use it Bug: 11641 Change-Id: I65ca96bddacf70444009c0642ea22173fa68992e Reviewed-on: https://code.wireshark.org/review/11372 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/conversation.c26
-rw-r--r--epan/conversation.h11
-rw-r--r--epan/dissectors/packet-atalk.c2
-rw-r--r--epan/dissectors/packet-hartip.c2
-rw-r--r--epan/dissectors/packet-http.c2
-rw-r--r--epan/dissectors/packet-l2tp.c2
-rw-r--r--epan/dissectors/packet-snmp.c2
-rw-r--r--epan/dissectors/packet-stun.c7
-rw-r--r--epan/dissectors/packet-tcp.c4
-rw-r--r--epan/dissectors/packet-tftp.c4
10 files changed, 44 insertions, 18 deletions
diff --git a/epan/conversation.c b/epan/conversation.c
index ab5cd5e312..f63007a12a 100644
--- a/epan/conversation.c
+++ b/epan/conversation.c
@@ -172,7 +172,7 @@ conversation_create_from_template(conversation_t *conversation, const address *a
* Set the protocol dissector used for the template conversation as
* the handler of the new conversation as well.
*/
- new_conversation_from_template->dissector_handle = conversation->dissector_handle;
+ new_conversation_from_template->dissector_tree = conversation->dissector_tree;
return new_conversation_from_template;
}
@@ -712,8 +712,7 @@ conversation_new(const guint32 setup_frame, const address *addr1, const address
conversation->setup_frame = conversation->last_frame = setup_frame;
conversation->data_list = NULL;
- /* clear dissector handle */
- conversation->dissector_handle = NULL;
+ conversation->dissector_tree = wmem_tree_new(wmem_file_scope());
/* set the options and key pointer */
conversation->options = options;
@@ -1280,9 +1279,22 @@ conversation_delete_proto_data(conversation_t *conv, const int proto)
}
void
+conversation_set_dissector_from_frame_number(conversation_t *conversation,
+ const guint32 starting_frame_num, const dissector_handle_t handle)
+{
+ wmem_tree_insert32(conversation->dissector_tree, starting_frame_num, (void *)handle);
+}
+
+void
conversation_set_dissector(conversation_t *conversation, const dissector_handle_t handle)
{
- conversation->dissector_handle = handle;
+ conversation_set_dissector_from_frame_number(conversation, 0, handle);
+}
+
+dissector_handle_t
+conversation_get_dissector(conversation_t *conversation, const guint32 frame_num)
+{
+ return (dissector_handle_t)wmem_tree_lookup32_le(conversation->dissector_tree, frame_num);
}
/*
@@ -1307,10 +1319,10 @@ try_conversation_dissector(const address *addr_a, const address *addr_b, const p
if (conversation != NULL) {
int ret;
- if (conversation->dissector_handle == NULL)
+ dissector_handle_t handle = (dissector_handle_t)wmem_tree_lookup32_le(conversation->dissector_tree, pinfo->fd->num);
+ if (handle == NULL)
return FALSE;
- ret=call_dissector_only(conversation->dissector_handle, tvb, pinfo,
- tree, data);
+ ret=call_dissector_only(handle, tvb, pinfo, tree, data);
if(!ret) {
/* this packet was rejected by the dissector
* so return FALSE in case our caller wants
diff --git a/epan/conversation.h b/epan/conversation.h
index 3753c15b61..d796cde152 100644
--- a/epan/conversation.h
+++ b/epan/conversation.h
@@ -79,8 +79,8 @@ typedef struct conversation {
/* Assume that setup_frame is also the lowest frame number for now. */
guint32 last_frame; /** highest frame number in this conversation */
GSList *data_list; /** list of data associated with conversation */
- dissector_handle_t dissector_handle;
- /** handle for protocol dissector client associated with conversation */
+ wmem_tree_t *dissector_tree;
+ /** tree containing protocol dissector client associated with conversation */
guint options; /** wildcard flags */
conversation_key *key_ptr; /** pointer to the key for this conversation */
} conversation_t;
@@ -161,6 +161,13 @@ WS_DLL_PUBLIC void conversation_delete_proto_data(conversation_t *conv, const in
WS_DLL_PUBLIC void conversation_set_dissector(conversation_t *conversation,
const dissector_handle_t handle);
+
+WS_DLL_PUBLIC void conversation_set_dissector_from_frame_number(conversation_t *conversation,
+ const guint32 starting_frame_num, const dissector_handle_t handle);
+
+WS_DLL_PUBLIC dissector_handle_t conversation_get_dissector(conversation_t *conversation,
+ const guint32 frame_num);
+
/**
* Given two address/port pairs for a packet, search for a matching
* conversation and, if found and it has a conversation dissector,
diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c
index c62655a317..a02dfc27f4 100644
--- a/epan/dissectors/packet-atalk.c
+++ b/epan/dissectors/packet-atalk.c
@@ -853,7 +853,7 @@ dissect_atp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
call_dissector_with_data(zip_atp_handle, new_tvb, pinfo, tree, &aspinfo);
else {
/* XXX need a conversation_get_dissector function ? */
- if (!aspinfo.reply && !conversation->dissector_handle) {
+ if (!aspinfo.reply && !conversation_get_dissector(conversation, pinfo->fd->num)) {
dissector_handle_t sub;
/* if it's a known ASP function call ASP dissector
diff --git a/epan/dissectors/packet-hartip.c b/epan/dissectors/packet-hartip.c
index 72e768849f..444326f750 100644
--- a/epan/dissectors/packet-hartip.c
+++ b/epan/dissectors/packet-hartip.c
@@ -815,7 +815,7 @@ hartip_set_conversation(packet_info *pinfo)
&pinfo->src, &pinfo->dst, pinfo->ptype,
pinfo->srcport, 0, NO_PORT_B);
if( (conversation == NULL) ||
- (conversation->dissector_handle != hartip_udp_handle) ) {
+ (conversation_get_dissector(conversation, pinfo->fd->num) != hartip_udp_handle) ) {
conversation = conversation_new(pinfo->fd->num,
&pinfo->src, &pinfo->dst, pinfo->ptype,
pinfo->srcport, 0, NO_PORT2);
diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c
index 877e783c3d..9ba6022f2a 100644
--- a/epan/dissectors/packet-http.c
+++ b/epan/dissectors/packet-http.c
@@ -2046,7 +2046,7 @@ http_payload_subdissector(tvbuff_t *tvb, proto_tree *tree,
* conversation (e.g., one we detected heuristically or via Decode-As) call the data
* dissector directly.
*/
- if (value_is_in_range(http_tcp_range, uri_port) || (conv && conv->dissector_handle == http_handle)) {
+ if (value_is_in_range(http_tcp_range, uri_port) || (conv && conversation_get_dissector(conv, pinfo->fd->num) == http_handle)) {
call_dissector(data_handle, tvb, pinfo, tree);
} else {
/* set pinfo->{src/dst port} and call the TCP sub-dissector lookup */
diff --git a/epan/dissectors/packet-l2tp.c b/epan/dissectors/packet-l2tp.c
index 2e742dee17..cc0293c40f 100644
--- a/epan/dissectors/packet-l2tp.c
+++ b/epan/dissectors/packet-l2tp.c
@@ -2415,7 +2415,7 @@ dissect_l2tp_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
pinfo->srcport, pinfo->destport, 0);
}
- if ((conv == NULL) || (conv->dissector_handle != l2tp_udp_handle)) {
+ if ((conv == NULL) || (conversation_get_dissector(conv, pinfo->fd->num) != l2tp_udp_handle)) {
conv = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
pinfo->srcport, 0, NO_PORT2);
conversation_set_dissector(conv, l2tp_udp_handle);
diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c
index ec90e60a27..24f904ff9e 100644
--- a/epan/dissectors/packet-snmp.c
+++ b/epan/dissectors/packet-snmp.c
@@ -3329,7 +3329,7 @@ dissect_snmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
if (pinfo->destport == UDP_PORT_SNMP) {
conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
pinfo->srcport, 0, NO_PORT_B);
- if( (conversation == NULL) || (conversation->dissector_handle!=snmp_handle) ) {
+ if( (conversation == NULL) || (conversation_get_dissector(conversation, pinfo->fd->num)!=snmp_handle) ) {
conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
pinfo->srcport, 0, NO_PORT2);
conversation_set_dissector(conversation, snmp_handle);
diff --git a/epan/dissectors/packet-stun.c b/epan/dissectors/packet-stun.c
index 13885a9167..c7affc408e 100644
--- a/epan/dissectors/packet-stun.c
+++ b/epan/dissectors/packet-stun.c
@@ -1343,6 +1343,13 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
}
}
+ if (!PINFO_FD_VISITED(pinfo) && is_turn && (pinfo->ptype == PT_TCP)
+ && (msg_type_method == CONNECTION_BIND) && (msg_type_class == RESPONSE)) {
+ /* RFC 6062: after the ConnectionBind exchange, the connection is no longer framed as TURN;
+ instead, it is an unframed pass-through.
+ Starting from next frame set conversation dissector to data */
+ conversation_set_dissector_from_frame_number(conversation, pinfo->fd->num+1, data_handle);
+ }
return reported_length;
}
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c
index 657da75c78..de4f725bf7 100644
--- a/epan/dissectors/packet-tcp.c
+++ b/epan/dissectors/packet-tcp.c
@@ -4295,7 +4295,7 @@ dissect_tcpopt_rvbd_trpy(const ip_tcp_opt *optp _U_, tvbuff_t *tvb,
&pinfo->src, &pinfo->dst, pinfo->ptype,
pinfo->srcport, pinfo->destport, 0);
}
- if (conversation->dissector_handle != sport_handle) {
+ if (conversation_get_dissector(conversation, pinfo->fd->num) != sport_handle) {
conversation_set_dissector(conversation, sport_handle);
}
} else if (data_handle != NULL) {
@@ -4308,7 +4308,7 @@ dissect_tcpopt_rvbd_trpy(const ip_tcp_opt *optp _U_, tvbuff_t *tvb,
&pinfo->src, &pinfo->dst, pinfo->ptype,
pinfo->srcport, pinfo->destport, 0);
}
- if (conversation->dissector_handle != data_handle) {
+ if (conversation_get_dissector(conversation, pinfo->fd->num) != data_handle) {
conversation_set_dissector(conversation, data_handle);
}
}
diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c
index 4b50a28a29..cd91bbdecf 100644
--- a/epan/dissectors/packet-tftp.c
+++ b/epan/dissectors/packet-tftp.c
@@ -568,7 +568,7 @@ dissect_tftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
(pinfo->match_uint == pinfo->destport)) {
conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
pinfo->srcport, 0, NO_PORT_B);
- if( (conversation == NULL) || (conversation->dissector_handle != tftp_handle) ){
+ if( (conversation == NULL) || (conversation_get_dissector(conversation, pinfo->fd->num) != tftp_handle) ){
conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
pinfo->srcport, 0, NO_PORT2);
conversation_set_dissector(conversation, tftp_handle);
@@ -576,7 +576,7 @@ dissect_tftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
} else {
conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
- if( (conversation == NULL) || (conversation->dissector_handle != tftp_handle) ){
+ if( (conversation == NULL) || (conversation_get_dissector(conversation, pinfo->fd->num) != tftp_handle) ){
conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, PT_UDP,
pinfo->destport, pinfo->srcport, 0);
conversation_set_dissector(conversation, tftp_handle);