Use an un-official community collaboration version of asn1c

1. It's no need to modify LTE-RRC's ASN.1 file for enabling option group
   feature in generate_asn1.
2. It's no need to patch the C header files generated from
   LTE-RRC/S1AP/X2AP's ASN.1 in fix_asn1.
3. It's no need to pre-process S1AP/X2AP's ASN.1 for enabling information
   object class feature by asn1tostruct.py.

This commit requires an un-official version of asn1c which are
collaboration of asn1c community members and `build_helper` is modified
in this commit accordingly :

  https://github.com/brchiu/asn1c/tree/velichkov_s1ap_plus_option_group

This asn1c can also convert ASN.1 of 5G NR RRC (38.331, v15.1.0) and
generate C files with -findirect-choice command line option without
tweaking ASN.1 file.

Examples for how to use this asn1c for S1AP are in S1AP files, e.g.
s1ap_eNB_nas_procedures.c and s1ap_eNB_handler.c.

There is an modified openair-cn (based on tag 0.5.0) with this new asn1c at :

  https://github.com/brchiu/openair-cn/tree/new-asn1c

Basic S1AP interaction and data transfer operation between OAI eNB and
this modified openair-cn has been tested.

Note: Community version of asn1c is keeping evolved to provide better usage.
This commit is contained in:
Bi-Ruei, Chiu
2018-07-13 10:04:46 +08:00
parent df1e5b21c8
commit a247907d3a
103 changed files with 159551 additions and 24258 deletions
+64 -34
View File
@@ -28,7 +28,6 @@
#include "s1ap_eNB_default_values.h"
#include "s1ap_common.h"
#include "s1ap_ies_defs.h"
#include "s1ap_eNB_defs.h"
#include "s1ap_eNB.h"
@@ -40,29 +39,60 @@
static
void s1ap_eNB_generate_trace_failure(struct s1ap_eNB_ue_context_s *ue_desc_p,
S1ap_E_UTRAN_Trace_ID_t *trace_id,
S1ap_Cause_t *cause_p)
S1AP_E_UTRAN_Trace_ID_t *trace_id,
S1AP_Cause_t *cause_p)
{
s1ap_message message;
S1ap_TraceFailureIndicationIEs_t *trace_failure_p;
uint8_t *buffer;
uint32_t length;
S1AP_S1AP_PDU_t pdu;
S1AP_TraceFailureIndication_t *out;
S1AP_TraceFailureIndicationIEs_t *ie;
uint8_t *buffer = NULL;
uint32_t length;
DevAssert(ue_desc_p != NULL);
DevAssert(trace_id != NULL);
DevAssert(cause_p != NULL);
memset(&message, 0, sizeof(s1ap_message));
/* Prepare the S1AP message to encode */
memset(&pdu, 0, sizeof(pdu));
pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_TraceFailureIndication;
pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore;
pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_TraceFailureIndication;
out = &pdu.choice.initiatingMessage.value.choice.TraceFailureIndication;
trace_failure_p = &message.msg.s1ap_TraceFailureIndicationIEs;
/* mandatory */
ie = (S1AP_TraceFailureIndicationIEs_t *)calloc(1, sizeof(S1AP_TraceFailureIndicationIEs_t));
ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
ie->criticality = S1AP_Criticality_reject;
ie->value.present = S1AP_TraceFailureIndicationIEs__value_PR_MME_UE_S1AP_ID;
ie->value.choice.MME_UE_S1AP_ID = ue_desc_p->mme_ue_s1ap_id;
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
trace_failure_p->mme_ue_s1ap_id = ue_desc_p->mme_ue_s1ap_id;
trace_failure_p->eNB_UE_S1AP_ID = ue_desc_p->eNB_ue_s1ap_id;
/* mandatory */
ie = (S1AP_TraceFailureIndicationIEs_t *)calloc(1, sizeof(S1AP_TraceFailureIndicationIEs_t));
ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
ie->criticality = S1AP_Criticality_reject;
ie->value.present = S1AP_TraceFailureIndicationIEs__value_PR_ENB_UE_S1AP_ID;
ie->value.choice.ENB_UE_S1AP_ID = ue_desc_p->eNB_ue_s1ap_id;
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
memcpy(&trace_failure_p->e_UTRAN_Trace_ID, trace_id, sizeof(S1ap_E_UTRAN_Trace_ID_t));
memcpy(&trace_failure_p->cause, cause_p, sizeof(S1ap_Cause_t));
/* mandatory */
ie = (S1AP_TraceFailureIndicationIEs_t *)calloc(1, sizeof(S1AP_TraceFailureIndicationIEs_t));
ie->id = S1AP_ProtocolIE_ID_id_E_UTRAN_Trace_ID;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_TraceFailureIndicationIEs__value_PR_E_UTRAN_Trace_ID;
memcpy(&ie->value.choice.E_UTRAN_Trace_ID, trace_id, sizeof(S1AP_E_UTRAN_Trace_ID_t));
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
/* mandatory */
ie = (S1AP_TraceFailureIndicationIEs_t *)calloc(1, sizeof(S1AP_TraceFailureIndicationIEs_t));
ie->id = S1AP_ProtocolIE_ID_id_Cause;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_TraceFailureIndicationIEs__value_PR_Cause;
memcpy(&ie->value.choice.Cause, cause_p, sizeof(S1AP_Cause_t));
ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) {
return;
}
@@ -71,46 +101,46 @@ void s1ap_eNB_generate_trace_failure(struct s1ap_eNB_ue_context_s *ue_desc_p,
length, ue_desc_p->tx_stream);
}
int s1ap_eNB_handle_trace_start(uint32_t assoc_id,
uint32_t stream,
struct s1ap_message_s *message_p)
int s1ap_eNB_handle_trace_start(uint32_t assoc_id,
uint32_t stream,
S1AP_S1AP_PDU_t *pdu)
{
S1ap_TraceStartIEs_t *trace_start_p;
S1AP_TraceStart_t *container;
S1AP_TraceStartIEs_t *ie;
struct s1ap_eNB_ue_context_s *ue_desc_p;
struct s1ap_eNB_mme_data_s *mme_ref_p;
DevAssert(message_p != NULL);
DevAssert(pdu != NULL);
trace_start_p = &message_p->msg.s1ap_TraceStartIEs;
container = &pdu->choice.initiatingMessage.value.choice.TraceStart;
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_TraceStartIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, TRUE);
mme_ref_p = s1ap_eNB_get_MME(NULL, assoc_id, 0);
DevAssert(mme_ref_p != NULL);
if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_ref_p->s1ap_eNB_instance,
trace_start_p->eNB_UE_S1AP_ID)) == NULL) {
ie->value.choice.ENB_UE_S1AP_ID)) == NULL) {
/* Could not find context associated with this eNB_ue_s1ap_id -> generate
* trace failure indication.
*/
S1ap_E_UTRAN_Trace_ID_t trace_id;
S1ap_Cause_t cause;
memset(&trace_id, 0, sizeof(S1ap_E_UTRAN_Trace_ID_t));
memset(&cause, 0, sizeof(S1ap_Cause_t));
cause.present = S1ap_Cause_PR_radioNetwork;
cause.choice.radioNetwork = S1ap_CauseRadioNetwork_unknown_pair_ue_s1ap_id;
S1AP_E_UTRAN_Trace_ID_t trace_id;
S1AP_Cause_t cause;
memset(&trace_id, 0, sizeof(S1AP_E_UTRAN_Trace_ID_t));
memset(&cause, 0, sizeof(S1AP_Cause_t));
cause.present = S1AP_Cause_PR_radioNetwork;
cause.choice.radioNetwork = S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id;
s1ap_eNB_generate_trace_failure(ue_desc_p, &trace_id, &cause);
}
return 0;
}
int s1ap_eNB_handle_deactivate_trace(uint32_t assoc_id,
uint32_t stream,
struct s1ap_message_s *message_p)
int s1ap_eNB_handle_deactivate_trace(uint32_t assoc_id,
uint32_t stream,
S1AP_S1AP_PDU_t *message_p)
{
// S1ap_DeactivateTraceIEs_t *deactivate_trace_p;
// S1AP_DeactivateTraceIEs_t *deactivate_trace_p;
//
// deactivate_trace_p = &message_p->msg.deactivateTraceIEs;