flexran_agent_net_comm.h 3.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.0  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */ 
21

22 23
/*! \file flexran_agent_net_comm.h
 * \brief FlexRAN agent network interface abstraction 
24 25 26 27
 * \autho Xenofon Foukas
 * \date 2016
 * \version 0.1
 */
28 29
#ifndef FLEXRAN_AGENT_NET_COMM_H_
#define FLEXRAN_AGENT_NET_COMM_H_
30

31
#include "flexran_agent_defs.h"
32 33 34 35

#include "tree.h"

/*Channel related information used for Tx/Rx of protocol messages*/
36 37
typedef struct flexran_agent_channel_s {
  RB_ENTRY(flexran_agent_channel_s) entry;
38 39 40 41 42
int channel_id;
void *channel_info;
/*Callbacks for channel message Tx and Rx*/
int (*msg_send)(void *data, int size, int priority, void *channel_info);
int (*msg_recv)(void **data, int *size, int *priority, void *channel_info);
43 44
void (*release)(struct flexran_agent_channel_s *channel);
} flexran_agent_channel_t;
45

46 47 48
typedef struct flexran_agent_channel_instance_s{
  RB_HEAD(flexran_agent_channel_map, flexran_agent_channel_s) flexran_agent_head;
} flexran_agent_channel_instance_t;
49 50

/*Send and receive messages using the channel registered for a specific agent*/
51 52
int flexran_agent_msg_send(mid_t mod_id, agent_id_t agent_id, void *data, int size, int priority);
int flexran_agent_msg_recv(mid_t mod_id, agent_id_t agent_id, void **data, int *size, int *priority);
53

54
/*Register a channel to an agent. Use FLEXRAN_AGENT_MAX to register the
55
 *same channel to all agents*/
56
int flexran_agent_register_channel(mid_t mod_id, flexran_agent_channel_t *channel, agent_id_t agent_id);
57

58 59
/*Unregister the current channel of an agent. Use FLEXRAN_AGENT_MAX to unregister all channels*/
void flexran_agent_unregister_channel(mid_t mod_id, agent_id_t agent_id);
60 61

/*Create a new channel. Returns the id of the new channel or negative number otherwise*/
62 63 64 65
int flexran_agent_create_channel(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),
				 void (*release)(flexran_agent_channel_t *channel));
66 67

/*Unregister a channel from all agents and destroy it. Returns 0 in case of success*/
68
int flexran_agent_destroy_channel(int channel_id);
69 70

/*Return an agent communication channel based on its id*/
71
flexran_agent_channel_t * get_channel(int channel_id);
72 73

/*Should be called before performing any channel operations*/
74
err_code_t flexran_agent_init_channel_container(void);
75

76
int flexran_agent_compare_channel(struct flexran_agent_channel_s *a, struct flexran_agent_channel_s *b);
77 78

/* RB_PROTOTYPE is for .h files */
79
RB_PROTOTYPE(flexran_agent_channel_map, flexran_agent_channel_s, entry, flexran_agent_compare_channel);
80

81
#endif /*FLEXRAN_AGENT_COMM_H_*/