asn1_msg.c 126 KB
Newer Older
1
/*******************************************************************************
nikaeinn's avatar
nikaeinn committed
2
3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

nikaeinn's avatar
nikaeinn committed
5
6
7
8
    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.
9
10


nikaeinn's avatar
nikaeinn committed
11
12
13
14
    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.
15

nikaeinn's avatar
nikaeinn committed
16
17
18
19
    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/>.
20
21

  Contact Information
nikaeinn's avatar
nikaeinn committed
22
23
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
nikaeinn's avatar
nikaeinn committed
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27
28
29
30

*******************************************************************************/

/*! \file asn1_msg.c
31
* \brief primitives to build the asn1 messages
32
33
* \author Raymond Knopp and Navid Nikaein
* \date 2011
34
* \version 1.0
35
36
* \company Eurecom
* \email: raymond.knopp@eurecom.fr and  navid.nikaein@eurecom.fr
37
*/
38

39
40
41
#ifdef USER_MODE
#include <stdio.h>
#include <sys/types.h>
42
43
44
45
46
#include <stdlib.h> /* for atoi(3) */
#include <unistd.h> /* for getopt(3) */
#include <string.h> /* for strerror(3) */
#include <sysexits.h> /* for EX_* exit codes */
#include <errno.h>  /* for errno */
47
48
49
50
51
52
53
54
55
#else
#include <linux/module.h>  /* Needed by all modules */
#endif
#ifdef USER_MODE
//#include "RRC/LITE/defs.h"
//#include "COMMON/mac_rrc_primitives.h"
#include "UTIL/LOG/log.h"
#endif
#include <asn_application.h>
56
#include <asn_internal.h> /* for _ASN_DEFAULT_STACK_MAX */
57
58
#include <per_encoder.h>

59
#include "assertions.h"
60
61
62
63
64
65
66
67
68
69
70
#include "RRCConnectionRequest.h"
#include "UL-CCCH-Message.h"
#include "UL-DCCH-Message.h"
#include "DL-CCCH-Message.h"
#include "DL-DCCH-Message.h"
#include "EstablishmentCause.h"
#include "RRCConnectionSetup.h"
#include "SRB-ToAddModList.h"
#include "DRB-ToAddModList.h"
#ifdef Rel10
#include "MCCH-Message.h"
71
//#define MRB1 1
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#endif

#include "RRC/LITE/defs.h"
#include "RRCConnectionSetupComplete.h"
#include "RRCConnectionReconfigurationComplete.h"
#include "RRCConnectionReconfiguration.h"
#include "MasterInformationBlock.h"
#include "SystemInformation.h"

#include "SystemInformationBlockType1.h"

#include "SIB-Type.h"

#include "BCCH-DL-SCH-Message.h"

#include "PHY/defs.h"

#include "MeasObjectToAddModList.h"
#include "ReportConfigToAddModList.h"
#include "MeasIdToAddModList.h"
92
#include "enb_config.h"
93

94
95
96
97
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif

98
99
100
101
102
103
104
//#include "PHY/defs.h"
#ifndef USER_MODE
#define msg printk
#ifndef errno
int errno;
#endif
#else
105
106
107
# if !defined (msg)
#   define msg printf
# endif
108
109
#endif

110
111
//#define XER_PRINT

112
extern Enb_properties_array_t enb_properties;
113
114
115
116
typedef struct xer_sprint_string_s {
  char *string;
  size_t string_size;
  size_t string_index;
117
118
} xer_sprint_string_t;

119
extern unsigned char NB_eNB_INST;
120
extern uint8_t usim_test;
121

122
123
uint16_t two_tier_hexagonal_cellIds[7] = {0,1,2,4,5,7,8};
uint16_t two_tier_hexagonal_adjacent_cellIds[7][6] = {{1,2,4,5,7,8},    // CellId 0
124
125
126
127
128
129
130
  {11,18,2,0,8,15}, // CellId 1
  {18,13,3,4,0,1},  // CellId 2
  {2,3,14,6,5,0},   // CellId 4
  {0,4,6,16,9,7},   // CellId 5
  {8,0,5,9,17,12},  // CellId 7
  {15,1,0,7,12,10}
};// CellId 8
131

132
133
134
135
136
137
/*
 * This is a helper function for xer_sprint, which directs all incoming data
 * into the provided string.
 */
static int xer__print2s (const void *buffer, size_t size, void *app_key)
{
138
139
140
141
142
143
  xer_sprint_string_t *string_buffer = (xer_sprint_string_t *) app_key;
  size_t string_remaining = string_buffer->string_size - string_buffer->string_index;

  if (string_remaining > 0) {
    if (size > string_remaining) {
      size = string_remaining;
144
    }
145

146
147
148
149
150
    memcpy(&string_buffer->string[string_buffer->string_index], buffer, size);
    string_buffer->string_index += size;
  }

  return 0;
151
152
}

153
int xer_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, void *sptr)
154
{
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
  asn_enc_rval_t er;
  xer_sprint_string_t string_buffer;

  string_buffer.string = string;
  string_buffer.string_size = string_size;
  string_buffer.string_index = 0;

  er = xer_encode(td, sptr, XER_F_BASIC, xer__print2s, &string_buffer);

  if (er.encoded < 0) {
    LOG_E(RRC, "xer_sprint encoding error (%d)!", er.encoded);
    er.encoded = string_buffer.string_size;
  } else {
    if (er.encoded > string_buffer.string_size) {
      LOG_E(RRC, "xer_sprint string buffer too small, got %d need %d!", string_buffer.string_size, er.encoded);
      er.encoded = string_buffer.string_size;
171
    }
172
  }
173

174
  return er.encoded;
175
}
176

