- use structure instead of many global variables for channel setup

- move channel setup code to one function
- support RFC2198 dynamic payload type setup

svn path=/trunk/; revision=23898
This commit is contained in:
Tomas Kukosa 2007-12-17 12:16:38 +00:00
parent e36ade488a
commit b433163b3f
3 changed files with 364 additions and 382 deletions

View File

@ -2,8 +2,13 @@
# Copyright 2005 Anders Broman anders.broman[at]ericsson.com
# $Id$
#----------------------------------------------------------------------------------------
#.OPT
PER
ALIGNED
#.END
#.EXPORTS
#----------------------------------------------------------------------------------------
T38FaxProfile
DataProtocolCapability NO_PROT_PREFIX
OpenLogicalChannel
@ -134,7 +139,6 @@ Rfc2733Format FECCapability/rfc2733Format FECMode/rfc2733Format
#.END
#----------------------------------------------------------------------------------------
#.FN_BODY OpenLogicalChannel/forwardLogicalChannelParameters
srtp_flag = FALSE;
h245_lc_dissector = NULL;
%(DEFAULT_BODY)s
if(h223_lc_params_temp && h245_lc_dissector)
@ -643,7 +647,8 @@ if (h245_pi != NULL)
if (gefx) gefx->id = standard_oid_str;
if(strcmp(standard_oid_str,"0.0.8.235.0.3.76") == 0) { /* MIKEY */
srtp_flag = TRUE;
if (upcoming_channel)
upcoming_channel->srtp_flag = TRUE;
}
if(!h245_lc_dissector && strcmp(standard_oid_str,"0.0.8.245.1.1.1") == 0)
@ -680,178 +685,106 @@ if (h245_pi != NULL)
#----------------------------------------------------------------------------------------
#.FN_BODY UnicastAddress/iPAddress/network VAL_PTR = &value_tvb
tvbuff_t *value_tvb;
%(DEFAULT_BODY)s
if ( media_channel )
ipv4_address = tvb_get_ipv4(value_tvb, 0);
if ( media_control_channel )
rtcp_ipv4_address = tvb_get_ipv4(value_tvb, 0);
if (upcoming_channel && upcoming_channel->upcoming_addr) {
tvb_memcpy(value_tvb, upcoming_channel->upcoming_addr->addr_buf, 0, 4);
SET_ADDRESS(&upcoming_channel->upcoming_addr->addr, AT_IPv4, 4, upcoming_channel->upcoming_addr->addr_buf);
}
#.END
#----------------------------------------------------------------------------------------
#.FN_BODY UnicastAddress/iPAddress/tsapIdentifier VAL_PTR = &tsapIdentifier
guint32 tsapIdentifier;
%(DEFAULT_BODY)s
if ( media_channel )
ipv4_port = tsapIdentifier;
if ( media_control_channel )
rtcp_ipv4_port = tsapIdentifier;
if (upcoming_channel && upcoming_channel->upcoming_addr) {
upcoming_channel->upcoming_addr->port = tsapIdentifier;
}
#.END
#----------------------------------------------------------------------------------------
#.FN_HDR H2250LogicalChannelAckParameters/mediaChannel
media_channel = TRUE;
if (upcoming_channel)
upcoming_channel->upcoming_addr = &upcoming_channel->media_addr;
#.END
#.FN_FTR H2250LogicalChannelAckParameters/mediaChannel
if (upcoming_channel)
upcoming_channel->upcoming_addr = NULL;
#.END
#----------------------------------------------------------------------------------------
#.FN_HDR H2250LogicalChannelParameters/mediaChannel
media_channel = TRUE;
if (upcoming_channel)
upcoming_channel->upcoming_addr = &upcoming_channel->media_addr;
#.END
#.FN_FTR H2250LogicalChannelParameters/mediaChannel
if (upcoming_channel)
upcoming_channel->upcoming_addr = NULL;
#.END
#----------------------------------------------------------------------------------------
#.FN_HDR H2250LogicalChannelAckParameters/mediaControlChannel
media_control_channel = TRUE;
if (upcoming_channel)
upcoming_channel->upcoming_addr = &upcoming_channel->media_control_addr;
#.END
#.FN_FTR H2250LogicalChannelAckParameters/mediaControlChannel
if (upcoming_channel)
upcoming_channel->upcoming_addr = NULL;
#.END
#----------------------------------------------------------------------------------------
#.FN_HDR H2250LogicalChannelParameters/mediaControlChannel
media_control_channel = TRUE;
if (upcoming_channel)
upcoming_channel->upcoming_addr = &upcoming_channel->media_control_addr;
#.END
#----------------------------------------------------------------------------------------
#.FN_FTR H2250LogicalChannelAckParameters/mediaChannel
media_channel = FALSE;
#.END
#----------------------------------------------------------------------------------------
#.FN_FTR H2250LogicalChannelAckParameters/mediaControlChannel
media_control_channel = FALSE;
#.END
#----------------------------------------------------------------------------------------
#.FN_FTR H2250LogicalChannelParameters/mediaChannel
media_channel = FALSE;
#.END
#----------------------------------------------------------------------------------------
#.FN_FTR H2250LogicalChannelParameters/mediaControlChannel
media_control_channel = FALSE;
if (upcoming_channel)
upcoming_channel->upcoming_addr = NULL;
#.END
#----------------------------------------------------------------------------------------
#.FN_HDR OpenLogicalChannelAck/forwardMultiplexAckParameters
media_channel = FALSE;
media_control_channel = FALSE;
upcoming_channel = ep_alloc0(sizeof(channel_info_t));
#.END
#----------------------------------------------------------------------------------------
#.FN_FTR OpenLogicalChannelAck/forwardMultiplexAckParameters
if (!actx->pinfo->fd->flags.visited) {
if (codec_type && strcmp(codec_type, "t38fax")==0) {
if(ipv4_address!=0 && ipv4_port!=0 && t38_handle){
address src_addr;
src_addr.type=AT_IPv4;
src_addr.len=4;
src_addr.data=(guint8*)&ipv4_address;
t38_add_address(actx->pinfo, &src_addr, ipv4_port, 0, "H245", actx->pinfo->fd->num);
}
} else {
if(ipv4_address!=0 && ipv4_port!=0 && rtp_handle){
address src_addr;
src_addr.type=AT_IPv4;
src_addr.len=4;
src_addr.data=(guint8*)&ipv4_address;
if (srtp_flag) {
struct srtp_info *dummy_srtp_info = se_alloc0(sizeof(struct srtp_info));
srtp_add_address(actx->pinfo, &src_addr, ipv4_port, 0, "H245", actx->pinfo->fd->num, NULL, dummy_srtp_info);
} else {
rtp_add_address(actx->pinfo, &src_addr, ipv4_port, 0, "H245", actx->pinfo->fd->num, NULL);
}
}
if(rtcp_ipv4_address!=0 && rtcp_ipv4_port!=0 && rtcp_handle){
address src_addr;
src_addr.type=AT_IPv4;
src_addr.len=4;
src_addr.data=(guint8*)&rtcp_ipv4_address;
rtcp_add_address(actx->pinfo, &src_addr, rtcp_ipv4_port, 0, "H245", actx->pinfo->fd->num);
}
}
h245_setup_channels(actx->pinfo, upcoming_channel);
}
upcoming_channel = NULL;
#.END
#----------------------------------------------------------------------------------------
#.FN_HDR OpenLogicalChannel/reverseLogicalChannelParameters
srtp_flag = FALSE;
upcoming_channel = ep_alloc0(sizeof(channel_info_t));
#.END
#.FN_HDR OpenLogicalChannel/reverseLogicalChannelParameters/multiplexParameters
media_channel = FALSE;
media_control_channel = FALSE;
#.END
#----------------------------------------------------------------------------------------
#.FN_FTR OpenLogicalChannel/reverseLogicalChannelParameters/multiplexParameters
#.FN_FTR OpenLogicalChannel/reverseLogicalChannelParameters
if (!actx->pinfo->fd->flags.visited) {
if (codec_type && (strcmp(codec_type, "t38fax")==0)) {
if(ipv4_address!=0 && ipv4_port!=0 && t38_handle){
address src_addr;
src_addr.type=AT_IPv4;
src_addr.len=4;
src_addr.data=(guint8*)&ipv4_address;
t38_add_address(actx->pinfo, &src_addr, ipv4_port, 0, "H245", actx->pinfo->fd->num);
}
} else {
if(ipv4_address!=0 && ipv4_port!=0 && rtp_handle){
address src_addr;
src_addr.type=AT_IPv4;
src_addr.len=4;
src_addr.data=(guint8*)&ipv4_address;
if (srtp_flag) {
struct srtp_info *dummy_srtp_info = se_alloc0(sizeof(struct srtp_info));
srtp_add_address(actx->pinfo, &src_addr, ipv4_port, 0, "H245", actx->pinfo->fd->num, NULL, dummy_srtp_info);
} else {
rtp_add_address(actx->pinfo, &src_addr, ipv4_port, 0, "H245", actx->pinfo->fd->num, NULL);
}
}
if(rtcp_ipv4_address!=0 && rtcp_ipv4_port!=0 && rtcp_handle){
address src_addr;
src_addr.type=AT_IPv4;
src_addr.len=4;
src_addr.data=(guint8*)&rtcp_ipv4_address;
rtcp_add_address(actx->pinfo, &src_addr, rtcp_ipv4_port, 0, "H245", actx->pinfo->fd->num);
}
}
h245_setup_channels(actx->pinfo, upcoming_channel);
}
upcoming_channel = NULL;
#.END
#--- RTPPayloadType ---------------------------------------------------------------------
#.FN_HDR RTPPayloadType
rfc_number = 0;
#.END
#.FN_PARS RTPPayloadType/payloadDescriptor/rfc-number
VAL_PTR = &rfc_number
#.END
#.FN_BODY RTPPayloadType/payloadType VAL_PTR = &pt
unsigned int pt;
%(DEFAULT_BODY)s
if ((rfc_number == 2198) && upcoming_channel) {
upcoming_channel->rfc2198 = pt;
}
#.END
#--- NonStandardParameter ---------------------------------------------------------------

