Commit 70ad5d58 authored by Nikos Makris's avatar Nikos Makris

Functionality for a simple protocol agent exchanging echo_request/reply messages

parent bc5e3031
......@@ -831,9 +831,12 @@ include_directories("${OPENAIR_DIR}/targets/COMMON")
include_directories("${OPENAIR_DIR}/targets/ARCH/COMMON")
include_directories("${OPENAIR_DIR}/targets/ARCH/EXMIMO/USERSPACE/LIB/")
include_directories("${OPENAIR_DIR}/targets/ARCH/EXMIMO/DEFS")
include_directories("${OPENAIR2_DIR}/UTIL/ASYNC_IF")
include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds6.1.1/liblfds611/inc")
include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/inc")
include_directories("${OPENAIR2_DIR}/LAYER2/PROTO_AGENT")
include_directories("${OPENAIR2_DIR}/ENB_APP")
include_directories("${OPENAIR2_DIR}/UTIL/OSA")
include_directories("${OPENAIR2_DIR}/UTIL/LFDS/liblfds6.1.1/liblfds611/inc")
include_directories("${OPENAIR2_DIR}/UTIL/MEM")
include_directories("${OPENAIR2_DIR}/UTIL/LISTS")
include_directories("${OPENAIR2_DIR}/UTIL/FIFO")
......@@ -854,7 +857,7 @@ include_directories("${OPENAIR_DIR}")
################
if (PDCP_SPLIT)
# set the version of protobuf messages, V3 not supported yet
add_list1_option(FSPT_VERSION V2 "PRPT MSG protobuf grammar version" V2 V3)
add_list1_option(FSPT_VERSION V2 "FSPT MSG protobuf grammar version" V2 V3)
if (${FSPT_VERSION} STREQUAL "V2")
set (FSPTDIR V2)
......@@ -871,7 +874,7 @@ if (PDCP_SPLIT)
set(FSPT_C_DIR ${protobuf_generated_dir}/${FSPTDIR})
message("calling protoc_call=${protoc_call} FSPT_C_DIR=${FSPT_C_DIR} FSPT_MSG_FILES=${FSPT_MSG_FILES}")
execute_process(COMMAND ${protoc_call} ${FSPT_C_DIR} ${FSPT_MSG_DIR} ${FSPT_MSG_FILES})
file(GLOB PRPT_source ${FSPT_C_DIR}/*.c)
file(GLOB FSPT_source ${FSPT_C_DIR}/*.c)
set(FSPT_OAI_generated
${FSPT_C_DIR}/header.pb-c.c
${FSPT_C_DIR}/flexsplit.pb-c.c
......@@ -897,6 +900,18 @@ if (PDCP_SPLIT)
set(ASYNC_IF_LIB ASYNC_IF)
include_directories(${OPENAIR2_DIR}/UTIL/ASYNC_IF)
add_library(PROTO_AGENT
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_handler.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_common.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_net_comm.c
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/proto_agent_async.c
)
set(PROTO_AGENT_LIB PROTO_AGENT)
#include_directories(${OPENAIR2_DIR}/LAYER2/PROTO_AGENT)
set(PROTOBUF_LIB "protobuf-c")
#set(PROTOBUF_LIB "protobuf") #for Cpp
......@@ -1525,6 +1540,24 @@ add_library(LFDS
${lfds}/lfds611_abstraction/lfds611_abstraction_malloc.c
)
set(lfds7 ${OPENAIR2_DIR}/UTIL/LFDS/liblfds7.0.0/liblfds700/src/)
file(GLOB lfds7_queue ${lfds7}/lfds700_queue/*.c)
file(GLOB lfds7_ring ${lfds7}/lfds700_ringbuffer/*.c)
file(GLOB lfds7_qbss ${lfds7}/lfds700_queue_bounded_singleconsumer_singleproducer/*.c)
file(GLOB lfds7_stack ${lfds7}/lfds700_stack/*.c)
file(GLOB lfds7_freelist ${lfds7}/lfds700_freelist/*.c)
file(GLOB lfds7_btree ${lfds7}/lfds700_btree_addonly_unbalanced/*.c)
file(GLOB lfds7_hash ${lfds7}/lfds700_hash_addonly/*.c)
file(GLOB lfds7_ordered_list ${lfds7}/lfds700_list_addonly_ordered_singlylinked/*.c)
file(GLOB lfds7_unordered_list ${lfds7}/lfds700_list_addonly_singlylinked_unordered/*.c)
file(GLOB lfds7_misc ${lfds7}/lfds700_misc/*.c)
include_directories(${lfds7})
add_library(LFDS7
${lfds7_queue} ${lfds7_ring} ${lfds7_qbss} ${lfds7_stack} ${lfds7_freelist} ${lfds7_btree} ${lfds7_hash} ${lfds7_ordered_list} ${lfds7_unordered_list} ${lfds7_misc}
)
# Simulation library
##########################
add_library(SIMU
......@@ -1688,11 +1721,11 @@ add_executable(lte-softmodem
target_link_libraries (lte-softmodem -ldl
-Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_LIB}
RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_LIB} ${FSPT_MSG_LIB} ${ASYNC_IF_LIB} ${PROTO_AGENT_LIB} LFDS7 protobuf-c
-Wl,--end-group )
target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES})
target_link_libraries (lte-softmodem pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${option_HW_lib} ${option_TP_lib} ${XFORMS_LIBRARIES} )
target_link_libraries (lte-softmodem pthread m ${CONFIG_LIBRARIES} rt ${PROTOBUF_LIB} crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${option_HW_lib} ${option_TP_lib} ${XFORMS_LIBRARIES} )
target_link_libraries (lte-softmodem ${LIBBOOST_LIBRARIES} -lboost_system) #Added manually as it is not found for some reason for USRP
target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-softmodem ${T_LIB})
......@@ -1724,11 +1757,11 @@ add_executable(lte-softmodem-nos1
)
target_link_libraries (lte-softmodem-nos1
-Wl,--start-group
RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${MIH_LIB}
RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCHED_LIB PHY LFDS ${RAL_LIB} ${ITTI_LIB} ${MIH_LIB}
-Wl,--end-group )
target_link_libraries (lte-softmodem-nos1 ${LIBXML2_LIBRARIES})
target_link_libraries (lte-softmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${option_HW_lib} ${option_TP_lib} ${XFORMS_LIBRARIES} )
target_link_libraries (lte-softmodem-nos1 pthread m ${CONFIG_LIBRARIES} rt ${PROTOBUF_LIB} crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${option_HW_lib} ${option_TP_lib} ${XFORMS_LIBRARIES} )
target_link_libraries (lte-softmodem-nos1 ${LIBBOOST_LIBRARIES} -lboost_system) #Added manually as it is not found for some reason for USRP
target_link_libraries (lte-softmodem-nos1 ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-softmodem-nos1 ${T_LIB})
......@@ -1827,11 +1860,11 @@ add_executable(oaisim
target_include_directories(oaisim PUBLIC ${OPENAIR_TARGETS}/SIMU/USER)
target_link_libraries (oaisim
-Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} LIB_NAS_UE SIMU SIMU_ETH SECU_OSA ${ITTI_LIB} ${MIH_LIB}
RRC_LIB S1AP_LIB S1AP_ENB ${FSPT_MSG_LIB} ${ASYNC_IF_LIB} ${PROTO_AGENT_LIB} LFDS7 X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} LIB_NAS_UE SIMU SIMU_ETH SECU_OSA ${ITTI_LIB} ${MIH_LIB}
-Wl,--end-group )
target_link_libraries (oaisim ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES})
target_link_libraries (oaisim pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${option_HW_lib} ${option_TP_lib}
target_link_libraries (oaisim pthread m ${PROTOBUF_LIB} ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} sctp ${option_HW_lib} ${option_TP_lib}
${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${OPENPGM_LIBRARIES})
#Force link with forms, regardless XFORMS option
target_link_libraries (oaisim forms)
......@@ -1866,11 +1899,11 @@ add_executable(oaisim_nos1
target_include_directories(oaisim_nos1 PUBLIC ${OPENAIR_TARGETS}/SIMU/USER)
target_link_libraries (oaisim_nos1
-Wl,--start-group
RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} SIMU SIMU_ETH SECU_OSA ${ITTI_LIB} ${MIH_LIB}
RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_LIB PHY LFDS ${MSC_LIB} L2 ${RAL_LIB} SIMU SIMU_ETH SECU_OSA ${ITTI_LIB} ${MIH_LIB} ${FSPT_MSG_LIB} ${ASYNC_IF_LIB} ${PROTO_AGENT_LIB} LFDS7 protobuf-c
-Wl,--end-group )
target_link_libraries (oaisim_nos1 ${LIBXML2_LIBRARIES} ${LAPACK_LIBRARIES})
target_link_libraries (oaisim_nos1 pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${option_HW_lib} ${option_TP_lib}
target_link_libraries (oaisim_nos1 pthread m ${PROTOBUF_LIB} ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${option_HW_lib} ${option_TP_lib}
${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${OPENPGM_LIBRARIES})
#Force link with forms, regardless XFORMS option
target_link_libraries (oaisim_nos1 forms)
......
......@@ -80,3 +80,6 @@ TASK_DEF(TASK_RAL_UE, TASK_PRIORITY_MED, 200)
//MESSAGE GENERATOR TASK
TASK_DEF(TASK_MSC, TASK_PRIORITY_MED, 200)
// Task for PROTO_AGENT
TASK_DEF(TASK_PROTO_AGENT, TASK_PRIORITY_MED, 200)
......@@ -57,11 +57,16 @@
# include "gtpv1u_eNB_task.h"
# endif
extern unsigned char NB_eNB_INST;
#endif
#if defined(ENABLE_ITTI)
#include "LAYER2/PROTO_AGENT/proto_agent.h"
//#include "../PROTO_AGENT/proto_agent.h"
/*------------------------------------------------------------------------------*/
# if defined(ENABLE_USE_MME)
# define ENB_REGISTER_RETRY_DELAY 10
......@@ -311,6 +316,8 @@ void *eNB_app_task(void *args_p)
for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) {
configure_phy(enb_id, enb_properties_p);
configure_rrc(enb_id, enb_properties_p);
//proto_server_start(enb_id, enb_properties_p);
//proto_agent_start(enb_id, enb_properties_p);
}
# if defined(ENABLE_USE_MME)
......
......@@ -170,6 +170,14 @@
#define ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U "ENB_IPV4_ADDRESS_FOR_S1U"
#define ENB_CONFIG_STRING_ENB_PORT_FOR_S1U "ENB_PORT_FOR_S1U"
#define ENB_CONFIG_STRING_FLEXSPLIT_CONFIG "FLEXSPLIT"
#define ENB_CONFIG_STRING_PROTO_AGENT_INTERFACE_NAME "PROTO_AGENT_INTERFACE_NAME"
#define ENB_CONFIG_STRING_PROTO_AGENT_IPV4_ADDRESS "PROTO_AGENT_IPV4_ADDRESS"
#define ENB_CONFIG_STRING_PROTO_AGENT_PORT "PROTO_AGENT_PORT"
#define ENB_CONFIG_STRING_PROTO_AGENT_CACHE "PROTO_AGENT_CACHE"
#define ENB_CONFIG_STRING_RRH_GW_CONFIG "rrh_gw_config"
#define ENB_CONFIG_STRING_RRH_GW_LOCAL_IF_NAME "local_if_name"
#define ENB_CONFIG_STRING_RRH_GW_LOCAL_ADDRESS "local_address"
......@@ -315,6 +323,7 @@ void enb_config_display(void)
}
}
for (j=0; j< enb_properties.properties[i]->nb_cc; j++) {
printf( "\teutra band for CC %d: \t%"PRId16":\n",j,enb_properties.properties[i]->eutra_band[j]);
printf( "\tdownlink freq for CC %d: \t%"PRIu64":\n",j,enb_properties.properties[i]->downlink_frequency[j]);
......@@ -625,6 +634,12 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
char *address = NULL;
char *cidr = NULL;
char *astring = NULL;
char* proto_agent_interface_name = NULL;
char* proto_agent_ipv4_address = NULL;
libconfig_int proto_agent_port = 0;
char* proto_agent_cache = NULL;
libconfig_int otg_ue_id = 0;
char* otg_app_type = NULL;
char* otg_bg_traffic = NULL;
......@@ -2327,7 +2342,6 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
if (address) {
IPV4_STR_ADDR_TO_INT_NWBO ( address, enb_properties.properties[enb_properties_index]->enb_ipv4_address_for_S1U, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" );
}
enb_properties.properties[enb_properties_index]->enb_port_for_S1U = enb_port_for_S1U;
enb_properties.properties[enb_properties_index]->enb_interface_name_for_S1_MME = strdup(enb_interface_name_for_S1_MME);
......@@ -2340,6 +2354,34 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
}
}
// PROTO_AGENT configuration
subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_FLEXSPLIT_CONFIG);
if (subsetting != NULL) {
if ( (
config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_PROTO_AGENT_INTERFACE_NAME,
(const char **)&proto_agent_interface_name)
&& config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_PROTO_AGENT_IPV4_ADDRESS,
(const char **)&proto_agent_ipv4_address)
&& config_setting_lookup_int(subsetting, ENB_CONFIG_STRING_PROTO_AGENT_PORT,
&proto_agent_port)
&& config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_PROTO_AGENT_CACHE,
(const char **)&proto_agent_cache)
)
) {
enb_properties.properties[enb_properties_index]->proto_agent_interface_name = strdup(proto_agent_interface_name);
cidr = proto_agent_ipv4_address;
address = strtok(cidr, "/");
enb_properties.properties[enb_properties_index]->proto_agent_ipv4_address = strdup(address);
enb_properties.properties[enb_properties_index]->proto_agent_port = proto_agent_port;
enb_properties.properties[enb_properties_index]->proto_agent_cache = strdup(proto_agent_cache);
}
}
// OTG _CONFIG
setting_otg = config_setting_get_member (setting_enb, ENB_CONF_STRING_OTG_CONFIG);
......
......@@ -222,6 +222,13 @@ typedef struct Enb_properties_s {
in_addr_t enb_ipv4_address_for_S1_MME;
char *proto_agent_interface_name;
in_addr_t proto_agent_ipv4_address;
tcp_udp_port_t proto_agent_port;
char *proto_agent_cache;
/* Nb of RRH to connect to */
uint8_t nb_rrh_gw;
char *rrh_gw_if_name;
......
......@@ -56,6 +56,10 @@
#include "UTIL/LOG/vcd_signal_dumper.h"
#include "msc.h"
#include "ENB_APP/enb_config.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
#if defined(ENABLE_SECURITY)
# include "UTIL/OSA/osa_defs.h"
#endif
......@@ -73,6 +77,7 @@
extern int otg_enabled;
#endif
//#include "LAYER2/PROTO_AGENT/proto_agent.h"
//-----------------------------------------------------------------------------
/*
......@@ -111,6 +116,7 @@ boolean_t pdcp_data_req(
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_IN);
CHECK_CTXT_ARGS(ctxt_pP);
#if T_TRACER
if (ctxt_pP->enb_flag != ENB_FLAG_NO)
T(T_ENB_PDCP_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_buffer_sizeP));
......@@ -361,6 +367,27 @@ boolean_t pdcp_data_req(
#endif
rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p);
//starting async
// const Enb_properties_array_t *enb_properties_p = NULL;
Enb_properties_array_t *enb_properties_p = NULL;
// enb_properties_p = malloc(sizeof(Enb_properties_array_t));
// memset(enb_properties_p, 0, sizeof(Enb_properties_array_t));
// printf("starting the client\n\n");
printf("Starting the async client\\n");
// new_thread(proto_server_start, NULL);
enb_properties_p = enb_config_get();
static int agent_started = 1;
if (agent_started == 1)
{
agent_started = proto_agent_start(ctxt_pP->module_id, enb_properties_p);
}
}
switch (rlc_status) {
......@@ -410,6 +437,21 @@ boolean_t pdcp_data_req(
Pdcp_stats_tx_bytes[module_id][(rb_id & RAB_OFFSET2 )>> RAB_SHIFT2][(rb_id & RAB_OFFSET)-DTCH] += sdu_buffer_size;
}
}*/
//starting async
// const Enb_properties_array_t *enb_properties_p = NULL;
// Enb_properties_array_t *enb_properties_p = NULL;
// enb_properties_p = malloc(sizeof(Enb_properties_array_t));
// memset(enb_properties_p, 0, sizeof(Enb_properties_array_t));
// printf("starting the client\n\n");
// printf("Starting the async client\\n");
// new_thread(proto_server_start, NULL);
// enb_properties_p = enb_config_get();
// proto_agent_start(ctxt_pP->module_id, enb_properties_p);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_DATA_REQ,VCD_FUNCTION_OUT);
return ret;
......
This diff is collapsed.
......@@ -41,6 +41,8 @@
#include "ENB_APP/enb_config.h" // for enb properties
#include "proto_agent_common.h"
void * proto_server_init(void *args);
int proto_agent_start(mid_t mod_id, const Enb_properties_array_t* enb_properties);
int proto_server_start(mid_t mod_id, const Enb_properties_array_t* enb_properties);
......
......@@ -51,8 +51,8 @@ proto_agent_async_channel_t * proto_server_async_channel_info(mid_t mod_id, char
channel->enb_id = mod_id;
/*Create a socket*/
printf("Starting async server\n");
new_thread(new_link_server, (void *) &dst_port);
channel->link = (void *) &dst_port;
channel->link = new_link_server(dst_port);
//channel->link = NULL;
printf("Started async server\n");
if (channel->link == NULL) goto error;
......@@ -79,7 +79,7 @@ proto_agent_async_channel_t * proto_server_async_channel_info(mid_t mod_id, char
return channel;
error:
LOG_I(PROTO_AGENT,"there was an error\n");
LOG_E(PROTO_AGENT,"there was an error\n");
return 1;
}
......
......@@ -87,6 +87,12 @@ int fsp_create_header(xid_t xid, Protocol__FspType type, Protocol__FspHeader **h
int proto_agent_hello(mid_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_hello(Protocol__FlexsplitMessage *msg);
int proto_agent_echo_request(mid_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_echo_request(Protocol__FlexsplitMessage *msg);
int proto_agent_echo_reply(mid_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_echo_reply(Protocol__FlexsplitMessage *msg);
Protocol__FlexsplitMessage* proto_agent_handle_message (mid_t mod_id,
uint8_t *data,
......@@ -97,6 +103,7 @@ Protocol__FlexsplitMessage *proto_agent_handle_timed_task(void *args);
/****************************
* get generic info from RAN
****************************/
......
......@@ -43,7 +43,7 @@
#include "UTIL/ASYNC_IF/link_manager.h"
#define NUM_MAX_ENB 2
#define NUM_MAX_ENB 10
#define NUM_MAX_UE 2048
#define DEFAULT_PROTO_AGENT_IPv4_ADDRESS "127.0.0.1"
#define DEFAULT_PROTO_AGENT_PORT 2210
......
......@@ -36,19 +36,26 @@
#include "proto_agent_common.h"
//#include "enb_agent_mac.h" // Do we need this?
#include "log.h"
#include "assertions.h"
proto_agent_message_decoded_callback agent_messages_callback[][3] = {
{proto_agent_hello, 0, 0}, /*PROTOCOL__PROGRAN_MESSAGE__MSG_HELLO_MSG*/
{proto_agent_hello, proto_agent_hello, 0},
{proto_agent_echo_reply, 0, 0},
// {proto_agent_rlc_data_req, proto_agent_rlc_data_req_ack, proto_agent_rlc_data_req_nack},
// {proto_agent_pdcp_data_ind, proto_agent_pdcp_data_ind_ack, proto_agent_rlc_data_ind_nack},
};
proto_agent_message_destruction_callback message_destruction_callback[] = {
proto_agent_destroy_hello,
proto_agent_destroy_echo_request,
proto_agent_destroy_echo_reply,
// proto_agent_destroy_rlc_data_req,
// proto_agent_destroy_rlc_data_req_ack,
// proto_agent_destroy_rlc_data_req_nack,
// proto_agent_destroy_pdcp_data_ind,
// proto_agent_destroy_pdcp_data_ind_ack,
// proto_agent_destroy_rlc_data_ind_nack,
};
static const char *proto_agent_direction2String[] = {
......@@ -67,43 +74,45 @@ Protocol__FlexsplitMessage* proto_agent_handle_message (mid_t mod_id,
err_code_t err_code;
DevAssert(data != NULL);
if (proto_agent_deserialize_message(data, size, &decoded_message) < 0) {
LOG_D(PROTO_AGENT, "Deserializing message \n");
if (proto_agent_deserialize_message(data, (int) size, &decoded_message) < 0) {
err_code= PROTOCOL__FLEXSPLIT_ERR__MSG_DECODING;
goto error;
}
Protocol__FspHeader *header = (Protocol__FspHeader*) decoded_message;
if (header->has_type)
{
LOG_D(PROTO_AGENT, "Deserialized MSG type is %d\n", header->type);
}
// Undestand why these calculations take place
if ((decoded_message->msg_case > sizeof(agent_messages_callback) / (3*sizeof(proto_agent_message_decoded_callback))) ||
(decoded_message->msg_dir > PROTOCOL__FLEXSPLIT_DIRECTION__UNSUCCESSFUL_OUTCOME)){
err_code= PROTOCOL__FLEXSPLIT_ERR__MSG_NOT_HANDLED;
LOG_D(PROTO_AGENT,"Handling message: MSG NOT handled, going to error\n");
goto error;
}
if (agent_messages_callback[decoded_message->msg_case-1][decoded_message->msg_dir-1] == NULL) {
err_code= PROTOCOL__FLEXSPLIT_ERR__MSG_NOT_SUPPORTED;
goto error;
}
err_code = ((*agent_messages_callback[decoded_message->msg_case-1][decoded_message->msg_dir-1])(mod_id, (void *) decoded_message, &reply_message));
if ( err_code < 0 ){
if ( err_code < 0 )
{
goto error;
} else if (err_code == 1) { //If err_code > 1, we do not want to dispose the message yet
}
else if (err_code == 1)
{
protocol__flexsplit_message__free_unpacked(decoded_message, NULL);
}
LOG_D(PROTO_AGENT,"Returning REPLY message after the callback\n");
return reply_message;
error:
LOG_E(PROTO_AGENT,"errno %d occured\n",err_code);
return NULL;
}
void * proto_agent_pack_message(Protocol__FlexsplitMessage *msg,
uint32_t * size){
void * buffer;
err_code_t err_code = PROTOCOL__FLEXSPLIT_ERR__NO_ERR;
......@@ -118,8 +127,7 @@ void * proto_agent_pack_message(Protocol__FlexsplitMessage *msg,
DevAssert(buffer !=NULL);
LOG_D(PROTO_AGENT,"Serilized the enb mac stats reply (size %d)\n", *size);
LOG_D(PROTO_AGENT,"Serialized the enb mac stats reply (size %d)\n", *size);
return buffer;
error :
......@@ -128,23 +136,6 @@ void * proto_agent_pack_message(Protocol__FlexsplitMessage *msg,
return NULL;
}
Protocol__FlexsplitMessage* proto_agent_process_timeout(long timer_id, void* timer_args){
struct proto_agent_timer_element_s *found = get_timer_entry(timer_id);
if (found == NULL ) goto error;
// LOG_I(PROTO_AGENT, "Found the entry (%p): timer_id is 0x%lx 0x%lx\n", found, timer_id, found->timer_id);
if (timer_args == NULL)
LOG_W(PROTO_AGENT,"null timer args\n");
// return found->cb(timer_args);
return 1;
error:
LOG_E(PROTO_AGENT, "can't get the timer element\n");
return TIMER_ELEMENT_NOT_FOUND;
}
err_code_t proto_agent_destroy_flexsplit_message(Protocol__FlexsplitMessage *msg) {
return ((*message_destruction_callback[msg->msg_case-1])(msg));
}
......@@ -126,7 +126,7 @@ int proto_agent_create_channel(void *channel_info,
/*element should be a real pointer*/
RB_INSERT(proto_agent_channel_map, &channel_instance.proto_agent_head, channel);
LOG_I(PROTO_AGENT,"Created a new channel with id 0x%lx\n", channel->channel_id);
LOG_D(PROTO_AGENT,"Created a new channel with id 0x%lx\n", channel->channel_id);
return channel_id;
}
......@@ -166,7 +166,7 @@ int proto_agent_destroy_channel(int channel_id) {
err_code_t proto_agent_init_channel_container(void) {
int i, j;
LOG_I(PROTO_AGENT, "init RB tree for channel container\n");
LOG_D(PROTO_AGENT, "init RB tree for channel container\n");
RB_INIT(&channel_instance.proto_agent_head);
......
......@@ -43,6 +43,9 @@
#include "assertions.h"
#include "ENB_APP/enb_config.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
extern boolean_t pdcp_data_ind(
const protocol_ctxt_t* const ctxt_pP,
const srb_flag_t srb_flagP,
......
......@@ -34,6 +34,9 @@
* \email: cedric.roux@eurecom.fr
* @ingroup _mac
*/
//#ifndef SERVER_TEST
//#define SERVER_TEST
//#endif
#include "link_manager.h"
#include "log.h"
......
......@@ -38,8 +38,8 @@
#ifndef LINK_MANAGER_H
#define LINK_MANAGER_H
//#include "message_queue.h"
#include "ringbuffer_queue.h"
#include "message_queue.h"
//#include "ringbuffer_queue.h"
#include "socket_link.h"
#include <pthread.h>
......
......@@ -61,28 +61,28 @@ socket_link_t *new_link_server(int port)
ret = calloc(1, sizeof(socket_link_t));
if (ret == NULL) {
LOG_E(MAC, "%s:%d: out of memory\n", __FILE__, __LINE__);
LOG_D(PROTO_AGENT, "%s:%d: out of memory\n", __FILE__, __LINE__);
goto error;
}
ret->socket_fd = -1;
LOG_D(MAC, "create a new link server socket at port %d\n", port);
LOG_D(PROTO_AGENT, "create a new link server socket at port %d\n", port);
socket_server = socket(AF_INET, SOCK_STREAM, 0);
if (socket_server == -1) {
LOG_E(MAC, "%s:%d: socket: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: socket: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
reuse = 1;
if (setsockopt(socket_server, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) == -1) {
LOG_E(MAC, "%s:%d: setsockopt: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: setsockopt: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
no_delay = 1;
if (setsockopt(socket_server, IPPROTO_TCP, TCP_NODELAY, &no_delay, sizeof(no_delay)) == -1) {
LOG_E(MAC, "%s:%d: setsockopt: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: setsockopt: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
......@@ -90,32 +90,33 @@ socket_link_t *new_link_server(int port)
addr.sin_port = htons(port);
addr.sin_addr.s_addr = INADDR_ANY;
if (bind(socket_server, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
LOG_E(MAC, "%s:%d: bind: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: bind: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
if (listen(socket_server, 5)) {
LOG_E(MAC, "%s:%d: listen: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: listen: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
addrlen = sizeof(addr);
ret->socket_fd = accept(socket_server, (struct sockaddr *)&addr, &addrlen);
if (ret->socket_fd == -1) {
LOG_E(MAC, "%s:%d: accept: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: accept: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
printf("Accepted new connection from client\n");
close(socket_server);
LOG_D(MAC, "connection from %s:%d\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
LOG_D(PROTO_AGENT, "connection from %s:%d\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
return ret;
error:
close(socket_server);
if (ret != NULL) close(ret->socket_fd);
free(ret);
LOG_E(MAC, "ERROR in new_link_server (see above), returning NULL\n");
LOG_E(PROTO_AGENT, "ERROR in new_link_server (see above), returning NULL\n");
return NULL;
}
......@@ -132,32 +133,31 @@ socket_link_t *new_link_client(char *server, int port)
}
ret->socket_fd = -1;
LOG_D(MAC, "create a new link client socket connecting to %s:%d\n", server, port);
LOG_I(PROTO_AGENT, "Creating a new link client socket connecting to %s:%d\n", server, port);
ret->socket_fd = socket(AF_INET, SOCK_STREAM, 0);
if (ret->socket_fd == -1) {
LOG_E(MAC, "%s:%d: socket: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: socket: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
no_delay = 1;
if (setsockopt(ret->socket_fd, SOL_TCP, TCP_NODELAY, &no_delay, sizeof(no_delay)) == -1) {
LOG_E(MAC, "%s:%d: setsockopt: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: setsockopt: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
if (inet_aton(server, &addr.sin_addr) == 0) {
LOG_E(MAC, "invalid IP address '%s', use a.b.c.d notation\n", server);
LOG_E(PROTO_AGENT, "invalid IP address '%s', use a.b.c.d notation\n", server);
goto error;
}
if (connect(ret->socket_fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
LOG_E(MAC, "%s:%d: connect: %s\n", __FILE__, __LINE__, strerror(errno));
LOG_E(PROTO_AGENT, "%s:%d: connect: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
LOG_D(MAC, "connection to %s:%d established\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
LOG_D(PROTO_AGENT, "connection to %s:%d established\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
return ret;
error:
......@@ -178,7 +178,7 @@ static int socket_send(int socket_fd, void *buf, int size)
while (size) {
l = send(socket_fd, s, size, MSG_NOSIGNAL);
if (l == -1) goto error;
if (l == 0) { LOG_E(MAC, "%s:%d: this cannot happen, normally...\n", __FILE__, __LINE__); abort(); }
if (l == 0) { LOG_E(PROTO_AGENT, "%s:%d: this cannot happen, normally...\n", __FILE__, __LINE__); abort(); }
size -= l;
s += l;
}
......@@ -186,7 +186,7 @@ static int socket_send(int socket_fd, void *buf, int size)
return 0;
error:
LOG_E(MAC, "socket_send: ERROR: %s\n", strerror(errno));
LOG_E(PROTO_AGENT, "socket_send: ERROR: %s\n", strerror(errno));
return -1;
}
......@@ -268,6 +268,11 @@ int link_receive_packet(socket_link_t *link, void **ret_data, int *ret_size)
link->bytes_received += 4;
LOG_I(PROTO_AGENT, "ASYNC BYTES Received are :%d \n", link->bytes_received);
LOG_I(PROTO_AGENT, "Size is :%d \n", size);
data = malloc(size);
if (data == NULL) {
LOG_E(MAC, "%s:%d: out of memory\n", __FILE__, __LINE__);
......@@ -280,6 +285,8 @@ int link_receive_packet(socket_link_t *link, void **ret_data, int *ret_size)
link->bytes_received += size;
link->packets_received++;
LOG_I(PROTO_AGENT, "received %d bytes\n", link->bytes_received);
*ret_data = data;
*ret_size = size;
return 0;
......
......@@ -94,6 +94,10 @@ int log_list_nb_elements = 0;
pthread_mutex_t log_lock;
pthread_cond_t log_notify;
pthread_mutex_t async_server_lock;
pthread_cond_t async_server_notify;
int async_server_shutdown;
#if !defined(LOG_NO_THREAD)
int log_list_head = 0;
int log_shutdown;
......@@ -285,6 +289,16 @@ int logInit (void)
g_log->log_component[MSC].filelog = 0;
g_log->log_component[MSC].filelog_name = "/tmp/msc.log";
g_log->log_component[PROTO_AGENT].name = "PROTO_AGENT";
g_log->log_component[PROTO_AGENT].level = LOG_EMERG;
g_log->log_component[PROTO_AGENT].flag = LOG_MED;
g_log->log_component[PROTO_AGENT].interval = 1;
g_log->log_component[PROTO_AGENT].fd = 0;
g_log->log_component[PROTO_AGENT].filelog = 0;
g_log->log_component[PROTO_AGENT].filelog_name = "/tmp/proto_agent.log";
g_log->log_component[OCM].name = "OCM";
g_log->log_component[OCM].level = LOG_EMERG;
g_log->log_component[OCM].flag = LOG_MED;
......
......@@ -282,6 +282,7 @@ typedef enum {
USIM,
LOCALIZE,
RRH,
PROTO_AGENT,
X2AP,
MAX_LOG_COMPONENTS,
}
......
......@@ -31,6 +31,10 @@
extern log_t *g_log;
extern pthread_mutex_t async_server_lock;
extern pthread_cond_t async_server_notify;
extern int async_server_shutdown;
#if !defined(LOG_NO_THREAD)
extern LOG_params log_list[2000];
extern pthread_mutex_t log_lock;
......
......@@ -6,6 +6,8 @@ message flexsplit_message {
optional flexsplit_direction msg_dir = 100;
oneof msg {
fsp_hello hello_msg = 1;
fsp_echo_request echo_request_msg = 2;
fsp_echo_reply echo_reply_msg = 3;
}
}
......@@ -42,3 +44,15 @@ enum flexsplit_err {
message fsp_hello {
optional fsp_header header = 1;
}
message fsp_echo_request {
optional fsp_header header = 1;
// extensions 100 to 199;
}
message fsp_echo_reply {
optional fsp_header header = 1;
// extensions 100 to 199;
}
......@@ -9,5 +9,7 @@ message fsp_header {
enum fsp_type {
// Discovery and maintenance messages
FSPT_HELLO = 0;
FSPT_ECHO_REQUEST = 1;
FSPT_ECHO_REPLY = 2;
}
......@@ -78,6 +78,8 @@
#include "PHY/TOOLS/lte_phy_scope.h"
//#endif
//#include "LAYER2/PROTO_AGENT/proto_agent.h"
#ifdef SMBV
// Rohde&Schwarz SMBV100A vector signal generator
#include "PHY/TOOLS/smbv.h"
......@@ -115,6 +117,8 @@ char smbv_ip[16];
#include "T.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
/*
DCI0_5MHz_TDD0_t UL_alloc_pdu;
DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu;
......@@ -255,6 +259,73 @@ help (void)
}
pthread_t log_thread;
pthread_t async_server_thread;
int async_server_thread_finalize (void);
void
async_server_thread_init (void)
{
//create log_list
//log_list_init(&log_list);
async_server_shutdown = 0;
if ((pthread_mutex_init (&async_server_lock, NULL) != 0)
|| (pthread_cond_init (&async_server_notify, NULL) != 0)) {
return;
}
if (pthread_create (&async_server_thread, NULL, proto_server_init, (void*) NULL)
!= 0) {
async_server_thread_finalize();
return;
}
}
//Call it after the last LOG call
int
async_server_thread_finalize (void)
{
int err = 0;
if (pthread_mutex_lock (&async_server_lock) != 0) {
return -1;
}
async_server_shutdown = 1;
/* Wake up LOG thread */
if ((pthread_cond_broadcast (&async_server_notify) != 0)
|| (pthread_mutex_unlock (&async_server_lock) != 0)) {
err = -1;
}
if (pthread_join (async_server_thread, NULL) != 0) {
err = -1;
}
if (pthread_mutex_unlock (&async_server_lock) != 0) {
err = -1;
}
if (!err) {
//log_list_free(&log_list);
pthread_mutex_lock (&async_server_lock);
pthread_mutex_destroy (&async_server_lock);
pthread_cond_destroy (&async_server_notify);
}
return err;
}
void
log_thread_init (void)
......@@ -1279,6 +1350,7 @@ main (int argc, char **argv)
int port,Process_Flag=0,wgt,Channel_Flag=0,temp;
#endif
//default parameters
oai_emulation.info.n_frames = MAX_FRAME_NUMBER; //1024; //10;
oai_emulation.info.n_frames_flag = 0; //fixme
......@@ -1339,6 +1411,9 @@ main (int argc, char **argv)
init_omv ();
#endif
//Before this call, NB_UE_INST and NB_eNB_INST are not set correctly
check_and_adjust_params ();
set_seed = oai_emulation.emulation_config.seed.value;
......@@ -1353,12 +1428,14 @@ main (int argc, char **argv)
init_ocm ();
#ifdef SMBV
// Rohde&Schwarz SMBV100A vector signal generator
smbv_init_config(smbv_fname, smbv_nframes);
smbv_write_config_from_frame_parms(smbv_fname, &PHY_vars_eNB_g[0][0]->lte_frame_parms);
#endif
// add events to future event list: Currently not used
//oai_emulation.info.oeh_enabled = 1;
if (oai_emulation.info.oeh_enabled == 1)
......@@ -1374,6 +1451,8 @@ main (int argc, char **argv)
t = clock ();
async_server_thread_init();
LOG_N(EMU,
">>>>>>>>>>>>>>>>>>>>>>>>>>> OAIEMU initialization done <<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment