From 09bd9ad788f8d51c874677eef9b5180f3b8c1e70 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sun, 27 Oct 2013 02:00:18 +0000 Subject: Have ANSI TCAP dissector pass data through subdissector parameter instead of using struct _packet_info. svn path=/trunk/; revision=52885 --- asn1/ansi_map/packet-ansi_map-template.c | 129 ++++++++++++++----------------- 1 file changed, 59 insertions(+), 70 deletions(-) (limited to 'asn1/ansi_map') diff --git a/asn1/ansi_map/packet-ansi_map-template.c b/asn1/ansi_map/packet-ansi_map-template.c index 5faa0f6810..7f048ba62c 100644 --- a/asn1/ansi_map/packet-ansi_map-template.c +++ b/asn1/ansi_map/packet-ansi_map-template.c @@ -401,9 +401,8 @@ ansi_map_init_protocol(void) /* Store Invoke information needed for the corresponding reply */ static void -update_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){ +update_saved_invokedata(packet_info *pinfo, struct ansi_tcap_private_t *p_private_tcap){ struct ansi_map_invokedata_t *ansi_map_saved_invokedata; - struct ansi_tcap_private_t *p_private_tcap; address* src = &(pinfo->src); address* dst = &(pinfo->dst); guint8 *src_str; @@ -414,39 +413,35 @@ update_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb dst_str = ep_address_to_str(dst); /* Data from the TCAP dissector */ - if (pinfo->private_data != NULL){ - p_private_tcap=(struct ansi_tcap_private_t *)pinfo->private_data; - if ((!pinfo->fd->flags.visited)&&(p_private_tcap->TransactionID_str)){ - /* Only do this once XXX I hope it's the right thing to do */ - /* The hash string needs to contain src and dest to distiguish differnt flows */ - switch(ansi_map_response_matching_type){ - case ANSI_MAP_TID_ONLY: - buf = wmem_strdup(wmem_packet_scope(), p_private_tcap->TransactionID_str); - break; - case 1: - buf = wmem_strdup_printf(wmem_packet_scope(), "%s%s",p_private_tcap->TransactionID_str,src_str); - break; - default: - buf = wmem_strdup_printf(wmem_packet_scope(), "%s%s%s",p_private_tcap->TransactionID_str,src_str,dst_str); - break; - } - /* If the entry allready exists don't owervrite it */ - ansi_map_saved_invokedata = (struct ansi_map_invokedata_t *)g_hash_table_lookup(TransactionId_table,buf); - if(ansi_map_saved_invokedata) - return; + if ((!pinfo->fd->flags.visited)&&(p_private_tcap->TransactionID_str)){ + /* Only do this once XXX I hope it's the right thing to do */ + /* The hash string needs to contain src and dest to distiguish differnt flows */ + switch(ansi_map_response_matching_type){ + case ANSI_MAP_TID_ONLY: + buf = wmem_strdup(wmem_packet_scope(), p_private_tcap->TransactionID_str); + break; + case 1: + buf = wmem_strdup_printf(wmem_packet_scope(), "%s%s",p_private_tcap->TransactionID_str,src_str); + break; + default: + buf = wmem_strdup_printf(wmem_packet_scope(), "%s%s%s",p_private_tcap->TransactionID_str,src_str,dst_str); + break; + } + /* If the entry allready exists don't owervrite it */ + ansi_map_saved_invokedata = (struct ansi_map_invokedata_t *)g_hash_table_lookup(TransactionId_table,buf); + if(ansi_map_saved_invokedata) + return; - ansi_map_saved_invokedata = wmem_new(wmem_file_scope(), struct ansi_map_invokedata_t); - ansi_map_saved_invokedata->opcode = p_private_tcap->d.OperationCode_private; - ansi_map_saved_invokedata->ServiceIndicator = ServiceIndicator; + ansi_map_saved_invokedata = wmem_new(wmem_file_scope(), struct ansi_map_invokedata_t); + ansi_map_saved_invokedata->opcode = p_private_tcap->d.OperationCode_private; + ansi_map_saved_invokedata->ServiceIndicator = ServiceIndicator; - g_hash_table_insert(TransactionId_table, - wmem_strdup(wmem_file_scope(), buf), - ansi_map_saved_invokedata); + g_hash_table_insert(TransactionId_table, + wmem_strdup(wmem_file_scope(), buf), + ansi_map_saved_invokedata); - /*g_warning("Invoke Hash string %s pkt: %u",buf,pinfo->fd->num);*/ - } + /*g_warning("Invoke Hash string %s pkt: %u",buf,pinfo->fd->num);*/ } - } /* value strings */ const value_string ansi_map_opr_code_strings[] = { @@ -4330,9 +4325,8 @@ static int dissect_returnData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ } static int -find_saved_invokedata(asn1_ctx_t *actx){ +find_saved_invokedata(asn1_ctx_t *actx, struct ansi_tcap_private_t *p_private_tcap){ struct ansi_map_invokedata_t *ansi_map_saved_invokedata; - struct ansi_tcap_private_t *p_private_tcap; address* src = &(actx->pinfo->src); address* dst = &(actx->pinfo->dst); guint8 *src_str; @@ -4342,45 +4336,40 @@ find_saved_invokedata(asn1_ctx_t *actx){ buf=(char *)wmem_alloc(wmem_packet_scope(), 1024); /* Data from the TCAP dissector */ - if (actx->pinfo->private_data != NULL){ - p_private_tcap=(struct ansi_tcap_private_t *)actx->pinfo->private_data; - /* The hash string needs to contain src and dest to distiguish differnt flows */ - src_str = ep_address_to_str(src); - dst_str = ep_address_to_str(dst); - /* Reverse order to invoke */ - switch(ansi_map_response_matching_type){ - case ANSI_MAP_TID_ONLY: - g_snprintf(buf,1024,"%s",p_private_tcap->TransactionID_str); - break; - case 1: - g_snprintf(buf,1024,"%s%s",p_private_tcap->TransactionID_str,dst_str); - break; - default: - g_snprintf(buf,1024,"%s%s%s",p_private_tcap->TransactionID_str,dst_str,src_str); - break; - } + /* The hash string needs to contain src and dest to distiguish differnt flows */ + src_str = ep_address_to_str(src); + dst_str = ep_address_to_str(dst); + /* Reverse order to invoke */ + switch(ansi_map_response_matching_type){ + case ANSI_MAP_TID_ONLY: + g_snprintf(buf,1024,"%s",p_private_tcap->TransactionID_str); + break; + case 1: + g_snprintf(buf,1024,"%s%s",p_private_tcap->TransactionID_str,dst_str); + break; + default: + g_snprintf(buf,1024,"%s%s%s",p_private_tcap->TransactionID_str,dst_str,src_str); + break; + } - /*g_warning("Find Hash string %s pkt: %u",buf,actx->pinfo->fd->num);*/ - ansi_map_saved_invokedata = (struct ansi_map_invokedata_t *)g_hash_table_lookup(TransactionId_table, buf); - if(ansi_map_saved_invokedata){ - OperationCode = ansi_map_saved_invokedata->opcode & 0xff; - ServiceIndicator = ansi_map_saved_invokedata->ServiceIndicator; - }else{ - OperationCode = OperationCode & 0x00ff; - } + /*g_warning("Find Hash string %s pkt: %u",buf,actx->pinfo->fd->num);*/ + ansi_map_saved_invokedata = (struct ansi_map_invokedata_t *)g_hash_table_lookup(TransactionId_table, buf); + if(ansi_map_saved_invokedata){ + OperationCode = ansi_map_saved_invokedata->opcode & 0xff; + ServiceIndicator = ansi_map_saved_invokedata->ServiceIndicator; }else{ - /*g_warning("No private data pkt: %u",actx->pinfo->fd->num);*/ OperationCode = OperationCode & 0x00ff; } + return OperationCode; } -static void -dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) { proto_item *ansi_map_item; proto_tree *ansi_map_tree = NULL; - struct ansi_tcap_private_t *p_private_tcap; + struct ansi_tcap_private_t *p_private_tcap = (struct ansi_tcap_private_t *)data; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); @@ -4394,9 +4383,9 @@ dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_set_str(pinfo->cinfo, COL_PROTOCOL, "ANSI MAP"); /* Data from the TCAP dissector */ - if (pinfo->private_data == NULL){ - proto_tree_add_text(tree, tvb, 0, -1, "Dissector ERROR this dissector relays on private data"); - return; + if (data == NULL){ + proto_tree_add_text(tree, tvb, 0, -1, "Dissector ERROR this dissector relies on dissector data"); + return 0; } /* @@ -4409,8 +4398,6 @@ dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) is801_pld = FALSE; ServiceIndicator = 0; - p_private_tcap=(struct ansi_tcap_private_t *)pinfo->private_data; - switch(p_private_tcap->d.pdu){ /* 1 : invoke, @@ -4424,10 +4411,10 @@ dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_add_fstr(pinfo->cinfo, COL_INFO,"%s Invoke ", val_to_str_ext(OperationCode, &ansi_map_opr_code_strings_ext, "Unknown ANSI-MAP PDU (%u)")); proto_item_append_text(p_private_tcap->d.OperationCode_item," %s",val_to_str_ext(OperationCode, &ansi_map_opr_code_strings_ext, "Unknown ANSI-MAP PDU (%u)")); dissect_invokeData(ansi_map_tree, tvb, 0, &asn1_ctx); - update_saved_invokedata(pinfo, ansi_map_tree, tvb); + update_saved_invokedata(pinfo, p_private_tcap); break; case 2: - OperationCode = find_saved_invokedata(&asn1_ctx); + OperationCode = find_saved_invokedata(&asn1_ctx, p_private_tcap); col_add_fstr(pinfo->cinfo, COL_INFO,"%s ReturnResult ", val_to_str_ext(OperationCode, &ansi_map_opr_code_strings_ext, "Unknown ANSI-MAP PDU (%u)")); proto_item_append_text(p_private_tcap->d.OperationCode_item," %s",val_to_str_ext(OperationCode, &ansi_map_opr_code_strings_ext, "Unknown ANSI-MAP PDU (%u)")); dissect_returnData(ansi_map_tree, tvb, 0, &asn1_ctx); @@ -4443,6 +4430,8 @@ dissect_ansi_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) DISSECTOR_ASSERT_NOT_REACHED(); break; } + + return tvb_length(tvb); } static void range_delete_callback(guint32 ssn) @@ -5335,7 +5324,7 @@ void proto_register_ansi_map(void) { proto_register_field_array(proto_ansi_map, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - register_dissector("ansi_map", dissect_ansi_map, proto_ansi_map); + new_register_dissector("ansi_map", dissect_ansi_map, proto_ansi_map); is637_tele_id_dissector_table = register_dissector_table("ansi_map.tele_id", "IS-637 Teleservice ID", -- cgit v1.2.1