177
178
uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index)
{
179
180
  return(two_tier_hexagonal_adjacent_cellIds[Mod_id][index]);
}
181
/* This only works for the hexagonal topology...need a more general function for other topologies */
winckel's avatar
RRC:    
winckel committed
182

183
184
uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId)
{
winckel's avatar
RRC:    
winckel committed
185
  uint8_t i;
186
187

  for(i=0; i<7; i++) {
188
    if(two_tier_hexagonal_cellIds[i] == phyCellId) {
189
      return i;
190
    }
191
  }
192

193
194
195
  LOG_E(RRC,"\nCannot get adjacent cell mod id! Fatal error!\n");
  return 0xFF; //error!
}
winckel's avatar
RRC:    
winckel committed
196

197
198
/*
uint8_t do_SIB1(LTE_DL_FRAME_PARMS *frame_parms, uint8_t *buffer,
199
    SystemInformationBlockType1_t *sib1) {
200
201
202
203
204
205
206
207
208
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286


  PLMN_IdentityInfo_t PLMN_identity_info;
  MCC_MNC_Digit_t dummy;
  asn_enc_rval_t enc_rval;
  SchedulingInfo_t schedulingInfo;
  SIB_Type_t sib_type;

  memset(sib1,0,sizeof(SystemInformationBlockType1_t));
  memset(&PLMN_identity_info,0,sizeof(PLMN_IdentityInfo_t));
  memset(&schedulingInfo,0,sizeof(SchedulingInfo_t));
  memset(&sib_type,0,sizeof(SIB_Type_t));

  PLMN_identity_info.plmn_Identity.mcc = CALLOC(1,sizeof(*PLMN_identity_info.plmn_Identity.mcc));
  memset(PLMN_identity_info.plmn_Identity.mcc,0,sizeof(*PLMN_identity_info.plmn_Identity.mcc));

  asn_set_empty(&PLMN_identity_info.plmn_Identity.mcc->list);//.size=0;

  dummy=2;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy);
  dummy=6;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy);
  dummy=2;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy);

  PLMN_identity_info.plmn_Identity.mnc.list.size=0;
  PLMN_identity_info.plmn_Identity.mnc.list.count=0;
  dummy=8;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy);
  dummy=0;ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy);
  //assign_enum(&PLMN_identity_info.cellReservedForOperatorUse,PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved);
  PLMN_identity_info.cellReservedForOperatorUse=PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;

  ASN_SEQUENCE_ADD(&sib1->cellAccessRelatedInfo.plmn_IdentityList.list,&PLMN_identity_info);


  // 16 bits
  sib1->cellAccessRelatedInfo.trackingAreaCode.buf = MALLOC(2);
  sib1->cellAccessRelatedInfo.trackingAreaCode.buf[0]=0x00;
  sib1->cellAccessRelatedInfo.trackingAreaCode.buf[1]=0x10;
  sib1->cellAccessRelatedInfo.trackingAreaCode.size=2;
  sib1->cellAccessRelatedInfo.trackingAreaCode.bits_unused=0;

  // 28 bits
  sib1->cellAccessRelatedInfo.cellIdentity.buf = MALLOC(8);
  sib1->cellAccessRelatedInfo.cellIdentity.buf[0]=0x01;
  sib1->cellAccessRelatedInfo.cellIdentity.buf[1]=0x48;
  sib1->cellAccessRelatedInfo.cellIdentity.buf[2]=0x0f;
  sib1->cellAccessRelatedInfo.cellIdentity.buf[3]=0x03;
  sib1->cellAccessRelatedInfo.cellIdentity.size=4;
  sib1->cellAccessRelatedInfo.cellIdentity.bits_unused=4;

  //  assign_enum(&sib1->cellAccessRelatedInfo.cellBarred,SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred);
  sib1->cellAccessRelatedInfo.cellBarred=SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred;

  //  assign_enum(&sib1->cellAccessRelatedInfo.intraFreqReselection,SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed);
  sib1->cellAccessRelatedInfo.intraFreqReselection=SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed;
  sib1->cellAccessRelatedInfo.csg_Indication=0;

  sib1->cellSelectionInfo.q_RxLevMin=-70;
  sib1->cellSelectionInfo.q_RxLevMinOffset=NULL;

  sib1->freqBandIndicator = 2;

  //  assign_enum(&schedulingInfo.si_Periodicity,SchedulingInfo__si_Periodicity_rf8);
  schedulingInfo.si_Periodicity=SchedulingInfo__si_Periodicity_rf8;

  //  assign_enum(&sib_type,SIB_Type_sibType3);
  sib_type=SIB_Type_sibType3;

  ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type);
  ASN_SEQUENCE_ADD(&sib1->schedulingInfoList.list,&schedulingInfo);

  sib1->tdd_Config = CALLOC(1,sizeof(struct TDD_Config));

  //assign_enum(&sib1->tdd_Config->subframeAssignment,TDD_Config__subframeAssignment_sa3);
  sib1->tdd_Config->subframeAssignment=frame_parms->tdd_config; //TDD_Config__subframeAssignment_sa3;

  //  assign_enum(&sib1->tdd_Config->specialSubframePatterns,TDD_Config__specialSubframePatterns_ssp0);
  sib1->tdd_Config->specialSubframePatterns=frame_parms->tdd_config_S;//TDD_Config__specialSubframePatterns_ssp0;

  //  assign_enum(&sib1->si_WindowLength,SystemInformationBlockType1__si_WindowLength_ms10);
  sib1->si_WindowLength=SystemInformationBlockType1__si_WindowLength_ms10;
  sib1->systemInfoValueTag=0;
  //  sib1.nonCriticalExtension = calloc(1,sizeof(*sib1.nonCriticalExtension));

#ifdef USER_MODE
  xer_fprint(stdout, &asn_DEF_SystemInformationBlockType1, (void*)sib1);
#endif

  enc_rval = uper_encode_to_buffer(&asn_DEF_SystemInformationBlockType1,
287
288
289
           (void*)sib1,
           buffer,
           200);
290
291
292
293
294
295
296
297
298
299
#ifdef USER_MODE
  LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
#endif

  if (enc_rval.encoded==-1)
    return(-1);
  return((enc_rval.encoded+7)/8);
}
*/
// AT4 packet
300
301
uint8_t do_MIB(uint8_t Mod_id, LTE_DL_FRAME_PARMS *frame_parms, uint32_t frame, uint8_t *buffer)
{
302
303
304
305
306
307
308
309
310
311
312

  asn_enc_rval_t enc_rval;
  BCCH_BCH_Message_t mib;
  uint8_t sfn = (uint8_t)((frame>>2)&0xff);
  uint16_t spare=0;

  switch (frame_parms->N_RB_DL) {

  case 6:
    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6;
    break;
313

314
315
316
  case 15:
    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n15;
    break;
317

318
319
320
  case 25:
    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n25;
    break;
321

322
323
324
  case 50:
    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n50;
    break;
325

326
327
328
  case 75:
    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n75;
    break;
329

330
331
332
  case 100:
    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n100;
    break;
333

334
335
336
337
  default:
    mib.message.dl_Bandwidth = MasterInformationBlock__dl_Bandwidth_n6;
    break;
  }
338

339
340
341
342
  switch (frame_parms->phich_config_common.phich_resource) {
  case oneSixth:
    mib.message.phich_Config.phich_Resource = 0;
    break;
343

344
345
346
  case half:
    mib.message.phich_Config.phich_Resource = 1;
    break;
347

348
349
350
  case one:
    mib.message.phich_Config.phich_Resource = 2;
    break;
351

352
353
354
355
356
  case two:
    mib.message.phich_Config.phich_Resource = 3;
    break;
  }

357
358
359
360
361
  printf("[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x,sfn %x\n",
         (uint32_t)mib.message.dl_Bandwidth,
         (uint32_t)frame_parms->phich_config_common.phich_duration,
         (uint32_t)mib.message.phich_Config.phich_Resource,
         (uint32_t)sfn);
362
363
364
365
366
367
368
369
370
  mib.message.phich_Config.phich_Duration = frame_parms->phich_config_common.phich_duration;
  mib.message.systemFrameNumber.buf = &sfn;
  mib.message.systemFrameNumber.size = 1;
  mib.message.systemFrameNumber.bits_unused=0;
  mib.message.spare.buf = (uint8_t *)&spare;
  mib.message.spare.size = 2;
  mib.message.spare.bits_unused = 6;  // This makes a spare of 10 bits

  enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_BCH_Message,
371
372
373
                                   (void*)&mib,
                                   buffer,
                                   100);
