defs.h 24.2 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
/*! \file RRC/LITE/defs.h
23 24 25
* \brief RRC struct definitions and function prototypes
* \author Navid Nikaein and Raymond Knopp
* \date 2010 - 2014
26 27
* \version 1.0
* \company Eurecom
28
* \email: navid.nikaein@eurecom.fr, raymond.knopp@eurecom.fr
29 30 31 32 33 34 35 36 37 38 39
*/

#ifndef __OPENAIR_RRC_DEFS_H__
#define __OPENAIR_RRC_DEFS_H__

#ifdef USER_MODE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif

40
#include "collection/tree.h"
winckel's avatar
winckel committed
41
#include "rrc_types.h"
42 43
#include "PHY/defs.h"
#include "COMMON/platform_constants.h"
44
#include "COMMON/platform_types.h"
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

#include "COMMON/mac_rrc_primitives.h"
#include "LAYER2/MAC/defs.h"

//#include "COMMON/openair_defs.h"
#ifndef USER_MODE
#include <rtai.h>
#endif

#include "SystemInformationBlockType1.h"
#include "SystemInformation.h"
#include "RRCConnectionReconfiguration.h"
#include "RRCConnectionReconfigurationComplete.h"
#include "RRCConnectionSetup.h"
#include "RRCConnectionSetupComplete.h"
#include "RRCConnectionRequest.h"
61
#include "RRCConnectionReestablishmentRequest.h"
62 63
#include "BCCH-DL-SCH-Message.h"
#include "BCCH-BCH-Message.h"
Cedric Roux's avatar
Cedric Roux committed
64
#if defined(Rel10) || defined(Rel14)
65 66
#include "MCCH-Message.h"
#include "MBSFNAreaConfiguration-r9.h"
67
#include "SCellToAddMod-r10.h"
68
#endif
69 70
#include "AS-Config.h"
#include "AS-Context.h"
71 72 73
#include "UE-EUTRA-Capability.h"
#include "MeasResults.h"

Cedric Roux's avatar
Cedric Roux committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
/* correct Rel(8|10)/Rel14 differences
 * the code is in favor of Rel14, those defines do the translation
 */
#if !defined(Rel14)
#  define CipheringAlgorithm_r12_t e_SecurityAlgorithmConfig__cipheringAlgorithm
#  define CipheringAlgorithm_r12_eea0 SecurityAlgorithmConfig__cipheringAlgorithm_eea0
#  define CipheringAlgorithm_r12_eea1 SecurityAlgorithmConfig__cipheringAlgorithm_eea1
#  define CipheringAlgorithm_r12_eea2 SecurityAlgorithmConfig__cipheringAlgorithm_eea2
#  define CipheringAlgorithm_r12_spare1 SecurityAlgorithmConfig__cipheringAlgorithm_spare1
#  define Alpha_r12_al0 UplinkPowerControlCommon__alpha_al0
#  define Alpha_r12_al04 UplinkPowerControlCommon__alpha_al04
#  define Alpha_r12_al05 UplinkPowerControlCommon__alpha_al05
#  define Alpha_r12_al06 UplinkPowerControlCommon__alpha_al06
#  define Alpha_r12_al07 UplinkPowerControlCommon__alpha_al07
#  define Alpha_r12_al08 UplinkPowerControlCommon__alpha_al08
#  define Alpha_r12_al09 UplinkPowerControlCommon__alpha_al09
#  define Alpha_r12_al1 UplinkPowerControlCommon__alpha_al1
#  define PreambleTransMax_n3 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3
#  define PreambleTransMax_n4 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4
#  define PreambleTransMax_n5 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5
#  define PreambleTransMax_n6 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6
#  define PreambleTransMax_n7 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7
#  define PreambleTransMax_n8 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8
#  define PreambleTransMax_n10 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10
#  define PreambleTransMax_n20 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20
#  define PreambleTransMax_n50 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50
#  define PreambleTransMax_n100 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100
#  define PreambleTransMax_n200 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200
#  define PeriodicBSR_Timer_r12_sf5 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf5
#  define PeriodicBSR_Timer_r12_sf10 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf10
#  define PeriodicBSR_Timer_r12_sf16 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf16
#  define PeriodicBSR_Timer_r12_sf20 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf20
#  define PeriodicBSR_Timer_r12_sf32 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf32
#  define PeriodicBSR_Timer_r12_sf40 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf40
#  define PeriodicBSR_Timer_r12_sf64 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf64
#  define PeriodicBSR_Timer_r12_sf80 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf80
#  define PeriodicBSR_Timer_r12_sf128 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf128
#  define PeriodicBSR_Timer_r12_sf160 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf160
#  define PeriodicBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf320
#  define PeriodicBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf640
#  define PeriodicBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf1280
#  define PeriodicBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf2560
#  define PeriodicBSR_Timer_r12_infinity MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity
#  define RetxBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf320
#  define RetxBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf640
#  define RetxBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf1280
#  define RetxBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560
#  define RetxBSR_Timer_r12_sf5120 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf5120
#  define RetxBSR_Timer_r12_sf10240 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf10240
#endif

