enb_config.c 187 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

Lionel Gauthier's avatar
Lionel Gauthier committed
22
/*
23 24
  enb_config.c
  -------------------
25
  AUTHOR  : Lionel GAUTHIER, navid nikaein, Laurent Winckel
Lionel Gauthier's avatar
Lionel Gauthier committed
26
  COMPANY : EURECOM
27
  EMAIL   : Lionel.Gauthier@eurecom.fr, navid.nikaein@eurecom.fr
28
*/
29 30

#include <string.h>
31
#include <inttypes.h>
32
#include <dlfcn.h>
33

34
#include "common/utils/LOG/log.h"
35 36
#include "assertions.h"
#include "enb_config.h"
37 38
#include "UTIL/OTG/otg.h"
#include "UTIL/OTG/otg_externs.h"
39 40 41
#include "intertask_interface.h"
#include "s1ap_eNB.h"
#include "sctp_eNB_task.h"
42
#include "common/ran_context.h"
43
#include "sctp_default_values.h"
44
#include "LTE_SystemInformationBlockType2.h"
45 46 47
#include "LAYER2/MAC/mac_extern.h"
#include "LAYER2/MAC/mac_proto.h"
#include "PHY/phy_extern.h"
48
#include "PHY/INIT/phy_init.h"
49
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
50 51
#include "nfapi_vnf.h"
#include "nfapi_pnf.h"
52
#include "targets/RT/USER/lte-softmodem.h"
53 54
#include "L1_paramdef.h"
#include "MACRLC_paramdef.h"
55
#include "common/config/config_userapi.h"
56 57
#include "RRC_config_tools.h"
#include "enb_paramdef.h"
frtabu's avatar
frtabu committed
58
#include "proto_agent.h"
59
#include "executables/thread-common.h"
Laurent Thomas's avatar
Laurent Thomas committed
60
#include <openair3/ocp-gtpu/gtp_itf.h>
61

62 63
extern uint32_t to_earfcn_DL(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw);
extern uint32_t to_earfcn_UL(int eutra_bandP, uint32_t ul_CarrierFreq, uint32_t bw);
64 65
extern char *parallel_config;
extern char *worker_config;
Lionel Gauthier's avatar
 
Lionel Gauthier committed
66

Raymond Knopp's avatar
Raymond Knopp committed
67 68
RAN_CONTEXT_t RC;

laurent's avatar
laurent committed
69
void RCconfig_flexran() {
70 71 72
  /* get number of eNBs */
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL);
73
  uint16_t num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt;
74 75 76 77
  paramdef_t flexranParams[] = FLEXRANPARAMS_DESC;
  config_get(flexranParams, sizeof(flexranParams)/sizeof(paramdef_t), CONFIG_STRING_NETWORK_CONTROLLER_CONFIG);

  if (!RC.flexran) {
laurent's avatar
laurent committed
78
    RC.flexran = calloc(num_enbs, sizeof(flexran_agent_info_t *));
79
    AssertFatal(RC.flexran,
80
                "can't ALLOCATE %zu Bytes for %d flexran agent info with size %zu\n",
laurent's avatar
laurent committed
81 82
                num_enbs * sizeof(flexran_agent_info_t *),
                num_enbs, sizeof(flexran_agent_info_t *));
83 84
  }

85
  for (uint16_t i = 0; i < num_enbs; i++) {
86
    RC.flexran[i] = calloc(1, sizeof(flexran_agent_info_t));
87
    AssertFatal(RC.flexran[i],
88
                "can't ALLOCATE %zu Bytes for flexran agent info (iteration %d/%d)\n",
89
                sizeof(flexran_agent_info_t), i + 1, num_enbs);
90
    /* if config says "yes", enable Agent, in all other cases it's like "no" */
91
    RC.flexran[i]->enabled          = strcasecmp(*(flexranParams[FLEXRAN_ENABLED].strptr), "yes") == 0;
laurent's avatar
laurent committed
92

93 94 95
    /* if not enabled, simply skip the rest, it is not needed anyway */
    if (!RC.flexran[i]->enabled)
      continue;
laurent's avatar
laurent committed
96

97 98 99 100 101
    RC.flexran[i]->interface_name   = strdup(*(flexranParams[FLEXRAN_INTERFACE_NAME_IDX].strptr));
    //inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN);
    RC.flexran[i]->remote_ipv4_addr = strdup(*(flexranParams[FLEXRAN_IPV4_ADDRESS_IDX].strptr));
    RC.flexran[i]->remote_port      = *(flexranParams[FLEXRAN_PORT_IDX].uptr);
    RC.flexran[i]->cache_name       = strdup(*(flexranParams[FLEXRAN_CACHE_IDX].strptr));
102
    RC.flexran[i]->node_ctrl_state  = strcasecmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0 ? ENB_WAIT : ENB_NORMAL_OPERATION;
103
    RC.flexran[i]->mod_id  = i;
104
  }
105 106
}

107

108
void RCconfig_L1(void) {
109 110 111 112
  int               i,j;
  paramdef_t L1_Params[] = L1PARAMS_DESC;
  paramlist_def_t L1_ParamList = {CONFIG_STRING_L1_LIST,NULL,0};

113
  if (RC.eNB == NULL) {
114
    RC.eNB                       = (PHY_VARS_eNB ** *)malloc((1+NUMBER_OF_eNB_MAX)*sizeof(PHY_VARS_eNB **));
115
    LOG_I(PHY,"RC.eNB = %p\n",RC.eNB);
laurent's avatar
laurent committed
116
    memset(RC.eNB,0,(1+NUMBER_OF_eNB_MAX)*sizeof(PHY_VARS_eNB **));
117 118
    RC.nb_L1_CC = malloc((1+RC.nb_L1_inst)*sizeof(int));
  }
119

Cedric Roux's avatar
Cedric Roux committed
120
  config_getlist( &L1_ParamList,L1_Params,sizeof(L1_Params)/sizeof(paramdef_t), NULL);
laurent's avatar
laurent committed
121

122 123 124 125 126
  if (L1_ParamList.numelt > 0) {
    for (j = 0; j < RC.nb_L1_inst; j++) {
      RC.nb_L1_CC[j] = *(L1_ParamList.paramarray[j][L1_CC_IDX].uptr);

      if (RC.eNB[j] == NULL) {
Laurent's avatar
Laurent committed
127
        RC.eNB[j]  = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB *));
laurent's avatar
laurent committed
128 129
        LOG_I(PHY,"RC.eNB[%d] = %p\n",j,RC.eNB[j]);
        memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB *));
130 131
      }

laurent's avatar
laurent committed
132
      for (i=0; i<RC.nb_L1_CC[j]; i++) {
133
        if (RC.eNB[j][i] == NULL) {
Laurent's avatar
Laurent committed
134
          RC.eNB[j][i] = (PHY_VARS_eNB *)calloc(1, sizeof(PHY_VARS_eNB));
135 136 137 138
          LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.eNB[j][i]);
          RC.eNB[j][i]->Mod_id  = j;
          RC.eNB[j][i]->CC_id   = i;
        }
139 140 141
      }

      if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
laurent's avatar
laurent committed
142
      } else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
143
        RC.eNB[j][0]->eth_params_n.local_if_name            = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_IF_NAME_IDX].strptr));
laurent's avatar
laurent committed
144 145 146 147 148 149 150
        RC.eNB[j][0]->eth_params_n.my_addr                  = strdup(*(L1_ParamList.paramarray[j][L1_LOCAL_N_ADDRESS_IDX].strptr));
        RC.eNB[j][0]->eth_params_n.remote_addr              = strdup(*(L1_ParamList.paramarray[j][L1_REMOTE_N_ADDRESS_IDX].strptr));
        RC.eNB[j][0]->eth_params_n.my_portc                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTC_IDX].iptr);
        RC.eNB[j][0]->eth_params_n.remote_portc             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTC_IDX].iptr);
        RC.eNB[j][0]->eth_params_n.my_portd                 = *(L1_ParamList.paramarray[j][L1_LOCAL_N_PORTD_IDX].iptr);
        RC.eNB[j][0]->eth_params_n.remote_portd             = *(L1_ParamList.paramarray[j][L1_REMOTE_N_PORTD_IDX].iptr);
        RC.eNB[j][0]->eth_params_n.transp_preference        = ETH_UDP_MODE;
151 152 153 154 155 156 157 158
        RC.nb_macrlc_inst = 1;  // This is used by mac_top_init_eNB()
        // This is used by init_eNB_afterRU()
        RC.nb_CC = (int *)malloc((1+RC.nb_inst)*sizeof(int));
        RC.nb_CC[0]=1;
        RC.nb_inst =1; // DJP - feptx_prec uses num_eNB but phy_init_RU uses nb_inst
        LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_inst=1 this is because phy_init_RU() uses that to index and not RC.num_eNB - why the 2 similar variables?\n", __FUNCTION__);
        LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_CC[0]=%d for init_eNB_afterRU()\n", __FUNCTION__, RC.nb_CC[0]);
        LOG_I(PHY,"%s() NFAPI PNF mode - RC.nb_macrlc_inst:%d because used by mac_top_init_eNB()\n", __FUNCTION__, RC.nb_macrlc_inst);
159
        mac_top_init_eNB();
160 161
        configure_nfapi_pnf(RC.eNB[j][0]->eth_params_n.remote_addr, RC.eNB[j][0]->eth_params_n.remote_portc, RC.eNB[j][0]->eth_params_n.my_addr, RC.eNB[j][0]->eth_params_n.my_portd,
                            RC.eNB[j][0]->eth_params_n     .remote_portd);
laurent's avatar
laurent committed
162
      } else { // other midhaul
163
      }
164

frtabu's avatar
frtabu committed
165
      // PRACH/PUCCH parameters
166 167 168
      RC.eNB[j][0]->prach_DTX_threshold    = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD_IDX].iptr);
      RC.eNB[j][0]->pucch1_DTX_threshold   = *(L1_ParamList.paramarray[j][L1_PUCCH1_DTX_THRESHOLD_IDX].iptr);
      RC.eNB[j][0]->pucch1ab_DTX_threshold = *(L1_ParamList.paramarray[j][L1_PUCCH1AB_DTX_THRESHOLD_IDX].iptr);
frtabu's avatar
frtabu committed
169 170 171 172 173

      for (int ce_level=0; ce_level<4; ce_level++) {
        RC.eNB[j][0]->prach_DTX_threshold_emtc[ce_level]    = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr);
        RC.eNB[j][0]->pucch1_DTX_threshold_emtc[ce_level]   = *(L1_ParamList.paramarray[j][L1_PUCCH1_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr);
        RC.eNB[j][0]->pucch1ab_DTX_threshold_emtc[ce_level] = *(L1_ParamList.paramarray[j][L1_PUCCH1AB_DTX_EMTC0_THRESHOLD_IDX+ce_level].iptr);
174
      }
175 176 177 178


      RC.eNB[j][0]->pusch_signal_threshold    = *(L1_ParamList.paramarray[j][L1_PUSCH_SIGNAL_THRESHOLD_IDX].iptr);
      LOG_I(ENB_APP,"PUSCH singal threshold = %d \n",RC.eNB[j][0]->pusch_signal_threshold);
179
    }// j=0..num_inst
laurent's avatar
laurent committed
180

181
    LOG_I(ENB_APP,"Initializing northbound interface for L1\n");
182 183
    l1_north_init_eNB();
  } else {
laurent's avatar
laurent committed
184
    LOG_I(PHY,"No " CONFIG_STRING_L1_LIST " configuration found");
185 186 187 188 189 190
    // DJP need to create some structures for VNF
    j = 0;
    RC.nb_L1_CC = malloc((1+RC.nb_L1_inst)*sizeof(int)); // DJP - 1 lot then???
    RC.nb_L1_CC[j]=1; // DJP - hmmm

    if (RC.eNB[j] == NULL) {
laurent's avatar
laurent committed
191
      RC.eNB[j]                       = (PHY_VARS_eNB **)malloc((1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB **));
192
      LOG_I(PHY,"RC.eNB[%d] = %p\n",j,RC.eNB[j]);
frtabu's avatar
frtabu committed
193
      memset(RC.eNB[j],0,(1+MAX_NUM_CCs)*sizeof(PHY_VARS_eNB***));
194 195
    }

laurent's avatar
laurent committed
196
    for (i=0; i<RC.nb_L1_CC[j]; i++) {
197 198
      if (RC.eNB[j][i] == NULL) {
        RC.eNB[j][i] = (PHY_VARS_eNB *)malloc(sizeof(PHY_VARS_eNB));
laurent's avatar
laurent committed
199
        memset((void *)RC.eNB[j][i],0,sizeof(PHY_VARS_eNB));
200 201 202 203 204
        LOG_I(PHY,"RC.eNB[%d][%d] = %p\n",j,i,RC.eNB[j][i]);
        RC.eNB[j][i]->Mod_id  = j;
        RC.eNB[j][i]->CC_id   = i;
      }
    }
205 206 207
  }
}

208
void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) {
209
  int               j;
210 211
  paramdef_t MacRLC_Params[] = MACRLCPARAMS_DESC;
  paramlist_def_t MacRLC_ParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0};
laurent's avatar
laurent committed
212
  config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL);
frtabu's avatar
frtabu committed
213
  config_getlist( &MacRLC_ParamList,MacRLC_Params,sizeof(MacRLC_Params)/sizeof(paramdef_t), NULL);
214

215
  if ( MacRLC_ParamList.numelt > 0) {
frtabu's avatar
frtabu committed
216 217
    RC.nb_macrlc_inst=MacRLC_ParamList.numelt;
    mac_top_init_eNB();
laurent's avatar
laurent committed
218
    RC.nb_mac_CC = (int *)malloc(RC.nb_macrlc_inst*sizeof(int));
219

220
    for (j = 0; j < RC.nb_macrlc_inst; j++) {
Cedric Roux's avatar
Cedric Roux committed
221 222
      RC.mac[j]->puSch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCH10xSNR_IDX ].iptr);
      RC.mac[j]->puCch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCH10xSNR_IDX ].iptr);
223
      RC.mac[j]->ue_multiple_max = *(MacRLC_ParamList.paramarray[j][MACRLC_UE_MULTIPLE_MAX_IDX ].iptr);
224 225 226 227
      RC.mac[j]->use_mcs_offset = *(MacRLC_ParamList.paramarray[j][MACRLC_USE_MCS_OFFSET_IDX ].iptr);
      RC.mac[j]->bler_lower = *(MacRLC_ParamList.paramarray[j][MACRLC_BLER_TARGET_LOWER_IDX ].dblptr);
      RC.mac[j]->bler_upper = *(MacRLC_ParamList.paramarray[j][MACRLC_BLER_TARGET_UPPER_IDX ].dblptr);
      RC.mac[j]->max_ul_rb_index = *(MacRLC_ParamList.paramarray[j][MACRLC_MAX_UL_RB_INDEX_IDX ].iptr);
228
      RC.nb_mac_CC[j] = *(MacRLC_ParamList.paramarray[j][MACRLC_CC_IDX].iptr);
229 230 231 232 233 234 235 236 237
      LOG_I(ENB_APP,"MAC instance %d parameters : pusch_snr %lf, pucch_snr %lf, ue_multiple_max %d, use_mcs_offset %d, bler_lower %lf, bler_upper %lf,max_ul_rb_index %d\n",
	j,
	RC.mac[j]->puSch10xSnr/10.0,
	RC.mac[j]->puCch10xSnr/10.0,
	RC.mac[j]->ue_multiple_max,
	RC.mac[j]->use_mcs_offset,
	RC.mac[j]->bler_lower,
	RC.mac[j]->bler_upper,
	RC.mac[j]->max_ul_rb_index);
238
      if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) {
frtabu's avatar
frtabu committed
239
        // check number of instances is same as RRC/PDCP
240
        LOG_I(ENB_APP,"Configuring local RRC for MACRLC\n");
241
      } else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "f1") == 0) {
242
        LOG_I(ENB_APP,"Configuring F1 interfaces for MACRLC\n");
frtabu's avatar
frtabu committed
243 244 245 246 247 248 249 250
        RC.mac[j]->eth_params_n.local_if_name            = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_IF_NAME_IDX].strptr));
        RC.mac[j]->eth_params_n.my_addr                  = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr));
        RC.mac[j]->eth_params_n.remote_addr              = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr));
        RC.mac[j]->eth_params_n.my_portc                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTC_IDX].iptr);
        RC.mac[j]->eth_params_n.remote_portc             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTC_IDX].iptr);
        RC.mac[j]->eth_params_n.my_portd                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTD_IDX].iptr);
        RC.mac[j]->eth_params_n.remote_portd             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTD_IDX].iptr);;
        RC.mac[j]->eth_params_n.transp_preference        = ETH_UDP_MODE;
251
        macrlc_has_f1[j]                                 = 1;
252
      } else { // other midhaul
laurent's avatar
laurent committed
253 254
        AssertFatal(1==0,"MACRLC %d: %s unknown northbound midhaul\n",j, *(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr));
      }
255 256 257

      if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "local_L1") == 0) {
      } else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr), "nfapi") == 0) {
laurent's avatar
laurent committed
258 259 260 261 262 263 264 265
        RC.mac[j]->eth_params_s.local_if_name            = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_IF_NAME_IDX].strptr));
        RC.mac[j]->eth_params_s.my_addr                  = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_ADDRESS_IDX].strptr));
        RC.mac[j]->eth_params_s.remote_addr              = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_ADDRESS_IDX].strptr));
        RC.mac[j]->eth_params_s.my_portc                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTC_IDX].iptr);
        RC.mac[j]->eth_params_s.remote_portc             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTC_IDX].iptr);
        RC.mac[j]->eth_params_s.my_portd                 = *(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_S_PORTD_IDX].iptr);
        RC.mac[j]->eth_params_s.remote_portd             = *(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_S_PORTD_IDX].iptr);
        RC.mac[j]->eth_params_s.transp_preference        = ETH_UDP_MODE;
266
        LOG_I(ENB_APP,"**************** vnf_port:%d\n", RC.mac[j]->eth_params_s.my_portc);
267
        configure_nfapi_vnf(RC.mac[j]->eth_params_s.my_addr, RC.mac[j]->eth_params_s.my_portc);
268
        LOG_I(ENB_APP,"**************** RETURNED FROM configure_nfapi_vnf() vnf_port:%d\n", RC.mac[j]->eth_params_s.my_portc);
269
      } else { // other midhaul
laurent's avatar
laurent committed
270
        AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr));
271
      }
laurent's avatar
laurent committed
272 273 274

      if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr), "default") == 0) {
        global_scheduler_mode=SCHED_MODE_DEFAULT;
275
        LOG_I(ENB_APP,"sched mode = default %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr));
laurent's avatar
laurent committed
276 277 278 279 280 281
      } else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr), "fairRR") == 0) {
        global_scheduler_mode=SCHED_MODE_FAIR_RR;
        printf("sched mode = fairRR %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr));
      } else {
        global_scheduler_mode=SCHED_MODE_DEFAULT;
        printf("sched mode = default %d [%s]\n",global_scheduler_mode,*(MacRLC_ParamList.paramarray[j][MACRLC_SCHED_MODE_IDX].strptr));
282
      }
283 284 285 286 287

      char *s = *MacRLC_ParamList.paramarray[j][MACRLC_DEFAULT_SCHED_DL_ALGO_IDX].strptr;
      void *d = dlsym(NULL, s);
      AssertFatal(d, "%s(): no default scheduler DL algo '%s' found\n", __func__, s);
      // release default, add new
288 289 290 291 292
      pp_impl_param_t *dl_pp = &RC.mac[j]->pre_processor_dl;
      dl_pp->dl_algo.unset(&dl_pp->dl_algo.data);
      dl_pp->dl_algo = *(default_sched_dl_algo_t *) d;
      dl_pp->dl_algo.data = dl_pp->dl_algo.setup();
      LOG_I(ENB_APP, "using default scheduler DL algo '%s'\n", dl_pp->dl_algo.name);
293
    }// j=0..num_inst
Robert Schmidt's avatar
Robert Schmidt committed
294
  } /*else {// MacRLC_ParamList.numelt > 0 // ignore it
frtabu's avatar
frtabu committed
295

laurent's avatar
laurent committed
296 297
    AssertFatal (0,
                 "No " CONFIG_STRING_MACRLC_LIST " configuration found");
Robert Schmidt's avatar
Robert Schmidt committed
298
  }*/
299
}
300

301
int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) {
302
  int               num_enbs                      = 0;
303
  int               j,k                           = 0;
304
  int32_t           enb_id                        = 0;
305
  int               nb_cc                         = 0;
306 307
  int32_t           offsetMaxLimit                = 0;
  int32_t           cycleNb                       = 0;
frtabu's avatar
frtabu committed
308
   
309
  MessageDef *msg_p = itti_alloc_new_message(TASK_RRC_ENB, 0, RRC_CONFIGURATION_REQ);
310 311 312
  ccparams_lte_t ccparams_lte;
  ccparams_sidelink_t SLconfig;
  ccparams_eMTC_t eMTCconfig;
313 314 315
  memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t));
  memset((void *)&SLconfig,0,sizeof(ccparams_sidelink_t));
  memset((void *)&eMTCconfig,0,sizeof(ccparams_eMTC_t));
