As suggested by Jakub Zawadzki: g_free() is NULL safe, so we don't need check against it.

Also (from me): Clean up spacing

svn path=/trunk/; revision=27727
This commit is contained in:
Bill Meier 2009-03-15 15:40:55 +00:00
parent 691a5cbed2
commit 0f9f5caf9d
4 changed files with 6825 additions and 6865 deletions

View File

@ -80,7 +80,7 @@ extern gboolean gtcap_DisplaySRT;
extern guint gtcap_RepetitionTimeout; extern guint gtcap_RepetitionTimeout;
extern guint gtcap_LostTimeout; extern guint gtcap_LostTimeout;
/* static dissector_handle_t tcap_handle = NULL; */ /* static dissector_handle_t tcap_handle = NULL; */
static dissector_table_t ber_oid_dissector_table=NULL; static dissector_table_t ber_oid_dissector_table=NULL;
static const char * cur_oid; static const char * cur_oid;
static const char * tcapext_oid; static const char * tcapext_oid;
@ -140,36 +140,32 @@ static GHashTable *TransactionId_table=NULL;
static void static void
TransactionId_table_cleanup(gpointer key , gpointer value, gpointer user_data _U_){ TransactionId_table_cleanup(gpointer key , gpointer value, gpointer user_data _U_){
struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata = value; struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata = value;
gchar *TransactionId_str = key; gchar *TransactionId_str = key;
if ( TransactionId_str ){ g_free(TransactionId_str);
g_free(TransactionId_str); g_free(ansi_tcap_saved_invokedata);
}
if (ansi_tcap_saved_invokedata){
g_free(ansi_tcap_saved_invokedata);
}
} }
void void
ansi_tcap_init_transaction_table(void){ ansi_tcap_init_transaction_table(void){
/* Destroy any existing memory chunks / hashes. */ /* Destroy any existing memory chunks / hashes. */
if (TransactionId_table){ if (TransactionId_table){
g_hash_table_foreach(TransactionId_table, TransactionId_table_cleanup, NULL); g_hash_table_foreach(TransactionId_table, TransactionId_table_cleanup, NULL);
g_hash_table_destroy(TransactionId_table); g_hash_table_destroy(TransactionId_table);
TransactionId_table = NULL; TransactionId_table = NULL;
} }
TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal); TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal);
} }
static void static void
ansi_tcap_init_protocol(void) ansi_tcap_init_protocol(void)
{ {
ansi_tcap_init_transaction_table(); ansi_tcap_init_transaction_table();
} }
/* Store Invoke information needed for the corresponding reply */ /* Store Invoke information needed for the corresponding reply */
@ -182,30 +178,30 @@ save_invoke_data(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){
if ((!pinfo->fd->flags.visited)&&(ansi_tcap_private.TransactionID_str)){ if ((!pinfo->fd->flags.visited)&&(ansi_tcap_private.TransactionID_str)){
/* Only do this once XXX I hope its the right thing to do */ /* Only do this once XXX I hope its the right thing to do */
/* The hash string needs to contain src and dest to distiguish differnt flows */ /* The hash string needs to contain src and dest to distiguish differnt flows */
buf = ep_alloc(MAX_TID_STR_LEN); buf = ep_alloc(MAX_TID_STR_LEN);
buf[0] = '\0'; buf[0] = '\0';
g_snprintf(buf, MAX_TID_STR_LEN, "%s%s%s", g_snprintf(buf, MAX_TID_STR_LEN, "%s%s%s",
ansi_tcap_private.TransactionID_str, address_to_str(src), ansi_tcap_private.TransactionID_str, address_to_str(src),
address_to_str(dst)); address_to_str(dst));
/* If the entry allready exists don't owervrite it */ /* If the entry allready exists don't owervrite it */
ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table,buf); ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table,buf);
if(ansi_tcap_saved_invokedata) if(ansi_tcap_saved_invokedata)
return; return;
ansi_tcap_saved_invokedata = g_malloc(sizeof(struct ansi_tcap_invokedata_t)); ansi_tcap_saved_invokedata = g_malloc(sizeof(struct ansi_tcap_invokedata_t));
ansi_tcap_saved_invokedata->OperationCode = ansi_tcap_private.d.OperationCode; ansi_tcap_saved_invokedata->OperationCode = ansi_tcap_private.d.OperationCode;
ansi_tcap_saved_invokedata->OperationCode_national = ansi_tcap_private.d.OperationCode_national; ansi_tcap_saved_invokedata->OperationCode_national = ansi_tcap_private.d.OperationCode_national;
ansi_tcap_saved_invokedata->OperationCode_private = ansi_tcap_private.d.OperationCode_private; ansi_tcap_saved_invokedata->OperationCode_private = ansi_tcap_private.d.OperationCode_private;
g_hash_table_insert(TransactionId_table, g_hash_table_insert(TransactionId_table,
g_strdup(buf), g_strdup(buf),
ansi_tcap_saved_invokedata); ansi_tcap_saved_invokedata);
/* /*
g_warning("Tcap Invoke Hash string %s",buf); g_warning("Tcap Invoke Hash string %s",buf);
*/ */
} }
} }
@ -225,15 +221,15 @@ find_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U
buf[0] = '\0'; buf[0] = '\0';
/* Reverse order to invoke */ /* Reverse order to invoke */
g_snprintf(buf, MAX_TID_STR_LEN, "%s%s%s", g_snprintf(buf, MAX_TID_STR_LEN, "%s%s%s",
ansi_tcap_private.TransactionID_str, address_to_str(dst), ansi_tcap_private.TransactionID_str, address_to_str(dst),
address_to_str(src)); address_to_str(src));
ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table, buf); ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table, buf);
if(ansi_tcap_saved_invokedata){ if(ansi_tcap_saved_invokedata){
ansi_tcap_private.d.OperationCode = ansi_tcap_saved_invokedata->OperationCode; ansi_tcap_private.d.OperationCode = ansi_tcap_saved_invokedata->OperationCode;
ansi_tcap_private.d.OperationCode_national = ansi_tcap_saved_invokedata->OperationCode_national; ansi_tcap_private.d.OperationCode_national = ansi_tcap_saved_invokedata->OperationCode_national;
ansi_tcap_private.d.OperationCode_private = ansi_tcap_saved_invokedata->OperationCode_private; ansi_tcap_private.d.OperationCode_private = ansi_tcap_saved_invokedata->OperationCode_private;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -256,61 +252,61 @@ find_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U
*/ */
static gboolean static gboolean
find_tcap_subdissector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){ find_tcap_subdissector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
proto_item *item; proto_item *item;
/* If "DialoguePortion objectApplicationId ObjectIDApplicationContext /* If "DialoguePortion objectApplicationId ObjectIDApplicationContext
* points to the subdissector this code can be used. * points to the subdissector this code can be used.
* *
if(ansi_tcap_private.d.oid_is_present){ if(ansi_tcap_private.d.oid_is_present){
call_ber_oid_callback(ansi_tcap_private.objectApplicationId_oid, tvb, 0, actx-pinfo, tree); call_ber_oid_callback(ansi_tcap_private.objectApplicationId_oid, tvb, 0, actx-pinfo, tree);
return TRUE; return TRUE;
} }
*/ */
if(ansi_tcap_private.d.pdu == 1){ if(ansi_tcap_private.d.pdu == 1){
/* Save Invoke data for this transaction */ /* Save Invoke data for this transaction */
save_invoke_data(actx->pinfo, tree, tvb); save_invoke_data(actx->pinfo, tree, tvb);
}else{ }else{
/* Get saved data for this transaction */ /* Get saved data for this transaction */
if(find_saved_invokedata(actx->pinfo, tree, tvb)){ if(find_saved_invokedata(actx->pinfo, tree, tvb)){
if(ansi_tcap_private.d.OperationCode == 0){ if(ansi_tcap_private.d.OperationCode == 0){
/* national */ /* national */
item = proto_tree_add_int(tree, hf_ansi_tcap_national, tvb, 0, 0, ansi_tcap_private.d.OperationCode_national); item = proto_tree_add_int(tree, hf_ansi_tcap_national, tvb, 0, 0, ansi_tcap_private.d.OperationCode_national);
}else{ }else{
item = proto_tree_add_int(tree, hf_ansi_tcap_private, tvb, 0, 0, ansi_tcap_private.d.OperationCode_private); item = proto_tree_add_int(tree, hf_ansi_tcap_private, tvb, 0, 0, ansi_tcap_private.d.OperationCode_private);
} }
PROTO_ITEM_SET_GENERATED(item); PROTO_ITEM_SET_GENERATED(item);
ansi_tcap_private.d.OperationCode_item = item; ansi_tcap_private.d.OperationCode_item = item;
} }
} }
if(ansi_tcap_private.d.OperationCode == 0){ if(ansi_tcap_private.d.OperationCode == 0){
/* national */ /* national */
item = proto_tree_add_text(tree, tvb, 0, -1, item = proto_tree_add_text(tree, tvb, 0, -1,
"Dissector for ANSI TCAP NATIONAL code:%u not implemented. Contact Wireshark developers if you want this supported", "Dissector for ANSI TCAP NATIONAL code:%u not implemented. Contact Wireshark developers if you want this supported",
ansi_tcap_private.d.OperationCode_national); ansi_tcap_private.d.OperationCode_national);
PROTO_ITEM_SET_GENERATED(item); PROTO_ITEM_SET_GENERATED(item);
return FALSE; return FALSE;
}else if(ansi_tcap_private.d.OperationCode == 1){ }else if(ansi_tcap_private.d.OperationCode == 1){
/* private */ /* private */
if((ansi_tcap_private.d.OperationCode_private & 0x0900) != 0x0900){ if((ansi_tcap_private.d.OperationCode_private & 0x0900) != 0x0900){
item = proto_tree_add_text(tree, tvb, 0, -1, item = proto_tree_add_text(tree, tvb, 0, -1,
"Dissector for ANSI TCAP PRIVATE code:%u not implemented. Contact Wireshark developers if you want this supported", "Dissector for ANSI TCAP PRIVATE code:%u not implemented. Contact Wireshark developers if you want this supported",
ansi_tcap_private.d.OperationCode_private); ansi_tcap_private.d.OperationCode_private);
PROTO_ITEM_SET_GENERATED(item); PROTO_ITEM_SET_GENERATED(item);
return FALSE; return FALSE;
} }
} }
/* This is abit of a hack as it assumes the private codes with a "family" of 0x09 is ANSI MAP /* This is abit of a hack as it assumes the private codes with a "family" of 0x09 is ANSI MAP
* See TODO above. * See TODO above.
* N.S0005-0 v 1.0 TCAP Formats and Procedures 5-16 Application Services * N.S0005-0 v 1.0 TCAP Formats and Procedures 5-16 Application Services
* 6.3.2 Component Portion * 6.3.2 Component Portion
* The Operation Code is partitioned into an Operation Family followed by a * The Operation Code is partitioned into an Operation Family followed by a
* Specifier associated with each Operation Family member. For TIA/EIA-41 the * Specifier associated with each Operation Family member. For TIA/EIA-41 the
* Operation Family is coded as decimal 9. Bit H of the Operation Family is always * Operation Family is coded as decimal 9. Bit H of the Operation Family is always
* coded as 0. * coded as 0.
*/ */
call_dissector(ansi_map_handle, tvb, actx->pinfo, tcap_top_tree); call_dissector(ansi_map_handle, tvb, actx->pinfo, tcap_top_tree);
return TRUE; return TRUE;
} }
#include "packet-ansi_tcap-fn.c" #include "packet-ansi_tcap-fn.c"
@ -321,24 +317,24 @@ find_tcap_subdissector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
static void static void
dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
{ {
proto_item *item=NULL; proto_item *item=NULL;
proto_tree *tree=NULL; proto_tree *tree=NULL;
#if 0 #if 0
proto_item *stat_item=NULL; proto_item *stat_item=NULL;
proto_tree *stat_tree=NULL; proto_tree *stat_tree=NULL;
gint offset = 0; gint offset = 0;
struct tcaphash_context_t * p_tcap_context; struct tcaphash_context_t * p_tcap_context;
dissector_handle_t subdissector_handle; dissector_handle_t subdissector_handle;
#endif #endif
asn1_ctx_t asn1_ctx; asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
ansi_tcap_ctx_init(&ansi_tcap_private); ansi_tcap_ctx_init(&ansi_tcap_private);
tcap_top_tree = parent_tree; tcap_top_tree = parent_tree;
if (check_col(pinfo->cinfo, COL_PROTOCOL)) if (check_col(pinfo->cinfo, COL_PROTOCOL))
{ {
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ANSI TCAP"); col_set_str(pinfo->cinfo, COL_PROTOCOL, "ANSI TCAP");
} }
/* create display subtree for the protocol */ /* create display subtree for the protocol */
@ -360,30 +356,30 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
#if 0 /* Skipp this part for now it will be rewritten */ #if 0 /* Skipp this part for now it will be rewritten */
if (g_ansi_tcap_HandleSRT && !tcap_subdissector_used ) { if (g_ansi_tcap_HandleSRT && !tcap_subdissector_used ) {
if (gtcap_DisplaySRT && tree) { if (gtcap_DisplaySRT && tree) {
stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat"); stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat");
PROTO_ITEM_SET_GENERATED(stat_item); PROTO_ITEM_SET_GENERATED(stat_item);
stat_tree = proto_item_add_subtree(stat_item, ett_ansi_tcap_stat); stat_tree = proto_item_add_subtree(stat_item, ett_ansi_tcap_stat);
} }
p_tcap_context=tcapsrt_call_matching(tvb, pinfo, stat_tree, gp_tcapsrt_info); p_tcap_context=tcapsrt_call_matching(tvb, pinfo, stat_tree, gp_tcapsrt_info);
ansi_tcap_private.context=p_tcap_context; ansi_tcap_private.context=p_tcap_context;
/* If the current message is TCAP only, /* If the current message is TCAP only,
* save the Application contexte name for the next messages * save the Application contexte name for the next messages
*/ */
if ( p_tcap_context && cur_oid && !p_tcap_context->oid_present ) { if ( p_tcap_context && cur_oid && !p_tcap_context->oid_present ) {
/* Save the application context and the sub dissector */ /* Save the application context and the sub dissector */
g_strlcpy(p_tcap_context->oid,cur_oid, LENGTH_OID); g_strlcpy(p_tcap_context->oid,cur_oid, LENGTH_OID);
if ( (subdissector_handle = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) { if ( (subdissector_handle = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
p_tcap_context->subdissector_handle=subdissector_handle; p_tcap_context->subdissector_handle=subdissector_handle;
p_tcap_context->oid_present=TRUE; p_tcap_context->oid_present=TRUE;
} }
} }
if (g_ansi_tcap_HandleSRT && p_tcap_context && p_tcap_context->callback) { if (g_ansi_tcap_HandleSRT && p_tcap_context && p_tcap_context->callback) {
/* Callback fonction for the upper layer */ /* Callback fonction for the upper layer */
(p_tcap_context->callback)(tvb, pinfo, stat_tree, p_tcap_context); (p_tcap_context->callback)(tvb, pinfo, stat_tree, p_tcap_context);
} }
} }
#endif #endif
} }
@ -392,8 +388,8 @@ void
proto_reg_handoff_ansi_tcap(void) proto_reg_handoff_ansi_tcap(void)
{ {
ansi_map_handle = find_dissector("ansi_map"); ansi_map_handle = find_dissector("ansi_map");
ber_oid_dissector_table = find_dissector_table("ber.oid"); ber_oid_dissector_table = find_dissector_table("ber.oid");
} }
@ -404,78 +400,67 @@ proto_register_ansi_tcap(void)
/* Setup list of header fields See Section 1.6.1 for details*/ /* Setup list of header fields See Section 1.6.1 for details*/
static hf_register_info hf[] = { static hf_register_info hf[] = {
/* Tcap Service Response Time */ /* Tcap Service Response Time */
{ &hf_ansi_tcapsrt_SessionId, { &hf_ansi_tcapsrt_SessionId,
{ "Session Id", { "Session Id",
"ansi_tcap.srt.session_id", "ansi_tcap.srt.session_id",
FT_UINT32, BASE_DEC, NULL, 0x0, FT_UINT32, BASE_DEC, NULL, 0x0,
"", HFILL } "", HFILL }
}, },
{ &hf_ansi_tcapsrt_BeginSession, { &hf_ansi_tcapsrt_BeginSession,
{ "Begin Session", { "Begin Session",
"ansi_tcap.srt.begin", "ansi_tcap.srt.begin",
FT_FRAMENUM, BASE_NONE, NULL, 0x0, FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"SRT Begin of Session", HFILL } "SRT Begin of Session", HFILL }
}, },
{ &hf_ansi_tcapsrt_EndSession, { &hf_ansi_tcapsrt_EndSession,
{ "End Session", { "End Session",
"ansi_tcap.srt.end", "ansi_tcap.srt.end",
FT_FRAMENUM, BASE_NONE, NULL, 0x0, FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"SRT End of Session", HFILL } "SRT End of Session", HFILL }
}, },
{ &hf_ansi_tcapsrt_SessionTime, { &hf_ansi_tcapsrt_SessionTime,
{ "Session duration", { "Session duration",
"ansi_tcap.srt.sessiontime", "ansi_tcap.srt.sessiontime",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
"Duration of the TCAP session", HFILL } "Duration of the TCAP session", HFILL }
}, },
{ &hf_ansi_tcapsrt_Duplicate, { &hf_ansi_tcapsrt_Duplicate,
{ "Request Duplicate", { "Request Duplicate",
"ansi_tcap.srt.duplicate", "ansi_tcap.srt.duplicate",
FT_UINT32, BASE_DEC, NULL, 0x0, FT_UINT32, BASE_DEC, NULL, 0x0,
"", HFILL } "", HFILL }
}, },
#include "packet-ansi_tcap-hfarr.c" #include "packet-ansi_tcap-hfarr.c"
}; };
/* Setup protocol subtree array */ /* Setup protocol subtree array */
static gint *ett[] = { static gint *ett[] = {
&ett_tcap, &ett_tcap,
&ett_param, &ett_param,
&ett_otid, &ett_otid,
&ett_dtid, &ett_dtid,
&ett_ansi_tcap_stat, &ett_ansi_tcap_stat,
#include "packet-ansi_tcap-ettarr.c" #include "packet-ansi_tcap-ettarr.c"
}; };
/*static enum_val_t tcap_options[] = { /*static enum_val_t tcap_options[] = {
{ "itu", "ITU", ITU_TCAP_STANDARD }, { "itu", "ITU", ITU_TCAP_STANDARD },
{ "ansi", "ANSI", ANSI_TCAP_STANDARD }, { "ansi", "ANSI", ANSI_TCAP_STANDARD },
{ NULL, NULL, 0 } { NULL, NULL, 0 }
};*/ };*/
/* Register the protocol name and description */ /* Register the protocol name and description */
proto_ansi_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME); proto_ansi_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME);
register_dissector("ansi_tcap", dissect_ansi_tcap, proto_ansi_tcap); register_dissector("ansi_tcap", dissect_ansi_tcap, proto_ansi_tcap);
/* Required function calls to register the header fields and subtrees used */ /* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_ansi_tcap, hf, array_length(hf)); proto_register_field_array(proto_ansi_tcap, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett)); proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&ansi_tcap_init_protocol); register_init_routine(&ansi_tcap_init_protocol);
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -171,7 +171,7 @@ extern gboolean gtcap_DisplaySRT;
extern guint gtcap_RepetitionTimeout; extern guint gtcap_RepetitionTimeout;
extern guint gtcap_LostTimeout; extern guint gtcap_LostTimeout;
/* static dissector_handle_t tcap_handle = NULL; */ /* static dissector_handle_t tcap_handle = NULL; */
static dissector_table_t ber_oid_dissector_table=NULL; static dissector_table_t ber_oid_dissector_table=NULL;
static const char * cur_oid; static const char * cur_oid;
static const char * tcapext_oid; static const char * tcapext_oid;
@ -231,36 +231,32 @@ static GHashTable *TransactionId_table=NULL;
static void static void
TransactionId_table_cleanup(gpointer key , gpointer value, gpointer user_data _U_){ TransactionId_table_cleanup(gpointer key , gpointer value, gpointer user_data _U_){
struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata = value; struct ansi_tcap_invokedata_t *ansi_tcap_saved_invokedata = value;
gchar *TransactionId_str = key; gchar *TransactionId_str = key;
if ( TransactionId_str ){ g_free(TransactionId_str);
g_free(TransactionId_str); g_free(ansi_tcap_saved_invokedata);
}
if (ansi_tcap_saved_invokedata){
g_free(ansi_tcap_saved_invokedata);
}
} }
void void
ansi_tcap_init_transaction_table(void){ ansi_tcap_init_transaction_table(void){
/* Destroy any existing memory chunks / hashes. */ /* Destroy any existing memory chunks / hashes. */
if (TransactionId_table){ if (TransactionId_table){
g_hash_table_foreach(TransactionId_table, TransactionId_table_cleanup, NULL); g_hash_table_foreach(TransactionId_table, TransactionId_table_cleanup, NULL);
g_hash_table_destroy(TransactionId_table); g_hash_table_destroy(TransactionId_table);
TransactionId_table = NULL; TransactionId_table = NULL;
} }
TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal); TransactionId_table = g_hash_table_new(g_str_hash, g_str_equal);
} }
static void static void
ansi_tcap_init_protocol(void) ansi_tcap_init_protocol(void)
{ {
ansi_tcap_init_transaction_table(); ansi_tcap_init_transaction_table();
} }
/* Store Invoke information needed for the corresponding reply */ /* Store Invoke information needed for the corresponding reply */
@ -273,30 +269,30 @@ save_invoke_data(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U_){
if ((!pinfo->fd->flags.visited)&&(ansi_tcap_private.TransactionID_str)){ if ((!pinfo->fd->flags.visited)&&(ansi_tcap_private.TransactionID_str)){
/* Only do this once XXX I hope its the right thing to do */ /* Only do this once XXX I hope its the right thing to do */
/* The hash string needs to contain src and dest to distiguish differnt flows */ /* The hash string needs to contain src and dest to distiguish differnt flows */
buf = ep_alloc(MAX_TID_STR_LEN); buf = ep_alloc(MAX_TID_STR_LEN);
buf[0] = '\0'; buf[0] = '\0';
g_snprintf(buf, MAX_TID_STR_LEN, "%s%s%s", g_snprintf(buf, MAX_TID_STR_LEN, "%s%s%s",
ansi_tcap_private.TransactionID_str, address_to_str(src), ansi_tcap_private.TransactionID_str, address_to_str(src),
address_to_str(dst)); address_to_str(dst));
/* If the entry allready exists don't owervrite it */ /* If the entry allready exists don't owervrite it */
ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table,buf); ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table,buf);
if(ansi_tcap_saved_invokedata) if(ansi_tcap_saved_invokedata)
return; return;
ansi_tcap_saved_invokedata = g_malloc(sizeof(struct ansi_tcap_invokedata_t)); ansi_tcap_saved_invokedata = g_malloc(sizeof(struct ansi_tcap_invokedata_t));
ansi_tcap_saved_invokedata->OperationCode = ansi_tcap_private.d.OperationCode; ansi_tcap_saved_invokedata->OperationCode = ansi_tcap_private.d.OperationCode;
ansi_tcap_saved_invokedata->OperationCode_national = ansi_tcap_private.d.OperationCode_national; ansi_tcap_saved_invokedata->OperationCode_national = ansi_tcap_private.d.OperationCode_national;
ansi_tcap_saved_invokedata->OperationCode_private = ansi_tcap_private.d.OperationCode_private; ansi_tcap_saved_invokedata->OperationCode_private = ansi_tcap_private.d.OperationCode_private;
g_hash_table_insert(TransactionId_table, g_hash_table_insert(TransactionId_table,
g_strdup(buf), g_strdup(buf),
ansi_tcap_saved_invokedata); ansi_tcap_saved_invokedata);
/* /*
g_warning("Tcap Invoke Hash string %s",buf); g_warning("Tcap Invoke Hash string %s",buf);
*/ */
} }
} }
@ -316,15 +312,15 @@ find_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U
buf[0] = '\0'; buf[0] = '\0';
/* Reverse order to invoke */ /* Reverse order to invoke */
g_snprintf(buf, MAX_TID_STR_LEN, "%s%s%s", g_snprintf(buf, MAX_TID_STR_LEN, "%s%s%s",
ansi_tcap_private.TransactionID_str, address_to_str(dst), ansi_tcap_private.TransactionID_str, address_to_str(dst),
address_to_str(src)); address_to_str(src));
ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table, buf); ansi_tcap_saved_invokedata = g_hash_table_lookup(TransactionId_table, buf);
if(ansi_tcap_saved_invokedata){ if(ansi_tcap_saved_invokedata){
ansi_tcap_private.d.OperationCode = ansi_tcap_saved_invokedata->OperationCode; ansi_tcap_private.d.OperationCode = ansi_tcap_saved_invokedata->OperationCode;
ansi_tcap_private.d.OperationCode_national = ansi_tcap_saved_invokedata->OperationCode_national; ansi_tcap_private.d.OperationCode_national = ansi_tcap_saved_invokedata->OperationCode_national;
ansi_tcap_private.d.OperationCode_private = ansi_tcap_saved_invokedata->OperationCode_private; ansi_tcap_private.d.OperationCode_private = ansi_tcap_saved_invokedata->OperationCode_private;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -347,61 +343,61 @@ find_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb _U
*/ */
static gboolean static gboolean
find_tcap_subdissector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){ find_tcap_subdissector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){
proto_item *item; proto_item *item;
/* If "DialoguePortion objectApplicationId ObjectIDApplicationContext /* If "DialoguePortion objectApplicationId ObjectIDApplicationContext
* points to the subdissector this code can be used. * points to the subdissector this code can be used.
* *
if(ansi_tcap_private.d.oid_is_present){ if(ansi_tcap_private.d.oid_is_present){
call_ber_oid_callback(ansi_tcap_private.objectApplicationId_oid, tvb, 0, actx-pinfo, tree); call_ber_oid_callback(ansi_tcap_private.objectApplicationId_oid, tvb, 0, actx-pinfo, tree);
return TRUE; return TRUE;
} }
*/ */
if(ansi_tcap_private.d.pdu == 1){ if(ansi_tcap_private.d.pdu == 1){
/* Save Invoke data for this transaction */ /* Save Invoke data for this transaction */
save_invoke_data(actx->pinfo, tree, tvb); save_invoke_data(actx->pinfo, tree, tvb);
}else{ }else{
/* Get saved data for this transaction */ /* Get saved data for this transaction */
if(find_saved_invokedata(actx->pinfo, tree, tvb)){ if(find_saved_invokedata(actx->pinfo, tree, tvb)){
if(ansi_tcap_private.d.OperationCode == 0){ if(ansi_tcap_private.d.OperationCode == 0){
/* national */ /* national */
item = proto_tree_add_int(tree, hf_ansi_tcap_national, tvb, 0, 0, ansi_tcap_private.d.OperationCode_national); item = proto_tree_add_int(tree, hf_ansi_tcap_national, tvb, 0, 0, ansi_tcap_private.d.OperationCode_national);
}else{ }else{
item = proto_tree_add_int(tree, hf_ansi_tcap_private, tvb, 0, 0, ansi_tcap_private.d.OperationCode_private); item = proto_tree_add_int(tree, hf_ansi_tcap_private, tvb, 0, 0, ansi_tcap_private.d.OperationCode_private);
} }
PROTO_ITEM_SET_GENERATED(item); PROTO_ITEM_SET_GENERATED(item);
ansi_tcap_private.d.OperationCode_item = item; ansi_tcap_private.d.OperationCode_item = item;
} }
} }
if(ansi_tcap_private.d.OperationCode == 0){ if(ansi_tcap_private.d.OperationCode == 0){
/* national */ /* national */
item = proto_tree_add_text(tree, tvb, 0, -1, item = proto_tree_add_text(tree, tvb, 0, -1,
"Dissector for ANSI TCAP NATIONAL code:%u not implemented. Contact Wireshark developers if you want this supported", "Dissector for ANSI TCAP NATIONAL code:%u not implemented. Contact Wireshark developers if you want this supported",
ansi_tcap_private.d.OperationCode_national); ansi_tcap_private.d.OperationCode_national);
PROTO_ITEM_SET_GENERATED(item); PROTO_ITEM_SET_GENERATED(item);
return FALSE; return FALSE;
}else if(ansi_tcap_private.d.OperationCode == 1){ }else if(ansi_tcap_private.d.OperationCode == 1){
/* private */ /* private */
if((ansi_tcap_private.d.OperationCode_private & 0x0900) != 0x0900){ if((ansi_tcap_private.d.OperationCode_private & 0x0900) != 0x0900){
item = proto_tree_add_text(tree, tvb, 0, -1, item = proto_tree_add_text(tree, tvb, 0, -1,
"Dissector for ANSI TCAP PRIVATE code:%u not implemented. Contact Wireshark developers if you want this supported", "Dissector for ANSI TCAP PRIVATE code:%u not implemented. Contact Wireshark developers if you want this supported",
ansi_tcap_private.d.OperationCode_private); ansi_tcap_private.d.OperationCode_private);
PROTO_ITEM_SET_GENERATED(item); PROTO_ITEM_SET_GENERATED(item);
return FALSE; return FALSE;
} }
} }
/* This is abit of a hack as it assumes the private codes with a "family" of 0x09 is ANSI MAP /* This is abit of a hack as it assumes the private codes with a "family" of 0x09 is ANSI MAP
* See TODO above. * See TODO above.
* N.S0005-0 v 1.0 TCAP Formats and Procedures 5-16 Application Services * N.S0005-0 v 1.0 TCAP Formats and Procedures 5-16 Application Services
* 6.3.2 Component Portion * 6.3.2 Component Portion
* The Operation Code is partitioned into an Operation Family followed by a * The Operation Code is partitioned into an Operation Family followed by a
* Specifier associated with each Operation Family member. For TIA/EIA-41 the * Specifier associated with each Operation Family member. For TIA/EIA-41 the
* Operation Family is coded as decimal 9. Bit H of the Operation Family is always * Operation Family is coded as decimal 9. Bit H of the Operation Family is always
* coded as 0. * coded as 0.
*/ */
call_dissector(ansi_map_handle, tvb, actx->pinfo, tcap_top_tree); call_dissector(ansi_map_handle, tvb, actx->pinfo, tcap_top_tree);
return TRUE; return TRUE;
} }
@ -1306,7 +1302,7 @@ dissect_ansi_tcap_PackageType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int
/*--- End of included file: packet-ansi_tcap-fn.c ---*/ /*--- End of included file: packet-ansi_tcap-fn.c ---*/
#line 317 "packet-ansi_tcap-template.c" #line 313 "packet-ansi_tcap-template.c"
@ -1314,24 +1310,24 @@ dissect_ansi_tcap_PackageType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int
static void static void
dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
{ {
proto_item *item=NULL; proto_item *item=NULL;
proto_tree *tree=NULL; proto_tree *tree=NULL;
#if 0 #if 0
proto_item *stat_item=NULL; proto_item *stat_item=NULL;
proto_tree *stat_tree=NULL; proto_tree *stat_tree=NULL;
gint offset = 0; gint offset = 0;
struct tcaphash_context_t * p_tcap_context; struct tcaphash_context_t * p_tcap_context;
dissector_handle_t subdissector_handle; dissector_handle_t subdissector_handle;
#endif #endif
asn1_ctx_t asn1_ctx; asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
ansi_tcap_ctx_init(&ansi_tcap_private); ansi_tcap_ctx_init(&ansi_tcap_private);
tcap_top_tree = parent_tree; tcap_top_tree = parent_tree;
if (check_col(pinfo->cinfo, COL_PROTOCOL)) if (check_col(pinfo->cinfo, COL_PROTOCOL))
{ {
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ANSI TCAP"); col_set_str(pinfo->cinfo, COL_PROTOCOL, "ANSI TCAP");
} }
/* create display subtree for the protocol */ /* create display subtree for the protocol */
@ -1353,30 +1349,30 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
#if 0 /* Skipp this part for now it will be rewritten */ #if 0 /* Skipp this part for now it will be rewritten */
if (g_ansi_tcap_HandleSRT && !tcap_subdissector_used ) { if (g_ansi_tcap_HandleSRT && !tcap_subdissector_used ) {
if (gtcap_DisplaySRT && tree) { if (gtcap_DisplaySRT && tree) {
stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat"); stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat");
PROTO_ITEM_SET_GENERATED(stat_item); PROTO_ITEM_SET_GENERATED(stat_item);
stat_tree = proto_item_add_subtree(stat_item, ett_ansi_tcap_stat); stat_tree = proto_item_add_subtree(stat_item, ett_ansi_tcap_stat);
} }
p_tcap_context=tcapsrt_call_matching(tvb, pinfo, stat_tree, gp_tcapsrt_info); p_tcap_context=tcapsrt_call_matching(tvb, pinfo, stat_tree, gp_tcapsrt_info);
ansi_tcap_private.context=p_tcap_context; ansi_tcap_private.context=p_tcap_context;
/* If the current message is TCAP only, /* If the current message is TCAP only,
* save the Application contexte name for the next messages * save the Application contexte name for the next messages
*/ */
if ( p_tcap_context && cur_oid && !p_tcap_context->oid_present ) { if ( p_tcap_context && cur_oid && !p_tcap_context->oid_present ) {
/* Save the application context and the sub dissector */ /* Save the application context and the sub dissector */
g_strlcpy(p_tcap_context->oid,cur_oid, LENGTH_OID); g_strlcpy(p_tcap_context->oid,cur_oid, LENGTH_OID);
if ( (subdissector_handle = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) { if ( (subdissector_handle = dissector_get_string_handle(ber_oid_dissector_table, cur_oid)) ) {
p_tcap_context->subdissector_handle=subdissector_handle; p_tcap_context->subdissector_handle=subdissector_handle;
p_tcap_context->oid_present=TRUE; p_tcap_context->oid_present=TRUE;
} }
} }
if (g_ansi_tcap_HandleSRT && p_tcap_context && p_tcap_context->callback) { if (g_ansi_tcap_HandleSRT && p_tcap_context && p_tcap_context->callback) {
/* Callback fonction for the upper layer */ /* Callback fonction for the upper layer */
(p_tcap_context->callback)(tvb, pinfo, stat_tree, p_tcap_context); (p_tcap_context->callback)(tvb, pinfo, stat_tree, p_tcap_context);
} }
} }
#endif #endif
} }
@ -1385,8 +1381,8 @@ void
proto_reg_handoff_ansi_tcap(void) proto_reg_handoff_ansi_tcap(void)
{ {
ansi_map_handle = find_dissector("ansi_map"); ansi_map_handle = find_dissector("ansi_map");
ber_oid_dissector_table = find_dissector_table("ber.oid"); ber_oid_dissector_table = find_dissector_table("ber.oid");
} }
@ -1397,37 +1393,37 @@ proto_register_ansi_tcap(void)
/* Setup list of header fields See Section 1.6.1 for details*/ /* Setup list of header fields See Section 1.6.1 for details*/
static hf_register_info hf[] = { static hf_register_info hf[] = {
/* Tcap Service Response Time */ /* Tcap Service Response Time */
{ &hf_ansi_tcapsrt_SessionId, { &hf_ansi_tcapsrt_SessionId,
{ "Session Id", { "Session Id",
"ansi_tcap.srt.session_id", "ansi_tcap.srt.session_id",
FT_UINT32, BASE_DEC, NULL, 0x0, FT_UINT32, BASE_DEC, NULL, 0x0,
"", HFILL } "", HFILL }
}, },
{ &hf_ansi_tcapsrt_BeginSession, { &hf_ansi_tcapsrt_BeginSession,
{ "Begin Session", { "Begin Session",
"ansi_tcap.srt.begin", "ansi_tcap.srt.begin",
FT_FRAMENUM, BASE_NONE, NULL, 0x0, FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"SRT Begin of Session", HFILL } "SRT Begin of Session", HFILL }
}, },
{ &hf_ansi_tcapsrt_EndSession, { &hf_ansi_tcapsrt_EndSession,
{ "End Session", { "End Session",
"ansi_tcap.srt.end", "ansi_tcap.srt.end",
FT_FRAMENUM, BASE_NONE, NULL, 0x0, FT_FRAMENUM, BASE_NONE, NULL, 0x0,
"SRT End of Session", HFILL } "SRT End of Session", HFILL }
}, },
{ &hf_ansi_tcapsrt_SessionTime, { &hf_ansi_tcapsrt_SessionTime,
{ "Session duration", { "Session duration",
"ansi_tcap.srt.sessiontime", "ansi_tcap.srt.sessiontime",
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
"Duration of the TCAP session", HFILL } "Duration of the TCAP session", HFILL }
}, },
{ &hf_ansi_tcapsrt_Duplicate, { &hf_ansi_tcapsrt_Duplicate,
{ "Request Duplicate", { "Request Duplicate",
"ansi_tcap.srt.duplicate", "ansi_tcap.srt.duplicate",
FT_UINT32, BASE_DEC, NULL, 0x0, FT_UINT32, BASE_DEC, NULL, 0x0,
"", HFILL } "", HFILL }
}, },
/*--- Included file: packet-ansi_tcap-hfarr.c ---*/ /*--- Included file: packet-ansi_tcap-hfarr.c ---*/
#line 1 "packet-ansi_tcap-hfarr.c" #line 1 "packet-ansi_tcap-hfarr.c"
@ -1637,16 +1633,16 @@ proto_register_ansi_tcap(void)
"ansi_tcap.T_paramSet", HFILL }}, "ansi_tcap.T_paramSet", HFILL }},
/*--- End of included file: packet-ansi_tcap-hfarr.c ---*/ /*--- End of included file: packet-ansi_tcap-hfarr.c ---*/
#line 439 "packet-ansi_tcap-template.c" #line 435 "packet-ansi_tcap-template.c"
}; };
/* Setup protocol subtree array */ /* Setup protocol subtree array */
static gint *ett[] = { static gint *ett[] = {
&ett_tcap, &ett_tcap,
&ett_param, &ett_param,
&ett_otid, &ett_otid,
&ett_dtid, &ett_dtid,
&ett_ansi_tcap_stat, &ett_ansi_tcap_stat,
/*--- Included file: packet-ansi_tcap-ettarr.c ---*/ /*--- Included file: packet-ansi_tcap-ettarr.c ---*/
#line 1 "packet-ansi_tcap-ettarr.c" #line 1 "packet-ansi_tcap-ettarr.c"
@ -1674,37 +1670,26 @@ proto_register_ansi_tcap(void)
&ett_ansi_tcap_T_paramSet, &ett_ansi_tcap_T_paramSet,
/*--- End of included file: packet-ansi_tcap-ettarr.c ---*/ /*--- End of included file: packet-ansi_tcap-ettarr.c ---*/
#line 449 "packet-ansi_tcap-template.c" #line 445 "packet-ansi_tcap-template.c"
}; };
/*static enum_val_t tcap_options[] = { /*static enum_val_t tcap_options[] = {
{ "itu", "ITU", ITU_TCAP_STANDARD }, { "itu", "ITU", ITU_TCAP_STANDARD },
{ "ansi", "ANSI", ANSI_TCAP_STANDARD }, { "ansi", "ANSI", ANSI_TCAP_STANDARD },
{ NULL, NULL, 0 } { NULL, NULL, 0 }
};*/ };*/
/* Register the protocol name and description */ /* Register the protocol name and description */
proto_ansi_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME); proto_ansi_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME);
register_dissector("ansi_tcap", dissect_ansi_tcap, proto_ansi_tcap); register_dissector("ansi_tcap", dissect_ansi_tcap, proto_ansi_tcap);
/* Required function calls to register the header fields and subtrees used */ /* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_ansi_tcap, hf, array_length(hf)); proto_register_field_array(proto_ansi_tcap, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett)); proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&ansi_tcap_init_protocol); register_init_routine(&ansi_tcap_init_protocol);
} }