defs.h 29.5 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 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
#include "PHY/defs.h"
43 44
#include "LAYER2/RLC/rlc.h"

45
#include "COMMON/platform_constants.h"
46
#include "COMMON/platform_types.h"
47 48 49

#include "LAYER2/MAC/defs.h"

Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
50
//for D2D
51
#define DEBUG_CTRL_SOCKET
52
#define BUFSIZE                1024
53
#define CONTROL_SOCKET_PORT_NO 8888
54
#define MAX_NUM_DEST           10
55 56
//netlink
//#define DEBUG_PDCP
57 58 59 60 61
#define UE_IP_PDCP_NETLINK_ID  31
#define PDCP_PID               1
#define NETLINK_HEADER_SIZE    16
#define SL_DEFAULT_RAB_ID      3
#define SLRB_ID                3
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

#define MAX_PAYLOAD 1024 /* maximum payload size*/

#define UE_STATE_NOTIFICATION_INTERVAL      50

#define IPV4_ADDR    "%u.%u.%u.%u"
#define IPV4_ADDR_FORMAT(aDDRESS)                 \
      (uint8_t)((aDDRESS)  & 0x000000ff),         \
      (uint8_t)(((aDDRESS) & 0x0000ff00) >> 8 ),  \
      (uint8_t)(((aDDRESS) & 0x00ff0000) >> 16),  \
      (uint8_t)(((aDDRESS) & 0xff000000) >> 24)


//-----------------------------------------------------
// header for Control socket

//Primitives
#define SESSION_INIT_REQ                    1
#define UE_STATUS_INFO                      2
#define GROUP_COMMUNICATION_ESTABLISH_REQ   3
#define GROUP_COMMUNICATION_ESTABLISH_RSP   4
#define DIRECT_COMMUNICATION_ESTABLISH_REQ  5
#define DIRECT_COMMUNICATION_ESTABLISH_RSP  6
#define GROUP_COMMUNICATION_RELEASE_REQ     7
#define GROUP_COMMUNICATION_RELEASE_RSP     8
87 88 89 90 91
#define DIRECT_COMMUNICATION_RELEASE_REQ    9
#define DIRECT_COMMUNICATION_RELEASE_RSP    10
#define PC5S_ESTABLISH_REQ                  11
#define PC5S_ESTABLISH_RSP                  12
#define PC5_DISCOVERY_MESSAGE               13
92 93
#define PC5S_RELEASE_REQ                    14
#define PC5S_RELEASE_RSP                    15
94

95
#define PC5_DISCOVERY_PAYLOAD_SIZE	        29
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

typedef enum {
   UE_STATE_OFF_NETWORK,
   UE_STATE_ON_NETWORK
} SL_UE_STATE_t;

typedef enum {
   GROUP_COMMUNICATION_RELEASE_OK = 0,
   GROUP_COMMUNICATION_RELEASE_FAILURE
} Group_Communication_Status_t;

struct GroupCommunicationEstablishReq {
   uint32_t sourceL2Id;
   uint32_t groupL2Id;
   uint32_t groupIpAddress;
   uint8_t pppp;
};

114 115 116 117 118 119
struct GroupCommunicationReleaseReq {
   uint32_t sourceL2Id;
   uint32_t groupL2Id;
   int slrb_id;
};

120 121 122
struct DirectCommunicationEstablishReq {
   uint32_t sourceL2Id;
   uint32_t destinationL2Id;
123
   uint32_t pppp;
124 125
};

126
struct PC5SEstablishReq{
127
   uint8_t type;
128 129 130 131 132
   uint32_t sourceL2Id;
   uint32_t destinationL2Id;
};

struct PC5SEstablishRsp{
133 134 135
   uint32_t slrbid_lcid28;
   uint32_t slrbid_lcid29;
   uint32_t slrbid_lcid30;
136
};
137

138 139 140 141 142
typedef enum {
   PC5S_RELEASE_OK = 0,
   PC5S_RELEASE_FAILURE
} PC5S_Release_Status_t;

143

144
//PC5_DISCOVERY MESSAGE
145
typedef struct  {
146 147
   unsigned char payload[PC5_DISCOVERY_PAYLOAD_SIZE];
   uint32_t measuredPower;
148
}  __attribute__((__packed__)) PC5DiscoveryMessage ;
149