125
// This corrects something generated by asn1c which is different between Rel8 and Rel10
Cedric Roux's avatar
Cedric Roux committed
126
#if !defined(Rel10) && !defined(Rel14)
127 128 129 130 131 132 133 134 135 136 137 138
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member SystemInformation_r8_IEs_sib_TypeAndInfo_Member
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11
#endif
139
/*
Cedric Roux's avatar
Cedric Roux committed
140
#if defined(Rel10) || defined(Rel14)
141 142
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib12_v920
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib13_v920
143
#endif
144
*/
145 146 147 148 149 150 151
//#include "L3_rrc_defs.h"
#ifndef NO_RRM
#include "L3_rrc_interface.h"
#include "rrc_rrm_msg.h"
#include "rrc_rrm_interface.h"
#endif

152 153 154 155
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif

Cedric Roux's avatar
Cedric Roux committed
156 157 158 159 160 161 162 163
/* TODO: be sure this include is correct.
 * It solves a problem of compilation of the RRH GW,
 * issue #186.
 */
#if !defined(ENABLE_ITTI)
# include "as_message.h"
#endif

164 165 166 167
#if defined(ENABLE_USE_MME)
# include "commonDef.h"
#endif

168
#if ENABLE_RAL
Lionel Gauthier's avatar
Lionel Gauthier committed
169 170 171
# include "collection/hashtable/obj_hashtable.h"
#endif

172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
//--------
typedef unsigned int uid_t;
#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((NUMBER_OF_UE_MAX/8)/sizeof(unsigned int)) + 1)
typedef struct uid_linear_allocator_s {
  unsigned int   bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE];
} uid_allocator_t;

//--------



#define PROTOCOL_RRC_CTXT_UE_FMT           PROTOCOL_CTXT_FMT
#define PROTOCOL_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)

#define PROTOCOL_RRC_CTXT_FMT           PROTOCOL_CTXT_FMT
#define PROTOCOL_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)
188 189
/** @defgroup _rrc RRC 
 * @ingroup _oai2
190 191 192
 * @{
 */

193
#if ENABLE_RAL
Lionel Gauthier's avatar
Lionel Gauthier committed
194
typedef struct rrc_ral_threshold_key_s {
195 196 197
  ral_link_param_type_t   link_param_type;
  ral_threshold_t         threshold;
} rrc_ral_threshold_key_t;
Lionel Gauthier's avatar
Lionel Gauthier committed
198 199
#endif

200 201
//#define NUM_PRECONFIGURED_LCHAN (NB_CH_CX*2)  //BCCH, CCCH

202 203
#define UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!!
#define UE_INDEX_INVALID  ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! used to be -1
winckel's avatar
winckel committed
204

winckel's avatar
winckel committed
205
typedef enum UE_STATE_e {
winckel's avatar
winckel committed
206 207
  RRC_INACTIVE=0,
  RRC_IDLE,
208 209
  RRC_SI_RECEIVED,
  RRC_CONNECTED,
210 211
  RRC_RECONFIGURED,
  RRC_HO_EXECUTION
212 213
} UE_STATE_t;

winckel's avatar
winckel committed
214
typedef enum HO_STATE_e {
215 216 217 218
  HO_IDLE=0,
  HO_MEASURMENT,
  HO_PREPARE,
  HO_CMD, // initiated by the src eNB
219 220 221 222 223
  HO_COMPLETE, // initiated by the target eNB

  HO_REQUEST,
  HO_ACK,
  HO_CONFIGURED,
224 225
} HO_STATE_t;

226 227
//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG
#define RRM_FREE(p)       if ( (p) != NULL) { free(p) ; p=NULL ; }
228 229 230
#define RRM_MALLOC(t,n)   (t *) malloc16( sizeof(t) * n )
#define RRM_CALLOC(t,n)   (t *) malloc16( sizeof(t) * n)
#define RRM_CALLOC2(t,s)  (t *) malloc16( s )
231

232 233 234
#define MAX_MEAS_OBJ 6
#define MAX_MEAS_CONFIG 6
#define MAX_MEAS_ID 6
235 236

#define PAYLOAD_SIZE_MAX 1024
237
#define RRC_BUF_SIZE 255
238
#define UNDEF_SECURITY_MODE 0xff
239
#define NO_SECURITY_MODE 0x20 // 0x33
240 241 242 243

#define CBA_OFFSET        0xfff4
// #define NUM_MAX_CBA_GROUP 4 // in the platform_constants

244 245 246
/* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */
#define RRC_TRANSACTION_IDENTIFIER_NUMBER  3

winckel's avatar
winckel committed
247
typedef struct UE_RRC_INFO_s {
248
  UE_STATE_t State;
249
  uint8_t SIB1systemInfoValueTag;
250 251
  uint32_t SIStatus;
  uint32_t SIcnt;
Cedric Roux's avatar
Cedric Roux committed
252
#if defined(Rel10) || defined(Rel14)
253
  uint8_t MCCHStatus[8]; // MAX_MBSFN_AREA
254
#endif
255
  uint8_t SIwindowsize; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40
256
  uint8_t handoverTarget;
257
  HO_STATE_t ho_state;
258
  uint16_t SIperiod; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120
259
  unsigned short UE_index;
260 261 262 263 264 265 266 267
  uint32_t T300_active;
  uint32_t T300_cnt;
  uint32_t T304_active;
  uint32_t T304_cnt;
  uint32_t T310_active;
  uint32_t T310_cnt;
  uint32_t N310_cnt;
  uint32_t N311_cnt;
268
  rnti_t   rnti;
winckel's avatar
winckel committed
269
} __attribute__ ((__packed__)) UE_RRC_INFO;
270

271
typedef struct UE_S_TMSI_s {
gauthier's avatar
gauthier committed
272 273 274
  boolean_t  presence;
  mme_code_t mme_code;
  m_tmsi_t   m_tmsi;
winckel's avatar
winckel committed
275
} __attribute__ ((__packed__)) UE_S_TMSI;
276

277
#if defined(ENABLE_ITTI)
winckel's avatar
winckel committed
278
typedef enum e_rab_satus_e {
279
  E_RAB_STATUS_NEW,
280 281
  E_RAB_STATUS_DONE, // from the eNB perspective
  E_RAB_STATUS_ESTABLISHED, // get the reconfigurationcomplete form UE
282
  E_RAB_STATUS_REESTABLISHED, // after HO
283
  E_RAB_STATUS_FAILED,
284
  E_RAB_STATUS_RELEASED
winckel's avatar
winckel committed
285 286
} e_rab_status_t;

287
typedef struct e_rab_param_s {
288 289
  e_rab_t param;
  uint8_t status;
290
  uint8_t xid; // transaction_id
winckel's avatar
winckel committed
291
} __attribute__ ((__packed__)) e_rab_param_t;
292 293
#endif

294 295


296
/* Intermediate structure for Handover management. Associated per-UE in eNB_RRC_INST */
winckel's avatar
winckel committed
297
typedef struct HANDOVER_INFO_s {
298 299
  uint8_t ho_prepare;
  uint8_t ho_complete;
300
  HO_STATE_t state; //current state of handover
301 302
  uint8_t modid_s; //module_idP of serving cell
  uint8_t modid_t; //module_idP of target cell
303 304
  uint16_t ueid_s; //UE index in serving cell
  uint16_t ueid_t; //UE index in target cell
305 306
  AS_Config_t as_config; /* these two parameters are taken from 36.331 section 10.2.2: HandoverPreparationInformation-r8-IEs */
  AS_Context_t as_context; /* They are mandatory for HO */
307 308
  uint8_t buf[RRC_BUF_SIZE];  /* ASN.1 encoded handoverCommandMessage */
  int size;   /* size of above message in bytes */
309 310
  /* TODO: to remove or not? */
  int source_x2id;
winckel's avatar
winckel committed
311
} HANDOVER_INFO;
312 313 314

