Commit 3b68376a authored by Robert Schmidt's avatar Robert Schmidt

PROTO_AGENT: Restructure/simplify code, UDP only, no own configuration

parent cf55a513
...@@ -103,8 +103,6 @@ typedef struct { ...@@ -103,8 +103,6 @@ typedef struct {
pthread_mutex_t ru_mutex; pthread_mutex_t ru_mutex;
/// condition variable for signaling setup completion of an RU /// condition variable for signaling setup completion of an RU
pthread_cond_t ru_cond; pthread_cond_t ru_cond;
struct cudu_params_s cudu;
} RAN_CONTEXT_t; } RAN_CONTEXT_t;
......
...@@ -416,132 +416,6 @@ void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) { ...@@ -416,132 +416,6 @@ void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) {
} }
void RCconfig_cudu() {
int j;
char *transport_type;
char *du_type;
char *balancing;
pthread_t myid = pthread_self();
printf("CONFIG my id is %u\n", myid);
paramdef_t DU_Params[] = DUPARAMS_DESC;
paramdef_t CU_Params[] = CUPARAMS_DESC;
paramlist_def_t DU_ParamList = {CONFIG_STRING_DU_LIST,NULL,0};
paramlist_def_t CU_ParamList = {CONFIG_STRING_CU_LIST,NULL,0};
config_getlist( &DU_ParamList,DU_Params,sizeof(DU_Params)/sizeof(paramdef_t), NULL);
config_getlist( &CU_ParamList,CU_Params,sizeof(CU_Params)/sizeof(paramdef_t), NULL);
paramdef_t CU_Bal[] = CU_BAL_DESC;
paramlist_def_t CU_BalList = {CONFIG_STRING_CU_BALANCING, NULL, 0};
config_get(&CU_Bal, sizeof(CU_Bal)/sizeof(paramdef_t),NULL);
//printf("%s\n", strdup(*(CU_Bal[0].strptr)));
balancing = strdup(*(CU_Bal[0].strptr));
if (strcmp(balancing, "ALL") == 0)
{
RC.cudu.cu_balancing = CU_BALANCING_ALL;
}
else if (strcmp(balancing, "ROUND_ROBIN") == 0)
{
RC.cudu.cu_balancing = CU_BALANCING_ROUND_ROBIN;
}
else
{
RC.cudu.cu_balancing = atoi(balancing) - 1;
}
// DU Parameters
RC.cudu.local_du.du_interface = strdup(*(DU_ParamList.paramarray[0][DU_INTERFACE_F1U].strptr));
RC.cudu.local_du.du_ipv4_address = strdup(*(DU_ParamList.paramarray[0][DU_ADDRESS_F1U].strptr));
RC.cudu.local_du.du_port = *(DU_ParamList.paramarray[0][DU_PORT_F1U].iptr);
transport_type = strdup(*(DU_ParamList.paramarray[0][DU_TYPE_F1U].strptr));
if (strcmp(transport_type, "TCP") == 0)
{
RC.cudu.local_du.tcp = 1;
RC.cudu.local_du.udp = 0;
RC.cudu.local_du.sctp = 0;
}
else if (strcmp(transport_type, "UDP") == 0)
{
RC.cudu.local_du.tcp = 0;
RC.cudu.local_du.udp = 1;
RC.cudu.local_du.sctp = 0;
}
else if (strcmp(transport_type, "SCTP") == 0)
{
RC.cudu.local_du.tcp = 0;
RC.cudu.local_du.udp = 0;
RC.cudu.local_du.sctp = 1;
}
else
{
RC.cudu.local_du.tcp = 1;
RC.cudu.local_du.udp = 0;
RC.cudu.local_du.sctp = 0;
}
//CU Parameters
j = CU_ParamList.numelt;
RC.cudu.serving_dus = j;
for (int k=0; k<j; k++)
{
RC.cudu.cu[k].cu_interface = strdup(*(CU_ParamList.paramarray[k][CU_INTERFACE_F1U].strptr));
RC.cudu.cu[k].cu_ipv4_address = strdup(*(CU_ParamList.paramarray[k][CU_ADDRESS_F1U].strptr));
RC.cudu.cu[k].cu_port = *(CU_ParamList.paramarray[k][CU_PORT_F1U].iptr);
RC.cudu.cu[k].cu_id = k;
du_type = strdup(*(CU_ParamList.paramarray[k][DU_TECH].strptr));
transport_type = strdup(*(CU_ParamList.paramarray[k][CU_TYPE_F1U].strptr));
if (strcmp(transport_type, "TCP") == 0)
{
RC.cudu.cu[k].tcp = 1;
RC.cudu.cu[k].udp = 0;
RC.cudu.cu[k].sctp = 0;
}
else if (strcmp(transport_type, "UDP") == 0)
{
RC.cudu.cu[k].tcp = 0;
RC.cudu.cu[k].udp = 1;
RC.cudu.cu[k].sctp = 0;
}
else if (strcmp(transport_type, "SCTP") == 0)
{
RC.cudu.cu[k].tcp = 0;
RC.cudu.cu[k].udp = 0;
RC.cudu.cu[k].sctp = 1;
}
else
{
RC.cudu.cu[k].tcp = 1;
RC.cudu.cu[k].udp = 0;
RC.cudu.cu[k].sctp = 0;
}
if (strcmp(du_type, "LTE") == 0)
{
RC.cudu.cu[k].du_type = DU_TYPE_LTE;
}
else if (strcmp(du_type, "WiFi") == 0)
{
RC.cudu.cu[k].du_type = DU_TYPE_WIFI;
}
else
{
RC.cudu.cu[k].du_type = DU_TYPE_LTE;
}
}
}
cudu_params_t *get_cudu_config()
{
return &(RC.cudu);
}
int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc) { int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc) {
int num_enbs = 0; int num_enbs = 0;
...@@ -2828,8 +2702,6 @@ void RCConfig(void) { ...@@ -2828,8 +2702,6 @@ void RCConfig(void) {
char aprefix[MAX_OPTNAME_SIZE*2 + 8]; char aprefix[MAX_OPTNAME_SIZE*2 + 8];
// RCconfig_cudu();
/* get global parameters, defined outside any section in the config file */ /* get global parameters, defined outside any section in the config file */
printf("Getting ENBSParams\n"); printf("Getting ENBSParams\n");
......
...@@ -82,37 +82,16 @@ typedef struct mme_ip_address_s { ...@@ -82,37 +82,16 @@ typedef struct mme_ip_address_s {
typedef struct du_interfaces { typedef struct du_params {
char *du_interface; const char *remote_ipv4_address;
char *du_ipv4_address; const int16_t remote_port;
uint16_t du_port; } du_params_t;
typedef struct cu_params {
unsigned tcp:1; const char *local_interface;
unsigned udp:1; const char *local_ipv4_address;
unsigned sctp:1; const uint16_t local_port;
} cu_params_t;
}du_interfaces_t;
typedef struct cu_interfaces {
char *cu_interface;
char *cu_ipv4_address;
uint16_t cu_port;
uint8_t du_type;
uint8_t cu_id;
unsigned tcp:1;
unsigned udp:1;
unsigned sctp:1;
}cu_interfaces_t;
typedef struct cudu_params_s {
du_interfaces_t local_du;
cu_interfaces_t cu[MAX_DU];
uint8_t serving_dus;
uint8_t cu_balancing;
}cudu_params_t;
typedef struct ru_config_s { typedef struct ru_config_s {
// indicates if local or remote rf is used (1 == LOCAL) // indicates if local or remote rf is used (1 == LOCAL)
...@@ -145,11 +124,7 @@ void ru_config_display(void); ...@@ -145,11 +124,7 @@ void ru_config_display(void);
int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc); int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc);
int RCconfig_S1(MessageDef *msg_p, uint32_t i); int RCconfig_S1(MessageDef *msg_p, uint32_t i);
int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i);
int RCconfig_CU_F1(uint32_t i);
void RCconfig_cudu(void);
cudu_params_t *get_cudu_config(void);
void read_config_and_init(void); void read_config_and_init(void);
int RCconfig_X2(MessageDef *msg_p, uint32_t i); int RCconfig_X2(MessageDef *msg_p, uint32_t i);
......
This diff is collapsed.
...@@ -45,20 +45,13 @@ void * proto_server_init(void *args); ...@@ -45,20 +45,13 @@ void * proto_server_init(void *args);
void * proto_server_receive(void *args); void * proto_server_receive(void *args);
void * proto_client_receive(void *args); void * proto_client_receive(void *args);
int proto_agent_start(uint8_t enb_id, mod_id_t mod_id, uint8_t type_id, cudu_params_t *cudu); int proto_agent_start(mod_id_t mod_id, const du_params_t *du);
int proto_server_start(mod_id_t mod_id, const cudu_params_t* cudu); int proto_server_start(mod_id_t mod_id, const cu_params_t* cu);
int proto_agent_stop(mod_id_t mod_id); int proto_agent_stop(mod_id_t mod_id);
void *proto_agent_task(void *args); void *proto_agent_task(void *args);
uint8_t select_du(uint8_t max_dus);
typedef struct
{
mod_id_t mod_id;
uint8_t type_id;
}proto_recv_t;
void proto_agent_send_rlc_data_req(uint8_t mod_id, uint8_t type_id, void proto_agent_send_rlc_data_req(uint8_t mod_id, uint8_t type_id,
const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, 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, const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, const mui_t muiP,
......
...@@ -34,61 +34,35 @@ ...@@ -34,61 +34,35 @@
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
uint16_t proto_udp = 0; proto_agent_async_channel_t *
uint16_t proto_tcp = 0; proto_server_async_channel_info(mod_id_t mod_id, const char *ip, uint16_t port)
uint16_t proto_sctp = 0; {
LOG_E(PROTO_AGENT, "does not bind to specific address at the moment, ignoring %s\n", ip);
proto_agent_async_channel_t * proto_server_async_channel_info(mod_id_t mod_id, char *dst_ip, uint16_t dst_port, const char* type, const char *peer_addr) {
proto_agent_async_channel_t *channel; proto_agent_async_channel_t *channel;
channel = (proto_agent_async_channel_t *) malloc(sizeof(proto_agent_channel_t)); channel = malloc(sizeof(proto_agent_channel_t));
channel->port = dst_port;
channel->peer_addr = NULL;
if (channel == NULL) if (channel == NULL)
goto error; goto error;
channel->port = port;
channel->peer_addr = NULL;
channel->enb_id = mod_id; channel->enb_id = mod_id;
/*Create a socket*/ channel->link = new_link_udp_server(port);
if (strcmp(type, "TCP") == 0)
{
proto_tcp = 1;
printf("PROTO_AGENT: sTARTING TCP SERVER\n");
channel->link = new_link_server(dst_port);
channel->type = 0;
}
else if (strcmp(type, "UDP") == 0)
{
proto_udp = 1;
//channel->link = new_udp_link_server(dst_port);
channel->link = new_link_udp_server(dst_port);
channel->type = 1;
channel->peer_addr = peer_addr;
}
else if (strcmp(type, "SCTP") == 0)
{
proto_sctp = 1;
//channel->link = new_sctp_link_server(dst_port);
channel->link = new_link_sctp_server(dst_port);
channel->type = 2;
}
if (channel->link == NULL) goto error; if (channel->link == NULL) goto error;
/*
* create a message queue
*/
channel->send_queue = new_message_queue(); channel->send_queue = new_message_queue();
if (channel->send_queue == NULL) goto error; if (channel->send_queue == NULL) goto error;
channel->receive_queue = new_message_queue(); channel->receive_queue = new_message_queue();
if (channel->receive_queue == NULL) goto error; if (channel->receive_queue == NULL) goto error;
/* channel->manager = create_link_manager(channel->send_queue,
* create a link manager channel->receive_queue,
*/ channel->link,
channel->manager = create_link_manager(channel->send_queue, channel->receive_queue, channel->link, channel->type, channel->peer_addr, channel->port); CHANNEL_UDP,
channel->peer_addr,
channel->port);
if (channel->manager == NULL) goto error; if (channel->manager == NULL) goto error;
return channel; return channel;
...@@ -99,55 +73,34 @@ proto_agent_async_channel_t * proto_server_async_channel_info(mod_id_t mod_id, c ...@@ -99,55 +73,34 @@ proto_agent_async_channel_t * proto_server_async_channel_info(mod_id_t mod_id, c
} }
proto_agent_async_channel_t * proto_agent_async_channel_info(mod_id_t mod_id, char *dst_ip, uint16_t dst_port, const char* type, const char *peer_addr) { proto_agent_async_channel_t *
proto_agent_async_channel_info(mod_id_t mod_id, const char *dst_ip, uint16_t dst_port)
{
proto_agent_async_channel_t *channel; proto_agent_async_channel_t *channel;
channel = (proto_agent_async_channel_t *) malloc(sizeof(proto_agent_channel_t)); channel = (proto_agent_async_channel_t *) malloc(sizeof(proto_agent_channel_t));
channel->port = dst_port;
channel->peer_addr = NULL;
if (channel == NULL) if (channel == NULL)
goto error; goto error;
channel->port = dst_port;
channel->peer_addr = dst_ip;
channel->enb_id = mod_id; channel->enb_id = mod_id;
/*Create a socket*/ channel->link = new_link_udp_client(channel->peer_addr, channel->port);
if (strcmp(type, "TCP") == 0)
{
proto_tcp = 1;
channel->link = new_link_client(dst_ip, dst_port);
channel->type = 0;
}
else if (strcmp(type, "UDP") == 0)
{
proto_udp = 1;
channel->link = new_link_udp_client(dst_ip, dst_port);
channel->type = 1;
channel->peer_addr = peer_addr;
}
else if (strcmp(type, "SCTP") == 0)
{
proto_sctp = 1;
channel->link = new_link_sctp_client(dst_ip, dst_port);;
channel->type = 2;
}
if (channel->link == NULL) goto error; if (channel->link == NULL) goto error;
/*
* create a message queue
*/
channel->send_queue = new_message_queue(); channel->send_queue = new_message_queue();
if (channel->send_queue == NULL) goto error; if (channel->send_queue == NULL) goto error;
channel->receive_queue = new_message_queue(); channel->receive_queue = new_message_queue();
if (channel->receive_queue == NULL) goto error; if (channel->receive_queue == NULL) goto error;
/* channel->manager = create_link_manager(channel->send_queue,
* create a link manager channel->receive_queue,
*/ channel->link,
channel->manager = create_link_manager(channel->send_queue, channel->receive_queue, channel->link, channel->type, channel->peer_addr, channel->port); CHANNEL_UDP,
channel->peer_addr,
channel->port);
if (channel->manager == NULL) goto error; if (channel->manager == NULL) goto error;
return channel; return channel;
...@@ -163,19 +116,12 @@ int proto_agent_async_msg_send(void *data, int size, int priority, void *channel ...@@ -163,19 +116,12 @@ int proto_agent_async_msg_send(void *data, int size, int priority, void *channel
return message_put(channel->send_queue, data, size, priority); return message_put(channel->send_queue, data, size, priority);
} }
int proto_agent_async_msg_recv(void **data, int *size, int *priority, void *channel_info) { int proto_agent_async_msg_recv(void **data, int *size, int *priority, void *channel_info)
{
proto_agent_async_channel_t *channel; proto_agent_async_channel_t *channel;
channel = (proto_agent_async_channel_t *)channel_info; channel = (proto_agent_async_channel_t *)channel_info;
if (channel == NULL) return message_get(channel->receive_queue, data, size, priority);
return 0;
else if (channel->type < 0)
return 0;
else if (channel->receive_queue == NULL)
return 0;
else
return message_get(channel->receive_queue, data, size, priority);
} }
void proto_agent_async_release(proto_agent_channel_t *channel) { void proto_agent_async_release(proto_agent_channel_t *channel) {
......
...@@ -39,10 +39,9 @@ ...@@ -39,10 +39,9 @@
#include "proto_agent_net_comm.h" #include "proto_agent_net_comm.h"
typedef struct { typedef struct proto_agent_async_channel_s {
mod_id_t enb_id; mod_id_t enb_id;
uint16_t type; // 0-> TCP, 1-> UDP, 2->SCTP const char *peer_addr;
char *peer_addr;
int port; int port;
socket_link_t *link; socket_link_t *link;
message_queue_t *send_queue; message_queue_t *send_queue;
...@@ -50,8 +49,8 @@ typedef struct { ...@@ -50,8 +49,8 @@ typedef struct {
link_manager_t *manager; link_manager_t *manager;
} proto_agent_async_channel_t; } proto_agent_async_channel_t;
proto_agent_async_channel_t * proto_agent_async_channel_info(mod_id_t mod_id, char *dst_ip, uint16_t dst_port, const char* type, const char *peer_addr); proto_agent_async_channel_t * proto_agent_async_channel_info(mod_id_t mod_id, const char *dst_ip, uint16_t dst_port);
proto_agent_async_channel_t * proto_server_async_channel_info(mod_id_t mod_id, char *dst_ip, uint16_t dst_port, const char* type, const char *peer_addr); proto_agent_async_channel_t * proto_server_async_channel_info(mod_id_t mod_id, const char *ip, uint16_t _port);
int proto_agent_async_msg_send(void *data, int size, int priority, void *channel_info); int proto_agent_async_msg_send(void *data, int size, int priority, void *channel_info);
......
...@@ -98,9 +98,9 @@ typedef enum { ...@@ -98,9 +98,9 @@ typedef enum {
typedef uint8_t xid_t; typedef uint8_t xid_t;
typedef uint8_t mod_id_t; // module or enb id typedef uint8_t mod_id_t; // module or enb id
typedef uint8_t lcid_t; typedef uint8_t lcid_t;
typedef int32_t err_code_t; typedef int32_t err_code_t;
#define CHANNEL_UDP 1
typedef struct { typedef struct {
/* general info */ /* general info */
...@@ -113,12 +113,16 @@ typedef struct { ...@@ -113,12 +113,16 @@ typedef struct {
uint32_t rx_msg[NUM_MAX_ENB]; uint32_t rx_msg[NUM_MAX_ENB];
uint32_t tx_msg[NUM_MAX_ENB]; uint32_t tx_msg[NUM_MAX_ENB];
}proto_agent_info_t; } proto_agent_info_t;
typedef struct { /* forward declaration */
mod_id_t enb_id; struct proto_agent_channel_s;
typedef struct proto_agent_instance_s {
mod_id_t mod_id;
proto_agent_info_t agent_info; proto_agent_info_t agent_info;
struct proto_agent_channel_s *channel;
}proto_agent_instance_t; pthread_t recv_thread;
} proto_agent_instance_t;
#endif #endif
...@@ -41,16 +41,18 @@ ...@@ -41,16 +41,18 @@
#include "tree.h" #include "tree.h"
#define ENB_AGENT_MAX 9 #define ENB_AGENT_MAX 9
/* forward declaration */
struct proto_agent_async_channel_s;
/*Channel related information used for Tx/Rx of protocol messages*/ /*Channel related information used for Tx/Rx of protocol messages*/
typedef struct proto_agent_channel_s { typedef struct proto_agent_channel_s {
RB_ENTRY(proto_agent_channel_s) entry; RB_ENTRY(proto_agent_channel_s) entry;
int channel_id; int channel_id;
void *channel_info; struct proto_agent_async_channel_s *channel_info;
uint16_t type; // 0-> TCP, 1-> UDP, 2->SCTP /*Callbacks for channel message Tx and Rx*/
/*Callbacks for channel message Tx and Rx*/ int (*msg_send)(void *data, int size, int priority, void *channel_info);
int (*msg_send)(void *data, int size, int priority, void *channel_info); int (*msg_recv)(void **data, int *size, int *priority, void *channel_info);
int (*msg_recv)(void **data, int *size, int *priority, void *channel_info); void (*release)(struct proto_agent_channel_s *channel);
void (*release)(struct proto_agent_channel_s *channel);
} proto_agent_channel_t; } proto_agent_channel_t;
typedef struct proto_agent_channel_instance_s{ typedef struct proto_agent_channel_instance_s{
......
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