Commit aa47fa4c authored by Laurent THOMAS's avatar Laurent THOMAS

remove F1-U protobuf implementation

parent 3e7c22e7
......@@ -1109,7 +1109,6 @@ include_directories("${OPENAIR2_DIR}/ENB_APP/CONTROL_MODULES/S1AP")
include_directories("${OPENAIR2_DIR}/UTIL/OSA")
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}/UTIL/MEM")
include_directories("${OPENAIR2_DIR}/UTIL/LISTS")
include_directories("${OPENAIR2_DIR}/UTIL/FIFO")
......@@ -1275,18 +1274,6 @@ include_directories (${FSPT_C_DIR})
# 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
......@@ -2780,7 +2767,7 @@ target_link_libraries (lte-softmodem
-Wl,--start-group
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U F1AP_LIB F1AP SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB
PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB LFDS7
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB}
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB}
-Wl,--end-group z dl)
target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES})
......@@ -2824,38 +2811,10 @@ target_link_libraries (ocp-enb
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP SCHED_LIB SCHED_RU_LIB
PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB MISC_NFAPI_LTE_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 SIMU_COMMON
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB}
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB}
-Wl,--end-group z dl)
target_link_libraries (ocp-enb ${LIBXML2_LIBRARIES} pthread m ${CONFIG_LIBRARIES} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${LIB_LMS_LIBRARIES} ${T_LIB})
add_executable(cu_test
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/cu_test.c
${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
${T_SOURCE}
)
target_link_libraries(cu_test
${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FSPT_MSG_LIB} ${PROTOBUF_LIB}
${PROTO_AGENT_LIB} pthread UTIL ${T_LIB} dl ITTI
)
add_executable(du_test
${OPENAIR2_DIR}/LAYER2/PROTO_AGENT/du_test.c
${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
${T_SOURCE}
)
target_link_libraries(du_test
${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FSPT_MSG_LIB} ${PROTOBUF_LIB}
${PROTO_AGENT_LIB} pthread UTIL ${T_LIB} dl ITTI
)
add_executable(oairu
${OPENAIR_TARGETS}/RT/USER/lte-ru.c
${OPENAIR_TARGETS}/RT/USER/ru_control.c
......@@ -2922,7 +2881,7 @@ target_link_libraries (lte-uesoftmodem
-Wl,--end-group z dl)
target_link_libraries (lte-uesoftmodem ${LIBXML2_LIBRARIES})
target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (lte-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (lte-uesoftmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (lte-uesoftmodem ${T_LIB})
......@@ -2963,7 +2922,7 @@ target_link_libraries (nr-softmodem
UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA
ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB
NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${FSPT_MSG_LIB}
-Wl,--end-group z dl)
target_link_libraries (nr-softmodem ${LIBXML2_LIBRARIES})
......@@ -3053,7 +3012,7 @@ target_link_libraries (nr-uesoftmodem
-Wl,--end-group z dl)
target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES})
target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES})
target_link_libraries (nr-uesoftmodem ${T_LIB})
......@@ -3364,7 +3323,7 @@ if (${T_TRACER})
PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX
L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_NR MAC_UE_NR NGAP_GNB
CN_UTILS GTPV1U SCTP_CLIENT MME_APP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB
ldpc_orig ldpc_optim ldpc_optim8seg ldpc PROTO_AGENT dfts)
ldpc_orig ldpc_optim ldpc_optim8seg ldpc dfts)
if (TARGET ${i})
add_dependencies(${i} generate_T)
endif()
......@@ -3474,7 +3433,7 @@ target_link_libraries (nr-ittisim
UTIL HASHTABLE SCTP_CLIENT SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA
ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_SIM_LIB} RRC_LIB NR_RRC_LIB
NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${FSPT_MSG_LIB}
PHY_NR_UE SCHED_NR_UE_LIB NR_L2_UE
-Wl,--end-group z dl)
......
......@@ -589,48 +589,20 @@ static void wait_nfapi_init(char *thread_name) {
}
void init_pdcp(void) {
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT:
LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (!get_softmodem_params()->nsa) {
if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) {
//pdcp_layer_init();
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
(PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (IS_SOFTMODEM_NOS1) {
printf("IS_SOFTMODEM_NOS1 option enabled \n");
pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT;
}
nr_pdcp_module_init(pdcp_initmask, 0);
if (NODE_IS_CU(RC.nrrrc[0]->node_type)) {
LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n");
pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req);
} else {
LOG_I(PDCP, "node is gNB \n");
pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req);
pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind);
}
} else {
LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n");
pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind);
}
} else {
pdcp_layer_init();
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
(PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (IS_SOFTMODEM_NOS1) {
printf("IS_SOFTMODEM_NOS1 option enabled \n");
pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT;
}
nr_pdcp_module_init(pdcp_initmask, 0);
pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req);
pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind);
}
}
int main( int argc, char **argv ) {
int ru_id, CC_id = 0;
start_background_system();
......
......@@ -5,7 +5,6 @@
#include "flexran_agent.h"
#include "PHY/defs_gNB.h"
#include "proto_agent.h"
#define DEFAULT_DLF 2680000000
......@@ -65,5 +64,6 @@ void init_gNB_afterRU(void);
extern int stop_L1L2(module_id_t gnb_id);
extern int restart_L1L2(module_id_t gnb_id);
void init_pdcp(void);
#endif
......@@ -55,7 +55,6 @@
#include "common/config/config_userapi.h"
#include "RRC_config_tools.h"
#include "enb_paramdef.h"
#include "proto_agent.h"
#include "executables/thread-common.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
......
......@@ -35,7 +35,6 @@
#include "f1ap_cu_rrc_message_transfer.h"
#include "f1ap_cu_ue_context_management.h"
#include "f1ap_cu_task.h"
#include "proto_agent.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
//Fixme: Uniq dirty DU instance, by global var, datamodel need better management
......
......@@ -35,7 +35,6 @@
#include "f1ap_du_ue_context_management.h"
#include "f1ap_du_rrc_message_transfer.h"
#include "f1ap_du_task.h"
#include "proto_agent.h"
#include <openair3/ocp-gtpu/gtp_itf.h>
//Fixme: Uniq dirty DU instance, by global var, datamodel need better management
......
......@@ -31,8 +31,8 @@
#include <stdio.h>
#include <nr_pdcp/nr_pdcp.h>
#include <softmodem-common.h>
#include <nr-softmodem.h>
#include <split_headers.h>
#include <proto_agent.h>
#include "gnb_app.h"
#include "gnb_config.h"
......@@ -135,34 +135,6 @@ static uint32_t gNB_app_register_x2(uint32_t gnb_id_start, uint32_t gnb_id_end)
/*------------------------------------------------------------------------------*/
static void init_pdcp(void) {
if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) {
pdcp_layer_init();
uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ?
(PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT;
if (IS_SOFTMODEM_NOS1) {
LOG_I(PDCP, "IS_SOFTMODEM_NOS1 option enabled\n");
pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT;
}
nr_pdcp_module_init(pdcp_initmask, 0);
if (NODE_IS_CU(RC.nrrrc[0]->node_type)) {
LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n");
pdcp_set_rlc_data_req_func(proto_agent_send_rlc_data_req);
} else {
LOG_I(PDCP, "node is gNB \n");
pdcp_set_rlc_data_req_func(rlc_data_req);
pdcp_set_pdcp_data_ind_func(pdcp_data_ind);
}
} else {
LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n");
pdcp_set_pdcp_data_ind_func(proto_agent_send_pdcp_data_ind);
}
}
/*------------------------------------------------------------------------------*/
void *gNB_app_task(void *args_p)
{
......
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include "ENB_APP/enb_paramdef.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
#define BUF_MAX 1400
int recv_client = 0;
FILE *output;
void usage(char *prg_name) {
fprintf(stderr, "usage: %s <file or ->\n", prg_name);
fprintf(stderr, " - is stdin\n");
fprintf(stderr, " received packets are written to stdout\n");
}
long uelapsed(struct timeval *s, struct timeval *e) {
return e->tv_sec * 1000000 + e->tv_usec - (s->tv_sec * 1000000 + s->tv_usec);
}
boolean_t
pdcp_data_ind(
const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const sdu_size_t sdu_buffer_sizeP,
mem_block_t *const sdu_buffer_pP
) {
fwrite(sdu_buffer_pP->data, sdu_buffer_sizeP, 1, stdout);
fflush(stdout);
free_mem_block(sdu_buffer_pP, __func__);
/* cannot free because of const */
//free(ctxt_pP);
recv_client = 1;
return 0;
}
void close_proto_agent(void) {
proto_agent_stop(0);
}
int main(int argc, char *argv[]) {
const cudu_params_t params = {
.local_ipv4_address = "192.168.12.45",
.local_port = 6464,
.remote_ipv4_address = "192.168.12.45",
.remote_port = 6465
};
protocol_ctxt_t p;
memset(&p, 0, sizeof p);
mem_block_t mem;
char s[BUF_MAX];
size_t size, totsize = 0;
struct timeval t_start, t_end;
FILE *f;
if (argc != 2) {
usage(argv[0]);
return 1;
}
if (strcmp(argv[1], "-") == 0) {
f = stdin;
} else {
f = fopen(argv[1], "r");
}
if (!f) {
fprintf(stderr, "cannot open %s: %s\n", argv[1], strerror(errno));
return 2;
}
pool_buffer_init();
if (proto_agent_start(0, &params) != 0) {
fprintf(stderr, "error on proto_agent_start()\n");
fclose(f);
return 3;
}
atexit(close_proto_agent);
/* wait for first packet of client */
while (!recv_client) sleep(1);
fprintf(stderr, "reading file\n");
/* now send back at the same time */
gettimeofday(&t_start, NULL);
while ((size = fread(s, 1, BUF_MAX, f)) > 0) {
usleep(10);
totsize += size;
mem.data = &s[0];
proto_agent_send_rlc_data_req(&p, 0, 0, 0, 0, 0, size, &mem);
}
gettimeofday(&t_end, NULL);
fclose(f);
long us = uelapsed(&t_start, &t_end);
fprintf(stderr, "read %zu bytes in %ld ms -> %.3fMB/s, %.3fMbps\n",
totsize, us / 1000, ((float) totsize ) / us,
((float) totsize) / us * 8);
fprintf(stderr, "check files using 'diff afile bfile'\n");
/* give some time in case the other direction is slower */
sleep(5);
return 0;
}
/*
*********************************************************
* arbitrary functions, needed for linking (used or not) *
*********************************************************
*/
rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const mui_t muiP,
confirm_t confirmP,
sdu_size_t sdu_sizeP,
mem_block_t *sdu_pP,
const uint32_t *const sourceL2Id,
const uint32_t *const destinationL2Id
) {
fprintf(stderr, "This should never be called on the CU\n");
exit(1);
}
pthread_t new_thread(void *(*f)(void *), void *b) {
pthread_t t;
pthread_attr_t att;
if (pthread_attr_init(&att)) {
fprintf(stderr, "pthread_attr_init err\n");
exit(1);
}
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
fprintf(stderr, "pthread_attr_setdetachstate err\n");
exit(1);
}
if (pthread_create(&t, &att, f, b)) {
fprintf(stderr, "pthread_create err\n");
exit(1);
}
if (pthread_attr_destroy(&att)) {
fprintf(stderr, "pthread_attr_destroy err\n");
exit(1);
}
return t;
}
int log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) {
return 0;
}
int config_get(paramdef_t *params,int numparams, char *prefix) {
return 0;
}
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) {
return 0;
}
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include "ENB_APP/enb_paramdef.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
#define BUF_MAX 1400
void usage(char *prg_name) {
fprintf(stderr, "usage: %s <file or ->\n", prg_name);
fprintf(stderr, " - is stdin\n");
fprintf(stderr, " received packets are written to stdout\n");
}
long uelapsed(struct timeval *s, struct timeval *e) {
return e->tv_sec * 1000000 + e->tv_usec - (s->tv_sec * 1000000 + s->tv_usec);
}
rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const mui_t muiP,
confirm_t confirmP,
sdu_size_t sdu_sizeP,
mem_block_t *sdu_pP,
const uint32_t *const sourceL2Id,
const uint32_t *const destinationL2Id
) {
fwrite(sdu_pP->data, sdu_sizeP, 1, stdout);
fflush(stdout);
free_mem_block(sdu_pP, __func__);
//free(ctxt_pP);
return 0;
}
void close_proto_agent(void) {
proto_agent_stop(0);
}
int main(int argc, char *argv[]) {
const cudu_params_t params = {
.local_ipv4_address = "192.168.12.45",
.local_port = 6465,
.remote_ipv4_address = "192.168.12.45",
.remote_port = 6464
};
protocol_ctxt_t p;
memset(&p, 0, sizeof p);
mem_block_t mem;
char s[BUF_MAX];
size_t size, totsize = 0;
struct timeval t_start, t_end;
FILE *f;
if (argc != 2) {
usage(argv[0]);
return 1;
}
if (strcmp(argv[1], "-") == 0) {
f = stdin;
} else {
f = fopen(argv[1], "r");
}
if (!f) {
fprintf(stderr, "cannot open %s: %s\n", argv[1], strerror(errno));
return 2;
}
pool_buffer_init();
if (proto_agent_start(0, &params) != 0) {
fprintf(stderr, "error on proto_agent_start()\n");
fclose(f);
return 3;
}
atexit(close_proto_agent);
gettimeofday(&t_start, NULL);
while ((size = fread(s, 1, BUF_MAX, f)) > 0) {
usleep(10);
totsize += size;
mem.data = &s[0];
proto_agent_send_pdcp_data_ind(&p, 0, 0, 0, size, &mem);
}
gettimeofday(&t_end, NULL);
fclose(f);
long us = uelapsed(&t_start, &t_end);
fprintf(stderr, "read %zu bytes in %ld ms -> %.3fMB/s, %.3fMbps\n",
totsize, us / 1000, ((float) totsize ) / us,
((float) totsize) / us * 8);
fprintf(stderr, "check files using 'diff afile bfile'\n");
/* wait, we are possibly receiving data */
sleep(5);
return 0;
}
/*
*********************************************************
* arbitrary functions, needed for linking (used or not) *
*********************************************************
*/
boolean_t
pdcp_data_ind(
const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP,
const sdu_size_t sdu_buffer_sizeP,
mem_block_t *const sdu_buffer_pP
) {
fprintf(stderr, "This should never be called on the DU\n");
exit(1);
}
pthread_t new_thread(void *(*f)(void *), void *b) {
pthread_t t;
pthread_attr_t att;
if (pthread_attr_init(&att)) {
fprintf(stderr, "pthread_attr_init err\n");
exit(1);
}
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
fprintf(stderr, "pthread_attr_setdetachstate err\n");
exit(1);
}
if (pthread_create(&t, &att, f, b)) {
fprintf(stderr, "pthread_create err\n");
exit(1);
}
if (pthread_attr_destroy(&att)) {
fprintf(stderr, "pthread_attr_destroy err\n");
exit(1);
}
return t;
}
int log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) {
return 0;
}
int config_get(paramdef_t *params,int numparams, char *prefix) {
return 0;
}
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) {
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent.h
* \brief top level enb agent receive thread and itti task
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#define _GNU_SOURCE
#include "proto_agent_common.h"
#include "common/utils/LOG/log.h"
#include "proto_agent.h"
#include "assertions.h"
#include "proto_agent_net_comm.h"
#include "proto_agent_async.h"
#include <common/utils/system.h>
#include <pthread.h>
#define ENB_AGENT_MAX 9
proto_agent_instance_t proto_agent[MAX_DU];
//pthread_t new_thread(void *(*f)(void *), void *b);
Protocol__FlexsplitMessage *proto_agent_timeout_fsp(void *args);
#define TEST_MOD 0
#define ECHO
/* Server side function; upon a new connection
reception, sends the hello packets
*/
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) {
int channel_id;
// RS: CUDU does not work!
//DevAssert(p->local_interface);
//DevAssert(p->local_ipv4_address);
//DevAssert(p->local_port > 1024); // "unprivileged" port
//DevAssert(p->remote_ipv4_address);
//DevAssert(p->remote_port > 1024); // "unprivileged" port
proto_agent[mod_id].mod_id = mod_id;
proto_agent[mod_id].exit = 0;
/* Initialize the channel container */
/* TODO only initialize the first time */
proto_agent_init_channel_container();
/*Create the async channel info*/
proto_agent_async_channel_t *channel_info;
channel_info = proto_agent_async_channel_info(mod_id, p->local_ipv4_address, p->local_port,
p->remote_ipv4_address, p->remote_port);
if (!channel_info) goto error;
/* Create a channel using the async channel info */
channel_id = proto_agent_create_channel((void *) channel_info,
proto_agent_async_msg_send,
proto_agent_async_msg_recv,
proto_agent_async_release);
if (channel_id <= 0) goto error;
proto_agent_channel_t *channel = proto_agent_get_channel(channel_id);
if (!channel) goto error;
proto_agent[mod_id].channel = channel;
/* Register the channel for all underlying agents (use ENB_AGENT_MAX) */
proto_agent_register_channel(mod_id, channel, ENB_AGENT_MAX);
// Code for sending the HELLO/ECHO_REQ message once a connection is established
//uint8_t *msg = NULL;
//Protocol__FlexsplitMessage *init_msg=NULL;
//if (udp == 0)
//{
// // If the comm is not UDP, allow the server to send the first packet over the channel
// //printf( "Proto agent Server: Calling the echo_request packet constructor\n");
// msg_flag = proto_agent_echo_request(mod_id, NULL, &init_msg);
// if (msg_flag != 0)
// goto error;
//
// int msgsize = 0;
// if (init_msg != NULL)
// msg = proto_agent_pack_message(init_msg, &msgsize);
// if (msg!= NULL)
// {
// LOG_D(PROTO_AGENT, "Server sending the message over the async channel\n");
// proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, (void *) channel_info);
// }
// /* After sending the message, wait for any replies;
// the server thread blocks until it reads any data
// over the channel
// */
//}
//proto_agent[mod_id].recv_thread = new_thread(proto_agent_receive, &proto_agent[mod_id]);
threadCreate(&proto_agent[mod_id].recv_thread, proto_agent_receive, &proto_agent[mod_id], "proto", -1, OAI_PRIORITY_RT_LOW);
fprintf(stderr, "[PROTO_AGENT] server started at port %s:%d\n", p->local_ipv4_address, p->local_port);
return 0;
error:
LOG_E(PROTO_AGENT, "there was an error\n");
return 1;
}
void proto_agent_stop(mod_id_t mod_id) {
if (!proto_agent[mod_id].channel) return;
/* unlock the independent read thread proto_agent_receive() */
proto_agent[mod_id].exit = 1;
proto_agent_async_msg_recv_unlock(proto_agent[mod_id].channel->channel_info);
proto_agent_async_release(proto_agent[mod_id].channel);
proto_agent_destroy_channel(proto_agent[mod_id].channel->channel_id);
free(proto_agent[mod_id].channel);
proto_agent[mod_id].channel = NULL;
LOG_W(PROTO_AGENT, "server stopped\n");
}
//void
//proto_agent_send_hello(void)
//{
// uint8_t *msg = NULL;
// Protocol__FlexsplitMessage *init_msg=NULL;
// int msg_flag = 0;
//
//
// //printf( "PDCP agent: Calling the HELLO packet constructor\n");
// msg_flag = proto_agent_hello(proto_agent[TEST_MOD].mod_id, NULL, &init_msg);
//
// int msgsize = 0;
// if (msg_flag == 0)
// {
// proto_agent_serialize_message(init_msg, &msg, &msgsize);
// }
//
// LOG_D(PROTO_AGENT, "Agent sending the message over the async channel\n");
// proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, (void *) client_channel[TEST_MOD]);
//}
rlc_op_status_t proto_agent_send_rlc_data_req(const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP, const mui_t muiP,
confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,const uint32_t *const SrcID, const uint32_t *const DstID) {
uint8_t *msg = NULL;
Protocol__FlexsplitMessage *init_msg=NULL;
int msg_flag = 0;
int msgsize = 0;
mod_id_t mod_id = ctxt_pP->module_id;
data_req_args args;
DevAssert(proto_agent[mod_id].channel);
DevAssert(proto_agent[mod_id].channel->channel_info);
args.ctxt = ctxt_pP;
args.srb_flag = srb_flagP;
args.MBMS_flag = MBMS_flagP;
args.rb_id = rb_idP;
args.mui = muiP;
args.confirm = confirmP;
args.sdu_size = sdu_sizeP;
args.sdu_p = sdu_pP;
msg_flag = proto_agent_pdcp_data_req(mod_id, (void *) &args, &init_msg);
if (msg_flag != 0 || !init_msg) goto error;
msg = proto_agent_pack_message(init_msg, &msgsize);
if (!msg) goto error;
proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
free_mem_block(sdu_pP, __func__);
return RLC_OP_STATUS_OK;
error:
LOG_E(PROTO_AGENT, "PROTO_AGENT there was an error\n");
return RLC_OP_STATUS_INTERNAL_ERROR;
}
boolean_t proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP,
const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP,
sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,
const uint32_t *const SrcID, const uint32_t *const DstID) {
uint8_t *msg = NULL;
Protocol__FlexsplitMessage *init_msg = NULL;
int msg_flag = 0;
int msgsize = 0;
mod_id_t mod_id = ctxt_pP->module_id;
data_req_args args;
DevAssert(proto_agent[mod_id].channel);
DevAssert(proto_agent[mod_id].channel->channel_info);
args.ctxt = ctxt_pP;
args.srb_flag = srb_flagP;
args.MBMS_flag = MBMS_flagP;
args.rb_id = rb_idP;
args.sdu_size = sdu_sizeP;
args.sdu_p = sdu_pP;
msg_flag = proto_agent_pdcp_data_ind(mod_id, (void *) &args, &init_msg);
if (msg_flag != 0 || !init_msg) goto error;
msg = proto_agent_pack_message(init_msg, &msgsize);
if (!msg) goto error;
proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
free_mem_block(sdu_pP, __func__);
return TRUE;
error:
LOG_E(PROTO_AGENT, "there was an error in %s\n", __func__);
return FALSE;
}
void *
proto_agent_receive(void *args) {
proto_agent_instance_t *inst = args;
void *data = NULL;
int size;
int priority;
err_code_t err_code;
pthread_setname_np(pthread_self(), "proto_rx");
Protocol__FlexsplitMessage *msg;
uint8_t *ser_msg;
while (1) {
msg = NULL;
ser_msg = NULL;
if ((size = proto_agent_async_msg_recv(&data, &priority, inst->channel->channel_info)) < 0) {
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING;
goto error;
}
if (inst->exit) break;
LOG_D(PROTO_AGENT, "Server side Received message with size %d and priority %d, calling message handle\n", size, priority);
msg = proto_agent_handle_message(inst->mod_id, data, size);
if (!msg) {
LOG_D(PROTO_AGENT, "msg to send back is NULL\n");
continue;
}
ser_msg = proto_agent_pack_message(msg, &size);
if (!ser_msg) {
continue;
}
LOG_D(PROTO_AGENT, "Server sending the reply message over the async channel\n");
if (proto_agent_async_msg_send((void *)ser_msg, (int) size, 1, inst->channel->channel_info)) {
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING;
goto error;
}
LOG_D(PROTO_AGENT, "sent message with size %d\n", size);
}
return NULL;
error:
LOG_E(PROTO_AGENT, "proto_agent_receive(): error %d occured\n",err_code);
return NULL;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file proto_agent.h
* \brief top level protocol agent
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_H_
#define PROTO_AGENT_H_
#include "ENB_APP/enb_config.h" // for enb properties
#include "proto_agent_common.h"
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include "RRC/NR/nr_rrc_defs.h"
void *proto_agent_receive(void *args);
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p);
void proto_agent_stop(mod_id_t mod_id);
rlc_op_status_t proto_agent_send_rlc_data_req( const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP, const mui_t muiP, confirm_t confirmP,
sdu_size_t sdu_sizeP, mem_block_t *sdu_pP,const uint32_t *const SrcID, const uint32_t *const DstID);
pdcp_data_ind_t proto_agent_send_pdcp_data_ind;
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "proto_agent_async.h"
#include "proto_agent_defs.h"
#include "common/utils/LOG/log.h"
proto_agent_async_channel_t *
proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bind_port,
const char* peer_ip, uint16_t peer_port)
{
proto_agent_async_channel_t *channel;
channel = malloc(sizeof(proto_agent_async_channel_t));
if (channel == NULL)
goto error;
channel->enb_id = mod_id;
channel->link = new_link_udp_server(bind_ip, bind_port);
if (channel->link == NULL) goto error;
channel->send_queue = new_message_queue();
if (channel->send_queue == NULL) goto error;
channel->receive_queue = new_message_queue();
if (channel->receive_queue == NULL) goto error;
channel->manager = create_link_manager(channel->send_queue,
channel->receive_queue,
channel->link);
/* manually set remote IP&port for UDP server remote end */
channel->manager->peer_port = peer_port;
channel->manager->peer_addr = peer_ip;
if (channel->manager == NULL) goto error;
return channel;
error:
if (channel)
free(channel);
LOG_E(PROTO_AGENT, "error creating proto_agent_async_channel_t\n");
return NULL;
}
int proto_agent_async_msg_send(void *data, int size, int priority, void *channel_info)
{
proto_agent_async_channel_t *channel = channel_info;
return message_put(channel->send_queue, data, size, priority);
}
int proto_agent_async_msg_recv(void **data, int *priority, void *channel_info)
{
proto_agent_async_channel_t *channel = channel_info;
return message_get(channel->receive_queue, data, priority);
}
void proto_agent_async_msg_recv_unlock(proto_agent_async_channel_t *channel) {
message_get_unlock(channel->receive_queue);
}
void proto_agent_async_release(proto_agent_channel_t *channel)
{
proto_agent_async_channel_t *channel_info = channel->channel_info;
destroy_link_manager(channel_info->manager);
destroy_message_queue(channel_info->send_queue);
destroy_message_queue(channel_info->receive_queue);
close_link(channel_info->link);
free(channel_info);
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_async.h
* \brief channel implementation for async interface
* \author Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_ASYNC_H_
#define PROTO_AGENT_ASYNC_H_
#include "proto_agent_net_comm.h"
typedef struct proto_agent_async_channel_s {
mod_id_t enb_id;
socket_link_t *link;
message_queue_t *send_queue;
message_queue_t *receive_queue;
link_manager_t *manager;
} proto_agent_async_channel_t;
proto_agent_async_channel_t *
proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bind_port,
const char *peer_ip, uint16_t peer_port);
int proto_agent_async_msg_send(void *data, int size, int priority, void *channel_info);
int proto_agent_async_msg_recv(void **data, int *priority, void *channel_info);
/* unlocks a running proto_agent_async_msg_recv() */
void proto_agent_async_msg_recv_unlock(proto_agent_async_channel_t *channel);
void proto_agent_async_release(proto_agent_channel_t *channel);
#endif /*PROTO_AGENT_ASYNC_H_*/
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_common.h
* \brief common message primitves and utilities
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_COMMON_H_
#define PROTO_AGENT_COMMON_H_
#include <time.h>
#include "flexsplit.pb-c.h"
// Do not need these
//#include "stats_messages.pb-c.h"
//#include "stats_common.pb-c.h"
#include "proto_agent_defs.h"
//#include "ENB_APP/enb_config.h"
#include "UTIL/MEM/mem_block.h"
//#include "LAYER2/MAC/extern.h"
//#include "LAYER2/RLC/rlc.h"
# include "tree.h"
# include "intertask_interface.h"
#define FLEXSPLIT_VERSION 0
typedef int (*proto_agent_message_decoded_callback)(
mod_id_t mod_id,
const void *params,
Protocol__FlexsplitMessage **msg
);
typedef int (*proto_agent_message_destruction_callback)(
Protocol__FlexsplitMessage *msg
);
/**********************************
* progRAN protocol messages helper
* functions and generic handlers
**********************************/
int proto_agent_serialize_message(Protocol__FlexsplitMessage *msg, uint8_t **buf, int *size);
int proto_agent_deserialize_message(void *data, int size, Protocol__FlexsplitMessage **msg);
uint8_t *proto_agent_pack_message(Protocol__FlexsplitMessage *msg, int *size);
err_code_t proto_agent_destroy_flexsplit_message(Protocol__FlexsplitMessage *msg);
int fsp_create_header(xid_t xid, Protocol__FspType type, Protocol__FspHeader **header);
int proto_agent_hello(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_hello(Protocol__FlexsplitMessage *msg);
int proto_agent_echo_request(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_echo_request(Protocol__FlexsplitMessage *msg);
int proto_agent_echo_reply(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_echo_reply(Protocol__FlexsplitMessage *msg);
int proto_agent_pdcp_data_req(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_pdcp_data_req_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_pdcp_data_req(Protocol__FlexsplitMessage *msg);
int proto_agent_pdcp_data_ind(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_destroy_pdcp_data_ind(Protocol__FlexsplitMessage *msg);
int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int just_print(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
int proto_agent_get_ack_result(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg);
Protocol__FlexsplitMessage* proto_agent_handle_message (mod_id_t mod_id,
uint8_t *data,
int size);
Protocol__FlexsplitMessage *proto_agent_handle_timed_task(void *args);
typedef struct _data_req_args data_req_args;
typedef struct _dl_data_args dl_data_args;
struct _data_req_args{
const protocol_ctxt_t* ctxt;
srb_flag_t srb_flag;
MBMS_flag_t MBMS_flag;
rb_id_t rb_id;
mui_t mui;
confirm_t confirm;
sdu_size_t sdu_size;
mem_block_t *sdu_p;
};
struct _dl_data_args{
uint8_t pdu_type;
uint32_t sn;
frame_t frame;
sub_frame_t subframe;
rnti_t rnti;
sdu_size_t sdu_size;
mem_block_t *sdu_p;
};
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_defs.h
* \brief enb agent common definitions
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_DEFS_H_
#define PROTO_AGENT_DEFS_H_
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include "openairinterface5g_limits.h"
#include "UTIL/ASYNC_IF/link_manager.h"
#define DEFAULT_PROTO_AGENT_IPv4_ADDRESS "127.0.0.1"
#define DEFAULT_PROTO_AGENT_PORT 2210
#define DEFAULT_PROTO_AGENT_CACHE "/mnt/oai_agent_cache"
typedef enum {
PROTO_AGENT_DEFAULT=0,
ENB_AGENT_PHY=1,
ENB_AGENT_MAC=2,
ENB_AGENT_RLC=3,
ENB_AGENT_PDCP=4,
ENB_AGENT_RRC=5,
ENB_AGENT_S1AP=6,
ENB_AGENT_GTP=7,
ENB_AGENT_X2AP=8,
ENB_AGENT_MAX=9,
} proto_agent_id_t;
/*
typedef enum {
ENB_AGENT_ACTION_NONE = 0x0,
ENB_AGENT_ACTION_SEND = 0x1,
ENB_AGENT_ACTION_APPLY = 0x2,
ENB_AGENT_ACTION_CLEAR = 0x4,
ENB_AGENT_ACTION_WRITE = 0x8,
ENB_AGENT_ACTION_FILTER = 0x10,
ENB_AGENT_ACTION_PREPROCESS = 0x20,
ENB_AGENT_ACTION_METER = 0x40,
ENB_AGENT_ACTION_MAX = 0x7f,
} agent_action_t;
*/
/*
typedef enum {
RAN_LTE_OAI= 0,
RAN_NAME_MAX = 0x7f,
} ran_name_t;
*/
typedef uint8_t xid_t;
typedef uint8_t mod_id_t; // module or enb id
typedef uint8_t lcid_t;
typedef int32_t err_code_t;
typedef struct {
/* general info */
/* stats */
uint32_t total_rx_msg;
uint32_t total_tx_msg;
uint32_t rx_msg[NUMBER_OF_eNB_MAX];
uint32_t tx_msg[NUMBER_OF_eNB_MAX];
} proto_agent_info_t;
/* forward declaration */
struct proto_agent_channel_s;
typedef struct proto_agent_instance_s {
mod_id_t mod_id;
proto_agent_info_t agent_info;
struct proto_agent_channel_s *channel;
pthread_t recv_thread;
uint8_t exit;
} proto_agent_instance_t;
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_handler.c
* \brief enb agent tx and rx message handler
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
*/
#include "proto_agent_common.h"
#include "common/utils/LOG/log.h"
#include "assertions.h"
proto_agent_message_decoded_callback proto_agent_messages_callback[][3] = {
{proto_agent_hello, 0, 0}, /* agent hello */
{proto_agent_echo_reply, 0, 0}, /* echo */
{0, just_print, 0}, /* just print */
{proto_agent_pdcp_data_req_process, proto_agent_pdcp_data_req_process, 0}, /* PDCP data REQ */
{0, proto_agent_get_ack_result, 0}, /* get ACK result */
{proto_agent_pdcp_data_ind_process, proto_agent_pdcp_data_ind_process, 0}, /* PDCP data IND */
{0, just_print, 0}, /* just print */
};
proto_agent_message_destruction_callback proto_message_destruction_callback[] = {
proto_agent_destroy_hello,
proto_agent_destroy_echo_request,
proto_agent_destroy_echo_reply,
proto_agent_destroy_pdcp_data_req,
0,
proto_agent_destroy_pdcp_data_ind,
0,
};
//static const char *proto_agent_direction2String[] = {
// "", /* not_set */
// "originating message", /* originating message */
// "successfull outcome", /* successfull outcome */
// "unsuccessfull outcome", /* unsuccessfull outcome */
//};
Protocol__FlexsplitMessage* proto_agent_handle_message (mod_id_t mod_id,
uint8_t *data,
int size){
Protocol__FlexsplitMessage *decoded_message = NULL;
Protocol__FlexsplitMessage *reply_message = NULL;
err_code_t err_code;
DevAssert(data != NULL);
LOG_D(PROTO_AGENT, "Deserializing message with size %u \n", size);
if (proto_agent_deserialize_message(data, (int) size, &decoded_message) < 0) {
err_code= PROTOCOL__FLEXSPLIT_ERR__MSG_DECODING;
goto error;
}
/* after deserialization, we don't need the original data memory anymore */
free(data);
Protocol__FspHeader *header = (Protocol__FspHeader*) decoded_message;
if (header->has_type)
{
LOG_D(PROTO_AGENT, "Deserialized MSG type is %d and %u\n", decoded_message->msg_case, decoded_message->msg_dir);
}
if ((decoded_message->msg_case > sizeof(proto_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;
}
err_code = ((*proto_agent_messages_callback[decoded_message->msg_case-1][decoded_message->msg_dir-1])(mod_id, (void *) decoded_message, &reply_message));
if ( err_code < 0 )
{
LOG_I(PROTO_AGENT, "decoded_message case : %d, direction : %d \n", decoded_message->msg_case-1, decoded_message->msg_dir-1);
goto error;
}
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;
}
uint8_t *proto_agent_pack_message(Protocol__FlexsplitMessage *msg, int *size)
{
uint8_t *buffer;
err_code_t err_code = PROTOCOL__FLEXSPLIT_ERR__NO_ERR;
if (proto_agent_serialize_message(msg, &buffer, size) < 0 ) {
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENCODING;
goto error;
}
if (proto_message_destruction_callback[msg->msg_case-1])
err_code = ((*proto_message_destruction_callback[msg->msg_case-1])(msg));
DevAssert(buffer !=NULL);
LOG_D(PROTO_AGENT,"Serialized the enb mac stats reply (size %d)\n", *size);
return buffer;
error :
LOG_E(PROTO_AGENT,"errno %d occured\n",err_code);
return NULL;
}
err_code_t proto_agent_destroy_flexsplit_message(Protocol__FlexsplitMessage *msg) {
return ((*proto_message_destruction_callback[msg->msg_case-1])(msg));
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_net_comm.c
* \brief enb agent network interface abstraction
* \author Xenofon Foukas
* \date 2016
* \version 0.1
*/
#include "proto_agent_net_comm.h"
#include "common/utils/LOG/log.h"
proto_agent_channel_t *proto_channel[NUMBER_OF_eNB_MAX][ENB_AGENT_MAX];
static proto_agent_channel_instance_t channel_instance;
int proto_agent_channel_id = 0;
int proto_agent_register_channel(mod_id_t mod_id, proto_agent_channel_t *channel, proto_agent_id_t agent_id) {
int i;
if (channel == NULL) {
return -1;
}
if (agent_id == ENB_AGENT_MAX) {
for (i = 0; i < ENB_AGENT_MAX; i++) {
proto_channel[mod_id][i] = channel;
}
} else {
proto_channel[mod_id][agent_id] = channel;
}
return 0;
}
void proto_agent_unregister_channel(mod_id_t mod_id, proto_agent_id_t agent_id) {
int i;
if (agent_id == ENB_AGENT_MAX) {
for (i = 0; i < ENB_AGENT_MAX; i++) {
proto_channel[mod_id][i] = NULL;
}
} else {
proto_channel[mod_id][agent_id] = NULL;
}
}
int proto_agent_create_channel(void *channel_info,
int (*msg_send)(void *data, int size, int priority, void *channel_info),
int (*msg_recv)(void **data, int *priority, void *channel_info),
void (*release)(proto_agent_channel_t *channel)) {
int channel_id = ++proto_agent_channel_id;
proto_agent_channel_t *channel = (proto_agent_channel_t *) malloc(sizeof(proto_agent_channel_t));
channel->channel_id = channel_id;
channel->channel_info = channel_info;
channel->msg_send = msg_send;
channel->msg_recv = msg_recv;
channel->release = release;
/*element should be a real pointer*/
RB_INSERT(proto_agent_channel_map, &channel_instance.proto_agent_head, channel);
LOG_D(PROTO_AGENT, "Created a new channel with id 0x%x\n", channel->channel_id);
return channel_id;
}
int proto_agent_destroy_channel(int channel_id) {
int i, j;
/*Check to see if channel exists*/
struct proto_agent_channel_s *e = NULL;
struct proto_agent_channel_s search;
memset(&search, 0, sizeof(struct proto_agent_channel_s));
e = RB_FIND(proto_agent_channel_map, &channel_instance.proto_agent_head, &search);
if (e == NULL) {
return -1;
}
/*Unregister the channel from all agents*/
for (i = 0; i < NUMBER_OF_eNB_MAX; i++) {
for (j = 0; j < ENB_AGENT_MAX; j++) {
if (proto_channel[i][j] != NULL) {
if (proto_channel[i][j]->channel_id == e->channel_id) {
proto_channel[i][j] = NULL;
}
}
}
}
/*Remove the channel from the tree and free memory*/
RB_REMOVE(proto_agent_channel_map, &channel_instance.proto_agent_head, e);
e->release(e);
free(e);
return 0;
}
err_code_t proto_agent_init_channel_container(void) {
int i, j;
LOG_D(PROTO_AGENT, "init RB tree for channel container\n");
RB_INIT(&channel_instance.proto_agent_head);
for (i = 0; i < NUMBER_OF_eNB_MAX; i++) {
for (j = 0; j < ENB_AGENT_MAX; j++) {
proto_channel[i][j] = NULL;
}
}
return 0;
}
RB_GENERATE(proto_agent_channel_map,proto_agent_channel_s, entry, proto_agent_compare_channel);
int proto_agent_compare_channel(struct proto_agent_channel_s *a, struct proto_agent_channel_s *b) {
if (a->channel_id < b->channel_id) return -1;
if (a->channel_id > b->channel_id) return 1;
// equal timers
return 0;
}
proto_agent_channel_t * proto_agent_get_channel(int channel_id) {
struct proto_agent_channel_s search;
memset(&search, 0, sizeof(struct proto_agent_channel_s));
search.channel_id = channel_id;
return RB_FIND(proto_agent_channel_map, &channel_instance.proto_agent_head, &search);
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file enb_agent_net_comm.h
* \brief enb agent network interface abstraction
* \autho Xenofon Foukas
* \date 2016
* \version 0.1
*/
#ifndef PROTO_AGENT_NET_COMM_H_
#define PROTO_AGENT_NET_COMM_H_
#include "proto_agent_defs.h"
#include "tree.h"
#define ENB_AGENT_MAX 9
/* forward declaration */
struct proto_agent_async_channel_s;
/*Channel related information used for Tx/Rx of protocol messages*/
typedef struct proto_agent_channel_s {
RB_ENTRY(proto_agent_channel_s) entry;
int channel_id;
struct proto_agent_async_channel_s *channel_info;
/*Callbacks for channel message Tx and Rx*/
int (*msg_send)(void *data, int size, int priority, void *channel_info);
int (*msg_recv)(void **data, int *priority, void *channel_info);
void (*release)(struct proto_agent_channel_s *channel);
} proto_agent_channel_t;
typedef struct proto_agent_channel_instance_s{
RB_HEAD(proto_agent_channel_map, proto_agent_channel_s) proto_agent_head;
} proto_agent_channel_instance_t;
/*Register a channel to an agent. Use ENB_AGENT_MAX to register the
*same channel to all agents*/
int proto_agent_register_channel(mod_id_t mod_id, proto_agent_channel_t *channel, proto_agent_id_t agent_id);
/*Unregister the current channel of an agent. Use ENB_AGENT_MAX to unregister all channels*/
void proto_agent_unregister_channel(mod_id_t mod_id, proto_agent_id_t agent_id);
/*Create a new channel. Returns the id of the new channel or negative number otherwise*/
int proto_agent_create_channel(void *channel_info,
int (*msg_send)(void *data, int size, int priority, void *channel_info),
int (*msg_recv)(void **data, int *priority, void *channel_info),
void (*release)(proto_agent_channel_t *channel));
/*Unregister a channel from all agents and destroy it. Returns 0 in case of success*/
int proto_agent_destroy_channel(int channel_id);
/*Return an agent communication channel based on its id*/
proto_agent_channel_t * proto_agent_get_channel(int channel_id);
/*Should be called before performing any channel operations*/
err_code_t proto_agent_init_channel_container(void);
int proto_agent_compare_channel(struct proto_agent_channel_s *a, struct proto_agent_channel_s *b);
/* RB_PROTOTYPE is for .h files */
RB_PROTOTYPE(proto_agent_channel_map, proto_agent_channel_s, entry, proto_agent_compare_channel);
#endif /*ENB_AGENT_COMM_H_*/
#ifndef __PROTO_AGENT_RLC_PRIMITIVES_H__
#define __PROTO_AGENT_RLC_PRIMITIVES_H__
#include "RRC/LTE/rrc_defs.h"
#include "LAYER2/PROTO_AGENT/proto_agent.h"
// PROTO AGENT
pthread_t async_server_thread;
int async_server_thread_finalize (void);
void async_server_thread_init (void);
pthread_mutex_t async_server_lock;
pthread_cond_t async_server_notify;
int async_server_shutdown;
#endif
......@@ -40,8 +40,6 @@
#include "openair2/F1AP/f1ap_du_rrc_message_transfer.h"
#include "openair2/LAYER2/PROTO_AGENT/proto_agent.h"
extern RAN_CONTEXT_t RC;
#include <stdint.h>
......
......@@ -54,8 +54,6 @@
#include "common/config/config_userapi.h"
#include "RRC_config_tools.h"
#include "enb_paramdef.h"
#include "proto_agent.h"
#include "m3ap_MCE.h"
......
......@@ -54,7 +54,6 @@
#include "common/config/config_userapi.h"
#include "RRC_config_tools.h"
#include "enb_paramdef.h"
#include "proto_agent.h"
int RCconfig_MME(void ) {
//int num_enbs = 0;
......
......@@ -499,8 +499,6 @@ static void init_pdcp(void) {
pdcp_set_rlc_data_req_func(rlc_data_req);
pdcp_set_pdcp_data_ind_func(pdcp_data_ind);
}
} else {
pdcp_set_pdcp_data_ind_func(proto_agent_send_pdcp_data_ind);
}
}
......
......@@ -30,7 +30,6 @@
#include "flexran_agent.h"
#include "s1ap_eNB.h"
#include "SIMULATION/ETH_TRANSPORT/proto.h"
#include "proto_agent.h"
#include "executables/softmodem-common.h"
......
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