From 0d7cd6c86d64501cd956172773391050ac22d931 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 29 Jul 2010 12:57:20 +0200 Subject: store callback-private-data (cb_priv) as user_ref2 in tcci and tcap_invocation --- src/app_support.c | 12 +++++++----- src/csl_cha_cco.c | 3 ++- src/tcap.h | 3 ++- src/tcap_user.h | 3 ++- src/tcu.c | 3 ++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/app_support.c b/src/app_support.c index bf2cab8..a583f42 100644 --- a/src/app_support.c +++ b/src/app_support.c @@ -60,11 +60,10 @@ struct map_app_reg_info { //int (*comp_ind_cb)( }; -/* local opCode, pointer to parsed asn1C structure, tcap indication, private ptr */ +/* local opCode, pointer to parsed asn1C structure, tcap indication, PRIVATE Ptr */ typedef void map_cbfn(long opcode, void *parsed, struct tcap_component_ind *tcci, void *priv); struct map_op_callback { - void *priv; /* call-back function to be called once the operation completes/fails/time-outs*/ map_cbfn *cb; }; @@ -103,7 +102,7 @@ int map_app_register(struct map_app_reg_info *mi) } /* The User Application is initiating a new MAP operation */ -int map_op_invoke(long opcode, void *parsed, struct map_op_callback *cb, +int map_op_invoke(long opcode, void *parsed, struct map_op_callback *cb, void *cb_priv, uint32_t timeout_sec, uint32_t dialogue_id, uint8_t *linked_id) { struct map_op_type_info *optinf; @@ -113,11 +112,12 @@ int map_op_invoke(long opcode, void *parsed, struct map_op_callback *cb, memset(&_tcpb, 0, sizeof(_tcpb)); optinf = get_op_type_info(app, opcode); - if (!optinf) + if (parsed && !optinf) return -EINVAL; tcpb->prim = TCAP_PR_TC_INVOKE; tcpb->user_ref = (unsigned long) cb; + tcpb->user_ref2 = (unsigned long) cb_priv; tcci->op_class = 1; /* do we need other types in MAP? */ tcci->dialg_id = dialogue_id; /* we currently only do one invocation per dialogue */ @@ -147,6 +147,7 @@ static int process_tcap_comp_ind(struct tcap_prim_buf *tcpb) struct tcap_component_ind *tcci = &tcpb->comp; struct map_op_type_info *optinf; void *parsed = NULL; + void *cb_priv; asn_dec_rval_t rv; int rc = 0; @@ -188,11 +189,12 @@ static int process_tcap_comp_ind(struct tcap_prim_buf *tcpb) goto out_reject; } cb = (struct map_op_callback *) tcci->user_ref; + cb_priv = (void *) tcci->user_ref2; if (!cb->cbfn) { rc = -EIO; goto out_reject; } - cb->cbfn(FIXME, parsed, tcpb, priv); + cb->cbfn(FIXME, parsed, tcpb, cb_priv); break; case TCAP_PR_TC_U_ERROR: case TCAP_PR_TC_U_REJECT: diff --git a/src/csl_cha_cco.c b/src/csl_cha_cco.c index 5ce0200..092b350 100644 --- a/src/csl_cha_cco.c +++ b/src/csl_cha_cco.c @@ -79,7 +79,7 @@ static Parameter_t *gen_param(const void *ctx, uint8_t *param, uint32_t param_le int tcap_cha_tc_invoke_req(struct tcap_dialogue *td, uint8_t op_class, int8_t inv_id, int8_t *linked_id, struct OPERATION *op, uint8_t *param, uint32_t param_len, uint32_t timeout, - unsigned long user_ref) + unsigned long user_ref, unsigned long user_ref2) { /* allocate new Invocation State Machine, link it with dialogue */ struct tcap_invocation *ti = tcap_ism_alloc(td, inv_id); @@ -90,6 +90,7 @@ int tcap_cha_tc_invoke_req(struct tcap_dialogue *td, uint8_t op_class, int8_t in return -ENOMEM; ti->user_ref = user_ref; + ti->user_ref2 = user_ref2; ti->inv_timeout = timeout; if (linked_id) { diff --git a/src/tcap.h b/src/tcap.h index a3bcdd8..4dcfcc8 100644 --- a/src/tcap.h +++ b/src/tcap.h @@ -111,6 +111,7 @@ struct tcap_invocation { /* user reference */ unsigned long user_ref; + unsigned long user_ref2; }; @@ -145,7 +146,7 @@ int tcap_ism_terminate(struct tcap_invocation *ti); int tcap_cha_tc_invoke_req(struct tcap_dialogue *td, uint8_t op_class, int8_t inv_id, int8_t *linked_id, struct OPERATION *op, uint8_t *param, uint32_t param_len, uint32_t timeout, - unsigned long user_ref); + unsigned long user_ref, unsigned long user_ref2); /* TC-U-ERROR request (TCL -> CHA) */ int tcap_cha_tc_u_error_req(struct tcap_dialogue *td, int8_t inv_id, diff --git a/src/tcap_user.h b/src/tcap_user.h index bcb146d..5396ab6 100644 --- a/src/tcap_user.h +++ b/src/tcap_user.h @@ -109,7 +109,7 @@ struct tcap_component_ind { } operation; struct tcap_user_info parameter; int last_component; /* is this the last component in the msg? */ - uint32_t timeout_secs; /* Timeout in seconds */ + uint32_t timeout_secs; /* Timeout in seconds */ union { struct { int is_private:1; /* Is this a private (1) or national (0) error code? */ @@ -152,6 +152,7 @@ struct tcap_prim_buf { /* private reference of the caller */ unsigned long user_ref; + unsigned long user_ref2; /* The actual primitive number */ enum tcap_primitive prim; diff --git a/src/tcu.c b/src/tcu.c index 6bc8d74..1103d5a 100644 --- a/src/tcu.c +++ b/src/tcu.c @@ -250,6 +250,7 @@ static int _tcu_comp_ind(enum tcap_primitive prim, struct tcap_invocation *ti, s tcci->dialg_id = ti->dialogue->dialogue_id; tcci->invoke_id = ti->invoke_id; tcpb->user_ref = ti->user_ref; + tcpb->user_ref2 = ti->user_ref2; if (ti->linked_id) { tcci->_linked_id = ti->_linked_id; tcci->linked_id = &tcci->_linked_id; @@ -391,7 +392,7 @@ static int tcap_user_req_comp(struct tcap_prim_buf *tcpb) rc = tcap_cha_tc_invoke_req(td, tcci->op_class, tcci->invoke_id, tcci->linked_id, op, tcci->parameter.data, tcci->parameter.data_len, tcci->timeout_secs, - tcpb->user_ref); + tcpb->user_ref, tcpb->user_ref2); break; case TCAP_PR_TC_RESULT_L: op = generate_op(td, tcci); -- cgit v1.2.3