store callback-private-data (cb_priv) as user_ref2 in tcci and tcap_invocation

This commit is contained in:
Harald Welte 2010-07-29 12:57:20 +02:00
parent ecf0680aa5
commit 0d7cd6c86d
5 changed files with 15 additions and 9 deletions

View File

@ -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:

View File

@ -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) {

View File

@ -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,

View File

@ -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;

View File

@ -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);