diff options
author | Harald Welte <laforge@gnumonks.org> | 2015-09-10 23:49:45 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2015-09-10 23:49:45 +0200 |
commit | e2e5d4dd53749549e058335e69014f5b85d8cc7f (patch) | |
tree | 71b5f4cbcfdc8582d47ccfbb3337e30da510f3d6 /src/rua_common.c | |
parent | 350814a5cb1abaf3b4c00efd14fbd4a28a5149db (diff) |
Back RUA/RANAP integration until RANAP Reset works for cs+ps
The hNodeB is now actively transmitting and we are getting up to the
HNBAP UE-REGISTER.req with the IMSI of the MS.
Diffstat (limited to 'src/rua_common.c')
-rw-r--r-- | src/rua_common.c | 95 |
1 files changed, 80 insertions, 15 deletions
diff --git a/src/rua_common.c b/src/rua_common.c index 637cd72..8f4da12 100644 --- a/src/rua_common.c +++ b/src/rua_common.c @@ -7,41 +7,106 @@ extern int asn1_xer_print; +static const struct value_string rua_cause_radio_vals[] = { + { RUA_CauseRadioNetwork_normal, "normal" }, + { RUA_CauseRadioNetwork_connect_failed, "connect failed" }, + { RUA_CauseRadioNetwork_network_release, "network release" }, + { RUA_CauseRadioNetwork_unspecified, "unspecified" }, + { 0, NULL } +}; + +static const struct value_string rua_cause_transp_vals[] = { + { RUA_CauseTransport_transport_resource_unavailable, "resource unavailable" }, + { RUA_CauseTransport_unspecified, "unspecified" }, + { 0, NULL } +}; + +static const struct value_string rua_cause_prot_vals[] = { + { RUA_CauseProtocol_transfer_syntax_error, "syntax error" }, + { RUA_CauseProtocol_abstract_syntax_error_reject, + "abstract syntax error; reject" }, + { RUA_CauseProtocol_abstract_syntax_error_ignore_and_notify, + "abstract syntax error; ignore and notify" }, + { RUA_CauseProtocol_message_not_compatible_with_receiver_state, + "message not compatible with receiver state" }, + { RUA_CauseProtocol_semantic_error, "semantic error" }, + { RUA_CauseProtocol_unspecified, "unspecified" }, + { RUA_CauseProtocol_abstract_syntax_error_falsely_constructed_message, + "falsely constructed message" }, + { 0, NULL } +}; + +static const struct value_string rua_cause_misc_vals[] = { + { RUA_CauseMisc_processing_overload, "processing overload" }, + { RUA_CauseMisc_hardware_failure, "hardware failure" }, + { RUA_CauseMisc_o_and_m_intervention, "OAM intervention" }, + { RUA_CauseMisc_unspecified, "unspecified" }, + { 0, NULL } +}; + +char *rua_cause_str(RUA_Cause_t *cause) +{ + static char buf[32]; + + switch (cause->present) { + case RUA_Cause_PR_radioNetwork: + snprintf(buf, sizeof(buf), "radio(%s)", + get_value_string(rua_cause_radio_vals, + cause->choice.radioNetwork)); + break; + case RUA_Cause_PR_transport: + snprintf(buf, sizeof(buf), "transport(%s)", + get_value_string(rua_cause_transp_vals, + cause->choice.transport)); + break; + case RUA_Cause_PR_protocol: + snprintf(buf, sizeof(buf), "protocol(%s)", + get_value_string(rua_cause_prot_vals, + cause->choice.protocol)); + break; + case RUA_Cause_PR_misc: + snprintf(buf, sizeof(buf), "misc(%s)", + get_value_string(rua_cause_misc_vals, + cause->choice.misc)); + break; + } + return buf; +} + + static struct msgb *rua_msgb_alloc(void) { return msgb_alloc(1024, "RUA Tx"); } -#if 0 -ssize_t rua_generate_initiating_message(uint8_t ** buffer, - uint32_t * length, +struct msgb *rua_generate_initiating_message( e_RUA_ProcedureCode procedureCode, RUA_Criticality_t criticality, asn_TYPE_descriptor_t * td, void *sptr) { RUA_RUA_PDU_t pdu; + struct msgb *msg = rua_msgb_alloc(); + asn_enc_rval_t rval; ssize_t encoded; memset(&pdu, 0, sizeof(pdu)); - pdu.present = RUA_RUA_PDU_PR_initiatingMessage; pdu.choice.initiatingMessage.procedureCode = procedureCode; pdu.choice.initiatingMessage.criticality = criticality; ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, sptr); - if (asn1_xer_print) - xer_fprint(stdout, &asn_DEF_RUA_RUA_PDU, (void *)&pdu); - - if ((encoded = - aper_encode_to_new_buffer(&asn_DEF_RUA_RUA_PDU, 0, &pdu, - (void **)buffer)) < 0) { - return -1; + rval = aper_encode_to_buffer(&asn_DEF_RUA_RUA_PDU, &pdu, + msg->data, msgb_tailroom(msg)); + if (rval.encoded < 0) { + LOGP(DMAIN, LOGL_ERROR, "Error encoding type %s\n", rval.failed_type->name); + msgb_free(msg); + return NULL; } - *length = encoded; - return encoded; + msgb_put(msg, rval.encoded/8); + + return msg; } -#endif struct msgb *rua_generate_successful_outcome( e_RUA_ProcedureCode procedureCode, @@ -74,7 +139,7 @@ struct msgb *rua_generate_successful_outcome( return NULL; } - msgb_put(msg, rval.encoded); + msgb_put(msg, rval.encoded/8); return msg; } |