150 151 152 153
typedef enum {
   DIRECT_COMMUNICATION_RELEASE_OK = 0,
   DIRECT_COMMUNICATION_RELEASE_FAILURE
} Direct_Communication_Status_t;
154

155 156 157 158
struct sidelink_ctrl_element {
   unsigned short type;
   union {
      struct GroupCommunicationEstablishReq group_comm_establish_req;
159
      struct DirectCommunicationEstablishReq direct_comm_establish_req;
160
      Group_Communication_Status_t group_comm_release_rsp;
161
      Direct_Communication_Status_t direct_comm_release_rsp;
162
      PC5S_Release_Status_t pc5s_release_rsp;
163 164
      SL_UE_STATE_t ue_state;
      int slrb_id;
165 166
      struct PC5SEstablishReq pc5s_establish_req;
      struct PC5SEstablishRsp pc5s_establish_rsp;
167
      PC5DiscoveryMessage pc5_discovery_message;
168 169 170
   } sidelinkPrimitive;
};

171

172 173 174 175 176 177 178 179
//global variables
extern struct sockaddr_in clientaddr;
extern int slrb_id;
extern pthread_mutex_t slrb_mutex;

//the thread function
void *send_UE_status_notification(void *);

Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
180

181

182 183 184 185 186 187 188 189 190 191 192 193
//#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"
194
#include "RRCConnectionReestablishmentRequest.h"
195
#include "BCCH-DL-SCH-Message.h"
196
#include "SBCCH-SL-BCH-MessageType.h"
197
#include "BCCH-BCH-Message.h"
Cedric Roux's avatar
Cedric Roux committed
198
#if defined(Rel10) || defined(Rel14)
199 200
#include "MCCH-Message.h"
#include "MBSFNAreaConfiguration-r9.h"
201
#include "SCellToAddMod-r10.h"
202
#endif
203 204
#include "AS-Config.h"
#include "AS-Context.h"
205 206
#include "UE-EUTRA-Capability.h"
#include "MeasResults.h"
207
#include "SidelinkUEInformation-r12.h"
208

Cedric Roux's avatar
Cedric Roux committed
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
/* 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

260
// This corrects something generated by asn1c which is different between Rel8 and Rel10
Cedric Roux's avatar
Cedric Roux committed
261
#if !defined(Rel10) && !defined(Rel14)
262 263 264 265 266 267 268 269 270 271 272 273
#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
274 275 276 277 278 279 280


#define NB_SIG_CNX_CH 1
#define NB_CNX_CH MAX_MOBILES_PER_ENB
#define NB_SIG_CNX_UE 2 //MAX_MANAGED_RG_PER_MOBILE
#define NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE

281
/*
Cedric Roux's avatar
Cedric Roux committed
282
#if defined(Rel10) || defined(Rel14)
283 284
#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
285
#endif
286
*/
287 288 289 290 291 292 293
//#include "L3_rrc_defs.h"
#ifndef NO_RRM
#include "L3_rrc_interface.h"
#include "rrc_rrm_msg.h"
#include "rrc_rrm_interface.h"
#endif

294 295 296 297
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif

Cedric Roux's avatar
Cedric Roux committed
298 299 300 301 302 303 304 305
/* 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

306 307 308 309
#if defined(ENABLE_USE_MME)
# include "commonDef.h"
#endif

310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
//--------
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)
326
/** @defgroup _rrc RRC
327
 * @ingroup _oai2
328 329 330 331
 * @{
 */


332 333
#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
334

335 336 337 338 339 340 341 342
typedef enum {
  RRC_OK=0,
  RRC_ConnSetup_failed,
  RRC_PHY_RESYNCH,
  RRC_Handover_failed,
  RRC_HO_STARTED
} RRC_status_t;

winckel's avatar
winckel committed
343
typedef enum UE_STATE_e {
winckel's avatar
winckel committed
344 345
  RRC_INACTIVE=0,
  RRC_IDLE,
346 347
  RRC_SI_RECEIVED,
  RRC_CONNECTED,
348 349
  RRC_RECONFIGURED,
  RRC_HO_EXECUTION
350 351
} UE_STATE_t;

winckel's avatar
winckel committed
352
typedef enum HO_STATE_e {
353 354 355 356 357 358 359
  HO_IDLE=0,
  HO_MEASURMENT,
  HO_PREPARE,
  HO_CMD, // initiated by the src eNB
  HO_COMPLETE // initiated by the target eNB
} HO_STATE_t;

360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
typedef enum SL_TRIGGER_e {
  SL_RECEIVE_COMMUNICATION=0,
  SL_TRANSMIT_RELAY_ONE_TO_ONE,
  SL_TRANSMIT_RELAY_ONE_TO_MANY,
  SL_TRANSMIT_NON_RELAY_ONE_TO_ONE,
  SL_TRANSMIT_NON_RELAY_ONE_TO_MANY,
  SL_RECEIVE_DISCOVERY,
  SL_TRANSMIT_NON_PS_DISCOVERY,
  SL_TRANSMIT_PS_DISCOVERY,
  SL_RECEIVE_V2X,
  SL_TRANSMIT_V2X,
  SL_REQUEST_DISCOVERY_TRANSMISSION_GAPS,
  SL_REQUEST_DISCOVERY_RECEPTION_GAPS
} SL_TRIGGER_t;

375 376
//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG
#define RRM_FREE(p)       if ( (p) != NULL) { free(p) ; p=NULL ; }
377 378 379
#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 )
380

381 382 383
#define MAX_MEAS_OBJ 6
#define MAX_MEAS_CONFIG 6
#define MAX_MEAS_ID 6
384 385

#define PAYLOAD_SIZE_MAX 1024
386
#define RRC_BUF_SIZE 255
387
#define UNDEF_SECURITY_MODE 0xff
388
#define NO_SECURITY_MODE 0x20
389 390 391 392

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

393 394 395
/* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */
#define RRC_TRANSACTION_IDENTIFIER_NUMBER  3

396 397 398 399 400 401 402 403 404 405 406 407
typedef struct {
  unsigned short transport_block_size;                  /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */
  unsigned short max_transport_blocks;                  /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */
  unsigned long  Guaranteed_bit_rate;           /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/
  unsigned long  Max_bit_rate;                  /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/
  uint8_t  Delay_class;                  /*!< \brief Delay class offered by MAC layer scheduling*/
  uint8_t  Target_bler;                  /*!< \brief Target Average Transport Block Error rate*/
  uint8_t  Lchan_t;                      /*!< \brief Logical Channel Type (BCCH,CCCH,DCCH,DTCH_B,DTCH,MRBCH)*/
} __attribute__ ((__packed__))  LCHAN_DESC;

#define LCHAN_DESC_SIZE sizeof(LCHAN_DESC)

winckel's avatar
winckel committed
408
typedef struct UE_RRC_INFO_s {
409
  UE_STATE_t State;
410
  uint8_t SIB1systemInfoValueTag;
411 412
  uint32_t SIStatus;
  uint32_t SIcnt;
Cedric Roux's avatar
Cedric Roux committed
413
#if defined(Rel10) || defined(Rel14)
414
  uint8_t MCCHStatus[8]; // MAX_MBSFN_AREA
415
#endif
416
  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
417
  uint8_t handoverTarget;
418
  HO_STATE_t ho_state;
419
  uint16_t SIperiod; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120
420
  unsigned short UE_index;
421 422 423 424 425 426 427 428
  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;
429
  rnti_t   rnti;
winckel's avatar
winckel committed
430
} __attribute__ ((__packed__)) UE_RRC_INFO;
431

432
typedef struct UE_S_TMSI_s {
gauthier's avatar
gauthier committed
433 434 435
  boolean_t  presence;
  mme_code_t mme_code;
  m_tmsi_t   m_tmsi;
winckel's avatar
winckel committed
436
} __attribute__ ((__packed__)) UE_S_TMSI;
437

438
#if defined(ENABLE_ITTI)
winckel's avatar
winckel committed
439
typedef enum e_rab_satus_e {
440
  E_RAB_STATUS_NEW,
441 442
  E_RAB_STATUS_DONE, // from the eNB perspective
  E_RAB_STATUS_ESTABLISHED, // get the reconfigurationcomplete form UE
443
  E_RAB_STATUS_FAILED,
winckel's avatar
winckel committed
444 445
} e_rab_status_t;

446
typedef struct e_rab_param_s {
447 448
  e_rab_t param;
  uint8_t status;
449
  uint8_t xid; // transaction_id
winckel's avatar
winckel committed
450
} __attribute__ ((__packed__)) e_rab_param_t;
451 452
#endif

453 454


455
/* Intermediate structure for Handover management. Associated per-UE in eNB_RRC_INST */
winckel's avatar
winckel committed
456
typedef struct HANDOVER_INFO_s {
457 458 459 460 461 462
  uint8_t ho_prepare;
  uint8_t ho_complete;
  uint8_t modid_s; //module_idP of serving cell
  uint8_t modid_t; //module_idP of target cell
  uint8_t ueid_s; //UE index in serving cell
  uint8_t ueid_t; //UE index in target cell
463 464
  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 */
465 466
  uint8_t buf[RRC_BUF_SIZE];  /* ASN.1 encoded handoverCommandMessage */
  int size;   /* size of above message in bytes */
winckel's avatar
winckel committed
467
} HANDOVER_INFO;
468 469 470

#define RRC_HEADER_SIZE_MAX 64
#define RRC_BUFFER_SIZE_MAX 1024
471
typedef struct {
472
  char Payload[RRC_BUFFER_SIZE_MAX];
473
  char Header[RRC_HEADER_SIZE_MAX];
474
  char payload_size;
475
} RRC_BUFFER;
476 477
#define RRC_BUFFER_SIZE sizeof(RRC_BUFFER)

winckel's avatar
winckel committed
478
typedef struct RB_INFO_s {
479
  uint16_t Rb_id;  //=Lchan_id
480
  LCHAN_DESC Lchan_desc[2];
481
  //  MAC_MEAS_REQ_ENTRY *Meas_entry;
winckel's avatar
winckel committed
482
} RB_INFO;
483

winckel's avatar
winckel committed
484
typedef struct SRB_INFO_s {
485
  uint16_t Srb_id;  //=Lchan_id
486 487
  RRC_BUFFER Rx_buffer;
  RRC_BUFFER Tx_buffer;
488 489
  LCHAN_DESC Lchan_desc[2];
  unsigned int Trans_id;
490
  uint8_t Active;
winckel's avatar
winckel committed
491
} SRB_INFO;
492

winckel's avatar
winckel committed
493
typedef struct RB_INFO_TABLE_ENTRY_s {
494
  RB_INFO Rb_info;
495 496 497
  uint8_t Active;
  uint32_t Next_check_frame;
  uint8_t Status;
winckel's avatar
winckel committed
498
} RB_INFO_TABLE_ENTRY;
499

winckel's avatar
winckel committed
500
typedef struct SRB_INFO_TABLE_ENTRY_s {
501
  SRB_INFO Srb_info;
502 503
  uint8_t Active;
  uint8_t Status;
504
  uint32_t Next_check_frame;
505
} SRB_INFO_TABLE_ENTRY;
506

winckel's avatar
winckel committed
507
typedef struct MEAS_REPORT_LIST_s {
508
  MeasId_t measId;
509
  //CellsTriggeredList  cellsTriggeredList;//OPTIONAL
510
  uint32_t numberOfReportsSent;
511
} MEAS_REPORT_LIST;
512

winckel's avatar
winckel committed
513
typedef struct HANDOVER_INFO_UE_s {
514
  PhysCellId_t targetCellId;
515
  uint8_t measFlag;
winckel's avatar
winckel committed
516
} HANDOVER_INFO_UE;
517

518
typedef struct eNB_RRC_UE_s {
519
  uint8_t                            primaryCC_id;
Cedric Roux's avatar
Cedric Roux committed
520
#if defined(Rel10) || defined(Rel14)
521 522 523
  SCellToAddMod_r10_t                sCell_config[2];
#endif
  SRB_ToAddModList_t*                SRB_configList;
524
  SRB_ToAddModList_t*                SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER];
525
  DRB_ToAddModList_t*                DRB_configList;
526
  DRB_ToAddModList_t*                DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER];
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
  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];
#endif
  /* Used integrity/ciphering algorithms */
Cedric Roux's avatar
Cedric Roux committed
548
  CipheringAlgorithm_r12_t                          ciphering_algorithm;
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
  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;

571 572
  /* Total number of e_rab already setup in the list */
  uint8_t                           setup_e_rabs;
573 574 575
  /* 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 */
