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:
+23
-64
@@ -29,7 +29,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "x2ap_common.h"
|
||||
#include "X2AP-PDU.h"
|
||||
#include "X2AP_X2AP-PDU.h"
|
||||
|
||||
int asn_debug = 0;
|
||||
int asn1_xer_print = 0;
|
||||
@@ -55,29 +55,27 @@ inline void ASN_DEBUG(const char *fmt, ...)
|
||||
ssize_t x2ap_generate_initiating_message(
|
||||
uint8_t **buffer,
|
||||
uint32_t *length,
|
||||
X2ap_ProcedureCode_t procedureCode,
|
||||
X2ap_Criticality_t criticality,
|
||||
X2AP_ProcedureCode_t procedureCode,
|
||||
X2AP_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
void *sptr)
|
||||
{
|
||||
X2AP_PDU_t pdu;
|
||||
X2AP_X2AP_PDU_t pdu;
|
||||
ssize_t encoded;
|
||||
|
||||
memset(&pdu, 0, sizeof(X2AP_PDU_t));
|
||||
|
||||
pdu.present = X2AP_PDU_PR_initiatingMessage;
|
||||
memset(&pdu, 0, sizeof(X2AP_X2AP_PDU_t));
|
||||
pdu.present = X2AP_X2AP_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_X2AP_PDU, (void *)&pdu);
|
||||
xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, (void *)&pdu);
|
||||
}
|
||||
|
||||
/* We can safely free list of IE from sptr */
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
|
||||
|
||||
if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu,
|
||||
if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_X2AP_PDU, 0, &pdu,
|
||||
(void **)buffer)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -89,107 +87,68 @@ ssize_t x2ap_generate_initiating_message(
|
||||
ssize_t x2ap_generate_successfull_outcome(
|
||||
uint8_t **buffer,
|
||||
uint32_t *length,
|
||||
X2ap_ProcedureCode_t procedureCode,
|
||||
X2ap_Criticality_t criticality,
|
||||
X2AP_ProcedureCode_t procedureCode,
|
||||
X2AP_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
void *sptr)
|
||||
{
|
||||
X2AP_PDU_t pdu;
|
||||
X2AP_X2AP_PDU_t pdu;
|
||||
ssize_t encoded;
|
||||
|
||||
memset(&pdu, 0, sizeof(X2AP_PDU_t));
|
||||
|
||||
pdu.present = X2AP_PDU_PR_successfulOutcome;
|
||||
memset(&pdu, 0, sizeof(X2AP_X2AP_PDU_t));
|
||||
pdu.present = X2AP_X2AP_PDU_PR_successfulOutcome;
|
||||
pdu.choice.successfulOutcome.procedureCode = procedureCode;
|
||||
pdu.choice.successfulOutcome.criticality = criticality;
|
||||
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
|
||||
|
||||
if (asn1_xer_print) {
|
||||
xer_fprint(stdout, &asn_DEF_X2AP_PDU, (void *)&pdu);
|
||||
xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, (void *)&pdu);
|
||||
}
|
||||
|
||||
/* We can safely free list of IE from sptr */
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
|
||||
|
||||
if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu,
|
||||
if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_X2AP_PDU, 0, &pdu,
|
||||
(void **)buffer)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*length = encoded;
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
ssize_t x2ap_generate_unsuccessfull_outcome(
|
||||
uint8_t **buffer,
|
||||
uint32_t *length,
|
||||
X2ap_ProcedureCode_t procedureCode,
|
||||
X2ap_Criticality_t criticality,
|
||||
X2AP_ProcedureCode_t procedureCode,
|
||||
X2AP_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
void *sptr)
|
||||
{
|
||||
X2AP_PDU_t pdu;
|
||||
X2AP_X2AP_PDU_t pdu;
|
||||
ssize_t encoded;
|
||||
|
||||
memset(&pdu, 0, sizeof(X2AP_PDU_t));
|
||||
|
||||
pdu.present = X2AP_PDU_PR_unsuccessfulOutcome;
|
||||
memset(&pdu, 0, sizeof(X2AP_X2AP_PDU_t));
|
||||
pdu.present = X2AP_X2AP_PDU_PR_unsuccessfulOutcome;
|
||||
pdu.choice.successfulOutcome.procedureCode = procedureCode;
|
||||
pdu.choice.successfulOutcome.criticality = criticality;
|
||||
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
|
||||
|
||||
if (asn1_xer_print) {
|
||||
xer_fprint(stdout, &asn_DEF_X2AP_PDU, (void *)&pdu);
|
||||
xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, (void *)&pdu);
|
||||
}
|
||||
|
||||
/* We can safely free list of IE from sptr */
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(*td, sptr);
|
||||
|
||||
if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu,
|
||||
if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_X2AP_PDU, 0, &pdu,
|
||||
(void **)buffer)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*length = encoded;
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
X2ap_IE_t *x2ap_new_ie(
|
||||
X2ap_ProtocolIE_ID_t id,
|
||||
X2ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t *type,
|
||||
void *sptr)
|
||||
{
|
||||
X2ap_IE_t *buff;
|
||||
|
||||
if ((buff = malloc(sizeof(X2ap_IE_t))) == NULL) {
|
||||
// Possible error on malloc
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset((void *)buff, 0, sizeof(X2ap_IE_t));
|
||||
|
||||
buff->id = id;
|
||||
buff->criticality = criticality;
|
||||
|
||||
if (ANY_fromType_aper(&buff->value, type, sptr) < 0) {
|
||||
fprintf(stderr, "Encoding of %s failed\n", type->name);
|
||||
free(buff);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (asn1_xer_print)
|
||||
if (xer_fprint(stdout, &asn_DEF_X2ap_IE, buff) < 0) {
|
||||
free(buff);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
||||
void x2ap_handle_criticality(X2ap_Criticality_t criticality)
|
||||
void x2ap_handle_criticality(X2AP_Criticality_t criticality)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user