diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 8cd37613fa7425fa6b31ac3133eaa7388705c4d1..56ee7b71d37f53e873adc6148b63d66e4c00eef0 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -748,6 +748,7 @@ if (ENB_AGENT_SB_IF) ${OPENAIR2_DIR}/ENB_APP/enb_agent.c ${OPENAIR2_DIR}/ENB_APP/enb_agent_task_manager.c ${OPENAIR2_DIR}/ENB_APP/enb_agent_net_comm.c + ${OPENAIR2_DIR}/ENB_APP/enb_agent_async.c ) set(ENB_AGENT_LIB ENB_AGENT) #include_directories(${OPENAIR2_DIR}/ENB_APP) diff --git a/openair2/ENB_APP/enb_agent_async.c b/openair2/ENB_APP/enb_agent_async.c new file mode 100644 index 0000000000000000000000000000000000000000..962e1a81ede726eff67c0ed8937391f713c1f0f8 --- /dev/null +++ b/openair2/ENB_APP/enb_agent_async.c @@ -0,0 +1,107 @@ +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2014 Eurecom + + OpenAirInterface is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + + OpenAirInterface is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OpenAirInterface.The full GNU General Public License is + included in this distribution in the file called "COPYING". If not, + see <http://www.gnu.org/licenses/>. + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr + + Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France. + + *******************************************************************************/ + +/*! \file enb_agent_async.c + * \brief channel implementation for async interface + * \author Xenofon Foukas + * \date 2016 + * \version 0.1 + */ + +#include "enb_agent_async.h" +#include "enb_agent_defs.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_instance_t *channel; + channel = (enb_agent_instance_t *) malloc(sizeof(enb_agent_instance_t)); + + if (channel == NULL) + goto error; + + channel->mod_id = mod_id; + /*Create a socket*/ + channel->link = new_link_client(dst_ip, dst_port); + if (channel->link == NULL) goto error; + + LOG_I(ENB_AGENT,"starting enb agent client for module id %d on ipv4 %s, port %d\n", + channel->mod_id, + dst_ip, + dst_port); + + /* + * create a message queue + */ + + 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; + + /* + * create a link manager + */ + channel->manager = create_link_manager(channel->send_queue, channel->receive_queue, channel->link); + if (channel->manager == NULL) goto error; + + return channel; + + error: + LOG_I(ENB_AGENT,"there was an error\n"); + return 1; +} + +int enb_agent_async_msg_send(void *data, int size, int priority, void *channel_info) { + enb_agent_instance_t *channel; + channel = (enb_agent_instance_t *)channel_info; + + return message_put(channel->send_queue, data, size, priority); +} + +int enb_agent_async_msg_recv(void **data, int *size, int *priority, void *channel_info) { + enb_agent_instance_t *channel; + channel = (enb_agent_instance_t *)channel_info; + + return message_get(channel->receive_queue, data, size, priority); +} + +void enb_agent_async_release(enb_agent_channel_t *channel) { + enb_agent_instance_t *channel_info; + channel_info = (enb_agent_instance_t *) 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); +} diff --git a/openair2/ENB_APP/enb_agent_async.h b/openair2/ENB_APP/enb_agent_async.h new file mode 100644 index 0000000000000000000000000000000000000000..53614cc87df723ffa85e4ac701ccf34fc1b616e5 --- /dev/null +++ b/openair2/ENB_APP/enb_agent_async.h @@ -0,0 +1,51 @@ +/******************************************************************************* + OpenAirInterface + Copyright(c) 1999 - 2014 Eurecom + + OpenAirInterface is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + + OpenAirInterface is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OpenAirInterface.The full GNU General Public License is + included in this distribution in the file called "COPYING". If not, + see <http://www.gnu.org/licenses/>. + + Contact Information + OpenAirInterface Admin: openair_admin@eurecom.fr + OpenAirInterface Tech : openair_tech@eurecom.fr + OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr + + Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France. + + *******************************************************************************/ + +/*! \file enb_agent_async.h + * \brief channel implementation for async interface + * \author Xenofon Foukas + * \date 2016 + * \version 0.1 + */ + +#ifndef ENB_AGENT_ASYNC_H_ +#define ENB_AGENT_ASYNC_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); + +int enb_agent_async_msg_send(void *data, int size, int priority, void *channel_info); + +int enb_agent_async_msg_recv(void **data, int *size, int *priority, void *channel_info); + +void enb_agent_async_release(enb_agent_channel_t *channel); + + +#endif /*ENB_AGENT_ASYNC_H_*/