flexran_agent_common.h 7.9 KB
Newer Older
1 2 3 4 5
/*
 * 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
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * 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
/*! \file flexran_agent_common.h
23
 * \brief common message primitves and utilities 
shahab's avatar
shahab committed
24 25
 * \author Xenofon Foukas, Mohamed Kassem and Navid Nikaein and shahab SHARIAT BAGHERI
 * \date 2017
26 27 28 29 30
 * \version 0.1
 */



31 32
#ifndef FLEXRAN_AGENT_COMMON_H_
#define FLEXRAN_AGENT_COMMON_H_
33

34
#include <time.h>
35 36

#include "header.pb-c.h"
37
#include "flexran.pb-c.h"
38 39
#include "stats_messages.pb-c.h"
#include "stats_common.pb-c.h"
shahab's avatar
shahab committed
40 41
#include "flexran_agent_ran_api.h"
#include "flexran_agent_net_comm.h"
42
#include "flexran_agent_defs.h"
43
#include "enb_config.h"
44 45 46 47 48 49

#include "LAYER2/RLC/rlc.h"

# include "tree.h"
# include "intertask_interface.h"

50
#define FLEXRAN_VERSION 0
51

52
typedef int (*flexran_agent_message_decoded_callback)(
53
	mid_t mod_id,
54
       	const void *params,
55
	Protocol__FlexranMessage **msg
56 57
);

58
typedef int (*flexran_agent_message_destruction_callback)(
59
	Protocol__FlexranMessage *msg
60 61
);

shahab's avatar
shahab committed
62 63 64 65 66 67 68 69 70 71 72 73 74
typedef struct {
 
  uint8_t is_initialized;
  volatile uint8_t cont_update;
  xid_t xid;
  Protocol__FlexranMessage *stats_req;
  Protocol__FlexranMessage *prev_stats_reply;

  pthread_mutex_t *mutex;
} stats_updates_context_t;

stats_updates_context_t stats_context[NUM_MAX_ENB];

75
/**********************************
76
 * FlexRAN protocol messages helper 
77 78 79
 * functions and generic handlers
 **********************************/

80
/* Helper functions for message (de)serialization */
81 82
int flexran_agent_serialize_message(Protocol__FlexranMessage *msg, void **buf, int *size);
int flexran_agent_deserialize_message(void *data, int size, Protocol__FlexranMessage **msg);
83

84 85
/* Serialize message and then destroy the input flexran msg. Should be called when protocol
   message is created dynamically */
86
void * flexran_agent_pack_message(Protocol__FlexranMessage *msg, 
87
			      int * size);
88

89
/* Calls destructor of the given message */
90
err_code_t flexran_agent_destroy_flexran_message(Protocol__FlexranMessage *msg);
91

92
/* Function to create the header for any FlexRAN protocol message */
93
int flexran_create_header(xid_t xid, Protocol__FlexType type, Protocol__FlexHeader **header);
94

95
/* Hello protocol message constructor and destructor */
96 97
int flexran_agent_hello(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_hello(Protocol__FlexranMessage *msg);
98

99
/* Echo request protocol message constructor and destructor */
100 101
int flexran_agent_echo_request(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_echo_request(Protocol__FlexranMessage *msg);
102

103
/* Echo reply protocol message constructor and destructor */
104 105
int flexran_agent_echo_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_echo_reply(Protocol__FlexranMessage *msg);
106

107
/* eNodeB configuration reply message constructor and destructor */
108 109
int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_enb_config_reply(Protocol__FlexranMessage *msg);
110

111
/* UE configuration reply message constructor and destructor */
112 113
int flexran_agent_ue_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_ue_config_reply(Protocol__FlexranMessage *msg);
114

115
/* Logical channel reply configuration message constructor and destructor */
116 117
int flexran_agent_lc_config_reply(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_lc_config_reply(Protocol__FlexranMessage *msg);
118

119
/* eNodeB configuration request message constructor and destructor */
120 121
int flexran_agent_enb_config_request(mid_t mod_id, const void* params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_enb_config_request(Protocol__FlexranMessage *msg);
122

123 124
/* UE configuration request message constructor */
/* TODO: Need to define and implement destructor */
125
int flexran_agent_destroy_ue_config_request(Protocol__FlexranMessage *msg);
126

127 128
/* Logical channel configuration request message constructor */
/* TODO: Need to define and implement destructor */
129
int flexran_agent_destroy_lc_config_request(Protocol__FlexranMessage *msg);
130

131
/* Control delegation message constructor and destructor */
132 133
int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_control_delegation(Protocol__FlexranMessage *msg);
134

135
/* Policy reconfiguration message constructor and destructor */
136 137
int flexran_agent_reconfiguration(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_agent_reconfiguration(Protocol__FlexranMessage *msg);
138

shahab's avatar
shahab committed
139 140 141 142 143
/* rrc triggering measurement message constructor and destructor */
int flexran_agent_rrc_measurement(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_rrc_measurement(Protocol__FlexranMessage *msg);


144
/* FlexRAN protocol message dispatcher function */
145
Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id, 
146 147 148
						    uint8_t *data, 
						    uint32_t size);

149
/* Function to be used to send a message to a dispatcher once the appropriate event is triggered. */
150
Protocol__FlexranMessage *flexran_agent_handle_timed_task(void *args);
151

shahab's avatar
shahab committed
152 153
/*Top level Statistics hanlder*/
int flexran_agent_handle_stats(mid_t mod_id, const void *params, Protocol__FlexranMessage **msg);
154

shahab's avatar
shahab committed
155 156
/* Function to be used to handle reply message . */
int flexran_agent_stats_reply(mid_t enb_id, xid_t xid, const report_config_t *report_config, Protocol__FlexranMessage **msg);
157

shahab's avatar
shahab committed
158
/* Top level Statistics request protocol message constructor and destructor */
shahab's avatar
shahab committed
159 160
int flexran_agent_stats_request(mid_t mod_id, xid_t xid, const stats_request_config_t *report_config, Protocol__FlexranMessage **msg);
int flexran_agent_destroy_stats_request(Protocol__FlexranMessage *msg);
161

shahab's avatar
shahab committed
162
err_code_t flexran_agent_init_cont_stats_update(mid_t mod_id);
163

shahab's avatar
shahab committed
164
void flexran_agent_send_update_stats(mid_t mod_id);
165

shahab's avatar
shahab committed
166
err_code_t flexran_agent_enable_cont_stats_update(mid_t mod_id, xid_t xid, stats_request_config_t *stats_req) ;
shahab's avatar
shahab committed
167
err_code_t flexran_agent_disable_cont_stats_update(mid_t mod_id);
168

169 170 171 172 173 174 175
/* Handle a received eNB config reply message as an "order" to reconfigure. It
 * does not come as a reconfiguration message as this is a "structured"
 * ProtoBuf message (as opposed to "unstructured" YAML). There is no destructor
 * since we do not reply to this message (yet). Instead, the controller has to
 * issue another eNB config request message. */
int flexran_agent_handle_enb_config_reply(mid_t mod_id, const void* params, Protocol__FlexranMessage **msg);

176 177 178 179 180 181 182 183
/* Handle a received UE config reply message as an "order" to reconfigure the
 * association of a UE to a slice.  It does not come as a reconfiguration
 * message as this is a "structured" ProtoBuf message (as opposed to
 * "unstructured" YAML). There is no destructor since we do not reply to this
 * message (yet). Instead, the controller has to issue another eNB config
 * request message. */
int flexran_agent_handle_ue_config_reply(mid_t mod_id, const void* params, Protocol__FlexranMessage **msg);

184
#endif