View File

@ -78,9 +78,7 @@ static void init_h245_packet_info(h245_packet_info *pi);
static int hf_h245_pdu_type = -1;
static int hf_h245Manufacturer = -1;
static int h245_tap = -1;
static int ett_h245 = -1;
static int h245dg_tap = -1;
static int ett_h245_returnedFunction = -1;
h245_packet_info *h245_pi=NULL;
static gboolean h245_reassembly = TRUE;
@ -206,15 +204,24 @@ static const value_string h245_AudioCapability_short_vals[] = {
/* To put the codec type only in COL_INFO when
an OLC is read */
const char* codec_type = NULL;
static guint32 ipv4_address;
static guint32 ipv4_port;
static guint32 rtcp_ipv4_address;
static guint32 rtcp_ipv4_port;
static gboolean media_channel;
static gboolean media_control_channel;
static gboolean srtp_flag;
static guint32 rfc_number;
typedef struct _unicast_addr_t {
address addr;
guint8 addr_buf[16];
guint32 port;
} unicast_addr_t;
typedef struct _channel_info_t {
unicast_addr_t *upcoming_addr;
unicast_addr_t media_addr;
unicast_addr_t media_control_addr;
unsigned int rfc2198;
gboolean srtp_flag;
} channel_info_t;
static channel_info_t *upcoming_channel = NULL;
/* NonStandardParameter */
static const char *nsiOID;
@ -225,6 +232,7 @@ static guint32 manufacturerCode;
static const value_string h245_RFC_number_vals[] = {
{ 2190, "RFC 2190 - H.263 Video Streams" },
{ 2198, "RFC 2198 - RTP Payload for Redundant Audio Data" },
{ 2429, "RFC 2429 - 1998 Version of ITU-T Rec. H.263 Video (H.263+)" },
{ 3016, "RFC 3016 - RTP Payload Format for MPEG-4 Audio/Visual Streams" },
{ 3267, "RFC 3267 - Adaptive Multi-Rate (AMR) and Adaptive Multi-Rate Wideband (AMR-WB)" },
@ -277,11 +285,57 @@ void h245_set_h223_add_lc_handle( h223_add_lc_handle_t handle )
h223_add_lc_handle = handle;
}
static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_channel)
{
gint *key;
GHashTable *rtp_dyn_payload = NULL;
if (!upcoming_channel) return;
if (codec_type && (strcmp(codec_type, "t38fax")==0)) {
if(upcoming_channel->media_addr.addr.type!=AT_NONE && upcoming_channel->media_addr.port!=0 && t38_handle){
t38_add_address(pinfo, &upcoming_channel->media_addr.addr,
upcoming_channel->media_addr.port, 0,
"H245", pinfo->fd->num);
}
} else {
if (upcoming_channel->rfc2198 > 0) {
#if GLIB_MAJOR_VERSION < 2
rtp_dyn_payload = g_hash_table_new( g_int_hash, g_int_equal);
#else
rtp_dyn_payload = g_hash_table_new_full( g_int_hash, g_int_equal, g_free, g_free);
#endif
key = g_malloc(sizeof(gint));
*key = upcoming_channel->rfc2198;
g_hash_table_insert(rtp_dyn_payload, key, g_strdup("red"));
}
if (upcoming_channel->media_addr.addr.type!=AT_NONE && upcoming_channel->media_addr.port!=0 && rtp_handle){
if (upcoming_channel->srtp_flag) {
struct srtp_info *dummy_srtp_info = se_alloc0(sizeof(struct srtp_info));
srtp_add_address(pinfo, &upcoming_channel->media_addr.addr,
upcoming_channel->media_addr.port, 0,
"H245", pinfo->fd->num, rtp_dyn_payload, dummy_srtp_info);
} else {
rtp_add_address(pinfo, &upcoming_channel->media_addr.addr,
upcoming_channel->media_addr.port, 0,
"H245", pinfo->fd->num, rtp_dyn_payload);
}
}
if(upcoming_channel->media_control_addr.addr.type!=AT_NONE && upcoming_channel->media_control_addr.port!=0 && rtcp_handle){
rtcp_add_address(pinfo, &upcoming_channel->media_control_addr.addr,
upcoming_channel->media_control_addr.port, 0,
"H245", pinfo->fd->num);
}
}
}
/* Initialize the protocol and registered fields */
int proto_h245 = -1;
#include "packet-h245-hf.c"
/* Initialize the subtree pointers */
static int ett_h245 = -1;
static int ett_h245_returnedFunction = -1;
#include "packet-h245-ett.c"
/* Forward declarations */

File diff suppressed because it is too large Load Diff