Commit 83bedef3 authored by frtabu's avatar frtabu

Allow build mode selection in build_oai (release, Debug, etc) using the -g...

Allow build mode selection in build_oai (release, Debug, etc) using the -g option. Fix some new warnings when building in Release mode. Modify default (no -g specified) to build Release version
parent 6260936e
...@@ -127,7 +127,7 @@ endfunction() ...@@ -127,7 +127,7 @@ endfunction()
#set(CMAKE_BUILD_TYPE "Debug") #set(CMAKE_BUILD_TYPE "Debug")
if (CMAKE_BUILD_TYPE STREQUAL "") if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "RelWithDebInfo") set(CMAKE_BUILD_TYPE "Release")
endif() endif()
message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}") message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
add_list_string_option(CMAKE_BUILD_TYPE "RelWithDebInfo" "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." Debug Release RelWithDebInfo MinSizeRel) add_list_string_option(CMAKE_BUILD_TYPE "RelWithDebInfo" "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." Debug Release RelWithDebInfo MinSizeRel)
...@@ -330,14 +330,14 @@ add_custom_target ( ...@@ -330,14 +330,14 @@ add_custom_target (
${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" "NR_" "-findirect-choice" ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" "NR_" "-findirect-choice"
DEPENDS ${NR_RRC_GRAMMAR} DEPENDS ${NR_RRC_GRAMMAR}
) )
# remove warnings in code generated by asn1c
set_property(SOURCE ${nr_rrc_source} PROPERTY COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-but-set-variable")
add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source} add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source}
${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c
) )
add_dependencies(NR_RRC_LIB nr_rrc_flag) add_dependencies(NR_RRC_LIB nr_rrc_flag)
include_directories ("${NR_RRC_FULL_DIR}") include_directories ("${NR_RRC_FULL_DIR}")
# S1AP # S1AP
# Same limitation as described in RRC: unknown generated file list # Same limitation as described in RRC: unknown generated file list
# so we generate it at cmake time # so we generate it at cmake time
...@@ -371,6 +371,8 @@ add_library(S1AP_LIB ...@@ -371,6 +371,8 @@ add_library(S1AP_LIB
${S1AP_DIR}/s1ap_common.c ${S1AP_DIR}/s1ap_common.c
) )
add_dependencies(S1AP_LIB rrc_flag s1ap_flag) add_dependencies(S1AP_LIB rrc_flag s1ap_flag)
# remove warnings in code generated by asn1c
target_compile_options(S1AP_LIB PUBLIC -Wno-unused-variable -Wno-unused-but-set-variable)
include_directories ("${S1AP_C_DIR}") include_directories ("${S1AP_C_DIR}")
include_directories ("${S1AP_DIR}") include_directories ("${S1AP_DIR}")
...@@ -424,6 +426,8 @@ add_library(X2AP_LIB ...@@ -424,6 +426,8 @@ add_library(X2AP_LIB
${X2AP_DIR}/x2ap_common.c ${X2AP_DIR}/x2ap_common.c
) )
add_dependencies(X2AP_LIB rrc_flag x2_flag) add_dependencies(X2AP_LIB rrc_flag x2_flag)
# remove warnings in code generated by asn1c
target_compile_options(X2AP_LIB PUBLIC -Wno-unused-variable -Wno-unused-but-set-variable)
include_directories ("${X2AP_C_DIR}") include_directories ("${X2AP_C_DIR}")
include_directories ("${X2AP_DIR}") include_directories ("${X2AP_DIR}")
...@@ -447,7 +451,7 @@ add_dependencies(X2AP_ENB rrc_flag x2_flag) ...@@ -447,7 +451,7 @@ add_dependencies(X2AP_ENB rrc_flag x2_flag)
add_list1_option(F1AP_RELEASE R15 "F1AP ASN.1 grammar version" R15) add_list1_option(F1AP_RELEASE R15 "F1AP ASN.1 grammar version" R15)
set(F1AP_DIR ${OPENAIR2_DIR}/F1AP) set(F1AP_DIR ${OPENAIR2_DIR}/F1AP)
if (${F1AP_RELEASE} STREQUAL "R15") if (${F1AP_RELEASE} STREQUAL "R15")
make_version(F1AP_VERSION 15 2 1) make_version(_VERSION 15 2 1)
set (ASN1RELDIR R15.2.1) set (ASN1RELDIR R15.2.1)
endif(${F1AP_RELEASE} STREQUAL "R15") endif(${F1AP_RELEASE} STREQUAL "R15")
add_definitions(-DF1AP_VERSION=${F1AP_VERSION}) add_definitions(-DF1AP_VERSION=${F1AP_VERSION})
...@@ -477,7 +481,8 @@ file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c) ...@@ -477,7 +481,8 @@ file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c)
add_library(F1AP_LIB add_library(F1AP_LIB
${F1AP_ASN_GENERATED_C_FILES} ${F1AP_ASN_GENERATED_C_FILES}
) )
# remove warnings in code generated by asn1c
target_compile_options(F1AP_LIB PUBLIC -Wno-unused-variable -Wno-unused-but-set-variable)
include_directories ("${F1AP_ASN_GENERATED_C_DIR}") include_directories ("${F1AP_ASN_GENERATED_C_DIR}")
include_directories ("${F1AP_DIR}") include_directories ("${F1AP_DIR}")
......
...@@ -91,8 +91,11 @@ Options ...@@ -91,8 +91,11 @@ Options
-i | --install-system-files -i | --install-system-files
Install OpenAirInterface required files in Linux system Install OpenAirInterface required files in Linux system
This option will require root password This option will require root password
-g | --run-with-gdb -g | --run-with-gdb <Release | RelWithDebInfo | MinSizeRel | Debug
Add debugging symbols to compilation directives. It also disables any compiler optimization. Only for debugging. Do not use in normal operation! specify the build mode used by cmake. defaults to Debug mode if -g is used alone, with no mode parameter
if -g is not specifies, Release mode is used.
-G | --cmaketrace
enable cmake debugging messages
--eNB --eNB
Makes the LTE softmodem Makes the LTE softmodem
--gNB --gNB
...@@ -192,12 +195,43 @@ function main() { ...@@ -192,12 +195,43 @@ function main() {
INSTALL_SYSTEM_FILES=1 INSTALL_SYSTEM_FILES=1
echo_info "Will copy OpenAirInterface files in Linux directories" echo_info "Will copy OpenAirInterface files in Linux directories"
shift;; shift;;
-g | --run-with-gdb) -g | --run-with-gdb)
GDB=1 case "$2" in
CMAKE_BUILD_TYPE="Debug" "Release")
echo_info "Will Compile with gdb symbols and disable compiler optimization" GDB=0
CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Debug --trace-expand" CMAKE_BUILD_TYPE="Release"
echo_info "Will Compile without gdb symbols and with compiler optimization"
CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Release"
shift
;;
"RelWithDebInfo")
GDB=0
CMAKE_BUILD_TYPE="RelWithDebInfo"
echo_info "Will Compile with gdb symbols"
CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=RelWithDebInfo"
shift
;;
"MinSizeRel")
GDB=0
CMAKE_BUILD_TYPE="MinSizeRel"
echo_info "Will Compile for minimal exec size"
CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=MinSizeRel"
shift
;;
"Debug" | *)
GDB=1
CMAKE_BUILD_TYPE="Debug"
echo_info "Will Compile with gdb symbols and disable compiler optimization"
CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Debug"
if [ "$1" == "Debug" ] ; then
shift
fi
;;
esac
shift;; shift;;
-G | --cmaketrace)
CMAKE_CMD="$CMAKE_CMD --trace-expand"
shift;;
--eNB) --eNB)
eNB=1 eNB=1
echo_info "Will compile eNB" echo_info "Will compile eNB"
......
...@@ -39,71 +39,70 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -39,71 +39,70 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
unsigned char symbol, unsigned char symbol,
unsigned char Ns, unsigned char Ns,
int sample_offset, int sample_offset,
int no_prefix) int no_prefix) {
{
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
NR_UE_COMMON *common_vars = &ue->common_vars; NR_UE_COMMON *common_vars = &ue->common_vars;
unsigned char aa; unsigned char aa;
unsigned int nb_prefix_samples; unsigned int nb_prefix_samples;
unsigned int nb_prefix_samples0; unsigned int nb_prefix_samples0;
if (ue->is_synchronized) { if (ue->is_synchronized) {
nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0); nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0);
} } else {
else {
nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples); nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
} }
//unsigned int subframe_offset;//,subframe_offset_F; //unsigned int subframe_offset;//,subframe_offset_F;
unsigned int slot_offset; unsigned int slot_offset;
//int i; //int i;
unsigned int frame_length_samples = frame_parms->samples_per_subframe * 10; unsigned int frame_length_samples = frame_parms->samples_per_subframe * 10;
unsigned int rx_offset; unsigned int rx_offset;
void (*dft)(int16_t *,int16_t *, int); void (*dft)(int16_t *,int16_t *, int);
int tmp_dft_in[8192] __attribute__ ((aligned (32))); // This is for misalignment issues for 6 and 15 PRBs int tmp_dft_in[8192] __attribute__ ((aligned (32))); // This is for misalignment issues for 6 and 15 PRBs
switch (frame_parms->ofdm_symbol_size) { switch (frame_parms->ofdm_symbol_size) {
case 128: case 128:
dft = dft128; dft = dft128;
break; break;
case 256: case 256:
dft = dft256; dft = dft256;
break; break;
case 512: case 512:
dft = dft512; dft = dft512;
break; break;
case 1024: case 1024:
dft = dft1024; dft = dft1024;
break; break;
case 1536: case 1536:
dft = dft1536; dft = dft1536;
break; break;
case 2048: case 2048:
dft = dft2048; dft = dft2048;
break; break;
case 3072: case 3072:
dft = dft3072; dft = dft3072;
break; break;
case 4096: case 4096:
dft = dft4096; dft = dft4096;
break; break;
case 8192: case 8192:
dft = dft8192; dft = dft8192;
break; break;
default: default:
printf("unsupported ofdm symbol size \n"); dft=0;
assert(0); printf("unsupported ofdm symbol size \n");
assert(0);
} }
if (no_prefix) { if (no_prefix) {
...@@ -124,22 +123,19 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -124,22 +123,19 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) { for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
memset(&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int)); memset(&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],0,frame_parms->ofdm_symbol_size*sizeof(int));
rx_offset = sample_offset + slot_offset + nb_prefix_samples0 - SOFFSET; rx_offset = sample_offset + slot_offset + nb_prefix_samples0 - SOFFSET;
// Align with 256 bit // Align with 256 bit
// rx_offset = rx_offset&0xfffffff8; // rx_offset = rx_offset&0xfffffff8;
#ifdef DEBUG_FEP #ifdef DEBUG_FEP
// if (ue->frame <100) // if (ue->frame <100)
/*LOG_I(PHY,*/printf("slot_fep: frame %d: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, slot_offset %u, sample_offset %d,rx_offset %u, frame_length_samples %u\n", /*LOG_I(PHY,*/printf("slot_fep: frame %d: slot %d, symbol %d, nb_prefix_samples %u, nb_prefix_samples0 %u, slot_offset %u, sample_offset %d,rx_offset %u, frame_length_samples %u\n",
ue->proc.proc_rxtx[(Ns)&1].frame_rx, Ns, symbol, nb_prefix_samples, nb_prefix_samples0, slot_offset, sample_offset, rx_offset, frame_length_samples); ue->proc.proc_rxtx[(Ns)&1].frame_rx, Ns, symbol, nb_prefix_samples, nb_prefix_samples0, slot_offset, sample_offset, rx_offset, frame_length_samples);
#endif #endif
if (symbol==0) { if (symbol==0) {
if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size)) if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size))
memcpy((short*) &common_vars->rxdata[aa][frame_length_samples], memcpy((short *) &common_vars->rxdata[aa][frame_length_samples],
(short*) &common_vars->rxdata[aa][0], (short *) &common_vars->rxdata[aa][0],
frame_parms->ofdm_symbol_size*sizeof(int)); frame_parms->ofdm_symbol_size*sizeof(int));
if ((rx_offset&7)!=0) { // if input to dft is not 256-bit aligned, issue for size 6,15 and 25 PRBs if ((rx_offset&7)!=0) { // if input to dft is not 256-bit aligned, issue for size 6,15 and 25 PRBs
...@@ -150,9 +146,8 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -150,9 +146,8 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
(int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
} else { // use dft input from RX buffer directly } else { // use dft input from RX buffer directly
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&ue->rx_dft_stats); start_meas(&ue->rx_dft_stats);
#endif #endif
dft((int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples], dft((int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples],
(int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
...@@ -160,7 +155,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -160,7 +155,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
#endif #endif
} }
} else { } else {
rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol; rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol;
// + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1); // + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1);
...@@ -168,6 +162,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -168,6 +162,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
memcpy((void *) &common_vars->rxdata[aa][frame_length_samples], memcpy((void *) &common_vars->rxdata[aa][frame_length_samples],
(void *) &common_vars->rxdata[aa][0], (void *) &common_vars->rxdata[aa][0],
frame_parms->ofdm_symbol_size*sizeof(int)); frame_parms->ofdm_symbol_size*sizeof(int));
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&ue->rx_dft_stats); start_meas(&ue->rx_dft_stats);
#endif #endif
...@@ -179,24 +174,21 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -179,24 +174,21 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
dft((int16_t *)tmp_dft_in, dft((int16_t *)tmp_dft_in,
(int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
} else { // use dft input from RX buffer directly } else { // use dft input from RX buffer directly
dft((int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples], dft((int16_t *) &common_vars->rxdata[aa][(rx_offset) % frame_length_samples],
(int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1); (int16_t *)&common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns]].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],1);
} }
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
stop_meas(&ue->rx_dft_stats); stop_meas(&ue->rx_dft_stats);
#endif #endif
} }
#ifdef DEBUG_FEP #ifdef DEBUG_FEP
// if (ue->frame <100) // if (ue->frame <100)
printf("slot_fep: frame %d: symbol %d rx_offset %u\n", ue->proc.proc_rxtx[(Ns)&1].frame_rx, symbol, rx_offset); printf("slot_fep: frame %d: symbol %d rx_offset %u\n", ue->proc.proc_rxtx[(Ns)&1].frame_rx, symbol, rx_offset);
#endif #endif
} }
#ifdef DEBUG_FEP #ifdef DEBUG_FEP
printf("slot_fep: done\n"); printf("slot_fep: done\n");
#endif #endif
...@@ -210,14 +202,11 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, ...@@ -210,14 +202,11 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
unsigned char symbol, unsigned char symbol,
unsigned char Ns, unsigned char Ns,
int sample_offset, int sample_offset,
int no_prefix) int no_prefix) {
{
uint32_t slot_offset; uint32_t slot_offset;
uint32_t rxdata_offset; uint32_t rxdata_offset;
unsigned int nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); unsigned int nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
unsigned int nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0); unsigned int nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0);
void (*dft)(int16_t *,int16_t *, int); void (*dft)(int16_t *,int16_t *, int);
switch (frame_parms->ofdm_symbol_size) { switch (frame_parms->ofdm_symbol_size) {
...@@ -257,17 +246,15 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, ...@@ -257,17 +246,15 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
dft = dft512; dft = dft512;
break; break;
} }
slot_offset = Ns * frame_parms->samples_per_slot; slot_offset = Ns * frame_parms->samples_per_slot;
if(symbol == 0) if(symbol == 0)
rxdata_offset = slot_offset + nb_prefix_samples0 - SOFFSET; rxdata_offset = slot_offset + nb_prefix_samples0 - SOFFSET;
else else
rxdata_offset = slot_offset + nb_prefix_samples0 + (symbol * (frame_parms->ofdm_symbol_size + nb_prefix_samples)) - SOFFSET; rxdata_offset = slot_offset + nb_prefix_samples0 + (symbol * (frame_parms->ofdm_symbol_size + nb_prefix_samples)) - SOFFSET;
dft((int16_t *)&rxdata[rxdata_offset], dft((int16_t *)&rxdata[rxdata_offset],
(int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1); (int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1);
return(0); return(0);
} }
...@@ -4429,7 +4429,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) { ...@@ -4429,7 +4429,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) {
static LTE_InterFreqBandInfo_t InterFreqBandInfo[4][4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it static LTE_InterFreqBandInfo_t InterFreqBandInfo[4][4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it
static LTE_BandInfoEUTRA_t BandInfoEUTRA[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it static LTE_BandInfoEUTRA_t BandInfoEUTRA[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it
asn_enc_rval_t enc_rval; asn_enc_rval_t enc_rval;
asn_dec_rval_t dec_rval; __attribute__ ((unused)) asn_dec_rval_t dec_rval; /* prevent warning: used only in assert macro */
long maxNumberROHC_ContextSessions = LTE_PDCP_Parameters__maxNumberROHC_ContextSessions_cs16; long maxNumberROHC_ContextSessions = LTE_PDCP_Parameters__maxNumberROHC_ContextSessions_cs16;
int i; int i;
LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability; LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability;
......
This diff is collapsed.
...@@ -3,110 +3,119 @@ ...@@ -3,110 +3,119 @@
#include "conf_network.h" #include "conf_network.h"
int get_plmn_index(const char * mccmnc, const networks_t networks) { int get_plmn_index(const char *mccmnc, const networks_t networks) {
char mcc[4]; char mcc[4];
char mnc[strlen(mccmnc) - 2]; char mnc[strlen(mccmnc) - 2];
strncpy(mcc, mccmnc, 3); strncpy(mcc, mccmnc, 3);
mcc[3] = '\0'; mcc[3] = '\0';
strncpy(mnc, mccmnc + 3, 3); strncpy(mnc, mccmnc + 3, 3);
mnc[strlen(mccmnc) - 3] = '\0'; mnc[strlen(mccmnc) - 3] = '\0';
for (int i = 0; i < networks.size; i++) {
if (strcmp(networks.items[i].conf.mcc, mcc) == 0) { for (int i = 0; i < networks.size; i++) {
if (strcmp(networks.items[i].conf.mnc, mnc) == 0) { if (strcmp(networks.items[i].conf.mcc, mcc) == 0) {
return i; if (strcmp(networks.items[i].conf.mnc, mnc) == 0) {
} return i;
} }
} }
return -1; }
return -1;
} }
plmn_t make_plmn_from_conf(const plmn_conf_param_t *plmn_conf) { plmn_t make_plmn_from_conf(const plmn_conf_param_t *plmn_conf) {
plmn_t plmn; plmn_t plmn;
char num[6]; char num[6];
memset(&plmn, 0xff, sizeof(plmn));
memset(&plmn, 0xff, sizeof(plmn)); snprintf(num, 6, "%s%s", plmn_conf->mcc, plmn_conf->mnc);
plmn.MCCdigit2 = plmn_conf->mcc[1];
snprintf(num, 6, "%s%s", plmn_conf->mcc, plmn_conf->mnc); plmn.MCCdigit1 = plmn_conf->mcc[0];
plmn.MCCdigit3 = plmn_conf->mcc[2];
plmn.MCCdigit2 = plmn_conf->mcc[1]; plmn.MNCdigit2 = plmn_conf->mnc[1];
plmn.MCCdigit1 = plmn_conf->mcc[0]; plmn.MNCdigit1 = plmn_conf->mnc[0];
plmn.MCCdigit3 = plmn_conf->mcc[2];
plmn.MNCdigit2 = plmn_conf->mnc[1]; if (strlen(plmn_conf->mnc) > 2) {
plmn.MNCdigit1 = plmn_conf->mnc[0]; plmn.MNCdigit3 = plmn_conf->mnc[2];
if (strlen(plmn_conf->mnc) > 2) { }
plmn.MNCdigit3 = plmn_conf->mnc[2];
} return plmn;
return plmn;
} }
void gen_network_record_from_conf(const plmn_conf_param_t *conf, network_record_t *record) { void gen_network_record_from_conf(const plmn_conf_param_t *conf, network_record_t *record) {
strcpy(record->fullname, conf->fullname); strcpy(record->fullname, conf->fullname);
strcpy(record->shortname, conf->shortname); strcpy(record->shortname, conf->shortname);
char num[10];
char num[6]; sprintf(num, "%s%s", conf->mcc, conf->mnc);
sprintf(num, "%s%s", conf->mcc, conf->mnc); record->num = atoi(num);
record->num = atoi(num); record->plmn = make_plmn_from_conf(conf);
record->tac_end = 0xfffd;
record->plmn = make_plmn_from_conf(conf); record->tac_start = 0x0001;
record->tac_end = 0xfffd;
record->tac_start = 0x0001;
} }
bool parse_plmn_param(config_setting_t *plmn_setting, plmn_conf_param_t *conf) { bool parse_plmn_param(config_setting_t *plmn_setting, plmn_conf_param_t *conf) {
int rc = 0; int rc = 0;
rc = config_setting_lookup_string(plmn_setting, FULLNAME, &conf->fullname); rc = config_setting_lookup_string(plmn_setting, FULLNAME, &conf->fullname);
if (rc != 1) {
printf("Error on FULLNAME\n"); if (rc != 1) {
return false; printf("Error on FULLNAME\n");
} return false;
rc = config_setting_lookup_string(plmn_setting, SHORTNAME, &conf->shortname); }
if (rc != 1) {
printf("Error on SHORTNAME\n"); rc = config_setting_lookup_string(plmn_setting, SHORTNAME, &conf->shortname);
return false;
} if (rc != 1) {
rc = config_setting_lookup_string(plmn_setting, MNC, &conf->mnc); printf("Error on SHORTNAME\n");
if (rc != 1 || strlen(conf->mnc) > 3 return false;
|| strlen(conf->mnc) < 2) { }
printf("Error ond MNC. Exiting\n");
return false; rc = config_setting_lookup_string(plmn_setting, MNC, &conf->mnc);
}
rc = config_setting_lookup_string(plmn_setting, MCC, &conf->mcc); if (rc != 1 || strlen(conf->mnc) > 3
if (rc != 1 || strlen(conf->mcc) != 3) { || strlen(conf->mnc) < 2) {
printf("Error on MCC\n"); printf("Error ond MNC. Exiting\n");
return false; return false;
} }
return true;
rc = config_setting_lookup_string(plmn_setting, MCC, &conf->mcc);
if (rc != 1 || strlen(conf->mcc) != 3) {
printf("Error on MCC\n");
return false;
}
return true;
} }
bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) { bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) {
config_setting_t *plmn_setting = NULL; config_setting_t *plmn_setting = NULL;
char plmn[10]; char plmn[16];
int size = 0; int size = 0;
size = config_setting_length(all_plmn_setting);
size = config_setting_length(all_plmn_setting); networks->size = size;
networks->items = malloc(sizeof(network_t) * size);
networks->size = size;
networks->items = malloc(sizeof(network_t) * size); for (int i = 0; i < size; i++) {
for (int i = 0; i < size; i++) { memset(&networks->items[i].record, 0xff, sizeof(network_record_t));
memset(&networks->items[i].record, 0xff, sizeof(network_record_t)); }
}
for ( int i = 0; i < networks->size; i++) {
for (int i = 0; i < networks->size; i++) { network_t *network = &networks->items[i];
network_t *network = &networks->items[i]; sprintf(plmn, "%s%d", PLMN, i);
sprintf(plmn, "%s%d", PLMN, i); plmn_setting = config_setting_get_member(all_plmn_setting, plmn);
plmn_setting = config_setting_get_member(all_plmn_setting, plmn);
if (plmn_setting == NULL) { if (plmn_setting == NULL) {
printf("PLMN%d not fouund\n", i); printf("PLMN%d not fouund\n", i);
return false; return false;
} }
if ( parse_plmn_param(plmn_setting, &network->conf) == false ) { if ( parse_plmn_param(plmn_setting, &network->conf) == false ) {
return false; return false;
} }
gen_network_record_from_conf(&network->conf, &network->record);
network->plmn = network->record.plmn; gen_network_record_from_conf(&network->conf, &network->record);
} network->plmn = network->record.plmn;
return true; }
return true;
} }
...@@ -7,113 +7,114 @@ ...@@ -7,113 +7,114 @@
#include "conf_user_plmn.h" #include "conf_user_plmn.h"
bool parse_config_file(const char *output_dir, const char *conf_filename, int output_flags) { bool parse_config_file(const char *output_dir, const char *conf_filename, int output_flags) {
int rc = true; int rc = true;
int ret; int ret;
int ue_nb = 0; short ue_nb = 0;
config_setting_t *root_setting = NULL; config_setting_t *root_setting = NULL;
config_setting_t *ue_setting = NULL; config_setting_t *ue_setting = NULL;
config_setting_t *all_plmn_setting = NULL; config_setting_t *all_plmn_setting = NULL;
char user[10]; char user[16];
config_t cfg; config_t cfg;
networks_t networks;;
networks_t networks;; ret = get_config_from_file(conf_filename, &cfg);
ret = get_config_from_file(conf_filename, &cfg); if (ret == false) {
if (ret == false) { exit(1);
exit(1); }
root_setting = config_root_setting(&cfg);
ue_nb = config_setting_length(root_setting) - 1;
all_plmn_setting = config_setting_get_member(root_setting, PLMN);
if (all_plmn_setting == NULL) {
printf("NO PLMN SECTION...EXITING...\n");
return (false);
}
if ( parse_plmns(all_plmn_setting, &networks) == false ) {
return false;
}
for (int i = 0; i < ue_nb; i++) {
emm_nvdata_t emm_data;
user_nvdata_t user_data;
user_data_conf_t user_data_conf;
usim_data_t usim_data;
usim_data_conf_t usim_data_conf;
user_plmns_t user_plmns;
sprintf(user, "%s%d", UE, i);
ue_setting = config_setting_get_member(root_setting, user);
if (ue_setting == NULL) {
printf("Check UE%d settings\n", i);
return false;
} }
root_setting = config_root_setting(&cfg); if ( parse_user_plmns_conf(ue_setting, i, &user_plmns, &usim_data_conf.hplmn, networks) == false ) {
ue_nb = config_setting_length(root_setting) - 1; return false;
all_plmn_setting = config_setting_get_member(root_setting, PLMN);
if (all_plmn_setting == NULL) {
printf("NO PLMN SECTION...EXITING...\n");
return (false);
}
if ( parse_plmns(all_plmn_setting, &networks) == false ) {
return false;
} }
for (int i = 0; i < ue_nb; i++) { rc = parse_ue_user_data(ue_setting, i, &user_data_conf);
emm_nvdata_t emm_data;
user_nvdata_t user_data;
user_data_conf_t user_data_conf;
usim_data_t usim_data; if (rc != true) {
usim_data_conf_t usim_data_conf; printf("Problem in USER section for UE%d. EXITING...\n", i);
return false;
user_plmns_t user_plmns; }
sprintf(user, "%s%d", UE, i); gen_user_data(&user_data_conf, &user_data);
rc = parse_ue_sim_param(ue_setting, i, &usim_data_conf);
ue_setting = config_setting_get_member(root_setting, user); if (rc != true) {
if (ue_setting == NULL) { printf("Problem in SIM section for UE%d. EXITING...\n", i);
printf("Check UE%d settings\n", i); return false;
return false; }
}
if ( parse_user_plmns_conf(ue_setting, i, &user_plmns, &usim_data_conf.hplmn, networks) == false ) { gen_usim_data(&usim_data_conf, &usim_data, &user_plmns, networks);
return false; gen_emm_data(&emm_data, usim_data_conf.hplmn, usim_data_conf.msin,
} &user_plmns.equivalents_home, networks);
rc = parse_ue_user_data(ue_setting, i, &user_data_conf); if ( output_flags & OUTPUT_UEDATA ) {
if (rc != true) { write_user_data(output_dir, i, &user_data);
printf("Problem in USER section for UE%d. EXITING...\n", i); }
return false;
}
gen_user_data(&user_data_conf, &user_data);
rc = parse_ue_sim_param(ue_setting, i, &usim_data_conf); if ( output_flags & OUTPUT_USIM ) {
if (rc != true) { write_usim_data(output_dir, i, &usim_data);
printf("Problem in SIM section for UE%d. EXITING...\n", i); }
return false;
}
gen_usim_data(&usim_data_conf, &usim_data, &user_plmns, networks);
gen_emm_data(&emm_data, usim_data_conf.hplmn, usim_data_conf.msin, if ( output_flags & OUTPUT_EMM ) {
&user_plmns.equivalents_home, networks); write_emm_data(output_dir, i, &emm_data);
}
if ( output_flags & OUTPUT_UEDATA ) { user_plmns_free(&user_plmns);
write_user_data(output_dir, i, &user_data); }
}
if ( output_flags & OUTPUT_USIM ) { free(networks.items);
write_usim_data(output_dir, i, &usim_data); networks.size=0;
} config_destroy(&cfg);
return(true);
}
if ( output_flags & OUTPUT_EMM ) { bool get_config_from_file(const char *filename, config_t *config) {
write_emm_data(output_dir, i, &emm_data); config_init(config);
}
user_plmns_free(&user_plmns); if (filename == NULL) {
// XXX write error message ?
return(false);
}
} /* Read the file. If there is an error, report it and exit. */
free(networks.items); if (!config_read_file(config, filename)) {
networks.size=0; fprintf(stderr, "Cant read config file '%s': %s\n", filename,
config_destroy(&cfg); config_error_text(config));
return(true);
}
bool get_config_from_file(const char *filename, config_t *config) { if ( config_error_type(config) == CONFIG_ERR_PARSE ) {
config_init(config); fprintf(stderr, "This is line %d\n", config_error_line(config));
if (filename == NULL) {
// XXX write error message ?
return(false);
} }
/* Read the file. If there is an error, report it and exit. */ config_destroy(config);
if (!config_read_file(config, filename)) { return (false);
fprintf(stderr, "Cant read config file '%s': %s\n", filename, }
config_error_text(config));
if ( config_error_type(config) == CONFIG_ERR_PARSE ) { return true;
fprintf(stderr, "This is line %d\n", config_error_line(config));
}
config_destroy(config);
return (false);
}
return true;
} }
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