576
  e_rab_param_t                      e_rab[NB_RB_MAX];//[S1AP_MAX_E_RAB];
577 578 579 580 581 582

  // 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
583
  uint32_t                           ul_failure_timer;
584
  uint32_t                           ue_release_timer;
585
  uint32_t                           ue_release_timer_thres;
586 587 588
} eNB_RRC_UE_t;

typedef uid_t ue_uid_t;
589

590 591 592 593 594 595 596 597 598
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;

599
  // another key for protocol layers but should not be used as a key for RB tree
600 601 602 603 604
  ue_uid_t       local_uid;

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

606
typedef struct {
607 608
  uint8_t                           *MIB;
  uint8_t                           sizeof_MIB;
609 610 611 612
  uint8_t                           *SIB1;
  uint8_t                           sizeof_SIB1;
  uint8_t                           *SIB23;
  uint8_t                           sizeof_SIB23;
613
#ifdef Rel14
614 615
  uint8_t                           *SIB1_BR;
  uint8_t                           sizeof_SIB1_BR;
616 617 618
  uint8_t                           *SIB23_BR;
  uint8_t                           sizeof_SIB23_BR;
#endif
619 620 621 622 623
  int                               physCellId;
  int                               Ncp;
  int                               p_eNB;
  uint32_t                          dl_CarrierFreq;
  uint32_t                          ul_CarrierFreq;
624
  uint32_t                          pbch_repetition;
625 626 627 628 629 630
  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;
631
  SystemInformationBlockType3_t     *sib3;
632
#ifdef Rel14
633
  SystemInformationBlockType1_t     *sib1_BR;
634
  SystemInformationBlockType2_t     *sib2_BR;
635
  SystemInformationBlockType2_t     *sib3_BR;
636
#endif
Cedric Roux's avatar
Cedric Roux committed
637
#if defined(Rel10) || defined(Rel14)
638 639
  SystemInformationBlockType13_r9_t *sib13;
  uint8_t                           MBMS_flag;
640 641 642
  uint8_t                           num_mbsfn_sync_area;
  uint8_t                           **MCCH_MESSAGE; //  MAX_MBSFN_AREA
  uint8_t                           sizeof_MCCH_MESSAGE[8];// MAX_MBSFN_AREA
643
  MCCH_Message_t            mcch;
644
  MBSFNAreaConfiguration_r9_t       *mcch_message;
645
  SRB_INFO                          MCCH_MESS[8];// MAX_MBSFN_AREA
646
#endif
647 648 649 650
  //TTN - SIB 18,19,21 for D2D
  SystemInformationBlockType18_r12_t *sib18;
  SystemInformationBlockType19_r12_t *sib19;
  SystemInformationBlockType21_r14_t *sib21;
651

652 653
  SRB_INFO                          SI;
  SRB_INFO                          Srb0;
654
} rrc_eNB_carrier_data_t;
655 656

typedef struct eNB_RRC_INST_s {
657 658
  /// southbound midhaul configuration
  eth_params_t                    eth_params_s;
659
  rrc_eNB_carrier_data_t          carrier[MAX_NUM_CCs];
660 661
  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
662
  uint8_t                           HO_flag;
663
  uint8_t                            Nb_ue;
664 665 666
  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

667 668 669 670 671 672
#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
673
  int32_t aggregation_period_ms;
674 675
  /// localization list for aggregated measurements from PHY
  struct list loc_list;
676
#endif
677

678
  //RRC configuration
679
#if defined(ENABLE_ITTI)
680
  RrcConfigurationReq configuration;
681
#endif
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
  // other PLMN parameters
  /// Mobile country code
  int mcc;
  /// Mobile network code
  int mnc;
  /// number of mnc digits
  int mnc_digit_length;

  // other RAN parameters
  int srb1_timer_poll_retransmit;
  int srb1_poll_pdu;
  int srb1_poll_byte;
  int srb1_max_retx_threshold;
  int srb1_timer_reordering;
  int srb1_timer_status_prohibit;
  int srs_enable[MAX_NUM_CCs];
698 699 700
} eNB_RRC_INST;