knopp's avatar
   
knopp committed
374
  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
375
               enc_rval.failed_type->name, enc_rval.encoded);
376
377
378
379

#if defined(ENABLE_ITTI)
# if !defined(DISABLE_XER_SPRINT)
  {
380
    char        message_string[20000];
381
382
    size_t      message_string_size;

383
    if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_BCH_Message, (void *) &mib)) > 0) {
384
      MessageDef *msg_p;
385

winckel's avatar
winckel committed
386
387
388
      msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText));
      msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
      memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
389

390
      itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
391
392
393
394
395
    }
  }
# endif
#endif

396
  if (enc_rval.encoded==-1) {
397
    return(-1);
398
  }
399

400
401
402
  return((enc_rval.encoded+7)/8);
  /*
  printf("MIB: %x ((MIB>>10)&63)+(MIB&3<<6)=SFN %x, MIB>>2&3 = phich_resource %d, MIB>>4&1 = phich_duration %d, MIB>>5&7 = system_bandwidth %d)\n",*(uint32_t *)buffer,
403
404
405
406
407
   (((*(uint32_t *)buffer)>>10)&0x3f)+(((*(uint32_t *)buffer)&3)<<6),
   ((*(uint32_t *)buffer)>>2)&0x3,
   ((*(uint32_t *)buffer)>>4)&0x1,
   ((*(uint32_t *)buffer)>>5)&0x7
   );
408
409
  */
}
winckel's avatar
RRC:    
winckel committed
410

411
412
uint8_t do_SIB1(uint8_t Mod_id, int CC_id,
                LTE_DL_FRAME_PARMS *frame_parms, uint8_t *buffer,
winckel's avatar
winckel committed
413
414
415
                BCCH_DL_SCH_Message_t *bcch_message,
                SystemInformationBlockType1_t **sib1
#if defined(ENABLE_ITTI)
416
                , RrcConfigurationReq *configuration
winckel's avatar
winckel committed
417
#endif
418
419
               )
{
420
421
422

  //  SystemInformation_t systemInformation;
  PLMN_IdentityInfo_t PLMN_identity_info;
winckel's avatar
winckel committed
423
  MCC_MNC_Digit_t dummy_mcc[3],dummy_mnc[3];
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
  asn_enc_rval_t enc_rval;
  SchedulingInfo_t schedulingInfo;
  SIB_Type_t sib_type;

  memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t));
  bcch_message->message.present = BCCH_DL_SCH_MessageType_PR_c1;
  bcch_message->message.choice.c1.present = BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1;
  //  memcpy(&bcch_message.message.choice.c1.choice.systemInformationBlockType1,sib1,sizeof(SystemInformationBlockType1_t));

  *sib1 = &bcch_message->message.choice.c1.choice.systemInformationBlockType1;

  memset(&PLMN_identity_info,0,sizeof(PLMN_IdentityInfo_t));
  memset(&schedulingInfo,0,sizeof(SchedulingInfo_t));
  memset(&sib_type,0,sizeof(SIB_Type_t));



  PLMN_identity_info.plmn_Identity.mcc = CALLOC(1,sizeof(*PLMN_identity_info.plmn_Identity.mcc));
  memset(PLMN_identity_info.plmn_Identity.mcc,0,sizeof(*PLMN_identity_info.plmn_Identity.mcc));

  asn_set_empty(&PLMN_identity_info.plmn_Identity.mcc->list);//.size=0;

winckel's avatar
winckel committed
446
447
448
449
450
451
452
453
454
455
456
457
#if defined(ENABLE_ITTI)
  dummy_mcc[0] = (configuration->mcc / 100) % 10;
  dummy_mcc[1] = (configuration->mcc / 10) % 10;
  dummy_mcc[2] = (configuration->mcc / 1) % 10;
#else
  dummy_mcc[0] = 0;
  dummy_mcc[1] = 0;
  dummy_mcc[2] = 1;
#endif
  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[0]);
  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[1]);
  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mcc->list,&dummy_mcc[2]);
458
459
460

  PLMN_identity_info.plmn_Identity.mnc.list.size=0;
  PLMN_identity_info.plmn_Identity.mnc.list.count=0;
winckel's avatar
winckel committed
461
#if defined(ENABLE_ITTI)
462

winckel's avatar
winckel committed
463
  if (configuration->mnc >= 100) {
464
465
466
467
468
469
470
471
472
473
    dummy_mnc[0] = (configuration->mnc / 100) % 10;
    dummy_mnc[1] = (configuration->mnc / 10) % 10;
    dummy_mnc[2] = (configuration->mnc / 1) % 10;
  } else {
    if (configuration->mnc_digit_length == 2) {
      dummy_mnc[0] = (configuration->mnc / 10) % 10;
      dummy_mnc[1] = (configuration->mnc / 1) % 10;
      dummy_mnc[2] = 0xf;
    } else {
      dummy_mnc[0] = (configuration->mnc / 100) % 100;
winckel's avatar
winckel committed
474
475
      dummy_mnc[1] = (configuration->mnc / 10) % 10;
      dummy_mnc[2] = (configuration->mnc / 1) % 10;
476
    }
winckel's avatar
winckel committed
477
  }
478

winckel's avatar
winckel committed
479
480
481
482
483
484
485
#else
  dummy_mnc[0] = 0;
  dummy_mnc[1] = 1;
  dummy_mnc[2] = 0xf;
#endif
  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy_mnc[0]);
  ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy_mnc[1]);
486

winckel's avatar
winckel committed
487
488
489
490
  if (dummy_mnc[2] != 0xf) {
    ASN_SEQUENCE_ADD(&PLMN_identity_info.plmn_Identity.mnc.list,&dummy_mnc[2]);
  }

491
492
493
494
495
496
497
498
  //assign_enum(&PLMN_identity_info.cellReservedForOperatorUse,PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved);
  PLMN_identity_info.cellReservedForOperatorUse=PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;

  ASN_SEQUENCE_ADD(&(*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list,&PLMN_identity_info);


  // 16 bits
  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf = MALLOC(2);
winckel's avatar
winckel committed
499
500
501
502
503
504
505
#if defined(ENABLE_ITTI)
  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[0] = (configuration->tac >> 8) & 0xff;
  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[1] = (configuration->tac >> 0) & 0xff;
#else
  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[0] = 0x00;
  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf[1] = 0x01;
#endif
506
507
508
509
510
  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.size=2;
  (*sib1)->cellAccessRelatedInfo.trackingAreaCode.bits_unused=0;

  // 28 bits
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf = MALLOC(8);
winckel's avatar
winckel committed
511
512
513
514
515
516
517
518
519
520
521
#if defined(ENABLE_ITTI)
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[0] = (configuration->cell_identity >> 20) & 0xff;
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[1] = (configuration->cell_identity >> 12) & 0xff;
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[2] = (configuration->cell_identity >>  4) & 0xff;
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[3] = (configuration->cell_identity <<  4) & 0xf0;
#else
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[0] = 0x00;
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[1] = 0x00;
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[2] = 0x00;
  (*sib1)->cellAccessRelatedInfo.cellIdentity.buf[3] = 0x10;
#endif
522
523
524
525
526
527
528
529
530
531
532
533
  (*sib1)->cellAccessRelatedInfo.cellIdentity.size=4;
  (*sib1)->cellAccessRelatedInfo.cellIdentity.bits_unused=4;

  //  assign_enum(&(*sib1)->cellAccessRelatedInfo.cellBarred,SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred);
  (*sib1)->cellAccessRelatedInfo.cellBarred=SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred;

  //  assign_enum(&(*sib1)->cellAccessRelatedInfo.intraFreqReselection,SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed);
  (*sib1)->cellAccessRelatedInfo.intraFreqReselection=SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_notAllowed;
  (*sib1)->cellAccessRelatedInfo.csg_Indication=0;

  (*sib1)->cellSelectionInfo.q_RxLevMin=-65;
  (*sib1)->cellSelectionInfo.q_RxLevMinOffset=NULL;
534
  //(*sib1)->p_Max = CALLOC(1, sizeof(P_Max_t));
535
  //*((*sib1)->p_Max) = 23;
536
537
  (*sib1)->freqBandIndicator =
#if defined(ENABLE_ITTI)
538
    configuration->eutra_band[CC_id];
539
#else
540
    7;
541
#endif
542
543
544
545
546
547
548
549
550

  schedulingInfo.si_Periodicity=SchedulingInfo__si_Periodicity_rf8;

  // This is for SIB2/3
  sib_type=SIB_Type_sibType3;
  ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type);
  ASN_SEQUENCE_ADD(&(*sib1)->schedulingInfoList.list,&schedulingInfo);

  //  ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,NULL);
551

552
#if defined(ENABLE_ITTI)
553

554
  if (configuration->frame_type[CC_id] == TDD)
555
556
#endif
  {
557
    (*sib1)->tdd_Config =                             CALLOC(1,sizeof(struct TDD_Config));
558

559
    (*sib1)->tdd_Config->subframeAssignment =
560
#if defined(ENABLE_ITTI)
561
      configuration->tdd_config[CC_id];
562
#else
563
      frame_parms->tdd_config;
564
#endif
565

566
    (*sib1)->tdd_Config->specialSubframePatterns =
567
#if defined(ENABLE_ITTI)
568
      configuration->tdd_config_s[CC_id];
569
#else
570
      frame_parms->tdd_config_S;
571
#endif
572
  }
573
574
575
576
577
578
579
580
581

  (*sib1)->si_WindowLength=SystemInformationBlockType1__si_WindowLength_ms20;
  (*sib1)->systemInfoValueTag=0;
  //  (*sib1).nonCriticalExtension = calloc(1,sizeof(*(*sib1).nonCriticalExtension));

#ifdef XER_PRINT
  xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message);
#endif
  enc_rval = uper_encode_to_buffer(&asn_DEF_BCCH_DL_SCH_Message,
winckel's avatar
winckel committed
582
583
584
                                   (void*)bcch_message,
                                   buffer,
                                   100);
knopp's avatar
   
knopp committed
585
  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
586
               enc_rval.failed_type->name, enc_rval.encoded);
winckel's avatar
winckel committed
587
588
589
590
591
592
593

#if defined(ENABLE_ITTI)
# if !defined(DISABLE_XER_SPRINT)
  {
    char        message_string[10000];
    size_t      message_string_size;

594
    if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) {
595
      MessageDef *msg_p;
winckel's avatar
winckel committed
596

winckel's avatar
winckel committed
597
598
599
      msg_p = itti_alloc_new_message_sized (TASK_RRC_ENB, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText));
      msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size;
      memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size);
winckel's avatar
winckel committed
600

601
      itti_send_msg_to_task(TASK_UNKNOWN, Mod_id, msg_p);
winckel's avatar
winckel committed
602
603
604
605
606
    }
  }
# endif
#endif

607
608
609
610
#ifdef USER_MODE
  LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
#endif

611
  if (enc_rval.encoded==-1) {
612
    return(-1);
613
  }
614

615
616
617
618
  return((enc_rval.encoded+7)/8);
}

uint8_t do_SIB23(uint8_t Mod_id,
619
                 int CC_id,
winckel's avatar
winckel committed
620
621
622
623
624
                 LTE_DL_FRAME_PARMS *frame_parms,
                 uint8_t *buffer,
                 BCCH_DL_SCH_Message_t *bcch_message,
                 SystemInformationBlockType2_t **sib2,
                 SystemInformationBlockType3_t **sib3
625
#ifdef Rel10
winckel's avatar
winckel committed
626
                 ,
627
                 SystemInformationBlockType13_r9_t **sib13,
winckel's avatar
winckel committed
628
                 uint8_t MBMS_flag
629
630
#endif
#if defined(ENABLE_ITTI)
631
                 , RrcConfigurationReq *configuration
632
#endif
633
634
                )
{
635
  struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib2_part,*sib3_part;
636
#ifdef Rel10
637
  struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib13_part;
638
639
  MBSFN_SubframeConfigList_t *MBSFNSubframeConfigList;
  MBSFN_AreaInfoList_r9_t *MBSFNArea_list;
640
  struct MBSFN_AreaInfo_r9 *MBSFN_Area1, *MBSFN_Area2;
641
642
643
#endif
  asn_enc_rval_t enc_rval;

644
  if (bcch_message) {
645
    memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_t));
646
  } else {
winckel's avatar
winckel committed
647
    LOG_E(RRC,"[eNB %d] BCCH_MESSAGE is null, exiting\n", Mod_id);
648
649
650
651
    exit(-1);
  }

  if (!sib2) {
winckel's avatar
winckel committed
652
    LOG_E(RRC,"[eNB %d] sib2 is null, exiting\n", Mod_id);
653
654
655
656
    exit(-1);
  }

  if (!sib3) {
winckel's avatar
winckel committed
657
    LOG_E(RRC,"[eNB %d] sib3 is null, exiting\n", Mod_id);
658
659
    exit(-1);
  }
660

661
#ifdef Rel10
winckel's avatar
winckel committed
662
  LOG_I(RRC,"[eNB %d] Configuration SIB2/3, MBMS = %d\n", Mod_id, MBMS_flag);
663
#else
winckel's avatar
winckel committed
664
  LOG_I(RRC,"[eNB %d] Configuration SIB2/3\n", Mod_id);
665
#endif
666
667
668
669
  sib2_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
  sib3_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
  memset(sib2_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
  memset(sib3_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
670

671
672
  sib2_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2;
  sib3_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3;
673
674
675
676
677

  *sib2 = &sib2_part->choice.sib2;
  *sib3 = &sib3_part->choice.sib3;

#ifdef Rel10
678

679
  if (MBMS_flag > 0) {
680
681
682
    sib13_part = CALLOC(1,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
    memset(sib13_part,0,sizeof(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member));
    sib13_part->present = SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920;
683
684
    *sib13 = &sib13_part->choice.sib13_v920;
  }
685

686
687
688
689
690
691
#endif

  // sib2

  (*sib2)->ac_BarringInfo = NULL;
#ifdef Rel10
692
#if 0
693
694
695
696
  (*sib2)->ssac_BarringForMMTEL_Voice_r9 = NULL;
  (*sib2)->ssac_BarringForMMTEL_Video_r9 = NULL;
  (*sib2)->ac_BarringForCSFB_r10 = NULL;
#endif
697
698
699
  (*sib2)->ext1 = NULL;
  (*sib2)->ext2 = NULL;
#endif
700

knopp's avatar
knopp committed
701
702
#if defined(ENABLE_ITTI)

703
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles                         = configuration->rach_numberOfRA_Preambles[CC_id];
knopp's avatar
knopp committed
704
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig                        = NULL;
705

706
  if (configuration->rach_preamblesGroupAConfig[CC_id]) {
707
708
709
    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig
      = CALLOC(1,sizeof(struct RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig));
    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA
710
      = configuration->rach_sizeOfRA_PreamblesGroupA[CC_id];
711
    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->messageSizeGroupA
712
      = configuration->rach_messageSizeGroupA[CC_id];
knopp's avatar
knopp committed
713
    (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig->messagePowerOffsetGroupB
714
      = configuration->rach_messagePowerOffsetGroupB[CC_id];
knopp's avatar
knopp committed
715
  }
716

717
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep                   = configuration->rach_powerRampingStep[CC_id];
718
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower =
719
720
721
    configuration->rach_preambleInitialReceivedTargetPower[CC_id];
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax                       = configuration->rach_preambleTransMax[CC_id];
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize                  = configuration->rach_raResponseWindowSize[CC_id];
722
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer          =
723
724
    configuration->rach_macContentionResolutionTimer[CC_id];
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx                                            = configuration->rach_maxHARQ_Msg3Tx[CC_id];
knopp's avatar
knopp committed
725
726

  // BCCH-Config
727
  (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff
728
    = configuration->bcch_modificationPeriodCoeff[CC_id];
knopp's avatar
knopp committed
729
730

  // PCCH-Config
731
  (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle
732
    = configuration->pcch_defaultPagingCycle[CC_id];
733
  (*sib2)->radioResourceConfigCommon.pcch_Config.nB
734
    = configuration->pcch_nB[CC_id];
knopp's avatar
knopp committed
735
736

  // PRACH-Config
737
  (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex
738
    = configuration->prach_root[CC_id];
739
  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex
740
    = configuration->prach_config_index[CC_id];
741
  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag
742
    = configuration->prach_high_speed[CC_id];
743
  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig
744
    = configuration->prach_zero_correlation[CC_id];
745
  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset
746
    = configuration->prach_freq_offset[CC_id];
knopp's avatar
knopp committed
747
748
749

  // PDSCH-Config
  (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower
750
    = configuration->pdsch_referenceSignalPower[CC_id];
knopp's avatar
knopp committed
751
  (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b
752
    = configuration->pdsch_p_b[CC_id];
knopp's avatar
knopp committed
753
754

  // PUSCH-Config
755
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB
756
    = configuration->pusch_n_SB[CC_id];
knopp's avatar
knopp committed
757
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode
758
    = configuration->pusch_hoppingMode[CC_id];
knopp's avatar
knopp committed
759
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset
760
    = configuration->pusch_hoppingOffset[CC_id];
knopp's avatar
knopp committed
761
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM
762
    = configuration->pusch_enable64QAM[CC_id];
knopp's avatar
knopp committed
763
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled
764
    = configuration->pusch_groupHoppingEnabled[CC_id];
knopp's avatar
knopp committed
765
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH
766
    = configuration->pusch_groupAssignment[CC_id];
knopp's avatar
knopp committed
767
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled
768
    = configuration->pusch_sequenceHoppingEnabled[CC_id];
knopp's avatar
knopp committed
769
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift
770
    = configuration->pusch_nDMRS1[CC_id];
knopp's avatar
knopp committed
771
772
773
774

  // PUCCH-Config

  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift
775
    = configuration->pucch_delta_shift[CC_id];
776
  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI
777
    = configuration->pucch_nRB_CQI[CC_id];
778
  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN
779
    = configuration->pucch_nCS_AN[CC_id];
780
#ifndef Rel10
781
  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN
782
    = configuration->pucch_n1_AN[CC_id];
783
#endif
knopp's avatar
knopp committed
784
785

  // SRS Config
786
  if (configuration->srs_enable[CC_id]) {
knopp's avatar
knopp committed
787
    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present
788
      = SoundingRS_UL_ConfigCommon_PR_setup;
knopp's avatar
knopp committed
789
    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_BandwidthConfig
790
      = configuration->srs_BandwidthConfig[CC_id];
knopp's avatar
knopp committed
791
    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig
792
      = configuration->srs_SubframeConfig[CC_id];
knopp's avatar
knopp committed
793
    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.ackNackSRS_SimultaneousTransmission
794
      = configuration->srs_ackNackST[CC_id];
795

796
    if (configuration->srs_MaxUpPts[CC_id]) {
knopp's avatar
knopp committed
797
      (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts
798
        = CALLOC(1,sizeof(long));
knopp's avatar
knopp committed
799
      *(*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts=1;
800
    } else {
knopp's avatar
knopp committed
801
802
      (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts = NULL;
    }
803
  } else {
knopp's avatar
knopp committed
804
805
806
807
808
809
    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present=SoundingRS_UL_ConfigCommon_PR_release;
    (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.release=0;
  }

  // uplinkPowerControlCommon

810
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH
811
    = configuration->pusch_p0_Nominal[CC_id];
812
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH
813
    = configuration->pucch_p0_Nominal[CC_id];
814
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.alpha
815
    = configuration->pusch_alpha[CC_id];
knopp's avatar
knopp committed
816
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1
817
    = configuration->pucch_deltaF_Format1[CC_id];
knopp's avatar
knopp committed
818
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b
819
    = configuration->pucch_deltaF_Format1b[CC_id];
knopp's avatar
knopp committed
820
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2
821
    = configuration->pucch_deltaF_Format2[CC_id];
knopp's avatar
knopp committed
822
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a
823
    = configuration->pucch_deltaF_Format2a[CC_id];
knopp's avatar
knopp committed
824
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b
825
    = configuration->pucch_deltaF_Format2b[CC_id];
knopp's avatar
knopp committed
826
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3
827
    = configuration->msg3_delta_Preamble[CC_id];
knopp's avatar
knopp committed
828
  (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength
829
    = configuration->ul_CyclicPrefixLength[CC_id];
knopp's avatar
knopp committed
830
831
832
833

  // UE Timers and Constants

  (*sib2)->ue_TimersAndConstants.t300
834
    = configuration->ue_TimersAndConstants_t300[CC_id];
knopp's avatar
knopp committed
835
  (*sib2)->ue_TimersAndConstants.t301
836
    = configuration->ue_TimersAndConstants_t301[CC_id];
knopp's avatar
knopp committed
837
  (*sib2)->ue_TimersAndConstants.t310
838
    = configuration->ue_TimersAndConstants_t310[CC_id];
knopp's avatar
knopp committed
839
  (*sib2)->ue_TimersAndConstants.n310
840
    = configuration->ue_TimersAndConstants_n310[CC_id];
knopp's avatar
knopp committed
841
  (*sib2)->ue_TimersAndConstants.t311
842
    = configuration->ue_TimersAndConstants_t311[CC_id];
knopp's avatar
knopp committed
843
  (*sib2)->ue_TimersAndConstants.n311
844
    = configuration->ue_TimersAndConstants_n311[CC_id];
knopp's avatar
knopp committed
845
846

#else
847
848
849
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles=RACH_ConfigCommon__preambleInfo__numberOfRA_Preambles_n64;
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL;
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.powerRampingStep=RACH_ConfigCommon__powerRampingParameters__powerRampingStep_dB2;
850
851
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.powerRampingParameters.preambleInitialReceivedTargetPower=
    RACH_ConfigCommon__powerRampingParameters__preambleInitialReceivedTargetPower_dBm_100;
852
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.preambleTransMax=RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10;
knopp's avatar
knopp committed
853
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.ra_ResponseWindowSize=RACH_ConfigCommon__ra_SupervisionInfo__ra_ResponseWindowSize_sf10;
854
855
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer=
    RACH_ConfigCommon__ra_SupervisionInfo__mac_ContentionResolutionTimer_sf48;
856
857
858
859
860
861
  (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = 4;

  // BCCH-Config
  (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff=BCCH_Config__modificationPeriodCoeff_n2;

  // PCCH-Config
knopp's avatar
knopp committed
862
  (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle = PCCH_Config__defaultPagingCycle_rf128;
863
864
865
866
867
868
869
870
871
872
  (*sib2)->radioResourceConfigCommon.pcch_Config.nB=PCCH_Config__nB_oneT;

  // PRACH-Config
  (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex=Mod_id;//0;//384;
  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex = 0;//3;
  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag = 0;
  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig = 1;//12;
  (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset = 2;

  // PDSCH-Config
knopp's avatar
   
knopp committed
873
  (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower=0;  // corresponds to 24.7 dBm 5 MHz/ 27.7 10 MHz/ 30.7 20 MHz
knopp's avatar
knopp committed
874

875
  if (frame_parms->mode1_flag==1) {
876
    (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=0;
877
  } else {
878
879
    (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=1;

880
  }
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932

  // PUSCH-Config
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB=1;
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode=PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset=0;
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM=0;
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled=1;
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH=0;
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled=0;
  (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift=0;

  // PUCCH-Config

  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift=PUCCH_ConfigCommon__deltaPUCCH_Shift_ds1;
  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI = 1;
  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN = 0;
  (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN = 32;


  (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present=SoundingRS_UL_ConfigCommon_PR_release;
  (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.release=0;

  // uplinkPowerControlCommon

  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH = -108;
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH = -108;
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.alpha=UplinkPowerControlCommon__alpha_al1;
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1=DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b=DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;

  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2=DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;

  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a=DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;

  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b=DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;

  (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 = 6;

  (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength=UL_CyclicPrefixLength_len1;

  (*sib2)->ue_TimersAndConstants.t300=UE_TimersAndConstants__t300_ms1000;

  (*sib2)->ue_TimersAndConstants.t301=UE_TimersAndConstants__t301_ms1000;

  (*sib2)->ue_TimersAndConstants.t310=UE_TimersAndConstants__t310_ms1000;

  (*sib2)->ue_TimersAndConstants.n310=UE_TimersAndConstants__n310_n20;

  (*sib2)->ue_TimersAndConstants.t311=UE_TimersAndConstants__t311_ms10000;

  (*sib2)->ue_TimersAndConstants.n311=UE_TimersAndConstants__n311_n1;

knopp's avatar
knopp committed
933
934
#endif

935
936
937
938
939
940
  (*sib2)->freqInfo.additionalSpectrumEmission = 1;
  (*sib2)->freqInfo.ul_CarrierFreq = NULL;
  (*sib2)->freqInfo.ul_Bandwidth = NULL;
  //  (*sib2)->mbsfn_SubframeConfigList = NULL;

#ifdef Rel10
941

942
  if (MBMS_flag > 0) {
943
    LOG_I(RRC,"Adding MBSFN subframe Configuration 1 to SIB2\n");
944
945
946
    MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig1;
    (*sib2)->mbsfn_SubframeConfigList = CALLOC(1,sizeof(struct MBSFN_SubframeConfigList));
    MBSFNSubframeConfigList = (*sib2)->mbsfn_SubframeConfigList;
947

948
949
    sib2_mbsfn_SubframeConfig1= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig1));
    memset((void*)sib2_mbsfn_SubframeConfig1,0,sizeof(*sib2_mbsfn_SubframeConfig1));
950

951
952
953
954
955
956
    sib2_mbsfn_SubframeConfig1->radioframeAllocationPeriod= MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
    sib2_mbsfn_SubframeConfig1->radioframeAllocationOffset= 1;
    sib2_mbsfn_SubframeConfig1->subframeAllocation.present= MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame;
    sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf= MALLOC(1);
    sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.size= 1;
    sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.bits_unused= 2;
957

958
    if (frame_parms->frame_type == TDD) {
959
      sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2 cuz 2last bits are unused.
960
    } else { /// 111000
961
      sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2;
962
    }
963

964
    ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig1);
965

966
967
968
969
970
    if (MBMS_flag == 4 ) {
      LOG_I(RRC,"Adding MBSFN subframe Configuration 2 to SIB2\n");
      MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig2;
      sib2_mbsfn_SubframeConfig2= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig2));
      memset((void*)sib2_mbsfn_SubframeConfig2,0,sizeof(*sib2_mbsfn_SubframeConfig2));
971

972
973
974
975
976
977
      sib2_mbsfn_SubframeConfig2->radioframeAllocationPeriod= MBSFN_SubframeConfig__radioframeAllocationPeriod_n4;
      sib2_mbsfn_SubframeConfig2->radioframeAllocationOffset= 1;
      sib2_mbsfn_SubframeConfig2->subframeAllocation.present= MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame;
      sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf= MALLOC(1);
      sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.size= 1;
      sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.bits_unused= 2;
978

979
      if (frame_parms->frame_type == TDD) {
980
981
982
        sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2 cuz 2last bits are unused.
      } else { ///000111
        sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2;
983
      }
984

985
986
      ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig2);
    }
987
  }
988

989
#else // no MBMS transmission
990
  (*sib2)->mbsfn_SubframeConfigList = NULL;
991
#endif
992

gauthier's avatar
gauthier committed
993
  (*sib2)->timeAlignmentTimerCommon=TimeAlignmentTimer_infinity;//TimeAlignmentTimer_sf5120;
994
995
996

  /// (*SIB3)
#ifdef Rel10
997
998
  (*sib3)->ext1 = NULL;
#if 0
999
1000
1001
1002
  (*sib3)->s_IntraSearch_v920=NULL;
  (*sib3)->s_NonIntraSearch_v920=NULL;
  (*sib3)->q_QualMin_r9=NULL;
  (*sib3)->threshServingLowQ_r9=NULL;
1003
#endif
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
#endif
  (*sib3)->cellReselectionInfoCommon.q_Hyst=SystemInformationBlockType3__cellReselectionInfoCommon__q_Hyst_dB4;

  (*sib3)->cellReselectionInfoCommon.speedStateReselectionPars=NULL;

  (*sib3)->cellReselectionServingFreqInfo.s_NonIntraSearch=NULL;
  (*sib3)->cellReselectionServingFreqInfo.threshServingLow=31;
  (*sib3)->cellReselectionServingFreqInfo.cellReselectionPriority=7;

  (*sib3)->intraFreqCellReselectionInfo.q_RxLevMin = -70;
  (*sib3)->intraFreqCellReselectionInfo.p_Max = NULL;