use session allocated memory for rtp_add_address/srtp_add_address hash tables

svn path=/trunk/; revision=44571
This commit is contained in:
Michael Mann 2012-08-19 00:21:26 +00:00
parent 4546cfeab5
commit 6c0e747f61
5 changed files with 31 additions and 79 deletions

View File

@ -336,15 +336,6 @@ static void update_unicast_addr(unicast_addr_t *req_addr, unicast_addr_t *ack_ad
}
}
static void free_encoding_name_str (void *ptr)
{
encoding_name_and_rate_t *encoding_name_and_rate = (encoding_name_and_rate_t *)ptr;
if (encoding_name_and_rate->encoding_name) {
g_free(encoding_name_and_rate->encoding_name);
}
}
static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_channel_lcl)
{
gint *key;
@ -365,11 +356,11 @@ static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_cha
/* (S)RTP, (S)RTCP */
if (upcoming_channel_lcl->rfc2198 > 0) {
encoding_name_and_rate_t *encoding_name_and_rate = g_malloc( sizeof(encoding_name_and_rate_t));
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, free_encoding_name_str);
encoding_name_and_rate->encoding_name = g_strdup("red");
encoding_name_and_rate_t *encoding_name_and_rate = se_alloc( sizeof(encoding_name_and_rate_t));
rtp_dyn_payload = g_hash_table_new(g_int_hash, g_int_equal);
encoding_name_and_rate->encoding_name = se_strdup("red");
encoding_name_and_rate->sample_rate = 8000;
key = g_malloc(sizeof(gint));
key = se_alloc(sizeof(gint));
*key = upcoming_channel_lcl->rfc2198;
g_hash_table_insert(rtp_dyn_payload, key, encoding_name_and_rate);
}

View File

