diff options
-rw-r--r-- | epan/dissectors/packet-kingfisher.c | 72 | ||||
-rw-r--r-- | epan/dissectors/packet-sdp.c | 59 |
2 files changed, 57 insertions, 74 deletions
diff --git a/epan/dissectors/packet-kingfisher.c b/epan/dissectors/packet-kingfisher.c index 089ffb20a7..9f566d955c 100644 --- a/epan/dissectors/packet-kingfisher.c +++ b/epan/dissectors/packet-kingfisher.c @@ -28,7 +28,7 @@ #include "config.h" #include <epan/packet.h> -#include <epan/emem.h> +#include <epan/wmem/wmem.h> #include <epan/conversation.h> #define SUPPORT_KINGFISHER_SERIES_2 @@ -181,7 +181,7 @@ kingfisher_checksum(tvbuff_t *tvb, int offset) static gboolean dissect_kingfisher(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_conv_dissector) { - kingfisher_packet_t *kfp; + kingfisher_packet_t kfp; proto_tree *kingfisher_tree=NULL; proto_item *item=NULL; const char *func_string = NULL; @@ -216,100 +216,94 @@ dissect_kingfisher(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean } - - - - kfp=ep_new(kingfisher_packet_t); - /* Verify that it looks like kingfisher */ /* the packet must be at least 9 bytes */ if(tvb_reported_length(tvb)<9){ return FALSE; } - /* the function code must be known */ - kfp->function = tvb_get_guint8( tvb, 6 ); - if (try_val_to_str(kfp->function, function_code_vals) == NULL) { + kfp.function = tvb_get_guint8( tvb, 6 ); + if (try_val_to_str(kfp.function, function_code_vals) == NULL) { /* This appears not to be a kingfisher packet */ return FALSE; } /* verify the length */ - kfp->length = tvb_get_guint8(tvb, 2); - if((kfp->length+1) != (guint8)tvb_length(tvb)){ + kfp.length = tvb_get_guint8(tvb, 2); + if((kfp.length+1) != (guint8)tvb_length(tvb)){ return FALSE; } /* verify the checksum */ - kfp->checksum = tvb_get_ntohs(tvb, kfp->length - 1); + kfp.checksum = tvb_get_ntohs(tvb, kfp.length - 1); checksum = kingfisher_checksum(tvb, 0); - if(kfp->checksum!=checksum){ + if(kfp.checksum!=checksum){ return FALSE; } - kfp->version = (kfp->function & 0x80)?3:2; - kfp->system = tvb_get_guint8( tvb, 0 ); - kfp->message = tvb_get_guint8( tvb, 5 ); + kfp.version = (kfp.function & 0x80)?3:2; + kfp.system = tvb_get_guint8( tvb, 0 ); + kfp.message = tvb_get_guint8( tvb, 5 ); - kfp->target = tvb_get_guint8( tvb, 1 ); - kfp->from = tvb_get_guint8( tvb, 3 ); - kfp->via = tvb_get_guint8( tvb, 4 ); + kfp.target = tvb_get_guint8( tvb, 1 ); + kfp.from = tvb_get_guint8( tvb, 3 ); + kfp.via = tvb_get_guint8( tvb, 4 ); - if( kfp->version == 3 ) + if( kfp.version == 3 ) { - kfp->target |= ( tvb_get_guint8( tvb, 7 ) << 8 ); - kfp->from |= ( tvb_get_guint8( tvb, 8 ) << 8 ); - kfp->via |= ( tvb_get_guint8( tvb, 9 ) << 8 ); + kfp.target |= ( tvb_get_guint8( tvb, 7 ) << 8 ); + kfp.from |= ( tvb_get_guint8( tvb, 8 ) << 8 ); + kfp.via |= ( tvb_get_guint8( tvb, 9 ) << 8 ); } /* Ok this does look like Kingfisher, so lets dissect it */ - func_string = val_to_str_const(kfp->function, function_code_vals, "Unknown function"); + func_string = val_to_str_const(kfp.function, function_code_vals, "Unknown function"); col_set_str(pinfo->cinfo, COL_PROTOCOL, "Kingfisher"); - col_add_fstr(pinfo->cinfo, COL_INFO, "%u > %u (%s)", kfp->from, kfp->target, func_string); + col_add_fstr(pinfo->cinfo, COL_INFO, "%u > %u (%s)", kfp.from, kfp.target, func_string); - message = (kfp->message & 0x0f) | ((kfp->message & 0xf0) >> 4); + message = (kfp.message & 0x0f) | ((kfp.message & 0xf0) >> 4); if(tree){ - item = proto_tree_add_protocol_format(tree, proto_kingfisher, tvb, 0, -1, "Kingfisher Protocol, From RTU: %d, Target RTU: %d", kfp->from, kfp->target ); + item = proto_tree_add_protocol_format(tree, proto_kingfisher, tvb, 0, -1, "Kingfisher Protocol, From RTU: %d, Target RTU: %d", kfp.from, kfp.target ); kingfisher_tree = proto_item_add_subtree( item, ett_kingfisher ); } /* version */ - proto_tree_add_uint(kingfisher_tree, hf_kingfisher_version, tvb, 6, 1, kfp->version); + proto_tree_add_uint(kingfisher_tree, hf_kingfisher_version, tvb, 6, 1, kfp.version); /* system id */ - proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_system, tvb, 0, 1, kfp->system, "System Identifier: %u (0x%02X)", kfp->system, kfp->system); + proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_system, tvb, 0, 1, kfp.system, "System Identifier: %u (0x%02X)", kfp.system, kfp.system); /* target rtu */ - proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_target, tvb, 1, 1, kfp->target, "Target RTU: %u (0x%02X)", kfp->target, kfp->target); + proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_target, tvb, 1, 1, kfp.target, "Target RTU: %u (0x%02X)", kfp.target, kfp.target); /* length */ - proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_length, tvb, 2, 1, kfp->length, "Length: %u (0x%02X)", kfp->length, kfp->length); + proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_length, tvb, 2, 1, kfp.length, "Length: %u (0x%02X)", kfp.length, kfp.length); /* from rtu */ - proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_from, tvb, 3, 1, kfp->from, "From RTU: %u (0x%02X)", kfp->from, kfp->from); + proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_from, tvb, 3, 1, kfp.from, "From RTU: %u (0x%02X)", kfp.from, kfp.from); /* via rtu */ - proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_via, tvb, 4, 1, kfp->via, "Via RTU: %u (0x%02X)", kfp->via, kfp->via); + proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_via, tvb, 4, 1, kfp.via, "Via RTU: %u (0x%02X)", kfp.via, kfp.via); /* message number */ - proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_message, tvb, 5, 1, kfp->message, "Message Number: %u (0x%02X, %s)", message, kfp->message, ((kfp->message & 0xf0)?"Response":"Request")); + proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_message, tvb, 5, 1, kfp.message, "Message Number: %u (0x%02X, %s)", message, kfp.message, ((kfp.message & 0xf0)?"Response":"Request")); /* message function code */ - proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_function, tvb, 6, 1, kfp->function, "Message Function Code: %u (0x%02X, %s)", kfp->function, kfp->function, func_string); + proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_function, tvb, 6, 1, kfp.function, "Message Function Code: %u (0x%02X, %s)", kfp.function, kfp.function, func_string); /* message data */ - if(kfp->length > ((kfp->version==3)?11:8)){ - proto_tree_add_text(kingfisher_tree, tvb, ((kfp->version==3)?10:7), kfp->length - ((kfp->version==3)?11:8), "Message Data"); + if(kfp.length > ((kfp.version==3)?11:8)){ + proto_tree_add_text(kingfisher_tree, tvb, ((kfp.version==3)?10:7), kfp.length - ((kfp.version==3)?11:8), "Message Data"); } /* checksum */ - proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_checksum, tvb, kfp->length-1, 2, kfp->checksum, "Checksum: 0x%04X [%s]", kfp->checksum, ((checksum != kfp->checksum)?"incorrect":"correct")); + proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_checksum, tvb, kfp.length-1, 2, kfp.checksum, "Checksum: 0x%04X [%s]", kfp.checksum, ((checksum != kfp.checksum)?"incorrect":"correct")); diff --git a/epan/dissectors/packet-sdp.c b/epan/dissectors/packet-sdp.c index e4676d448c..aa870bcb88 100644 --- a/epan/dissectors/packet-sdp.c +++ b/epan/dissectors/packet-sdp.c @@ -53,7 +53,6 @@ #include <epan/packet.h> #include <epan/strutil.h> -#include <epan/emem.h> #include <epan/wmem/wmem.h> #include <epan/base64.h> #include <epan/asn1.h> @@ -89,8 +88,8 @@ static int proto_sdp = -1; static int proto_sprt = -1; static const char* UNKNOWN_ENCODING = "Unknown"; -static emem_tree_t *sdp_transport_reqs = NULL; -static emem_tree_t *sdp_transport_rsps = NULL; +static wmem_tree_t *sdp_transport_reqs = NULL; +static wmem_tree_t *sdp_transport_rsps = NULL; /* preference globals */ static gboolean global_sdp_establish_conversation = TRUE; @@ -1204,7 +1203,7 @@ static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto return; /* Invalid */ } - key = se_new(gint); + key = wmem_new(wmem_file_scope(), gint); *key = (gint)strtol((char*)payload_type, NULL, 10); transport_info->encoding_name[pt] = (char*)tvb_get_ephemeral_string(tvb, offset, tokenlen); @@ -1239,15 +1238,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 = se_new(encoding_name_and_rate_t); - encoding_name_and_rate->encoding_name = se_strdup(transport_info->encoding_name[pt]); + encoding_name_and_rate = wmem_new(wmem_file_scope(), encoding_name_and_rate_t); + encoding_name_and_rate->encoding_name = wmem_strdup(wmem_file_scope(), 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 = se_new(gint); + key2 = wmem_new(wmem_file_scope(), gint); *key2 = (gint)strtol((char*)payload_type, NULL, 10); g_hash_table_insert(transport_info->media[n].rtp_dyn_payload, key2, encoding_name_and_rate); @@ -1257,9 +1256,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 = se_new(encoding_name_and_rate_t); + encoding_name_and_rate = wmem_new(wmem_file_scope(), encoding_name_and_rate_t); - encoding_name_and_rate->encoding_name = se_strdup(transport_info->encoding_name[pt]); + encoding_name_and_rate->encoding_name = wmem_strdup(wmem_file_scope(), transport_info->encoding_name[pt]); encoding_name_and_rate->sample_rate = transport_info->sample_rate[pt]; g_hash_table_insert(transport_info->media[ transport_info->media_count ].rtp_dyn_payload, key, encoding_name_and_rate); @@ -1662,7 +1661,7 @@ convert_disposable_media(transport_info_t* transport_info, disposable_media_info if ((media_info->connection_address != NULL) && (media_info->connection_type != NULL)) { if (strcmp(media_info->connection_type, "IP4") == 0) { - transport_info->src_addr[transport_index].data = se_alloc(4); + transport_info->src_addr[transport_index].data = wmem_alloc(wmem_file_scope(), 4); if (inet_pton(AF_INET, media_info->connection_address, (void*)transport_info->src_addr[transport_index].data) > 0) { /* connection_address could be converted to a valid ipv4 address*/ transport_info->proto_bitmask[transport_index] |= SDP_IPv4; @@ -1670,7 +1669,7 @@ convert_disposable_media(transport_info_t* transport_info, disposable_media_info transport_info->src_addr[transport_index].len = 4; } } else if (strcmp(media_info->connection_type, "IP6") == 0) { - transport_info->src_addr[transport_index].data = se_alloc(16); + transport_info->src_addr[transport_index].data = wmem_alloc(wmem_file_scope(), 16); if (inet_pton(AF_INET6, media_info->connection_address, (void*)transport_info->src_addr[transport_index].data) > 0) { /* connection_address could be converted to a valid ipv6 address*/ transport_info->proto_bitmask[transport_index] |= SDP_IPv6; @@ -1687,7 +1686,7 @@ convert_disposable_media(transport_info_t* transport_info, disposable_media_info msrp_handle) { transport_info->src_addr[transport_index].type = AT_IPv4; transport_info->src_addr[transport_index].len = 4; - transport_info->src_addr[transport_index].data = se_memdup(media_info->msrp_ipaddr, 4); + transport_info->src_addr[transport_index].data = wmem_memdup(wmem_file_scope(), media_info->msrp_ipaddr, 4); transport_info->media_port[transport_index] = media_info->msrp_port_number; } @@ -1719,9 +1718,9 @@ setup_sdp_transport(tvbuff_t *tvb, packet_info *pinfo, enum sdp_exchange_type ex memset(&media_info, 0, sizeof(media_info)); if (request_frame != 0) - transport_info = (transport_info_t*)se_tree_lookup32( sdp_transport_reqs, request_frame ); + transport_info = (transport_info_t*)wmem_tree_lookup32( sdp_transport_reqs, request_frame ); if (transport_info == NULL) { - transport_info = se_new0(transport_info_t); + transport_info = wmem_new0(wmem_file_scope(), transport_info_t); transport_info->media_count = -1; for (n = 0; n < SDP_NO_OF_PT; n++) { @@ -1734,11 +1733,11 @@ setup_sdp_transport(tvbuff_t *tvb, packet_info *pinfo, enum sdp_exchange_type ex } if (request_frame != 0) - se_tree_insert32(sdp_transport_reqs, request_frame, (void *)transport_info); + wmem_tree_insert32(sdp_transport_reqs, request_frame, (void *)transport_info); } if (exchange_type != SDP_EXCHANGE_OFFER) - se_tree_insert32(sdp_transport_rsps, pinfo->fd->num, (void *)transport_info); + wmem_tree_insert32(sdp_transport_rsps, pinfo->fd->num, (void *)transport_info); /* Offer has already been answered or rejected and hash tables freed, so * don't try to add to it @@ -1840,7 +1839,7 @@ setup_sdp_transport(tvbuff_t *tvb, packet_info *pinfo, enum sdp_exchange_type ex (transport_info->proto_bitmask[n] & (SDP_IPv4|SDP_IPv6))) { if (rtp_handle) { if (transport_info->proto_bitmask[n] & SDP_SRTP_PROTO) { - srtp_info = se_new0(struct srtp_info); + srtp_info = wmem_new0(wmem_file_scope(), struct srtp_info); if (transport_info->encryption_algorithm != SRTP_ENC_ALG_NOT_SET) { srtp_info->encryption_algorithm = transport_info->encryption_algorithm; srtp_info->auth_algorithm = transport_info->auth_algorithm; @@ -1955,9 +1954,9 @@ void setup_sdp_transport_resend(int current_frame, int request_frame) transport_info_t* transport_info = NULL; if (request_frame != 0) { - transport_info = (transport_info_t*)se_tree_lookup32( sdp_transport_reqs, request_frame ); + transport_info = (transport_info_t*)wmem_tree_lookup32( sdp_transport_reqs, request_frame ); if (transport_info != NULL) { - se_tree_insert32(sdp_transport_reqs, current_frame, (void *)transport_info); + wmem_tree_insert32(sdp_transport_reqs, current_frame, (void *)transport_info); } } } @@ -1982,15 +1981,15 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) struct srtp_info *srtp_info = NULL; /* Initialise packet info for passing to tap */ - sdp_pi = ep_new(sdp_packet_info); + sdp_pi = wmem_new(wmem_packet_scope(), sdp_packet_info); sdp_pi->summary_str[0] = '\0'; if (!pinfo->fd->flags.visited) { - transport_info = (transport_info_t*)se_tree_lookup32( sdp_transport_reqs, pinfo->fd->num ); + transport_info = (transport_info_t*)wmem_tree_lookup32( sdp_transport_reqs, pinfo->fd->num ); if (transport_info == NULL) { /* Can't find it in the requests, make sure it's not a response */ - transport_info = (transport_info_t*)se_tree_lookup32( sdp_transport_rsps, pinfo->fd->num ); + transport_info = (transport_info_t*)wmem_tree_lookup32( sdp_transport_rsps, pinfo->fd->num ); } } @@ -2182,7 +2181,7 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) (transport_info->proto_bitmask[n] & (SDP_IPv4|SDP_IPv6))) { if (rtp_handle) { if (transport_info->proto_bitmask[n] & SDP_SRTP_PROTO) { - srtp_info = se_new0(struct srtp_info); + srtp_info = wmem_new0(wmem_file_scope(), struct srtp_info); if (transport_info->encryption_algorithm != SRTP_ENC_ALG_NOT_SET) { srtp_info->encryption_algorithm = transport_info->encryption_algorithm; srtp_info->auth_algorithm = transport_info->auth_algorithm; @@ -2320,17 +2319,6 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tap_queue_packet(sdp_tap, pinfo, sdp_pi); } -static void -sdp_init(void) -{ - /* se_...() allocations are automatically cleared when a new capture starts, - so we should be safe to create the tree without any previous checks */ - sdp_transport_reqs = se_tree_create_non_persistent( - EMEM_TREE_TYPE_RED_BLACK, "sdp_transport_reqs"); - sdp_transport_rsps = se_tree_create_non_persistent( - EMEM_TREE_TYPE_RED_BLACK, "sdp_transport_rsps"); -} - void proto_register_sdp(void) { @@ -2730,7 +2718,8 @@ proto_register_sdp(void) "upon port numbers found in SDP payload", &global_sdp_establish_conversation); - register_init_routine(sdp_init); + sdp_transport_reqs = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); + sdp_transport_rsps = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); /* * Register the dissector by name, so other dissectors can |