316 317
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  paramdef_t ENBParams[]  = ENBPARAMS_DESC;
laurent's avatar
laurent committed
318
  paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0};
319
  checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
320
  paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
321
  paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
322 323
  paramdef_t eMTCParams[]              = EMTCPARAMS_DESC((&eMTCconfig));
  checkedparam_t config_check_eMTCparams[] = EMTCPARAMS_CHECK;
324
  srb1_params_t srb1_params;
325
  memset((void *)&srb1_params,0,sizeof(srb1_params_t));
326 327 328
  paramdef_t SRB1Params[] = SRB1PARAMS_DESC(srb1_params);
  paramdef_t SLParams[]              = CCPARAMS_SIDELINK_DESC(SLconfig);

laurent's avatar
laurent committed
329
  /* map parameter checking array instances to parameter definition array instances */
330
  for (int I=0; I< ( sizeof(CCsParams)/ sizeof(paramdef_t)  ) ; I++) {
laurent's avatar
laurent committed
331
    CCsParams[I].chkPptr = &(config_check_CCparams[I]);
332
  }
333

334 335 336 337
  for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
    eMTCParams[I].chkPptr = &(config_check_eMTCparams[I]);
  }

laurent's avatar
laurent committed
338 339
  /* get global parameters, defined outside any section in the config file */
  config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
340 341
  num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt;
  AssertFatal (i<num_enbs,
frtabu's avatar
frtabu committed
342
               "Failed to parse config file no %uth element in %s \n",i, ENB_CONFIG_STRING_ACTIVE_ENBS);
343

344 345
  if (num_enbs>0) {
    // Output a list of all eNBs.
laurent's avatar
laurent committed
346 347 348 349 350 351 352 353
    config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL);

    if (ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr == NULL) {
      // Calculate a default eNB ID
      if (EPC_MODE_ENABLED) {
        uint32_t hash;
        hash = s1ap_generate_eNB_id ();
        enb_id = i + (hash & 0xFFFF8);
354
      } else {
laurent's avatar
laurent committed
355
        enb_id = i;
356
      }
laurent's avatar
laurent committed
357 358 359
    } else {
      enb_id = *(ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr);
    }
360

frtabu's avatar
frtabu committed
361 362 363 364 365
    LOG_I(RRC,"Instance %d: Southbound Transport %s\n",i,*(ENBParamList.paramarray[i][ENB_TRANSPORT_S_PREFERENCE_IDX].strptr));

    if (strcmp(*(ENBParamList.paramarray[i][ENB_TRANSPORT_S_PREFERENCE_IDX].strptr), "f1") == 0) {
      paramdef_t SCTPParams[]  = SCTPPARAMS_DESC;
      char aprefix[MAX_OPTNAME_SIZE*2 + 8];
frtabu's avatar
frtabu committed
366
      sprintf(aprefix,"%s.[%u].%s",ENB_CONFIG_STRING_ENB_LIST,i,ENB_CONFIG_STRING_SCTP_CONFIG);
frtabu's avatar
frtabu committed
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
      config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
      rrc->node_id        = *(ENBParamList.paramarray[0][ENB_ENB_ID_IDX].uptr);
      LOG_I(ENB_APP,"F1AP: gNB_CU_id[%d] %d\n",k,rrc->node_id);
      rrc->node_name = strdup(*(ENBParamList.paramarray[0][ENB_ENB_NAME_IDX].strptr));
      LOG_I(ENB_APP,"F1AP: gNB_CU_name[%d] %s\n",k,rrc->node_name);
      rrc->eth_params_s.local_if_name            = strdup(*(ENBParamList.paramarray[i][ENB_LOCAL_S_IF_NAME_IDX].strptr));
      rrc->eth_params_s.my_addr                  = strdup(*(ENBParamList.paramarray[i][ENB_LOCAL_S_ADDRESS_IDX].strptr));
      rrc->eth_params_s.remote_addr              = strdup(*(ENBParamList.paramarray[i][ENB_REMOTE_S_ADDRESS_IDX].strptr));
      rrc->eth_params_s.my_portc                 = *(ENBParamList.paramarray[i][ENB_LOCAL_S_PORTC_IDX].uptr);
      rrc->eth_params_s.remote_portc             = *(ENBParamList.paramarray[i][ENB_REMOTE_S_PORTC_IDX].uptr);
      rrc->eth_params_s.my_portd                 = *(ENBParamList.paramarray[i][ENB_LOCAL_S_PORTD_IDX].uptr);
      rrc->eth_params_s.remote_portd             = *(ENBParamList.paramarray[i][ENB_REMOTE_S_PORTD_IDX].uptr);
      rrc->eth_params_s.transp_preference        = ETH_UDP_MODE;
      rrc->node_type                             = ngran_eNB_CU;
      rrc->sctp_in_streams                       = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr);
      rrc->sctp_out_streams                      = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr);
    } else {
      // set to ngran_eNB for now, it will get set to ngran_eNB_DU if macrlc entity which uses F1 is present
      // Note: we will have to handle the case of ngran_ng_eNB_DU
      if (macrlc_has_f1 == 0) {
        rrc->node_type = ngran_eNB;
        LOG_I(RRC,"Setting node_type to ngran_eNB\n");
      } else {
        rrc->node_type = ngran_eNB_DU;
        LOG_I(RRC,"Setting node_type to ngran_eNB_DU\n");
392
      }
frtabu's avatar
frtabu committed
393
    }
394

frtabu's avatar
frtabu committed
395
    rrc->nr_cellid        = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr);
396

laurent's avatar
laurent committed
397
    // search if in active list
398

laurent's avatar
laurent committed
399
    for (k=0; k <num_enbs ; k++) {
400
      if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[k], *(ENBParamList.paramarray[i][ENB_ENB_NAME_IDX].strptr)) == 0) {
laurent's avatar
laurent committed
401
        char enbpath[MAX_OPTNAME_SIZE + 8];
402 403 404 405 406 407 408 409 410
        sprintf(enbpath,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
        paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
        paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0};
        /* map parameter checking array instances to parameter definition array instances */
        checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;

        for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I)
          PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);

411 412
        // In the configuration file it is in seconds. For RRC it has to be in milliseconds
        RRC_CONFIGURATION_REQ (msg_p).rrc_inactivity_timer_thres = (*ENBParamList.paramarray[i][ENB_RRC_INACTIVITY_THRES_IDX].uptr) * 1000;
laurent's avatar
laurent committed
413
        RRC_CONFIGURATION_REQ (msg_p).cell_identity = enb_id;
414
        RRC_CONFIGURATION_REQ (msg_p).tac = *ENBParamList.paramarray[i][ENB_TRACKING_AREA_CODE_IDX].uptr;
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
        AssertFatal(!ENBParamList.paramarray[i][ENB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr
                    && !ENBParamList.paramarray[i][ENB_MOBILE_NETWORK_CODE_IDX_OLD].strptr,
                    "It seems that you use an old configuration file. Please change the existing\n"
                    "    tracking_area_code  =  \"1\";\n"
                    "    mobile_country_code =  \"208\";\n"
                    "    mobile_network_code =  \"93\";\n"
                    "to\n"
                    "    tracking_area_code  =  1; // no string!!\n"
                    "    plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n");
        config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), enbpath);

        if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6)
          AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n",
                      PLMNParamList.numelt);

        RRC_CONFIGURATION_REQ(msg_p).num_plmn = PLMNParamList.numelt;

        for (int l = 0; l < PLMNParamList.numelt; ++l) {
          RRC_CONFIGURATION_REQ(msg_p).mcc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_COUNTRY_CODE_IDX].uptr;
          RRC_CONFIGURATION_REQ(msg_p).mnc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_NETWORK_CODE_IDX].uptr;
          RRC_CONFIGURATION_REQ(msg_p).mnc_digit_length[l] = *PLMNParamList.paramarray[l][ENB_MNC_DIGIT_LENGTH].u8ptr;
          AssertFatal(RRC_CONFIGURATION_REQ(msg_p).mnc_digit_length[l] == 3
                      || RRC_CONFIGURATION_REQ(msg_p).mnc[l] < 100,
                      "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n",
                      RRC_CONFIGURATION_REQ(msg_p).mnc[l]);
        }
441

442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
        /* measurement reports enabled? */
        if (ENBParamList.paramarray[i][ENB_ENABLE_MEASUREMENT_REPORTS].strptr != NULL &&
            *(ENBParamList.paramarray[i][ENB_ENABLE_MEASUREMENT_REPORTS].strptr) != NULL &&
            !strcmp(*(ENBParamList.paramarray[i][ENB_ENABLE_MEASUREMENT_REPORTS].strptr), "yes"))
          RRC_CONFIGURATION_REQ (msg_p).enable_measurement_reports = 1;
        else
          RRC_CONFIGURATION_REQ (msg_p).enable_measurement_reports = 0;

        /* x2 enabled? */
        if (ENBParamList.paramarray[i][ENB_ENABLE_X2].strptr != NULL &&
            *(ENBParamList.paramarray[i][ENB_ENABLE_X2].strptr) != NULL &&
            !strcmp(*(ENBParamList.paramarray[i][ENB_ENABLE_X2].strptr), "yes"))
          RRC_CONFIGURATION_REQ (msg_p).enable_x2 = 1;
        else
          RRC_CONFIGURATION_REQ (msg_p).enable_x2 = 0;

458 459 460 461 462 463 464 465
       /* m2 enabled */
       if (ENBParamList.paramarray[i][ENB_ENABLE_ENB_M2].strptr != NULL &&
            *(ENBParamList.paramarray[i][ENB_ENABLE_ENB_M2].strptr) != NULL &&
            !strcmp(*(ENBParamList.paramarray[i][ENB_ENABLE_ENB_M2].strptr), "yes"))
          RRC_CONFIGURATION_REQ (msg_p).eMBMS_M2_configured = 1;
        else
          RRC_CONFIGURATION_REQ (msg_p).eMBMS_M2_configured = 0;

laurent's avatar
laurent committed
466
        // Parse optional physical parameters
467
        config_getlist( &CCsParamList,NULL,0,enbpath);
laurent's avatar
laurent committed
468
        LOG_I(RRC,"num component carriers %d \n",CCsParamList.numelt);
469

laurent's avatar
laurent committed
470 471 472 473 474 475 476 477 478
        if ( CCsParamList.numelt> 0) {
          char ccspath[MAX_OPTNAME_SIZE*2 + 16];

          for (j = 0; j < CCsParamList.numelt ; j++) {
            sprintf(ccspath,"%s.%s.[%i]",enbpath,ENB_CONFIG_STRING_COMPONENT_CARRIERS,j);
            LOG_I(RRC, "enb_config::RCconfig_RRC() parameter number: %d, total number of parameters: %zd, ccspath: %s \n \n", j, sizeof(CCsParams)/sizeof(paramdef_t), ccspath);
            config_get( CCsParams,sizeof(CCsParams)/sizeof(paramdef_t),ccspath);
            //printf("Component carrier %d\n",component_carrier);
            nb_cc++;
479 480 481
            // Cell params, MIB/SIB1 in DU
            RRC_CONFIGURATION_REQ (msg_p).tdd_config[j] = ccparams_lte.tdd_config;
            AssertFatal (ccparams_lte.tdd_config <= LTE_TDD_Config__subframeAssignment_sa6,
frtabu's avatar
frtabu committed
482
                         "Failed to parse eNB configuration file %s, enb %u illegal tdd_config %d (should be 0-%d)!",
483 484 485
                         RC.config_file_name, i, ccparams_lte.tdd_config, LTE_TDD_Config__subframeAssignment_sa6);
            RRC_CONFIGURATION_REQ (msg_p).tdd_config_s[j] = ccparams_lte.tdd_config_s;
            AssertFatal (ccparams_lte.tdd_config_s <= LTE_TDD_Config__specialSubframePatterns_ssp8,
frtabu's avatar
frtabu committed
486
                         "Failed to parse eNB configuration file %s, enb %u illegal tdd_config_s %d (should be 0-%d)!",
487 488 489 490
                         RC.config_file_name, i, ccparams_lte.tdd_config_s, LTE_TDD_Config__specialSubframePatterns_ssp8);

            if (!ccparams_lte.prefix_type)
              AssertFatal (0,
frtabu's avatar
frtabu committed
491
                           "Failed to parse eNB configuration file %s, enb %u define %s: NORMAL,EXTENDED!\n",
492 493 494 495 496 497 498
                           RC.config_file_name, i, ENB_CONFIG_STRING_PREFIX_TYPE);
            else if (strcmp(ccparams_lte.prefix_type, "NORMAL") == 0) {
              RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = NORMAL;
            } else  if (strcmp(ccparams_lte.prefix_type, "EXTENDED") == 0) {
              RRC_CONFIGURATION_REQ (msg_p).prefix_type[j] = EXTENDED;
            } else {
              AssertFatal (0,
frtabu's avatar
frtabu committed
499
                           "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
500 501
                           RC.config_file_name, i, ccparams_lte.prefix_type);
            }
502

503 504
            if (!ccparams_lte.pbch_repetition)
              AssertFatal (0,
frtabu's avatar
frtabu committed
505
                           "Failed to parse eNB configuration file %s, enb %u define %s: TRUE,FALSE!\n",
506 507 508 509 510 511 512
                           RC.config_file_name, i, ENB_CONFIG_STRING_PBCH_REPETITION);
            else if (strcmp(ccparams_lte.pbch_repetition, "TRUE") == 0) {
              RRC_CONFIGURATION_REQ (msg_p).pbch_repetition[j] = 1;
            } else  if (strcmp(ccparams_lte.pbch_repetition, "FALSE") == 0) {
              RRC_CONFIGURATION_REQ (msg_p).pbch_repetition[j] = 0;
            } else {
              AssertFatal (0,
frtabu's avatar
frtabu committed
513
                           "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pbch_repetition choice: TRUE or FALSE !\n",
514 515
                           RC.config_file_name, i, ccparams_lte.pbch_repetition);
            }
516

517 518 519 520
            RRC_CONFIGURATION_REQ (msg_p).eutra_band[j] = ccparams_lte.eutra_band;
            RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j] = (uint32_t) ccparams_lte.downlink_frequency;
            RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j] = (unsigned int) ccparams_lte.uplink_frequency_offset;
            RRC_CONFIGURATION_REQ (msg_p).Nid_cell[j]= ccparams_lte.Nid_cell;
521

522 523
            if (ccparams_lte.Nid_cell>503) {
              AssertFatal (0,
frtabu's avatar
frtabu committed
524
                           "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
525 526
                           RC.config_file_name, i, ccparams_lte.Nid_cell);
            }
527

528
            RRC_CONFIGURATION_REQ (msg_p).N_RB_DL[j]= ccparams_lte.N_RB_DL;
529

530 531 532 533 534 535 536
            if ((ccparams_lte.N_RB_DL!=6) &&
                (ccparams_lte.N_RB_DL!=15) &&
                (ccparams_lte.N_RB_DL!=25) &&
                (ccparams_lte.N_RB_DL!=50) &&
                (ccparams_lte.N_RB_DL!=75) &&
                (ccparams_lte.N_RB_DL!=100)) {
              AssertFatal (0,
frtabu's avatar
frtabu committed
537
                           "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
538 539
                           RC.config_file_name, i, ccparams_lte.N_RB_DL);
            }
540

541 542 543 544 545 546
            if (strcmp(ccparams_lte.frame_type, "FDD") == 0) {
              RRC_CONFIGURATION_REQ (msg_p).frame_type[j] = FDD;
            } else  if (strcmp(ccparams_lte.frame_type, "TDD") == 0) {
              RRC_CONFIGURATION_REQ (msg_p).frame_type[j] = TDD;
            } else {
              AssertFatal (0,
frtabu's avatar
frtabu committed
547
                           "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
548
                           RC.config_file_name, i, ccparams_lte.frame_type);
549
            }
550

551 552 553 554 555 556 557
            if (config_check_band_frequencies(j,
                                              RRC_CONFIGURATION_REQ (msg_p).eutra_band[j],
                                              RRC_CONFIGURATION_REQ (msg_p).downlink_frequency[j],
                                              RRC_CONFIGURATION_REQ (msg_p).uplink_frequency_offset[j],
                                              RRC_CONFIGURATION_REQ (msg_p).frame_type[j])) {
              AssertFatal(0, "error calling enb_check_band_frequencies\n");
            }
558

559 560
            if ((ccparams_lte.nb_antenna_ports <1) || (ccparams_lte.nb_antenna_ports > 2))
              AssertFatal (0,
frtabu's avatar
frtabu committed
561
                           "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for nb_antenna_ports choice: 1..2 !\n",
562
                           RC.config_file_name, i, ccparams_lte.nb_antenna_ports);
laurent's avatar
laurent committed
563

564
            RRC_CONFIGURATION_REQ (msg_p).nb_antenna_ports[j] = ccparams_lte.nb_antenna_ports;
565

566
            if (!NODE_IS_DU(rrc->node_type)) { //this is CU or eNB, SIB2-20 in CU
567 568
              // Radio Resource Configuration (SIB2)
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_root =  ccparams_lte.prach_root;
laurent's avatar
laurent committed
569

570 571
              if ((ccparams_lte.prach_root <0) || (ccparams_lte.prach_root > 1023))
                AssertFatal (0,
frtabu's avatar
frtabu committed
572
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for prach_root choice: 0..1023 !\n",
573
                             RC.config_file_name, i, ccparams_lte.prach_root);
574

575
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_config_index = ccparams_lte.prach_config_index;
576

577 578
              if ((ccparams_lte.prach_config_index <0) || (ccparams_lte.prach_config_index > 63))
                AssertFatal (0,
frtabu's avatar
frtabu committed
579
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for prach_config_index choice: 0..1023 !\n",
580
                             RC.config_file_name, i, ccparams_lte.prach_config_index);
581

582 583
              if (!ccparams_lte.prach_high_speed)
                AssertFatal (0,
frtabu's avatar
frtabu committed
584
                             "Failed to parse eNB configuration file %s, enb %u define %s: ENABLE,DISABLE!\n",
585 586 587 588 589 590 591
                             RC.config_file_name, i, ENB_CONFIG_STRING_PRACH_HIGH_SPEED);
              else if (strcmp(ccparams_lte.prach_high_speed, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_high_speed = TRUE;
              } else if (strcmp(ccparams_lte.prach_high_speed, "DISABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_high_speed = FALSE;
              } else
                AssertFatal (0,
frtabu's avatar
frtabu committed
592
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for prach_config choice: ENABLE,DISABLE !\n",
593
                             RC.config_file_name, i, ccparams_lte.prach_high_speed);
594

595
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_zero_correlation = ccparams_lte.prach_zero_correlation;
596

597 598 599
              if ((ccparams_lte.prach_zero_correlation <0) ||
                  (ccparams_lte.prach_zero_correlation > 15))
                AssertFatal (0,
frtabu's avatar
frtabu committed
600
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for prach_zero_correlation choice: 0..15!\n",
601
                             RC.config_file_name, i, ccparams_lte.prach_zero_correlation);
602

603
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].prach_freq_offset = ccparams_lte.prach_freq_offset;
604

605 606 607
              if ((ccparams_lte.prach_freq_offset <0) ||
                  (ccparams_lte.prach_freq_offset > 94))
                AssertFatal (0,
frtabu's avatar
frtabu committed
608
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for prach_freq_offset choice: 0..94!\n",
609
                             RC.config_file_name, i, ccparams_lte.prach_freq_offset);
610

611
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_delta_shift = ccparams_lte.pucch_delta_shift-1;
612

613 614 615
              if ((ccparams_lte.pucch_delta_shift <1) ||
                  (ccparams_lte.pucch_delta_shift > 3))
                AssertFatal (0,
frtabu's avatar
frtabu committed
616
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pucch_delta_shift choice: 1..3!\n",
617
                             RC.config_file_name, i, ccparams_lte.pucch_delta_shift);
618

619
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_nRB_CQI = ccparams_lte.pucch_nRB_CQI;
620

621 622 623
              if ((ccparams_lte.pucch_nRB_CQI <0) ||
                  (ccparams_lte.pucch_nRB_CQI > 98))
                AssertFatal (0,
frtabu's avatar
frtabu committed
624
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pucch_nRB_CQI choice: 0..98!\n",
625
                             RC.config_file_name, i, ccparams_lte.pucch_nRB_CQI);
626

627
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_nCS_AN = ccparams_lte.pucch_nCS_AN;
628

629 630 631
              if ((ccparams_lte.pucch_nCS_AN <0) ||
                  (ccparams_lte.pucch_nCS_AN > 7))
                AssertFatal (0,
frtabu's avatar
frtabu committed
632
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pucch_nCS_AN choice: 0..7!\n",
633
                             RC.config_file_name, i, ccparams_lte.pucch_nCS_AN);
laurent's avatar
laurent committed
634

635
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_n1_AN = ccparams_lte.pucch_n1_AN;
636

637 638 639
              if ((ccparams_lte.pucch_n1_AN <0) ||
                  (ccparams_lte.pucch_n1_AN > 2047))
                AssertFatal (0,
frtabu's avatar
frtabu committed
640
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pucch_n1_AN choice: 0..2047!\n",
641
                             RC.config_file_name, i, ccparams_lte.pucch_n1_AN);
642

643
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pdsch_referenceSignalPower = ccparams_lte.pdsch_referenceSignalPower;
644

645 646 647
              if ((ccparams_lte.pdsch_referenceSignalPower <-60) ||
                  (ccparams_lte.pdsch_referenceSignalPower > 50))
                AssertFatal (0,
frtabu's avatar
frtabu committed
648
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pdsch_referenceSignalPower choice:-60..50!\n",
649
                             RC.config_file_name, i, ccparams_lte.pdsch_referenceSignalPower);
650

651
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pdsch_p_b = ccparams_lte.pdsch_p_b;
652

653 654 655
              if ((ccparams_lte.pdsch_p_b <0) ||
                  (ccparams_lte.pdsch_p_b > 3))
                AssertFatal (0,
frtabu's avatar
frtabu committed
656
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pdsch_p_b choice: 0..3!\n",
657
                             RC.config_file_name, i, ccparams_lte.pdsch_p_b);
658

659
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_n_SB = ccparams_lte.pusch_n_SB;
660

661 662 663
              if ((ccparams_lte.pusch_n_SB <1) ||
                  (ccparams_lte.pusch_n_SB > 4))
                AssertFatal (0,
frtabu's avatar
frtabu committed
664
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pusch_n_SB choice: 1..4!\n",
665
                             RC.config_file_name, i, ccparams_lte.pusch_n_SB);
666

667 668
              if (!ccparams_lte.pusch_hoppingMode)
                AssertFatal (0,
frtabu's avatar
frtabu committed
669
                             "Failed to parse eNB configuration file %s, enb %u define %s: interSubframe,intraAndInterSubframe!\n",
670 671 672
                             RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_HOPPINGMODE);
              else if (strcmp(ccparams_lte.pusch_hoppingMode,"interSubFrame")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame;
frtabu's avatar
frtabu committed
673
              } else if (strcmp(ccparams_lte.pusch_hoppingMode,"intraAndInterSubFrame")==0) {
674 675 676
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingMode = LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_intraAndInterSubFrame;
              } else
                AssertFatal (0,
frtabu's avatar
frtabu committed
677
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pusch_hoppingMode choice: interSubframe,intraAndInterSubframe!\n",
678
                             RC.config_file_name, i, ccparams_lte.pusch_hoppingMode);
679

680
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_hoppingOffset = ccparams_lte.pusch_hoppingOffset;
681

682 683 684
              if ((ccparams_lte.pusch_hoppingOffset<0) ||
                  (ccparams_lte.pusch_hoppingOffset>98))
                AssertFatal (0,
frtabu's avatar
frtabu committed
685
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pusch_hoppingOffset choice: 0..98!\n",
686
                             RC.config_file_name, i, ccparams_lte.pusch_hoppingMode);
687

688 689
              if (!ccparams_lte.pusch_enable64QAM)
                AssertFatal (0,
frtabu's avatar
frtabu committed
690
                             "Failed to parse eNB configuration file %s, enb %u define %s: ENABLE,DISABLE!\n",
691 692 693
                             RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_ENABLE64QAM);
              else if (strcmp(ccparams_lte.pusch_enable64QAM, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = TRUE;
frtabu's avatar
frtabu committed
694
              } else if (strcmp(ccparams_lte.pusch_enable64QAM, "DISABLE") == 0) {
695
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_enable64QAM = FALSE;
frtabu's avatar
frtabu committed
696
              } else
697
                AssertFatal (0,
frtabu's avatar
frtabu committed
698
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pusch_enable64QAM choice: ENABLE,DISABLE!\n",
699
                             RC.config_file_name, i, ccparams_lte.pusch_enable64QAM);
700

701 702
              if (!ccparams_lte.pusch_groupHoppingEnabled)
                AssertFatal (0,
frtabu's avatar
frtabu committed
703
                             "Failed to parse eNB configuration file %s, enb %u define %s: ENABLE,DISABLE!\n",
704 705 706
                             RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_GROUP_HOPPING_EN);
              else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled = TRUE;
frtabu's avatar
frtabu committed
707
              } else if (strcmp(ccparams_lte.pusch_groupHoppingEnabled, "DISABLE") == 0) {
708
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupHoppingEnabled= FALSE;
frtabu's avatar
frtabu committed
709
              } else
710
                AssertFatal (0,
frtabu's avatar
frtabu committed
711
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pusch_groupHoppingEnabled choice: ENABLE,DISABLE!\n",
712
                             RC.config_file_name, i, ccparams_lte.pusch_groupHoppingEnabled);
713

714
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_groupAssignment = ccparams_lte.pusch_groupAssignment;
715

716 717 718
              if ((ccparams_lte.pusch_groupAssignment<0)||
                  (ccparams_lte.pusch_groupAssignment>29))
                AssertFatal (0,
frtabu's avatar
frtabu committed
719
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pusch_groupAssignment choice: 0..29!\n",
720
                             RC.config_file_name, i, ccparams_lte.pusch_groupAssignment);
721

722 723
              if (!ccparams_lte.pusch_sequenceHoppingEnabled)
                AssertFatal (0,
frtabu's avatar
frtabu committed
724
                             "Failed to parse eNB configuration file %s, enb %u define %s: ENABLE,DISABLE!\n",
725 726 727
                             RC.config_file_name, i, ENB_CONFIG_STRING_PUSCH_SEQUENCE_HOPPING_EN);
              else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = TRUE;
frtabu's avatar
frtabu committed
728
              } else if (strcmp(ccparams_lte.pusch_sequenceHoppingEnabled, "DISABLE") == 0) {
729 730 731
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_sequenceHoppingEnabled = FALSE;
              } else
                AssertFatal (0,
frtabu's avatar
frtabu committed
732
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pusch_sequenceHoppingEnabled choice: ENABLE,DISABLE!\n",
733
                             RC.config_file_name, i, ccparams_lte.pusch_sequenceHoppingEnabled);
734

735
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_nDMRS1= ccparams_lte.pusch_nDMRS1;  //cyclic_shift in RRC!
laurent's avatar
laurent committed
736

737 738 739
              if ((ccparams_lte.pusch_nDMRS1 <0) ||
                  (ccparams_lte.pusch_nDMRS1>7))
                AssertFatal (0,
frtabu's avatar
frtabu committed
740
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pusch_nDMRS1 choice: 0..7!\n",
741
                             RC.config_file_name, i, ccparams_lte.pusch_nDMRS1);
742

743 744 745 746 747 748
              if (strcmp(ccparams_lte.phich_duration,"NORMAL")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration= LTE_PHICH_Config__phich_Duration_normal;
              } else if (strcmp(ccparams_lte.phich_duration,"EXTENDED")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration= LTE_PHICH_Config__phich_Duration_extended;
              } else
                AssertFatal (0,
frtabu's avatar
frtabu committed
749
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for phich_duration choice: NORMAL,EXTENDED!\n",
750
                             RC.config_file_name, i, ccparams_lte.phich_duration);
laurent's avatar
laurent committed
751

752 753
              if (strcmp(ccparams_lte.phich_resource,"ONESIXTH")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_oneSixth ;
frtabu's avatar
frtabu committed
754
              } else if (strcmp(ccparams_lte.phich_resource,"HALF")==0) {
755
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_half;
frtabu's avatar
frtabu committed
756
              } else if (strcmp(ccparams_lte.phich_resource,"ONE")==0) {
757
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_one;
frtabu's avatar
frtabu committed
758
              } else if (strcmp(ccparams_lte.phich_resource,"TWO")==0) {
759
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource= LTE_PHICH_Config__phich_Resource_two;
frtabu's avatar
frtabu committed
760
              } else
761
                AssertFatal (0,
frtabu's avatar
frtabu committed
762
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for phich_resource choice: ONESIXTH,HALF,ONE,TWO!\n",
763
                             RC.config_file_name, i, ccparams_lte.phich_resource);
laurent's avatar
laurent committed
764

765 766 767
              printf("phich.resource %ld (%s), phich.duration %ld (%s)\n",
                     RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_resource,ccparams_lte.phich_resource,
                     RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].phich_duration,ccparams_lte.phich_duration);
laurent's avatar
laurent committed
768

769 770
              if (strcmp(ccparams_lte.srs_enable, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= TRUE;
frtabu's avatar
frtabu committed
771
              } else if (strcmp(ccparams_lte.srs_enable, "DISABLE") == 0) {
772
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable= FALSE;
frtabu's avatar
frtabu committed
773
              } else
laurent's avatar
laurent committed
774
                AssertFatal (0,
frtabu's avatar
frtabu committed
775
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
776
                             RC.config_file_name, i, ccparams_lte.srs_enable);
777

778 779
              if (RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_enable== TRUE) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_BandwidthConfig= ccparams_lte.srs_BandwidthConfig;
780

781 782
                if ((ccparams_lte.srs_BandwidthConfig < 0) ||
                    (ccparams_lte.srs_BandwidthConfig >7))
frtabu's avatar
frtabu committed
783
                  AssertFatal (0, "Failed to parse eNB configuration file %s, enb %u unknown value %d for srs_BandwidthConfig choice: 0...7\n",
784 785 786 787 788 789 790
                               RC.config_file_name, i, ccparams_lte.srs_BandwidthConfig);

                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_SubframeConfig= ccparams_lte.srs_SubframeConfig;

                if ((ccparams_lte.srs_SubframeConfig<0) ||
                    (ccparams_lte.srs_SubframeConfig>15))
                  AssertFatal (0,
frtabu's avatar
frtabu committed
791
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for srs_SubframeConfig choice: 0..15 !\n",
792 793 794 795
                               RC.config_file_name, i, ccparams_lte.srs_SubframeConfig);

                if (strcmp(ccparams_lte.srs_ackNackST, "ENABLE") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= TRUE;
frtabu's avatar
frtabu committed
796
                } else if (strcmp(ccparams_lte.srs_ackNackST, "DISABLE") == 0) {
797 798 799
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_ackNackST= FALSE;
                } else
                  AssertFatal (0,
frtabu's avatar
frtabu committed
800
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for srs_BandwidthConfig choice: ENABLE,DISABLE !\n",
801 802 803 804
                               RC.config_file_name, i, ccparams_lte.srs_ackNackST);

                if (strcmp(ccparams_lte.srs_MaxUpPts, "ENABLE") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= TRUE;
frtabu's avatar
frtabu committed
805
                } else if (strcmp(ccparams_lte.srs_MaxUpPts, "DISABLE") == 0) {
806
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].srs_MaxUpPts= FALSE;
frtabu's avatar
frtabu committed
807
                } else
808
                  AssertFatal (0,
frtabu's avatar
frtabu committed
809
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for srs_MaxUpPts choice: ENABLE,DISABLE !\n",
810 811 812 813 814 815 816 817
                               RC.config_file_name, i, ccparams_lte.srs_MaxUpPts);
              }

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_p0_Nominal= ccparams_lte.pusch_p0_Nominal;

              if ((ccparams_lte.pusch_p0_Nominal<-126) ||
                  (ccparams_lte.pusch_p0_Nominal>24))
                AssertFatal (0,
frtabu's avatar
frtabu committed
818
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pusch_p0_Nominal choice: -126..24 !\n",
819
                             RC.config_file_name, i, ccparams_lte.pusch_p0_Nominal);
820

821 822
              if (strcmp(ccparams_lte.pusch_alpha,"AL0")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al0;
frtabu's avatar
frtabu committed
823
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL04")==0) {
824
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al04;
frtabu's avatar
frtabu committed
825
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL05")==0) {
826
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al05;
frtabu's avatar
frtabu committed
827
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL06")==0) {
828
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al06;
frtabu's avatar
frtabu committed
829
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL07")==0) {
830
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al07;
frtabu's avatar
frtabu committed
831
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL08")==0) {
832
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al08;
frtabu's avatar
frtabu committed
833
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL09")==0) {
834
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al09;
frtabu's avatar
frtabu committed
835
              } else if (strcmp(ccparams_lte.pusch_alpha,"AL1")==0) {
836
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pusch_alpha= LTE_Alpha_r12_al1;
837
              } else
838
                AssertFatal (0,
frtabu's avatar
frtabu committed
839
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pucch_Alpha choice: AL0,AL04,AL05,AL06,AL07,AL08,AL09,AL1!\n",
840
                             RC.config_file_name, i, ccparams_lte.pusch_alpha);
841

842
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_p0_Nominal= ccparams_lte.pucch_p0_Nominal;
843

844 845 846
              if ((ccparams_lte.pucch_p0_Nominal<-127) ||
                  (ccparams_lte.pucch_p0_Nominal>-96))
                AssertFatal (0,
frtabu's avatar
frtabu committed
847
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pucch_p0_Nominal choice: -127..-96 !\n",
848 849 850 851 852 853 854
                             RC.config_file_name, i, ccparams_lte.pucch_p0_Nominal);

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].msg3_delta_Preamble= ccparams_lte.msg3_delta_Preamble;

              if ((ccparams_lte.msg3_delta_Preamble<-1) ||
                  (ccparams_lte.msg3_delta_Preamble>6))
                AssertFatal (0,
frtabu's avatar
frtabu committed
855
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for msg3_delta_Preamble choice: -1..6 !\n",
856 857 858 859
                             RC.config_file_name, i, ccparams_lte.msg3_delta_Preamble);

              if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF_2")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF_2;
frtabu's avatar
frtabu committed
860
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF0")==0) {
861
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF0;
frtabu's avatar
frtabu committed
862
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format1,"deltaF2")==0) {
863
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2;
frtabu's avatar
frtabu committed
864
              } else
865
                AssertFatal (0,
frtabu's avatar
frtabu committed
866
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pucch_deltaF_Format1 choice: deltaF_2,dltaF0,deltaF2!\n",
867 868 869 870
                             RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format1);

              if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF1")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF1;
frtabu's avatar
frtabu committed
871
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF3")==0) {
872
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3;
frtabu's avatar
frtabu committed
873
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format1b,"deltaF5")==0) {
874
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format1b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF5;
frtabu's avatar
frtabu committed
875
              } else
876
                AssertFatal (0,
frtabu's avatar
frtabu committed
877
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pucch_deltaF_Format1b choice: deltaF1,dltaF3,deltaF5!\n",
878 879 880 881
                             RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format1b);

              if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF_2")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF_2;
frtabu's avatar
frtabu committed
882
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF0")==0) {
883
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0;
frtabu's avatar
frtabu committed
884
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF1")==0) {
885
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF1;
frtabu's avatar
frtabu committed
886
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format2,"deltaF2")==0) {
887 888 889
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF2;
              } else
                AssertFatal (0,
frtabu's avatar
frtabu committed
890
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pucch_deltaF_Format2 choice: deltaF_2,dltaF0,deltaF1,deltaF2!\n",
891 892 893 894
                             RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2);

              if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF_2")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF_2;
frtabu's avatar
frtabu committed
895
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF0")==0) {
896
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0;
frtabu's avatar
frtabu committed
897
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format2a,"deltaF2")==0) {
898
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2a= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF2;
frtabu's avatar
frtabu committed
899
              } else
900
                AssertFatal (0,
frtabu's avatar
frtabu committed
901
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pucch_deltaF_Format2a choice: deltaF_2,dltaF0,deltaF2!\n",
902 903 904 905
                             RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2a);

              if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF_2")==0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF_2;
frtabu's avatar
frtabu committed
906
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF0")==0) {
907
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0;
frtabu's avatar
frtabu committed
908
              } else if (strcmp(ccparams_lte.pucch_deltaF_Format2b,"deltaF2")==0) {
909
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pucch_deltaF_Format2b= LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF2;
frtabu's avatar
frtabu committed
910
              } else
911
                AssertFatal (0,
frtabu's avatar
frtabu committed
912
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pucch_deltaF_Format2b choice: deltaF_2,dltaF0,deltaF2!\n",
913 914 915 916 917 918 919 920
                             RC.config_file_name, i, ccparams_lte.pucch_deltaF_Format2b);

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_numberOfRA_Preambles= (ccparams_lte.rach_numberOfRA_Preambles/4)-1;

              if ((ccparams_lte.rach_numberOfRA_Preambles <4) ||
                  (ccparams_lte.rach_numberOfRA_Preambles>64) ||
                  ((ccparams_lte.rach_numberOfRA_Preambles&3)!=0))
                AssertFatal (0,
frtabu's avatar
frtabu committed
921
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_numberOfRA_Preambles choice: 4,8,12,...,64!\n",
922 923 924 925 926 927 928 929 930 931
                             RC.config_file_name, i, ccparams_lte.rach_numberOfRA_Preambles);

              if (strcmp(ccparams_lte.rach_preamblesGroupAConfig, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preamblesGroupAConfig= TRUE;
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_sizeOfRA_PreamblesGroupA= (ccparams_lte.rach_sizeOfRA_PreamblesGroupA/4)-1;

                if ((ccparams_lte.rach_numberOfRA_Preambles <4) ||
                    (ccparams_lte.rach_numberOfRA_Preambles>60) ||
                    ((ccparams_lte.rach_numberOfRA_Preambles&3)!=0))
                  AssertFatal (0,
frtabu's avatar
frtabu committed
932
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_sizeOfRA_PreamblesGroupA choice: 4,8,12,...,60!\n",
933 934 935
                               RC.config_file_name, i, ccparams_lte.rach_sizeOfRA_PreamblesGroupA);

                switch (ccparams_lte.rach_messageSizeGroupA) {
frtabu's avatar
frtabu committed
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953
                  case 56:
                    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b56;
                    break;

                  case 144:
                    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b144;
                    break;

                  case 208:
                    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b208;
                    break;

                  case 256:
                    RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messageSizeGroupA= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messageSizeGroupA_b256;
                    break;

                  default:
                    AssertFatal (0,
frtabu's avatar
frtabu committed
954
                                 "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_messageSizeGroupA choice: 56,144,208,256!\n",
frtabu's avatar
frtabu committed
955 956
                                 RC.config_file_name, i, ccparams_lte.rach_messageSizeGroupA);
                    break;
957 958 959 960
                }

                if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"minusinfinity")==0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_minusinfinity;
frtabu's avatar
frtabu committed
961
                } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB0")==0) {
962
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB0;
frtabu's avatar
frtabu committed
963
                } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB5")==0) {
964
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB5;
frtabu's avatar
frtabu committed
965
                } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB8")==0) {
966
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB8;
frtabu's avatar
frtabu committed
967
                } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB10")==0) {
968
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB10;
frtabu's avatar
frtabu committed
969
                } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB12")==0) {
970
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB12;
frtabu's avatar
frtabu committed
971
                } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB15")==0) {
972
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB15;
frtabu's avatar
frtabu committed
973
                } else if (strcmp(ccparams_lte.rach_messagePowerOffsetGroupB,"dB18")==0) {
974
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_messagePowerOffsetGroupB= LTE_RACH_ConfigCommon__preambleInfo__preamblesGroupAConfig__messagePowerOffsetGroupB_dB18;
frtabu's avatar
frtabu committed
975
                } else
976
                  AssertFatal (0,
frtabu's avatar
frtabu committed
977
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for rach_messagePowerOffsetGroupB choice: minusinfinity,dB0,dB5,dB8,dB10,dB12,dB15,dB18!\n",
978 979 980 981 982
                               RC.config_file_name, i, ccparams_lte.rach_messagePowerOffsetGroupB);
              } else if (strcmp(ccparams_lte.rach_preamblesGroupAConfig, "DISABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preamblesGroupAConfig= FALSE;
              } else
                AssertFatal (0,
frtabu's avatar
frtabu committed
983
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for rach_preamblesGroupAConfig choice: ENABLE,DISABLE !\n",
984 985 986 987 988 989 990 991
                             RC.config_file_name, i, ccparams_lte.rach_preamblesGroupAConfig);

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleInitialReceivedTargetPower= (ccparams_lte.rach_preambleInitialReceivedTargetPower+120)/2;

              if ((ccparams_lte.rach_preambleInitialReceivedTargetPower<-120) ||
                  (ccparams_lte.rach_preambleInitialReceivedTargetPower>-90) ||
                  ((ccparams_lte.rach_preambleInitialReceivedTargetPower&1)!=0))
                AssertFatal (0,
frtabu's avatar
frtabu committed
992
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_preambleInitialReceivedTargetPower choice: -120,-118,...,-90 !\n",
993 994 995 996 997 998 999 1000
                             RC.config_file_name, i, ccparams_lte.rach_preambleInitialReceivedTargetPower);

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_powerRampingStep= ccparams_lte.rach_powerRampingStep/2;

              if ((ccparams_lte.rach_powerRampingStep<0) ||
                  (ccparams_lte.rach_powerRampingStep>6) ||
                  ((ccparams_lte.rach_powerRampingStep&1)!=0))
                AssertFatal (0,
frtabu's avatar
frtabu committed
1001
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_powerRampingStep choice: 0,2,4,6 !\n",
1002 1003 1004
                             RC.config_file_name, i, ccparams_lte.rach_powerRampingStep);

              switch (ccparams_lte.rach_preambleTransMax) {
frtabu's avatar
frtabu committed
1005 1006 1007
                case 3:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n3;
                  break;
1008

frtabu's avatar
frtabu committed
1009 1010 1011
                case 4:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n4;
                  break;
1012

frtabu's avatar
frtabu committed
1013 1014 1015
                case 5:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n5;
                  break;
1016

frtabu's avatar
frtabu committed
1017 1018 1019
                case 6:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n6;
                  break;
1020

frtabu's avatar
frtabu committed
1021 1022 1023
                case 7:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n7;
                  break;
1024

frtabu's avatar
frtabu committed
1025 1026 1027
                case 8:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n8;
                  break;
1028

frtabu's avatar
frtabu committed
1029 1030 1031
                case 10:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n10;
                  break;
1032

frtabu's avatar
frtabu committed
1033 1034 1035
                case 20:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n20;
                  break;
1036

frtabu's avatar
frtabu committed
1037 1038 1039
                case 50:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n50;
                  break;
1040

frtabu's avatar
frtabu committed
1041 1042 1043
                case 100:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n100;
                  break;
1044

frtabu's avatar
frtabu committed
1045 1046 1047
                case 200:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_preambleTransMax= LTE_PreambleTransMax_n200;
                  break;
1048

frtabu's avatar
frtabu committed
1049 1050
                default:
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1051
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_preambleTransMax choice: 3,4,5,6,7,8,10,20,50,100,200!\n",
frtabu's avatar
frtabu committed
1052 1053
                               RC.config_file_name, i, ccparams_lte.rach_preambleTransMax);
                  break;
1054 1055 1056 1057 1058 1059 1060 1061
              }

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_raResponseWindowSize=  (ccparams_lte.rach_raResponseWindowSize==10)?7:ccparams_lte.rach_raResponseWindowSize-2;

              if ((ccparams_lte.rach_raResponseWindowSize<0)||
                  (ccparams_lte.rach_raResponseWindowSize==9)||
                  (ccparams_lte.rach_raResponseWindowSize>10))
                AssertFatal (0,
frtabu's avatar
frtabu committed
1062
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_raResponseWindowSize choice: 2,3,4,5,6,7,8,10!\n",
1063 1064 1065 1066 1067 1068 1069 1070
                             RC.config_file_name, i, ccparams_lte.rach_preambleTransMax);

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_macContentionResolutionTimer= (ccparams_lte.rach_macContentionResolutionTimer/8)-1;

              if ((ccparams_lte.rach_macContentionResolutionTimer<8) ||
                  (ccparams_lte.rach_macContentionResolutionTimer>64) ||
                  ((ccparams_lte.rach_macContentionResolutionTimer&7)!=0))
                AssertFatal (0,
frtabu's avatar
frtabu committed
1071
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_macContentionResolutionTimer choice: 8,16,...,56,64!\n",
1072 1073 1074 1075 1076 1077 1078
                             RC.config_file_name, i, ccparams_lte.rach_preambleTransMax);

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].rach_maxHARQ_Msg3Tx= ccparams_lte.rach_maxHARQ_Msg3Tx;

              if ((ccparams_lte.rach_maxHARQ_Msg3Tx<0) ||
                  (ccparams_lte.rach_maxHARQ_Msg3Tx>8))
                AssertFatal (0,
frtabu's avatar
frtabu committed
1079
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for rach_maxHARQ_Msg3Tx choice: 1..8!\n",
1080 1081 1082
                             RC.config_file_name, i, ccparams_lte.rach_preambleTransMax);

              switch (ccparams_lte.pcch_defaultPagingCycle) {
frtabu's avatar
frtabu committed
1083 1084 1085
                case 32:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf32;
                  break;
1086

frtabu's avatar
frtabu committed
1087 1088 1089
                case 64:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf64;
                  break;
1090

frtabu's avatar
frtabu committed
1091 1092 1093
                case 128:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf128;
                  break;
1094

frtabu's avatar
frtabu committed
1095 1096 1097
                case 256:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_defaultPagingCycle= LTE_PCCH_Config__defaultPagingCycle_rf256;
                  break;
1098

frtabu's avatar
frtabu committed
1099 1100
                default:
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1101
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for pcch_defaultPagingCycle choice: 32,64,128,256!\n",
frtabu's avatar
frtabu committed
1102 1103
                               RC.config_file_name, i, ccparams_lte.pcch_defaultPagingCycle);
                  break;
1104 1105
              }

1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122
              if (strcmp(ccparams_lte.pcch_nB, "fourT") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_fourT;
              } else if (strcmp(ccparams_lte.pcch_nB, "twoT") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_twoT;
              } else if (strcmp(ccparams_lte.pcch_nB, "oneT") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneT;
              } else if (strcmp(ccparams_lte.pcch_nB, "halfT") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_halfT;
              } else if (strcmp(ccparams_lte.pcch_nB, "quarterT") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_quarterT;
              } else if (strcmp(ccparams_lte.pcch_nB, "oneEighthT") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneEighthT;
              } else if (strcmp(ccparams_lte.pcch_nB, "oneSixteenthT") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneSixteenthT;
              } else if (strcmp(ccparams_lte.pcch_nB, "oneThirtySecondT") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].pcch_nB= LTE_PCCH_Config__nB_oneThirtySecondT;
              } else {
frtabu's avatar
frtabu committed
1123
                AssertFatal (0, "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for pcch_nB choice: fourT,twoT,oneT,halfT,quarterT,oneighthT,oneSixteenthT,oneThirtySecondT !\n",
1124 1125 1126 1127
                             RC.config_file_name,
                             i,
                             ccparams_lte.pcch_nB);
              }
1128

1129 1130 1131 1132 1133 1134 1135 1136
              if (strcmp(ccparams_lte.drx_Config_present, "prNothing") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_Config_present = LTE_DRX_Config_PR_NOTHING;
              } else if (strcmp(ccparams_lte.drx_Config_present, "prRelease") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_Config_present = LTE_DRX_Config_PR_release;
              } else if (strcmp(ccparams_lte.drx_Config_present, "prSetup") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_Config_present = LTE_DRX_Config_PR_setup;
              } else {
                AssertFatal (0,
frtabu's avatar
frtabu committed
1137
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for drx_Config_present choice: prNothing, prRelease, prSetup!\n",
1138 1139
                             RC.config_file_name, i, ccparams_lte.drx_Config_present);
              }
1140

1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173
              if (strcmp(ccparams_lte.drx_onDurationTimer, "psf1") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf1;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf2") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf2;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf3") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf3;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf4") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf4;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf5") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf5;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf6") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf6;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf8") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf8;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf10") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf10;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf20") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf20;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf30") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf30;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf40") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf40;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf50") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf50;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf60") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf60;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf80") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf80;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf100") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf100;
              } else if (strcmp(ccparams_lte.drx_onDurationTimer, "psf200") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_onDurationTimer = (long) LTE_DRX_Config__setup__onDurationTimer_psf200;
              } else {
1174
                AssertFatal (0,
frtabu's avatar
frtabu committed
1175
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for drx_onDurationTimer choice !\n",
1176
                             RC.config_file_name, i, ccparams_lte.drx_onDurationTimer);
1177
                break;
1178
              }
1179

1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
              if (strcmp(ccparams_lte.drx_InactivityTimer, "psf1") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf1;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf2") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf2;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf3") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf3;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf4") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf4;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf5") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf5;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf6") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf6;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf8") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf8;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf10") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf10;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf20") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf20;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf30") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf30;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf40") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf40;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf50") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf50;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf60") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf60;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf80") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf80;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf100") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf100;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf200") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf200;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf300") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf300;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf500") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf500;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf750") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf750;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf1280") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf1280;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf1920") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf1920;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf2560") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf2560;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "psf0-v1020") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_psf0_v1020;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare9") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare9;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare8") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare8;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare7") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare7;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare6") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare6;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare5") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare5;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare4") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare4;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare3") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare3;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare2") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare2;
              } else if (strcmp(ccparams_lte.drx_InactivityTimer, "spare1") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_InactivityTimer = (long) LTE_DRX_Config__setup__drx_InactivityTimer_spare1;
              } else {
1245
                AssertFatal (0,
frtabu's avatar
frtabu committed
1246
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for drx_InactivityTimer choice !\n",
1247
                             RC.config_file_name, i, ccparams_lte.drx_InactivityTimer);
1248
                break;
1249
              }
1250

1251
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_multiple_max= ccparams_lte.ue_multiple_max;
1252

1253
              if (!ccparams_lte.mbms_dedicated_serving_cell)
1254
                AssertFatal (0,
frtabu's avatar
frtabu committed
1255
                             "Failed to parse eNB configuration file %s, enb %u define %s: TRUE,FALSE!\n",
1256 1257 1258 1259 1260
                             RC.config_file_name, i, ENB_CONFIG_STRING_MBMS_DEDICATED_SERVING_CELL);
              else if (strcmp(ccparams_lte.mbms_dedicated_serving_cell, "ENABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].mbms_dedicated_serving_cell = TRUE;
              } else  if (strcmp(ccparams_lte.mbms_dedicated_serving_cell, "DISABLE") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].mbms_dedicated_serving_cell  = FALSE;
1261 1262
              } else {
                AssertFatal (0,
frtabu's avatar
frtabu committed
1263
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for mbms_dedicated_serving_cell choice: TRUE or FALSE !\n",
1264
                             RC.config_file_name, i, ccparams_lte.mbms_dedicated_serving_cell);
1265 1266
              }

1267 1268 1269 1270 1271
              switch (ccparams_lte.N_RB_DL) {
                case 25:
                  if ((ccparams_lte.ue_multiple_max < 1) ||
                      (ccparams_lte.ue_multiple_max > 4))
                    AssertFatal (0,
frtabu's avatar
frtabu committed
1272
                                 "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for ue_multiple_max choice: 1..4!\n",
1273
                                 RC.config_file_name, i, ccparams_lte.ue_multiple_max);
1274

1275 1276 1277 1278 1279 1280
                  break;

                case 50:
                  if ((ccparams_lte.ue_multiple_max < 1) ||
                      (ccparams_lte.ue_multiple_max > 8))
                    AssertFatal (0,
frtabu's avatar
frtabu committed
1281
                                 "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for ue_multiple_max choice: 1..8!\n",
1282 1283 1284 1285 1286 1287 1288 1289
                                 RC.config_file_name, i, ccparams_lte.ue_multiple_max);

                  break;

                case 100:
                  if ((ccparams_lte.ue_multiple_max < 1) ||
                      (ccparams_lte.ue_multiple_max > 16))
                    AssertFatal (0,
frtabu's avatar
frtabu committed
1290
                                 "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for ue_multiple_max choice: 1..16!\n",
1291 1292 1293 1294 1295 1296
                                 RC.config_file_name, i, ccparams_lte.ue_multiple_max);

                  break;

                default:
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1297
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for N_RB_DL choice: 25,50,100 !\n",
1298 1299
                               RC.config_file_name, i, ccparams_lte.N_RB_DL);
                  break;
1300
              }
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317

              if (strcmp(ccparams_lte.drx_RetransmissionTimer, "psf1") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_RetransmissionTimer = (long) LTE_DRX_Config__setup__drx_RetransmissionTimer_psf1;
              } else if (strcmp(ccparams_lte.drx_RetransmissionTimer, "psf2") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_RetransmissionTimer = (long) LTE_DRX_Config__setup__drx_RetransmissionTimer_psf2;
              } else if (strcmp(ccparams_lte.drx_RetransmissionTimer, "psf4") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_RetransmissionTimer = (long) LTE_DRX_Config__setup__drx_RetransmissionTimer_psf4;
              } else if (strcmp(ccparams_lte.drx_RetransmissionTimer, "psf6") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_RetransmissionTimer = (long) LTE_DRX_Config__setup__drx_RetransmissionTimer_psf6;
              } else if (strcmp(ccparams_lte.drx_RetransmissionTimer, "psf8") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_RetransmissionTimer = (long) LTE_DRX_Config__setup__drx_RetransmissionTimer_psf8;
              } else if (strcmp(ccparams_lte.drx_RetransmissionTimer, "psf16") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_RetransmissionTimer = (long) LTE_DRX_Config__setup__drx_RetransmissionTimer_psf16;
              } else if (strcmp(ccparams_lte.drx_RetransmissionTimer, "psf24") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_RetransmissionTimer = (long) LTE_DRX_Config__setup__drx_RetransmissionTimer_psf24;
              } else if (strcmp(ccparams_lte.drx_RetransmissionTimer, "psf33") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_RetransmissionTimer = (long) LTE_DRX_Config__setup__drx_RetransmissionTimer_psf33;
1318 1319
              } else {
                AssertFatal (0,
frtabu's avatar
frtabu committed
1320
                             "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for drx_RetransmissionTimer choice !\n",
1321 1322
                             RC.config_file_name, i, ccparams_lte.drx_RetransmissionTimer);
                break;
1323 1324
              }

1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
              if (ccparams_lte.drx_longDrx_CycleStartOffset_present == NULL || strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prNothing") == 0) {
                RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_NOTHING;
              } else {
                if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf10") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf10;
                  offsetMaxLimit = 10;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf20") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf20;
                  offsetMaxLimit = 20;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf32") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf32;
                  offsetMaxLimit = 32;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf40") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf40;
                  offsetMaxLimit = 40;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf64") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf64;
                  offsetMaxLimit = 64;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf80") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf80;
                  offsetMaxLimit = 80;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf128") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf128;
                  offsetMaxLimit = 128;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf160") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf160;
                  offsetMaxLimit = 160;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf256") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf256;
                  offsetMaxLimit = 256;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf320") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf320;
                  offsetMaxLimit = 320;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf512") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf512;
                  offsetMaxLimit = 512;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf640") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf640;
                  offsetMaxLimit = 640;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf1024") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf1024;
                  offsetMaxLimit = 1024;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf1280") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf1280;
                  offsetMaxLimit = 1280;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf2048") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf2048;
                  offsetMaxLimit = 2048;
                } else if (strcmp(ccparams_lte.drx_longDrx_CycleStartOffset_present, "prSf2560") == 0) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset_present = LTE_DRX_Config__setup__longDRX_CycleStartOffset_PR_sf2560;
                  offsetMaxLimit = 2560;
                } else {
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1378
                               "Failed to parse eNB configuration file \"%s\", enb %u unknown string value \"%s\" for drx_longDrx_CycleStartOffset_present choice !\n",
1379 1380 1381 1382 1383 1384 1385
                               RC.config_file_name, i, ccparams_lte.drx_longDrx_CycleStartOffset_present);
                }

                if (ccparams_lte.drx_longDrx_CycleStartOffset >= 0 && ccparams_lte.drx_longDrx_CycleStartOffset < offsetMaxLimit) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_longDrx_CycleStartOffset = ccparams_lte.drx_longDrx_CycleStartOffset;
                } else {
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1386
                               "Failed to parse eNB configuration file %s, enb %u incoherent value \"%d\" for drx_longDrx_CycleStartOffset !\n",
1387 1388
                               RC.config_file_name, i, ccparams_lte.drx_longDrx_CycleStartOffset);
                }
1389 1390
              }

1391 1392 1393
              if  (strcmp(ccparams_lte.drx_shortDrx_Cycle, "") == 0 || ccparams_lte.drx_shortDrx_ShortCycleTimer == 0) {
                if  (strcmp(ccparams_lte.drx_shortDrx_Cycle, "") != 0 || ccparams_lte.drx_shortDrx_ShortCycleTimer != 0) {
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1394
                               "Failed to parse eNB configuration file %s, enb %u incoherent values \"%s\" -  \"%d\" for drx_shortDrx_Cycle or drx_shortDrx_ShortCycleTimer choice !\n",
1395 1396 1397 1398 1399
                               RC.config_file_name, i, ccparams_lte.drx_shortDrx_Cycle, ccparams_lte.drx_shortDrx_ShortCycleTimer);
                } else {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = -1;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_ShortCycleTimer = 0;
                }
1400
              } else {
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450
                if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf2") == 0) {
                  cycleNb = 2;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf2;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf5") == 0) {
                  cycleNb = 5;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf5;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf8") == 0) {
                  cycleNb = 8;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf8;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf10") == 0) {
                  cycleNb = 10;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf10;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf16") == 0) {
                  cycleNb = 16;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf16;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf20") == 0) {
                  cycleNb = 20;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf20;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf32") == 0) {
                  cycleNb = 32;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf32;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf40") == 0) {
                  cycleNb = 40;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf40;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf64") == 0) {
                  cycleNb = 64;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf64;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf80") == 0) {
                  cycleNb = 80;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf80;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf128") == 0) {
                  cycleNb = 128;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf128;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf160") == 0) {
                  cycleNb = 160;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf160;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf256") == 0) {
                  cycleNb = 256;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf256;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf320") == 0) {
                  cycleNb = 320;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf320;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf512") == 0) {
                  cycleNb = 512;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf512;
                } else if (strcmp(ccparams_lte.drx_shortDrx_Cycle, "sf640") == 0) {
                  cycleNb = 640;
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_Cycle = LTE_DRX_Config__setup__shortDRX__shortDRX_Cycle_sf640;
                } else {
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1451
                               "Failed to parse eNB configuration file %s, enb %u incoherent value \"%s\" for drx_shortDrx_Cycle !\n",
1452 1453 1454 1455 1456
                               RC.config_file_name, i, ccparams_lte.drx_shortDrx_Cycle);
                }

                if (cycleNb > 0 && (offsetMaxLimit % cycleNb != 0 || cycleNb == offsetMaxLimit)) {
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1457
                               "Failed to parse eNB configuration file %s, enb %u incompatible (not multiple) values \"%d\" -  \"%d\" for drx_shortDrx_Cycle and drx_longDrx_CycleStartOffset choice !\n",
1458 1459 1460 1461 1462 1463 1464
                               RC.config_file_name, i, cycleNb, offsetMaxLimit);
                }

                if (ccparams_lte.drx_shortDrx_ShortCycleTimer >= 1 && ccparams_lte.drx_shortDrx_ShortCycleTimer <= 16 ) {
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].drx_shortDrx_ShortCycleTimer = ccparams_lte.drx_shortDrx_ShortCycleTimer;
                } else {
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1465
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for drx_shortDrx_ShortCycleTimer choice !\n",
1466 1467
                               RC.config_file_name, i, ccparams_lte.drx_shortDrx_ShortCycleTimer );
                }
1468
              }
1469

1470 1471 1472 1473
              switch (ccparams_lte.bcch_modificationPeriodCoeff) {
                case 2:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n2;
                  break;
1474

frtabu's avatar
frtabu committed
1475 1476 1477
                case 4:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n4;
                  break;
1478

frtabu's avatar
frtabu committed
1479 1480 1481
                case 8:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n8;
                  break;
1482

frtabu's avatar
frtabu committed
1483 1484 1485
                case 16:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].bcch_modificationPeriodCoeff= LTE_BCCH_Config__modificationPeriodCoeff_n16;
                  break;
1486

frtabu's avatar
frtabu committed
1487 1488
                default:
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1489
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for bcch_modificationPeriodCoeff choice: 2,4,8,16",
frtabu's avatar
frtabu committed
1490 1491
                               RC.config_file_name, i, ccparams_lte.bcch_modificationPeriodCoeff);
                  break;
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501
              }

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t300= ccparams_lte.ue_TimersAndConstants_t300;
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t301= ccparams_lte.ue_TimersAndConstants_t301;
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t310= ccparams_lte.ue_TimersAndConstants_t310;
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_t311= ccparams_lte.ue_TimersAndConstants_t311;
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_n310= ccparams_lte.ue_TimersAndConstants_n310;
              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TimersAndConstants_n311= ccparams_lte.ue_TimersAndConstants_n311;

              switch (ccparams_lte.ue_TransmissionMode) {
frtabu's avatar
frtabu committed
1502 1503 1504
                case 1:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1;
                  break;
1505

frtabu's avatar
frtabu committed
1506 1507 1508
                case 2:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2;
                  break;
1509

frtabu's avatar
frtabu committed
1510 1511 1512
                case 3:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm3;
                  break;
1513

frtabu's avatar
frtabu committed
1514 1515 1516
                case 4:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm4;
                  break;
1517

frtabu's avatar
frtabu committed
1518 1519 1520
                case 5:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm5;
                  break;
1521

frtabu's avatar
frtabu committed
1522 1523 1524
                case 6:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm6;
                  break;
1525

frtabu's avatar
frtabu committed
1526 1527 1528
                case 7:
                  RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_TransmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm7;
                  break;
1529

frtabu's avatar
frtabu committed
1530 1531
                default:
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1532
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for ue_TransmissionMode choice: 1,2,3,4,5,6,7",
frtabu's avatar
frtabu committed
1533 1534
                               RC.config_file_name, i, ccparams_lte.ue_TransmissionMode);
                  break;
1535 1536 1537 1538 1539
              }

              RRC_CONFIGURATION_REQ (msg_p).radioresourceconfig[j].ue_multiple_max= ccparams_lte.ue_multiple_max;

              switch (ccparams_lte.N_RB_DL) {
frtabu's avatar
frtabu committed
1540 1541 1542 1543
                case 25:
                  if ((ccparams_lte.ue_multiple_max < 1) ||
                      (ccparams_lte.ue_multiple_max > 4))
                    AssertFatal (0,
frtabu's avatar
frtabu committed
1544
                                 "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for ue_multiple_max choice: 1..4!\n",
frtabu's avatar
frtabu committed
1545
                                 RC.config_file_name, i, ccparams_lte.ue_multiple_max);
1546

frtabu's avatar
frtabu committed
1547
                  break;
1548

frtabu's avatar
frtabu committed
1549 1550 1551 1552
                case 50:
                  if ((ccparams_lte.ue_multiple_max < 1) ||
                      (ccparams_lte.ue_multiple_max > 8))
                    AssertFatal (0,
frtabu's avatar
frtabu committed
1553
                                 "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for ue_multiple_max choice: 1..8!\n",
frtabu's avatar
frtabu committed
1554
                                 RC.config_file_name, i, ccparams_lte.ue_multiple_max);
1555

frtabu's avatar
frtabu committed
1556
                  break;
1557

frtabu's avatar
frtabu committed
1558 1559 1560 1561
                case 100:
                  if ((ccparams_lte.ue_multiple_max < 1) ||
                      (ccparams_lte.ue_multiple_max > 16))
                    AssertFatal (0,
frtabu's avatar
frtabu committed
1562
                                 "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for ue_multiple_max choice: 1..16!\n",
frtabu's avatar
frtabu committed
1563
                                 RC.config_file_name, i, ccparams_lte.ue_multiple_max);
1564

frtabu's avatar
frtabu committed
1565
                  break;
1566

frtabu's avatar
frtabu committed
1567 1568
                default:
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1569
                               "Failed to parse eNB configuration file %s, enb %u unknown value \"%d\" for N_RB_DL choice: 25,50,100 !\n",
frtabu's avatar
frtabu committed
1570 1571
                               RC.config_file_name, i, ccparams_lte.N_RB_DL);
                  break;
1572 1573 1574 1575 1576 1577
              }

              // eMBMS configuration
              RRC_CONFIGURATION_REQ(msg_p).eMBMS_configured = 0;
              printf("No eMBMS configuration, skipping it\n");
              // eMTC configuration
laurent's avatar
laurent committed
1578
              char brparamspath[MAX_OPTNAME_SIZE*2 + 160];
1579 1580 1581 1582 1583
              sprintf(brparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_EMTC_PARAMETERS);
              config_get(eMTCParams, sizeof(eMTCParams)/sizeof(paramdef_t), brparamspath);
              RRC_CONFIGURATION_REQ(msg_p).eMTC_configured = eMTCconfig.eMTC_configured&1;

              if (eMTCconfig.eMTC_configured > 0) fill_eMTC_configuration(msg_p,&eMTCconfig, i,j,RC.config_file_name,brparamspath);
frtabu's avatar
frtabu committed
1584
              else                            printf("No eMTC configuration, skipping it\n");
1585 1586

              // Sidelink configuration
laurent's avatar
laurent committed
1587
              char SLparamspath[MAX_OPTNAME_SIZE*2 + 160];
1588 1589 1590 1591
              sprintf(SLparamspath,"%s.%s", ccspath, ENB_CONFIG_STRING_SL_PARAMETERS);
              config_get( SLParams, sizeof(SLParams)/sizeof(paramdef_t), SLparamspath);
              // Sidelink Resource pool information
              RRC_CONFIGURATION_REQ (msg_p).SL_configured=SLconfig.sidelink_configured&1;
1592

1593 1594
              if (SLconfig.sidelink_configured==1) fill_SL_configuration(msg_p,&SLconfig,i,j,RC.config_file_name);
              else                                 printf("No SL configuration skipping it\n");
1595
            } // !NODE_IS_DU(node_type)
1596
          }
1597

1598 1599
          RRC_CONFIGURATION_REQ (msg_p).nr_scg_ssb_freq = ccparams_lte.nr_scg_ssb_freq;

1600
          if (!NODE_IS_DU(rrc->node_type)) {
1601 1602 1603
            char srb1path[MAX_OPTNAME_SIZE*2 + 8];
            sprintf(srb1path,"%s.%s",enbpath,ENB_CONFIG_STRING_SRB1);
            config_get( SRB1Params,sizeof(SRB1Params)/sizeof(paramdef_t), srb1path);
1604

1605
            switch (srb1_params.srb1_max_retx_threshold) {
frtabu's avatar
frtabu committed
1606 1607 1608
              case 1:
                rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t1;
                break;
1609

frtabu's avatar
frtabu committed
1610 1611 1612
              case 2:
                rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t2;
                break;
1613

frtabu's avatar
frtabu committed
1614 1615 1616
              case 3:
                rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t3;
                break;
laurent's avatar
laurent committed
1617

frtabu's avatar
frtabu committed
1618 1619 1620
              case 4:
                rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t4;
                break;
laurent's avatar
laurent committed
1621

frtabu's avatar
frtabu committed
1622 1623 1624
              case 6:
                rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t6;
                break;
1625

frtabu's avatar
frtabu committed
1626 1627 1628
              case 8:
                rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t8;
                break;
1629

frtabu's avatar
frtabu committed
1630 1631 1632
              case 16:
                rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t16;
                break;
1633

frtabu's avatar
frtabu committed
1634 1635 1636
              case 32:
                rrc->srb1_max_retx_threshold = LTE_UL_AM_RLC__maxRetxThreshold_t32;
                break;
1637

frtabu's avatar
frtabu committed
1638 1639
              default:
                AssertFatal (0,
frtabu's avatar
frtabu committed
1640
                             "Bad config value when parsing eNB configuration file %s, enb %u  srb1_max_retx_threshold %d!\n",
frtabu's avatar
frtabu committed
1641
                             RC.config_file_name, i, srb1_params.srb1_max_retx_threshold);
1642
            }
1643

1644
            switch (srb1_params.srb1_poll_pdu) {
frtabu's avatar
frtabu committed
1645 1646 1647
              case 4:
                rrc->srb1_poll_pdu = LTE_PollPDU_p4;
                break;
1648

frtabu's avatar
frtabu committed
1649 1650 1651
              case 8:
                rrc->srb1_poll_pdu = LTE_PollPDU_p8;
                break;
1652

frtabu's avatar
frtabu committed
1653 1654 1655
              case 16:
                rrc->srb1_poll_pdu = LTE_PollPDU_p16;
                break;
1656

frtabu's avatar
frtabu committed
1657 1658 1659
              case 32:
                rrc->srb1_poll_pdu = LTE_PollPDU_p32;
                break;
1660

frtabu's avatar
frtabu committed
1661 1662 1663
              case 64:
                rrc->srb1_poll_pdu = LTE_PollPDU_p64;
                break;
1664

frtabu's avatar
frtabu committed
1665 1666 1667
              case 128:
                rrc->srb1_poll_pdu = LTE_PollPDU_p128;
                break;
1668

frtabu's avatar
frtabu committed
1669 1670 1671
              case 256:
                rrc->srb1_poll_pdu = LTE_PollPDU_p256;
                break;
1672

frtabu's avatar
frtabu committed
1673 1674 1675 1676 1677
              default:
                if (srb1_params.srb1_poll_pdu >= 10000)
                  rrc->srb1_poll_pdu = LTE_PollPDU_pInfinity;
                else
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1678
                               "Bad config value when parsing eNB configuration file %s, enb %u  srb1_poll_pdu %d!\n",
frtabu's avatar
frtabu committed
1679
                               RC.config_file_name, i, srb1_params.srb1_poll_pdu);
1680
            }
1681

1682
            rrc->srb1_poll_byte             = srb1_params.srb1_poll_byte;
1683

1684
            switch (srb1_params.srb1_poll_byte) {
frtabu's avatar
frtabu committed
1685 1686 1687
              case 25:
                rrc->srb1_poll_byte = LTE_PollByte_kB25;
                break;
1688

frtabu's avatar
frtabu committed
1689 1690 1691
              case 50:
                rrc->srb1_poll_byte = LTE_PollByte_kB50;
                break;
1692

frtabu's avatar
frtabu committed
1693 1694 1695
              case 75:
                rrc->srb1_poll_byte = LTE_PollByte_kB75;
                break;
1696

frtabu's avatar
frtabu committed
1697 1698 1699
              case 100:
                rrc->srb1_poll_byte = LTE_PollByte_kB100;
                break;
1700

frtabu's avatar
frtabu committed
1701 1702 1703
              case 125:
                rrc->srb1_poll_byte = LTE_PollByte_kB125;
                break;
1704

frtabu's avatar
frtabu committed
1705 1706 1707
              case 250:
                rrc->srb1_poll_byte = LTE_PollByte_kB250;
                break;
1708

frtabu's avatar
frtabu committed
1709 1710 1711
              case 375:
                rrc->srb1_poll_byte = LTE_PollByte_kB375;
                break;
1712

frtabu's avatar
frtabu committed
1713 1714 1715
              case 500:
                rrc->srb1_poll_byte = LTE_PollByte_kB500;
                break;
1716

frtabu's avatar
frtabu committed
1717 1718 1719
              case 750:
                rrc->srb1_poll_byte = LTE_PollByte_kB750;
                break;
1720

frtabu's avatar
frtabu committed
1721 1722 1723
              case 1000:
                rrc->srb1_poll_byte = LTE_PollByte_kB1000;
                break;
1724

frtabu's avatar
frtabu committed
1725 1726 1727
              case 1250:
                rrc->srb1_poll_byte = LTE_PollByte_kB1250;
                break;
1728

frtabu's avatar
frtabu committed
1729 1730 1731
              case 1500:
                rrc->srb1_poll_byte = LTE_PollByte_kB1500;
                break;
1732

frtabu's avatar
frtabu committed
1733 1734 1735
              case 2000:
                rrc->srb1_poll_byte = LTE_PollByte_kB2000;
                break;
1736

frtabu's avatar
frtabu committed
1737 1738 1739
              case 3000:
                rrc->srb1_poll_byte = LTE_PollByte_kB3000;
                break;
1740

frtabu's avatar
frtabu committed
1741 1742 1743 1744 1745
              default:
                if (srb1_params.srb1_poll_byte >= 10000)
                  rrc->srb1_poll_byte = LTE_PollByte_kBinfinity;
                else
                  AssertFatal (0,
frtabu's avatar
frtabu committed
1746
                               "Bad config value when parsing eNB configuration file %s, enb %u  srb1_poll_byte %d!\n",
frtabu's avatar
frtabu committed
1747
                               RC.config_file_name, i, srb1_params.srb1_poll_byte);
laurent's avatar
laurent committed
1748
            }
1749

1750 1751 1752 1753 1754 1755
            if (srb1_params.srb1_timer_poll_retransmit <= 250) {
              rrc->srb1_timer_poll_retransmit = (srb1_params.srb1_timer_poll_retransmit - 5)/5;
            } else if (srb1_params.srb1_timer_poll_retransmit <= 500) {
              rrc->srb1_timer_poll_retransmit = (srb1_params.srb1_timer_poll_retransmit - 300)/50 + 50;
            } else {
              AssertFatal (0,
frtabu's avatar
frtabu committed
1756
                           "Bad config value when parsing eNB configuration file %s, enb %u  srb1_timer_poll_retransmit %d!\n",
1757 1758
                           RC.config_file_name, i, srb1_params.srb1_timer_poll_retransmit);
            }
1759

1760 1761 1762 1763 1764
            if (srb1_params.srb1_timer_status_prohibit <= 250) {
              rrc->srb1_timer_status_prohibit = srb1_params.srb1_timer_status_prohibit/5;
            } else if ((srb1_params.srb1_timer_poll_retransmit >= 300) && (srb1_params.srb1_timer_poll_retransmit <= 500)) {
              rrc->srb1_timer_status_prohibit = (srb1_params.srb1_timer_status_prohibit - 300)/50 + 51;
            } else {
laurent's avatar
laurent committed
1765
              AssertFatal (0,
frtabu's avatar
frtabu committed
1766
                           "Bad config value when parsing eNB configuration file %s, enb %u  srb1_timer_status_prohibit %d!\n",
1767 1768
                           RC.config_file_name, i, srb1_params.srb1_timer_status_prohibit);
            }
1769

1770
            switch (srb1_params.srb1_timer_reordering) {
frtabu's avatar
frtabu committed
1771 1772 1773
              case 0:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms0;
                break;
1774

frtabu's avatar
frtabu committed
1775 1776 1777
              case 5:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms5;
                break;
1778

frtabu's avatar
frtabu committed
1779 1780 1781
              case 10:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms10;
                break;
1782

frtabu's avatar
frtabu committed
1783 1784 1785
              case 15:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms15;
                break;
1786

frtabu's avatar
frtabu committed
1787 1788 1789
              case 20:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms20;
                break;
Raymond Knopp's avatar
 
Raymond Knopp committed
1790

frtabu's avatar
frtabu committed
1791 1792 1793
              case 25:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms25;
                break;
1794

frtabu's avatar
frtabu committed
1795 1796 1797
              case 30:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms30;
                break;
1798

frtabu's avatar
frtabu committed
1799 1800 1801
              case 35:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms35;
                break;
1802

frtabu's avatar
frtabu committed
1803 1804 1805
              case 40:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms40;
                break;
1806

frtabu's avatar
frtabu committed
1807 1808 1809
              case 45:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms45;
                break;
1810

frtabu's avatar
frtabu committed
1811 1812 1813
              case 50:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms50;
                break;
1814

frtabu's avatar
frtabu committed
1815 1816 1817
              case 55:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms55;
                break;
1818

frtabu's avatar
frtabu committed
1819 1820 1821
              case 60:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms60;
                break;
1822

frtabu's avatar
frtabu committed
1823 1824 1825
              case 65:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms65;
                break;
1826

frtabu's avatar
frtabu committed
1827 1828 1829
              case 70:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms70;
                break;
1830

frtabu's avatar
frtabu committed
1831 1832 1833
              case 75:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms75;
                break;
1834

frtabu's avatar
frtabu committed
1835 1836 1837
              case 80:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms80;
                break;
1838

frtabu's avatar
frtabu committed
1839 1840 1841
              case 85:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms85;
                break;
1842

frtabu's avatar
frtabu committed
1843 1844 1845
              case 90:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms90;
                break;
1846

frtabu's avatar
frtabu committed
1847 1848 1849
              case 95:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms95;
                break;
1850

frtabu's avatar
frtabu committed
1851 1852 1853
              case 100:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms100;
                break;
1854

frtabu's avatar
frtabu committed
1855 1856 1857
              case 110:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms110;
                break;
1858

frtabu's avatar
frtabu committed
1859 1860 1861
              case 120:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms120;
                break;
1862

frtabu's avatar
frtabu committed
1863 1864 1865
              case 130:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms130;
                break;
1866

frtabu's avatar
frtabu committed
1867 1868 1869
              case 140:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms140;
                break;
1870

frtabu's avatar
frtabu committed
1871 1872 1873
              case 150:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms150;
                break;
1874

frtabu's avatar
frtabu committed
1875 1876 1877
              case 160:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms160;
                break;
1878

frtabu's avatar
frtabu committed
1879 1880 1881
              case 170:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms170;
                break;
1882

frtabu's avatar
frtabu committed
1883 1884 1885
              case 180:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms180;
                break;
1886

frtabu's avatar
frtabu committed
1887 1888 1889
              case 190:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms190;
                break;
1890

frtabu's avatar
frtabu committed
1891 1892 1893
              case 200:
                rrc->srb1_timer_reordering = LTE_T_Reordering_ms200;
                break;
1894

frtabu's avatar
frtabu committed
1895 1896
              default:
                AssertFatal (0,
frtabu's avatar
frtabu committed
1897
                             "Bad config value when parsing eNB configuration file %s, enb %u  srb1_timer_reordering %d!\n",
frtabu's avatar
frtabu committed
1898
                             RC.config_file_name, i, srb1_params.srb1_timer_reordering);
1899
            }
1900 1901
          }
        }
1902
      }
1903
    }
frtabu's avatar
frtabu committed
1904

1905
    memcpy(&rrc->configuration, &RRC_CONFIGURATION_REQ(msg_p), sizeof(RRC_CONFIGURATION_REQ(msg_p)));
1906
  }
1907

frtabu's avatar
frtabu committed
1908
  LOG_I(RRC,"Node type %d \n ", rrc->node_type);
1909
  return 0;
1910 1911
}

1912 1913 1914 1915
int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) {
  int k;
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  paramdef_t ENBParams[]  = ENBPARAMS_DESC;
frtabu's avatar
frtabu committed
1916 1917
  paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0};
  config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
1918 1919
  int num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt;
  AssertFatal (i<num_enbs,
frtabu's avatar
frtabu committed
1920
               "Failed to parse config file no %uth element in %s \n",i, ENB_CONFIG_STRING_ACTIVE_ENBS);
1921 1922 1923

  if (num_enbs>0) {
    // Output a list of all eNBs.
frtabu's avatar
frtabu committed
1924
    config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL);
1925
    AssertFatal(ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr != NULL,
frtabu's avatar
frtabu committed
1926
                "eNB id %u is not defined in configuration file\n",i);
Raymond Knopp's avatar
Raymond Knopp committed
1927
    F1AP_SETUP_REQ (msg_p).num_cells_available = 0;
1928

1929 1930
    for (k=0; k <num_enbs ; k++) {
      if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[k], *(ENBParamList.paramarray[i][ENB_ENB_NAME_IDX].strptr) )== 0) {
1931
        char aprefix[MAX_OPTNAME_SIZE*2 + 8];
Robert Schmidt's avatar
Robert Schmidt committed
1932 1933 1934 1935 1936 1937 1938 1939 1940
        sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
        paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
        paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0};
        /* map parameter checking array instances to parameter definition array instances */
        checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;

        for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I)
          PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);

frtabu's avatar
frtabu committed
1941
        config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix);
Robert Schmidt's avatar
Robert Schmidt committed
1942
        paramdef_t SCTPParams[]  = SCTPPARAMS_DESC;
frtabu's avatar
frtabu committed
1943
        F1AP_SETUP_REQ (msg_p).num_cells_available++;
1944
        F1AP_SETUP_REQ (msg_p).gNB_DU_id        = *(ENBParamList.paramarray[0][ENB_ENB_ID_IDX].uptr);
1945
        LOG_I(ENB_APP,"F1AP: gNB_DU_id[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).gNB_DU_id);
1946 1947
        F1AP_SETUP_REQ (msg_p).gNB_DU_name      = strdup(*(ENBParamList.paramarray[0][ENB_ENB_NAME_IDX].strptr));
        LOG_I(ENB_APP,"F1AP: gNB_DU_name[%d] %s\n",k,F1AP_SETUP_REQ (msg_p).gNB_DU_name);
Robert Schmidt's avatar
Robert Schmidt committed
1948
        F1AP_SETUP_REQ (msg_p).tac[k]              = *ENBParamList.paramarray[i][ENB_TRACKING_AREA_CODE_IDX].uptr;
1949
        LOG_I(ENB_APP,"F1AP: tac[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).tac[k]);
Robert Schmidt's avatar
Robert Schmidt committed
1950
        F1AP_SETUP_REQ (msg_p).mcc[k]              = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr;
1951
        LOG_I(ENB_APP,"F1AP: mcc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mcc[k]);
Robert Schmidt's avatar
Robert Schmidt committed
1952
        F1AP_SETUP_REQ (msg_p).mnc[k]              = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr;
1953
        LOG_I(ENB_APP,"F1AP: mnc[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mnc[k]);
Robert Schmidt's avatar
Robert Schmidt committed
1954
        F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr;
1955 1956 1957 1958 1959
        LOG_I(ENB_APP,"F1AP: mnc_digit_length[%d] %d\n",k,F1AP_SETUP_REQ (msg_p).mnc_digit_length[k]);
        AssertFatal((F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] == 2) ||
                    (F1AP_SETUP_REQ (msg_p).mnc_digit_length[k] == 3),
                    "BAD MNC DIGIT LENGTH %d",
                    F1AP_SETUP_REQ (msg_p).mnc_digit_length[k]);
frtabu's avatar
frtabu committed
1960
        F1AP_SETUP_REQ (msg_p).nr_cellid[k] = (uint64_t)*(ENBParamList.paramarray[i][ENB_NRCELLID_IDX].u64ptr);
1961
        LOG_I(ENB_APP,"F1AP: nr_cellid[%d] %ld\n",k,F1AP_SETUP_REQ (msg_p).nr_cellid[k]);
1962 1963
        LOG_I(ENB_APP,"F1AP: CU_ip4_address in DU %s\n",RC.mac[k]->eth_params_n.remote_addr);
        LOG_I(ENB_APP,"FIAP: CU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4_address,(int)strlen(RC.mac[k]->eth_params_n.remote_addr));
1964 1965 1966
        F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv6 = 0;
        F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4 = 1;
        //strcpy(F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv6_address, "");
1967 1968 1969
        strcpy(F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4_address, RC.mac[k]->eth_params_n.remote_addr);
        LOG_I(ENB_APP,"F1AP: DU_ip4_address in DU %s\n",RC.mac[k]->eth_params_n.my_addr);
        LOG_I(ENB_APP,"FIAP: DU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address,(int)strlen(RC.mac[k]->eth_params_n.my_addr));
1970 1971 1972
        F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6 = 0;
        F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4 = 1;
        //strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6_address, "");
1973
        strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address, RC.mac[k]->eth_params_n.my_addr);
1974 1975 1976
        //strcpy(F1AP_SETUP_REQ (msg_p).CU_ip_address[l].ipv6_address,*(F1ParamList.paramarray[l][ENB_CU_IPV6_ADDRESS_IDX].strptr));
        //F1AP_SETUP_REQ (msg_p).CU_port = RC.mac[k]->eth_params_n.remote_portc; // maybe we dont need it
        sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG);
frtabu's avatar
frtabu committed
1977
        config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
1978 1979 1980 1981 1982
        F1AP_SETUP_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr);
        F1AP_SETUP_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr);
        eNB_RRC_INST *rrc = RC.rrc[k];
        // wait until RRC cell information is configured
        int cell_info_configured=0;
frtabu's avatar
frtabu committed
1983

1984 1985 1986 1987 1988 1989 1990
        do {
          LOG_I(ENB_APP,"ngran_eNB_DU: Waiting for basic cell configuration\n");
          usleep(100000);
          pthread_mutex_lock(&rrc->cell_info_mutex);
          cell_info_configured = rrc->cell_info_configured;
          pthread_mutex_unlock(&rrc->cell_info_mutex);
        } while (cell_info_configured ==0);
1991

1992 1993 1994 1995
        rrc->configuration.mcc[0] = F1AP_SETUP_REQ (msg_p).mcc[k];
        rrc->configuration.mnc[0] = F1AP_SETUP_REQ (msg_p).mnc[k];
        rrc->configuration.tac    = F1AP_SETUP_REQ (msg_p).tac[k];
        rrc->nr_cellid = F1AP_SETUP_REQ (msg_p).nr_cellid[k];
1996 1997
        F1AP_SETUP_REQ (msg_p).nr_pci[k]    = rrc->carrier[0].physCellId;
        F1AP_SETUP_REQ (msg_p).num_ssi[k] = 0;
1998

1999 2000
        if (rrc->carrier[0].sib1->tdd_Config) {
          LOG_I(ENB_APP,"ngran_DU: Configuring Cell %d for TDD\n",k);
2001
          F1AP_SETUP_REQ (msg_p).fdd_flag = 0;
2002
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nr_arfcn            = freq_to_arfcn10(rrc->carrier[0].sib1->freqBandIndicator,
frtabu's avatar
frtabu committed
2003
              rrc->carrier[0].dl_CarrierFreq);
2004 2005 2006 2007 2008 2009 2010
          // For LTE use scs field to carry prefix type and number of antennas
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.scs                 = (rrc->carrier[0].Ncp<<2)+rrc->carrier[0].p_eNB;;
          // use nrb field to hold LTE N_RB_DL (0...5)
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nrb                 = rrc->carrier[0].mib.message.dl_Bandwidth;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nrb                 = rrc->carrier[0].mib.message.dl_Bandwidth;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.num_frequency_bands = 1;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nr_band[0]          = rrc->carrier[0].sib1->freqBandIndicator;
Raymond Knopp's avatar
Raymond Knopp committed
2011
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.sul_active          = 0;
frtabu's avatar
frtabu committed
2012
        } else {
2013
          LOG_I(ENB_APP,"ngran_DU: Configuring Cell %d for FDD\n",k);
2014
          F1AP_SETUP_REQ (msg_p).fdd_flag = 1;
2015
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_arfcn             = freq_to_arfcn10(rrc->carrier[0].sib1->freqBandIndicator,
frtabu's avatar
frtabu committed
2016
              rrc->carrier[0].dl_CarrierFreq);
2017 2018 2019 2020 2021 2022 2023
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_arfcn             = F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_arfcn;
          // For LTE use scs field to carry prefix type and number of antennas
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_scs                  = (rrc->carrier[0].Ncp<<2)+rrc->carrier[0].p_eNB;;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_scs                  = rrc->carrier[0].Ncp;
          // use nrb field to hold LTE N_RB_DL (0...5)
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nrb                  = rrc->carrier[0].mib.message.dl_Bandwidth;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nrb                  = rrc->carrier[0].mib.message.dl_Bandwidth;
2024 2025 2026 2027 2028 2029 2030 2031 2032
          // RK: we need to check there value for FDD's frequency_bands DL/UL
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_num_frequency_bands  = 1;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_band[0]           = rrc->carrier[0].sib1->freqBandIndicator;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_num_frequency_bands  = 1;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_band[0]           = rrc->carrier[0].sib1->freqBandIndicator;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_num_sul_frequency_bands  = 0;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.ul_nr_sul_band[0]           = rrc->carrier[0].sib1->freqBandIndicator;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_num_sul_frequency_bands  = 0;
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.dl_nr_sul_band[0]           = rrc->carrier[0].sib1->freqBandIndicator;
2033 2034
          F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.sul_active              = 0;
        }
frtabu's avatar
frtabu committed
2035

2036
        F1AP_SETUP_REQ (msg_p).measurement_timing_information[k]             = "0";
2037 2038 2039
        F1AP_SETUP_REQ (msg_p).ranac[k]                                      = 0;
        F1AP_SETUP_REQ (msg_p).mib[k]                                        = rrc->carrier[0].MIB;
        F1AP_SETUP_REQ (msg_p).sib1[k]                                       = rrc->carrier[0].SIB1;
2040 2041
        F1AP_SETUP_REQ (msg_p).mib_length[k]                                 = rrc->carrier[0].sizeof_MIB;
        F1AP_SETUP_REQ (msg_p).sib1_length[k]                                = rrc->carrier[0].sizeof_SIB1;
2042 2043 2044 2045
        break;
      } // if
    } // for
  } // if
frtabu's avatar
frtabu committed
2046

2047 2048
  return 0;
}
2049

laurent's avatar
laurent committed
2050 2051 2052 2053 2054
int RCconfig_gtpu(void ) {
  int               num_enbs                      = 0;
  char             *enb_interface_name_for_S1U    = NULL;
  char             *enb_ipv4_address_for_S1U      = NULL;
  uint32_t          enb_port_for_S1U              = 0;
2055 2056
  char             *address                       = NULL;
  char             *cidr                          = NULL;
laurent's avatar
laurent committed
2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072
  char gtpupath[MAX_OPTNAME_SIZE*2 + 8];
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  paramdef_t GTPUParams[]  = GTPUPARAMS_DESC;
  LOG_I(GTPU,"Configuring GTPu\n");
  /* get number of active eNodeBs */
  config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
  num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt;
  AssertFatal (num_enbs >0,
               "Failed to parse config file no active eNodeBs in %s \n", ENB_CONFIG_STRING_ACTIVE_ENBS);
  sprintf(gtpupath,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,0,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
  config_get( GTPUParams,sizeof(GTPUParams)/sizeof(paramdef_t),gtpupath);
  cidr = enb_ipv4_address_for_S1U;
  address = strtok(cidr, "/");

  if (address) {
    MessageDef *message;
2073
    AssertFatal((message = itti_alloc_new_message(TASK_ENB_APP, 0, GTPV1U_ENB_S1_REQ))!=NULL,"");
laurent's avatar
laurent committed
2074 2075 2076
    IPV4_STR_ADDR_TO_INT_NWBO ( address, GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" );
    LOG_I(GTPU,"Configuring GTPu address : %s -> %x\n",address,GTPV1U_ENB_S1_REQ(message).enb_ip_address_for_S1u_S12_S4_up);
    GTPV1U_ENB_S1_REQ(message).enb_port_for_S1u_S12_S4_up = enb_port_for_S1U;
Laurent Thomas's avatar
Laurent Thomas committed
2077 2078 2079
    strcpy(GTPV1U_ENB_S1_REQ(message).addrStr,address);
    sprintf(GTPV1U_ENB_S1_REQ(message).portStr,"%d", enb_port_for_S1U);
    itti_send_msg_to_task (TASK_VARIABLE, 0, message); // data model is wrong: gtpu doesn't have enb_id (or module_id)
laurent's avatar
laurent committed
2080 2081 2082 2083 2084
  } else
    LOG_E(GTPU,"invalid address for S1U\n");

  return 0;
}
2085

2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345
int RCconfig_M2(MessageDef *msg_p, uint32_t i) {
  int   I, J, j, k, l;
  int   enb_id;
  char *address = NULL;
  char *cidr    = NULL;
  ccparams_lte_t ccparams_lte;
  memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t));
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  paramdef_t ENBParams[]  = ENBPARAMS_DESC;
  paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0};
  /* get global parameters, defined outside any section in the config file */
  config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
  checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
  paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
  paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0};

 // ccparams_MCE_t MCEconfig;
 // memset((void *)&MCEconfig,0,sizeof(ccparams_MCE_t));
 // paramdef_t MCEParams[]              = MCEPARAMS_DESC((&MCEconfig));
 // checkedparam_t config_check_MCEparams[] = MCEPARAMS_CHECK;


  /* map parameter checking array instances to parameter definition array instances */
  for (I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
    CCsParams[I].chkPptr = &(config_check_CCparams[I]);
  }

  AssertFatal(i < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt,
              "Failed to parse config file %s, %uth attribute %s \n",
              RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS);

  if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt > 0) {
    // Output a list of all eNBs.
    config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL);

    if (ENBParamList.numelt > 0) {
      for (k = 0; k < ENBParamList.numelt; k++) {
        if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) {
          // Calculate a default eNB ID
          if (EPC_MODE_ENABLED) {
            uint32_t hash;
            hash = s1ap_generate_eNB_id ();
            enb_id = k + (hash & 0xFFFF8);
          } else {
            enb_id = k;
          }
        } else {
          enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr);
        }

        // search if in active list
        for (j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) {
          if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) {
            paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
            paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0};
            /* map parameter checking array instances to parameter definition array instances */
            checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;

            for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I)
              PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);

            paramdef_t M2Params[]  = M2PARAMS_DESC;
            paramlist_def_t M2ParamList = {ENB_CONFIG_STRING_TARGET_MCE_M2_IP_ADDRESS,NULL,0};
            paramdef_t SCTPParams[]  = SCTPPARAMS_DESC;
            paramdef_t NETParams[]  =  NETPARAMS_DESC;
            paramdef_t MBMSConfigParams[]  = MBMS_CONFIG_PARAMS_DESC;
            paramdef_t MBMSParams[]  = MBMSPARAMS_DESC;
           paramlist_def_t MBMSConfigParamList = {ENB_CONFIG_STRING_MBMS_CONFIGURATION_DATA_LIST,NULL,0};
           paramlist_def_t MBMSParamList = {ENB_CONFIG_STRING_MBMS_SERVICE_AREA_LIST,NULL,0};
            /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */
            /* this is most probably a problem with the config module */
            char aprefix[MAX_OPTNAME_SIZE*80 + 8];
            sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
            /* Some default/random parameters */
            M2AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id;

            if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) {
              M2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB;
            } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) {
              M2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB;
            } else {
              AssertFatal (0,
                           "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
                           RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr));
            }

            M2AP_REGISTER_ENB_REQ (msg_p).eNB_name         = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr));
            M2AP_REGISTER_ENB_REQ (msg_p).tac              = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr;
            config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix);



//            char aprefix2[MAX_OPTNAME_SIZE*80 + 8];
//            sprintf(aprefix2,"%s.[%i].%s.[0]",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_MBMS_CONFIGURATION_DATA_LIST);
//            config_getlist(&MBMSParamList, MBMSParams, sizeof(MBMSParams)/sizeof(paramdef_t), aprefix2);
//         if (MBMSParamList.numelt < 1 || MBMSParamList.numelt > 8)
//              AssertFatal(0, "The number of MBMS Areas must be in [1,8], but is %d\n",
//                          MBMSParamList.numelt);
//         M2AP_REGISTER_ENB_REQ (msg_p).num_mbms_service_area_list = MBMSParamList.numelt;
//         for(J=0; J<MBMSParamList.numelt;J++){
//             M2AP_REGISTER_ENB_REQ (msg_p).mbms_service_area_list[J] = *MBMSParamList.paramarray[J][ENB_MBMS_SERVICE_AREA_IDX].uptr;
//         }
//

            char aprefix2[MAX_OPTNAME_SIZE*80 + 8];
            sprintf(aprefix2,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
            config_getlist(&MBMSConfigParamList, MBMSConfigParams, sizeof(MBMSConfigParams)/sizeof(paramdef_t), aprefix2);
            if (MBMSConfigParamList.numelt < 1 || MBMSConfigParamList.numelt > 8)
              AssertFatal(0, "The number of MBMS Config Data must be in [1,8], but is %d\n",
                          MBMSConfigParamList.numelt);
            M2AP_REGISTER_ENB_REQ (msg_p).num_mbms_configuration_data_list = MBMSConfigParamList.numelt;
           for(int I=0; I < MBMSConfigParamList.numelt; I++){

                   sprintf(aprefix2,"%s.[%i].%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_MBMS_CONFIGURATION_DATA_LIST,I);
                   config_getlist(&MBMSParamList, MBMSParams, sizeof(MBMSParams)/sizeof(paramdef_t), aprefix2);
                   if (MBMSParamList.numelt < 1 || MBMSParamList.numelt > 8)
                     AssertFatal(0, "The number of MBMS Areas must be in [1,8], but is %d\n",
                                 MBMSParamList.numelt);
                   M2AP_REGISTER_ENB_REQ (msg_p).mbms_configuration_data_list[I].num_mbms_service_area_list = MBMSParamList.numelt;
                   for(J=0; J<MBMSParamList.numelt;J++){
                       M2AP_REGISTER_ENB_REQ (msg_p).mbms_configuration_data_list[I].mbms_service_area_list[J] = *MBMSParamList.paramarray[J][ENB_MBMS_SERVICE_AREA_IDX].uptr;
                   }

          }


            if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6)
              AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n",
                          PLMNParamList.numelt);

            if (PLMNParamList.numelt > 1)
              LOG_W(M2AP, "M2AP currently handles only one PLMN, ignoring the others!\n");

            M2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr;
            M2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr;
            M2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr;
            AssertFatal(M2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3
                        || M2AP_REGISTER_ENB_REQ(msg_p).mnc < 100,
                        "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n",
                        M2AP_REGISTER_ENB_REQ(msg_p).mnc);
            /* CC params */
            config_getlist(&CCsParamList, NULL, 0, aprefix);
            M2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt;

            if (CCsParamList.numelt > 0) {
              //char ccspath[MAX_OPTNAME_SIZE*2 + 16];
              for (J = 0; J < CCsParamList.numelt ; J++) {
                sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, J);
                config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix);
                M2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = ccparams_lte.eutra_band;
                M2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = (uint32_t) ccparams_lte.downlink_frequency;
                M2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = (unsigned int) ccparams_lte.uplink_frequency_offset;
                M2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= ccparams_lte.Nid_cell;

                if (ccparams_lte.Nid_cell>503) {
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
                               RC.config_file_name, k, ccparams_lte.Nid_cell);
                }

                M2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= ccparams_lte.N_RB_DL;

                if ((ccparams_lte.N_RB_DL!=6) && (ccparams_lte.N_RB_DL!=15) && (ccparams_lte.N_RB_DL!=25) && (ccparams_lte.N_RB_DL!=50) && (ccparams_lte.N_RB_DL!=75) && (ccparams_lte.N_RB_DL!=100)) {
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
                               RC.config_file_name, k, ccparams_lte.N_RB_DL);
                }

                if (strcmp(ccparams_lte.frame_type, "FDD") == 0) {
                  M2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = FDD;
                } else  if (strcmp(ccparams_lte.frame_type, "TDD") == 0) {
                  M2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD;
                } else {
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
                               RC.config_file_name, k, ccparams_lte.frame_type);
                }

                M2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency, ccparams_lte.N_RB_DL);
                M2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency + ccparams_lte.uplink_frequency_offset, ccparams_lte.N_RB_DL);
              }
            }

            sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
            config_getlist( &M2ParamList,M2Params,sizeof(M2Params)/sizeof(paramdef_t),aprefix);
            AssertFatal(M2ParamList.numelt <= M2AP_MAX_NB_ENB_IP_ADDRESS,
                        "value of M2ParamList.numelt %d must be lower than M2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase M2AP_MAX_NB_ENB_IP_ADDRESS\n",
                        M2ParamList.numelt,M2AP_MAX_NB_ENB_IP_ADDRESS);
            M2AP_REGISTER_ENB_REQ (msg_p).nb_m2 = 0;

            for (l = 0; l < M2ParamList.numelt; l++) {
              M2AP_REGISTER_ENB_REQ (msg_p).nb_m2 += 1;
              strcpy(M2AP_REGISTER_ENB_REQ (msg_p).target_mce_m2_ip_address[l].ipv4_address,*(M2ParamList.paramarray[l][ENB_M2_IPV4_ADDRESS_IDX].strptr));
              strcpy(M2AP_REGISTER_ENB_REQ (msg_p).target_mce_m2_ip_address[l].ipv6_address,*(M2ParamList.paramarray[l][ENB_M2_IPV6_ADDRESS_IDX].strptr));

              if (strcmp(*(M2ParamList.paramarray[l][ENB_M2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) {
                M2AP_REGISTER_ENB_REQ (msg_p).target_mce_m2_ip_address[l].ipv4 = 1;
                M2AP_REGISTER_ENB_REQ (msg_p).target_mce_m2_ip_address[l].ipv6 = 0;
              } else if (strcmp(*(M2ParamList.paramarray[l][ENB_M2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) {
                M2AP_REGISTER_ENB_REQ (msg_p).target_mce_m2_ip_address[l].ipv4 = 0;
                M2AP_REGISTER_ENB_REQ (msg_p).target_mce_m2_ip_address[l].ipv6 = 1;
              } else if (strcmp(*(M2ParamList.paramarray[l][ENB_M2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) {
                M2AP_REGISTER_ENB_REQ (msg_p).target_mce_m2_ip_address[l].ipv4 = 1;
                M2AP_REGISTER_ENB_REQ (msg_p).target_mce_m2_ip_address[l].ipv6 = 1;
              }
            }
            // timers
            //{
            //  int t_reloc_prep = 0;
            //  int tx2_reloc_overall = 0;
            //  paramdef_t p[] = {
            //    { "t_reloc_prep", "t_reloc_prep", 0, iptr:&t_reloc_prep, defintval:0, TYPE_INT, 0 },
            //    { "tx2_reloc_overall", "tx2_reloc_overall", 0, iptr:&tx2_reloc_overall, defintval:0, TYPE_INT, 0 }
            //  };
            //  config_get(p, sizeof(p)/sizeof(paramdef_t), aprefix);

            //  if (t_reloc_prep <= 0 || t_reloc_prep > 10000 ||
            //      tx2_reloc_overall <= 0 || tx2_reloc_overall > 20000) {
            //    LOG_E(M2AP, "timers in configuration file have wrong values. We must have [0 < t_reloc_prep <= 10000] and [0 < tx2_reloc_overall <= 20000]\n");
            //    exit(1);
            //  }

            //  M2AP_REGISTER_ENB_REQ (msg_p).t_reloc_prep = t_reloc_prep;
            //  M2AP_REGISTER_ENB_REQ (msg_p).tx2_reloc_overall = tx2_reloc_overall;
            //}
            // SCTP SETTING
            M2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS;
            M2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams  = SCTP_IN_STREAMS;

            if (EPC_MODE_ENABLED) {
              sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG);
              config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
              M2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr);
              M2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr);
            }

            sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
            // NETWORK_INTERFACES
            config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix);
            M2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_M2C = (uint32_t)*(NETParams[ENB_PORT_FOR_M2C_IDX].uptr);

            if ((NETParams[ENB_IPV4_ADDR_FOR_M2C_IDX].strptr == NULL) || (M2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_M2C == 0)) {
              LOG_E(RRC,"Add eNB IPv4 address and/or port for M2C in the CONF file!\n");
              exit(1);
            }

            cidr = *(NETParams[ENB_IPV4_ADDR_FOR_M2C_IDX].strptr);
            address = strtok(cidr, "/");
            M2AP_REGISTER_ENB_REQ (msg_p).enb_m2_ip_address.ipv6 = 0;
            M2AP_REGISTER_ENB_REQ (msg_p).enb_m2_ip_address.ipv4 = 1;
            strcpy(M2AP_REGISTER_ENB_REQ (msg_p).enb_m2_ip_address.ipv4_address, address);
          }
        }
      }
    }
  }

  return 0;
}

2346 2347
//-----------------------------------------------------------------------------
/*
Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2348
* Configure the s1ap_register_enb_req in itti message for future
2349 2350 2351
* communications between eNB(s) and MME.
*/
int RCconfig_S1(
Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2352 2353
  MessageDef *msg_p,
  uint32_t i)
2354 2355 2356 2357 2358 2359 2360
//-----------------------------------------------------------------------------
{
  int enb_id = 0;
  int32_t my_int = 0;
  const char *active_enb[MAX_ENB];
  char *address = NULL;
  char *cidr    = NULL;
2361
  ccparams_lte_t ccparams_lte;
2362
  memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t));
laurent's avatar
laurent committed
2363
  // for no gcc warnings
2364
  (void)my_int;
2365
  memset((char *)active_enb, 0, MAX_ENB * sizeof(char *));
2366
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
2367 2368
  paramdef_t ENBParams[] = ENBPARAMS_DESC;
  paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST, NULL, 0};
laurent's avatar
laurent committed
2369
  /* get global parameters, defined outside any section in the config file */
2370 2371
  config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL);
  AssertFatal (i < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt,
laurent's avatar
laurent committed
2372 2373
               "Failed to parse config file %s, %uth attribute %s \n",
               RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
2374

2375
  if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt > 0) {
2376
    // Output a list of all eNBs.
2377
    config_getlist(&ENBParamList, ENBParams, sizeof(ENBParams)/sizeof(paramdef_t), NULL);
laurent's avatar
laurent committed
2378

2379
    if (ENBParamList.numelt > 0) {
2380
      for (int k = 0; k < ENBParamList.numelt; k++) {
laurent's avatar
laurent committed
2381 2382 2383
        if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) {
          // Calculate a default eNB ID
          if (EPC_MODE_ENABLED) {
2384 2385
            uint32_t hash = 0;
            hash = s1ap_generate_eNB_id();
laurent's avatar
laurent committed
2386 2387 2388 2389 2390 2391 2392
            enb_id = k + (hash & 0xFFFF8);
          } else {
            enb_id = k;
          }
        } else {
          enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr);
        }
2393

laurent's avatar
laurent committed
2394
        // search if in active list
2395
        for (int j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) {
laurent's avatar
laurent committed
2396
          if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) {
2397 2398
            paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
            paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0};
2399
            paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
2400 2401
            /* map parameter checking array instances to parameter definition array instances */
            checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2402

2403 2404 2405
            for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
              CCsParams[I].chkPptr = &(config_check_CCparams[I]);
            }
Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2406

2407 2408
            /* map parameter checking array instances to parameter definition array instances */
            checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;
2409

2410
            for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) {
2411
              PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);
2412
            }
2413

2414 2415 2416 2417
            paramdef_t S1Params[] = S1PARAMS_DESC;
            paramlist_def_t S1ParamList = {ENB_CONFIG_STRING_MME_IP_ADDRESS, NULL, 0};
            paramdef_t SCTPParams[] = SCTPPARAMS_DESC;
            paramdef_t NETParams[] =  NETPARAMS_DESC;
laurent's avatar
laurent committed
2418
            char aprefix[MAX_OPTNAME_SIZE*2 + 8];
2419
            sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k);
laurent's avatar
laurent committed
2420
            S1AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id;
2421

laurent's avatar
laurent committed
2422 2423 2424 2425
            if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) {
              S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB;
            } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) {
              S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB;
2426 2427 2428 2429 2430
              // Temporary option to be able to parse an eNB configuration file which is treated as gNB from
              // the X2AP layer and test the setup of an ENDC X2AP connection. To be removed when we are ready to
              // parse an actual gNB configuration file wrt. the X2AP parameters instead.
            } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_GNB") == 0) {
              S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_GNB;
laurent's avatar
laurent committed
2431
            } else {
2432
              AssertFatal(0,
frtabu's avatar
frtabu committed
2433
                          "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2434 2435
                          RC.config_file_name,
                          i,
2436
                          *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr));
laurent's avatar
laurent committed
2437
            }
2438

2439 2440
            S1AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr));
            S1AP_REGISTER_ENB_REQ(msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr;
2441 2442 2443 2444 2445 2446 2447 2448 2449
            AssertFatal(!ENBParamList.paramarray[k][ENB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr
                        && !ENBParamList.paramarray[k][ENB_MOBILE_NETWORK_CODE_IDX_OLD].strptr,
                        "It seems that you use an old configuration file. Please change the existing\n"
                        "    tracking_area_code  =  \"1\";\n"
                        "    mobile_country_code =  \"208\";\n"
                        "    mobile_network_code =  \"93\";\n"
                        "to\n"
                        "    tracking_area_code  =  1; // no string!!\n"
                        "    plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n");
Haruki NAOI's avatar
Haruki NAOI committed
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508
            if(*ENBParamList.paramarray[k][ENB_S1SETUP_RSP_TIMER_IDX].uptr <= 0xffff)
            {
              S1AP_REGISTER_ENB_REQ(msg_p).s1_setuprsp_wait_timer = *ENBParamList.paramarray[k][ENB_S1SETUP_RSP_TIMER_IDX].uptr;
            }
            else
            {
              LOG_E(S1AP, 
                    "s1setup_rsp_timer value in conf file is invalid (%d). Default value is set.\n",
                    *ENBParamList.paramarray[k][ENB_S1SETUP_RSP_TIMER_IDX].uptr);
              S1AP_REGISTER_ENB_REQ(msg_p).s1_setuprsp_wait_timer = 5;
            }

            if(*ENBParamList.paramarray[k][ENB_S1SETUP_REQ_TIMER_IDX].uptr <= 0xffff)
            {
              S1AP_REGISTER_ENB_REQ(msg_p).s1_setupreq_wait_timer = *ENBParamList.paramarray[k][ENB_S1SETUP_REQ_TIMER_IDX].uptr;
            }
            else
            {
              LOG_E(S1AP, 
                    "s1setup_req_timer value in conf file is invalid (%d). Default value is set.\n",
                    *ENBParamList.paramarray[k][ENB_S1SETUP_REQ_TIMER_IDX].uptr);
              S1AP_REGISTER_ENB_REQ(msg_p).s1_setupreq_wait_timer = 5;
            }

            if(*ENBParamList.paramarray[k][ENB_S1SETUP_REQ_COUNT_IDX].uptr <= 0xffff)
            {
              S1AP_REGISTER_ENB_REQ(msg_p).s1_setupreq_count = *ENBParamList.paramarray[k][ENB_S1SETUP_REQ_COUNT_IDX].uptr;
            }
            else
            {
              LOG_E(S1AP, 
                    "s1setup_req_count value in conf file is invalid (%d). Default value is set.\n",
                    *ENBParamList.paramarray[k][ENB_S1SETUP_REQ_COUNT_IDX].uptr);
              S1AP_REGISTER_ENB_REQ(msg_p).s1_setupreq_count = 0xffff;
            }

            if(*ENBParamList.paramarray[k][ENB_SCTP_REQ_TIMER_IDX].uptr <= 0xffff)
            {
              S1AP_REGISTER_ENB_REQ(msg_p).sctp_req_timer = *ENBParamList.paramarray[k][ENB_SCTP_REQ_TIMER_IDX].uptr;
            }
            else
            {
              LOG_E(S1AP, 
                    "sctp_req_timer value in conf file is invalid (%d). Default value is set.\n",
                    *ENBParamList.paramarray[k][ENB_SCTP_REQ_TIMER_IDX].uptr);
              S1AP_REGISTER_ENB_REQ(msg_p).sctp_req_timer = 180;
            }

            if(*ENBParamList.paramarray[k][ENB_SCTP_REQ_COUNT_IDX].uptr <= 0xffff)
            {
              S1AP_REGISTER_ENB_REQ(msg_p).sctp_req_count = *ENBParamList.paramarray[k][ENB_SCTP_REQ_COUNT_IDX].uptr;
            }
            else
            {
              LOG_E(S1AP, 
                    "sctp_req_count value in conf file is invalid (%d). Default value is set.\n",
                    *ENBParamList.paramarray[k][ENB_SCTP_REQ_COUNT_IDX].uptr);
              S1AP_REGISTER_ENB_REQ(msg_p).sctp_req_count = 0xffff;
            }
2509
            config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix);
2510

Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2511
            if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) {
2512 2513
              AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n",
                          PLMNParamList.numelt);
2514
            }
2515 2516

            S1AP_REGISTER_ENB_REQ(msg_p).num_plmn = PLMNParamList.numelt;
2517

2518 2519 2520 2521 2522 2523 2524 2525 2526
            for (int l = 0; l < PLMNParamList.numelt; ++l) {
              S1AP_REGISTER_ENB_REQ(msg_p).mcc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_COUNTRY_CODE_IDX].uptr;
              S1AP_REGISTER_ENB_REQ(msg_p).mnc[l] = *PLMNParamList.paramarray[l][ENB_MOBILE_NETWORK_CODE_IDX].uptr;
              S1AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length[l] = *PLMNParamList.paramarray[l][ENB_MNC_DIGIT_LENGTH].u8ptr;
              AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length[l] == 3
                          || S1AP_REGISTER_ENB_REQ(msg_p).mnc[l] < 100,
                          "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n",
                          S1AP_REGISTER_ENB_REQ(msg_p).mnc[l]);
            }
2527

2528 2529 2530
            /* Default DRX param */
            /*
            * Here we get the config of the first CC, since the s1ap_register_enb_req_t doesn't support multiple CC.
2531
            * There is a unique value of defaultPagingCycle per eNB (same for multiple cells).
2532 2533 2534 2535 2536
            * Hence, it should be stated somewhere that the value should be the same for every CC, or put the value outside the CC
            * in the conf file.
            */
            sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, 0);
            config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix);
Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2537

2538
            switch (ccparams_lte.pcch_defaultPagingCycle) {
2539 2540 2541 2542
              case 32: {
                S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0;
                break;
              }
Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2543

2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560
              case 64: {
                S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 1;
                break;
              }

              case 128: {
                S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 2;
                break;
              }

              case 256: {
                S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 3;
                break;
              }

              default: {
                LOG_E(S1AP, "Default I-DRX value in conf file is invalid (%i). Should be 32, 64, 128 or 256. \
2561
                       Default DRX set to 32 in MME configuration\n",
2562
                      ccparams_lte.pcch_defaultPagingCycle);
2563 2564 2565 2566 2567 2568 2569
                S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0;
              }
            }

            /* MME connection params */
            sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k);
            config_getlist(&S1ParamList, S1Params, sizeof(S1Params)/sizeof(paramdef_t), aprefix);
laurent's avatar
laurent committed
2570 2571 2572 2573 2574 2575 2576 2577 2578
            S1AP_REGISTER_ENB_REQ (msg_p).nb_mme = 0;

            for (int l = 0; l < S1ParamList.numelt; l++) {
              S1AP_REGISTER_ENB_REQ (msg_p).nb_mme += 1;
              strcpy(S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4_address,*(S1ParamList.paramarray[l][ENB_MME_IPV4_ADDRESS_IDX].strptr));
              strcpy(S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6_address,*(S1ParamList.paramarray[l][ENB_MME_IPV6_ADDRESS_IDX].strptr));

              if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) {
                S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4 = 1;
2579
                S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6 = 0;
laurent's avatar
laurent committed
2580
              } else if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) {
2581
                S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4 = 0;
laurent's avatar
laurent committed
2582 2583 2584 2585
                S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6 = 1;
              } else if (strcmp(*(S1ParamList.paramarray[l][ENB_MME_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) {
                S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv4 = 1;
                S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6 = 1;
2586
              }
2587

2588
              if (S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].iptr) {
2589
                S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].numelt;
2590
              } else {
2591
                S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = 0;
2592
              }
2593

2594
              /* set S1-mme port (sctp) */
2595
              S1AP_REGISTER_ENB_REQ(msg_p).mme_port[l] = *S1ParamList.paramarray[l][ENB_MME_PORT_IDX].u16ptr;
2596

2597 2598 2599 2600 2601
              AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] <= S1AP_REGISTER_ENB_REQ(msg_p).num_plmn,
                          "List of broadcast PLMN to be sent to MME can not be longer than actual "
                          "PLMN list (max %d, but is %d)\n",
                          S1AP_REGISTER_ENB_REQ(msg_p).num_plmn,
                          S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l]);
2602

2603 2604 2605 2606 2607 2608 2609 2610 2611
              for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l]; ++el) {
                /* UINTARRAY gets mapped to int, see config_libconfig.c:223 */
                S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] = S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].iptr[el];
                AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] >= 0
                            && S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn,
                            "index for MME's MCC/MNC (%d) is an invalid index for the registered PLMN IDs (%d)\n",
                            S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el],
                            S1AP_REGISTER_ENB_REQ(msg_p).num_plmn);
              }
2612

2613 2614 2615
              /* if no broadcasst_plmn array is defined, fill default values */
              if (S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] == 0) {
                S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = S1AP_REGISTER_ENB_REQ(msg_p).num_plmn;
2616

Louis Adrien Dufrene's avatar
Louis Adrien Dufrene committed
2617
                for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; ++el) {
2618
                  S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] = el;
2619
                }
2620
              }
laurent's avatar
laurent committed
2621
            }
2622

laurent's avatar
laurent committed
2623 2624 2625
            // SCTP SETTING
            S1AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS;
            S1AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams  = SCTP_IN_STREAMS;
2626

laurent's avatar
laurent committed
2627 2628 2629 2630 2631 2632
            if (EPC_MODE_ENABLED) {
              sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG);
              config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
              S1AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr);
              S1AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr);
            }
2633

laurent's avatar
laurent committed
2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644
            sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
            // NETWORK_INTERFACES
            config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix);
            cidr = *(NETParams[ENB_IPV4_ADDRESS_FOR_S1_MME_IDX].strptr);
            address = strtok(cidr, "/");
            S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv6 = 0;
            S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv4 = 1;
            strcpy(S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv4_address, address);
            break;
          }
        }
2645 2646 2647 2648
      }
    }
  }

laurent's avatar
laurent committed
2649
  return 0;
2650 2651
}

laurent's avatar
laurent committed
2652
int RCconfig_X2(MessageDef *msg_p, uint32_t i) {
2653
  int   I, J, j, k, l;
2654 2655 2656
  int   enb_id;
  char *address = NULL;
  char *cidr    = NULL;
2657
  ccparams_lte_t ccparams_lte;
2658
  memset((void *)&ccparams_lte,0,sizeof(ccparams_lte_t));
2659 2660 2661 2662 2663
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  paramdef_t ENBParams[]  = ENBPARAMS_DESC;
  paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0};
  /* get global parameters, defined outside any section in the config file */
  config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
2664
  checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK;
2665
  paramdef_t CCsParams[] = CCPARAMS_DESC(ccparams_lte);
2666 2667 2668 2669 2670 2671
  paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0};

  /* map parameter checking array instances to parameter definition array instances */
  for (I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) {
    CCsParams[I].chkPptr = &(config_check_CCparams[I]);
  }
2672

2673
  AssertFatal(i < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt,
frtabu's avatar
frtabu committed
2674 2675
              "Failed to parse config file %s, %uth attribute %s \n",
              RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
2676

2677 2678 2679
  if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt > 0) {
    // Output a list of all eNBs.
    config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL);
laurent's avatar
laurent committed
2680

2681 2682
    if (ENBParamList.numelt > 0) {
      for (k = 0; k < ENBParamList.numelt; k++) {
frtabu's avatar
frtabu committed
2683 2684
        if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) {
          // Calculate a default eNB ID
2685
          if (EPC_MODE_ENABLED) {
frtabu's avatar
frtabu committed
2686 2687 2688
            uint32_t hash;
            hash = s1ap_generate_eNB_id ();
            enb_id = k + (hash & 0xFFFF8);
2689
          } else {
frtabu's avatar
frtabu committed
2690
            enb_id = k;
2691
          }
frtabu's avatar
frtabu committed
2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721
        } else {
          enb_id = *(ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr);
        }

        // search if in active list
        for (j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) {
          if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) {
            paramdef_t PLMNParams[] = PLMNPARAMS_DESC;
            paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0};
            /* map parameter checking array instances to parameter definition array instances */
            checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK;

            for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I)
              PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]);

            paramdef_t X2Params[]  = X2PARAMS_DESC;
            paramlist_def_t X2ParamList = {ENB_CONFIG_STRING_TARGET_ENB_X2_IP_ADDRESS,NULL,0};
            paramdef_t SCTPParams[]  = SCTPPARAMS_DESC;
            paramdef_t NETParams[]  =  NETPARAMS_DESC;
            /* TODO: fix the size - if set lower we have a crash (MAX_OPTNAME_SIZE was 64 when this code was written) */
            /* this is most probably a problem with the config module */
            char aprefix[MAX_OPTNAME_SIZE*80 + 8];
            sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
            /* Some default/random parameters */
            X2AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id;

            if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) {
              X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_MACRO_ENB;
            } else  if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) {
              X2AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB;
2722
            }else {
frtabu's avatar
frtabu committed
2723
              AssertFatal (0,
frtabu's avatar
frtabu committed
2724
                           "Failed to parse eNB configuration file %s, enb %u unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
frtabu's avatar
frtabu committed
2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777
                           RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr));
            }

            X2AP_REGISTER_ENB_REQ (msg_p).eNB_name         = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr));
            X2AP_REGISTER_ENB_REQ (msg_p).tac              = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr;
            config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix);

            if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6)
              AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n",
                          PLMNParamList.numelt);

            if (PLMNParamList.numelt > 1)
              LOG_W(X2AP, "X2AP currently handles only one PLMN, ignoring the others!\n");

            X2AP_REGISTER_ENB_REQ (msg_p).mcc = *PLMNParamList.paramarray[0][ENB_MOBILE_COUNTRY_CODE_IDX].uptr;
            X2AP_REGISTER_ENB_REQ (msg_p).mnc = *PLMNParamList.paramarray[0][ENB_MOBILE_NETWORK_CODE_IDX].uptr;
            X2AP_REGISTER_ENB_REQ (msg_p).mnc_digit_length = *PLMNParamList.paramarray[0][ENB_MNC_DIGIT_LENGTH].u8ptr;
            AssertFatal(X2AP_REGISTER_ENB_REQ(msg_p).mnc_digit_length == 3
                        || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100,
                        "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n",
                        X2AP_REGISTER_ENB_REQ(msg_p).mnc);
            /* CC params */
            config_getlist(&CCsParamList, NULL, 0, aprefix);
            X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt;

            if (CCsParamList.numelt > 0) {
              //char ccspath[MAX_OPTNAME_SIZE*2 + 16];
              for (J = 0; J < CCsParamList.numelt ; J++) {
                sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, J);
                config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix);
                X2AP_REGISTER_ENB_REQ (msg_p).eutra_band[J] = ccparams_lte.eutra_band;
                X2AP_REGISTER_ENB_REQ (msg_p).downlink_frequency[J] = (uint32_t) ccparams_lte.downlink_frequency;
                X2AP_REGISTER_ENB_REQ (msg_p).uplink_frequency_offset[J] = (unsigned int) ccparams_lte.uplink_frequency_offset;
                X2AP_REGISTER_ENB_REQ (msg_p).Nid_cell[J]= ccparams_lte.Nid_cell;

                if (ccparams_lte.Nid_cell>503) {
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for Nid_cell choice: 0...503 !\n",
                               RC.config_file_name, k, ccparams_lte.Nid_cell);
                }

                X2AP_REGISTER_ENB_REQ (msg_p).N_RB_DL[J]= ccparams_lte.N_RB_DL;

                if ((ccparams_lte.N_RB_DL!=6) && (ccparams_lte.N_RB_DL!=15) && (ccparams_lte.N_RB_DL!=25) && (ccparams_lte.N_RB_DL!=50) && (ccparams_lte.N_RB_DL!=75) && (ccparams_lte.N_RB_DL!=100)) {
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%d\" for N_RB_DL choice: 6,15,25,50,75,100 !\n",
                               RC.config_file_name, k, ccparams_lte.N_RB_DL);
                }

                if (strcmp(ccparams_lte.frame_type, "FDD") == 0) {
                  X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = FDD;
                } else  if (strcmp(ccparams_lte.frame_type, "TDD") == 0) {
                  X2AP_REGISTER_ENB_REQ (msg_p).frame_type[J] = TDD;
wujing's avatar
wujing committed
2778 2779
                  X2AP_REGISTER_ENB_REQ (msg_p).subframeAssignment[J] = ccparams_lte.tdd_config;
                  X2AP_REGISTER_ENB_REQ (msg_p).specialSubframe[J] = ccparams_lte.tdd_config_s;
frtabu's avatar
frtabu committed
2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796
                } else {
                  AssertFatal (0,
                               "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
                               RC.config_file_name, k, ccparams_lte.frame_type);
                }

                X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_DL[J] = to_earfcn_DL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency, ccparams_lte.N_RB_DL);
                X2AP_REGISTER_ENB_REQ (msg_p).fdd_earfcn_UL[J] = to_earfcn_UL(ccparams_lte.eutra_band, ccparams_lte.downlink_frequency + ccparams_lte.uplink_frequency_offset, ccparams_lte.N_RB_DL);
              }
            }

            sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k);
            config_getlist( &X2ParamList,X2Params,sizeof(X2Params)/sizeof(paramdef_t),aprefix);
            AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS,
                        "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n",
                        X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS);
            X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0;
Raymond Knopp's avatar
Raymond Knopp committed
2797
            LOG_I(X2AP,"X2ParamList.numelt %d\n",X2ParamList.numelt);
frtabu's avatar
frtabu committed
2798 2799 2800 2801 2802
            for (l = 0; l < X2ParamList.numelt; l++) {
              X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1;
              strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr));
              strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr));

Raymond Knopp's avatar
Raymond Knopp committed
2803
              LOG_I(X2AP,"registering with ip : %s\n",*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr));
frtabu's avatar
frtabu committed
2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814
              if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) {
                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1;
                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 0;
              } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv6") == 0) {
                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 0;
                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1;
              } else if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "no") == 0) {
                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1;
                X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 1;
              }
            }
2815

