Commit d16cbcc9 authored by winckel's avatar winckel

Reorganized eNB app code to have less global variables.

Added PHY configuration message sent to all eNB.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4999 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent e2586fc4
...@@ -60,63 +60,56 @@ extern char *g_conf_config_file_name; ...@@ -60,63 +60,56 @@ extern char *g_conf_config_file_name;
# endif # endif
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
# if defined(ENABLE_USE_MME) static Enb_properties_t *enb_properties[MAX_ENB];
static uint32_t enb_nb = 1; /* Default number of eNB */ static int enb_nb_properties;
# endif
/*------------------------------------------------------------------------------*/
static void configure_phy(uint32_t enb_id)
{
MessageDef *msg_p;
msg_p = itti_alloc_new_message (TASK_ENB_APP, PHY_CONFIGURATION_REQ);
PHY_CONFIGURATION_REQ (msg_p).frame_type = enb_properties[enb_id]->frame_type;
PHY_CONFIGURATION_REQ (msg_p).prefix_type = enb_properties[enb_id]->prefix_type;
PHY_CONFIGURATION_REQ (msg_p).downlink_frequency = enb_properties[enb_id]->downlink_frequency;
PHY_CONFIGURATION_REQ (msg_p).uplink_frequency_offset = enb_properties[enb_id]->uplink_frequency_offset;
extern Enb_properties_t *g_enb_properties[]; itti_send_msg_to_task (TASK_PHY_ENB, enb_id, msg_p);
extern int g_num_enb_properties; }
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
static void configure_rrc(void) static void configure_rrc(uint32_t enb_id)
{ {
uint32_t eNB_id_start = 0;
uint32_t eNB_id_end = 1;
uint32_t eNB_id;
MessageDef *msg_p; MessageDef *msg_p;
# if defined(OAI_EMU)
eNB_id_start = oai_emulation.info.first_enb_local;
eNB_id_end = oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local;
# endif
for (eNB_id = eNB_id_start; (eNB_id < eNB_id_end) ; eNB_id++)
{
msg_p = itti_alloc_new_message (TASK_ENB_APP, RRC_CONFIGURATION_REQ); msg_p = itti_alloc_new_message (TASK_ENB_APP, RRC_CONFIGURATION_REQ);
RRC_CONFIGURATION_REQ (msg_p).cell_identity = g_enb_properties[eNB_id]->eNB_id; RRC_CONFIGURATION_REQ (msg_p).cell_identity = enb_properties[enb_id]->eNB_id;
RRC_CONFIGURATION_REQ (msg_p).tac = g_enb_properties[eNB_id]->tac; RRC_CONFIGURATION_REQ (msg_p).tac = enb_properties[enb_id]->tac;
RRC_CONFIGURATION_REQ (msg_p).mcc = g_enb_properties[eNB_id]->mcc; RRC_CONFIGURATION_REQ (msg_p).mcc = enb_properties[enb_id]->mcc;
RRC_CONFIGURATION_REQ (msg_p).mnc = g_enb_properties[eNB_id]->mnc; RRC_CONFIGURATION_REQ (msg_p).mnc = enb_properties[enb_id]->mnc;
itti_send_msg_to_task (TASK_RRC_ENB, eNB_id, msg_p); itti_send_msg_to_task (TASK_RRC_ENB, enb_id, msg_p);
}
} }
/*------------------------------------------------------------------------------*/
# if defined(ENABLE_USE_MME) # if defined(ENABLE_USE_MME)
static uint32_t eNB_app_register() static uint32_t eNB_app_register(uint32_t enb_id_start, uint32_t enb_id_end)
{ {
uint32_t eNB_id_start = 0; uint32_t enb_id;
uint32_t eNB_id_end = 1;
uint32_t eNB_id;
uint32_t mme_id; uint32_t mme_id;
MessageDef *msg_p; MessageDef *msg_p;
uint32_t register_enb_pending = 0; uint32_t register_enb_pending = 0;
# if defined(OAI_EMU) # if defined(OAI_EMU)
eNB_id_start = oai_emulation.info.first_enb_local;
eNB_id_end = oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local;
DevCheck(eNB_id_end <= NUMBER_OF_eNB_MAX, eNB_id_end, NUMBER_OF_eNB_MAX, 0);
# endif # endif
//DevCheck(eNB_id_end <= (sizeof(g_enb_properties) / sizeof(g_enb_properties[0])), eNB_id_end, (sizeof(g_enb_properties) / sizeof(g_enb_properties[0])), 0);
DevCheck((eNB_id_end - eNB_id_start) == g_num_enb_properties, eNB_id_end - eNB_id_start, g_num_enb_properties, 0);
for (eNB_id = eNB_id_start; (eNB_id < eNB_id_end) ; eNB_id++) for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++)
{ {
# if defined(OAI_EMU) # if defined(OAI_EMU)
if (oai_emulation.info.cli_start_enb[eNB_id] == 1) if (oai_emulation.info.cli_start_enb[enb_id] == 1)
# endif # endif
{ {
s1ap_register_enb_req_t *s1ap_register_eNB; s1ap_register_enb_req_t *s1ap_register_eNB;
...@@ -124,7 +117,7 @@ static uint32_t eNB_app_register() ...@@ -124,7 +117,7 @@ static uint32_t eNB_app_register()
/* Overwrite default eNB ID */ /* Overwrite default eNB ID */
hash = s1ap_generate_eNB_id (); hash = s1ap_generate_eNB_id ();
g_enb_properties[eNB_id]->eNB_id = eNB_id + (hash & 0xFFFF8); enb_properties[enb_id]->eNB_id = enb_id + (hash & 0xFFFF8);
/* note: there is an implicit relationship between the data structure and the message name */ /* note: there is an implicit relationship between the data structure and the message name */
msg_p = itti_alloc_new_message (TASK_ENB_APP, S1AP_REGISTER_ENB_REQ); msg_p = itti_alloc_new_message (TASK_ENB_APP, S1AP_REGISTER_ENB_REQ);
...@@ -132,30 +125,30 @@ static uint32_t eNB_app_register() ...@@ -132,30 +125,30 @@ static uint32_t eNB_app_register()
s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p); s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p);
/* Some default/random parameters */ /* Some default/random parameters */
s1ap_register_eNB->eNB_id = g_enb_properties[eNB_id]->eNB_id; s1ap_register_eNB->eNB_id = enb_properties[enb_id]->eNB_id;
s1ap_register_eNB->cell_type = g_enb_properties[eNB_id]->cell_type; s1ap_register_eNB->cell_type = enb_properties[enb_id]->cell_type;
s1ap_register_eNB->eNB_name = g_enb_properties[eNB_id]->eNB_name; s1ap_register_eNB->eNB_name = enb_properties[enb_id]->eNB_name;
s1ap_register_eNB->tac = g_enb_properties[eNB_id]->tac; s1ap_register_eNB->tac = enb_properties[enb_id]->tac;
s1ap_register_eNB->mcc = g_enb_properties[eNB_id]->mcc; s1ap_register_eNB->mcc = enb_properties[enb_id]->mcc;
s1ap_register_eNB->mnc = g_enb_properties[eNB_id]->mnc; s1ap_register_eNB->mnc = enb_properties[enb_id]->mnc;
s1ap_register_eNB->default_drx = g_enb_properties[eNB_id]->default_drx; s1ap_register_eNB->default_drx = enb_properties[enb_id]->default_drx;
s1ap_register_eNB->nb_mme = g_enb_properties[eNB_id]->nb_mme; s1ap_register_eNB->nb_mme = enb_properties[enb_id]->nb_mme;
DevCheck(s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS, eNB_id, s1ap_register_eNB->nb_mme, S1AP_MAX_NB_MME_IP_ADDRESS); AssertFatal (s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS, "Too many MME for eNB %d (%d/%d)!", enb_id, s1ap_register_eNB->nb_mme, S1AP_MAX_NB_MME_IP_ADDRESS);
for (mme_id = 0; mme_id < s1ap_register_eNB->nb_mme; mme_id++) for (mme_id = 0; mme_id < s1ap_register_eNB->nb_mme; mme_id++)
{ {
s1ap_register_eNB->mme_ip_address[mme_id].ipv4 = g_enb_properties[eNB_id]->mme_ip_address[mme_id].ipv4; s1ap_register_eNB->mme_ip_address[mme_id].ipv4 = enb_properties[enb_id]->mme_ip_address[mme_id].ipv4;
s1ap_register_eNB->mme_ip_address[mme_id].ipv6 = g_enb_properties[eNB_id]->mme_ip_address[mme_id].ipv6; s1ap_register_eNB->mme_ip_address[mme_id].ipv6 = enb_properties[enb_id]->mme_ip_address[mme_id].ipv6;
strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv4_address, strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv4_address,
g_enb_properties[eNB_id]->mme_ip_address[mme_id].ipv4_address, enb_properties[enb_id]->mme_ip_address[mme_id].ipv4_address,
sizeof(s1ap_register_eNB->mme_ip_address[0].ipv4_address)); sizeof(s1ap_register_eNB->mme_ip_address[0].ipv4_address));
strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv6_address, strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv6_address,
g_enb_properties[eNB_id]->mme_ip_address[mme_id].ipv6_address, enb_properties[enb_id]->mme_ip_address[mme_id].ipv6_address,
sizeof(s1ap_register_eNB->mme_ip_address[0].ipv6_address)); sizeof(s1ap_register_eNB->mme_ip_address[0].ipv6_address));
} }
itti_send_msg_to_task (TASK_S1AP, eNB_id, msg_p); itti_send_msg_to_task (TASK_S1AP, enb_id, msg_p);
register_enb_pending++; register_enb_pending++;
} }
...@@ -170,11 +163,15 @@ static uint32_t eNB_app_register() ...@@ -170,11 +163,15 @@ static uint32_t eNB_app_register()
void *eNB_app_task(void *args_p) void *eNB_app_task(void *args_p)
{ {
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
uint32_t enb_nb = 1; /* Default number of eNB is 1 */
uint32_t enb_id_start = 0;
uint32_t enb_id_end = enb_id_start + enb_nb;
# if defined(ENABLE_USE_MME) # if defined(ENABLE_USE_MME)
static uint32_t register_enb_pending; uint32_t register_enb_pending;
static uint32_t registered_enb; uint32_t registered_enb;
static long enb_register_retry_timer_id; long enb_register_retry_timer_id;
# endif # endif
uint32_t enb_id;
MessageDef *msg_p; MessageDef *msg_p;
const char *msg_name; const char *msg_name;
instance_t instance; instance_t instance;
...@@ -185,16 +182,31 @@ void *eNB_app_task(void *args_p) ...@@ -185,16 +182,31 @@ void *eNB_app_task(void *args_p)
# if defined(ENABLE_USE_MME) # if defined(ENABLE_USE_MME)
# if defined(OAI_EMU) # if defined(OAI_EMU)
enb_nb = oai_emulation.info.nb_enb_local; enb_nb = oai_emulation.info.nb_enb_local;
enb_id_start = oai_emulation.info.first_enb_local;
enb_id_end = oai_emulation.info.first_enb_local + enb_nb;
AssertFatal (enb_id_end <= NUMBER_OF_eNB_MAX,
"Last eNB index is greater or equal to maximum eNB index (%d/%d)!",
enb_id_end, NUMBER_OF_eNB_MAX);
# endif # endif
# endif # endif
enb_config_init(g_conf_config_file_name);
configure_rrc(); enb_nb_properties = enb_config_init(g_conf_config_file_name, enb_properties);
AssertFatal (enb_nb <= enb_nb_properties,
"Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!",
g_conf_config_file_name, enb_nb, enb_nb_properties);
for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++)
{
configure_phy(enb_id);
configure_rrc(enb_id);
}
# if defined(ENABLE_USE_MME) # if defined(ENABLE_USE_MME)
/* Try to register each eNB */ /* Try to register each eNB */
registered_enb = 0; registered_enb = 0;
register_enb_pending = eNB_app_register (); register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);
# else # else
/* Start L2L1 task */ /* Start L2L1 task */
msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE); msg_p = itti_alloc_new_message(TASK_ENB_APP, INITIALIZE_MESSAGE);
...@@ -245,7 +257,7 @@ void *eNB_app_task(void *args_p) ...@@ -245,7 +257,7 @@ void *eNB_app_task(void *args_p)
itti_send_msg_to_task (TASK_L2L1, INSTANCE_DEFAULT, msg_init_p); itti_send_msg_to_task (TASK_L2L1, INSTANCE_DEFAULT, msg_init_p);
# if defined(OAI_EMU) # if defined(OAI_EMU)
/* If also inform all NAS UE tasks */ /* Also inform all NAS UE tasks */
for (instance = NB_eNB_INST + oai_emulation.info.first_ue_local; for (instance = NB_eNB_INST + oai_emulation.info.first_ue_local;
instance < (NB_eNB_INST + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); instance ++) instance < (NB_eNB_INST + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); instance ++)
{ {
...@@ -270,7 +282,7 @@ void *eNB_app_task(void *args_p) ...@@ -270,7 +282,7 @@ void *eNB_app_task(void *args_p)
sleep(ENB_REGISTER_RETRY_DELAY); sleep(ENB_REGISTER_RETRY_DELAY);
/* Restart the registration process */ /* Restart the registration process */
registered_enb = 0; registered_enb = 0;
register_enb_pending = eNB_app_register (); register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);
} }
} }
} }
...@@ -290,7 +302,7 @@ void *eNB_app_task(void *args_p) ...@@ -290,7 +302,7 @@ void *eNB_app_task(void *args_p)
{ {
/* Restart the registration process */ /* Restart the registration process */
registered_enb = 0; registered_enb = 0;
register_enb_pending = eNB_app_register (); register_enb_pending = eNB_app_register (enb_id_start, enb_id_end);
} }
break; break;
# endif # endif
......
...@@ -48,19 +48,20 @@ ...@@ -48,19 +48,20 @@
#include "LAYER2/MAC/extern.h" #include "LAYER2/MAC/extern.h"
// Hard to find a defined value for max enb... int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_properties) {
#define MAX_ENB 16
Enb_properties_t *g_enb_properties[MAX_ENB];
int g_num_enb_properties = 0;
int enb_config_init(char* lib_config_file_name_pP) {
config_t cfg; config_t cfg;
config_setting_t *setting; config_setting_t *setting;
config_setting_t *setting_mme_addresses; config_setting_t *setting_mme_addresses;
config_setting_t *setting_mme_address; config_setting_t *setting_mme_address;
config_setting_t *setting_enb; config_setting_t *setting_enb;
int num_enbs, num_mme_address, i, j, parse_error = 0, enb_properties_index; int num_enb_properties = 0;
int enb_properties_index = 0;
int num_enbs;
int num_mme_address;
int i;
int j;
int parse_error = 0;
long int enb_id; long int enb_id;
const char* cell_type; const char* cell_type;
long int tac; long int tac;
...@@ -78,8 +79,7 @@ int enb_config_init(char* lib_config_file_name_pP) { ...@@ -78,8 +79,7 @@ int enb_config_init(char* lib_config_file_name_pP) {
char* preference; char* preference;
const char* active_enb[MAX_ENB]; const char* active_enb[MAX_ENB];
memset((char*)enb_properties, 0 , MAX_ENB * sizeof(Enb_properties_t*));
memset((char*)g_enb_properties, 0 , MAX_ENB * sizeof(Enb_properties_t*));
memset((char*)active_enb, 0 , MAX_ENB * sizeof(char*)); memset((char*)active_enb, 0 , MAX_ENB * sizeof(char*));
config_init(&cfg); config_init(&cfg);
...@@ -102,7 +102,6 @@ int enb_config_init(char* lib_config_file_name_pP) { ...@@ -102,7 +102,6 @@ int enb_config_init(char* lib_config_file_name_pP) {
} }
// Get list of active eNBs, (only these will be configured) // Get list of active eNBs, (only these will be configured)
g_num_enb_properties = 0;
setting = config_lookup(&cfg, ENB_CONFIG_STRING_ACTIVE_ENBS); setting = config_lookup(&cfg, ENB_CONFIG_STRING_ACTIVE_ENBS);
if(setting != NULL) if(setting != NULL)
{ {
...@@ -114,7 +113,7 @@ int enb_config_init(char* lib_config_file_name_pP) { ...@@ -114,7 +113,7 @@ int enb_config_init(char* lib_config_file_name_pP) {
"Failed to parse config file %s, %uth attribute %s \n", "Failed to parse config file %s, %uth attribute %s \n",
lib_config_file_name_pP, i, ENB_CONFIG_STRING_ACTIVE_ENBS); lib_config_file_name_pP, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
active_enb[i] = strdup(active_enb[i]); active_enb[i] = strdup(active_enb[i]);
g_num_enb_properties += 1; num_enb_properties += 1;
} }
} }
...@@ -142,33 +141,33 @@ int enb_config_init(char* lib_config_file_name_pP) { ...@@ -142,33 +141,33 @@ int enb_config_init(char* lib_config_file_name_pP) {
lib_config_file_name_pP, i); lib_config_file_name_pP, i);
} }
// search if in active list // search if in active list
for (j=0; j < g_num_enb_properties; j++) { for (j=0; j < num_enb_properties; j++) {
if (strcmp(active_enb[j], enb_name) == 0) { if (strcmp(active_enb[j], enb_name) == 0) {
g_enb_properties[enb_properties_index] = calloc(1, sizeof(Enb_properties_t)); enb_properties[enb_properties_index] = calloc(1, sizeof(Enb_properties_t));
g_enb_properties[enb_properties_index]->eNB_id = enb_id; enb_properties[enb_properties_index]->eNB_id = enb_id;
if (strcmp(cell_type, "CELL_MACRO_ENB") == 0) { if (strcmp(cell_type, "CELL_MACRO_ENB") == 0) {
g_enb_properties[enb_properties_index]->cell_type = CELL_MACRO_ENB; enb_properties[enb_properties_index]->cell_type = CELL_MACRO_ENB;
} else if (strcmp(cell_type, "CELL_HOME_ENB") == 0) { } else if (strcmp(cell_type, "CELL_HOME_ENB") == 0) {
g_enb_properties[enb_properties_index]->cell_type = CELL_HOME_ENB; enb_properties[enb_properties_index]->cell_type = CELL_HOME_ENB;
} else { } else {
AssertError (0, parse_error ++, AssertError (0, parse_error ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
lib_config_file_name_pP, i, cell_type); lib_config_file_name_pP, i, cell_type);
} }
g_enb_properties[enb_properties_index]->eNB_name = strdup(enb_name); enb_properties[enb_properties_index]->eNB_name = strdup(enb_name);
g_enb_properties[enb_properties_index]->tac = (uint16_t)tac; enb_properties[enb_properties_index]->tac = (uint16_t)tac;
g_enb_properties[enb_properties_index]->mcc = (uint16_t)mcc; enb_properties[enb_properties_index]->mcc = (uint16_t)mcc;
g_enb_properties[enb_properties_index]->mnc = (uint16_t)mnc; enb_properties[enb_properties_index]->mnc = (uint16_t)mnc;
if (strcmp(default_drx, "PAGING_DRX_32") == 0) { if (strcmp(default_drx, "PAGING_DRX_32") == 0) {
g_enb_properties[enb_properties_index]->default_drx = PAGING_DRX_32; enb_properties[enb_properties_index]->default_drx = PAGING_DRX_32;
} else if (strcmp(default_drx, "PAGING_DRX_64") == 0) { } else if (strcmp(default_drx, "PAGING_DRX_64") == 0) {
g_enb_properties[enb_properties_index]->default_drx = PAGING_DRX_64; enb_properties[enb_properties_index]->default_drx = PAGING_DRX_64;
} else if (strcmp(default_drx, "PAGING_DRX_128") == 0) { } else if (strcmp(default_drx, "PAGING_DRX_128") == 0) {
g_enb_properties[enb_properties_index]->default_drx = PAGING_DRX_128; enb_properties[enb_properties_index]->default_drx = PAGING_DRX_128;
} else if (strcmp(default_drx, "PAGING_DRX_256") == 0) { } else if (strcmp(default_drx, "PAGING_DRX_256") == 0) {
g_enb_properties[enb_properties_index]->default_drx = PAGING_DRX_256; enb_properties[enb_properties_index]->default_drx = PAGING_DRX_256;
} else { } else {
AssertError (0, parse_error ++, AssertError (0, parse_error ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for default_drx choice: PAGING_DRX_32..PAGING_DRX_256 !\n", "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for default_drx choice: PAGING_DRX_32..PAGING_DRX_256 !\n",
...@@ -178,47 +177,47 @@ int enb_config_init(char* lib_config_file_name_pP) { ...@@ -178,47 +177,47 @@ int enb_config_init(char* lib_config_file_name_pP) {
// Parse optional physical parameters // Parse optional physical parameters
if(config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_FRAME_TYPE, &frame_type)) { if(config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_FRAME_TYPE, &frame_type)) {
if (strcmp(frame_type, "FDD") == 0) { if (strcmp(frame_type, "FDD") == 0) {
g_enb_properties[enb_properties_index]->frame_type = FDD; enb_properties[enb_properties_index]->frame_type = FDD;
} else if (strcmp(frame_type, "TDD") == 0) { } else if (strcmp(frame_type, "TDD") == 0) {
g_enb_properties[enb_properties_index]->frame_type = TDD; enb_properties[enb_properties_index]->frame_type = TDD;
} else { } else {
AssertError (0, parse_error ++, AssertError (0, parse_error ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n", "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
lib_config_file_name_pP, i, frame_type); lib_config_file_name_pP, i, frame_type);
} }
} else { } else {
g_enb_properties[enb_properties_index]->frame_type = FDD; // Default frame type enb_properties[enb_properties_index]->frame_type = FDD; // Default frame type
} }
if(config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_PREFIX_TYPE, &prefix_type)) { if(config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_PREFIX_TYPE, &prefix_type)) {
if (strcmp(prefix_type, "NORMAL") == 0) { if (strcmp(prefix_type, "NORMAL") == 0) {
g_enb_properties[enb_properties_index]->prefix_type = NORMAL; enb_properties[enb_properties_index]->prefix_type = NORMAL;
} else if (strcmp(prefix_type, "EXTENDED") == 0) { } else if (strcmp(prefix_type, "EXTENDED") == 0) {
g_enb_properties[enb_properties_index]->prefix_type = EXTENDED; enb_properties[enb_properties_index]->prefix_type = EXTENDED;
} else { } else {
AssertError (0, parse_error ++, AssertError (0, parse_error ++,
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n", "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
lib_config_file_name_pP, i, prefix_type); lib_config_file_name_pP, i, prefix_type);
} }
} else { } else {
g_enb_properties[enb_properties_index]->prefix_type = NORMAL; // Default prefix type enb_properties[enb_properties_index]->prefix_type = NORMAL; // Default prefix type
} }
if(config_setting_lookup_int64(setting_enb, ENB_CONFIG_STRING_DOWNLINK_FREQUENCY, &downlink_frequency)) { if(config_setting_lookup_int64(setting_enb, ENB_CONFIG_STRING_DOWNLINK_FREQUENCY, &downlink_frequency)) {
g_enb_properties[enb_properties_index]->downlink_frequency = downlink_frequency; enb_properties[enb_properties_index]->downlink_frequency = downlink_frequency;
} else { } else {
g_enb_properties[enb_properties_index]->downlink_frequency = 2680000000UL; // Default downlink frequency enb_properties[enb_properties_index]->downlink_frequency = 2680000000UL; // Default downlink frequency
} }
if(config_setting_lookup_int(setting_enb, ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET, &uplink_frequency_offset)) { if(config_setting_lookup_int(setting_enb, ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET, &uplink_frequency_offset)) {
g_enb_properties[enb_properties_index]->uplink_frequency_offset = uplink_frequency_offset; enb_properties[enb_properties_index]->uplink_frequency_offset = uplink_frequency_offset;
} else { } else {
g_enb_properties[enb_properties_index]->uplink_frequency_offset = -120000000; // Default uplink frequency offset enb_properties[enb_properties_index]->uplink_frequency_offset = -120000000; // Default uplink frequency offset
} }
setting_mme_addresses = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_MME_IP_ADDRESS); setting_mme_addresses = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_MME_IP_ADDRESS);
num_mme_address = config_setting_length(setting_mme_addresses); num_mme_address = config_setting_length(setting_mme_addresses);
g_enb_properties[enb_properties_index]->nb_mme = 0; enb_properties[enb_properties_index]->nb_mme = 0;
for (j = 0; j < num_mme_address; j++) { for (j = 0; j < num_mme_address; j++) {
setting_mme_address = config_setting_get_elem(setting_mme_addresses, j); setting_mme_address = config_setting_get_elem(setting_mme_addresses, j);
if( !( if( !(
...@@ -232,24 +231,24 @@ int enb_config_init(char* lib_config_file_name_pP) { ...@@ -232,24 +231,24 @@ int enb_config_init(char* lib_config_file_name_pP) {
"Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n", "Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n",
lib_config_file_name_pP, i, j); lib_config_file_name_pP, i, j);
} }
g_enb_properties[enb_properties_index]->nb_mme += 1; enb_properties[enb_properties_index]->nb_mme += 1;
g_enb_properties[enb_properties_index]->mme_ip_address[j].ipv4_address = strdup(ipv4); enb_properties[enb_properties_index]->mme_ip_address[j].ipv4_address = strdup(ipv4);
g_enb_properties[enb_properties_index]->mme_ip_address[j].ipv6_address = strdup(ipv6); enb_properties[enb_properties_index]->mme_ip_address[j].ipv6_address = strdup(ipv6);
if (strcmp(active, "yes") == 0) { if (strcmp(active, "yes") == 0) {
g_enb_properties[enb_properties_index]->mme_ip_address[j].active = 1; enb_properties[enb_properties_index]->mme_ip_address[j].active = 1;
#if defined(ENABLE_USE_MME) #if defined(ENABLE_USE_MME)
EPC_MODE_ENABLED = 1; EPC_MODE_ENABLED = 1;
#endif #endif
} // else { (calloc) } // else { (calloc)
if (strcmp(preference, "ipv4") == 0) { if (strcmp(preference, "ipv4") == 0) {
g_enb_properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1; enb_properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
} else if (strcmp(preference, "ipv6") == 0) { } else if (strcmp(preference, "ipv6") == 0) {
g_enb_properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1; enb_properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
} else if (strcmp(preference, "no") == 0) { } else if (strcmp(preference, "no") == 0) {
g_enb_properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1; enb_properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
g_enb_properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1; enb_properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
} }
} }
enb_properties_index += 1; enb_properties_index += 1;
...@@ -258,12 +257,12 @@ int enb_config_init(char* lib_config_file_name_pP) { ...@@ -258,12 +257,12 @@ int enb_config_init(char* lib_config_file_name_pP) {
} }
} }
} }
AssertError (enb_properties_index == g_num_enb_properties, parse_error ++, AssertError (enb_properties_index == num_enb_properties, parse_error ++,
"Failed to parse eNB configuration file %s, mismatch between %u active eNBs and %u corresponding defined eNBs !\n", "Failed to parse eNB configuration file %s, mismatch between %u active eNBs and %u corresponding defined eNBs !\n",
lib_config_file_name_pP, g_num_enb_properties, enb_properties_index); lib_config_file_name_pP, num_enb_properties, enb_properties_index);
AssertFatal (parse_error == 0, AssertFatal (parse_error == 0,
"Failed to parse eNB configuration file %s, found %d error%s !\n", "Failed to parse eNB configuration file %s, found %d error%s !\n",
lib_config_file_name_pP, parse_error, parse_error > 1 ? "s" : ""); lib_config_file_name_pP, parse_error, parse_error > 1 ? "s" : "");
return 0; return num_enb_properties;
} }
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
#include "PHY/impl_defs_lte.h" #include "PHY/impl_defs_lte.h"
#include "s1ap_messages_types.h" #include "s1ap_messages_types.h"
// Hard to find a defined value for max enb...
#define MAX_ENB 16
#define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR,NwBo,MeSsAgE ) do {\ #define IPV4_STR_ADDR_TO_INT_NWBO(AdDr_StR,NwBo,MeSsAgE ) do {\
struct in_addr inp;\ struct in_addr inp;\
if ( inet_aton(AdDr_StR, &inp ) < 0 ) {\ if ( inet_aton(AdDr_StR, &inp ) < 0 ) {\
...@@ -43,6 +46,7 @@ ...@@ -43,6 +46,7 @@
NwBo = inp.s_addr;\ NwBo = inp.s_addr;\
}\ }\
} while (0); } while (0);
#define ENB_CONFIG_STRING_ACTIVE_ENBS "Active_eNBs" #define ENB_CONFIG_STRING_ACTIVE_ENBS "Active_eNBs"
#define ENB_CONFIG_STRING_ENB_LIST "eNBs" #define ENB_CONFIG_STRING_ENB_LIST "eNBs"
...@@ -72,6 +76,7 @@ ...@@ -72,6 +76,7 @@
#define ENB_CONFIG_STRING_ENB_IPV4_ADDRESS_FOR_S1_MME "ENB_IPV4_ADDRESS_FOR_S1_MME" #define ENB_CONFIG_STRING_ENB_IPV4_ADDRESS_FOR_S1_MME "ENB_IPV4_ADDRESS_FOR_S1_MME"
#define ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1U "ENB_INTERFACE_NAME_FOR_S1U" #define ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1U "ENB_INTERFACE_NAME_FOR_S1U"
#define ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U "ENB_IPV4_ADDRESS_FOR_S1U" #define ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U "ENB_IPV4_ADDRESS_FOR_S1U"
typedef struct mme_ip_address_s { typedef struct mme_ip_address_s {
unsigned ipv4:1; unsigned ipv4:1;
unsigned ipv6:1; unsigned ipv6:1;
...@@ -127,7 +132,6 @@ typedef struct Enb_properties_s { ...@@ -127,7 +132,6 @@ typedef struct Enb_properties_s {
} Enb_properties_t; } Enb_properties_t;
int enb_config_init(char* lib_config_file_name_pP, Enb_properties_t **enb_properties);
int enb_config_init(char* lib_config_file_name_pP);
#endif /* ENB_CONFIG_H_ */ #endif /* ENB_CONFIG_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment