change encode buffer to pkbuf
This commit is contained in:
parent
b6ec39d281
commit
8d747b50ea
|
@ -1,32 +1,3 @@
|
|||
/*
|
||||
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those
|
||||
* of the authors and should not be interpreted as representing official policies,
|
||||
* either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
#define TRACE_MODULE _decoder
|
||||
|
||||
#include "core_debug.h"
|
||||
|
|
|
@ -1,171 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2015, EURECOM (www.eurecom.fr)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those
|
||||
* of the authors and should not be interpreted as representing official policies,
|
||||
* either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
#define TRACE_MODULE encoder
|
||||
#define TRACE_MODULE _encoder
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "s1ap_message.h"
|
||||
|
||||
static inline int s1ap_encode_initiating(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length);
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_successfull_outcome(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length);
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_unsuccessfull_outcome(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length);
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf);
|
||||
|
||||
static inline int s1ap_encode_initial_context_setup_request(
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_s1setupresponse(
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_s1setupfailure(
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_downlink_nas_transport(
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf);
|
||||
static inline int s1ap_encode_ue_context_release_command (
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf);
|
||||
|
||||
ssize_t s1ap_generate_initiating_message(pkbuf_t *pkbuf,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr);
|
||||
ssize_t s1ap_generate_successfull_outcome(pkbuf_t *pkbuf,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr);
|
||||
ssize_t s1ap_generate_unsuccessfull_outcome(pkbuf_t *pkbuf,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr);
|
||||
|
||||
int s1ap_encode_pdu(pkbuf_t **pkb, s1ap_message *message_p)
|
||||
{
|
||||
int ret = -1;
|
||||
uint8_t **buffer = 0;
|
||||
uint32_t *length = 0;
|
||||
int encoded = -1;
|
||||
|
||||
d_assert (message_p, return -1, "Null param");
|
||||
|
||||
*pkb = pkbuf_alloc(0, S1AP_SDU_SIZE);
|
||||
d_assert(*pkb, return -1, "Null Param");
|
||||
|
||||
switch (message_p->direction)
|
||||
{
|
||||
case S1AP_PDU_PR_initiatingMessage:
|
||||
ret = s1ap_encode_initiating(message_p, buffer, length);
|
||||
encoded = s1ap_encode_initiating(message_p, *pkb);
|
||||
break;
|
||||
|
||||
case S1AP_PDU_PR_successfulOutcome:
|
||||
ret = s1ap_encode_successfull_outcome(message_p, buffer, length);
|
||||
encoded = s1ap_encode_successfull_outcome(message_p, *pkb);
|
||||
break;
|
||||
|
||||
case S1AP_PDU_PR_unsuccessfulOutcome:
|
||||
ret = s1ap_encode_unsuccessfull_outcome(message_p, buffer, length);
|
||||
encoded = s1ap_encode_unsuccessfull_outcome(message_p, *pkb);
|
||||
break;
|
||||
|
||||
default:
|
||||
d_warn("Unknown message outcome (%d) or not implemented",
|
||||
(int)message_p->direction);
|
||||
pkbuf_free(*pkb);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (encoded < 0)
|
||||
{
|
||||
pkbuf_free(*pkb);
|
||||
return -1;
|
||||
}
|
||||
|
||||
(*pkb)->len = encoded;
|
||||
return encoded;
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_initiating(
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
switch (message_p->procedureCode)
|
||||
{
|
||||
case S1ap_ProcedureCode_id_downlinkNASTransport:
|
||||
return s1ap_encode_downlink_nas_transport(message_p, pkbuf);
|
||||
|
||||
case S1ap_ProcedureCode_id_InitialContextSetup:
|
||||
return s1ap_encode_initial_context_setup_request(message_p, pkbuf);
|
||||
|
||||
case S1ap_ProcedureCode_id_UEContextRelease:
|
||||
return s1ap_encode_ue_context_release_command(message_p, pkbuf);
|
||||
|
||||
default:
|
||||
d_warn("Unknown procedure ID (%d) for initiating message_p\n",
|
||||
(int)message_p->procedureCode);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
*pkb = pkbuf_alloc(0, *length);
|
||||
d_assert(*pkb, return -1, "Null Param");
|
||||
memcpy((*pkb)->payload, *buffer, *length);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t s1ap_generate_initiating_message(uint8_t **buffer, uint32_t *length,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr)
|
||||
static inline int s1ap_encode_successfull_outcome(
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
S1AP_PDU_t pdu;
|
||||
ssize_t encoded;
|
||||
|
||||
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
||||
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
||||
pdu.choice.initiatingMessage.procedureCode = procedureCode;
|
||||
pdu.choice.initiatingMessage.criticality = criticality;
|
||||
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, sptr);
|
||||
|
||||
/*
|
||||
* 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_S1AP_PDU, 0, &pdu, (void **)buffer)) < 0)
|
||||
switch (message_p->procedureCode)
|
||||
{
|
||||
d_error("Encoding of %s failed", td->name);
|
||||
return -1;
|
||||
case S1ap_ProcedureCode_id_S1Setup:
|
||||
return s1ap_encode_s1setupresponse(message_p, pkbuf);
|
||||
|
||||
default:
|
||||
d_warn("Unknown procedure ID (%d) for successfull "
|
||||
"outcome message\n", (int)message_p->procedureCode);
|
||||
break;
|
||||
}
|
||||
|
||||
*length = encoded;
|
||||
return encoded;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t s1ap_generate_successfull_outcome(uint8_t **buffer, uint32_t *length,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr)
|
||||
static inline int s1ap_encode_unsuccessfull_outcome(
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
S1AP_PDU_t pdu;
|
||||
ssize_t encoded;
|
||||
|
||||
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
||||
pdu.present = S1AP_PDU_PR_successfulOutcome;
|
||||
pdu.choice.successfulOutcome.procedureCode = procedureCode;
|
||||
pdu.choice.successfulOutcome.criticality = criticality;
|
||||
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
|
||||
|
||||
/*
|
||||
* 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_S1AP_PDU, 0, &pdu, (void **)buffer)) < 0)
|
||||
switch (message_p->procedureCode)
|
||||
{
|
||||
d_error("Encoding of %s failed", td->name);
|
||||
return -1;
|
||||
case S1ap_ProcedureCode_id_S1Setup:
|
||||
return s1ap_encode_s1setupfailure(message_p, pkbuf);
|
||||
|
||||
default:
|
||||
d_warn("Unknown procedure ID (%d) for unsuccessfull "
|
||||
"outcome message\n", (int)message_p->procedureCode);
|
||||
break;
|
||||
}
|
||||
|
||||
*length = encoded;
|
||||
return encoded;
|
||||
}
|
||||
|
||||
ssize_t s1ap_generate_unsuccessfull_outcome(uint8_t **buffer, uint32_t *length,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr)
|
||||
{
|
||||
S1AP_PDU_t pdu;
|
||||
ssize_t encoded;
|
||||
|
||||
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
||||
pdu.present = S1AP_PDU_PR_unsuccessfulOutcome;
|
||||
pdu.choice.successfulOutcome.procedureCode = procedureCode;
|
||||
pdu.choice.successfulOutcome.criticality = criticality;
|
||||
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
|
||||
|
||||
/*
|
||||
* 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_S1AP_PDU, 0, &pdu, (void **)buffer)) < 0)
|
||||
{
|
||||
d_error("Encoding of %s failed", td->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*length = encoded;
|
||||
return encoded;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_initial_context_setup_request(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length)
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
S1ap_InitialContextSetupRequest_t initialContextSetupRequest;
|
||||
S1ap_InitialContextSetupRequest_t *initialContextSetupRequest_p =
|
||||
|
@ -181,14 +145,14 @@ static inline int s1ap_encode_initial_context_setup_request(
|
|||
return -1;
|
||||
}
|
||||
|
||||
return s1ap_generate_initiating_message(buffer, length,
|
||||
return s1ap_generate_initiating_message(pkbuf,
|
||||
S1ap_ProcedureCode_id_InitialContextSetup,
|
||||
S1ap_Criticality_reject, &asn_DEF_S1ap_InitialContextSetupRequest,
|
||||
initialContextSetupRequest_p);
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_s1setupresponse(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length)
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
S1ap_S1SetupResponse_t s1SetupResponse;
|
||||
S1ap_S1SetupResponse_t *s1SetupResponse_p = &s1SetupResponse;
|
||||
|
@ -201,13 +165,13 @@ static inline int s1ap_encode_s1setupresponse(
|
|||
return -1;
|
||||
}
|
||||
|
||||
return s1ap_generate_successfull_outcome(buffer, length,
|
||||
return s1ap_generate_successfull_outcome(pkbuf,
|
||||
S1ap_ProcedureCode_id_S1Setup, message_p->criticality,
|
||||
&asn_DEF_S1ap_S1SetupResponse, s1SetupResponse_p);
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_s1setupfailure(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length)
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
S1ap_S1SetupFailure_t s1SetupFailure;
|
||||
S1ap_S1SetupFailure_t *s1SetupFailure_p = &s1SetupFailure;
|
||||
|
@ -220,13 +184,13 @@ static inline int s1ap_encode_s1setupfailure(
|
|||
return -1;
|
||||
}
|
||||
|
||||
return s1ap_generate_unsuccessfull_outcome(buffer, length,
|
||||
return s1ap_generate_unsuccessfull_outcome(pkbuf,
|
||||
S1ap_ProcedureCode_id_S1Setup, message_p->criticality,
|
||||
&asn_DEF_S1ap_S1SetupFailure, s1SetupFailure_p);
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_downlink_nas_transport(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length)
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
S1ap_DownlinkNASTransport_t downlinkNasTransport;
|
||||
S1ap_DownlinkNASTransport_t *downlinkNasTransport_p = &downlinkNasTransport;
|
||||
|
@ -236,7 +200,7 @@ static inline int s1ap_encode_downlink_nas_transport(
|
|||
/*
|
||||
* Convert IE structure into asn1 message_p
|
||||
*/
|
||||
if (s1ap_encode_s1ap_downlinknastransport_ies( downlinkNasTransport_p,
|
||||
if (s1ap_encode_s1ap_downlinknastransport_ies(downlinkNasTransport_p,
|
||||
&message_p->msg.s1ap_DownlinkNASTransport_IEs) < 0)
|
||||
{
|
||||
return -1;
|
||||
|
@ -245,13 +209,13 @@ static inline int s1ap_encode_downlink_nas_transport(
|
|||
/*
|
||||
* Generate Initiating message_p for the list of IEs
|
||||
*/
|
||||
return s1ap_generate_initiating_message(buffer, length,
|
||||
return s1ap_generate_initiating_message(pkbuf,
|
||||
S1ap_ProcedureCode_id_downlinkNASTransport, message_p->criticality,
|
||||
&asn_DEF_S1ap_DownlinkNASTransport, downlinkNasTransport_p);
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_ue_context_release_command (
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length)
|
||||
s1ap_message *message_p, pkbuf_t *pkbuf)
|
||||
{
|
||||
S1ap_UEContextReleaseCommand_t ueContextReleaseCommand;
|
||||
S1ap_UEContextReleaseCommand_t *ueContextReleaseCommand_p =
|
||||
|
@ -269,68 +233,96 @@ static inline int s1ap_encode_ue_context_release_command (
|
|||
return -1;
|
||||
}
|
||||
|
||||
return s1ap_generate_initiating_message(buffer, length,
|
||||
return s1ap_generate_initiating_message(pkbuf,
|
||||
S1ap_ProcedureCode_id_UEContextRelease, message_p->criticality,
|
||||
&asn_DEF_S1ap_UEContextReleaseCommand, ueContextReleaseCommand_p);
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_initiating(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length)
|
||||
|
||||
ssize_t s1ap_generate_initiating_message(pkbuf_t *pkbuf,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr)
|
||||
{
|
||||
switch (message_p->procedureCode)
|
||||
S1AP_PDU_t pdu;
|
||||
asn_enc_rval_t enc_ret = {0};
|
||||
|
||||
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
||||
pdu.present = S1AP_PDU_PR_initiatingMessage;
|
||||
pdu.choice.initiatingMessage.procedureCode = procedureCode;
|
||||
pdu.choice.initiatingMessage.criticality = criticality;
|
||||
ANY_fromType_aper(&pdu.choice.initiatingMessage.value, td, sptr);
|
||||
|
||||
/*
|
||||
* We can safely free list of IE from sptr
|
||||
*/
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY (*td, sptr);
|
||||
|
||||
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
||||
&pdu, pkbuf->payload, S1AP_SDU_SIZE);
|
||||
if (enc_ret.encoded < 0)
|
||||
{
|
||||
case S1ap_ProcedureCode_id_downlinkNASTransport:
|
||||
return s1ap_encode_downlink_nas_transport(
|
||||
message_p, buffer, length);
|
||||
|
||||
case S1ap_ProcedureCode_id_InitialContextSetup:
|
||||
return s1ap_encode_initial_context_setup_request(
|
||||
message_p, buffer, length);
|
||||
|
||||
case S1ap_ProcedureCode_id_UEContextRelease:
|
||||
return s1ap_encode_ue_context_release_command (
|
||||
message_p, buffer, length);
|
||||
|
||||
default:
|
||||
d_warn("Unknown procedure ID (%d) for initiating message_p\n",
|
||||
(int)message_p->procedureCode);
|
||||
break;
|
||||
d_error("Encoding of %s failed", td->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return enc_ret.encoded;
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_successfull_outcome(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length)
|
||||
ssize_t s1ap_generate_successfull_outcome(pkbuf_t *pkbuf,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr)
|
||||
{
|
||||
switch (message_p->procedureCode)
|
||||
{
|
||||
case S1ap_ProcedureCode_id_S1Setup:
|
||||
return s1ap_encode_s1setupresponse(message_p, buffer, length);
|
||||
S1AP_PDU_t pdu;
|
||||
asn_enc_rval_t enc_ret = {0};
|
||||
|
||||
default:
|
||||
d_warn("Unknown procedure ID (%d) for successfull "
|
||||
"outcome message\n", (int)message_p->procedureCode);
|
||||
break;
|
||||
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
||||
pdu.present = S1AP_PDU_PR_successfulOutcome;
|
||||
pdu.choice.successfulOutcome.procedureCode = procedureCode;
|
||||
pdu.choice.successfulOutcome.criticality = criticality;
|
||||
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
|
||||
|
||||
/*
|
||||
* We can safely free list of IE from sptr
|
||||
*/
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY (*td, sptr);
|
||||
|
||||
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
||||
&pdu, pkbuf->payload, S1AP_SDU_SIZE);
|
||||
if (enc_ret.encoded < 0)
|
||||
{
|
||||
d_error("Encoding of %s failed", td->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return enc_ret.encoded;
|
||||
}
|
||||
|
||||
static inline int s1ap_encode_unsuccessfull_outcome(
|
||||
s1ap_message *message_p, uint8_t **buffer, uint32_t *length)
|
||||
ssize_t s1ap_generate_unsuccessfull_outcome(pkbuf_t *pkbuf,
|
||||
e_S1ap_ProcedureCode procedureCode, S1ap_Criticality_t criticality,
|
||||
asn_TYPE_descriptor_t * td, void *sptr)
|
||||
{
|
||||
switch (message_p->procedureCode)
|
||||
{
|
||||
case S1ap_ProcedureCode_id_S1Setup:
|
||||
return s1ap_encode_s1setupfailure(message_p, buffer, length);
|
||||
S1AP_PDU_t pdu;
|
||||
asn_enc_rval_t enc_ret = {0};
|
||||
|
||||
default:
|
||||
d_warn("Unknown procedure ID (%d) for unsuccessfull "
|
||||
"outcome message\n", (int)message_p->procedureCode);
|
||||
break;
|
||||
memset(&pdu, 0, sizeof (S1AP_PDU_t));
|
||||
pdu.present = S1AP_PDU_PR_unsuccessfulOutcome;
|
||||
pdu.choice.successfulOutcome.procedureCode = procedureCode;
|
||||
pdu.choice.successfulOutcome.criticality = criticality;
|
||||
ANY_fromType_aper(&pdu.choice.successfulOutcome.value, td, sptr);
|
||||
|
||||
/*
|
||||
* We can safely free list of IE from sptr
|
||||
*/
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY (*td, sptr);
|
||||
|
||||
enc_ret = aper_encode_to_buffer(&asn_DEF_S1AP_PDU,
|
||||
&pdu, pkbuf->payload, S1AP_SDU_SIZE);
|
||||
if (enc_ret.encoded < 0)
|
||||
{
|
||||
d_error("Encoding of %s failed", td->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return enc_ret.encoded;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue