Commit dec1c93c authored by Xenofon Foukas's avatar Xenofon Foukas

Changed channel struct for async_channel implementation

parent a054eb81
...@@ -39,21 +39,21 @@ ...@@ -39,21 +39,21 @@
#include "log.h" #include "log.h"
enb_agent_instance_t * enb_agent_async_channel_info(mid_t mod_id, char *dst_ip, uint16_t dst_port) { enb_agent_async_channel_t * enb_agent_async_channel_info(mid_t mod_id, char *dst_ip, uint16_t dst_port) {
enb_agent_instance_t *channel; enb_agent_async_channel_t *channel;
channel = (enb_agent_instance_t *) malloc(sizeof(enb_agent_instance_t)); channel = (enb_agent_async_channel_t *) malloc(sizeof(enb_agent_channel_t));
if (channel == NULL) if (channel == NULL)
goto error; goto error;
channel->mod_id = mod_id; channel->enb_id = mod_id;
/*Create a socket*/ /*Create a socket*/
channel->link = new_link_client(dst_ip, dst_port); channel->link = new_link_client(dst_ip, dst_port);
if (channel->link == NULL) goto error; if (channel->link == NULL) goto error;
LOG_I(ENB_AGENT,"starting enb agent client for module id %d on ipv4 %s, port %d\n", LOG_I(ENB_AGENT,"starting enb agent client for module id %d on ipv4 %s, port %d\n",
channel->mod_id, channel->enb_id,
dst_ip, dst_ip,
dst_port); dst_port);
...@@ -80,22 +80,22 @@ enb_agent_instance_t * enb_agent_async_channel_info(mid_t mod_id, char *dst_ip, ...@@ -80,22 +80,22 @@ enb_agent_instance_t * enb_agent_async_channel_info(mid_t mod_id, char *dst_ip,
} }
int enb_agent_async_msg_send(void *data, int size, int priority, void *channel_info) { int enb_agent_async_msg_send(void *data, int size, int priority, void *channel_info) {
enb_agent_instance_t *channel; enb_agent_async_channel_t *channel;
channel = (enb_agent_instance_t *)channel_info; channel = (enb_agent_channel_t *)channel_info;
return message_put(channel->send_queue, data, size, priority); return message_put(channel->send_queue, data, size, priority);
} }
int enb_agent_async_msg_recv(void **data, int *size, int *priority, void *channel_info) { int enb_agent_async_msg_recv(void **data, int *size, int *priority, void *channel_info) {
enb_agent_instance_t *channel; enb_agent_async_channel_t *channel;
channel = (enb_agent_instance_t *)channel_info; channel = (enb_agent_async_channel_t *)channel_info;
return message_get(channel->receive_queue, data, size, priority); return message_get(channel->receive_queue, data, size, priority);
} }
void enb_agent_async_release(enb_agent_channel_t *channel) { void enb_agent_async_release(enb_agent_channel_t *channel) {
enb_agent_instance_t *channel_info; enb_agent_async_channel_t *channel_info;
channel_info = (enb_agent_instance_t *) channel->channel_info; channel_info = (enb_agent_async_channel_t *) channel->channel_info;
destroy_link_manager(channel_info->manager); destroy_link_manager(channel_info->manager);
......
...@@ -39,7 +39,15 @@ ...@@ -39,7 +39,15 @@
#include "enb_agent_net_comm.h" #include "enb_agent_net_comm.h"
enb_agent_instance_t * enb_agent_async_channel_info(mid_t mod_id, char *dst_ip, uint16_t dst_port); typedef struct {
mid_t enb_id;
socket_link_t *link;
message_queue_t *send_queue;
message_queue_t *receive_queue;
link_manager_t *manager;
} enb_agent_async_channel_t;
enb_agent_async_channel_t * enb_agent_async_channel_info(mid_t mod_id, char *dst_ip, uint16_t dst_port);
int enb_agent_async_msg_send(void *data, int size, int priority, void *channel_info); int enb_agent_async_msg_send(void *data, int size, int priority, void *channel_info);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "enb_agent_net_comm.h" #include "enb_agent_net_comm.h"
#include "log.h" #include "log.h"
enb_agent_channel_t *agent_channel[NUM_MAX_ENB_AGENT][ENB_AGENT_MAX]; enb_agent_channel_t *agent_channel[NUM_MAX_ENB][ENB_AGENT_MAX];
enb_agent_channel_instance_t channel_instance; enb_agent_channel_instance_t channel_instance;
int enb_agent_channel_id = 0; int enb_agent_channel_id = 0;
...@@ -146,7 +146,7 @@ int enb_agent_destroy_channel(int channel_id) { ...@@ -146,7 +146,7 @@ int enb_agent_destroy_channel(int channel_id) {
} }
/*Unregister the channel from all agents*/ /*Unregister the channel from all agents*/
for (i = 0; i < NUM_MAX_ENB_AGENT; i++) { for (i = 0; i < NUM_MAX_ENB; i++) {
for (j = 0; j < ENB_AGENT_MAX; j++) { for (j = 0; j < ENB_AGENT_MAX; j++) {
if (agent_channel[i][j] != NULL) { if (agent_channel[i][j] != NULL) {
if (agent_channel[i][j]->channel_id == e->channel_id) { if (agent_channel[i][j]->channel_id == e->channel_id) {
...@@ -170,7 +170,7 @@ err_code_t enb_agent_init_channel_container(void) { ...@@ -170,7 +170,7 @@ err_code_t enb_agent_init_channel_container(void) {
RB_INIT(&channel_instance.enb_agent_head); RB_INIT(&channel_instance.enb_agent_head);
for (i = 0; i < NUM_MAX_ENB_AGENT; i++) { for (i = 0; i < NUM_MAX_ENB; i++) {
for (j = 0; j < ENB_AGENT_MAX; j++) { for (j = 0; j < ENB_AGENT_MAX; j++) {
agent_channel[i][j] == NULL; agent_channel[i][j] == NULL;
} }
......
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