Commit 0efde021 authored by Robert Schmidt's avatar Robert Schmidt

Sanitize link_manager interface, correct in FlexRAN/PROTO_AGENT

This commit cleans up the link_manager interface:
* don't provide peer_addr/port in create_link_manager() (for TCP/SCTP it is not
  needed, so in the UDP case in needs to be set explicitly)
* Make FlexRAN connect again (correct hardcoded address)
* Fix FlexRAN: retain the manager pointer
* Fix FlexRAN: store receive_queue pointer
* the link_manager's sender thread passes the correct peer_addr/port for the
  UDP case
parent 34adfd2a
...@@ -67,26 +67,18 @@ flexran_agent_async_channel_t * flexran_agent_async_channel_info(mid_t mod_id, c ...@@ -67,26 +67,18 @@ flexran_agent_async_channel_t * flexran_agent_async_channel_info(mid_t mod_id, c
} }
// not using the circular buffer: affects the PDCP split // not using the circular buffer: affects the PDCP split
//channel->receive_queue = new_message_queue(500); //channel->receive_queue = new_message_queue(500);
channel->send_queue = new_message_queue(); channel->receive_queue = new_message_queue();
if (channel->receive_queue == NULL) { if (channel->receive_queue == NULL) {
LOG_E(FLEXRAN_AGENT, "could not create send_queue\n"); LOG_E(FLEXRAN_AGENT, "could not create send_queue\n");
goto error; goto error;
} }
/* /* create a link manager */
* create a link manager channel->manager = create_link_manager(channel->send_queue, channel->receive_queue, channel->link);
*/ if (channel->manager == NULL) {
LOG_E(FLEXRAN_AGENT, "could not create link_manager\n");
// PDCP split interface ASYNC_IF link manager is using more arguments goto error;
}
// channel->manager = create_link_manager(channel->send_queue, channel->receive_queue, channel->link);
// Hardcoded fix: TODO: Fix this
uint8_t type = 1;
char *peer_addr = strdup("127.0.0.1");
uint32_t port = 10000;
create_link_manager(channel->send_queue, channel->receive_queue, channel->link, type, peer_addr, port);
if (channel->manager == NULL) goto error;
return channel; return channel;
......
...@@ -44,9 +44,6 @@ proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bi ...@@ -44,9 +44,6 @@ proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bi
if (channel == NULL) if (channel == NULL)
goto error; goto error;
channel->peer_port = peer_port;
channel->peer_addr = peer_ip;
channel->enb_id = mod_id; channel->enb_id = mod_id;
channel->link = new_link_udp_server(bind_ip, bind_port); channel->link = new_link_udp_server(bind_ip, bind_port);
...@@ -59,10 +56,11 @@ proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bi ...@@ -59,10 +56,11 @@ proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bi
channel->manager = create_link_manager(channel->send_queue, channel->manager = create_link_manager(channel->send_queue,
channel->receive_queue, channel->receive_queue,
channel->link, channel->link);
CHANNEL_UDP, /* manually set remote IP&port for UDP server remote end */
channel->peer_addr, channel->manager->peer_port = peer_port;
channel->peer_port); channel->manager->peer_addr = peer_ip;
if (channel->manager == NULL) goto error; if (channel->manager == NULL) goto error;
return channel; return channel;
......
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
typedef struct proto_agent_async_channel_s { typedef struct proto_agent_async_channel_s {
mod_id_t enb_id; mod_id_t enb_id;
const char *peer_addr;
int peer_port;
socket_link_t *link; socket_link_t *link;
message_queue_t *send_queue; message_queue_t *send_queue;
message_queue_t *receive_queue; message_queue_t *receive_queue;
......
...@@ -47,7 +47,7 @@ static void *link_manager_sender_thread(void *_manager) ...@@ -47,7 +47,7 @@ static void *link_manager_sender_thread(void *_manager)
while (manager->run) { while (manager->run) {
while (message_get(manager->send_queue, &data, &size, &priority) == 0) { while (message_get(manager->send_queue, &data, &size, &priority) == 0) {
link_send_packet(manager->socket_link, data, size, manager->peer_addr, manager->port); link_send_packet(manager->socket_link, data, size, manager->peer_addr, manager->peer_port);
free(data); free(data);
} }
// if (message_get(manager->send_queue, &data, &size, &priority)) // if (message_get(manager->send_queue, &data, &size, &priority))
...@@ -95,10 +95,7 @@ error: ...@@ -95,10 +95,7 @@ error:
link_manager_t *create_link_manager( link_manager_t *create_link_manager(
message_queue_t *send_queue, message_queue_t *send_queue,
message_queue_t *receive_queue, message_queue_t *receive_queue,
socket_link_t *link, socket_link_t *link)
uint16_t type,
const char *peer_addr,
int port )
{ {
link_manager_t *ret = NULL; link_manager_t *ret = NULL;
pthread_attr_t attr; pthread_attr_t attr;
...@@ -113,9 +110,6 @@ link_manager_t *create_link_manager( ...@@ -113,9 +110,6 @@ link_manager_t *create_link_manager(
ret->send_queue = send_queue; ret->send_queue = send_queue;
ret->receive_queue = receive_queue; ret->receive_queue = receive_queue;
ret->socket_link = link; ret->socket_link = link;
ret->type = type;
ret->peer_addr = peer_addr;
ret->port = port;
ret->run = 1; ret->run = 1;
if (pthread_attr_init(&attr)) if (pthread_attr_init(&attr))
......
...@@ -45,9 +45,8 @@ typedef struct { ...@@ -45,9 +45,8 @@ typedef struct {
message_queue_t *send_queue; message_queue_t *send_queue;
message_queue_t *receive_queue; message_queue_t *receive_queue;
socket_link_t *socket_link; socket_link_t *socket_link;
uint16_t type; const char *peer_addr; /* for UDP server remote IP */
const char *peer_addr; int peer_port; /* for UDP server remote address */
int port;
pthread_t sender; pthread_t sender;
pthread_t receiver; pthread_t receiver;
volatile int run; volatile int run;
...@@ -56,10 +55,7 @@ typedef struct { ...@@ -56,10 +55,7 @@ typedef struct {
link_manager_t *create_link_manager( link_manager_t *create_link_manager(
message_queue_t *send_queue, message_queue_t *send_queue,
message_queue_t *receive_queue, message_queue_t *receive_queue,
socket_link_t *link, socket_link_t *link);
uint16_t type,
const char *peer_addr,
int port);
void destroy_link_manager(link_manager_t *); void destroy_link_manager(link_manager_t *);
......
...@@ -205,7 +205,6 @@ socket_link_t *new_link_udp_server(const char *bind_addr, int bind_port) ...@@ -205,7 +205,6 @@ socket_link_t *new_link_udp_server(const char *bind_addr, int bind_port)
goto error; goto error;
} }
ret->socket_fd = socket_server; ret->socket_fd = socket_server;
ret->peer_port = 0;
return ret; return ret;
error: error:
...@@ -251,7 +250,6 @@ socket_link_t *new_link_udp_client(const char *server, int port){ ...@@ -251,7 +250,6 @@ socket_link_t *new_link_udp_client(const char *server, int port){
getsockname(s, (struct sockaddr *)&si_other, &slen); getsockname(s, (struct sockaddr *)&si_other, &slen);
ret->socket_fd = s; ret->socket_fd = s;
ret->peer_port = port; //ntohs(si_other.sin_port);
return ret; return ret;
error: error:
......
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