Cedric Roux's avatar
Cedric Roux committed
2816 2817 2818 2819
            // timers
            {
              int t_reloc_prep = 0;
              int tx2_reloc_overall = 0;
Cedric Roux's avatar
Cedric Roux committed
2820 2821
              int t_dc_prep = 0;
              int t_dc_overall = 0;
Cedric Roux's avatar
Cedric Roux committed
2822 2823
              paramdef_t p[] = {
                { "t_reloc_prep", "t_reloc_prep", 0, iptr:&t_reloc_prep, defintval:0, TYPE_INT, 0 },
Cedric Roux's avatar
Cedric Roux committed
2824 2825 2826
                { "tx2_reloc_overall", "tx2_reloc_overall", 0, iptr:&tx2_reloc_overall, defintval:0, TYPE_INT, 0 },
                { "t_dc_prep", "t_dc_prep", 0, iptr:&t_dc_prep, defintval:0, TYPE_INT, 0 },
                { "t_dc_overall", "t_dc_overall", 0, iptr:&t_dc_overall, defintval:0, TYPE_INT, 0 }
Cedric Roux's avatar
Cedric Roux committed
2827 2828 2829 2830
              };
              config_get(p, sizeof(p)/sizeof(paramdef_t), aprefix);

              if (t_reloc_prep <= 0 || t_reloc_prep > 10000 ||
Cedric Roux's avatar
Cedric Roux committed
2831 2832 2833 2834
                  tx2_reloc_overall <= 0 || tx2_reloc_overall > 20000 ||
                  t_dc_prep <= 0 || t_dc_prep > 10000 ||
                  t_dc_overall <= 0 || t_dc_overall > 20000) {
                LOG_E(X2AP, "timers in configuration file have wrong values. We must have [0 < t_reloc_prep <= 10000] and [0 < tx2_reloc_overall <= 20000] and [0 < t_dc_prep <= 10000] and [0 < t_dc_overall <= 20000]\n");
Cedric Roux's avatar
Cedric Roux committed
2835 2836 2837
                exit(1);
              }

frtabu's avatar
frtabu committed
2838 2839
              X2AP_REGISTER_ENB_REQ (msg_p).t_reloc_prep = t_reloc_prep;
              X2AP_REGISTER_ENB_REQ (msg_p).tx2_reloc_overall = tx2_reloc_overall;
Cedric Roux's avatar
Cedric Roux committed
2840 2841
              X2AP_REGISTER_ENB_REQ (msg_p).t_dc_prep = t_dc_prep;
              X2AP_REGISTER_ENB_REQ (msg_p).t_dc_overall = t_dc_overall;
Cedric Roux's avatar
Cedric Roux committed
2842
            }
frtabu's avatar
frtabu committed
2843 2844 2845
            // SCTP SETTING
            X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = SCTP_OUT_STREAMS;
            X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams  = SCTP_IN_STREAMS;
2846

2847
            if (EPC_MODE_ENABLED) {
frtabu's avatar
frtabu committed
2848 2849 2850 2851
              sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_SCTP_CONFIG);
              config_get( SCTPParams,sizeof(SCTPParams)/sizeof(paramdef_t),aprefix);
              X2AP_REGISTER_ENB_REQ (msg_p).sctp_in_streams = (uint16_t)*(SCTPParams[ENB_SCTP_INSTREAMS_IDX].uptr);
              X2AP_REGISTER_ENB_REQ (msg_p).sctp_out_streams = (uint16_t)*(SCTPParams[ENB_SCTP_OUTSTREAMS_IDX].uptr);
2852 2853
            }

frtabu's avatar
frtabu committed
2854 2855 2856 2857 2858 2859 2860 2861
            sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
            // NETWORK_INTERFACES
            config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix);
            X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr);

            if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) {
              LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n");
              exit(1);
2862 2863
            }

frtabu's avatar
frtabu committed
2864 2865 2866 2867 2868 2869 2870
            cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr);
            address = strtok(cidr, "/");
            X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv6 = 0;
            X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4 = 1;
            strcpy(X2AP_REGISTER_ENB_REQ (msg_p).enb_x2_ip_address.ipv4_address, address);
          }
        }
2871 2872 2873
      }
    }
  }
laurent's avatar
laurent committed
2874 2875

  return 0;
2876
}
Lionel Gauthier's avatar
 
Lionel Gauthier committed
2877

2878
int RCconfig_parallel(void) {
2879 2880
  char *parallel_conf = NULL;
  char *worker_conf   = NULL;
2881 2882
  paramdef_t ThreadParams[]  = THREAD_CONF_DESC;
  paramlist_def_t THREADParamList = {THREAD_CONFIG_STRING_THREAD_STRUCT,NULL,0};
2883
  config_getlist( &THREADParamList,NULL,0,NULL);
2884

2885
  if(parallel_config == NULL) {
2886 2887 2888 2889 2890 2891
    if(THREADParamList.numelt>0) {
      config_getlist( &THREADParamList,ThreadParams,sizeof(ThreadParams)/sizeof(paramdef_t),NULL);
      parallel_conf = strdup(*(THREADParamList.paramarray[0][THREAD_PARALLEL_IDX].strptr));
    } else {
      parallel_conf = strdup("PARALLEL_RU_L1_TRX_SPLIT");
    }
2892

2893
    set_parallel_conf(parallel_conf);
2894
  }
2895

2896
  if(worker_config == NULL) {
2897 2898 2899 2900 2901 2902
    if(THREADParamList.numelt>0) {
      config_getlist( &THREADParamList,ThreadParams,sizeof(ThreadParams)/sizeof(paramdef_t),NULL);
      worker_conf   = strdup(*(THREADParamList.paramarray[0][THREAD_WORKER_IDX].strptr));
    } else {
      worker_conf   = strdup("WORKER_ENABLE");
    }
2903

2904
    set_worker_conf(worker_conf);
2905 2906
  }

Dong Anyuan's avatar
Dong Anyuan committed
2907
  free(worker_conf);
Dong Anyuan's avatar
Dong Anyuan committed
2908
  free(parallel_conf);
2909 2910
  return 0;
}
2911

2912
void RCConfig(void) {
2913 2914 2915 2916 2917
  paramlist_def_t MACRLCParamList = {CONFIG_STRING_MACRLC_LIST,NULL,0};
  paramlist_def_t L1ParamList = {CONFIG_STRING_L1_LIST,NULL,0};
  paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0};
  paramdef_t ENBSParams[] = ENBSPARAMS_DESC;
  paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0};
frtabu's avatar
frtabu committed
2918
  char aprefix[MAX_OPTNAME_SIZE*2 + 8];
laurent's avatar
laurent committed
2919
  /* get global parameters, defined outside any section in the config file */
2920
  printf("Getting ENBSParams\n");
laurent's avatar
laurent committed
2921
  config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL);
2922
  //EPC_MODE_ENABLED = ((*ENBSParams[ENB_NOS1_IDX].uptr) == 0);
2923
  RC.nb_inst = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt;
2924

2925 2926
  if (RC.nb_inst > 0) {
    RC.nb_CC = (int *)malloc((1+RC.nb_inst)*sizeof(int));
2927

laurent's avatar
laurent committed
2928
    for (int i=0; i<RC.nb_inst; i++) {
2929 2930
      sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,i);
      config_getlist( &CCsParamList,NULL,0, aprefix);
laurent's avatar
laurent committed
2931
      RC.nb_CC[i]    = CCsParamList.numelt;
2932 2933
    }
  }
frtabu's avatar
frtabu committed
2934

laurent's avatar
laurent committed
2935 2936
  config_getlist( &MACRLCParamList,NULL,0, NULL);
  RC.nb_macrlc_inst  = MACRLCParamList.numelt;
2937 2938
  AssertFatal(RC.nb_macrlc_inst <= MAX_MAC_INST,
              "Too many macrlc instances %d\n",RC.nb_macrlc_inst);
laurent's avatar
laurent committed
2939 2940 2941 2942 2943 2944
  // Get num L1 instances
  config_getlist( &L1ParamList,NULL,0, NULL);
  RC.nb_L1_inst = L1ParamList.numelt;
  // Get num RU instances
  config_getlist( &RUParamList,NULL,0, NULL);
  RC.nb_RU     = RUParamList.numelt;
2945
  RCconfig_parallel();
2946
}
2947

2948 2949
int check_plmn_identity(rrc_eNB_carrier_data_t *carrier,uint16_t mcc,uint16_t mnc,uint8_t mnc_digit_length) {
  AssertFatal(carrier->sib1->cellAccessRelatedInfo.plmn_IdentityList.list.count > 0,
frtabu's avatar
frtabu committed
2950
              "plmn info isn't there\n");
2951
  AssertFatal(mnc_digit_length ==2 || mnc_digit_length == 3,
frtabu's avatar
frtabu committed
2952
              "impossible mnc_digit_length %d\n",mnc_digit_length);
2953
  LTE_PLMN_IdentityInfo_t *plmn_Identity_info = carrier->sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[0];
2954 2955

  // check if mcc is different and return failure if so
frtabu's avatar
frtabu committed
2956
  if (mcc !=
2957 2958 2959 2960 2961 2962 2963 2964 2965
      (*plmn_Identity_info->plmn_Identity.mcc->list.array[0]*100)+
      (*plmn_Identity_info->plmn_Identity.mcc->list.array[1]*10) +
      (*plmn_Identity_info->plmn_Identity.mcc->list.array[2])) return(0);

  // check that mnc digit length is different and return failure if so
  if (mnc_digit_length != plmn_Identity_info->plmn_Identity.mnc.list.count) return 0;

  // check that 2 digit mnc is different and return failure if so
  if (mnc_digit_length == 2 &&
frtabu's avatar
frtabu committed
2966
      (mnc !=
2967 2968 2969
       (*plmn_Identity_info->plmn_Identity.mnc.list.array[0]*10) +
       (*plmn_Identity_info->plmn_Identity.mnc.list.array[1]))) return(0);
  else if (mnc_digit_length == 3 &&
frtabu's avatar
frtabu committed
2970 2971 2972 2973
           (mnc !=
            (*plmn_Identity_info->plmn_Identity.mnc.list.array[0]*100) +
            (*plmn_Identity_info->plmn_Identity.mnc.list.array[1]*10) +
            (*plmn_Identity_info->plmn_Identity.mnc.list.array[2]))) return(0);
2974 2975 2976 2977 2978 2979 2980 2981

  // if we're here, the mcc/mnc match so return success
  return(1);
}

void extract_and_decode_SI(int inst,int si_ind,uint8_t *si_container,int si_container_length) {
  eNB_RRC_INST *rrc = RC.rrc[inst];
  rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0];
2982
  LTE_BCCH_DL_SCH_Message_t *bcch_message ;
Raymond Knopp's avatar
Raymond Knopp committed
2983
  AssertFatal(si_ind==2,"Can only handle a single SI block for now\n");
2984
  LOG_I(ENB_APP, "rrc inst %d: Trying to decode SI block %d @ %p, length %d\n",inst,si_ind,si_container,si_container_length);
2985 2986 2987
  // point to first SI block
  bcch_message = &carrier->systemInformation;
  asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
frtabu's avatar
frtabu committed
2988 2989 2990 2991 2992
                            &asn_DEF_LTE_BCCH_DL_SCH_Message,
                            (void **)&bcch_message,
                            (const void *)si_container,
                            si_container_length);

2993 2994
  if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
    AssertFatal(1==0, "[ENB_APP][RRC inst %"PRIu8"] Failed to decode BCCH_DLSCH_MESSAGE (%zu bits)\n",
frtabu's avatar
frtabu committed
2995 2996
                inst,
                dec_rval.consumed );
2997
  }
frtabu's avatar
frtabu committed
2998

2999
  if (bcch_message->message.present == LTE_BCCH_DL_SCH_MessageType_PR_c1) {
3000
    switch (bcch_message->message.choice.c1.present) {
frtabu's avatar
frtabu committed
3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101
      case LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1:
        AssertFatal(1==0,"Should have received SIB1 from CU\n");
        break;

      case LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformation: {
        LTE_SystemInformation_t *si = &bcch_message->message.choice.c1.choice.systemInformation;

        for (int i=0; i<si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count; i++) {
          LOG_I(ENB_APP,"Extracting SI %d/%d\n",i,si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count);
          struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *typeandinfo;
          typeandinfo = si->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.array[i];

          switch(typeandinfo->present) {
            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2:
              carrier->sib2 = &typeandinfo->choice.sib2;
              carrier->SIB23 = (uint8_t *)malloc(64);
              memcpy((void *)carrier->SIB23,(void *)si_container,si_container_length);
              carrier->sizeof_SIB23 = si_container_length;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB2 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3:
              carrier->sib3 = &typeandinfo->choice.sib3;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB3 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4:
              //carrier->sib4 = &typeandinfo->choice.sib4;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB4 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5:
              //carrier->sib5 = &typeandinfo->choice.sib5;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB5 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6:
              //carrier->sib6 = &typeandinfo->choice.sib6;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB6 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7:
              //carrier->sib7 = &typeandinfo->choice.sib7;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB7 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8:
              //carrier->sib8 = &typeandinfo->choice.sib8;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB8 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9:
              //carrier->sib9 = &typeandinfo->choice.sib9;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB9 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10:
              //carrier->sib10 = &typeandinfo->choice.sib10;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB10 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11:
              //carrier->sib11 = &typeandinfo->choice.sib11;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB11 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920:
              //carrier->sib12 = &typeandinfo->choice.sib12;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB12 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920:
              carrier->sib13 = &typeandinfo->choice.sib13_v920;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB13 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            //SIB18
            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250:
              carrier->sib18 = &typeandinfo->choice.sib18_v1250;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB18 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            //SIB19
            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250:
              carrier->sib19 = &typeandinfo->choice.sib19_v1250;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB19 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            //SIB21
            case LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430:
              carrier->sib21 = &typeandinfo->choice.sib21_v1430;
              LOG_I( ENB_APP, "[RRC %"PRIu8"] Found SIB21 in CU F1AP_SETUP_RESP message\n", inst);
              break;

            default:
              AssertFatal(1==0,"Shouldn't have received this SI %d\n",typeandinfo->present);
              break;
          }
        }

        break;
3102
      }
frtabu's avatar
frtabu committed
3103

3104
      case LTE_BCCH_DL_SCH_MessageType__c1_PR_NOTHING:
3105 3106
        AssertFatal(0, "Should have received SIB1 from CU\n");
        break;
3107
    }
frtabu's avatar
frtabu committed
3108
  } else AssertFatal(1==0,"No SI messages\n");
3109 3110 3111 3112 3113
}

void configure_du_mac(int inst) {
  eNB_RRC_INST *rrc = RC.rrc[inst];
  rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0];
3114
  LOG_I(ENB_APP,"Configuring MAC/L1 %d, carrier->sib2 %p\n",inst,&carrier->sib2->radioResourceConfigCommon);
3115
  rrc_mac_config_req_eNB(inst, 0,
frtabu's avatar
frtabu committed
3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132
                         carrier->physCellId,
                         carrier->p_eNB,
                         carrier->Ncp,
                         carrier->sib1->freqBandIndicator,
                         carrier->dl_CarrierFreq,
                         carrier->pbch_repetition,
                         0, // rnti
                         (LTE_BCCH_BCH_Message_t *) &carrier->mib,
                         (LTE_RadioResourceConfigCommonSIB_t *) &carrier->sib2->radioResourceConfigCommon,
                         (LTE_RadioResourceConfigCommonSIB_t *) &carrier->sib2_BR->radioResourceConfigCommon,
                         (struct LTE_PhysicalConfigDedicated *)NULL,
                         (LTE_SCellToAddMod_r10_t *)NULL,
                         //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
                         (LTE_MeasObjectToAddMod_t **) NULL,
                         (LTE_MAC_MainConfig_t *) NULL, 0,
                         (struct LTE_LogicalChannelConfig *)NULL,
                         (LTE_MeasGapConfig_t *) NULL,
3133
                         carrier->sib1->tdd_Config,
frtabu's avatar
frtabu committed
3134 3135 3136 3137 3138
                         NULL,
                         &carrier->sib1->schedulingInfoList,
                         carrier->ul_CarrierFreq,
                         carrier->sib2->freqInfo.ul_Bandwidth,
                         &carrier->sib2->freqInfo.additionalSpectrumEmission,
3139
                         (LTE_MBSFN_SubframeConfigList_t *) carrier->sib2->mbsfn_SubframeConfigList,
frtabu's avatar
frtabu committed
3140 3141
                         carrier->MBMS_flag,
                         (LTE_MBSFN_AreaInfoList_r9_t *) & carrier->sib13->mbsfn_AreaInfoList_r9,
3142 3143 3144 3145 3146 3147 3148
                         (LTE_PMCH_InfoList_r9_t *) NULL,
                         NULL,
                         0,
                         (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL,
                         (LTE_SchedulingInfo_MBMS_r14_t *) NULL,
                         (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL,
                         (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL,
3149 3150
                         (LTE_MBSFN_AreaInfoList_r9_t *) NULL,
			 (LTE_MBSFNAreaConfiguration_r9_t*) NULL
frtabu's avatar
frtabu committed
3151
                        );
3152 3153
}

3154 3155
void handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) {
  int i,j,si_ind;
3156
  LOG_I(ENB_APP, "cells_to_activated %d, RRC instances %d\n",
frtabu's avatar
frtabu committed
3157 3158 3159 3160
        resp->num_cells_to_activate,RC.nb_inst);

  for (j=0; j<resp->num_cells_to_activate; j++) {
    for (i=0; i<RC.nb_inst; i++) {
3161
      rrc_eNB_carrier_data_t *carrier =  &RC.rrc[i]->carrier[0];
3162
      // identify local index of cell j by nr_cellid, plmn identity and physical cell ID
3163
      LOG_I(ENB_APP, "Checking cell %d, rrc inst %d : rrc->nr_cellid %lx, resp->nr_cellid %lx\n",
3164
            j,i,RC.rrc[i]->nr_cellid,resp->cells_to_activate[j].nr_cellid);
frtabu's avatar
frtabu committed
3165

3166 3167 3168
      if (RC.rrc[i]->nr_cellid == resp->cells_to_activate[j].nr_cellid &&
          (check_plmn_identity(carrier, resp->cells_to_activate[j].mcc, resp->cells_to_activate[j].mnc, resp->cells_to_activate[j].mnc_digit_length)>0 &&
           resp->cells_to_activate[j].nrpci == carrier->physCellId)) {
frtabu's avatar
frtabu committed
3169
        // copy system information and decode it
3170
        for (si_ind=2; si_ind<resp->cells_to_activate[j].num_SI; si_ind++)  {
3171 3172 3173 3174
          //printf("SI %d size %d: ", si_ind, resp->SI_container_length[j][si_ind]);
          //for (int n=0;n<resp->SI_container_length[j][si_ind];n++)
          //  printf("%02x ",resp->SI_container[j][si_ind][n]);
          //printf("\n");
Raymond Knopp's avatar
Raymond Knopp committed
3175
          if (si_ind==6) si_ind=9;
3176 3177
          if (resp->cells_to_activate[j].SI_container[si_ind] != NULL) {
            extract_and_decode_SI(i,
Raymond Knopp's avatar
Raymond Knopp committed
3178
                                  si_ind,
3179 3180
                                  resp->cells_to_activate[j].SI_container[si_ind],
                                  resp->cells_to_activate[j].SI_container_length[si_ind]);
Raymond Knopp's avatar
Raymond Knopp committed
3181
          }
3182

frtabu's avatar
frtabu committed
3183 3184 3185 3186
        }

        // perform MAC/L1 common configuration
        configure_du_mac(i);
3187 3188
      } else {
        LOG_E(ENB_APP, "F1 Setup Response not matching\n");
3189
      }
3190 3191
    }
  }
3192
}
3193

frtabu's avatar
frtabu committed
3194
void read_config_and_init(void) {
3195
  int macrlc_has_f1[MAX_MAC_INST];
frtabu's avatar
frtabu committed
3196
  memset(macrlc_has_f1, 0, MAX_MAC_INST*sizeof(int));
3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212

  if (RC.nb_macrlc_inst > 0)
    AssertFatal(RC.nb_macrlc_inst == RC.nb_inst,
                "Number of MACRLC instances %d != number of RRC instances %d\n",
                RC.nb_macrlc_inst, RC.nb_inst);

  RCconfig_L1();
  LOG_I(PHY, "%s() RC.nb_L1_inst: %d\n", __FUNCTION__, RC.nb_L1_inst);
  RCconfig_macrlc(macrlc_has_f1);
  LOG_I(MAC, "%s() RC.nb_macrlc_inst: %d\n", __FUNCTION__, RC.nb_macrlc_inst);

  if (RC.nb_L1_inst > 0)
    AssertFatal(l1_north_init_eNB() == 0, "could not initialize L1 north interface\n");

  RC.rrc = malloc(RC.nb_inst * sizeof(eNB_RRC_INST *));
  AssertFatal(RC.rrc, "could not allocate memory for RC.rrc\n");
frtabu's avatar
frtabu committed
3213

3214 3215
  for (uint32_t enb_id = 0; enb_id < RC.nb_inst; enb_id++) {
    RC.rrc[enb_id] = malloc(sizeof(eNB_RRC_INST));
frtabu's avatar
frtabu committed
3216
    AssertFatal(RC.rrc[enb_id], "RRC context for eNB %u not allocated\n", enb_id);
3217
    memset((void *)RC.rrc[enb_id], 0, sizeof(eNB_RRC_INST));
3218
    RCconfig_RRC(enb_id, RC.rrc[enb_id],macrlc_has_f1[enb_id]);
3219
  }
3220 3221

  RCconfig_flexran();
3222
}