#define RRC_HEADER_SIZE_MAX 64
#define RRC_BUFFER_SIZE_MAX 1024
315
typedef struct {
316
  char Payload[RRC_BUFFER_SIZE_MAX];
317
  char Header[RRC_HEADER_SIZE_MAX];
318
  char payload_size;
319
} RRC_BUFFER;
320 321
#define RRC_BUFFER_SIZE sizeof(RRC_BUFFER)

winckel's avatar
winckel committed
322
typedef struct RB_INFO_s {
323
  uint16_t Rb_id;  //=Lchan_id
324 325
  LCHAN_DESC Lchan_desc[2];
  MAC_MEAS_REQ_ENTRY *Meas_entry;
winckel's avatar
winckel committed
326
} RB_INFO;
327

winckel's avatar
winckel committed
328
typedef struct SRB_INFO_s {
329
  uint16_t Srb_id;  //=Lchan_id
330 331
  RRC_BUFFER Rx_buffer;
  RRC_BUFFER Tx_buffer;
332 333
  LCHAN_DESC Lchan_desc[2];
  unsigned int Trans_id;
334
  uint8_t Active;
winckel's avatar
winckel committed
335
} SRB_INFO;
336

winckel's avatar
winckel committed
337
typedef struct RB_INFO_TABLE_ENTRY_s {
338
  RB_INFO Rb_info;
339 340 341
  uint8_t Active;
  uint32_t Next_check_frame;
  uint8_t Status;
winckel's avatar
winckel committed
342
} RB_INFO_TABLE_ENTRY;
343

winckel's avatar
winckel committed
344
typedef struct SRB_INFO_TABLE_ENTRY_s {
345
  SRB_INFO Srb_info;
346 347
  uint8_t Active;
  uint8_t Status;
348
  uint32_t Next_check_frame; 
349
} SRB_INFO_TABLE_ENTRY;
350

winckel's avatar
winckel committed
351
typedef struct MEAS_REPORT_LIST_s {
352
  MeasId_t measId;
353
  //CellsTriggeredList  cellsTriggeredList;//OPTIONAL
354
  uint32_t numberOfReportsSent;
355
} MEAS_REPORT_LIST;
356

winckel's avatar
winckel committed
357
typedef struct HANDOVER_INFO_UE_s {
358
  PhysCellId_t targetCellId;
359
  uint8_t measFlag;
winckel's avatar
winckel committed
360
} HANDOVER_INFO_UE;
361

362
typedef struct eNB_RRC_UE_s {
363
  uint8_t                            primaryCC_id;
Cedric Roux's avatar
Cedric Roux committed
364
#if defined(Rel10) || defined(Rel14)
365 366 367
  SCellToAddMod_r10_t                sCell_config[2];
#endif
  SRB_ToAddModList_t*                SRB_configList;
368
  SRB_ToAddModList_t*                SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER];
369
  DRB_ToAddModList_t*                DRB_configList;
370
  DRB_ToAddModList_t*                DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER];
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
  uint8_t                            DRB_active[8];
  struct PhysicalConfigDedicated*    physicalConfigDedicated;
  struct SPS_Config*                 sps_Config;
  MeasObjectToAddMod_t*              MeasObj[MAX_MEAS_OBJ];
  struct ReportConfigToAddMod*       ReportConfig[MAX_MEAS_CONFIG];
  struct QuantityConfig*             QuantityConfig;
  struct MeasIdToAddMod*             MeasId[MAX_MEAS_ID];
  MAC_MainConfig_t*                  mac_MainConfig;
  MeasGapConfig_t*                   measGapConfig;
  SRB_INFO                           SI;
  SRB_INFO                           Srb0;
  SRB_INFO_TABLE_ENTRY               Srb1;
  SRB_INFO_TABLE_ENTRY               Srb2;
  MeasConfig_t*                      measConfig;
  HANDOVER_INFO*                     handover_info;

#if defined(ENABLE_SECURITY)
  /* KeNB as derived from KASME received from EPC */
  uint8_t kenb[32];
390 391
  uint8_t nh[32];
  int8_t  nh_ncc;
392 393
#endif
  /* Used integrity/ciphering algorithms */
