Implement TC-U-ERROR.req primitive

This commit is contained in:
Harald Welte 2010-07-19 19:21:16 +02:00
parent 57058f3600
commit d5c4b8ef20
4 changed files with 60 additions and 2 deletions

View File

@ -177,10 +177,34 @@ int tcap_cha_tc_result_req(struct tcap_dialogue *td, int8_t inv_id, int last,
}
/* TC-U-ERROR request TCL -> CHA */
int tcap_cha_tc_u_error_req()
int tcap_cha_tc_u_error_req(struct tcap_dialogue *td, int8_t inv_id,
ErrorCode_t *err, uint8_t *param,
uint32_t param_len)
{
struct tcap_invocation *ti = tcap_ism_lookup(td, inv_id);
struct Component *comp;
if (!ti)
return -ENOENT;
comp = talloc_zero(td, struct Component);
if (!comp)
return -ENOMEM;
/* Assemble requested component */
comp->present = Component_PR_returnError;
if (err)
memcpy(&comp->choice.returnError.errorCode, err, sizeof(*err));
if (param && param_len)
comp->choice.returnError.parameter =
gen_param(comp, param, param_len);
/* Mark component available for this dialogue ID */
asn_sequence_add(&td->pend_comp->list, comp);
return 0;
}
/* TC-U-REJECT.req (TCU -> CHA) */

View File

@ -143,6 +143,11 @@ int tcap_cha_tc_invoke_req(struct tcap_dialogue *td, uint8_t op_class, int8_t in
int8_t *linked_id, struct OPERATION *op,
uint8_t *param, uint32_t param_len, uint32_t timeout);
/* TC-U-ERROR request (TCL -> CHA) */
int tcap_cha_tc_u_error_req(struct tcap_dialogue *td, int8_t inv_id,
ErrorCode_t *err, uint8_t *param,
uint32_t param_len);
/* Dialogue Terminated (CHA <- DHA) */
int tcap_cha_dialg_term(struct tcap_dialogue *td);

View File

@ -113,7 +113,10 @@ struct tcap_component_ind {
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 error;
struct {
int is_private:1; /* Is this a private (1) or national (0) error code? */
long err;
} error;
uint8_t op_class;
/* private */
int8_t _linked_id; /* actual storage for linked ID */

View File

@ -311,6 +311,7 @@ int tcap_tcu_result_nl_ind(struct tcap_invocation *ti, struct OPERATION *oper, P
return _tcu_comp_ind(TCAP_PR_TC_RESULT_NL, ti, oper, param, last);
}
/* Allocate and Fill a OPERATION_t from information inside a tcap_component_ind */
static OPERATION_t *generate_op(struct tcap_dialogue *td, struct tcap_component_ind *tcci)
{
OPERATION_t *op;
@ -333,10 +334,31 @@ static OPERATION_t *generate_op(struct tcap_dialogue *td, struct tcap_component_
return op;
}
/* Allocate and Fill an ErrorCode_t from information inside a tcap_component_ind */
static ErrorCode_t *generate_errcode(struct tcap_dialogue *td, struct tcap_component_ind *tcci)
{
ErrorCode_t *err;
err = talloc_zero(td, ErrorCode_t);
if (!err)
return NULL;
if (tcci->error.is_private) {
err->present = ErrorCode_PR_privateer;
asn_long2INTEGER(&err->choice.privateer, tcci->error.err);
} else {
err->present = ErrorCode_PR_nationaler;
err->choice.nationaler = tcci->error.err;
}
return err;
}
LIB_EXPORTED int tcap_user_req_comp(enum tcap_primitive prim, struct tcap_component_ind *tcci)
{
struct tcap_dialogue *td;
OPERATION_t *op = NULL;
ErrorCode_t *err = NULL;
int rc = 0;
fprintf(stdout, "<- USER_REQ_COMP(%s)\n", tcap_prim_name(prim));
@ -373,6 +395,9 @@ LIB_EXPORTED int tcap_user_req_comp(enum tcap_primitive prim, struct tcap_compon
tcci->parameter.data, tcci->parameter.data_len);
break;
case TCAP_PR_TC_U_ERROR:
rc = tcap_cha_tc_u_error_req(td, tcci->invoke_id, generate_errcode(td, tcci),
tcci->parameter.data, tcci->parameter.data_len);
break;
case TCAP_PR_TC_U_REJECT:
case TCAP_PR_TC_CANCEL:
case TCAP_PR_TC_TIMER_RESET:
@ -382,6 +407,7 @@ LIB_EXPORTED int tcap_user_req_comp(enum tcap_primitive prim, struct tcap_compon
}
talloc_free(op);
talloc_free(err);
return rc;
}