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
}
// not using the circular buffer: affects the PDCP split
//channel->receive_queue = new_message_queue(500);
channel->send_queue = new_message_queue();
channel->receive_queue = new_message_queue();
if (channel->receive_queue == NULL) {
LOG_E(FLEXRAN_AGENT, "could not create send_queue\n");
goto error;
}
/*
* create a link manager
*/
// PDCP split interface ASYNC_IF link manager is using more arguments
// 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;
/* 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");
goto error;
}
return channel;
......
......@@ -44,9 +44,6 @@ proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bi
if (channel == NULL)
goto error;
channel->peer_port = peer_port;
channel->peer_addr = peer_ip;
channel->enb_id = mod_id;
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
channel->manager = create_link_manager(channel->send_queue,
channel->receive_queue,
channel->link,
CHANNEL_UDP,
channel->peer_addr,
channel->peer_port);
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;
......
......@@ -41,8 +41,6 @@
typedef struct proto_agent_async_channel_s {
mod_id_t enb_id;
const char *peer_addr;
int peer_port;
socket_link_t *link;
message_queue_t *send_queue;
message_queue_t *receive_queue;
......
......@@ -47,7 +47,7 @@ static void *link_manager_sender_thread(void *_manager)
while (manager->run) {
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);
}
// if (message_get(manager->send_queue, &data, &size, &priority))
......@@ -95,10 +95,7 @@ error:
link_manager_t *create_link_manager(
message_queue_t *send_queue,
message_queue_t *receive_queue,
socket_link_t *link,
uint16_t type,
const char *peer_addr,
int port )
socket_link_t *link)
{
link_manager_t *ret = NULL;
pthread_attr_t attr;
......@@ -113,9 +110,6 @@ link_manager_t *create_link_manager(
ret->send_queue = send_queue;
ret->receive_queue = receive_queue;
ret->socket_link = link;
ret->type = type;
ret->peer_addr = peer_addr;
ret->port = port;
ret->run = 1;
if (pthread_attr_init(&attr))
......
......@@ -45,9 +45,8 @@ typedef struct {
message_queue_t *send_queue;
message_queue_t *receive_queue;
socket_link_t *socket_link;
uint16_t type;
const char *peer_addr;
int port;
const char *peer_addr; /* for UDP server remote IP */
int peer_port; /* for UDP server remote address */
pthread_t sender;
pthread_t receiver;
volatile int run;
......@@ -56,10 +55,7 @@ typedef struct {
link_manager_t *create_link_manager(
message_queue_t *send_queue,
message_queue_t *receive_queue,
socket_link_t *link,
uint16_t type,
const char *peer_addr,
int port);
socket_link_t *link);
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)
goto error;
}
ret->socket_fd = socket_server;
ret->peer_port = 0;
return ret;
error:
......@@ -251,7 +250,6 @@ socket_link_t *new_link_udp_client(const char *server, int port){
getsockname(s, (struct sockaddr *)&si_other, &slen);
ret->socket_fd = s;
ret->peer_port = port; //ntohs(si_other.sin_port);
return ret;
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