temp/
.tags
.tags1
+.asn
tools/asn1c
-build_and_run_e2sim
-test_e2_termination
-upload_to_demo_laptop
+tools/asn_defs/*.asn
+tools/asn_defs/*.asn1
+
+test/WLG/build/
+test/X2/build/
-# Copyright 2019 AT&T Intellectual Property
-# Copyright 2019 Nokia
-#
-# Licensed 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.
-#
+#/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+#******************************************************************************/
cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_CXX_COMPILER "/usr/bin/g++")
set(CMAKE_CXX_STANDARD 14)
-project(e2sim)
-
-set (HOME_DIR $ENV{HOME})
-
-include_directories("src")
-include_directories("src/ASN1/lib")
-include_directories("src/SCTP/")
-include_directories("src/E2AP")
-include_directories("src/X2AP")
-
-#for ASN1_API
-#include_directories("src/ASN1")
-#include_directories("src/ASN1/asn")
-#include_directories("src/ASN1/generated")
-#add_library(ASN1_API
-# "src/ASN1/lib/asn_x2ap.cpp"
-#)
-
-link_directories("build")
+add_definitions("-D ASN_DISABLE_OER_SUPPORT")
-#-----------------------------------------------
-file(GLOB E2AGENT_SOURCES
- "src/e2agent.cpp"
- "src/e2sim_defs.cpp"
- "src/SCTP/*.cpp"
- "src/E2AP/*.cpp"
- )
-add_executable(e2agent ${E2AGENT_SOURCES})
-
-#for ASN1_API
-target_link_libraries(e2agent ASN1_API)
+project(e2sim)
-#-----------------------------------------------
-file(GLOB E2TERM_SOURCES
- "src/e2termination_test.cpp"
- "src/e2sim_defs.cpp"
- "src/SCTP/*.cpp"
- "src/E2AP/*.cpp"
+set (E2SIM_ROOT ./)
+
+include_directories("${E2SIM_ROOT}/src")
+include_directories("${E2SIM_ROOT}/src/DEF")
+include_directories("${E2SIM_ROOT}/src/SCTP/")
+include_directories("${E2SIM_ROOT}/src/E2AP")
+include_directories("${E2SIM_ROOT}/src/E2AP/E2SM")
+include_directories("${E2SIM_ROOT}/ASN1c")
+
+find_library( SCTP_STD_LIB sctp ) #needed for sctp_sendmsg
+
+#----------------------------------------------
+file(GLOB E2SIM_SOURCES
+ "${E2SIM_ROOT}/e2sim.cpp"
+ "${E2SIM_ROOT}/src/DEF/*.cpp"
+ "${E2SIM_ROOT}/src/SCTP/*.cpp"
+ "${E2SIM_ROOT}/src/E2AP/*.c"
+ "${E2SIM_ROOT}/src/E2AP/*.cpp"
+ "${E2SIM_ROOT}/ASN1c/*.c"
)
-add_executable(e2term ${E2TERM_SOURCES})
-target_link_libraries(e2term ASN1_API)
-
-#-----------------------------------------------
-file(GLOB X2TERM_SOURCES
- "src/x2termination_test.cpp"
- "src/e2sim_defs.cpp"
- "src/SCTP/*.cpp"
- "src/X2AP/*.cpp"
+add_executable(e2sim ${E2SIM_SOURCES})
+target_link_libraries( e2sim ${SCTP_STD_LIB} )
+
+#----------------------------------------------
+file(GLOB RICSIM_SOURCES
+ "${E2SIM_ROOT}/ricsim.cpp"
+ "${E2SIM_ROOT}/src/DEF/*.cpp"
+ "${E2SIM_ROOT}/src/SCTP/*.cpp"
+ "${E2SIM_ROOT}/src/E2AP/*.c"
+ "${E2SIM_ROOT}/src/E2AP/*.cpp"
+ "${E2SIM_ROOT}/ASN1c/*.c"
)
-add_executable(x2term ${X2TERM_SOURCES})
-target_link_libraries(x2term ASN1_API)
+add_executable(ricsim ${RICSIM_SOURCES})
+target_link_libraries( ricsim ${SCTP_STD_LIB} )
-/*****************************************************************************
+#/*****************************************************************************
# *
# Copyright 2019 AT&T Intellectual Property *
# Copyright 2019 Nokia *
# See the License for the specific language governing permissions and *
# limitations under the License. *
# *
-******************************************************************************/
+#******************************************************************************/
-# INSTALLATION
- * Tested environment: Ubuntu 16.04
- * Install dependencies
+
+# INSTALLATION (tested on Ubuntu 16.04)
+ 1. Install dependencies
$ sudo apt-get update
$ sudo apt-get install -y
build-essential
libboost-all-dev
$ sudo apt-get clean
- ## Build
- $ ./build_e2sim
+ 2. SET ENVIRONMENT VARIABLE
+ Add this line to `~/.bashrc`
+ export E2SIM_DIR=<your e2sim directory>
-# SET ENVIRONMENT VARIABLE
- Add this line to `~/.bashrc`
- $ export E2SIM_DIR=<your e2sim directory>
+ 3. Build the official e2sim
+ $ ./build_e2sim
-# RUN E2SIM
- $ cd $E2SIM_DIR/build/
- $ ./e2agent [SERVER IP] [PORT]
+# USAGE
+ $ $E2SIM_DIR/build/e2sim [SERVER IP] [PORT]
- By default, SERVER IP = 127.0.0.1, PORT = 36422 (X2AP Port)
+ By default, SERVER IP = 127.0.0.1, PORT = 36421
# DOCKER
Note: The commands in this section must be run from $E2SIM_DIR
* Build docker image
- $ ./build_docker
+ $ sudo docker build -f docker/Dockerfile -t [DOCKER_IMAGE]:[TAG] .
- ## Run docker container
- $ sudo docker run --rm --net host -it e2agent sh -c "./build/e2agent [SERVER IP] [PORT]"
+ * Example how to run docker container
+ $ sudo docker run --rm --net host -it [DOCKER_IMAGE]:[TAG] sh -c "./build/e2sim [SERVER IP] [PORT]"
-# SUPPORTED MESSAGE FLOWS (Last updated May 24, 2019)
+# SUPPORTED MESSAGE FLOWS
-- X2 SETUP REQUEST (RIC -> RAN)
-- X2 SETUP RESPONSE (RAN -> RIC)
+- RIC INDICATION (RAN -> RIC) version 1.3.0 September 13, 2019
+ SgNBAdditionRequest
+
+- RIC SUBSCRIPTION REQUEST (RIC -> RAN) version 1.2.0 May 24, 2019
+- RIC SUBSCRIPTION RESPONSE (RAN -> RIC)
+- RIC SUBSCRIPTION FAILURE (RAN -> RIC)
- ENDC X2 SETUP REQUEST (RIC -> RAN)
- ENDC X2 SETUP RESPONSE (RAN -> RIC)
-- RIC SUBSCRIPTION REQUEST (RIC -> RAN)
-- RIC SUBSCRIPTION RESPONSE (RAN -> RIC)
-- RIC SUBSCRIPTION FAILURE (RAN -> RIC)
+- X2 SETUP REQUEST (RIC -> RAN)
+- X2 SETUP RESPONSE (RAN -> RIC)
+
+# GENERATING ASN1C CODES FOR E2AP, E2SM, X2AP
+ 1. Install asn1c compiler
+ ./tools/install_asn1c
+ 2. Generate asn1c codes using e2ap, e2sm and x2ap specs
+ Download the following files into tools/asn_defs
+ - e2ap-v031.asn
+ - e2sm-gNB-X2-release-1-v041.asn
+ - x2ap-no-desc-15-04.asn
# Change logs:
03/12/2019: currently supports sending and receiving X2 SETUP messages
#!/bin/bash
-#
-#
-# Copyright 2019 AT&T Intellectual Property
-# Copyright 2019 Nokia
-#
-# Licensed 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.
-#
-# build utility for E2 Agent
+#/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+#******************************************************************************/
set -e
-E2SIM_DIR=$PWD
-ASN1_C_DIR=$E2SIM_DIR/build/CMakeFiles/ASN1
-
+E2SIM_VERSION='1.3.0'
+export E2SIM_DIR=$PWD
source $E2SIM_DIR/tools/build_helper.bash
+DOCKER_IMAGE='e2sim'
-print_help()
-{
+print_help() {
echo "
This program installs E2 Simulator
You should have ubuntu 14.xx, updated, and the Linux kernel >= 3.14
The program is run by default with no option
- Options
+ USAGE:
+ ./build_e2sim [OPTIONS]
+
+ OPTIONS:
--clean
Erase all files to make a rebuild from start
+ --docker
+ Build docker image
-h
Print this help
"
}
-generate_asn1c_codes()
-{
- X2AP_RELEASE="R14"
- X2AP_ASN_FILES="x2ap-14.6.0.asn1"
- ASN_SOURCE_X2AP=$E2SIM_DIR/src/X2AP/MESSAGES/ASN1/${X2AP_RELEASE}/${X2AP_ASN_FILES}
-
- ASN_SOURCE_Pendulum=$E2SIM_DIR/src/ONS2019/pendulum.asn1
-
- done_flag="$ASN1_C_DIR"/done
-
- #-ot = older than, -nt = newer than
-
- if [ "$done_flag" -ot $ASN_SOURCE_X2AP ] ; then
- echo_info "Generate C codes for from source file"
- #echo_info $ASN_SOURCE
-
- rm -f "$ASN1_C_DIR"/*.c "$ASN1_C_DIR"/*.h
- mkdir -p $ASN1_C_DIR
- asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example \
- -fno-include-deps -D $ASN1_C_DIR $ASN_SOURCE_X2AP \
- |& egrep -v "^Copied|^Compiled" | sort -u
-
- asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example \
- -fno-include-deps -D $ASN1_C_DIR $ASN_SOURCE_Pendulum \
- |& egrep -v "^Copied|^Compiled" | sort -u
-
- echo_success "ASN1 C codes generated at: $ASN1_C_DIR"
- fi
- touch $done_flag
-}
-
-install_rmr()
-{
- echo_info "Will install rmr library"
- /bin/bash rmr_interface/rmr_install.sh
-}
-
-compile_asn_api_lib()
-{
- echo_info "Will complie ASN1_API library"
- # rm -rf build/libASN1_API.a
- # rm -rf build/asn_x2ap.o
- # rm -rf build/asn_e2ap.o
-
- g++ -O3 -std=c++14 -Wall \
- -I./src/ASN1/ -I./src/ASN1/asn/ -I./src/ASN1/generated/ \
- -c src/ASN1/lib/asn_e2ap.cpp \
- -o build/asn_e2ap.o
- ar -crv build/libASN1_API.a build/asn_e2ap.o
-
- g++ -O3 -std=c++14 -Wall \
- -I./src/ASN1/ -I./src/ASN1/asn/ -I./src/ASN1/generated/ \
- -c src/ASN1/lib/asn_x2ap.cpp \
- -o build/asn_x2ap.o
- ar -crv build/libASN1_API.a build/asn_x2ap.o
-}
-
-function main()
-{
-
+function main(){
case "$1" in
--clean)
echo_info "Will clean all previously producted files under build/"
exit
;;
- "")
- ;;
-
- --rmr)
- install_rmr
+ --docker)
+ echo "Will build docker image ${DOCKER_IMAGE}:${E2SIM_VERSION}"
+ sudo docker build -f docker/Dockerfile -t $DOCKER_IMAGE:$E2SIM_VERSION .
exit
;;
- --lib)
- compile_asn_api_lib
- exit
+ "")
;;
-h)
BUILD_DIR=$E2SIM_DIR/build
mkdir -p $BUILD_DIR
- mkdir -p $BUILD_DIR/log
-
- # generate_asn1c_codes #X2AP, pendulum
-
- compile_asn_api_lib
echo_info "Will build e2sim"
cd $BUILD_DIR
make -j`nproc`
echo_success "e2sim compiled"
-
}
main "$@"
bison \
flex \
libboost-all-dev \
+ iputils-ping \
+ net-tools \
+ nano \
+ vim \
&& apt-get clean
# Copy E2Sim sources into the container
#include "e2sim_defs.h"
#include "e2sim_sctp.hpp"
-#include "asn_e2ap.hpp"
#include "e2ap_message_handler.hpp"
using namespace std;
-void test(void)
-{
- e2ap_pdu_t* pdu = new_e2ap_pdu();
-
- gNB_config gnb_cfg;
-
- e2ap_create_ENDCX2SetupResponse(pdu, gnb_cfg);
-
- e2ap_print_pdu(pdu);
-
- //Encode into buffer
- sctp_buffer_t data;
- e2ap_encode_pdu(pdu, data.buffer, sizeof(data.buffer), data.len);
-
-}
-
int main(int argc, char* argv[]){
-
- LOG_I("E2 Agent (E2 Simulator) Version %s", VERSION);
-
- // test();
- // return 0;
+ LOG_I("Start E2 Agent (E2 Simulator)");
options_t ops = read_input_options(argc, argv);
sctp_buffer_t recv_buf;
LOG_I("[SCTP] Waiting for SCTP data");
+
while(1) //constantly looking for data on SCTP interface
{
if(sctp_receive_data(client_fd, recv_buf) <= 0)
echo "e2sim starting at ${E2SIM_BIND_ADDR}:${E2SIM_PORT:-36421}"
fi
-${E2SIM:-/home/e2sim/build/e2agent} ${E2SIM_BIND_ADDR} ${E2SIM_PORT:-36421}
+${E2SIM:-/home/e2sim/build/e2sim} ${E2SIM_BIND_ADDR} ${E2SIM_PORT:-36421}
--- /dev/null
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <assert.h>
+
+#include "e2sim_sctp.hpp"
+#include "e2ap_message_handler.hpp"
+
+extern "C" {
+ #include "e2sim_defs.h"
+ #include "E2AP-PDU.h"
+ #include "e2ap_asn1c_codec.h"
+}
+
+using namespace std;
+
+void encode_and_send_sctp_data(E2AP_PDU_t* pdu, int client_fd)
+{
+ uint8_t *buf;
+ sctp_buffer_t data;
+
+ data.len = e2ap_asn1c_encode_pdu(pdu, &buf);
+ memcpy(data.buffer, buf, data.len);
+
+ sctp_send_data(client_fd, data);
+}
+
+void wait_for_sctp_data(int client_fd)
+{
+ sctp_buffer_t recv_buf;
+ if(sctp_receive_data(client_fd, recv_buf) > 0)
+ {
+ LOG_I("[SCTP] Received new data of size %d", recv_buf.len);
+ e2ap_handle_sctp_data(client_fd, recv_buf);
+ }
+}
+
+int main(int argc, char* argv[]){
+ LOG_I("Start RIC Simulator");
+
+ options_t ops = read_input_options(argc, argv);
+ int client_fd = sctp_start_client(ops.server_ip, ops.server_port);
+
+ //1. Send ENDCX2Setup
+ E2AP_PDU_t* pdu_setup = e2ap_xml_to_pdu("E2AP_ENDCX2SetupRequest.xml");
+ e2ap_asn1c_print_pdu(pdu_setup);
+ encode_and_send_sctp_data(pdu_setup, client_fd);
+ LOG_I("[SCTP] Sent ENDC X2 SETUP REQUEST");
+
+ //2. Receive ENDCX2SetupResponse
+ wait_for_sctp_data(client_fd);
+
+ //3. Send RICSubscriptionRequest
+ E2AP_PDU_t* pdu_sub = e2ap_xml_to_pdu("E2AP_RICsubscriptionRequest_Ashwin.xml");
+ e2ap_asn1c_print_pdu(pdu_sub);
+ encode_and_send_sctp_data(pdu_sub, client_fd);
+ LOG_I("[SCTP] Sent RIC SUBSCRIPTION REQUEST");
+
+ //4. Receive RICSubscriptionResponse
+ while(1){
+ wait_for_sctp_data(client_fd);
+ }
+
+
+ //---------------------------------------
+ close(client_fd);
+ LOG_I("[SCTP] Connection closed.");
+
+ return 0;
+
+}
#ifndef E2SIM_DEFS_H
#define E2SIM_DEFS_H
-#include <iostream>
+// #include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
#define VERSION "1.2.0" //May 2019
#define DEFAULT_SCTP_IP "127.0.0.1"
-#define X2AP_SCTP_PORT 36422
-#define MAX_SCTP_BUFFER 1024
+#define X2AP_PPID (452984832) //27 = 1b, PPID = 1b000000(hex) -> 452984832(dec)
+#define X2AP_SCTP_PORT 36421
+#define RIC_SCTP_SRC_PORT 36422
+#define MAX_SCTP_BUFFER 1024
#define WORKDIR_ENV "E2SIM_DIR" //environment variable
#define LOG_I(...) {printf(__VA_ARGS__); printf("\n");}
--- /dev/null
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+#include "e2sm.h"
+
+#include "ActionParameter-Item.h"
+#include "ActionParameter-Value.h"
+#include "PLMN-Identity.h"
+#include "GlobalENB-ID.h"
+#include "GlobalGNB-ID.h"
+#include "Interface-ID.h"
+#include "ProtocolIE-Field.h"
+#include "InterfaceMessageType.h"
+#include "InterfaceProtocolIE-Item.h"
+
+static PLMN_Identity_t *createPLMN_ID(const unsigned char *data) {
+
+ PLMN_Identity_t *plmnId = calloc(1, sizeof(PLMN_Identity_t));
+ ASN_STRUCT_RESET(asn_DEF_PLMN_Identity, plmnId);
+ plmnId->size = 3;
+ plmnId->buf = calloc(1, 3);
+ memcpy(plmnId->buf, data, 3);
+
+ return plmnId;
+}
+
+static GNB_ID_t *createGnb_id(const unsigned char *data, int numOfBits) {
+
+ if (numOfBits < 22 || numOfBits > 32) {
+ printf("[Error] GNB_ID_t number of bits = %d, needs to be 22 .. 32", numOfBits);
+ return NULL;
+ }
+
+ GNB_ID_t *gnb = calloc(1, sizeof(GNB_ID_t));
+ ASN_STRUCT_RESET(asn_DEF_GNB_ID, gnb);
+
+ gnb->present = GNB_ID_PR_gNB_ID;
+ gnb->choice.gNB_ID.size = numOfBits % 8 == 0 ? (unsigned int)(numOfBits / 8) : (unsigned int)(numOfBits / 8 + 1);
+ gnb->choice.gNB_ID.bits_unused = gnb->choice.gNB_ID.size * 8 - numOfBits;
+ gnb->choice.gNB_ID.buf = calloc(1, gnb->choice.gNB_ID.size);
+ memcpy(gnb->choice.gNB_ID.buf, data, gnb->choice.gNB_ID.size);
+ gnb->choice.gNB_ID.buf[gnb->choice.gNB_ID.size - 1] =
+ ((unsigned)(gnb->choice.gNB_ID.buf[gnb->choice.gNB_ID.size - 1] >> (unsigned)gnb->choice.gNB_ID.bits_unused)
+ << (unsigned)gnb->choice.gNB_ID.bits_unused);
+
+ return gnb;
+}
+
+static GlobalGNB_ID_t *createGlobalGNB_ID(PLMN_Identity_t *plmnIdentity, GNB_ID_t *gnb) {
+
+ GlobalGNB_ID_t *ggnbId = calloc(1, sizeof(GlobalGNB_ID_t));
+ ASN_STRUCT_RESET(asn_DEF_GlobalGNB_ID, ggnbId);
+
+ memcpy(&ggnbId->pLMN_Identity, plmnIdentity, sizeof(PLMN_Identity_t));
+ memcpy(&ggnbId->gNB_ID, gnb, sizeof(GNB_ID_t));
+
+ return ggnbId;
+}
+
+static Interface_ID_t *createInterfaceIDForGnb(GlobalGNB_ID_t *gnb) {
+
+ Interface_ID_t *interfaceId = calloc(1, sizeof(Interface_ID_t));
+ ASN_STRUCT_RESET(asn_DEF_Interface_ID, interfaceId);
+
+ interfaceId->present = Interface_ID_PR_global_gNB_ID;
+ interfaceId->choice.global_gNB_ID = gnb;
+
+ return interfaceId;
+}
+
+static InterfaceMessageType_t *createInterfaceMessageInitiating(long procedureCode) {
+
+ InterfaceMessageType_t *intMsgT = calloc(1, sizeof(InterfaceMessageType_t));
+ ASN_STRUCT_RESET(asn_DEF_InterfaceMessageType, intMsgT);
+
+ intMsgT->procedureCode = procedureCode;
+ intMsgT->typeOfMessage = TypeOfMessage_initiating_message;
+
+ return intMsgT;
+}
+
+E2SM_gNB_X2_eventTriggerDefinition_t* create_eventTriggerDefinition(void)
+{
+ //PLMN_Identity
+ unsigned char plmnidData[3] = {0x33, 0xF4, 0x55};
+ PLMN_Identity_t *plmnid = createPLMN_ID(plmnidData);
+ // xer_fprint(stdout, &asn_DEF_PLMN_Identity, (void *)plmnid);
+
+ //GNB_ID
+ unsigned char gnbData[3] = {0x99, 0xaa, 0xbb};
+ GNB_ID_t *gnb = createGnb_id(gnbData, 26);
+ // xer_fprint(stdout, &asn_DEF_GNB_ID, (void *)gnb);
+
+ //GlobalGNB_ID
+ GlobalGNB_ID_t *globaGnb = createGlobalGNB_ID(plmnid, gnb);
+ // xer_fprint(stdout, &asn_DEF_GlobalGNB_ID, (void *)globaGnb);
+
+ //Interface_ID
+ Interface_ID_t *gnbInterfaceId = createInterfaceIDForGnb(globaGnb);
+ // xer_fprint(stdout, &asn_DEF_Interface_ID, (void *)gnbInterfaceId);
+
+ //InterfaceMessageType
+ InterfaceMessageType_t *initiatingInterface = createInterfaceMessageInitiating(35);
+
+ //EventTriggerDefinition
+ E2SM_gNB_X2_eventTriggerDefinition_t *eventTrigger = calloc(1, sizeof(E2SM_gNB_X2_eventTriggerDefinition_t));
+ ASN_STRUCT_RESET(asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, eventTrigger);
+
+ memcpy(&eventTrigger->interface_ID , gnbInterfaceId, sizeof(Interface_ID_t));
+
+ eventTrigger->interfaceDirection = 0;
+ memcpy(&eventTrigger->interfaceMessageType, initiatingInterface, sizeof(InterfaceMessageType_t));
+
+ return eventTrigger;
+}
+
+#define E2AP_ASN1C_FIND_PROTOCOLIE_BY_ID(IE_TYPE, ie, container, IE_ID) \
+ do {\
+ IE_TYPE **ptr; \
+ ie = NULL; \
+ for (ptr = container->protocolIEs.list.array; \
+ ptr < &container->protocolIEs.list.array[container->protocolIEs.list.count]; \
+ ptr++) { \
+ if((*ptr)->id == IE_ID) { \
+ ie = *ptr; \
+ break; \
+ } \
+ } \
+ } while(0)
+
+
+void test_eventTriggerDefinition(void)
+{
+ E2SM_gNB_X2_eventTriggerDefinition_t *eventTrigger = create_eventTriggerDefinition();
+
+ xer_fprint(stdout, &asn_DEF_E2SM_gNB_X2_eventTriggerDefinition, (void *)eventTrigger);
+ printf("\n");
+
+ uint8_t *eventBuff;
+ int eventBuff_len;
+
+ eventBuff_len = aper_encode_to_new_buffer(&asn_DEF_E2SM_gNB_X2_eventTriggerDefinition,
+ 0, eventTrigger, (void **)&eventBuff);
+
+ LOG_I("Encoded eventBuff_len = %d", eventBuff_len);
+
+ //-----------------------------------------------------------------------
+ E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionRequest.xml");
+ e2ap_asn1c_print_pdu(pdu);
+
+ InitiatingMessage_t *initiatingMessage = pdu->choice.initiatingMessage;
+ xer_fprint(stdout, &asn_DEF_InitiatingMessage, (void *)initiatingMessage);
+
+ RICsubscriptionRequest_t *request = &initiatingMessage->value.choice.RICsubscriptionRequest;
+ xer_fprint(stdout, &asn_DEF_RICsubscriptionRequest, (void *)request);
+
+ LOG_I("num of IEs = %d", request->protocolIEs.list.count);
+
+
+ RICsubscriptionRequest_IEs_t *ie;
+
+ ie = request->protocolIEs.list.array[2];
+
+ // E2AP_ASN1C_FIND_PROTOCOLIE_BY_ID(RICsubscriptionRequest_IEs_t, ie, request, ProtocolIE_ID_id_RICsubscription);
+ // E2AP_ASN1C_FIND_PROTOCOLIE_BY_ID(RICsubscriptionRequest_IEs_t, ie, request, ProtocolIE_ID_id_RICrequestID);
+
+ assert( ie != NULL);
+
+ xer_fprint(stdout, &asn_DEF_RICsubscription, (void *)ie);
+ // xer_fprint(stdout, &asn_DEF_RICrequestID, (void *)ie);
+
+
+}
+
+//
+// typedef struct ProtocolIE_Container_119P0 {
+// A_SEQUENCE_OF(struct RICsubscriptionRequest_IEs) list;
+//
+// /* Context for parsing across buffer boundaries */
+// asn_struct_ctx_t _asn_ctx;
+// } ProtocolIE_Container_119P0_t;
-/*****************************************************************************\r
-# *\r
-# Copyright 2019 AT&T Intellectual Property *\r
-# Copyright 2019 Nokia *\r
-# *\r
-# Licensed under the Apache License, Version 2.0 (the "License"); *\r
-# you may not use this file except in compliance with the License. *\r
-# You may obtain a copy of the License at *\r
-# *\r
-# http://www.apache.org/licenses/LICENSE-2.0 *\r
-# *\r
-# Unless required by applicable law or agreed to in writing, software *\r
-# distributed under the License is distributed on an "AS IS" BASIS, *\r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *\r
-# See the License for the specific language governing permissions and *\r
-# limitations under the License. *\r
-# *\r
-******************************************************************************/\r
-#ifndef E2AP_ASN_CODEC_HPP\r
-#define E2AP_ASN_CODEC_HPP\r
-\r
-#include "e2sim_defs.h"\r
-#include "asn_e2ap.hpp"\r
-\r
-#define ERROR_MESSAGE_BUFFER 1024\r
-#define PDU_PRINT_BUFFER 4096\r
-\r
-void e2ap_encode_pdu(e2ap_pdu_t* pdu, unsigned char* buf, int buf_size, int &encoded_size);\r
-\r
-void e2ap_decode_pdu(e2ap_pdu_t* pdu, unsigned char* buf, int &encoded_size);\r
-\r
-void e2ap_print_pdu(e2ap_pdu_t* pdu);\r
-\r
-#endif\r
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+#ifndef E2SM_H
+#define E2SM_H
+
+#include "E2SM-gNB-X2-eventTriggerDefinition.h"
+#include "E2AP-PDU.h"
+#include "e2ap_asn1c_codec.h"
+
+E2SM_gNB_X2_eventTriggerDefinition_t* create_eventTriggerDefinition(void);
+
+void test_eventTriggerDefinition(void);
+
+#endif
--- /dev/null
+<E2AP-PDU>
+ <unsuccessfulOutcome>
+ <procedureCode>36</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <ENDCX2SetupFailure>
+ <protocolIEs>
+ <ENDCX2SetupFailure-IEs>
+ <id>5</id>
+ <criticality><ignore/></criticality>
+ <value>
+ <Cause>
+ <radioNetwork><ho-target-not-allowed/></radioNetwork>
+ </Cause>
+ </value>
+ </ENDCX2SetupFailure-IEs>
+ </protocolIEs>
+ </ENDCX2SetupFailure>
+ </value>
+ </unsuccessfulOutcome>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <initiatingMessage>
+ <procedureCode>36</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <ENDCX2SetupRequest>
+ <protocolIEs>
+ <ENDCX2SetupRequest-IEs>
+ <id>244</id>
+ <criticality><reject/></criticality>
+ <value>
+ <InitiatingNodeType-EndcX2Setup>
+ <init-eNB>
+ <ENB-ENDCX2SetupReqIEs>
+ <id>21</id>
+ <criticality><reject/></criticality>
+ <value>
+ <GlobalENB-ID>
+ <pLMN-Identity>61 62 63</pLMN-Identity>
+ <eNB-ID>
+ <macro-eNB-ID>
+ 00110101000000000001
+ </macro-eNB-ID>
+ </eNB-ID>
+ </GlobalENB-ID>
+ </value>
+ </ENB-ENDCX2SetupReqIEs>
+ <ENB-ENDCX2SetupReqIEs>
+ <id>250</id>
+ <criticality><reject/></criticality>
+ <value>
+ <ServedEUTRAcellsENDCX2ManagementList>
+ <SEQUENCE>
+ <servedEUTRACellInfo>
+ <pCI>0</pCI>
+ <cellId>
+ <pLMN-Identity>61 62 63</pLMN-Identity>
+ <eUTRANcellIdentifier>
+ 0110010001100101011001100000
+ </eUTRANcellIdentifier>
+ </cellId>
+ <tAC>61 62</tAC>
+ <broadcastPLMNs>
+ <PLMN-Identity>61 62 63</PLMN-Identity>
+ </broadcastPLMNs>
+ <eUTRA-Mode-Info>
+ <fDD>
+ <uL-EARFCN>21400</uL-EARFCN>
+ <dL-EARFCN>3400</dL-EARFCN>
+ <uL-Transmission-Bandwidth><bw25/></uL-Transmission-Bandwidth>
+ <dL-Transmission-Bandwidth><bw50/></dL-Transmission-Bandwidth>
+ </fDD>
+ </eUTRA-Mode-Info>
+ </servedEUTRACellInfo>
+ </SEQUENCE>
+ </ServedEUTRAcellsENDCX2ManagementList>
+ </value>
+ </ENB-ENDCX2SetupReqIEs>
+ </init-eNB>
+ </InitiatingNodeType-EndcX2Setup>
+ </value>
+ </ENDCX2SetupRequest-IEs>
+ </protocolIEs>
+ </ENDCX2SetupRequest>
+ </value>
+ </initiatingMessage>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <successfulOutcome>
+ <procedureCode>36</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <ENDCX2SetupResponse>
+ <protocolIEs>
+ <ENDCX2SetupResponse-IEs>
+ <id>246</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RespondingNodeType-EndcX2Setup>
+ <respond-en-gNB>
+ <En-gNB-ENDCX2SetupReqAckIEs>
+ <id>252</id>
+ <criticality><reject/></criticality>
+ <value>
+ <GlobalGNB-ID>
+ <pLMN-Identity>02 F8 29</pLMN-Identity>
+ <gNB-ID>
+ <gNB-ID>
+ 000000000001001000110100
+ </gNB-ID>
+ </gNB-ID>
+ </GlobalGNB-ID>
+ </value>
+ </En-gNB-ENDCX2SetupReqAckIEs>
+ <En-gNB-ENDCX2SetupReqAckIEs>
+ <id>253</id>
+ <criticality><reject/></criticality>
+ <value>
+ <ServedNRcellsENDCX2ManagementList>
+ <SEQUENCE>
+ <servedNRCellInfo>
+ <nrpCI>99</nrpCI>
+ <nrCellID>
+ <pLMN-Identity>02 F8 29</pLMN-Identity>
+ <nRcellIdentifier>
+ 000000000000011110101011000000010010
+ </nRcellIdentifier>
+ </nrCellID>
+ <broadcastPLMNs>
+ <PLMN-Identity>02 F8 29</PLMN-Identity>
+ </broadcastPLMNs>
+ <nrModeInfo>
+ <fdd>
+ <ul-NRFreqInfo>
+ <nRARFCN>100</nRARFCN>
+ <freqBandListNr>
+ <FreqBandNrItem>
+ <freqBandIndicatorNr>9</freqBandIndicatorNr>
+ <supportedSULBandList>
+ <SupportedSULFreqBandItem>
+ <freqBandIndicatorNr>9</freqBandIndicatorNr>
+ </SupportedSULFreqBandItem>
+ </supportedSULBandList>
+ </FreqBandNrItem>
+ </freqBandListNr>
+ </ul-NRFreqInfo>
+ <dl-NRFreqInfo>
+ <nRARFCN>100</nRARFCN>
+ <freqBandListNr>
+ <FreqBandNrItem>
+ <freqBandIndicatorNr>9</freqBandIndicatorNr>
+ <supportedSULBandList>
+ <SupportedSULFreqBandItem>
+ <freqBandIndicatorNr>9</freqBandIndicatorNr>
+ </SupportedSULFreqBandItem>
+ </supportedSULBandList>
+ </FreqBandNrItem>
+ </freqBandListNr>
+ </dl-NRFreqInfo>
+ <ul-NR-TxBW>
+ <nRSCS><scs15/></nRSCS>
+ <nRNRB><nrb11/></nRNRB>
+ </ul-NR-TxBW>
+ <dl-NR-TxBW>
+ <nRSCS><scs15/></nRSCS>
+ <nRNRB><nrb11/></nRNRB>
+ </dl-NR-TxBW>
+ </fdd>
+ </nrModeInfo>
+ <measurementTimingConfiguration>04 05</measurementTimingConfiguration>
+ </servedNRCellInfo>
+ </SEQUENCE>
+ </ServedNRcellsENDCX2ManagementList>
+ </value>
+ </En-gNB-ENDCX2SetupReqAckIEs>
+ </respond-en-gNB>
+ </RespondingNodeType-EndcX2Setup>
+ </value>
+ </ENDCX2SetupResponse-IEs>
+ </protocolIEs>
+ </ENDCX2SetupResponse>
+ </value>
+ </successfulOutcome>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <initiatingMessage>
+ <procedureCode>3</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <ErrorIndication>
+ <protocolIEs>
+ <ErrorIndication-IEs>
+ <id>5</id>
+ <criticality><ignore/></criticality>
+ <value>
+ <Cause>
+ <radioNetwork><ho-target-not-allowed/></radioNetwork>
+ </Cause>
+ </value>
+ </ErrorIndication-IEs>
+ </protocolIEs>
+ </ErrorIndication>
+ </value>
+ </initiatingMessage>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <initiatingMessage>
+ <procedureCode>205</procedureCode>
+ <criticality><ignore/></criticality>
+ <value>
+ <RICindication>
+ <protocolIEs>
+ <RICindication-IEs>
+ <id>60030</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICrequestID>
+ <ricRequestorID>6</ricRequestorID>
+ <ricRequestSequenceNumber>12</ricRequestSequenceNumber>
+ </RICrequestID>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60003</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RANfunctionID>10</RANfunctionID>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60017</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICactionID>100</RICactionID>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60028</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICindicationSN>100</RICindicationSN>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60029</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICindicationType><report/></RICindicationType>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60026</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICindicationHeader>10 74 68 65 10 68 65 6C 40</RICindicationHeader>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60027</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICindicationMessage>
+ 00 1B 40 80 80 00 00 08 00 6F 00 02 00 0C 00 F8
+ 00 05 08 4D 86 D6 40 00 CB 00 20 31 32 33 34 35
+ 36 37 38 39 31 32 33 34 35 36 37 38 39 31 32 33
+ 34 35 36 37 38 39 31 32 33 34 35 00 CC 00 06 08
+ 07 D0 20 03 E8 00 CE 00 0C 0B 49 6E 66 6F 72 6D
+ 61 74 69 6F 6E 01 17 00 08 00 33 32 31 34 35 36
+ 30 01 13 00 01 22 00 CD 00 1B 00 00 D1 00 16 1A
+ 11 50 00 08 21 09 E0 41 41 42 42 43 43 44 44 45
+ 45 5A 5A 59 58
+ </RICindicationMessage>
+ </value>
+ </RICindication-IEs>
+ </protocolIEs>
+ </RICindication>
+ </value>
+ </initiatingMessage>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <initiatingMessage>
+ <procedureCode>205</procedureCode>
+ <criticality><ignore/></criticality>
+ <value>
+ <RICindication>
+ <protocolIEs>
+ <RICindication-IEs>
+ <id>60030</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICrequestID>
+ <ricRequestorID>6</ricRequestorID>
+ <ricRequestSequenceNumber>12</ricRequestSequenceNumber>
+ </RICrequestID>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60003</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RANfunctionID>10</RANfunctionID>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60017</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICactionID>100</RICactionID>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60028</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICindicationSN>100</RICindicationSN>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60029</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICindicationType><report/></RICindicationType>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60026</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICindicationHeader>10 74 68 65 10 68 65 6C 40</RICindicationHeader>
+ </value>
+ </RICindication-IEs>
+ <RICindication-IEs>
+ <id>60027</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICindicationMessage>
+ 00 1B 40 80 80 00 00 08 00 6F 00 02 00 0C 00 F8
+ 00 05 08 4D 86 D6 40 00 CB 00 20 31 32 33 34 35
+ 36 37 38 39 31 32 33 34 35 36 37 38 39 31 32 33
+ 34 35 36 37 38 39 31 32 33 34 35 00 CC 00 06 08
+ 07 D0 20 03 E8 00 CE 00 0C 0B 49 6E 66 6F 72 6D
+ 61 74 69 6F 6E 01 17 00 08 00 33 32 31 34 35 36
+ 30 01 13 00 01 23 00 CD 00 1B 00 00 D1 00 16 1A
+ 11 50 00 08 21 09 E0 41 41 42 42 43 43 44 44 45
+ 45 5A 5A 59 58
+ </RICindicationMessage>
+ </value>
+ </RICindication-IEs>
+ </protocolIEs>
+ </RICindication>
+ </value>
+ </initiatingMessage>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <initiatingMessage>
+ <procedureCode>201</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <RICsubscriptionRequest>
+ <protocolIEs>
+ <RICsubscriptionRequest-IEs>
+ <id>60030</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICrequestID>
+ <ricRequestorID>1</ricRequestorID>
+ <ricRequestSequenceNumber>200</ricRequestSequenceNumber>
+ </RICrequestID>
+ </value>
+ </RICsubscriptionRequest-IEs>
+ <RICsubscriptionRequest-IEs>
+ <id>60003</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RANfunctionID>33</RANfunctionID>
+ </value>
+ </RICsubscriptionRequest-IEs>
+ <RICsubscriptionRequest-IEs>
+ <id>60033</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICsubscription>
+ <ricEventTriggerDefinition>00 01 02 03 40 0b 16 02 00 23 40</ricEventTriggerDefinition>
+ <ricAction-ToBeSetup-List>
+ <ProtocolIE-Single-Container>
+ <id>60011</id>
+ <criticality><ignore/></criticality>
+ <value>
+ <RICaction-ToBeSetup-Item>
+ <ricActionID>255</ricActionID>
+ <ricActionType><report/></ricActionType>
+ </RICaction-ToBeSetup-Item>
+ </value>
+ </ProtocolIE-Single-Container>
+ </ricAction-ToBeSetup-List>
+ </RICsubscription>
+ </value>
+ </RICsubscriptionRequest-IEs>
+ </protocolIEs>
+ </RICsubscriptionRequest>
+ </value>
+ </initiatingMessage>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>\r
+ <initiatingMessage>\r
+ <procedureCode>201</procedureCode>\r
+ <criticality><reject/></criticality>\r
+ <value>\r
+ <RICsubscriptionRequest>\r
+ <protocolIEs>\r
+ <RICsubscriptionRequest-IEs>\r
+ <id>60030</id>\r
+ <criticality><reject/></criticality>\r
+ <value>\r
+ <RICrequestID>\r
+ <ricRequestorID>2</ricRequestorID>\r
+ <ricRequestSequenceNumber>1</ricRequestSequenceNumber>\r
+ </RICrequestID>\r
+ </value>\r
+ </RICsubscriptionRequest-IEs>\r
+ <RICsubscriptionRequest-IEs>\r
+ <id>60003</id>\r
+ <criticality><reject/></criticality>\r
+ <value>\r
+ <RANfunctionID>0</RANfunctionID>\r
+ </value>\r
+ </RICsubscriptionRequest-IEs>\r
+ <RICsubscriptionRequest-IEs>\r
+ <id>60033</id>\r
+ <criticality><reject/></criticality>\r
+ <value>\r
+ <RICsubscription>\r
+ <ricEventTriggerDefinition>10 54 65 73 10 54 65 73 40 1B 40</ricEventTriggerDefinition>\r
+ <ricAction-ToBeSetup-List>\r
+ <ProtocolIE-Single-Container>\r
+ <id>60011</id>\r
+ <criticality><ignore/></criticality>\r
+ <value>\r
+ <RICaction-ToBeSetup-Item>\r
+ <ricActionID>4</ricActionID>\r
+ <ricActionType><report/></ricActionType>\r
+ </RICaction-ToBeSetup-Item>\r
+ </value>\r
+ </ProtocolIE-Single-Container>\r
+ </ricAction-ToBeSetup-List>\r
+ </RICsubscription>\r
+ </value>\r
+ </RICsubscriptionRequest-IEs>\r
+ </protocolIEs>\r
+ </RICsubscriptionRequest>\r
+ </value>\r
+ </initiatingMessage>\r
+</E2AP-PDU>\r
--- /dev/null
+<E2AP-PDU>
+ <successfulOutcome>
+ <procedureCode>201</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <RICsubscriptionResponse>
+ <protocolIEs>
+ <RICsubscriptionResponse-IEs>
+ <id>60030</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICrequestID>
+ <ricRequestorID>2</ricRequestorID>
+ <ricRequestSequenceNumber>205</ricRequestSequenceNumber>
+ </RICrequestID>
+ </value>
+ </RICsubscriptionResponse-IEs>
+ <RICsubscriptionResponse-IEs>
+ <id>60003</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RANfunctionID>0</RANfunctionID>
+ </value>
+ </RICsubscriptionResponse-IEs>
+ <RICsubscriptionResponse-IEs>
+ <id>60012</id>
+ <criticality><reject/></criticality>
+ <value>
+ <RICaction-Admitted-List>
+ <ProtocolIE-Single-Container>
+ <id>60013</id>
+ <criticality><ignore/></criticality>
+ <value>
+ <RICaction-Admitted-Item>
+ <ricActionID>1</ricActionID>
+ </RICaction-Admitted-Item>
+ </value>
+ </ProtocolIE-Single-Container>
+ </RICaction-Admitted-List>
+ </value>
+ </RICsubscriptionResponse-IEs>
+ </protocolIEs>
+ </RICsubscriptionResponse>
+ </value>
+ </successfulOutcome>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <unsuccessfulOutcome>
+ <procedureCode>6</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <X2SetupFailure>
+ <protocolIEs>
+ <X2SetupFailure-IEs>
+ <id>5</id>
+ <criticality><ignore/></criticality>
+ <value>
+ <Cause>
+ <radioNetwork><ho-target-not-allowed/></radioNetwork>
+ </Cause>
+ </value>
+ </X2SetupFailure-IEs>
+ </protocolIEs>
+ </X2SetupFailure>
+ </value>
+ </unsuccessfulOutcome>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <initiatingMessage>
+ <procedureCode>6</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <X2SetupRequest>
+ <protocolIEs>
+ <X2SetupRequest-IEs>
+ <id>21</id>
+ <criticality><reject/></criticality>
+ <value>
+ <GlobalENB-ID>
+ <pLMN-Identity>13 30 23</pLMN-Identity>
+ <eNB-ID>
+ <macro-eNB-ID>
+ 11111111111111111111
+ </macro-eNB-ID>
+ </eNB-ID>
+ </GlobalENB-ID>
+ </value>
+ </X2SetupRequest-IEs>
+ <X2SetupRequest-IEs>
+ <id>20</id>
+ <criticality><reject/></criticality>
+ <value>
+ <ServedCells>
+ <SEQUENCE>
+ <servedCellInfo>
+ <pCI>503</pCI>
+ <cellId>
+ <pLMN-Identity>13 30 23</pLMN-Identity>
+ <eUTRANcellIdentifier>
+ 1111111111111111111100000000
+ </eUTRANcellIdentifier>
+ </cellId>
+ <tAC>00 00</tAC>
+ <broadcastPLMNs>
+ <PLMN-Identity>13 30 23</PLMN-Identity>
+ </broadcastPLMNs>
+ <eUTRA-Mode-Info>
+ <fDD>
+ <uL-EARFCN>0</uL-EARFCN>
+ <dL-EARFCN>0</dL-EARFCN>
+ <uL-Transmission-Bandwidth><bw6/></uL-Transmission-Bandwidth>
+ <dL-Transmission-Bandwidth><bw15/></dL-Transmission-Bandwidth>
+ </fDD>
+ </eUTRA-Mode-Info>
+ </servedCellInfo>
+ </SEQUENCE>
+ </ServedCells>
+ </value>
+ </X2SetupRequest-IEs>
+ </protocolIEs>
+ </X2SetupRequest>
+ </value>
+ </initiatingMessage>
+</E2AP-PDU>
--- /dev/null
+<E2AP-PDU>
+ <successfulOutcome>
+ <procedureCode>6</procedureCode>
+ <criticality><reject/></criticality>
+ <value>
+ <X2SetupResponse>
+ <protocolIEs>
+ <X2SetupResponse-IEs>
+ <id>21</id>
+ <criticality><reject/></criticality>
+ <value>
+ <GlobalENB-ID>
+ <pLMN-Identity>02 F8 39</pLMN-Identity>
+ <eNB-ID>
+ <macro-eNB-ID>
+ 00000000111000110000
+ </macro-eNB-ID>
+ </eNB-ID>
+ </GlobalENB-ID>
+ </value>
+ </X2SetupResponse-IEs>
+ <X2SetupResponse-IEs>
+ <id>20</id>
+ <criticality><reject/></criticality>
+ <value>
+ <ServedCells>
+ <SEQUENCE>
+ <servedCellInfo>
+ <pCI>0</pCI>
+ <cellId>
+ <pLMN-Identity>02 F8 39</pLMN-Identity>
+ <eUTRANcellIdentifier>
+ 0000000011100011000000000000
+ </eUTRANcellIdentifier>
+ </cellId>
+ <tAC>00 01</tAC>
+ <broadcastPLMNs>
+ <PLMN-Identity>02 F8 39</PLMN-Identity>
+ </broadcastPLMNs>
+ <eUTRA-Mode-Info>
+ <fDD>
+ <uL-EARFCN>21400</uL-EARFCN>
+ <dL-EARFCN>3400</dL-EARFCN>
+ <uL-Transmission-Bandwidth><bw50/></uL-Transmission-Bandwidth>
+ <dL-Transmission-Bandwidth><bw50/></dL-Transmission-Bandwidth>
+ </fDD>
+ </eUTRA-Mode-Info>
+ </servedCellInfo>
+ </SEQUENCE>
+ </ServedCells>
+ </value>
+ </X2SetupResponse-IEs>
+ <X2SetupResponse-IEs>
+ <id>24</id>
+ <criticality><reject/></criticality>
+ <value>
+ <GUGroupIDList>
+ <GU-Group-ID>
+ <pLMN-Identity>02 F8 39</pLMN-Identity>
+ <mME-Group-ID>00 00</mME-Group-ID>
+ </GU-Group-ID>
+ </GUGroupIDList>
+ </value>
+ </X2SetupResponse-IEs>
+ </protocolIEs>
+ </X2SetupResponse>
+ </value>
+ </successfulOutcome>
+</E2AP-PDU>
--- /dev/null
+/* Dependencies */
+typedef enum Criticality {
+ Criticality_reject = 0,
+ Criticality_ignore = 1,
+ Criticality_notify = 2
+} e_Criticality;
+
+
+-- Event Trigger Definition OCTET STRING contents
+E2SM-gNB-X2-eventTriggerDefinition ::= SEQUENCE{
+ interface-ID Interface-ID,
+ interfaceDirection InterfaceDirection,
+ interfaceMessageType InterfaceMessageType,
+ interfaceProtocolIE-List SEQUENCE (SIZE(1..maxofInterfaceProtocolIE)) OF InterfaceProtocolIE-Item OPTIONAL,
+ ...
+}
--- /dev/null
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+#include "e2ap_asn1c_codec.h"
+
+void e2ap_asn1c_print_pdu(const E2AP_PDU_t* pdu)
+{
+ xer_fprint(stdout, &asn_DEF_E2AP_PDU, (void *)pdu);
+ printf("\n");
+}
+
+void asn1c_xer_print(asn_TYPE_descriptor_t *typeDescriptor, void *data)
+{
+ xer_fprint(stdout, typeDescriptor, (void *)data);
+ printf("\n");
+}
+
+
+E2AP_PDU_t* e2ap_xml_to_pdu(char const* xml_message)
+{
+ // E2AP_PDU_t *pdu = new E2AP_PDU_t();
+ E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
+
+ assert(pdu != 0);
+
+ uint8_t buf[MAX_XML_BUFFER];
+ asn_dec_rval_t rval;
+ size_t size;
+ FILE *f;
+
+ char XML_path[300];
+ char *work_dir = getenv(WORKDIR_ENV);
+
+ strcpy(XML_path, work_dir);
+ strcat(XML_path, E2AP_XML_DIR);
+ strcat(XML_path, xml_message);
+
+ LOG_D("Generate E2AP PDU from XML file: %s\n", XML_path);
+ memset(buf, 0, sizeof(buf));
+
+ f = fopen(XML_path, "r");
+ if(!f){
+ LOG_E("Unable to open %s. Make sure you have set the Environment Variable E2SIM_DIR, see README", XML_path)
+ }
+
+ assert(f);
+
+ size = fread(buf, 1, sizeof(buf), f);
+ if(size == 0 || size == sizeof(buf))
+ {
+ LOG_E("Input too long: %s", XML_path);
+ exit(1);
+ }
+
+ fclose(f);
+
+ rval = xer_decode(0, &asn_DEF_E2AP_PDU, (void **)&pdu, buf, size);
+
+ assert(rval.code == RC_OK);
+
+ return pdu;
+}
+
+int e2ap_asn1c_encode_pdu(E2AP_PDU_t* pdu, unsigned char **buffer)
+{
+ int len;
+
+ *buffer = NULL;
+ assert(pdu != NULL);
+ assert(buffer != NULL);
+
+ len = aper_encode_to_new_buffer(&asn_DEF_E2AP_PDU, 0, pdu, (void **)buffer);
+
+ if (len < 0) {
+ LOG_E("[E2AP ASN] Unable to aper encode");
+ exit(1);
+ }
+ else {
+ LOG_D("[E2AP ASN] Encoded succesfully, encoded size = %d", len);
+ }
+
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_E2AP_PDU, pdu);
+
+ return len;
+}
+
+void e2ap_asn1c_decode_pdu(E2AP_PDU_t* pdu, unsigned char *buffer, int len)
+{
+ asn_dec_rval_t dec_ret;
+
+ assert(buffer != NULL);
+
+ dec_ret = aper_decode(NULL, &asn_DEF_E2AP_PDU, (void **)&pdu, buffer, len, 0, 0);
+
+ if (dec_ret.code != RC_OK) {
+ LOG_E("[E2AP ASN] Failed to decode pdu");
+ exit(1);
+ }
+ else {
+ LOG_D("[E2AP ASN] Decoded succesfully");
+ }
+}
+
+int e2ap_asn1c_get_procedureCode(E2AP_PDU_t* pdu)
+{
+ int procedureCode = -1;
+
+ switch(pdu->present)
+ {
+ case E2AP_PDU_PR_initiatingMessage:
+ procedureCode = pdu->choice.initiatingMessage->procedureCode;
+ break;
+
+ case E2AP_PDU_PR_successfulOutcome:
+ procedureCode = pdu->choice.successfulOutcome->procedureCode;
+ break;
+
+ case E2AP_PDU_PR_unsuccessfulOutcome:
+ procedureCode = pdu->choice.unsuccessfulOutcome->procedureCode;
+ break;
+
+ default:
+ LOG_E("[E2AP] Error: Unknown index %d in E2AP PDU", (int)pdu->present);
+ break;
+ }
+
+ return procedureCode;
+}
--- /dev/null
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+#ifndef E2AP_ASN1C_CODEC_H
+#define E2AP_ASN1C_CODEC_H
+
+#include "e2sim_defs.h"
+#include "E2AP-PDU.h"
+#include "InitiatingMessage.h"
+#include "SuccessfulOutcome.h"
+#include "UnsuccessfulOutcome.h"
+
+#define ASN1C_PDU_PRINT_BUFFER 4096
+#define MAX_XML_BUFFER 10000
+#define E2AP_XML_DIR "/src/E2AP/XML/"
+
+void e2ap_asn1c_print_pdu(const E2AP_PDU_t* pdu);
+
+void asn1c_xer_print(asn_TYPE_descriptor_t *typeDescriptor, void *data);
+
+E2AP_PDU_t* e2ap_xml_to_pdu(char const* xml_message);
+
+int e2ap_asn1c_encode_pdu(E2AP_PDU_t* pdu, unsigned char **buffer);
+
+void e2ap_asn1c_decode_pdu(E2AP_PDU_t* pdu, unsigned char *buffer, int len);
+
+int e2ap_asn1c_get_procedureCode(E2AP_PDU_t* pdu);
+
+#endif
# *\r
******************************************************************************/\r
#include "e2ap_message_handler.hpp"\r
+#include <unistd.h>\r
\r
void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data)\r
{\r
//decode the data into E2AP-PDU\r
- e2ap_pdu_t* pdu = new_e2ap_pdu();\r
+ E2AP_PDU_t* pdu = new E2AP_PDU_t();\r
\r
- e2ap_decode_pdu(pdu, data.buffer, data.len);\r
+ e2ap_asn1c_decode_pdu(pdu, data.buffer, data.len);\r
\r
- e2ap_print_pdu(pdu);\r
+ e2ap_asn1c_print_pdu(pdu);\r
\r
- int index = e2ap_get_index(pdu);\r
- int procedureCode = e2ap_get_procedureCode(pdu);\r
+ int procedureCode = e2ap_asn1c_get_procedureCode(pdu);\r
+ int index = (int)pdu->present;\r
\r
- LOG_I("[E2AP] Unpacked E2AP-PDU: index = %d, procedureCode = %d\n", index, procedureCode);\r
+ LOG_D("[E2AP] Unpacked E2AP-PDU: index = %d, procedureCode = %d\n",\r
+ index, procedureCode);\r
\r
switch(procedureCode)\r
{\r
- case 6: //X2Setup\r
+ case ProcedureCode_id_x2Setup: //X2Setup = 6\r
switch(index)\r
{\r
- case 1: //initiatingMessage\r
- LOG_D("[E2AP] Received X2-SETUP-REQUEST");\r
+ case E2AP_PDU_PR_initiatingMessage: //initiatingMessage\r
+ LOG_I("[E2AP] Received X2-SETUP-REQUEST");\r
e2ap_handle_X2SetupRequest(pdu, socket_fd);\r
break;\r
\r
- case 2: //successfulOutcome\r
- LOG_D("[E2AP] Received X2-SETUP-RESPONSE");\r
- //e2ap_handle_X2SetupResponse(pdu, socket_fd);\r
+ case E2AP_PDU_PR_successfulOutcome: //successfulOutcome\r
+ LOG_I("[E2AP] Received X2-SETUP-RESPONSE");\r
break;\r
\r
- case 3:\r
+ case E2AP_PDU_PR_unsuccessfulOutcome:\r
break;\r
\r
default:\r
}\r
break;\r
\r
- case 36: //ENDCX2Setup\r
+ case ProcedureCode_id_endcX2Setup: //ENDCX2Setup = 36\r
switch(index)\r
{\r
- case 1: //initiatingMessage\r
- LOG_D("[E2AP] Received ENDC-X2-SETUP-REQUEST");\r
+ case E2AP_PDU_PR_initiatingMessage: //initiatingMessage\r
+ LOG_I("[E2AP] Received ENDC-X2-SETUP-REQUEST");\r
e2ap_handle_ENDCX2SetupRequest(pdu, socket_fd);\r
break;\r
\r
- case 2: //successfulOutcome\r
- LOG_D("[E2AP] Received ENDC-X2-SETUP-RESPONSE");\r
- //x2ap_handle_X2SetupResponse(pdu, socket_fd);\r
+ case E2AP_PDU_PR_successfulOutcome: //successfulOutcome\r
+ LOG_I("[E2AP] Received ENDC-X2-SETUP-RESPONSE");\r
+ //no handler yet\r
break;\r
\r
- case 3:\r
- LOG_D("[E2AP] Received ENDC-X2-SETUP-FAILURE");\r
+ case E2AP_PDU_PR_unsuccessfulOutcome:\r
+ LOG_I("[E2AP] Received ENDC-X2-SETUP-FAILURE");\r
+ //no handler yet\r
break;\r
\r
default:\r
}\r
break;\r
\r
- case 201: //RIC SUBSCRIPTION\r
+ case ProcedureCode_id_reset: //reset = 7\r
switch(index)\r
{\r
- case 1: //initiatingMessage\r
- LOG_D("[E2AP] Received RIC-SUBSCRIPTION-REQUEST");\r
- e2ap_handle_RICSubscriptionRequest(pdu, socket_fd);\r
+ case E2AP_PDU_PR_initiatingMessage:\r
+ LOG_I("[E2AP] Received RESET-REQUEST");\r
break;\r
\r
- case 2:\r
- LOG_D("[E2AP] Received RIC-SUBSCRIPTION-RESPONSE");\r
+ case E2AP_PDU_PR_successfulOutcome:\r
break;\r
\r
- case 3:\r
- LOG_D("[E2AP] Received RIC-SUBSCRIPTION-FAILURE");\r
+ case E2AP_PDU_PR_unsuccessfulOutcome:\r
break;\r
\r
default:\r
- LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index);\r
- break;\r
+ LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index);\r
+ break;\r
+ }\r
+ break;\r
+\r
+ case ProcedureCode_id_ricSubscription: //RIC SUBSCRIPTION = 201\r
+ switch(index)\r
+ {\r
+ case E2AP_PDU_PR_initiatingMessage: //initiatingMessage\r
+ LOG_I("[E2AP] Received RIC-SUBSCRIPTION-REQUEST");\r
+ //e2ap_handle_RICSubscriptionRequest(pdu, socket_fd);\r
+ e2ap_handle_RICSubscriptionRequest_securityDemo(pdu, socket_fd);\r
+ break;\r
+\r
+ case E2AP_PDU_PR_successfulOutcome:\r
+ LOG_I("[E2AP] Received RIC-SUBSCRIPTION-RESPONSE");\r
+ break;\r
+\r
+ case E2AP_PDU_PR_unsuccessfulOutcome:\r
+ LOG_I("[E2AP] Received RIC-SUBSCRIPTION-FAILURE");\r
+ break;\r
+\r
+ default:\r
+ LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU", index);\r
+ break;\r
+ }\r
+ break;\r
+\r
+ case ProcedureCode_id_ricIndication: // 205\r
+ switch(index)\r
+ {\r
+ case E2AP_PDU_PR_initiatingMessage: //initiatingMessage\r
+ LOG_I("[E2AP] Received RIC-INDICATION");\r
+ // e2ap_handle_RICSubscriptionRequest(pdu, socket_fd);\r
+ break;\r
+\r
+ default:\r
+ LOG_E("[E2AP] Invalid message index=%d in E2AP-PDU %d", index,\r
+ (int)ProcedureCode_id_ricIndication);\r
+ break;\r
}\r
break;\r
\r
}\r
}\r
\r
-void e2ap_handle_X2SetupRequest(e2ap_pdu_t* pdu, int &socket_fd)\r
+/*\r
+Simply send back X2SetupResponse\r
+Todo: add more handling options (failure, duplicated request, etc.)\r
+*/\r
+void e2ap_handle_X2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd)\r
{\r
- /*\r
- Simply send back X2SetupResponse\r
- Todo: add more handling options (failure, duplicated request, etc.)\r
- */\r
+ E2AP_PDU_t* res_pdu = e2ap_xml_to_pdu("E2AP_X2SetupResponse.xml");\r
\r
- e2ap_pdu_t* res_pdu = new_e2ap_pdu();\r
- eNB_config cfg;\r
+ LOG_D("[E2AP] Created X2-SETUP-RESPONSE");\r
\r
- e2ap_create_X2SetupResponse(res_pdu, cfg);\r
- LOG_D("[E2AP] Created X2-SETUP-RESPONSE")\r
+ e2ap_asn1c_print_pdu(res_pdu);\r
\r
- e2ap_print_pdu(res_pdu);\r
+ uint8_t *buf;\r
+ sctp_buffer_t data;\r
\r
- //encode response pdu into buffer\r
- sctp_buffer_t res_data;\r
- e2ap_encode_pdu(res_pdu, res_data.buffer, sizeof(res_data.buffer), res_data.len);\r
+ data.len = e2ap_asn1c_encode_pdu(res_pdu, &buf);\r
+ memcpy(data.buffer, buf, data.len);\r
\r
//send response data over sctp\r
- if(sctp_send_data(socket_fd, res_data) > 0) {\r
+ if(sctp_send_data(socket_fd, data) > 0) {\r
LOG_I("[SCTP] Sent X2-SETUP-RESPONSE");\r
} else {\r
LOG_E("[SCTP] Unable to send X2-SETUP-RESPONSE to peer");\r
}\r
}\r
\r
-void e2ap_handle_X2SetupResponse(e2ap_pdu_t* pdu, int &socket_fd)\r
-{\r
- ;\r
-}\r
-\r
-void e2ap_handle_ENDCX2SetupRequest(e2ap_pdu_t* pdu, int &socket_fd)\r
+/*\r
+Simply send back ENDCX2SetupResponse\r
+Todo: add more handling options (failure, duplicated request, etc.)\r
+*/\r
+void e2ap_handle_ENDCX2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd)\r
{\r
- /*\r
- Simply send back ENDCX2SetupResponse\r
- Todo: add more handling options (failure, duplicated request, etc.)\r
- */\r
+ E2AP_PDU_t* res_pdu = e2ap_xml_to_pdu("E2AP_ENDCX2SetupResponse.xml");\r
\r
- e2ap_pdu_t* res_pdu = new_e2ap_pdu();\r
- gNB_config gnb_cfg;\r
-\r
- e2ap_create_ENDCX2SetupResponse(res_pdu, gnb_cfg);\r
LOG_D("[E2AP] Created ENDC-X2-SETUP-RESPONSE");\r
\r
- e2ap_print_pdu(res_pdu);\r
+ e2ap_asn1c_print_pdu(res_pdu);\r
\r
+ uint8_t *buf;\r
sctp_buffer_t data;\r
- e2ap_encode_pdu(res_pdu, data.buffer, sizeof(data.buffer), data.len);\r
+\r
+ data.len = e2ap_asn1c_encode_pdu(res_pdu, &buf);\r
+ memcpy(data.buffer, buf, data.len);\r
\r
//send response data over sctp\r
if(sctp_send_data(socket_fd, data) > 0) {\r
}\r
}\r
\r
-void e2ap_handle_RICSubscriptionRequest(e2ap_pdu_t* pdu, int &socket_fd)\r
+/*\r
+Simply send back hard-coded RICSubscriptionResponse\r
+Todo: add more handling options (failure, duplicated request, etc.)\r
+*/\r
+void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd)\r
{\r
- RICsubscription_params_t params;\r
- e2ap_parse_RICsubscriptionRequest(pdu, params);\r
+ E2AP_PDU_t* res_pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionResponse.xml");\r
\r
- /* Example handling logic\r
- - Accept if request id is even-numbered -> send back response\r
- in this case, accept every other actions\r
+ LOG_D("[E2AP] Created RIC-SUBSCRIPTION-RESPONSE");\r
\r
- - Reject if request id is odd-numbered -> send back failure\r
- */\r
+ e2ap_asn1c_print_pdu(res_pdu);\r
\r
- e2ap_pdu_t* res_pdu = new_e2ap_pdu();\r
- bool is_failure = false;\r
+ uint8_t *buf;\r
+ sctp_buffer_t data;\r
\r
- if(params.request_id % 2 == 0)\r
- {\r
- for(size_t i = 0; i < params.actionList.size(); i++)\r
- {\r
- if(i%2 == 0){\r
- params.actionList[i].isAdmitted = true;\r
- } else {\r
- params.actionList[i].isAdmitted = false;\r
- params.actionList[i].notAdmitted_cause = RICcause_radioNetwork;\r
- params.actionList[i].notAdmitted_subCause = 5;\r
- }\r
- }\r
+ data.len = e2ap_asn1c_encode_pdu(res_pdu, &buf);\r
+ memcpy(data.buffer, buf, data.len);\r
\r
- e2ap_create_RICsubscriptionResponse(res_pdu, params);\r
- LOG_I("[E2AP] Created RIC-SUBSCRIPTION-RESPONSE");\r
+ //send response data over sctp\r
+ if(sctp_send_data(socket_fd, data) > 0) {\r
+ LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-RESPONSE");\r
+ } else {\r
+ LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE to peer");\r
}\r
- else\r
- {\r
- is_failure = true;\r
+}\r
\r
- for(size_t i = 0; i < params.actionList.size(); i++)\r
- {\r
- params.actionList[i].isAdmitted = false;\r
- params.actionList[i].notAdmitted_cause = RICcause_radioNetwork;\r
- params.actionList[i].notAdmitted_subCause = 5;\r
- }\r
+void e2ap_handle_RICSubscriptionRequest_securityDemo(E2AP_PDU_t* pdu, int &socket_fd)\r
+{\r
+ E2AP_PDU_t* res_pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionResponse.xml");\r
\r
- e2ap_create_RICsubscriptionFailure(res_pdu, params);\r
- LOG_I("[E2AP] Created RIC-SUBSCRIPTION-FAILURE");\r
- }\r
+ LOG_D("[E2AP] Created RIC-SUBSCRIPTION-RESPONSE");\r
\r
- e2ap_print_pdu(res_pdu);\r
+ e2ap_asn1c_print_pdu(res_pdu);\r
\r
- //Encode into buffer\r
+ uint8_t *buf;\r
sctp_buffer_t data;\r
- e2ap_encode_pdu(res_pdu, data.buffer, sizeof(data.buffer), data.len);\r
+\r
+ data.len = e2ap_asn1c_encode_pdu(res_pdu, &buf);\r
+ memcpy(data.buffer, buf, data.len);\r
\r
//send response data over sctp\r
- if(sctp_send_data(socket_fd, data) > 0)\r
- {\r
- if(is_failure) {\r
- LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-FAILURE");\r
- }\r
- else {\r
- LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-RESPONSE");\r
- }\r
+ if(sctp_send_data(socket_fd, data) > 0) {\r
+ LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-RESPONSE");\r
+ } else {\r
+ LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE to peer");\r
}\r
- else\r
- {\r
- if(is_failure) {\r
- LOG_I("[SCTP] Unable to send RIC-SUBSCRIPTION-FAILURE");\r
+\r
+ //Start sending RIC Indication\r
+ int count1 = 0, count2 = 0;\r
+\r
+ E2AP_PDU_t* indication_type1 = e2ap_xml_to_pdu("E2AP_RICindication_type1.xml");\r
+ E2AP_PDU_t* indication_type2 = e2ap_xml_to_pdu("E2AP_RICindication_type2.xml");\r
+\r
+ uint8_t *buf1, *buf2;\r
+ sctp_buffer_t data1, data2;\r
+ data1.len = e2ap_asn1c_encode_pdu(indication_type1, &buf1);\r
+ memcpy(data1.buffer, buf1, data1.len);\r
+\r
+ data2.len = e2ap_asn1c_encode_pdu(indication_type2, &buf2);\r
+ memcpy(data2.buffer, buf2, data2.len);\r
+\r
+ while(1){\r
+ sleep(1);\r
+ //type1\r
+ if(sctp_send_data(socket_fd, data1) > 0) {\r
+ count1++;\r
+ LOG_I("[SCTP] Sent RIC-INDICATION SgNBAdditionRequest Type 1, count1 = %d", count1);\r
+ } else {\r
+ LOG_E("[SCTP] Unable to send RIC-INDICATION to peer");\r
}\r
- else {\r
- LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE");\r
+\r
+ sleep(1);\r
+ //type2\r
+ if(sctp_send_data(socket_fd, data2) > 0) {\r
+ count2++;\r
+ LOG_I("[SCTP] Sent RIC-INDICATION SgNBAdditionRequest Type 2, count2 = %d", count2);\r
+ } else {\r
+ LOG_E("[SCTP] Unable to send RIC-INDICATION to peer");\r
}\r
- }\r
+ } //end while\r
\r
}\r
+\r
+// void e2ap_handle_RICSubscriptionRequest_old(e2ap_pdu_t* pdu, int &socket_fd)\r
+// {\r
+// RICsubscription_params_t params;\r
+// e2ap_parse_RICsubscriptionRequest(pdu, params);\r
+//\r
+// /* Example handling logic\r
+// - Accept if request id is even-numbered -> send back response\r
+// in this case, accept every other actions\r
+//\r
+// - Reject if request id is odd-numbered -> send back failure\r
+// */\r
+//\r
+// e2ap_pdu_t* res_pdu = new_e2ap_pdu();\r
+// bool is_failure = false;\r
+//\r
+// if(params.request_id % 2 == 0)\r
+// {\r
+// for(size_t i = 0; i < params.actionList.size(); i++)\r
+// {\r
+// if(i%2 == 0){\r
+// params.actionList[i].isAdmitted = true;\r
+// } else {\r
+// params.actionList[i].isAdmitted = false;\r
+// params.actionList[i].notAdmitted_cause = RICcause_radioNetwork;\r
+// params.actionList[i].notAdmitted_subCause = 5;\r
+// }\r
+// }\r
+//\r
+// e2ap_create_RICsubscriptionResponse(res_pdu, params);\r
+// LOG_I("[E2AP] Created RIC-SUBSCRIPTION-RESPONSE");\r
+// }\r
+// else\r
+// {\r
+// is_failure = true;\r
+//\r
+// for(size_t i = 0; i < params.actionList.size(); i++)\r
+// {\r
+// params.actionList[i].isAdmitted = false;\r
+// params.actionList[i].notAdmitted_cause = RICcause_radioNetwork;\r
+// params.actionList[i].notAdmitted_subCause = 5;\r
+// }\r
+//\r
+// e2ap_create_RICsubscriptionFailure(res_pdu, params);\r
+// LOG_I("[E2AP] Created RIC-SUBSCRIPTION-FAILURE");\r
+// }\r
+//\r
+// e2ap_print_pdu(res_pdu);\r
+//\r
+// //Encode into buffer\r
+// sctp_buffer_t data;\r
+// e2ap_encode_pdu(res_pdu, data.buffer, sizeof(data.buffer), data.len);\r
+//\r
+// //send response data over sctp\r
+// if(sctp_send_data(socket_fd, data) > 0)\r
+// {\r
+// if(is_failure) {\r
+// LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-FAILURE");\r
+// }\r
+// else {\r
+// LOG_I("[SCTP] Sent RIC-SUBSCRIPTION-RESPONSE");\r
+// }\r
+// }\r
+// else\r
+// {\r
+// if(is_failure) {\r
+// LOG_I("[SCTP] Unable to send RIC-SUBSCRIPTION-FAILURE");\r
+// }\r
+// else {\r
+// LOG_E("[SCTP] Unable to send RIC-SUBSCRIPTION-RESPONSE");\r
+// }\r
+// }\r
+//\r
+// }\r
#ifndef E2AP_MESSAGE_HANDLER_HPP\r
#define E2AP_MESSAGE_HANDLER_HPP\r
\r
-#include "e2sim_defs.h"\r
#include "e2sim_sctp.hpp"\r
-#include "asn_e2ap.hpp"\r
-#include "e2ap_asn_codec.hpp"\r
+\r
+extern "C" {\r
+ #include "e2sim_defs.h"\r
+ #include "e2ap_asn1c_codec.h"\r
+}\r
\r
void e2ap_handle_sctp_data(int &socket_fd, sctp_buffer_t &data);\r
\r
-void e2ap_handle_X2SetupRequest(e2ap_pdu_t* pdu, int &socket_fd);\r
+void e2ap_handle_X2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd);\r
+\r
+void e2ap_handle_X2SetupResponse(E2AP_PDU_t* pdu, int &socket_fd);\r
\r
-void e2ap_handle_X2SetupResponse(e2ap_pdu_t* pdu, int &socket_fd);\r
+void e2ap_handle_ENDCX2SetupRequest(E2AP_PDU_t* pdu, int &socket_fd);\r
\r
-void e2ap_handle_ENDCX2SetupRequest(e2ap_pdu_t* pdu, int &socket_fd);\r
+void e2ap_handle_RICSubscriptionRequest(E2AP_PDU_t* pdu, int &socket_fd);\r
\r
-void e2ap_handle_RICSubscriptionRequest(e2ap_pdu_t* pdu, int &socket_fd);\r
+void e2ap_handle_RICSubscriptionRequest_securityDemo(E2AP_PDU_t* pdu, int &socket_fd);\r
\r
#endif\r
#include "e2sim_sctp.hpp"
// #include "e2sim_defs.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/sctp.h>
+#include <signal.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
int sctp_start_server(const char *server_ip_str, const int server_port)
{
if(server_port < 1 || server_port > 65535) {
{
server4_addr.sin_family = AF_INET;
server4_addr.sin_port = htons(server_port);
-
server_addr = (struct sockaddr*)&server4_addr;
- af = AF_INET;
addr_len = sizeof(server4_addr);
}
else if(inet_pton(AF_INET6, server_ip_str, &server6_addr.sin6_addr) == 1)
{
server6_addr.sin6_family = AF_INET6;
server6_addr.sin6_port = htons(server_port);
-
server_addr = (struct sockaddr*)&server6_addr;
- af = AF_INET6;
addr_len = sizeof(server6_addr);
}
else {
exit(1);
}
- if((client_fd = socket(af, SOCK_STREAM, IPPROTO_SCTP)) == -1)
+ if((client_fd = socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP)) == -1)
{
perror("socket");
exit(1);
}
- LOG_I("[SCTP] Connecting to server at %s:%d ...", server_ip_str, server_port);
+ //--------------------------------
+ //Bind before connect
+ auto optval = 1;
+ if( setsockopt(client_fd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof optval) != 0 ){
+ perror("setsockopt port");
+ exit(1);
+ }
+
+ if( setsockopt(client_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval) != 0 ){
+ perror("setsockopt addr");
+ exit(1);
+ }
+ struct sockaddr_in6 client6_addr {};
+ client6_addr.sin6_family = AF_INET6;
+ client6_addr.sin6_port = htons(RIC_SCTP_SRC_PORT);
+ client6_addr.sin6_addr = in6addr_any;
+
+ LOG_I("[SCTP] Binding client socket to source port %d", RIC_SCTP_SRC_PORT);
+ if(bind(client_fd, (struct sockaddr*)&client6_addr, sizeof(client6_addr)) == -1) {
+ perror("bind");
+ exit(1);
+ }
+ // end binding ---------------------
+
+ LOG_I("[SCTP] Connecting to server at %s:%d ...", server_ip_str, server_port);
if(connect(client_fd, server_addr, addr_len) == -1) {
perror("connect");
exit(1);
}
-
assert(client_fd != 0);
LOG_I("[SCTP] Connection established");
return client_fd;
-
}
int sctp_accept_connection(const char *server_ip_str, const int server_fd)
return sent_len;
}
+int sctp_send_data_X2AP(int &socket_fd, sctp_buffer_t &data)
+{
+ int sent_len = sctp_sendmsg(socket_fd, (void*)(&(data.buffer[0])), data.len,
+ NULL, 0, (uint32_t) X2AP_PPID, 0, 0, 0, 0);
+
+ if(sent_len == -1) {
+ perror("[SCTP] sctp_send_data");
+ exit(1);
+ }
+
+}
+
/*
Receive data from SCTP socket
Outcome of recv()
int sctp_send_data(int &socket_fd, sctp_buffer_t &data);
-int sctp_receive_data(int &socket_fd, sctp_buffer_t &data);
-
+int sctp_send_data_X2AP(int &socket_fd, sctp_buffer_t &data);
+int sctp_receive_data(int &socket_fd, sctp_buffer_t &data);
#endif
+++ /dev/null
-/*
- *
- * Copyright 2019 AT&T Intellectual Property
- * Copyright 2019 Nokia
- *
- * Licensed 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.
- *
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <assert.h>
-#include <unistd.h> //for close()
-#include <arpa/inet.h> //for inet_ntop()
-
-#include "e2sim_defs.h"
-#include "e2sim_sctp.h"
-#include "x2ap_message_handler.h"
-
-//OSN 2019
-#include "Pendulum_asn_codec.h"
-#include "adruino_serial.h"
-
-//rmr
-#include <errno.h>
-#include <sys/epoll.h>
-#include <rmr/rmr.h>
-#include "rmr_wrapper.h"
-
-static void pendulum_control_E2_agent(int client_fd)
-{
- printf("--------------------------------------\n");
- printf("E2 AGENT - START PENDULUM CONTROL\n");
- printf("--------------------------------------\n");
-
- uint8_t *buffer;
- uint32_t len;
- clock_t begin;
- double rtt; //ms
-
- uint8_t recv_buf[MAX_SCTP_BUFFER];
- int recv_len;
-
- double angle;
- double torque;
- long sqn;
- int count = 0;
-
- //serial
- int serial_fd;
- char serial_buffer[MAX_SERIAL_BUFFER];
- serial_fd = start_serial_inferface(DEFAULT_BAUDRATE, DEFAULT_SERIAL_PORT);
-
- int MSG_NUM = 10;
-
- // printf("Enter number of messages: ");
- // scanf("%d", &MSG_NUM);
- //
- // //fgets(serial_buffer, MAX_SERIAL_BUFFER, stdin);
- // serialport_write(serial_fd, serial_buffer);
-
- serialport_write(serial_fd, "hello arduino\n");
-
- // for(int i = 0; i < MSG_NUM; i++)
- while(1)
- {
-
- printf("----------------\n");
- count += 1;
- buffer = NULL;
- len = 0;
-
- //1.Read from serial
- serial_readline(serial_fd, serial_buffer, MAX_SERIAL_BUFFER);
- if(serial_buffer[0] == '\n')
- {
- //printf("RECEIVED EOL\n");
- continue;
- }
- //printf("[Adruino] %s", serial_buffer);
-
- begin = clock();
-
- //2. Encode pendulum angle to ASN1 message
- len = pendulum_create_asn_msg(&buffer, 0, 0, 0, serial_buffer);
-
- //3. Send ASN1 message to socket
- if(sctp_send_to_socket(client_fd, buffer, (size_t)len) > 0){
- printf("Sent ASN1 message to E2 Termination\n");
- }
-
- // 4. Receive response from E2 Termination
- memset(recv_buf, 0, sizeof(recv_buf));
- recv_len = 0;
- recv_len = recv(client_fd, &recv_buf, sizeof(recv_buf), 0);
- if(recv_len == -1)
- {
- perror("recv()");
- return;
- }
-
- char *recv_str;
- recv_str = pendulum_get_strval(recv_buf, recv_len);
- printf("Received response message #%d from xApp: %s\n", count, recv_str);
-
- // 5. TODO: Send response to serial
- serial_writeline(serial_fd, recv_str);
-
- //serialport_write(serial_fd, "hello\n");
-
- begin = clock() - begin;
- rtt = 1000*((double)begin)/CLOCKS_PER_SEC; // in ms
- printf("E2Agent-RIC-E2Agent RTT = %f ms\n", rtt);
- }
-
-
- close(client_fd);
-}
-
-int main(int argc, char *argv[])
-{
- printf("E2 Simulator. Version %s\n", VERSION);
- // test_rmr(); return 0;
- // test_adruino_serial(); return 0;
-
- char* server_ip = DEFAULT_SCTP_IP;
- int server_port = X2AP_SCTP_PORT;
-
- int server_fd;
- int client_fd;
- struct sockaddr client_addr;
- socklen_t client_addr_size;
-
- //read input
- if(argc == 3) //user provided IP and PORT
- {
- server_ip = argv[1];
- server_port = atoi(argv[2]);
- if(server_port < 1 || server_port > 65535) {
- printf("Invalid port number (%d). Valid values are between 1 and 65535.\n" , server_port);
- return -1;
- }
- }
- else if(argc == 2) //user provided only IP
- {
- server_ip = argv[1];
- }
- else if(argc == 1)
- {
- server_ip = DEFAULT_SCTP_IP;
- }
- else
- {
- printf("Unrecognized option.\n");
- printf("Usage: %s [SERVER IP ADDRESS] [SERVER PORT]\n", argv[0]);
- return -1;
- }
-
- server_fd = sctp_start_server(server_ip, server_port);
-
- printf("Waiting for connection...\n");
- client_fd = accept(server_fd, &client_addr, &client_addr_size);
- if(client_fd == -1){
- perror("accept()");
- close(client_fd);
- return -1;
- }
-
- //Todo: retrieve client ip addr
- struct sockaddr_in* client_ipv4 = (struct sockaddr_in*)&client_addr;
- char client_ip_addr[INET_ADDRSTRLEN];
- inet_ntop(AF_INET, &(client_ipv4->sin_addr), client_ip_addr, INET_ADDRSTRLEN);
-
- printf("New client connected from %s\n", client_ip_addr);
-
- // while(1) //put while loop if want to receive from multiple clients
- // {
- uint8_t recv_buf[MAX_SCTP_BUFFER];
- int recv_len = 0;
-
- memset(recv_buf, 0, sizeof(recv_buf));
-
- printf("------------------------\n");
- recv_len = recv(client_fd, &recv_buf, sizeof(recv_buf), 0);
- if(recv_len == -1)
- {
- perror("recv()");
- return -1;
- }
- else if(recv_len == 0)
- {
- printf("\nConnection from %s closed by remote peer\n", client_ip_addr);
- if(close(client_fd) == -1)
- {
- perror("close");
- }
- return -1;
- }
-
- //printf("Received a message of size %d\n", recv_len);
-
- //TODO: check PPID here before calling x2ap handler
-
- sctp_data_t response = {NULL, 0};
- x2ap_eNB_handle_message(recv_buf, recv_len, &response);
-
- //=======================================================================
- //reply to client
- assert(response.data != NULL);
- if(sctp_send_to_socket(client_fd, response.data, (size_t)response.len) > 0){
- printf("Sent X2 SETUP RESPONSE \n");
- } else{
- perror("send to socket");
- return -1;
- }
-
- printf("X2 Setup Completed \n");
-
- //=========================================================================
- // Pendulum interaction
- // Send pendulum state to E2 Termination and receive response
- pendulum_control_E2_agent(client_fd);
- // } //end while
-
- close(client_fd);
-
- return 0;
-}
--- /dev/null
+#/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+#******************************************************************************/
+
+cmake_minimum_required(VERSION 3.5.1)
+set(CMAKE_CXX_COMPILER "/usr/bin/g++")
+set(CMAKE_CXX_STANDARD 14)
+
+add_definitions("-D ASN_DISABLE_OER_SUPPORT")
+
+project(e2sim)
+
+set (HOME_DIR $ENV{HOME})
+#set (E2SIM_ROOT ../../../)
+
+include_directories("src")
+include_directories("src/SCTP/")
+include_directories("src/E2AP")
+include_directories("src/E2AP/E2SM")
+include_directories("ASN1c")
+
+find_library( SCTP_LIBRARY sctp ) #needed for sctp_sendmsg
+
+#----------------------------------------------
+file(GLOB E2AGENT_SOURCES
+ "src/e2agent.cpp"
+ "src/e2sim_defs.cpp"
+ "src/SCTP/*.cpp"
+ "src/E2AP/*.c"
+ "src/E2AP/*.cpp"
+ "ASN1c/*.c"
+ )
+add_executable(e2agent ${E2AGENT_SOURCES})
+target_link_libraries( e2agent ${SCTP_LIBRARY} )
+
+#----------------------------------------------
+file(GLOB RICSIM_SOURCES
+ "src/ric_sim.cpp"
+ "src/e2sim_defs.cpp"
+ "src/SCTP/*.cpp"
+ "src/E2AP/*.c"
+ "src/E2AP/*.cpp"
+ "ASN1c/*.c"
+ )
+add_executable(ric_sim ${RICSIM_SOURCES})
+target_link_libraries( ric_sim ${SCTP_LIBRARY} )
+
+
+#----------------------------------------------
+file(GLOB X2TERM_SOURCES
+ "src/x2term.cpp"
+ "src/e2sim_defs.cpp"
+ "src/SCTP/*.cpp"
+ "src/E2AP/*.c"
+ "src/E2AP/*.cpp"
+ "ASN1c/*.c"
+ )
+add_executable(x2term ${X2TERM_SOURCES})
+target_link_libraries( x2term ${SCTP_LIBRARY} )
+
+
+#-----------------------------------------------
+file(GLOB TEST
+ "src/test_asn1c.cpp"
+ "src/e2sim_defs.cpp"
+# "src/SCTP/*.cpp"
+ "ASN1c/*.c"
+ "src/E2AP/*.c"
+ "src/E2AP/E2SM/*.c"
+ )
+add_executable(test_asn1c ${TEST})
--- /dev/null
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <assert.h>
+#include <string>
+#include <iostream>
+
+extern "C" {
+ #include "e2sim_defs.h"
+ #include "E2AP-PDU.h"
+ #include "e2ap_asn1c_codec.h"
+ #include "e2sm.h"
+
+}
+
+using namespace std;
+
+int main(int argc, char* argv[]){
+
+ LOG_I("Test ASN1c");
+
+ test_eventTriggerDefinition();
+ return 0;
+
+ E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_X2SetupRequest.xml");
+ // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_X2SetupResponse.xml");
+ // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_X2SetupFailure.xml");
+
+ // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_ENDCX2SetupRequest.xml");
+ // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_ENDCX2SetupResponse.xml");
+ // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_ENDCX2SetupFailure.xml");
+
+ // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionRequest.xml");
+ // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionResponse.xml");
+ // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_ErrorIndication.xml");
+
+ e2ap_asn1c_print_pdu(pdu);
+
+ /* Test encoding */
+ uint8_t *buf;
+ sctp_buffer_t data;
+
+ data.len = e2ap_asn1c_encode_pdu(pdu, &buf);
+ memcpy(data.buffer, buf, data.len);
+
+ /* Test decoding */
+ E2AP_PDU_t* pdu1 = new E2AP_PDU_t();
+
+ e2ap_asn1c_decode_pdu(pdu1, data.buffer, data.len);
+
+ e2ap_asn1c_print_pdu(pdu1);
+
+ int index = (int)pdu1->present;
+
+ int pCode = e2ap_asn1c_get_procedureCode(pdu1);
+
+ LOG_I("Index = %d, procedureCode = %d", index, pCode);
+
+
+ return 0;
+}
--- /dev/null
+#/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+#******************************************************************************/
+
+cmake_minimum_required(VERSION 3.5.1)
+set(CMAKE_CXX_COMPILER "/usr/bin/g++")
+set(CMAKE_CXX_STANDARD 14)
+
+add_definitions("-D ASN_DISABLE_OER_SUPPORT")
+
+set (E2SIM_ROOT ../../)
+
+include_directories("${E2SIM_ROOT}/src")
+include_directories("${E2SIM_ROOT}/src/DEF")
+include_directories("${E2SIM_ROOT}/src/SCTP/")
+include_directories("${E2SIM_ROOT}/src/E2AP")
+include_directories("${E2SIM_ROOT}/src/E2AP/E2SM")
+include_directories("${E2SIM_ROOT}/ASN1c")
+
+find_library( SCTP_STD_LIB sctp ) #needed for sctp_sendmsg
+
+#----------------------------------------------
+file(GLOB WLG_SOURCES
+ "${E2SIM_ROOT}/test/WLG/ric_wlg.cpp"
+ "${E2SIM_ROOT}/src/DEF/*.cpp"
+ "${E2SIM_ROOT}/src/SCTP/*.cpp"
+ "${E2SIM_ROOT}/src/E2AP/*.c"
+ "${E2SIM_ROOT}/src/E2AP/*.cpp"
+ "${E2SIM_ROOT}/ASN1c/*.c"
+ )
+add_executable(ric_wlg ${WLG_SOURCES})
+target_link_libraries( ric_wlg ${SCTP_STD_LIB} )
+
+#----------------------------------------------
+file(GLOB RICPERF_SOURCES
+ "${E2SIM_ROOT}/test/WLG/ric_perf.cpp"
+ "${E2SIM_ROOT}/src/DEF/*.cpp"
+ "${E2SIM_ROOT}/src/SCTP/*.cpp"
+ "${E2SIM_ROOT}/src/E2AP/*.c"
+ "${E2SIM_ROOT}/src/E2AP/*.cpp"
+ "${E2SIM_ROOT}/ASN1c/*.c"
+ )
+add_executable(ric_perf ${RICPERF_SOURCES})
+target_link_libraries( ric_perf ${SCTP_STD_LIB} )
#******************************************************************************/
set -e
-sudo docker build -f docker/Dockerfile -t e2agent .
+
+mkdir -p build
+cd build
+rm -rf CMakeCache.txt
+cmake ..
+make -j`nproc`
--- /dev/null
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <assert.h>
+
+#include "e2sim_sctp.hpp"
+#include "e2ap_message_handler.hpp"
+
+extern "C" {
+ #include "e2sim_defs.h"
+ #include "E2AP-PDU.h"
+ #include "e2ap_asn1c_codec.h"
+
+ #include "ProtocolIE-Field.h"
+}
+
+using namespace std;
+
+void encode_and_send_sctp_data(E2AP_PDU_t* pdu, int client_fd)
+{
+ uint8_t *buf;
+ sctp_buffer_t data;
+
+ data.len = e2ap_asn1c_encode_pdu(pdu, &buf);
+ memcpy(data.buffer, buf, data.len);
+
+ sctp_send_data(client_fd, data);
+}
+
+void wait_for_sctp_data(int client_fd)
+{
+ sctp_buffer_t recv_buf;
+ if(sctp_receive_data(client_fd, recv_buf) > 0)
+ {
+ LOG_I("[SCTP] Received new data of size %d", recv_buf.len);
+ e2ap_handle_sctp_data(client_fd, recv_buf);
+ }
+}
+
+void set_seqnum(E2AP_PDU_t* pdu)
+{
+ InitiatingMessage_t *initiatingMessage = pdu->choice.initiatingMessage;
+ // xer_fprint(stdout, &asn_DEF_InitiatingMessage, (void *)initiatingMessage);
+
+ RICsubscriptionRequest_t *request = &initiatingMessage->value.choice.RICsubscriptionRequest;
+ xer_fprint(stdout, &asn_DEF_RICsubscriptionRequest, (void *)request);
+
+ LOG_I("num of IEs = %d", request->protocolIEs.list.count);
+
+ RICsubscriptionRequest_IEs_t *ie;
+
+ ie = request->protocolIEs.list.array[2];
+
+ xer_fprint(stdout, &asn_DEF_RICsubscription, (void *)ie);
+
+ // e2ap_asn1c_print_pdu(pdu);
+}
+
+int subresponse_get_sequenceNum(E2AP_PDU_t* pdu)
+{
+ SuccessfulOutcome_t *responseMsg = pdu->choice.successfulOutcome;
+
+ RICrequestID_t *requestid;
+
+ int num_IEs = responseMsg->value.choice.RICsubscriptionResponse.protocolIEs.list.count;
+
+ for(int edx = 0; edx < num_IEs; edx++)
+ {
+ RICsubscriptionResponse_IEs_t *memb_ptr =
+ responseMsg->value.choice.RICsubscriptionResponse.protocolIEs.list.array[edx];
+
+ switch(memb_ptr->id)
+ {
+ case (ProtocolIE_ID_id_RICrequestID):
+ requestid = &memb_ptr->value.choice.RICrequestID;
+ // xer_fprint(stdout, &asn_DEF_RICrequestID, (void *)requestid);
+ return requestid->ricRequestSequenceNumber;
+ break;
+ }
+ }
+}
+
+void subrequest_set_sequenceNum(E2AP_PDU_t* pdu, int seq)
+{
+ InitiatingMessage_t *initiatingMessage = pdu->choice.initiatingMessage;
+
+ RICrequestID_t *requestid;
+
+ int num_IEs = initiatingMessage->value.choice.RICsubscriptionRequest.protocolIEs.list.count;
+
+ for(int edx = 0; edx < num_IEs; edx++)
+ {
+ RICsubscriptionRequest_IEs_t *memb_ptr =
+ initiatingMessage->value.choice.RICsubscriptionRequest.protocolIEs.list.array[edx];
+
+ switch(memb_ptr->id)
+ {
+ case (ProtocolIE_ID_id_RICrequestID):
+ requestid = &memb_ptr->value.choice.RICrequestID;
+ requestid->ricRequestSequenceNumber = seq;
+ break;
+ }
+ }
+
+}
+
+void subscription_response_get_field(E2AP_PDU_t* pdu)
+{
+ SuccessfulOutcome_t *responseMsg = pdu->choice.successfulOutcome;
+
+ RICrequestID_t *requestid;
+ RANfunctionID_t * ranfunctionid;
+ RICsubscription_t * ricsubscription;
+
+ int requestID_val, sequenceNum;
+
+ int num_IEs = responseMsg->value.choice.RICsubscriptionResponse.protocolIEs.list.count;
+
+ LOG_I("num of IEs = %d", num_IEs);
+
+ for(int edx = 0; edx < num_IEs; edx++)
+ {
+ RICsubscriptionResponse_IEs_t *memb_ptr =
+ responseMsg->value.choice.RICsubscriptionResponse.protocolIEs.list.array[edx];
+
+ switch(memb_ptr->id)
+ {
+ case (ProtocolIE_ID_id_RICrequestID):
+ requestid = &memb_ptr->value.choice.RICrequestID;
+ xer_fprint(stdout, &asn_DEF_RICrequestID, (void *)requestid);
+ requestID_val = requestid->ricRequestorID;
+ sequenceNum = requestid->ricRequestSequenceNumber;
+ requestid->ricRequestSequenceNumber = 202;
+ break;
+
+ case (ProtocolIE_ID_id_RANfunctionID):
+ ranfunctionid = &memb_ptr->value.choice.RANfunctionID;
+ xer_fprint(stdout, &asn_DEF_RANfunctionID, (void *)ranfunctionid);
+ break;
+
+ // case (ProtocolIE_ID_id_RICsubscription):
+ // ricsubscription = &memb_ptr->value.choice.RICsubscription;
+ // xer_fprint(stdout, &asn_DEF_RICsubscription, (void *)ricsubscription);
+ // break;
+ }
+ }
+
+ LOG_I("Request ID = %d, seq = %d", requestID_val, sequenceNum);
+}
+
+void subscription_request_get_field(E2AP_PDU_t* pdu)
+{
+ InitiatingMessage_t *initiatingMessage = pdu->choice.initiatingMessage;
+
+ RICrequestID_t *requestid;
+ RANfunctionID_t * ranfunctionid;
+ RICsubscription_t * ricsubscription;
+
+ int num_IEs = initiatingMessage->value.choice.RICsubscriptionRequest.protocolIEs.list.count;
+
+ LOG_I("num of IEs = %d", num_IEs);
+
+ for(int edx = 0; edx < num_IEs; edx++)
+ {
+ RICsubscriptionRequest_IEs_t *memb_ptr =
+ initiatingMessage->value.choice.RICsubscriptionRequest.protocolIEs.list.array[edx];
+
+ switch(memb_ptr->id)
+ {
+ case (ProtocolIE_ID_id_RICrequestID):
+ requestid = &memb_ptr->value.choice.RICrequestID;
+ xer_fprint(stdout, &asn_DEF_RICrequestID, (void *)requestid);
+ break;
+
+ case (ProtocolIE_ID_id_RANfunctionID):
+ ranfunctionid = &memb_ptr->value.choice.RANfunctionID;
+ xer_fprint(stdout, &asn_DEF_RANfunctionID, (void *)ranfunctionid);
+ break;
+
+ case (ProtocolIE_ID_id_RICsubscription):
+ ricsubscription = &memb_ptr->value.choice.RICsubscription;
+ xer_fprint(stdout, &asn_DEF_RICsubscription, (void *)ricsubscription);
+ break;
+ }
+ }
+}
+
+int main(int argc, char* argv[]){
+ LOG_I("Start RIC Simulator - Performance Test");
+
+ options_t ops = read_input_options(argc, argv);
+ int client_fd = sctp_start_client(ops.server_ip, ops.server_port);
+
+ //1. Send ENDCX2Setup
+ E2AP_PDU_t* pdu_setup = e2ap_xml_to_pdu("E2AP_ENDCX2SetupRequest.xml");
+ // e2ap_asn1c_print_pdu(pdu_setup);
+ encode_and_send_sctp_data(pdu_setup, client_fd);
+ LOG_I("[SCTP] Sent ENDC X2 SETUP REQUEST");
+
+ //2. Receive ENDCX2SetupResponse
+ wait_for_sctp_data(client_fd);
+
+ //3. Send RICSubscriptionRequest
+ E2AP_PDU_t* pdu_sub = e2ap_xml_to_pdu("E2AP_RICsubscriptionRequest_Ashwin.xml");
+ e2ap_asn1c_print_pdu(pdu_sub);
+ encode_and_send_sctp_data(pdu_sub, client_fd);
+ LOG_I("[SCTP] Sent RIC SUBSCRIPTION REQUEST");
+
+
+ //4. Receive RIC SUBSCRIPT RESPONSE
+ int count = 0;
+
+ while(1)
+ {
+ usleep(1000); //sleep for one ms
+
+ sctp_buffer_t recv_buf;
+
+ int res_seq;
+
+ if(sctp_receive_data(client_fd, recv_buf) > 0)
+ {
+ LOG_I("[SCTP] Received new data of size %d", recv_buf.len);
+ // e2ap_handle_sctp_data(client_fd, recv_buf);
+
+ E2AP_PDU_t* res_pdu = new E2AP_PDU_t();
+
+ e2ap_asn1c_decode_pdu(res_pdu, recv_buf.buffer, recv_buf.len);
+
+ int procedureCode = e2ap_asn1c_get_procedureCode(res_pdu);
+ int index = (int)res_pdu->present;
+
+ if(index == E2AP_PDU_PR_successfulOutcome && \
+ procedureCode == ProcedureCode_id_ricSubscription)
+ {
+ res_seq =subresponse_get_sequenceNum(res_pdu);
+ count++;
+
+ LOG_I("Received RIC SUBSCRIPTION RESPONSE, seq = %d, totalCount = %d",\
+ res_seq, count);
+
+ //Put res_seq in new subscription request
+ E2AP_PDU_t* req_pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionRequest.xml");
+ subrequest_set_sequenceNum(req_pdu, res_seq);
+ // e2ap_asn1c_print_pdu(req_pdu);
+
+ encode_and_send_sctp_data(req_pdu, client_fd);
+ LOG_I("Send new SUBSCRIPT REQUEST, seq = %d", res_seq);
+ }
+
+ }
+ }
+
+
+ // E2AP_PDU_t* res_pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionResponse.xml");
+ //
+ // //Extract subscription response sequence number
+ // int res_seq = subresponse_get_sequenceNum(res_pdu);
+ // LOG_I("Subscription Response SeqNo = %d", res_seq);
+ //
+ // //Put responseSeq in new subscription request
+ // E2AP_PDU_t* req_pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionRequest.xml");
+ //
+ // subrequest_set_sequenceNum(req_pdu, res_seq);
+
+ // e2ap_asn1c_print_pdu(req_pdu);
+
+ return 0;
+}
-/*****************************************************************************\r
-# *\r
-# Copyright 2019 AT&T Intellectual Property *\r
-# Copyright 2019 Nokia *\r
-# *\r
-# Licensed under the Apache License, Version 2.0 (the "License"); *\r
-# you may not use this file except in compliance with the License. *\r
-# You may obtain a copy of the License at *\r
-# *\r
-# http://www.apache.org/licenses/LICENSE-2.0 *\r
-# *\r
-# Unless required by applicable law or agreed to in writing, software *\r
-# distributed under the License is distributed on an "AS IS" BASIS, *\r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *\r
-# See the License for the specific language governing permissions and *\r
-# limitations under the License. *\r
-# *\r
-******************************************************************************/\r
-\r
-#include "e2ap_asn_codec.hpp"\r
-\r
-void e2ap_encode_pdu(e2ap_pdu_t* pdu, unsigned char* buf, int buf_size, int &encoded_size)\r
-{\r
- char err_buf[ERROR_MESSAGE_BUFFER];\r
-\r
- encoded_size = e2ap_asn_per_encode(pdu, buf, buf_size, err_buf, sizeof(err_buf));\r
-\r
- if(encoded_size != -1)\r
- {\r
- LOG_D("[E2AP] ASN Encode successful, encoded_size = %d", encoded_size);\r
- }\r
- else\r
- {\r
- LOG_E("[E2AP] Encode error: %s", err_buf);\r
- exit(1);\r
- }\r
-\r
-}\r
-\r
-void e2ap_decode_pdu(e2ap_pdu_t* pdu, unsigned char* buf, int &encoded_size)\r
-{\r
- char err_buf[ERROR_MESSAGE_BUFFER];\r
-\r
- int rc = e2ap_asn_per_decode(pdu, buf, encoded_size, err_buf, sizeof(err_buf));\r
- if(rc == -1) {\r
- LOG_E("[E2AP] Decode error: %s", err_buf);\r
- } else {\r
- LOG_D("[E2AP] ASN decode successful");\r
- }\r
-}\r
-\r
-void e2ap_print_pdu(e2ap_pdu_t* pdu)\r
-{\r
- char pdu_str[PDU_PRINT_BUFFER];\r
-\r
- e2ap_asn_print(pdu, pdu_str, sizeof(pdu_str));\r
-\r
- LOG_D("[E2AP] %s", pdu_str);\r
-}\r
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <assert.h>
+
+#include "e2sim_sctp.hpp"
+#include "e2ap_message_handler.hpp"
+
+extern "C" {
+ #include "e2sim_defs.h"
+ #include "E2AP-PDU.h"
+ #include "e2ap_asn1c_codec.h"
+
+ #include "ProtocolIE-Field.h"
+}
+
+using namespace std;
+
+
+int main(int argc, char* argv[]){
+ LOG_I("Start RIC WLG");
+
+ options_t ops = read_input_options(argc, argv);
+
+ int server_fd = sctp_start_server(ops.server_ip, ops.server_port);
+ int client_fd = sctp_accept_connection(ops.server_ip, server_fd);
+
+ sctp_buffer_t recv_buf;
+
+ LOG_I("[SCTP] Waiting for SCTP data");
+
+ while(1) //constantly looking for data on SCTP interface
+ {
+ if(sctp_receive_data(client_fd, recv_buf) <= 0)
+ break;
+
+ LOG_I("[SCTP] Received new data of size %d", recv_buf.len);
+
+ e2ap_handle_sctp_data(client_fd, recv_buf);
+ }
+
+ return 0;
+}
--- /dev/null
+#/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+#******************************************************************************/
+
+cmake_minimum_required(VERSION 3.5.1)
+set(CMAKE_CXX_COMPILER "/usr/bin/g++")
+set(CMAKE_CXX_STANDARD 14)
+
+add_definitions("-D ASN_DISABLE_OER_SUPPORT")
+
+project(x2term)
+
+set (E2SIM_ROOT ../../)
+
+include_directories("${E2SIM_ROOT}/src")
+include_directories("${E2SIM_ROOT}/src/DEF")
+include_directories("${E2SIM_ROOT}/src/SCTP/")
+include_directories("${E2SIM_ROOT}/src/E2AP")
+include_directories("${E2SIM_ROOT}/src/E2AP/E2SM")
+include_directories("${E2SIM_ROOT}/ASN1c")
+
+find_library( SCTP_STD_LIB sctp ) #needed for sctp_sendmsg
+
+#----------------------------------------------
+file(GLOB X2TERM_SOURCES
+ "${E2SIM_ROOT}/test/X2/x2term.cpp"
+ "${E2SIM_ROOT}/src/DEF/*.cpp"
+ "${E2SIM_ROOT}/src/SCTP/*.cpp"
+ "${E2SIM_ROOT}/src/E2AP/*.c"
+ "${E2SIM_ROOT}/src/E2AP/*.cpp"
+ "${E2SIM_ROOT}/ASN1c/*.c"
+ )
+add_executable(x2term ${X2TERM_SOURCES})
+target_link_libraries( x2term ${SCTP_STD_LIB} )
--- /dev/null
+/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+******************************************************************************/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <assert.h>
+
+#include "e2sim_sctp.hpp"
+#include "e2ap_message_handler.hpp"
+
+extern "C" {
+ #include "e2sim_defs.h"
+ #include "E2AP-PDU.h"
+ #include "e2ap_asn1c_codec.h"
+}
+
+using namespace std;
+
+void encode_and_send_sctp_data(E2AP_PDU_t* pdu, int client_fd)
+{
+ uint8_t *buf;
+ sctp_buffer_t data;
+
+ data.len = e2ap_asn1c_encode_pdu(pdu, &buf);
+ memcpy(data.buffer, buf, data.len);
+
+ // sctp_send_data(client_fd, data);
+ sctp_send_data_X2AP(client_fd, data);
+}
+
+void wait_for_sctp_data(int client_fd)
+{
+ sctp_buffer_t recv_buf;
+ if(sctp_receive_data(client_fd, recv_buf) > 0)
+ {
+ LOG_I("[SCTP] Received new data of size %d", recv_buf.len);
+ e2ap_handle_sctp_data(client_fd, recv_buf);
+ }
+}
+
+
+int main(int argc, char* argv[]){
+ LOG_I("Start RIC Simulator");
+
+ options_t ops = read_input_options(argc, argv);
+ int client_fd = sctp_start_client(ops.server_ip, ops.server_port);
+
+ //Send X2 Setup Request
+ E2AP_PDU_t* pdu_setup = e2ap_xml_to_pdu("E2AP_X2SetupRequest.xml");
+ e2ap_asn1c_print_pdu(pdu_setup);
+
+ encode_and_send_sctp_data(pdu_setup, client_fd);
+
+ //wait to receive X2SetupResponse
+ wait_for_sctp_data(client_fd);
+}
int client_fd = sctp_start_client(ops.server_ip, ops.server_port);
- // test_X2Setup(client_fd);
- test_ENDCX2Setup(client_fd);
+ test_X2Setup(client_fd);
+ // test_ENDCX2Setup(client_fd);
return 0;
--- /dev/null
+#!/bin/bash
+#/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+#******************************************************************************/
+
+E2AP_asn="e2ap-v031.asn"
+E2SM_asn="e2sm-gNB-X2-release-1-v041.asn"
+X2AP_asn="x2ap-no-desc-15-04.asn"
+
+GEN_DIR=../../src/ASN1c/
+
+rm -f $GEN_DIR/*.c $GEN_DIR/*.h
+
+asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example \
+ -fno-include-deps -D $GEN_DIR $E2AP_asn $X2AP_asn \
+ |& egrep -v "^Copied|^Compiled" | sort -u
+
+asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example \
+ -fno-include-deps -D $GEN_DIR $E2SM_asn $X2AP_asn \
+ |& egrep -v "^Copied|^Compiled" | sort -u
+
+echo "ASN1 C codes generated at $GEN_DIR"
+
+# asn1c -fcompound-names -fno-include-deps -findirect-choice -gen-PER -no-gen-OER /tmp/e2ap-v031.asn /tmp/x2ap-no-desc-15-04.asn
-#
-#
-# Copyright 2019 AT&T Intellectual Property
-# Copyright 2019 Nokia
-#
-# Licensed 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.
-#
+#/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+#******************************************************************************/
#######################################
# Helper Func
-#*****************************************************************************
+#!/bin/bash
+#/*****************************************************************************
# *
# Copyright 2019 AT&T Intellectual Property *
# Copyright 2019 Nokia *
# See the License for the specific language governing permissions and *
# limitations under the License. *
# *
-#*****************************************************************************
+#******************************************************************************/
-# Run a default build and run the e2sim executable
-
-set -e
-
-clear
-
-./build_e2sim --clean
-
-./build_e2sim
-
-echo "===================== Running E2 Agent Simulator ========================"
-
-./build/e2agent
+echo "Will install asn1c"
+sudo rm -rf asn1c
+git clone https://gerrit.o-ran-sc.org/r/com/asn1c.git
+cd asn1c/
+autoreconf -iv
+./configure
+cd examples
+chmod u+x crfc2asn1.pl
+cd ..
+make
+sudo make install
--- /dev/null
+#!/bin/bash
+#/*****************************************************************************
+# *
+# Copyright 2019 AT&T Intellectual Property *
+# Copyright 2019 Nokia *
+# *
+# Licensed 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. *
+# *
+#******************************************************************************/
+
+sudo apt-get update \
+ && sudo apt-get install -y \
+ build-essential \
+ git \
+ cmake \
+ libsctp-dev \
+ lksctp-tools \
+ autoconf \
+ automake \
+ libtool \
+ bison \
+ flex \
+ libboost-all-dev \
+ iputils-ping \
+ net-tools \
+ nano \
+ vim \
+ && sudo apt-get clean