#define MAX_UE_CAPABILITY_SIZE 255
winckel's avatar
winckel committed
701
typedef struct OAI_UECapability_s {
702 703 704 705 706
  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
707
typedef struct UE_RRC_INST_s {
winckel's avatar
winckel committed
708 709
  Rrc_State_t     RrcState;
  Rrc_Sub_State_t RrcSubState;
710
# if defined(ENABLE_USE_MME)
winckel's avatar
winckel committed
711 712 713
  plmn_t          plmnID;
  Byte_t          rat;
  as_nas_info_t   initialNasMsg;
714
# endif
Raymond Knopp's avatar
 
Raymond Knopp committed
715
  OAI_UECapability_t *UECap;
716 717 718 719 720 721
  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];
722
  HANDOVER_INFO_UE HandoverInfoUe;
723 724 725 726 727 728
  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];
729
  SystemInformationBlockType1_t *sib1[NB_CNX_UE];
730
  SystemInformation_t *si[NB_CNX_UE]; //!< Temporary storage for an SI message. Decoding happens in decode_SI().
731 732 733 734 735 736 737 738 739 740
  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];
741 742
  uint8_t                           *MIB;
#ifdef Rel14
743
  //SIB18
744
  SystemInformationBlockType18_r12_t *sib18[NB_CNX_UE];
745
  SystemInformationBlockType19_r12_t *sib19[NB_CNX_UE];
746

747
  SBCCH_SL_BCH_MessageType_t   mib_sl[NB_CNX_UE];
748 749
  /// Preconfiguration for Sidelink
  struct SL_Preconfiguration_r12 *SL_Preconfiguration[NB_CNX_UE];
750 751 752 753
  //source L2 Id
  uint32_t sourceL2Id;
  //group L2 Id
  uint32_t groupL2Id;
754
  //current destination
755
  uint32_t destinationL2Id;
756
  SL_INFO sl_info[MAX_NUM_LCID];
757 758
  //sl_discovery..
  SRB_INFO SL_Discovery[NB_CNX_UE];
759
#endif
760

Cedric Roux's avatar
Cedric Roux committed
761
#if defined(Rel10) || defined(Rel14)
762
  uint8_t                           MBMS_flag;
763 764 765
  uint8_t *MCCH_MESSAGE[NB_CNX_UE];
  uint8_t sizeof_MCCH_MESSAGE[NB_CNX_UE];
  uint8_t MCCH_MESSAGEStatus[NB_CNX_UE];
766
  MBSFNAreaConfiguration_r9_t       *mcch_message[NB_CNX_UE];
767 768
  SystemInformationBlockType12_r9_t *sib12[NB_CNX_UE];
  SystemInformationBlockType13_r9_t *sib13[NB_CNX_UE];
769
#endif
770 771 772 773
#ifdef CBA
  uint8_t                         num_active_cba_groups;
  uint16_t                        cba_rnti[NUM_MAX_CBA_GROUP];
#endif
774
  uint8_t                         num_srb;
775 776 777
  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];
778
  rb_id_t                         *defaultDRB; // remember the ID of the default DRB
779 780 781 782
  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];
783 784
  MEAS_REPORT_LIST      *measReportList[NB_CNX_UE][MAX_MEAS_ID];
  uint32_t           measTimer[NB_CNX_UE][MAX_MEAS_ID][6]; // 6 neighboring cells
785
  RSRP_Range_t                    s_measure;
786
  struct MeasConfig__speedStatePars *speedStatePars;
787 788 789 790
  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];
791
  double                          filter_coeff_rsrp; // [7] ???
792
  double                          filter_coeff_rsrq; // [7] ???
793 794 795 796
  float                           rsrp_db[7];
  float                           rsrq_db[7];
  float                           rsrp_db_filtered[7];
  float                           rsrq_db_filtered[7];
797 798 799 800 801 802
#if defined(ENABLE_SECURITY)
  /* KeNB as computed from parameters within USIM card */
  uint8_t kenb[32];
#endif

  /* Used integrity/ciphering algorithms */
Cedric Roux's avatar
Cedric Roux committed
803
  CipheringAlgorithm_r12_t                          ciphering_algorithm;
804
  e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
805 806 807 808 809

#ifdef Rel14
  /// Used for Sidelink Preconfiguration
  DRB_ToAddModList_t *DRB_configList;
#endif
winckel's avatar
winckel committed
810
} UE_RRC_INST;
811

812
#include "proto.h"
winckel's avatar
winckel committed
813

814
#endif
815
/** @} */