forked from acouzens/open5gs
sample code for decoding S1SetupRequest
This commit is contained in:
parent
afc96a3b16
commit
273e32c498
|
@ -0,0 +1,23 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
noinst_LTLIBRARIES = libasn.la
|
||||
|
||||
libasn_la_SOURCES = \
|
||||
s1ap_ies_defs.h s1ap_common.h
|
||||
|
||||
nodist_libasn_la_SOURCES = \
|
||||
s1ap_common.c \
|
||||
s1ap_encoder.c s1ap_decoder.c s1ap_xer_print.c \
|
||||
s1ap_mme_encoder.c s1ap_mme_decoder.c
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/lib/core/include \
|
||||
-I$(top_srcdir)/lib/asn/asn1c
|
||||
|
||||
AM_CFLAGS = \
|
||||
-Wall -Werror -Wno-incompatible-pointer-types
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MOSTLYCLEANFILES = *.stackdump
|
||||
|
||||
EXTRA_DIST = .libs $(noinst_LTLIBRARIES)
|
|
@ -39,7 +39,7 @@
|
|||
#endif
|
||||
|
||||
int asn_debug = 0;
|
||||
int asn1_xer_print = 0;
|
||||
int asn1_xer_print = 1;
|
||||
|
||||
void free_wrapper(void *ptr)
|
||||
{
|
||||
|
|
|
@ -384,6 +384,7 @@ inline void ASN_DEBUG(const char *fmt, ...);
|
|||
|
||||
extern int asn_debug;
|
||||
extern int asn1_xer_print;
|
||||
extern void free_wrapper(void *ptr);
|
||||
|
||||
# include "mme_default_values.h"
|
||||
#if 0 /* modified by acetcom */
|
||||
|
|
|
@ -0,0 +1,283 @@
|
|||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
|
||||
/*! \file s1ap_mme_decoder.c
|
||||
\brief s1ap decode procedures for MME
|
||||
\author Sebastien ROUX <sebastien.roux@eurecom.fr>
|
||||
\date 2012
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if 0 /* modified by acetcom */
|
||||
#include "assertions.h"
|
||||
#endif
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_ies_defs.h"
|
||||
#include "s1ap_mme_decoder.h"
|
||||
#if 0 /* modified by acetcom */
|
||||
#include "s1ap_mme_handlers.h"
|
||||
#include "intertask_interface.h"
|
||||
#include "assertions.h"
|
||||
#include "dynamic_memory_check.h"
|
||||
#include "log.h"
|
||||
#else
|
||||
#include "core_debug.h"
|
||||
#endif
|
||||
|
||||
static int
|
||||
s1ap_mme_decode_initiating (
|
||||
s1ap_message *message,
|
||||
S1ap_InitiatingMessage_t *initiating_p) {
|
||||
int ret = -1;
|
||||
#if 0
|
||||
MessageDef *message_p = NULL;
|
||||
#endif
|
||||
char *message_string = NULL;
|
||||
#if 0
|
||||
size_t message_string_size;
|
||||
MessagesIds message_id = MESSAGES_ID_MAX;
|
||||
#endif
|
||||
d_assert(initiating_p != NULL, return -1, "Null param");
|
||||
message_string = calloc (10000, sizeof (char));
|
||||
#if 0
|
||||
s1ap_string_total_size = 0;
|
||||
message->procedureCode = initiating_p->procedureCode;
|
||||
message->criticality = initiating_p->criticality;
|
||||
#endif
|
||||
|
||||
switch (initiating_p->procedureCode) {
|
||||
case S1ap_ProcedureCode_id_uplinkNASTransport: {
|
||||
ret = s1ap_decode_s1ap_uplinknastransport_ies (&message->msg.s1ap_UplinkNASTransport_IEs, &initiating_p->value);
|
||||
s1ap_xer_print_s1ap_uplinknastransport_ (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_UPLINK_NAS_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case S1ap_ProcedureCode_id_S1Setup: {
|
||||
ret = s1ap_decode_s1ap_s1setuprequesties (&message->msg.s1ap_S1SetupRequestIEs, &initiating_p->value);
|
||||
s1ap_xer_print_s1ap_s1setuprequest (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_S1_SETUP_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case S1ap_ProcedureCode_id_initialUEMessage: {
|
||||
ret = s1ap_decode_s1ap_initialuemessage_ies (&message->msg.s1ap_InitialUEMessage_IEs, &initiating_p->value);
|
||||
s1ap_xer_print_s1ap_initialuemessage_ (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_INITIAL_UE_MESSAGE_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case S1ap_ProcedureCode_id_UEContextReleaseRequest: {
|
||||
ret = s1ap_decode_s1ap_uecontextreleaserequest_ies (&message->msg.s1ap_UEContextReleaseRequest_IEs, &initiating_p->value);
|
||||
s1ap_xer_print_s1ap_uecontextreleaserequest_ (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_UE_CONTEXT_RELEASE_REQ_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case S1ap_ProcedureCode_id_UECapabilityInfoIndication: {
|
||||
ret = s1ap_decode_s1ap_uecapabilityinfoindicationies (&message->msg.s1ap_UECapabilityInfoIndicationIEs, &initiating_p->value);
|
||||
s1ap_xer_print_s1ap_uecapabilityinfoindication (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_UE_CAPABILITY_IND_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case S1ap_ProcedureCode_id_NASNonDeliveryIndication: {
|
||||
ret = s1ap_decode_s1ap_nasnondeliveryindication_ies (&message->msg.s1ap_NASNonDeliveryIndication_IEs, &initiating_p->value);
|
||||
s1ap_xer_print_s1ap_nasnondeliveryindication_ (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_NAS_NON_DELIVERY_IND_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
d_error("Unknown procedure ID (%d) for initiating message\n", (int)initiating_p->procedureCode);
|
||||
d_assert(0, return -1, "Unknown procedure ID (%d) for initiating message\n", (int)initiating_p->procedureCode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
message_string_size = strlen (message_string);
|
||||
message_p = itti_alloc_new_message_sized (TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
|
||||
message_p->ittiMsg.s1ap_uplink_nas_log.size = message_string_size;
|
||||
memcpy (&message_p->ittiMsg.s1ap_uplink_nas_log.text, message_string, message_string_size);
|
||||
itti_send_msg_to_task (TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
|
||||
#endif
|
||||
free_wrapper (message_string);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
s1ap_mme_decode_successfull_outcome (
|
||||
s1ap_message *message,
|
||||
S1ap_SuccessfulOutcome_t *successfullOutcome_p) {
|
||||
int ret = -1;
|
||||
#if 0
|
||||
MessageDef *message_p = NULL;
|
||||
#endif
|
||||
char *message_string = NULL;
|
||||
#if 0
|
||||
size_t message_string_size = 0;
|
||||
MessagesIds message_id = MESSAGES_ID_MAX;
|
||||
#endif
|
||||
d_assert(successfullOutcome_p != NULL, return -1, "Null param");
|
||||
message_string = calloc (10000, sizeof (char));
|
||||
#if 0
|
||||
s1ap_string_total_size = 0;
|
||||
message->procedureCode = successfullOutcome_p->procedureCode;
|
||||
message->criticality = successfullOutcome_p->criticality;
|
||||
#endif
|
||||
|
||||
switch (successfullOutcome_p->procedureCode) {
|
||||
case S1ap_ProcedureCode_id_InitialContextSetup: {
|
||||
ret = s1ap_decode_s1ap_initialcontextsetupresponseies (&message->msg.s1ap_InitialContextSetupResponseIEs, &successfullOutcome_p->value);
|
||||
s1ap_xer_print_s1ap_initialcontextsetupresponse (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case S1ap_ProcedureCode_id_UEContextRelease: {
|
||||
ret = s1ap_decode_s1ap_uecontextreleasecomplete_ies (&message->msg.s1ap_UEContextReleaseComplete_IEs, &successfullOutcome_p->value);
|
||||
s1ap_xer_print_s1ap_uecontextreleasecomplete_ (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_UE_CONTEXT_RELEASE_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
d_error("Unknown procedure ID (%ld) for successfull outcome message\n", successfullOutcome_p->procedureCode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
message_string_size = strlen (message_string);
|
||||
message_p = itti_alloc_new_message_sized (TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
|
||||
message_p->ittiMsg.s1ap_initial_context_setup_log.size = message_string_size;
|
||||
memcpy (&message_p->ittiMsg.s1ap_initial_context_setup_log.text, message_string, message_string_size);
|
||||
itti_send_msg_to_task (TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
|
||||
#endif
|
||||
free_wrapper (message_string);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
s1ap_mme_decode_unsuccessfull_outcome (
|
||||
s1ap_message *message,
|
||||
S1ap_UnsuccessfulOutcome_t *unSuccessfulOutcome_p) {
|
||||
int ret = -1;
|
||||
#if 0
|
||||
MessageDef *message_p = NULL;
|
||||
#endif
|
||||
char *message_string = NULL;
|
||||
#if 0
|
||||
size_t message_string_size = 0;
|
||||
MessagesIds message_id = MESSAGES_ID_MAX;
|
||||
#endif
|
||||
d_assert(unSuccessfulOutcome_p != NULL, return -1, "Null param");
|
||||
message_string = calloc (10000, sizeof (char));
|
||||
#if 0
|
||||
s1ap_string_total_size = 0;
|
||||
message->procedureCode = unSuccessfulOutcome_p->procedureCode;
|
||||
message->criticality = unSuccessfulOutcome_p->criticality;
|
||||
#endif
|
||||
|
||||
switch (unSuccessfulOutcome_p->procedureCode) {
|
||||
case S1ap_ProcedureCode_id_InitialContextSetup: {
|
||||
ret = s1ap_decode_s1ap_initialcontextsetupfailureies (&message->msg.s1ap_InitialContextSetupFailureIEs, &unSuccessfulOutcome_p->value);
|
||||
s1ap_xer_print_s1ap_initialcontextsetupfailure (s1ap_xer__print2sp, message_string, message);
|
||||
#if 0
|
||||
message_id = S1AP_INITIAL_CONTEXT_SETUP_LOG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
d_error("Unknown procedure ID (%d) for unsuccessfull outcome message\n", (int)unSuccessfulOutcome_p->procedureCode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
message_string_size = strlen (message_string);
|
||||
message_p = itti_alloc_new_message_sized (TASK_S1AP, message_id, message_string_size + sizeof (IttiMsgText));
|
||||
message_p->ittiMsg.s1ap_initial_context_setup_log.size = message_string_size;
|
||||
memcpy (&message_p->ittiMsg.s1ap_initial_context_setup_log.text, message_string, message_string_size);
|
||||
itti_send_msg_to_task (TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
|
||||
#endif
|
||||
free_wrapper (message_string);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
s1ap_mme_decode_pdu (
|
||||
s1ap_message *message,
|
||||
uint8_t *buffer, uint32_t len) {
|
||||
S1AP_PDU_t pdu = {0};
|
||||
S1AP_PDU_t *pdu_p = &pdu;
|
||||
asn_dec_rval_t dec_ret = {0};
|
||||
d_assert(buffer != NULL, return -1, "Null param");
|
||||
memset ((void *)pdu_p, 0, sizeof (S1AP_PDU_t));
|
||||
dec_ret = aper_decode (NULL, &asn_DEF_S1AP_PDU, (void **)&pdu_p, buffer, len, 0, 0);
|
||||
|
||||
if (dec_ret.code != RC_OK) {
|
||||
d_error("Failed to decode PDU\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
message->direction = pdu_p->present;
|
||||
|
||||
switch (pdu_p->present) {
|
||||
case S1AP_PDU_PR_initiatingMessage:
|
||||
return s1ap_mme_decode_initiating (message, &pdu_p->choice.initiatingMessage);
|
||||
|
||||
case S1AP_PDU_PR_successfulOutcome:
|
||||
return s1ap_mme_decode_successfull_outcome (message, &pdu_p->choice.successfulOutcome);
|
||||
|
||||
case S1AP_PDU_PR_unsuccessfulOutcome:
|
||||
return s1ap_mme_decode_unsuccessfull_outcome (message, &pdu_p->choice.unsuccessfulOutcome);
|
||||
|
||||
default:
|
||||
d_error("Unknown message outcome (%d) or not implemented", (int)pdu_p->present);
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef FILE_S1AP_MME_DECODER_SEEN
|
||||
#define FILE_S1AP_MME_DECODER_SEEN
|
||||
#if 0 /* modified by acetcom */
|
||||
#include "bstrlib.h"
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_ies_defs.h"
|
||||
#endif
|
||||
|
||||
int s1ap_mme_decode_pdu(s1ap_message *message, uint8_t *buffer, uint32_t len) __attribute__ ((warn_unused_result));
|
||||
|
||||
#endif /* FILE_S1AP_MME_DECODER_SEEN */
|
|
@ -0,0 +1,264 @@
|
|||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
|
||||
/*! \file s1ap_mme_encoder.c
|
||||
\brief s1ap encode procedures for MME
|
||||
\author Sebastien ROUX <sebastien.roux@eurecom.fr>
|
||||
\date 2012
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#if 0 /* modified by acetcom */
|
||||
#include "intertask_interface.h"
|
||||
#endif
|
||||
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_ies_defs.h"
|
||||
#include "s1ap_mme_encoder.h"
|
||||
#if 0 /* modified by acetcom */
|
||||
#include "s1ap_mme.h"
|
||||
#include "assertions.h"
|
||||
#include "log.h"
|
||||
#else
|
||||
#include "core_debug.h"
|
||||
#endif
|
||||
|
||||
static inline int s1ap_mme_encode_initial_context_setup_request (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length);
|
||||
static inline int s1ap_mme_encode_s1setupresponse (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length);
|
||||
static inline int s1ap_mme_encode_s1setupfailure (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length);
|
||||
static inline int s1ap_mme_encode_ue_context_release_command (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length);
|
||||
static inline int s1ap_mme_encode_downlink_nas_transport (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length);
|
||||
|
||||
static inline int s1ap_mme_encode_initiating (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length);
|
||||
static inline int s1ap_mme_encode_successfull_outcome (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * len);
|
||||
static inline int s1ap_mme_encode_unsuccessfull_outcome (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * len);
|
||||
|
||||
static inline int
|
||||
s1ap_mme_encode_initial_context_setup_request (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
S1ap_InitialContextSetupRequest_t initialContextSetupRequest;
|
||||
S1ap_InitialContextSetupRequest_t *initialContextSetupRequest_p = &initialContextSetupRequest;
|
||||
|
||||
memset (initialContextSetupRequest_p, 0, sizeof (S1ap_InitialContextSetupRequest_t));
|
||||
|
||||
if (s1ap_encode_s1ap_initialcontextsetuprequesties (initialContextSetupRequest_p, &message_p->msg.s1ap_InitialContextSetupRequestIEs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return s1ap_generate_initiating_message (buffer, length, S1ap_ProcedureCode_id_InitialContextSetup, S1ap_Criticality_reject, &asn_DEF_S1ap_InitialContextSetupRequest, initialContextSetupRequest_p);
|
||||
}
|
||||
|
||||
int
|
||||
s1ap_mme_encode_pdu (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
d_assert (message_p != NULL, return -1, "Null param");
|
||||
d_assert (buffer != NULL, return -1, "Null param");
|
||||
d_assert (length != NULL, return -1, "Null param");
|
||||
|
||||
switch (message_p->direction) {
|
||||
case S1AP_PDU_PR_initiatingMessage:
|
||||
return s1ap_mme_encode_initiating (message_p, buffer, length);
|
||||
|
||||
case S1AP_PDU_PR_successfulOutcome:
|
||||
return s1ap_mme_encode_successfull_outcome (message_p, buffer, length);
|
||||
|
||||
case S1AP_PDU_PR_unsuccessfulOutcome:
|
||||
return s1ap_mme_encode_unsuccessfull_outcome (message_p, buffer, length);
|
||||
|
||||
default:
|
||||
d_warn("Unknown message outcome (%d) or not implemented", (int)message_p->direction);
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
s1ap_mme_encode_initiating (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
switch (message_p->procedureCode) {
|
||||
case S1ap_ProcedureCode_id_downlinkNASTransport:
|
||||
return s1ap_mme_encode_downlink_nas_transport (message_p, buffer, length);
|
||||
|
||||
case S1ap_ProcedureCode_id_InitialContextSetup:
|
||||
return s1ap_mme_encode_initial_context_setup_request (message_p, buffer, length);
|
||||
|
||||
case S1ap_ProcedureCode_id_UEContextRelease:
|
||||
return s1ap_mme_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;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
s1ap_mme_encode_successfull_outcome (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
switch (message_p->procedureCode) {
|
||||
case S1ap_ProcedureCode_id_S1Setup:
|
||||
return s1ap_mme_encode_s1setupresponse (message_p, buffer, length);
|
||||
|
||||
default:
|
||||
d_warn("Unknown procedure ID (%d) for successfull outcome message\n", (int)message_p->procedureCode);
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
s1ap_mme_encode_unsuccessfull_outcome (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
switch (message_p->procedureCode) {
|
||||
case S1ap_ProcedureCode_id_S1Setup:
|
||||
return s1ap_mme_encode_s1setupfailure (message_p, buffer, length);
|
||||
|
||||
default:
|
||||
d_warn("Unknown procedure ID (%d) for unsuccessfull outcome message\n", (int)message_p->procedureCode);
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
s1ap_mme_encode_s1setupresponse (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
S1ap_S1SetupResponse_t s1SetupResponse;
|
||||
S1ap_S1SetupResponse_t *s1SetupResponse_p = &s1SetupResponse;
|
||||
|
||||
memset (s1SetupResponse_p, 0, sizeof (S1ap_S1SetupResponse_t));
|
||||
|
||||
if (s1ap_encode_s1ap_s1setupresponseies (s1SetupResponse_p, &message_p->msg.s1ap_S1SetupResponseIEs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return s1ap_generate_successfull_outcome (buffer, length, S1ap_ProcedureCode_id_S1Setup, message_p->criticality, &asn_DEF_S1ap_S1SetupResponse, s1SetupResponse_p);
|
||||
}
|
||||
|
||||
static inline int
|
||||
s1ap_mme_encode_s1setupfailure (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
S1ap_S1SetupFailure_t s1SetupFailure;
|
||||
S1ap_S1SetupFailure_t *s1SetupFailure_p = &s1SetupFailure;
|
||||
|
||||
memset (s1SetupFailure_p, 0, sizeof (S1ap_S1SetupFailure_t));
|
||||
|
||||
if (s1ap_encode_s1ap_s1setupfailureies (s1SetupFailure_p, &message_p->msg.s1ap_S1SetupFailureIEs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return s1ap_generate_unsuccessfull_outcome (buffer, length, S1ap_ProcedureCode_id_S1Setup, message_p->criticality, &asn_DEF_S1ap_S1SetupFailure, s1SetupFailure_p);
|
||||
}
|
||||
|
||||
static inline int
|
||||
s1ap_mme_encode_downlink_nas_transport (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
S1ap_DownlinkNASTransport_t downlinkNasTransport;
|
||||
S1ap_DownlinkNASTransport_t *downlinkNasTransport_p = &downlinkNasTransport;
|
||||
|
||||
memset (downlinkNasTransport_p, 0, sizeof (S1ap_DownlinkNASTransport_t));
|
||||
|
||||
/*
|
||||
* Convert IE structure into asn1 message_p
|
||||
*/
|
||||
if (s1ap_encode_s1ap_downlinknastransport_ies (downlinkNasTransport_p, &message_p->msg.s1ap_DownlinkNASTransport_IEs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate Initiating message_p for the list of IEs
|
||||
*/
|
||||
return s1ap_generate_initiating_message (buffer, length, S1ap_ProcedureCode_id_downlinkNASTransport, message_p->criticality, &asn_DEF_S1ap_DownlinkNASTransport, downlinkNasTransport_p);
|
||||
}
|
||||
|
||||
static inline int
|
||||
s1ap_mme_encode_ue_context_release_command (
|
||||
s1ap_message * message_p,
|
||||
uint8_t ** buffer,
|
||||
uint32_t * length)
|
||||
{
|
||||
S1ap_UEContextReleaseCommand_t ueContextReleaseCommand;
|
||||
S1ap_UEContextReleaseCommand_t *ueContextReleaseCommand_p = &ueContextReleaseCommand;
|
||||
|
||||
memset (ueContextReleaseCommand_p, 0, sizeof (S1ap_UEContextReleaseCommand_t));
|
||||
|
||||
/*
|
||||
* Convert IE structure into asn1 message_p
|
||||
*/
|
||||
if (s1ap_encode_s1ap_uecontextreleasecommand_ies (ueContextReleaseCommand_p, &message_p->msg.s1ap_UEContextReleaseCommand_IEs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return s1ap_generate_initiating_message (buffer, length, S1ap_ProcedureCode_id_UEContextRelease, message_p->criticality, &asn_DEF_S1ap_UEContextReleaseCommand, ueContextReleaseCommand_p);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef FILE_S1AP_MME_ENCODER_SEEN
|
||||
#define FILE_S1AP_MME_ENCODER_SEEN
|
||||
|
||||
int s1ap_mme_encode_pdu(s1ap_message *message, uint8_t **buffer, uint32_t *len)
|
||||
__attribute__ ((warn_unused_result));
|
||||
|
||||
#endif /* FILE_S1AP_MME_ENCODER_SEEN */
|
|
@ -6,8 +6,22 @@
|
|||
|
||||
#include "testutil.h"
|
||||
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_ies_defs.h"
|
||||
#include "s1ap_mme_decoder.h"
|
||||
|
||||
static void s1ap_test1(abts_case *tc, void *data)
|
||||
{
|
||||
char *s1setup_msg[] = {
|
||||
"\x00\x11\x00\x2d\x00\x00\x04\x00\x3b\x00\x09\x00\x00\xf1\x10\x40\x54\xf6\x40\x10\x00\x3c\x40\x09\x03\x00\x4a\x4c\x54\x2d\x36\x32\x31\x00\x40\x00\x07\x00\x0c\x0e\x40\x00\xf1\x10\x00\x89\x40\x01\x00",
|
||||
};
|
||||
s1ap_message message;
|
||||
int result;
|
||||
char *message_string = calloc (10000, sizeof (char));
|
||||
|
||||
result = s1ap_mme_decode_pdu(&message, (unsigned char*)s1setup_msg[0], 49);
|
||||
|
||||
free(message_string);
|
||||
}
|
||||
|
||||
abts_suite *test_s1ap(abts_suite *suite)
|
||||
|
|
Loading…
Reference in New Issue