Cedric Roux's avatar
Cedric Roux committed
394
  CipheringAlgorithm_r12_t                          ciphering_algorithm;
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
  e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;

  uint8_t                            Status;
  rnti_t                             rnti;
  uint64_t                           random_ue_identity;

#if defined(ENABLE_ITTI)
  /* Information from UE RRC ConnectionRequest */
  UE_S_TMSI                          Initialue_identity_s_TMSI;
  EstablishmentCause_t               establishment_cause;

  /* Information from UE RRC ConnectionReestablishmentRequest */
  ReestablishmentCause_t             reestablishment_cause;

  /* UE id for initial connection to S1AP */
  uint16_t                           ue_initial_id;

  /* Information from S1AP initial_context_setup_req */
  uint32_t                           eNB_ue_s1ap_id :24;

  security_capabilities_t            security_capabilities;
416 417
  
  int                                next_hop_chain_count;
418

419 420
  uint8_t                            next_security_key[SECURITY_KEY_LENGTH];
  
421 422
  /* Total number of e_rab already setup in the list */
  uint8_t                           setup_e_rabs;
423 424 425
  /* Number of e_rab to be setup in the list */
  uint8_t                            nb_of_e_rabs;
  /* list of e_rab to be setup by RRC layers */
426
  e_rab_param_t                      e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB];
427 428 429 430 431 432
  /* UE aggregate maximum bitrate */
  ambr_t ue_ambr;
  /* Number of e_rab to be released in the list */
  uint8_t                           nb_e_rabs_tobereleased;
  /* list of e_rab to be released by RRC layers */
  uint8_t                           e_rabs_tobereleased[NB_RB_MAX];
433 434 435 436 437
  // LG: For GTPV1 TUNNELS
  uint32_t                           enb_gtp_teid[S1AP_MAX_E_RAB];
  transport_layer_addr_t             enb_gtp_addrs[S1AP_MAX_E_RAB];
  rb_id_t                            enb_gtp_ebi[S1AP_MAX_E_RAB];
#endif
438
  uint32_t                           ul_failure_timer;
439
  uint32_t                           ue_release_timer;
440
  uint32_t                           ue_release_timer_thres;
441 442 443
} eNB_RRC_UE_t;

typedef uid_t ue_uid_t;
444

445 446 447 448 449 450 451 452 453
typedef struct rrc_eNB_ue_context_s {
  /* Tree related data */
  RB_ENTRY(rrc_eNB_ue_context_s) entries;

  /* Uniquely identifies the UE between MME and eNB within the eNB.
   * This id is encoded on 24bits.
   */
  rnti_t         ue_id_rnti;

454
  // another key for protocol layers but should not be used as a key for RB tree
455 456 457 458 459
  ue_uid_t       local_uid;

  /* UE id for initial connection to S1AP */
  struct eNB_RRC_UE_s   ue_context;
} rrc_eNB_ue_context_t;
460

461
typedef struct {
462 463 464 465 466 467 468 469 470 471 472 473
  uint8_t                           *SIB1;
  uint8_t                           sizeof_SIB1;
  uint8_t                           *SIB23;
  uint8_t                           sizeof_SIB23;
  uint16_t                          physCellId;
  BCCH_BCH_Message_t                mib;
  BCCH_DL_SCH_Message_t             siblock1;
  BCCH_DL_SCH_Message_t             systemInformation;
  //  SystemInformation_t               systemInformation;
  SystemInformationBlockType1_t     *sib1;
  SystemInformationBlockType2_t     *sib2;
  SystemInformationBlockType3_t     *sib3;
Cedric Roux's avatar
Cedric Roux committed
474
#if defined(Rel10) || defined(Rel14)
475 476
  SystemInformationBlockType13_r9_t *sib13;
  uint8_t                           MBMS_flag;
477 478 479
  uint8_t                           num_mbsfn_sync_area;
  uint8_t                           **MCCH_MESSAGE; //  MAX_MBSFN_AREA
  uint8_t                           sizeof_MCCH_MESSAGE[8];// MAX_MBSFN_AREA
480
  MCCH_Message_t            mcch;
481
  MBSFNAreaConfiguration_r9_t       *mcch_message;
482
  SRB_INFO                          MCCH_MESS[8];// MAX_MBSFN_AREA
483
#endif
484 485 486 487
#ifdef CBA
  uint8_t                        num_active_cba_groups;
  uint16_t                       cba_rnti[NUM_MAX_CBA_GROUP];
#endif
488 489
  SRB_INFO                          SI;
  SRB_INFO                          Srb0;
490
} rrc_eNB_carrier_data_t;
491 492

