Commit 008a70c9 authored by Lionel Gauthier's avatar Lionel Gauthier

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5274 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent c71fd045
/******************************************************************************* /*******************************************************************************
Eurecom OpenAirInterface Eurecom OpenAirInterface
Copyright(c) 1999 - 2012 Eurecom Copyright(c) 1999 - 2014 Eurecom
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License, under the terms and conditions of the GNU General Public License,
...@@ -30,26 +30,43 @@ ...@@ -30,26 +30,43 @@
/*! \file x2ap_common.c /*! \file x2ap_common.c
* \brief x2ap procedures for both eNB and MME * \brief x2ap procedures for both eNB and MME
* \author Sebastien ROUX <sebastien.roux@eurecom.fr> * \author Sebastien ROUX <sebastien.roux@eurecom.fr>, Lionel GAUTHIER <Lionel.GAUTHIER@eurecom.fr>
* \date 2012 * \date 2014
* \version 0.1 * \version 0.1
*/ */
#include <stdint.h> #include <stdint.h>
#include "x2ap_common.h" #include "x2ap_common.h"
#include "X2AP-PDU.h"
int asn_debug = 0; int asn_debug = 0;
int asn1_xer_print = 0; int asn1_xer_print = 0;
#if defined(EMIT_ASN_DEBUG_EXTERN)
inline void ASN_DEBUG(const char *fmt, ...)
{
if (asn_debug) {
int adi = asn_debug_indent;
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "[ASN1]");
while(adi--) fprintf(stderr, " ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
}
}
#endif
ssize_t x2ap_generate_initiating_message( ssize_t x2ap_generate_initiating_message(
uint8_t **buffer, uint8_t **buffer,
uint32_t *length, uint32_t *length,
e_ProcedureCode procedureCode, e_X2ap_ProcedureCode procedureCode,
Criticality_t criticality, X2ap_Criticality_t criticality,
asn_TYPE_descriptor_t *td, asn_TYPE_descriptor_t *td,
void *sptr) { void *sptr)
{
X2AP_PDU_t pdu; X2AP_PDU_t pdu;
ssize_t encoded; ssize_t encoded;
...@@ -60,10 +77,15 @@ ssize_t x2ap_generate_initiating_message( ...@@ -60,10 +77,15 @@ ssize_t x2ap_generate_initiating_message(
pdu.choice.initiatingMessage.criticality = criticality; pdu.choice.initiatingMessage.criticality = criticality;
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, sptr); ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, sptr);
if (asn1_xer_print) if (asn1_xer_print) {
xer_fprint(stdout,&asn_DEF_X2AP_PDU,(void*)&pdu); xer_fprint(stdout, &asn_DEF_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, (void**)buffer)) < 0) { if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu,
(void **)buffer)) < 0) {
return -1; return -1;
} }
...@@ -74,11 +96,11 @@ ssize_t x2ap_generate_initiating_message( ...@@ -74,11 +96,11 @@ ssize_t x2ap_generate_initiating_message(
ssize_t x2ap_generate_successfull_outcome( ssize_t x2ap_generate_successfull_outcome(
uint8_t **buffer, uint8_t **buffer,
uint32_t *length, uint32_t *length,
e_ProcedureCode procedureCode, e_X2ap_ProcedureCode procedureCode,
Criticality_t criticality, X2ap_Criticality_t criticality,
asn_TYPE_descriptor_t *td, asn_TYPE_descriptor_t *td,
void *sptr) { void *sptr)
{
X2AP_PDU_t pdu; X2AP_PDU_t pdu;
ssize_t encoded; ssize_t encoded;
...@@ -89,7 +111,15 @@ ssize_t x2ap_generate_successfull_outcome( ...@@ -89,7 +111,15 @@ ssize_t x2ap_generate_successfull_outcome(
pdu.choice.successfulOutcome.criticality = criticality; pdu.choice.successfulOutcome.criticality = criticality;
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr); ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu, (void**)buffer)) < 0) { if (asn1_xer_print) {
xer_fprint(stdout, &asn_DEF_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,
(void **)buffer)) < 0) {
return -1; return -1;
} }
...@@ -101,11 +131,11 @@ ssize_t x2ap_generate_successfull_outcome( ...@@ -101,11 +131,11 @@ ssize_t x2ap_generate_successfull_outcome(
ssize_t x2ap_generate_unsuccessfull_outcome( ssize_t x2ap_generate_unsuccessfull_outcome(
uint8_t **buffer, uint8_t **buffer,
uint32_t *length, uint32_t *length,
e_ProcedureCode procedureCode, e_X2ap_ProcedureCode procedureCode,
Criticality_t criticality, X2ap_Criticality_t criticality,
asn_TYPE_descriptor_t *td, asn_TYPE_descriptor_t *td,
void *sptr) { void *sptr)
{
X2AP_PDU_t pdu; X2AP_PDU_t pdu;
ssize_t encoded; ssize_t encoded;
...@@ -116,7 +146,15 @@ ssize_t x2ap_generate_unsuccessfull_outcome( ...@@ -116,7 +146,15 @@ ssize_t x2ap_generate_unsuccessfull_outcome(
pdu.choice.successfulOutcome.criticality = criticality; pdu.choice.successfulOutcome.criticality = criticality;
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr); ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
if ((encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, &pdu, (void**)buffer)) < 0) { if (asn1_xer_print) {
xer_fprint(stdout, &asn_DEF_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,
(void **)buffer)) < 0) {
return -1; return -1;
} }
...@@ -125,27 +163,31 @@ ssize_t x2ap_generate_unsuccessfull_outcome( ...@@ -125,27 +163,31 @@ ssize_t x2ap_generate_unsuccessfull_outcome(
return encoded; return encoded;
} }
IE_t *x2ap_new_ie( X2ap_IE_t *x2ap_new_ie(
ProtocolIE_ID_t id, X2ap_ProtocolIE_ID_t id,
Criticality_t criticality, X2ap_Criticality_t criticality,
asn_TYPE_descriptor_t *type, asn_TYPE_descriptor_t *type,
void *sptr) { void *sptr)
{
X2ap_IE_t *buff;
IE_t *buff; if ((buff = malloc(sizeof(X2ap_IE_t))) == NULL) {
if ((buff = malloc(sizeof(IE_t))) == NULL) {
// Possible error on malloc // Possible error on malloc
return NULL; return NULL;
} }
memset((void*)buff, 0, sizeof(IE_t)); memset((void *)buff, 0, sizeof(X2ap_IE_t));
buff->id = id; buff->id = id;
buff->criticality = criticality; buff->criticality = criticality;
ANY_fromType_aper(&buff->value, type, sptr); 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 (asn1_xer_print)
if (xer_fprint(stdout, &asn_DEF_IE, buff) < 0) { if (xer_fprint(stdout, &asn_DEF_X2ap_IE, buff) < 0) {
free(buff); free(buff);
return NULL; return NULL;
} }
...@@ -153,6 +195,7 @@ IE_t *x2ap_new_ie( ...@@ -153,6 +195,7 @@ IE_t *x2ap_new_ie(
return buff; return buff;
} }
void x2ap_handle_criticality(e_Criticality criticality) { void x2ap_handle_criticality(X2ap_Criticality_t criticality)
{
} }
...@@ -288,8 +288,8 @@ typedef int (*x2ap_message_decoded_callback)( ...@@ -288,8 +288,8 @@ typedef int (*x2ap_message_decoded_callback)(
ssize_t x2ap_generate_successfull_outcome( ssize_t x2ap_generate_successfull_outcome(
uint8_t **buffer, uint8_t **buffer,
uint32_t *length, uint32_t *length,
e_ProcedureCode procedureCode, e_X2ap_ProcedureCode procedureCode,
Criticality_t criticality, X2ap_Criticality_t criticality,
asn_TYPE_descriptor_t *td, asn_TYPE_descriptor_t *td,
void *sptr); void *sptr);
...@@ -305,8 +305,8 @@ ssize_t x2ap_generate_successfull_outcome( ...@@ -305,8 +305,8 @@ ssize_t x2ap_generate_successfull_outcome(
ssize_t x2ap_generate_initiating_message( ssize_t x2ap_generate_initiating_message(
uint8_t **buffer, uint8_t **buffer,
uint32_t *length, uint32_t *length,
e_ProcedureCode procedureCode, e_X2ap_ProcedureCode procedureCode,
Criticality_t criticality, X2ap_Criticality_t criticality,
asn_TYPE_descriptor_t *td, asn_TYPE_descriptor_t *td,
void *sptr); void *sptr);
...@@ -322,8 +322,8 @@ ssize_t x2ap_generate_initiating_message( ...@@ -322,8 +322,8 @@ ssize_t x2ap_generate_initiating_message(
ssize_t x2ap_generate_unsuccessfull_outcome( ssize_t x2ap_generate_unsuccessfull_outcome(
uint8_t **buffer, uint8_t **buffer,
uint32_t *length, uint32_t *length,
e_ProcedureCode procedureCode, e_X2ap_ProcedureCode procedureCode,
Criticality_t criticality, X2ap_Criticality_t criticality,
asn_TYPE_descriptor_t *td, asn_TYPE_descriptor_t *td,
void *sptr); void *sptr);
...@@ -334,15 +334,16 @@ ssize_t x2ap_generate_unsuccessfull_outcome( ...@@ -334,15 +334,16 @@ ssize_t x2ap_generate_unsuccessfull_outcome(
\param sptr Structure to be encoded in the value field \param sptr Structure to be encoded in the value field
@returns a pointer to the newly created IE structure or NULL in case of failure @returns a pointer to the newly created IE structure or NULL in case of failure
**/ **/
IE_t *x2ap_new_ie(ProtocolIE_ID_t id, X2ap_IE_t *x2ap_new_ie(
Criticality_t criticality, X2ap_ProtocolIE_ID_t id,
asn_TYPE_descriptor_t *type, X2ap_Criticality_t criticality,
void *sptr); asn_TYPE_descriptor_t *type,
void *sptr);
/** \brief Handle criticality /** \brief Handle criticality
\param criticality Criticality of the IE \param criticality Criticality of the IE
@returns void @returns void
**/ **/
void x2ap_handle_criticality(e_Criticality criticality); void x2ap_handle_criticality(X2ap_Criticality_t criticality);
#endif /* X2AP_COMMON_H_ */ #endif /* X2AP_COMMON_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment