Commit d27641a4 authored by gauthier's avatar gauthier

Begin to begin sending packets (many things to do hash assoc id, mme_ue_id, nas security, etc)

parent 7c28ae73
......@@ -216,18 +216,20 @@ add_definitions("-DPACKAGE_BUGREPORT=\"openair4g-devel@lists.eurecom.fr\"")
# Debug related options
#########################################
add_boolean_option(MSG_PRINT False "print debug messages")
add_boolean_option(DISABLE_XER_PRINT False "print XER Format")
add_boolean_option(XER_PRINT False "print XER Format")
add_boolean_option(RRC_MSG_PRINT False "print RRC messages")
add_boolean_option(PDCP_MSG_PRINT False "print PDCP messages to /tmp/pdcp.log")
add_boolean_option(DEBUG_PDCP_PAYLOAD False "print PDCP PDU to stdout") # if true, make sure that global and PDCP log levels are trace
add_boolean_option(ASN_DEBUG False "ASN1 coder/decoder Debug")
add_boolean_option(EMIT_ASN_DEBUG False "ASN1 coder/decoder Debug")
add_boolean_option(MSG_PRINT False "print debug messages")
add_boolean_option(DISABLE_XER_PRINT False "print XER Format")
add_boolean_option(XER_PRINT False "print XER Format")
add_boolean_option(RRC_MSG_PRINT False "print RRC messages")
add_boolean_option(PDCP_MSG_PRINT False "print PDCP messages to /tmp/pdcp.log")
add_boolean_option(DEBUG_PDCP_PAYLOAD False "print PDCP PDU to stdout") # if true, make sure that global and PDCP log levels are trace
add_boolean_option(DEBUG_MAC_INTERFACE False "print MAC-RLC PDU exchange to stdout") # if true, make sure that global and PDCP log levels are trace
add_boolean_option(TRACE_RLC_PAYLOAD False "print RLC PDU to stdout") # if true, make sure that global and PDCP log levels are trace
add_boolean_option(TEST_OMG False "???")
add_boolean_option(DEBUG_OMG False "???")
add_boolean_option(XFORMS False "This adds the possibility to see the signal oscilloscope")
add_boolean_option(PRINT_STATS False "This adds the possibility to see the status")
add_boolean_option(TRACE_RLC_PAYLOAD False "print RLC PDU to stdout") # if true, make sure that global and PDCP log levels are trace
add_boolean_option(TEST_OMG False "???")
add_boolean_option(DEBUG_OMG False "???")
add_boolean_option(XFORMS False "This adds the possibility to see the signal oscilloscope")
add_boolean_option(PRINT_STATS False "This adds the possibility to see the status")
add_boolean_option(DEBUG_CONSOLE False "makes debugging easier, disables stdout/stderr buffering")
......@@ -1660,6 +1662,12 @@ target_link_libraries (test_epc_generate_scenario
add_executable(test_epc_play_scenario
${OPENAIR3_DIR}/TEST/EPC_TEST/play_scenario.c
${OPENAIR3_DIR}/TEST/EPC_TEST/play_scenario_decode.c
${OPENAIR3_DIR}/TEST/EPC_TEST/play_scenario_display.c
${OPENAIR3_DIR}/TEST/EPC_TEST/play_scenario_fsm.c
${OPENAIR3_DIR}/TEST/EPC_TEST/play_scenario_parse.c
${OPENAIR3_DIR}/TEST/EPC_TEST/play_scenario_s1ap.c
${OPENAIR3_DIR}/TEST/EPC_TEST/play_scenario_sctp.c
${OPENAIR3_DIR}/TEST/EPC_TEST/play_scenario.h
${OPENAIR2_DIR}/ENB_APP/enb_config.h
${OPENAIR2_DIR}/COMMON/commonDef.h
......
......@@ -7,7 +7,7 @@ set ( DEBUG_OMG False )
set ( DISABLE_XER_PRINT False )
set ( DRIVER2013 True )
set ( EMOS False )
set ( EMIT_ASN_DEBUG True )
set ( EMIT_ASN_DEBUG False )
set ( ENABLE_FXP True )
set ( ENABLE_ITTI True )
set ( ENABLE_NAS_UE_LOGGING True )
......@@ -76,4 +76,4 @@ set ( SMBV False )
set ( TEST_OMG False )
set ( USE_MME "R10" )
set ( USER_MODE True )
set ( XER_PRINT False )
set ( XER_PRINT True )
......@@ -22,7 +22,7 @@
# Contact Information
# OpenAirInterface Admin: openair_admin@eurecom.fr
# OpenAirInterface Tech : openair_tech@eurecom.fr
# OpenAirInterface Dev : openair4g-devel@eurecom.fr
# OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr
#
# Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
#
......
......@@ -72,9 +72,9 @@ s1ap_eNB_config_t s1ap_config;
static int s1ap_eNB_generate_s1_setup_request(
s1ap_eNB_instance_t *instance_p, s1ap_eNB_mme_data_t *s1ap_mme_data_p);
static
void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *s1ap_register_eNB);
static
void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp);
uint32_t s1ap_generate_eNB_id(void)
......@@ -150,7 +150,7 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
itti_send_msg_to_task(TASK_SCTP, instance_p->instance, message_p);
}
static
void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *s1ap_register_eNB)
{
s1ap_eNB_instance_t *new_instance;
......@@ -210,7 +210,6 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *
}
}
static
void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp)
{
s1ap_eNB_instance_t *instance_p;
......
......@@ -48,133 +48,28 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <libxml/xmlmemory.h>
#include <libxml/debugXML.h>
#include <libxml/xmlIO.h>
#include <libxml/DOCBparser.h>
#include <libxml/xinclude.h>
#include <libxml/catalog.h>
#include <libxml/xmlreader.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
#include "intertask_interface_init.h"
#include "timer.h"
#include "assertions.h"
#include "play_scenario.h"
//#include "s1ap_eNB.h"
#include "s1ap_common.h"
#include "s1ap_ies_defs.h"
#include "s1ap_eNB_decoder.h"
#include "intertask_interface.h"
#include "enb_config.h"
#include "play_scenario.h"
#include "sctp_eNB_task.h"
#include "log.h"
//------------------------------------------------------------------------------
#define ENB_CONFIG_MAX_XSLT_PARAMS 32
#define PLAY_SCENARIO 1
#define GS_IS_FILE 1
#define GS_IS_DIR 2
//------------------------------------------------------------------------------
char *g_openair_dir = NULL;
//------------------------------------------------------------------------------
extern Enb_properties_array_t enb_properties;
extern int xmlLoadExtDtdDefaultValue;
extern int asn_debug;
extern int asn1_xer_print;
//------------------------------------------------------------------------------
void test_print_hex_octets(const unsigned char * const byte_stream, const unsigned long int num);
int is_file_exists ( const char const * file_nameP, const char const *file_roleP);
int strip_extension( char *in_filename);
int split_path ( char * pathP, char *** resP);
void display_node ( xmlNodePtr node, unsigned int indent);
void display_tree ( xmlNodePtr node, unsigned int indent);
//-------------------------
void free_packet(test_packet_t* packet);
void free_scenario(test_scenario_t* scenario);
//-------------------------
void display_packet_sctp_init(const sctp_inithdr_t * const sctp);
void display_packet_sctp_initack(const sctp_initackhdr_t * const sctp);
void display_packet_sctp_data(const sctp_datahdr_t * const sctp);
void display_packet_sctp(const test_sctp_hdr_t * const sctp);
void display_packet_ip(const test_ip_hdr_t * const ip);
void display_packet(const test_packet_t * const packet);
void display_scenario(const test_scenario_t * const scenario);
//-------------------------
char * test_ip2ip_str(const test_ip_t * const ip);
int hex2data(unsigned char * const data, const unsigned char * const hexstring, const unsigned int len);
sctp_cid_t chunk_type_str2cid(const xmlChar * const chunk_type_str);
const char * const chunk_type_cid2str(const sctp_cid_t chunk_type);
test_action_t action_str2test_action_t(const xmlChar * const action);
void ip_str2test_ip(const xmlChar * const ip_str, test_ip_t * const ip);
//-------------------------
int test_s1ap_decode_initiating_message(s1ap_message *message, S1ap_InitiatingMessage_t *initiating_p);
int test_s1ap_decode_successful_outcome(s1ap_message *message, S1ap_SuccessfulOutcome_t *successfullOutcome_p);
int test_s1ap_decode_unsuccessful_outcome(s1ap_message *message, S1ap_UnsuccessfulOutcome_t *unSuccessfullOutcome_p);
int test_s1ap_decode_pdu(s1ap_message *message, const uint8_t * const buffer,const uint32_t length);
void test_decode_s1ap(test_s1ap_t * const s1ap);
//-------------------------
void parse_s1ap(xmlDocPtr doc, const xmlNode const *s1ap_node, test_s1ap_t * const s1ap);
void parse_sctp_data_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_datahdr_t * const sctp_hdr);
void parse_sctp_init_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_inithdr_t * const sctp_hdr);
void parse_sctp_init_ack_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_initackhdr_t * const sctp_hdr);
void parse_sctp(xmlDocPtr doc, const xmlNode const *sctp_node, test_sctp_hdr_t * const sctp_hdr);
test_packet_t* parse_xml_packet(xmlDocPtr doc, xmlNodePtr node);
//-------------------------
int play_scenario(test_scenario_t* scenario);
int generate_xml_scenario(
const char const * test_dir_name,
const char const * test_scenario_filename,
const char const * enb_config_filename,
char const * play_scenario_filename /* OUT PARAM*/);
//-----------------------------------------------------------------------------
void test_print_hex_octets(const unsigned char * const byte_stream, const unsigned long int num)
//-----------------------------------------------------------------------------
{
unsigned long octet_index = 0;
if (byte_stream == NULL) {
return;
}
fprintf(stdout, "+-----+-------------------------------------------------+\n");
fprintf(stdout, "| | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n");
fprintf(stdout, "+-----+-------------------------------------------------+\n");
for (octet_index = 0; octet_index < num; octet_index++) {
if ((octet_index % 16) == 0) {
if (octet_index != 0) {
fprintf(stdout, " |\n");
}
fprintf(stdout, " %04ld |", octet_index);
}
/*
* Print every single octet in hexadecimal form
*/
fprintf(stdout, " %02x", byte_stream[octet_index]);
/*
* Align newline and pipes according to the octets in groups of 2
*/
}
/*
* Append enough spaces and put final pipe
*/
unsigned char index;
for (index = octet_index; index < 16; ++index) {
fprintf(stdout, " ");
}
fprintf(stdout, " |\n");
}
//------------------------------------------------------------------------------
// test if file exist in current directory
int is_file_exists( const char const * file_nameP, const char const *file_roleP)
......@@ -202,7 +97,7 @@ int is_file_exists( const char const * file_nameP, const char const *file_roleP)
//------------------------------------------------------------------------------
int strip_extension(char *in_filename)
int et_strip_extension(char *in_filename)
{
static const uint8_t name_min_len = 1;
static const uint8_t max_ext_len = 5; // .pdml !
......@@ -237,193 +132,38 @@ int split_path( char * pathP, char *** resP)
return n_spaces;
}
//------------------------------------------------------------------------------
void display_node(xmlNodePtr node, unsigned int indent)
{
int i = 0;
if (node->type == XML_ELEMENT_NODE) {
xmlChar *path = xmlGetNodePath(node);
for (i=0; i<indent; i++) {
printf(" ");
}
if (node->children != NULL && node->children->type == XML_TEXT_NODE) {
xmlChar *content = xmlNodeGetContent(node);
printf("%s -> %s\n", path, content);
xmlFree(content);
} else {
printf("%s\n", path);
}
xmlFree(path);
}
}
/**
* print_element_names:
* @node: the initial xml node to consider.
* @indent: indentation level.
*
* Prints the names of the all the xml elements
* that are siblings or children of a given xml node.
*/
//------------------------------------------------------------------------------
void display_tree(xmlNodePtr node, unsigned int indent)
{
xmlNode *cur_node = NULL;
for (cur_node = node; cur_node; cur_node = cur_node->next) {
if (cur_node->type == XML_ELEMENT_NODE) {
display_node(cur_node, indent);
}
display_tree(cur_node->children, indent++);
}
}
//------------------------------------------------------------------------------
void free_packet(test_packet_t* packet)
void et_free_packet(et_packet_t* packet)
{
if (packet) {
switch (packet->sctp_hdr.chunk_type) {
case SCTP_CID_DATA:
free_pointer(packet->sctp_hdr.u.data_hdr.payload.binary_stream);
et_free_pointer(packet->sctp_hdr.u.data_hdr.payload.binary_stream);
break;
default:
;
}
free_pointer(packet);
et_free_pointer(packet);
}
}
//------------------------------------------------------------------------------
void free_scenario(test_scenario_t* scenario)
void et_free_scenario(et_scenario_t* scenario)
{
test_packet_t *packet = NULL;
test_packet_t *next_packet = NULL;
et_packet_t *packet = NULL;
et_packet_t *next_packet = NULL;
if (scenario) {
packet = scenario->list_packet;
while (packet) {
next_packet = packet->next;
free_packet(packet);
et_free_packet(packet);
packet = next_packet->next;
}
free_pointer(scenario);
}
}
//------------------------------------------------------------------------------
void display_packet_sctp_init(const sctp_inithdr_t * const sctp)
{
if (sctp) {
fprintf(stdout, "\t\tSCTP.init.init_tag : %u\n", sctp->init_tag);
fprintf(stdout, "\t\tSCTP.init.a_rwnd : %u\n", sctp->a_rwnd);
fprintf(stdout, "\t\tSCTP.init.num_inbound_streams : %u\n", sctp->num_inbound_streams);
fprintf(stdout, "\t\tSCTP.init.num_outbound_streams : %u\n", sctp->num_outbound_streams);
fprintf(stdout, "\t\tSCTP.init.initial_tsn : %u\n", sctp->initial_tsn);
}
}
//------------------------------------------------------------------------------
void display_packet_sctp_initack(const sctp_initackhdr_t * const sctp)
{
if (sctp) {
fprintf(stdout, "\t\tSCTP.initack.init_tag : %u\n", sctp->init_tag);
fprintf(stdout, "\t\tSCTP.initack.a_rwnd : %u\n", sctp->a_rwnd);
fprintf(stdout, "\t\tSCTP.initack.num_inbound_streams : %u\n", sctp->num_inbound_streams);
fprintf(stdout, "\t\tSCTP.initack.num_outbound_streams : %u\n", sctp->num_outbound_streams);
fprintf(stdout, "\t\tSCTP.initack.initial_tsn : %u\n", sctp->initial_tsn);
}
}
//------------------------------------------------------------------------------
void display_packet_sctp_data(const sctp_datahdr_t * const sctp)
{
if (sctp) {
fprintf(stdout, "\t\tSCTP.data.tsn : %u\n", sctp->tsn);
fprintf(stdout, "\t\tSCTP.data.stream : %u\n", sctp->stream);
fprintf(stdout, "\t\tSCTP.data.ssn : %u\n", sctp->ssn);
fprintf(stdout, "\t\tSCTP.data.ppid : %u\n", sctp->ppid);
//fprintf(stdout, "\t\tSCTP.data.pdu_type : %u\n", sctp->payload.pdu_type);
//fprintf(stdout, "\t\tSCTP.data.procedure_code : %u\n", sctp->payload.procedure_code);
fprintf(stdout, "\t\tSCTP.data.binary_stream_allocated_size : %u\n", sctp->payload.binary_stream_allocated_size);
if (NULL != sctp->payload.binary_stream) {
fprintf(stdout, "\t\tSCTP.data.binary_stream :\n");
test_print_hex_octets(sctp->payload.binary_stream, sctp->payload.binary_stream_allocated_size);
} else {
fprintf(stdout, "\t\tSCTP.data.binary_stream : NULL\n");
}
et_free_pointer(scenario);
}
}
//------------------------------------------------------------------------------
void display_packet_sctp(const test_sctp_hdr_t * const sctp)
{
if (sctp) {
fprintf(stdout, "\t\tSCTP.src_port : %u\n", sctp->src_port);
fprintf(stdout, "\t\tSCTP.dst_port : %u\n", sctp->dst_port);
fprintf(stdout, "\t\tSCTP.chunk_type : %s\n", chunk_type_cid2str(sctp->chunk_type));
switch (sctp->chunk_type) {
case SCTP_CID_DATA:
display_packet_sctp_data(&sctp->u.data_hdr);
break;
case SCTP_CID_INIT:
display_packet_sctp_initack(&sctp->u.init_hdr);
break;
case SCTP_CID_INIT_ACK:
display_packet_sctp_initack(&sctp->u.init_ack_hdr);
break;
default:
;
}
}
}
//------------------------------------------------------------------------------
void display_packet_ip(const test_ip_hdr_t * const ip)
{
if (ip) {
fprintf(stdout, "\t\tSource address : %s\n", test_ip2ip_str(&ip->src));
fprintf(stdout, "\t\tDestination address : %s\n", test_ip2ip_str(&ip->dst));
}
}
//------------------------------------------------------------------------------
void display_packet(const test_packet_t * const packet)
{
if (packet) {
fprintf(stdout, "\tPacket:\tnum %u | original frame number %u \n", packet->packet_number, packet->original_frame_number);
fprintf(stdout, "\tPacket:\ttime relative to 1st packet %ld.%06lu\n",
packet->time_relative_to_first_packet.tv_sec, packet->time_relative_to_first_packet.tv_usec);
fprintf(stdout, "\tPacket:\ttime relative to last tx packet %ld.%06lu\n",
packet->time_relative_to_last_sent_packet.tv_sec, packet->time_relative_to_last_sent_packet.tv_usec);
fprintf(stdout, "\tPacket:\ttime relative to last_received packet %ld.%06lu\n",
packet->time_relative_to_last_received_packet.tv_sec, packet->time_relative_to_last_received_packet.tv_usec);
switch(packet->action) {
case ACTION_S1C_SEND:
fprintf(stdout, "\tPacket:\tAction SEND\n");
break;
case ACTION_S1C_RECEIVE:
fprintf(stdout, "\tPacket:\tAction RECEIVE\n");
break;
default:
fprintf(stdout, "\tPacket:\tAction UNKNOWN\n");
}
display_packet_ip(&packet->ip_hdr);
display_packet_sctp(&packet->sctp_hdr);
}
}
//------------------------------------------------------------------------------
void display_scenario(const test_scenario_t * const scenario)
{
test_packet_t *packet = NULL;
if (scenario) {
fprintf(stdout, "Scenario: %s\n", (scenario->name != NULL) ? (char*)scenario->name:"UNKNOWN NAME");
packet = scenario->list_packet;
while (packet) {
display_packet(packet);
packet = packet->next;
}
}
}
//------------------------------------------------------------------------------
char * test_ip2ip_str(const test_ip_t * const ip)
char * et_ip2ip_str(const et_ip_t * const ip)
{
static char str[INET6_ADDRSTRLEN];
......@@ -445,7 +185,7 @@ char * test_ip2ip_str(const test_ip_t * const ip)
//returns 0 on success, negative on error
//data is a buffer of at least len bytes
//hexstring is upper or lower case hexadecimal, NOT prepended with "0x"
int hex2data(unsigned char * const data, const unsigned char * const hexstring, const unsigned int len)
int et_hex2data(unsigned char * const data, const unsigned char * const hexstring, const unsigned int len)
{
unsigned const char *pos = hexstring;
char *endptr = NULL;
......@@ -477,7 +217,7 @@ int hex2data(unsigned char * const data, const unsigned char * const hexstring,
return 0;
}
//------------------------------------------------------------------------------
sctp_cid_t chunk_type_str2cid(const xmlChar * const chunk_type_str)
sctp_cid_t et_chunk_type_str2cid(const xmlChar * const chunk_type_str)
{
if ((!xmlStrcmp(chunk_type_str, (const xmlChar *)"DATA"))) { return SCTP_CID_DATA;}
if ((!xmlStrcmp(chunk_type_str, (const xmlChar *)"INIT"))) { return SCTP_CID_INIT;}
......@@ -501,7 +241,7 @@ sctp_cid_t chunk_type_str2cid(const xmlChar * const chunk_type_str)
AssertFatal (0, "ERROR: %s() cannot convert: %s\n", __FUNCTION__, chunk_type_str);
}
//------------------------------------------------------------------------------
const char * const chunk_type_cid2str(const sctp_cid_t chunk_type)
const char * const et_chunk_type_cid2str(const sctp_cid_t chunk_type)
{
switch (chunk_type) {
case SCTP_CID_DATA: return "DATA"; break;
......@@ -528,15 +268,15 @@ const char * const chunk_type_cid2str(const sctp_cid_t chunk_type)
}
}
//------------------------------------------------------------------------------
test_action_t action_str2test_action_t(const xmlChar * const action)
et_packet_action_t et_action_str2et_action_t(const xmlChar * const action)
{
if ((!xmlStrcmp(action, (const xmlChar *)"SEND"))) { return ACTION_S1C_SEND;}
if ((!xmlStrcmp(action, (const xmlChar *)"RECEIVE"))) { return ACTION_S1C_RECEIVE;}
if ((!xmlStrcmp(action, (const xmlChar *)"SEND"))) { return ET_PACKET_ACTION_S1C_SEND;}
if ((!xmlStrcmp(action, (const xmlChar *)"RECEIVE"))) { return ET_PACKET_ACTION_S1C_RECEIVE;}
AssertFatal (0, "ERROR: %s cannot convert: %s\n", __FUNCTION__, action);
//if (NULL == action) {return ACTION_S1C_NULL;}
}
//------------------------------------------------------------------------------
void ip_str2test_ip(const xmlChar * const ip_str, test_ip_t * const ip)
void et_ip_str2et_ip(const xmlChar * const ip_str, et_ip_t * const ip)
{
AssertFatal (NULL != ip_str, "ERROR %s() Cannot convert null string to ip address!\n", __FUNCTION__);
AssertFatal (NULL != ip, "ERROR %s() out parameter pointer is NULL!\n", __FUNCTION__);
......@@ -550,732 +290,207 @@ void ip_str2test_ip(const xmlChar * const ip_str, test_ip_t * const ip)
AssertFatal (0, "ERROR %s() Could not parse ip address %s!\n", __FUNCTION__, ip_str);
}
}
//------------------------------------------------------------------------------
int test_s1ap_decode_initiating_message(s1ap_message *message,
S1ap_InitiatingMessage_t *initiating_p)
{
char *message_string = NULL;
int ret = -1;
DevAssert(initiating_p != NULL);
message_string = calloc(20000, sizeof(char));
AssertFatal (NULL != message_string, "ERROR malloc()failed!\n");
message->procedureCode = initiating_p->procedureCode;
message->criticality = initiating_p->criticality;
switch(initiating_p->procedureCode) {
case S1ap_ProcedureCode_id_downlinkNASTransport:
ret = s1ap_decode_s1ap_downlinknastransporties(
&message->msg.s1ap_DownlinkNASTransportIEs,
&initiating_p->value);
s1ap_xer_print_s1ap_downlinknastransport(s1ap_xer__print2sp, message_string, message);
break;
case S1ap_ProcedureCode_id_InitialContextSetup:
ret = s1ap_decode_s1ap_initialcontextsetuprequesties(
&message->msg.s1ap_InitialContextSetupRequestIEs, &initiating_p->value);
s1ap_xer_print_s1ap_initialcontextsetuprequest(s1ap_xer__print2sp, message_string, message);
break;
case S1ap_ProcedureCode_id_UEContextRelease:
ret = s1ap_decode_s1ap_uecontextreleasecommandies(
&message->msg.s1ap_UEContextReleaseCommandIEs, &initiating_p->value);
s1ap_xer_print_s1ap_uecontextreleasecommand(s1ap_xer__print2sp, message_string, message);
break;
case S1ap_ProcedureCode_id_Paging:
ret = s1ap_decode_s1ap_pagingies(
&message->msg.s1ap_PagingIEs, &initiating_p->value);
s1ap_xer_print_s1ap_paging(s1ap_xer__print2sp, message_string, message);
break;
case S1ap_ProcedureCode_id_uplinkNASTransport:
ret = s1ap_decode_s1ap_uplinknastransporties (&message->msg.s1ap_UplinkNASTransportIEs, &initiating_p->value);
s1ap_xer_print_s1ap_uplinknastransport(s1ap_xer__print2sp, message_string, message);
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);
break;
case S1ap_ProcedureCode_id_initialUEMessage:
ret = s1ap_decode_s1ap_initialuemessageies (&message->msg.s1ap_InitialUEMessageIEs, &initiating_p->value);
s1ap_xer_print_s1ap_initialuemessage(s1ap_xer__print2sp, message_string, message);
break;
case S1ap_ProcedureCode_id_UEContextReleaseRequest:
ret = s1ap_decode_s1ap_uecontextreleaserequesties (&message->msg.s1ap_UEContextReleaseRequestIEs, &initiating_p->value);
s1ap_xer_print_s1ap_uecontextreleaserequest(s1ap_xer__print2sp, message_string, message);
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);
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);
break;
default:
free(message_string);
AssertFatal( 0 , "Unknown procedure ID (%d) for initiating message\n",
(int)initiating_p->procedureCode);
return -1;
}
fprintf(stdout, "s1ap_xer_print:\n%s\n", message_string);
free(message_string);
return ret;
}
/*------------------------------------------------------------------------------*/
uint32_t et_eNB_app_register(const Enb_properties_array_t *enb_properties)
{
uint32_t enb_id;
uint32_t mme_id;
MessageDef *msg_p;
uint32_t register_enb_pending = 0;
char *str = NULL;
struct in_addr addr;
for (enb_id = 0; (enb_id < enb_properties->number) ; enb_id++) {
{
s1ap_register_enb_req_t *s1ap_register_eNB;
/* note: there is an implicit relationship between the data structure and the message name */
msg_p = itti_alloc_new_message (TASK_ENB_APP, S1AP_REGISTER_ENB_REQ);
s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p);
/* Some default/random parameters */
s1ap_register_eNB->eNB_id = enb_properties->properties[enb_id]->eNB_id;
s1ap_register_eNB->cell_type = enb_properties->properties[enb_id]->cell_type;
s1ap_register_eNB->eNB_name = enb_properties->properties[enb_id]->eNB_name;
s1ap_register_eNB->tac = enb_properties->properties[enb_id]->tac;
s1ap_register_eNB->mcc = enb_properties->properties[enb_id]->mcc;
s1ap_register_eNB->mnc = enb_properties->properties[enb_id]->mnc;
s1ap_register_eNB->mnc_digit_length = enb_properties->properties[enb_id]->mnc_digit_length;
s1ap_register_eNB->default_drx = enb_properties->properties[enb_id]->pcch_defaultPagingCycle[0];
s1ap_register_eNB->nb_mme = enb_properties->properties[enb_id]->nb_mme;
AssertFatal (s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS, "Too many MME for eNB %d (%d/%d)!", enb_id, s1ap_register_eNB->nb_mme,
S1AP_MAX_NB_MME_IP_ADDRESS);
for (mme_id = 0; mme_id < s1ap_register_eNB->nb_mme; mme_id++) {
s1ap_register_eNB->mme_ip_address[mme_id].ipv4 = enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv4;
s1ap_register_eNB->mme_ip_address[mme_id].ipv6 = enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv6;
strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv4_address,
enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv4_address,
sizeof(s1ap_register_eNB->mme_ip_address[0].ipv4_address));
strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv6_address,
enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv6_address,
sizeof(s1ap_register_eNB->mme_ip_address[0].ipv6_address));
}
//------------------------------------------------------------------------------
int test_s1ap_decode_successful_outcome(s1ap_message *message,
S1ap_SuccessfulOutcome_t *successfullOutcome_p)
{
char *message_string = NULL;
int ret = -1;
DevAssert(successfullOutcome_p != NULL);
message_string = calloc(20000, sizeof(char));
AssertFatal (NULL != message_string, "ERROR malloc()failed!\n");
message->procedureCode = successfullOutcome_p->procedureCode;
message->criticality = successfullOutcome_p->criticality;
switch(successfullOutcome_p->procedureCode) {
case S1ap_ProcedureCode_id_S1Setup:
ret = s1ap_decode_s1ap_s1setupresponseies(
&message->msg.s1ap_S1SetupResponseIEs, &successfullOutcome_p->value);
s1ap_xer_print_s1ap_s1setupresponse(s1ap_xer__print2sp, message_string, message);
break;
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);
break;
case S1ap_ProcedureCode_id_UEContextRelease:
ret = s1ap_decode_s1ap_uecontextreleasecompleteies (&message->msg.s1ap_UEContextReleaseCompleteIEs, &successfullOutcome_p->value);
s1ap_xer_print_s1ap_uecontextreleasecomplete(s1ap_xer__print2sp, message_string, message);
break;
default:
free(message_string);
AssertFatal(0, "Unknown procedure ID (%d) for successfull outcome message\n",
(int)successfullOutcome_p->procedureCode);
return -1;
}
fprintf(stdout, "s1ap_xer_print:\n%s\n", message_string);
free(message_string);
return ret;
}
s1ap_register_eNB->sctp_in_streams = enb_properties->properties[enb_id]->sctp_in_streams;
s1ap_register_eNB->sctp_out_streams = enb_properties->properties[enb_id]->sctp_out_streams;
//------------------------------------------------------------------------------
int test_s1ap_decode_unsuccessful_outcome(s1ap_message *message,
S1ap_UnsuccessfulOutcome_t *unSuccessfullOutcome_p)
{
char *message_string = NULL;
int ret = -1;
DevAssert(unSuccessfullOutcome_p != NULL);
message_string = calloc(20000, sizeof(char));
AssertFatal (NULL != message_string, "ERROR malloc()failed!\n");
message->procedureCode = unSuccessfullOutcome_p->procedureCode;
message->criticality = unSuccessfullOutcome_p->criticality;
switch(unSuccessfullOutcome_p->procedureCode) {
case S1ap_ProcedureCode_id_S1Setup:
ret = s1ap_decode_s1ap_s1setupfailureies(
&message->msg.s1ap_S1SetupFailureIEs, &unSuccessfullOutcome_p->value);
s1ap_xer_print_s1ap_s1setupfailure(s1ap_xer__print2sp, message_string, message);
break;
case S1ap_ProcedureCode_id_InitialContextSetup:
ret = s1ap_decode_s1ap_initialcontextsetupfailureies (&message->msg.s1ap_InitialContextSetupFailureIEs, &unSuccessfullOutcome_p->value);
s1ap_xer_print_s1ap_initialcontextsetupfailure(s1ap_xer__print2sp, message_string, message);
break;
default:
free(message_string);
AssertFatal(0,"Unknown procedure ID (%d) for unsuccessfull outcome message\n",
(int)unSuccessfullOutcome_p->procedureCode);
break;
s1ap_register_eNB->enb_ip_address.ipv6 = 0;
s1ap_register_eNB->enb_ip_address.ipv4 = 1;
addr.s_addr = enb_properties->properties[enb_id]->enb_ipv4_address_for_S1_MME;
str = inet_ntoa(addr);
strcpy(s1ap_register_eNB->enb_ip_address.ipv4_address,