typedef struct eNB_RRC_INST_s {
493
  rrc_eNB_carrier_data_t          carrier[MAX_NUM_CCs];
494 495
  uid_allocator_t                    uid_allocator; // for rrc_ue_head
  RB_HEAD(rrc_ue_tree_s, rrc_eNB_ue_context_s)     rrc_ue_head; // ue_context tree key search by rnti
496
  uint8_t                           HO_flag;
497
  uint8_t                            Nb_ue;
498
#if ENABLE_RAL
Lionel Gauthier's avatar
Lionel Gauthier committed
499 500
  obj_hash_table_t                  *ral_meas_thresholds;
#endif
501 502 503
  hash_table_t                      *initial_id2_s1ap_ids; // key is    content is rrc_ue_s1ap_ids_t
  hash_table_t                      *s1ap_id2_s1ap_ids   ; // key is    content is rrc_ue_s1ap_ids_t

504 505 506 507 508 509
#ifdef LOCALIZATION
  /// localization type, 0: power based, 1: time based
  uint8_t loc_type;
  /// epoch timestamp in millisecond, RRC
  int32_t reference_timestamp_ms;
  /// aggregate physical states every n millisecond
510
  int32_t aggregation_period_ms;
511 512
  /// localization list for aggregated measurements from PHY
  struct list loc_list;
513
#endif
514
  //RRC configuration
515
#if defined(ENABLE_ITTI)
516
  RrcConfigurationReq configuration;
517
#endif
518 519 520
} eNB_RRC_INST;

#define MAX_UE_CAPABILITY_SIZE 255
winckel's avatar
winckel committed
521
typedef struct OAI_UECapability_s {
522 523 524 525 526
  uint8_t sdu[MAX_UE_CAPABILITY_SIZE];
  uint8_t sdu_size;
  UE_EUTRA_Capability_t *UE_EUTRA_Capability;
} OAI_UECapability_t;

winckel's avatar
winckel committed
527
typedef struct UE_RRC_INST_s {
winckel's avatar
winckel committed
528 529
  Rrc_State_t     RrcState;
  Rrc_Sub_State_t RrcSubState;
530
# if defined(ENABLE_USE_MME)
winckel's avatar
winckel committed
531 532 533
  plmn_t          plmnID;
  Byte_t          rat;
  as_nas_info_t   initialNasMsg;
534
# endif
Raymond Knopp's avatar
 
Raymond Knopp committed
535
  OAI_UECapability_t *UECap;
536 537 538 539 540 541
  uint8_t *UECapability;
  uint8_t UECapability_size;
  UE_RRC_INFO Info[NB_SIG_CNX_UE];
  SRB_INFO Srb0[NB_SIG_CNX_UE];
  SRB_INFO_TABLE_ENTRY Srb1[NB_CNX_UE];
  SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE];
542
  HANDOVER_INFO_UE HandoverInfoUe;
543 544 545 546 547 548
  uint8_t *SIB1[NB_CNX_UE];
  uint8_t sizeof_SIB1[NB_CNX_UE];
  uint8_t *SI[NB_CNX_UE];
  uint8_t sizeof_SI[NB_CNX_UE];
  uint8_t SIB1Status[NB_CNX_UE];
  uint8_t SIStatus[NB_CNX_UE];
549
  SystemInformationBlockType1_t *sib1[NB_CNX_UE];
550
  SystemInformation_t *si[NB_CNX_UE]; //!< Temporary storage for an SI message. Decoding happens in decode_SI().
551 552 553 554 555 556 557 558 559 560
  SystemInformationBlockType2_t *sib2[NB_CNX_UE];
  SystemInformationBlockType3_t *sib3[NB_CNX_UE];
  SystemInformationBlockType4_t *sib4[NB_CNX_UE];
  SystemInformationBlockType5_t *sib5[NB_CNX_UE];
  SystemInformationBlockType6_t *sib6[NB_CNX_UE];
  SystemInformationBlockType7_t *sib7[NB_CNX_UE];
  SystemInformationBlockType8_t *sib8[NB_CNX_UE];
  SystemInformationBlockType9_t *sib9[NB_CNX_UE];
  SystemInformationBlockType10_t *sib10[NB_CNX_UE];
  SystemInformationBlockType11_t *sib11[NB_CNX_UE];
561

Cedric Roux's avatar
Cedric Roux committed
562
#if defined(Rel10) || defined(Rel14)
563
  uint8_t                           MBMS_flag;
564 565 566
  uint8_t *MCCH_MESSAGE[NB_CNX_UE];
  uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE];
  uint8_t MCCH_MESSAGEStatus[NB_CNX_UE];
567
  MBSFNAreaConfiguration_r9_t       *mcch_message[NB_CNX_UE];
568 569
  SystemInformationBlockType12_r9_t *sib12[NB_CNX_UE];
  SystemInformationBlockType13_r9_t *sib13[NB_CNX_UE];
570
#endif
571 572 573 574
#ifdef CBA
  uint8_t                         num_active_cba_groups;
  uint16_t                        cba_rnti[NUM_MAX_CBA_GROUP];
#endif
575
  uint8_t                         num_srb;
576 577 578
  struct SRB_ToAddMod             *SRB1_config[NB_CNX_UE];
  struct SRB_ToAddMod             *SRB2_config[NB_CNX_UE];
  struct DRB_ToAddMod             *DRB_config[NB_CNX_UE][8];
579
  rb_id_t                         *defaultDRB; // remember the ID of the default DRB
580 581 582 583
  MeasObjectToAddMod_t            *MeasObj[NB_CNX_UE][MAX_MEAS_OBJ];
  struct ReportConfigToAddMod     *ReportConfig[NB_CNX_UE][MAX_MEAS_CONFIG];
  struct QuantityConfig           *QuantityConfig[NB_CNX_UE];
  struct MeasIdToAddMod           *MeasId[NB_CNX_UE][MAX_MEAS_ID];
584 585
  MEAS_REPORT_LIST      *measReportList[NB_CNX_UE][MAX_MEAS_ID];
  uint32_t           measTimer[NB_CNX_UE][MAX_MEAS_ID][6]; // 6 neighboring cells
586
  RSRP_Range_t                    s_measure;
587
  struct MeasConfig__speedStatePars *speedStatePars;
588 589 590 591
  struct PhysicalConfigDedicated  *physicalConfigDedicated[NB_CNX_UE];
  struct SPS_Config               *sps_Config[NB_CNX_UE];
  MAC_MainConfig_t                *mac_MainConfig[NB_CNX_UE];
  MeasGapConfig_t                 *measGapConfig[NB_CNX_UE];
592
  double                          filter_coeff_rsrp; // [7] ???
593
  double                          filter_coeff_rsrq; // [7] ???
594 595 596 597
  float                           rsrp_db[7];
  float                           rsrq_db[7];
  float                           rsrp_db_filtered[7];
  float                           rsrq_db_filtered[7];
598
#if ENABLE_RAL
Lionel Gauthier's avatar
Lionel Gauthier committed
599
  obj_hash_table_t               *ral_meas_thresholds;
600
  ral_transaction_id_t            scan_transaction_id;
Lionel Gauthier's avatar
Lionel Gauthier committed
601
#endif
602 603 604
#if defined(ENABLE_SECURITY)
  /* KeNB as computed from parameters within USIM card */
  uint8_t kenb[32];
605 606
  uint8_t nh[32];
  int8_t  nh_ncc;
607 608 609
#endif

  /* Used integrity/ciphering algorithms */
Cedric Roux's avatar
Cedric Roux committed
610
  CipheringAlgorithm_r12_t                          ciphering_algorithm;
611
  e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
612 613 614 615 616 617 618

  // X2 HO stats and measurements
  uint8_t                            rrc_ue_do_meas; // flag to start the meas only once
  uint32_t                           rrc_ue_x2_src_enb_ms; // form connected to idle : include x2 delay
  struct list                        rrc_ue_x2_src_enb_list;
  uint32_t                           rrc_ue_x2_target_enb_ms; // from idle to connected
  struct list                        rrc_ue_x2_target_enb_list;
winckel's avatar
winckel committed
619
} UE_RRC_INST;
620

621
#include "proto.h"
winckel's avatar
winckel committed
622

623
#endif
624
/** @} */