Set up BFCP conversations

svn path=/trunk/; revision=46165
This commit is contained in:
Anders Broman 2012-11-24 17:06:08 +00:00
parent 535a8887d7
commit dff339dd1e
2 changed files with 83 additions and 29 deletions

View File

@ -381,40 +381,18 @@ dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
return offset;
}
/* Code to actually dissect BFCP packets */
static gboolean dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
static void
dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
int offset = 0;
guint8 primitive;
const gchar *str;
gint bfcp_payload_length;
proto_tree *bfcp_tree = NULL;
guint8 first_byte;
/* Size of smallest BFCP packet: 12 octets */
if (tvb_length(tvb) < 12)
return FALSE;
/* Check version and reserved bits in first byte */
first_byte = tvb_get_guint8(tvb, 0);
/* If first_byte of bfcp_packet is a combination of the
* version and the I bit. The value must be either 0x20 or 0x30
* if the bit is set, otherwise it is not BFCP.
*/
if ((first_byte != 0x20) && (first_byte != 0x30))
return FALSE;
primitive = tvb_get_guint8(tvb, 1);
if ((primitive < 1) || (primitive > 18))
return FALSE;
str = match_strval(primitive, map_bfcp_primitive);
if (NULL == str)
return FALSE;
/* Make entries in Protocol column and Info column on summary display*/
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BFCP");
@ -464,6 +442,40 @@ static gboolean dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_tree, offset, bfcp_payload_length);
} /* if(tree) */
}
static gboolean
dissect_bfcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
guint8 primitive;
guint8 first_byte;
const gchar *str;
/* Size of smallest BFCP packet: 12 octets */
if (tvb_length(tvb) < 12)
return FALSE;
/* Check version and reserved bits in first byte */
first_byte = tvb_get_guint8(tvb, 0);
/* If first_byte of bfcp_packet is a combination of the
* version and the I bit. The value must be either 0x20 or 0x30
* if the bit is set, otherwise it is not BFCP.
*/
if ((first_byte != 0x20) && (first_byte != 0x30))
return FALSE;
primitive = tvb_get_guint8(tvb, 1);
if ((primitive < 1) || (primitive > 18))
return FALSE;
str = match_strval(primitive, map_bfcp_primitive);
if (NULL == str)
return FALSE;
dissect_bfcp(tvb, pinfo, tree);
return TRUE;
}
@ -647,6 +659,8 @@ void proto_register_bfcp(void)
proto_bfcp = proto_register_protocol("Binary Floor Control Protocol",
"BFCP", "bfcp");
register_dissector("bfcp", dissect_bfcp, proto_bfcp);
bfcp_module = prefs_register_protocol(proto_bfcp,
proto_reg_handoff_bfcp);
@ -672,17 +686,17 @@ void proto_reg_handoff_bfcp(void)
{
dissector_handle_t bfcp_handle;
heur_dissector_add("tcp", dissect_bfcp, proto_bfcp);
heur_dissector_add("udp", dissect_bfcp, proto_bfcp);
bfcp_handle = new_create_dissector_handle(dissect_bfcp, proto_bfcp);
heur_dissector_add("tcp", dissect_bfcp_heur, proto_bfcp);
heur_dissector_add("udp", dissect_bfcp_heur, proto_bfcp);
bfcp_handle = create_dissector_handle(dissect_bfcp, proto_bfcp);
dissector_add_handle("tcp.port", bfcp_handle);
dissector_add_handle("udp.port", bfcp_handle);
prefs_initialized = TRUE;
}
heur_dissector_set_enabled("tcp", dissect_bfcp, proto_bfcp,
heur_dissector_set_enabled("tcp", dissect_bfcp_heur, proto_bfcp,
bfcp_enable_heuristic_dissection);
heur_dissector_set_enabled("udp", dissect_bfcp, proto_bfcp,
heur_dissector_set_enabled("udp", dissect_bfcp_heur, proto_bfcp,
bfcp_enable_heuristic_dissection);
}

View File

@ -63,6 +63,7 @@
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/tap.h>
#include <epan/conversation.h>
#include "packet-sdp.h"
#include "packet-frame.h"
@ -85,6 +86,7 @@ static dissector_handle_t sprt_handle;
static dissector_handle_t msrp_handle;
static dissector_handle_t h264_handle;
static dissector_handle_t mp4ves_handle;
static dissector_handle_t bfcp_handle;
static int sdp_tap = -1;
@ -294,6 +296,8 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
gboolean is_t38 = FALSE;
gboolean is_msrp = FALSE;
gboolean is_sprt = FALSE;
gboolean is_bfcp_udp = FALSE;
gboolean is_bfcp_tcp = FALSE;
gboolean set_rtp = FALSE;
gboolean is_ipv4_addr = FALSE;
gboolean is_ipv6_addr = FALSE;
@ -498,6 +502,8 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
(strcmp(transport_info.media_proto[n],"udptl") == 0));
/* Check if media protocol is MSRP/TCP */
is_msrp = (strcmp(transport_info.media_proto[n],"msrp/tcp") == 0);
is_bfcp_udp = (strcmp(transport_info.media_proto[n],"UDP/BFCP") == 0);
is_bfcp_tcp = (strcmp(transport_info.media_proto[n],"TCP/BFCP") == 0);
/* Check if media protocol is SPRT */
is_sprt = ((strcmp(transport_info.media_proto[n],"UDPSPRT") == 0) ||
(strcmp(transport_info.media_proto[n],"udpsprt") == 0));
@ -633,6 +639,39 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (strlen(sdp_pi->summary_str)) g_strlcat(sdp_pi->summary_str, " ", 50);
g_strlcat(sdp_pi->summary_str, "t38", 50);
}
/* Setup BFCP conversations */
if ((!pinfo->fd->flags.visited) && is_bfcp_udp && (is_ipv4_addr || is_ipv6_addr) && (port != 0)) {
conversation_t* p_conv;
address null_addr;
SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
p_conv = find_conversation( pinfo->fd->num, &src_addr, &null_addr, PT_UDP, port, 0,
NO_ADDR_B | NO_PORT_B);
if(!p_conv){
p_conv = conversation_new( pinfo->fd->num, &src_addr, &null_addr, PT_UDP,
port, 0,
NO_ADDR2 | NO_PORT2);
conversation_set_dissector(p_conv, bfcp_handle);
}
}
if ((!pinfo->fd->flags.visited) && is_bfcp_tcp && (is_ipv4_addr || is_ipv6_addr) && (port != 0)) {
conversation_t* p_conv;
address null_addr;
SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
p_conv = find_conversation( pinfo->fd->num, &src_addr, &null_addr, PT_TCP, port, 0,
NO_ADDR_B | NO_PORT_B);
if(!p_conv){
p_conv = conversation_new( pinfo->fd->num, &src_addr, &null_addr, PT_TCP,
port, 0,
NO_ADDR2 | NO_PORT2);
conversation_set_dissector(p_conv, bfcp_handle);
}
}
}
/* Free the remainded hash tables not used */
@ -2400,6 +2439,7 @@ proto_reg_handoff_sdp(void)
sprt_handle = find_dissector("sprt");
h264_handle = find_dissector("h264");
mp4ves_handle = find_dissector("mp4ves");
bfcp_handle = find_dissector("bfcp");
proto_sprt = dissector_handle_get_protocol_index(find_dissector("sprt"));