@ -8057,17 +8057,6 @@ elem_a2p_bearer_session(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
return(curr_offset - offset);
}
static void
free_encoding_name_str(void *ptr)
{
encoding_name_and_rate_t *encoding_name_and_rate = (encoding_name_and_rate_t *) ptr;
if (encoding_name_and_rate->encoding_name)
{
g_free(encoding_name_and_rate->encoding_name);
}
}
/*
* IOS 5 4.2.90
*/
@ -8094,7 +8083,7 @@ elem_a2p_bearer_format(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
gint *key;
encoding_name_and_rate_t *encoding_name_and_rate;
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, free_encoding_name_str);
rtp_dyn_payload = g_hash_table_new(g_int_hash, g_int_equal);
rtp_dyn_payload_used = FALSE;
first_assigned_found = FALSE;
@ -8330,11 +8319,11 @@ elem_a2p_bearer_format(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
format_assigned &&
(first_assigned_found == FALSE))
{
key = (gint *) g_malloc(sizeof(gint));
key = (gint *) se_alloc(sizeof(gint));
*key = rtp_payload_type;
encoding_name_and_rate = g_malloc(sizeof(encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = g_strdup(mime_type);
encoding_name_and_rate = se_alloc(sizeof(encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = se_strdup(mime_type);
encoding_name_and_rate->sample_rate = sample_rate;
g_hash_table_insert(rtp_dyn_payload, key, encoding_name_and_rate);
@ -8347,11 +8336,11 @@ elem_a2p_bearer_format(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
if (in_band_format_assigned)
{
key = (gint *) g_malloc(sizeof(gint));
key = (gint *) se_alloc(sizeof(gint));
*key = rtp_payload_type;
encoding_name_and_rate = g_malloc(sizeof(encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = g_strdup("telephone-event");
encoding_name_and_rate = se_alloc(sizeof(encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = se_strdup("telephone-event");
encoding_name_and_rate->sample_rate = sample_rate;
g_hash_table_insert(rtp_dyn_payload, key, encoding_name_and_rate);

View File

@ -115,16 +115,6 @@ static dissector_handle_t rtp_handle;
static const char applemidi_unknown_command[] = "unknown command: 0x%04x";
static void free_encoding_name_str (void *ptr)
{
encoding_name_and_rate_t *encoding_name_and_rate = (encoding_name_and_rate_t *)ptr;
if (encoding_name_and_rate->encoding_name) {
g_free(encoding_name_and_rate->encoding_name);
}
}
static void
dissect_applemidi_common( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 command ) {
@ -312,11 +302,11 @@ dissect_applemidi_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) {
/* set dynamic payload-type 97 which is used by Apple for their RTP-MIDI implementation for this
address/port-tuple to cause RTP-dissector to call the RTP-MIDI-dissector for payload-decoding */
encoding_name_and_rate = g_malloc( sizeof( encoding_name_and_rate_t ) );
rtp_dyn_payload = g_hash_table_new_full( g_int_hash, g_int_equal, g_free, free_encoding_name_str );
encoding_name_and_rate->encoding_name = g_strdup( "rtp-midi" );
encoding_name_and_rate = se_alloc( sizeof( encoding_name_and_rate_t ) );
rtp_dyn_payload = g_hash_table_new( g_int_hash, g_int_equal );
encoding_name_and_rate->encoding_name = se_strdup( "rtp-midi" );
encoding_name_and_rate->sample_rate = 10000;
key = g_malloc( sizeof( gint ) );
key = se_alloc( sizeof( gint ) );
*key = 97;
g_hash_table_insert( rtp_dyn_payload, key, encoding_name_and_rate );
rtp_add_address( pinfo, &pinfo->src, pinfo->srcport, 0, APPLEMIDI_DISSECTOR_SHORTNAME,

View File

@ -467,15 +467,6 @@ static void update_unicast_addr(unicast_addr_t *req_addr, unicast_addr_t *ack_ad
}
}
static void free_encoding_name_str (void *ptr)
{
encoding_name_and_rate_t *encoding_name_and_rate = (encoding_name_and_rate_t *)ptr;
if (encoding_name_and_rate->encoding_name) {
g_free(encoding_name_and_rate->encoding_name);
}
}
static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_channel_lcl)
{
gint *key;
@ -496,11 +487,11 @@ static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_cha
/* (S)RTP, (S)RTCP */
if (upcoming_channel_lcl->rfc2198 > 0) {
encoding_name_and_rate_t *encoding_name_and_rate = g_malloc( sizeof(encoding_name_and_rate_t));
rtp_dyn_payload = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, free_encoding_name_str);
encoding_name_and_rate->encoding_name = g_strdup("red");
encoding_name_and_rate_t *encoding_name_and_rate = se_alloc( sizeof(encoding_name_and_rate_t));
rtp_dyn_payload = g_hash_table_new(g_int_hash, g_int_equal);
encoding_name_and_rate->encoding_name = se_strdup("red");
encoding_name_and_rate->sample_rate = 8000;
key = g_malloc(sizeof(gint));
key = se_alloc(sizeof(gint));
*key = upcoming_channel_lcl->rfc2198;
g_hash_table_insert(rtp_dyn_payload, key, encoding_name_and_rate);
}
@ -1932,7 +1923,7 @@ static int hf_h245_encrypted = -1; /* OCTET_STRING */
static int hf_h245_encryptedAlphanumeric = -1; /* EncryptedAlphanumeric */
/*--- End of included file: packet-h245-hf.c ---*/
#line 398 "../../asn1/h245/packet-h245-template.c"
#line 389 "../../asn1/h245/packet-h245-template.c"
/* Initialize the subtree pointers */
static int ett_h245 = -1;
@ -2433,7 +2424,7 @@ static gint ett_h245_FlowControlIndication = -1;
static gint ett_h245_MobileMultilinkReconfigurationIndication = -1;
/*--- End of included file: packet-h245-ett.c ---*/
#line 403 "../../asn1/h245/packet-h245-template.c"
#line 394 "../../asn1/h245/packet-h245-template.c"
/* Forward declarations */
static int dissect_h245_MultimediaSystemControlMessage(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
@ -14503,7 +14494,7 @@ static void dissect_OpenLogicalChannel_PDU(tvbuff_t *tvb _U_, packet_info *pinfo
/*--- End of included file: packet-h245-fn.c ---*/
#line 412 "../../asn1/h245/packet-h245-template.c"
#line 403 "../../asn1/h245/packet-h245-template.c"
static void
dissect_h245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
@ -20197,7 +20188,7 @@ void proto_register_h245(void) {
NULL, HFILL }},
/*--- End of included file: packet-h245-hfarr.c ---*/
#line 493 "../../asn1/h245/packet-h245-template.c"
#line 484 "../../asn1/h245/packet-h245-template.c"
};
/* List of subtrees */
@ -20700,7 +20691,7 @@ void proto_register_h245(void) {
&ett_h245_MobileMultilinkReconfigurationIndication,
/*--- End of included file: packet-h245-ettarr.c ---*/
#line 500 "../../asn1/h245/packet-h245-template.c"
#line 491 "../../asn1/h245/packet-h245-template.c"
};
module_t *h245_module;

View File

@ -270,15 +270,6 @@ static void dissect_sdp_media(tvbuff_t *tvb, proto_item *ti,
transport_info_t *transport_info);
static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_item *ti, int length, transport_info_t *transport_info);
static void free_encoding_name_str (void *ptr)
{
encoding_name_and_rate_t *encoding_name_and_rate = (encoding_name_and_rate_t *)ptr;
if (encoding_name_and_rate->encoding_name) {
g_free(encoding_name_and_rate->encoding_name);
}
}
static void
dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
@ -347,7 +338,7 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
transport_info.media_proto[n] = NULL;
transport_info.media[n].pt_count = 0;
transport_info.media[n].rtp_dyn_payload =
g_hash_table_new_full(g_int_hash, g_int_equal, g_free, free_encoding_name_str);
g_hash_table_new(g_int_hash, g_int_equal);
}
transport_info.media_count = 0;
@ -1628,7 +1619,7 @@ static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto
return; /* Invalid */
}
key = g_malloc(sizeof (gint));
key = se_alloc(sizeof (gint));
*key = atol((char*)payload_type);
transport_info->encoding_name[pt] = (char*)tvb_get_ephemeral_string(tvb, offset, tokenlen);
@ -1663,15 +1654,15 @@ static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto
*/
if (transport_info->media_count == 0) {
for (n = 0; n < SDP_MAX_RTP_CHANNELS; n++) {
encoding_name_and_rate = g_malloc(sizeof (encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = g_strdup(transport_info->encoding_name[pt]);
encoding_name_and_rate = se_alloc(sizeof (encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = se_strdup(transport_info->encoding_name[pt]);
encoding_name_and_rate->sample_rate = transport_info->sample_rate[pt];
if (n == 0) {
g_hash_table_insert(transport_info->media[n].rtp_dyn_payload,
key, encoding_name_and_rate);
} else { /* we create a new key and encoding_name to assign to the other hash tables */
gint *key2;
key2 = g_malloc(sizeof (gint));
key2 = se_alloc(sizeof (gint));
*key2 = atol((char*)payload_type);
g_hash_table_insert(transport_info->media[n].rtp_dyn_payload,
key2, encoding_name_and_rate);
@ -1681,9 +1672,9 @@ static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto
/* if the "a=" is after an "m=", only apply to this "m=" */
} else
/* in case there is an overflow in SDP_MAX_RTP_CHANNELS, we keep always the last "m=" */
encoding_name_and_rate = g_malloc(sizeof (encoding_name_and_rate_t));
encoding_name_and_rate = se_alloc(sizeof (encoding_name_and_rate_t));
encoding_name_and_rate->encoding_name = g_strdup(transport_info->encoding_name[pt]);
encoding_name_and_rate->encoding_name = se_strdup(transport_info->encoding_name[pt]);
encoding_name_and_rate->sample_rate = transport_info->sample_rate[pt];
if (transport_info->media_count == SDP_MAX_RTP_CHANNELS-1)
g_hash_table_insert(transport_info->media[ transport_info->media_count ].rtp_dyn_payload,