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
...@@ -193,10 +196,41 @@ function main() { ...@@ -193,10 +196,41 @@ function main() {
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)
case "$2" in
"Release")
GDB=0
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 GDB=1
CMAKE_BUILD_TYPE="Debug" CMAKE_BUILD_TYPE="Debug"
echo_info "Will Compile with gdb symbols and disable compiler optimization" echo_info "Will Compile with gdb symbols and disable compiler optimization"
CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Debug --trace-expand" CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Debug"
if [ "$1" == "Debug" ] ; then
shift
fi
;;
esac
shift;;
-G | --cmaketrace)
CMAKE_CMD="$CMAKE_CMD --trace-expand"
shift;; shift;;
--eNB) --eNB)
eNB=1 eNB=1
......
...@@ -39,28 +39,26 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -39,28 +39,26 @@ 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
...@@ -102,6 +100,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -102,6 +100,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
break; break;
default: default:
dft=0;
printf("unsupported ofdm symbol size \n"); printf("unsupported ofdm symbol size \n");
assert(0); assert(0);
} }
...@@ -124,11 +123,9 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -124,11 +123,9 @@ 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",
...@@ -136,10 +133,9 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -136,10 +133,9 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
#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
...@@ -152,7 +148,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -152,7 +148,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
#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) {
...@@ -260,7 +249,6 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, ...@@ -260,7 +249,6 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
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
...@@ -268,6 +256,5 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms, ...@@ -268,6 +256,5 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
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;
......
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
#include "gtpv1u.h" #include "gtpv1u.h"
#if defined(ENB_MODE) #if defined(ENB_MODE)
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/vcd_signal_dumper.h"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
...@@ -68,8 +68,7 @@ extern "C" { ...@@ -68,8 +68,7 @@ extern "C" {
void void
nwGtpv1uDisplayBanner(void) nwGtpv1uDisplayBanner(void) {
{
printf(" *----------------------------------------------------------------------------*\n"); printf(" *----------------------------------------------------------------------------*\n");
printf(" * *\n"); printf(" * *\n");
printf(" * n w - g t p v 2 u *\n"); printf(" * n w - g t p v 2 u *\n");
...@@ -102,7 +101,6 @@ nwGtpv1uDisplayBanner(void) ...@@ -102,7 +101,6 @@ nwGtpv1uDisplayBanner(void)
printf(" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *\n"); printf(" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *\n");
printf(" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *\n"); printf(" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *\n");
printf(" *----------------------------------------------------------------------------*\n\n"); printf(" *----------------------------------------------------------------------------*\n\n");
} }
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
* RBTree Search Functions * RBTree Search Functions
...@@ -144,8 +142,7 @@ RB_GENERATE(NwGtpv1uTunnelEndPointIdentifierMap, NwGtpv1uTunnelEndPoint, ...@@ -144,8 +142,7 @@ RB_GENERATE(NwGtpv1uTunnelEndPointIdentifierMap, NwGtpv1uTunnelEndPoint,
static inline NwS32T static inline NwS32T
nwGtpv1uCompareTeid(struct NwGtpv1uTunnelEndPoint *a, nwGtpv1uCompareTeid(struct NwGtpv1uTunnelEndPoint *a,
struct NwGtpv1uTunnelEndPoint *b) struct NwGtpv1uTunnelEndPoint *b) {
{
if(a->teid > b->teid) { if(a->teid > b->teid) {
return 1; return 1;
} }
...@@ -167,8 +164,7 @@ nwGtpv1uCompareTeid(struct NwGtpv1uTunnelEndPoint *a, ...@@ -167,8 +164,7 @@ nwGtpv1uCompareTeid(struct NwGtpv1uTunnelEndPoint *a,
*/ */
static inline NwS32T static inline NwS32T
nwGtpv1uCompareSeqNum(struct NwGtpv1uTrxn *a, struct NwGtpv1uTrxn *b) nwGtpv1uCompareSeqNum(struct NwGtpv1uTrxn *a, struct NwGtpv1uTrxn *b) {
{
if(a->seqNum > b->seqNum) { if(a->seqNum > b->seqNum) {
return 1; return 1;
} }
...@@ -197,31 +193,24 @@ nwGtpv1uCompareSeqNum(struct NwGtpv1uTrxn *a, struct NwGtpv1uTrxn *b) ...@@ -197,31 +193,24 @@ nwGtpv1uCompareSeqNum(struct NwGtpv1uTrxn *a, struct NwGtpv1uTrxn *b)
static NwGtpv1uRcT static NwGtpv1uRcT
nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPort, nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPort,
NwGtpv1uMsgT *pMsg) NwGtpv1uMsgT *pMsg) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
uint8_t *msgHdr; uint8_t *msgHdr;
NW_ASSERT(thiz); NW_ASSERT(thiz);
NW_ASSERT(pMsg); NW_ASSERT(pMsg);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz); NW_ENTER(thiz);
#endif #endif
msgHdr = &pMsg->msgBuf[pMsg->msgBufOffset]; msgHdr = &pMsg->msgBuf[pMsg->msgBufOffset];
NW_ASSERT(msgHdr != NULL); NW_ASSERT(msgHdr != NULL);
*(msgHdr++) = (pMsg->version << 5) | *(msgHdr++) = (pMsg->version << 5) |
(pMsg->protocolType << 4) | (pMsg->protocolType << 4) |
(pMsg->extHdrFlag << 2) | (pMsg->extHdrFlag << 2) |
(pMsg->seqNumFlag << 1) | (pMsg->seqNumFlag << 1) |
(pMsg->npduNumFlag); (pMsg->npduNumFlag);
*(msgHdr++) = (pMsg->msgType); *(msgHdr++) = (pMsg->msgType);
*((uint16_t *) msgHdr) = htons(pMsg->msgLen); *((uint16_t *) msgHdr) = htons(pMsg->msgLen);
msgHdr += 2; msgHdr += 2;
*((uint32_t *) msgHdr) = htonl(pMsg->teid); *((uint32_t *) msgHdr) = htonl(pMsg->teid);
msgHdr += 4; msgHdr += 4;
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
...@@ -234,10 +223,8 @@ nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPo ...@@ -234,10 +223,8 @@ nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPo
if(pMsg->seqNumFlag || pMsg->extHdrFlag || pMsg->npduNumFlag) { if(pMsg->seqNumFlag || pMsg->extHdrFlag || pMsg->npduNumFlag) {
*((uint16_t *) msgHdr) = (pMsg->seqNumFlag ? htons(pMsg->seqNum) : 0x0000); *((uint16_t *) msgHdr) = (pMsg->seqNumFlag ? htons(pMsg->seqNum) : 0x0000);
msgHdr += 2; msgHdr += 2;
*((uint8_t *) msgHdr) = (pMsg->npduNumFlag ? htons(pMsg->npduNum) : 0x00); *((uint8_t *) msgHdr) = (pMsg->npduNumFlag ? htons(pMsg->npduNum) : 0x00);
msgHdr++; msgHdr++;
*((uint8_t *) msgHdr) = (pMsg->extHdrFlag ? htons(pMsg->nextExtHdrType) : 0x00); *((uint8_t *) msgHdr) = (pMsg->extHdrFlag ? htons(pMsg->nextExtHdrType) : 0x00);
msgHdr++; msgHdr++;
} }
...@@ -248,7 +235,6 @@ nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPo ...@@ -248,7 +235,6 @@ nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPo
pMsg->msgBufOffset, pMsg->msgBufOffset,
peerIp, peerIp,
peerPort); peerPort);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_LEAVE(thiz); NW_LEAVE(thiz);
#endif #endif
...@@ -270,15 +256,12 @@ nwGtpv1uSendUlpMessageIndication( NW_IN NwGtpv1uStackT *thiz, ...@@ -270,15 +256,12 @@ nwGtpv1uSendUlpMessageIndication( NW_IN NwGtpv1uStackT *thiz,
NW_IN uint32_t peerIp, NW_IN uint32_t peerIp,
NW_IN uint16_t peerPort, NW_IN uint16_t peerPort,
NW_IN uint8_t *pMsgBuf, NW_IN uint8_t *pMsgBuf,
NW_IN uint16_t msgLength) NW_IN uint16_t msgLength) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uUlpApiT ulpApi; NwGtpv1uUlpApiT ulpApi;
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz); NW_ENTER(thiz);
#endif #endif
ulpApi.apiType = apiType; ulpApi.apiType = apiType;
ulpApi.apiInfo.recvMsgInfo.msgType = msgType; ulpApi.apiInfo.recvMsgInfo.msgType = msgType;
ulpApi.apiInfo.recvMsgInfo.hUlpTrxn = hUlpTrxn; ulpApi.apiInfo.recvMsgInfo.hUlpTrxn = hUlpTrxn;
...@@ -293,23 +276,18 @@ nwGtpv1uSendUlpMessageIndication( NW_IN NwGtpv1uStackT *thiz, ...@@ -293,23 +276,18 @@ nwGtpv1uSendUlpMessageIndication( NW_IN NwGtpv1uStackT *thiz,
rc = thiz->ulp.ulpReqCallback(thiz->ulp.hUlp, &ulpApi); rc = thiz->ulp.ulpReqCallback(thiz->ulp.hUlp, &ulpApi);
NW_ASSERT(rc == NW_GTPV1U_OK); NW_ASSERT(rc == NW_GTPV1U_OK);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_LEAVE(thiz); NW_LEAVE(thiz);
#endif #endif
return rc; return rc;
} }
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uPeerRspTimeout(void *arg) nwGtpv1uPeerRspTimeout(void *arg) {
{
NwGtpv1uRcT rc = NW_GTPV1U_OK; NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTrxnT *thiz; NwGtpv1uTrxnT *thiz;
NwGtpv1uTimeoutInfoT *timeoutInfo = arg; NwGtpv1uTimeoutInfoT *timeoutInfo = arg;
GTPU_WARNING( "Retransmission timer expired\n"); GTPU_WARNING( "Retransmission timer expired\n");
thiz = ((NwGtpv1uTrxnT *)timeoutInfo->timeoutArg); thiz = ((NwGtpv1uTrxnT *)timeoutInfo->timeoutArg);
rc = thiz->pStack->udp.udpDataReqCallback(thiz->pStack->udp.hUdp, rc = thiz->pStack->udp.udpDataReqCallback(thiz->pStack->udp.hUdp,
thiz->pMsg->msgBuf, thiz->pMsg->msgBuf,
...@@ -346,23 +324,19 @@ static NwGtpv1uRcT ...@@ -346,23 +324,19 @@ static NwGtpv1uRcT
NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz, NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz,
NW_IN uint32_t teid, NW_IN uint32_t teid,
NW_IN NwGtpv1uUlpSessionHandleT hUlpSession, NW_IN NwGtpv1uUlpSessionHandleT hUlpSession,
NW_OUT NwGtpv1uStackSessionHandleT *phStackSession ) NW_OUT NwGtpv1uStackSessionHandleT *phStackSession ) {
{
NwGtpv1uRcT rc = NW_GTPV1U_OK; NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTunnelEndPointT *pTunnelEndPoint; NwGtpv1uTunnelEndPointT *pTunnelEndPoint;
NwGtpv1uTunnelEndPointT *pCollision; NwGtpv1uTunnelEndPointT *pCollision;
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz); NW_ENTER(thiz);
#endif #endif
pTunnelEndPoint = nwGtpTunnelEndPointNew(thiz); pTunnelEndPoint = nwGtpTunnelEndPointNew(thiz);
if(pTunnelEndPoint) { if(pTunnelEndPoint) {
pTunnelEndPoint->teid = teid; pTunnelEndPoint->teid = teid;
pTunnelEndPoint->pStack = thiz; pTunnelEndPoint->pStack = thiz;
pTunnelEndPoint->hUlpSession = hUlpSession; pTunnelEndPoint->hUlpSession = hUlpSession;
pCollision = RB_INSERT(NwGtpv1uTunnelEndPointIdentifierMap, &(thiz->teidMap), pCollision = RB_INSERT(NwGtpv1uTunnelEndPointIdentifierMap, &(thiz->teidMap),
pTunnelEndPoint); pTunnelEndPoint);
...@@ -378,6 +352,7 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz, ...@@ -378,6 +352,7 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz,
*phStackSession = (NwGtpv1uStackSessionHandleT) pTunnelEndPoint; *phStackSession = (NwGtpv1uStackSessionHandleT) pTunnelEndPoint;
pTunnelEndPoint = RB_FIND(NwGtpv1uTunnelEndPointIdentifierMap, pTunnelEndPoint = RB_FIND(NwGtpv1uTunnelEndPointIdentifierMap,
&(thiz->teidMap), pTunnelEndPoint); &(thiz->teidMap), pTunnelEndPoint);
//NW_ASSERT(pTunnelEndPoint); //NW_ASSERT(pTunnelEndPoint);
if (!pTunnelEndPoint) { if (!pTunnelEndPoint) {
GTPU_ERROR("Tunnel end-point cannot be NULL"); GTPU_ERROR("Tunnel end-point cannot be NULL");
...@@ -387,7 +362,6 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz, ...@@ -387,7 +362,6 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz,
pTunnelEndPoint, (unsigned int)teid, (unsigned int)teid); pTunnelEndPoint, (unsigned int)teid, (unsigned int)teid);
} }
} }
} else { } else {
*phStackSession = (NwGtpv1uStackSessionHandleT) NULL; *phStackSession = (NwGtpv1uStackSessionHandleT) NULL;
rc = NW_GTPV1U_FAILURE; rc = NW_GTPV1U_FAILURE;
...@@ -409,10 +383,9 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz, ...@@ -409,10 +383,9 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz,
static NwGtpv1uRcT static NwGtpv1uRcT
nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz, nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz,
NW_IN NwGtpv1uUlpApiT *pUlpReq) NW_IN NwGtpv1uUlpApiT *pUlpReq) {
{
NwGtpv1uRcT rc = NW_GTPV1U_OK; NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTunnelEndPointT *pRemovedTeid; __attribute__ ((unused)) NwGtpv1uTunnelEndPointT *pRemovedTeid;
if(pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle) { if(pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle) {
GTPU_DEBUG( "Destroying Tunnel end-point '%lx'", GTPU_DEBUG( "Destroying Tunnel end-point '%lx'",
...@@ -420,10 +393,8 @@ nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz, ...@@ -420,10 +393,8 @@ nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz,
pRemovedTeid = RB_REMOVE(NwGtpv1uTunnelEndPointIdentifierMap, &(thiz->teidMap), pRemovedTeid = RB_REMOVE(NwGtpv1uTunnelEndPointIdentifierMap, &(thiz->teidMap),
(NwGtpv1uTunnelEndPointT *)( (NwGtpv1uTunnelEndPointT *)(
pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle)); pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle));
NW_ASSERT(pRemovedTeid == (NwGtpv1uTunnelEndPointT *)( NW_ASSERT(pRemovedTeid == (NwGtpv1uTunnelEndPointT *)(
pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle)); pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle));
rc = nwGtpTunnelEndPointDestroy(thiz, rc = nwGtpTunnelEndPointDestroy(thiz,
(NwGtpv1uTunnelEndPointT *) (NwGtpv1uTunnelEndPointT *)
pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle); pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle);
...@@ -444,11 +415,9 @@ nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz, ...@@ -444,11 +415,9 @@ nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz,
*/ */
static NwGtpv1uRcT static NwGtpv1uRcT
nwGtpv1uInitialReq( NW_IN NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq) nwGtpv1uInitialReq( NW_IN NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uTrxnT *pTrxn; NwGtpv1uTrxnT *pTrxn;
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz); NW_ENTER(thiz);
#endif #endif
...@@ -487,23 +456,18 @@ nwGtpv1uInitialReq( NW_IN NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq) ...@@ -487,23 +456,18 @@ nwGtpv1uInitialReq( NW_IN NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq)
*/ */
static NwGtpv1uRcT static NwGtpv1uRcT
nwGtpv1uSendto( NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq) nwGtpv1uSendto( NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NW_ASSERT(thiz); NW_ASSERT(thiz);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz); NW_ENTER(thiz);
#endif #endif
(void) nwGtpv1uMsgSetTeid(pUlpReq->apiInfo.sendtoInfo.hMsg, (void) nwGtpv1uMsgSetTeid(pUlpReq->apiInfo.sendtoInfo.hMsg,
pUlpReq->apiInfo.sendtoInfo.teid); pUlpReq->apiInfo.sendtoInfo.teid);
rc = nwGtpv1uCreateAndSendMsg(thiz, rc = nwGtpv1uCreateAndSendMsg(thiz,
pUlpReq->apiInfo.sendtoInfo.ipAddr, pUlpReq->apiInfo.sendtoInfo.ipAddr,
2152, 2152,
(NwGtpv1uMsgT *) (NwGtpv1uMsgT *) pUlpReq->apiInfo.sendtoInfo.hMsg); (NwGtpv1uMsgT *) (NwGtpv1uMsgT *) pUlpReq->apiInfo.sendtoInfo.hMsg);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_LEAVE(thiz); NW_LEAVE(thiz);
#endif #endif
...@@ -530,22 +494,17 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz, ...@@ -530,22 +494,17 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
NwGtpv1uTunnelEndPointT *pTunnelEndPoint = NULL; NwGtpv1uTunnelEndPointT *pTunnelEndPoint = NULL;
NwGtpv1uTunnelEndPointT tunnelEndPointKey; NwGtpv1uTunnelEndPointT tunnelEndPointKey;
// uint16_t hdr_len = 0; // uint16_t hdr_len = 0;
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz); NW_ENTER(thiz);
#endif #endif
// no buffer offset // no buffer offset
msgHdr = (NwGtpv1uMsgHeaderT *) gpdu; msgHdr = (NwGtpv1uMsgHeaderT *) gpdu;
tunnelEndPointKey.teid = ntohl(msgHdr->teid); tunnelEndPointKey.teid = ntohl(msgHdr->teid);
pTunnelEndPoint = RB_FIND(NwGtpv1uTunnelEndPointIdentifierMap, pTunnelEndPoint = RB_FIND(NwGtpv1uTunnelEndPointIdentifierMap,
&(thiz->teidMap), &tunnelEndPointKey); &(thiz->teidMap), &tunnelEndPointKey);
if(pTunnelEndPoint) { if(pTunnelEndPoint) {
NwGtpv1uMsgHandleT hMsg; NwGtpv1uMsgHandleT hMsg;
rc = nwGtpv1uMsgFromBufferNew( (NwGtpv1uStackHandleT)thiz, rc = nwGtpv1uMsgFromBufferNew( (NwGtpv1uStackHandleT)thiz,
(uint8_t *)gpdu, (uint8_t *)gpdu,
gpduLen, gpduLen,
...@@ -570,7 +529,6 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz, ...@@ -570,7 +529,6 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
" G-PDU ltid %u size %u", " G-PDU ltid %u size %u",
tunnelEndPointKey.teid, tunnelEndPointKey.teid,
gpduLen); gpduLen);
rc = nwGtpSessionSendMsgApiToUlpEntity(pTunnelEndPoint, pMsg); rc = nwGtpSessionSendMsgApiToUlpEntity(pTunnelEndPoint, pMsg);
} }
} else { } else {
...@@ -604,15 +562,12 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz, ...@@ -604,15 +562,12 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
NW_IN uint8_t *msgBuf, NW_IN uint8_t *msgBuf,
NW_IN uint32_t msgBufLen, NW_IN uint32_t msgBufLen,
NW_IN uint16_t peerPort, NW_IN uint16_t peerPort,
NW_IN uint32_t peerIp) NW_IN uint32_t peerIp) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
uint16_t seqNum = 0; uint16_t seqNum = 0;
NwGtpv1uMsgHandleT hMsg = 0; NwGtpv1uMsgHandleT hMsg = 0;
int bufLen = 0; int bufLen = 0;
seqNum = ntohs(*(uint16_t *) (msgBuf + (((*msgBuf) & 0x02) ? 8 : 4))); seqNum = ntohs(*(uint16_t *) (msgBuf + (((*msgBuf) & 0x02) ? 8 : 4)));
MSC_LOG_RX_MESSAGE( MSC_LOG_RX_MESSAGE(
(thiz->stackType == GTPU_STACK_ENB) ? MSC_GTPU_ENB:MSC_GTPU_SGW, (thiz->stackType == GTPU_STACK_ENB) ? MSC_GTPU_ENB:MSC_GTPU_SGW,
(thiz->stackType == GTPU_STACK_ENB) ? MSC_GTPU_SGW:MSC_GTPU_ENB, (thiz->stackType == GTPU_STACK_ENB) ? MSC_GTPU_SGW:MSC_GTPU_ENB,
...@@ -621,7 +576,6 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz, ...@@ -621,7 +576,6 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
MSC_AS_TIME_FMT" ECHO-REQ seq %u size %u", MSC_AS_TIME_FMT" ECHO-REQ seq %u size %u",
0,0,seqNum, msgBufLen); 0,0,seqNum, msgBufLen);
/* Send Echo Response */ /* Send Echo Response */
rc = nwGtpv1uMsgNew( (NwGtpv1uStackHandleT)thiz, rc = nwGtpv1uMsgNew( (NwGtpv1uStackHandleT)thiz,
NW_TRUE, /* SeqNum flag */ NW_TRUE, /* SeqNum flag */
NW_FALSE, NW_FALSE,
...@@ -632,28 +586,24 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz, ...@@ -632,28 +586,24 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
0, 0,
0, 0,
(&hMsg)); (&hMsg));
bufLen = sizeof(NwGtpv1uIeTv1T)+ ((NwGtpv1uMsgT *)hMsg)->msgLen;
bufLen = sizeof(NwGtpv1uIeTv1T)+ ((NwGtpv1uMsgT*)hMsg)->msgLen; //#warning CROUX DIRTY +16, TO BE FIXED!!!
//#warning CROUX DIRTY +16, TO BE FIXED!!!
/* the +16 is there because by analyzing memory allocation with some external /* the +16 is there because by analyzing memory allocation with some external
* tool, I saw that there were 6 bytes accessed after bufLen in nwGtpv1uCreateAndSendMsg * tool, I saw that there were 6 bytes accessed after bufLen in nwGtpv1uCreateAndSendMsg
* the value "16" has been chosen arbitrarily, just bigger than 6 * the value "16" has been chosen arbitrarily, just bigger than 6
*/ */
((NwGtpv1uMsgT*)hMsg)->msgBuf = itti_malloc( ((NwGtpv1uMsgT *)hMsg)->msgBuf = itti_malloc(
TASK_GTPV1_U, TASK_GTPV1_U,
TASK_UDP, TASK_UDP,
bufLen + 16 /* CROUX - dirty +16, to be fixed! */); bufLen + 16 /* CROUX - dirty +16, to be fixed! */);
((NwGtpv1uMsgT*)hMsg)->msgBufLen = bufLen; ((NwGtpv1uMsgT *)hMsg)->msgBufLen = bufLen;
NW_ASSERT(NW_GTPV1U_OK == rc); NW_ASSERT(NW_GTPV1U_OK == rc);
/* /*
* The Restart Counter value in the Recovery information element shall * The Restart Counter value in the Recovery information element shall
* not be used, i.e. it shall be set to zero by the sender and shall be * not be used, i.e. it shall be set to zero by the sender and shall be
* ignored by the receiver. * ignored by the receiver.
*/ */
rc = nwGtpv1uMsgAddIeTV1(hMsg, NW_GTPV1U_IE_RECOVERY, 0x00); rc = nwGtpv1uMsgAddIeTV1(hMsg, NW_GTPV1U_IE_RECOVERY, 0x00);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
GTPU_INFO("Sending NW_GTP_ECHO_RSP message to %x:%x with seq %u\n", GTPU_INFO("Sending NW_GTP_ECHO_RSP message to %x:%x with seq %u\n",
peerIp, peerIp,
...@@ -672,10 +622,8 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz, ...@@ -672,10 +622,8 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
peerIp, peerIp,
peerPort, peerPort,
(NwGtpv1uMsgT *) hMsg); (NwGtpv1uMsgT *) hMsg);
rc = nwGtpv1uMsgDelete((NwGtpv1uStackHandleT)thiz, hMsg); rc = nwGtpv1uMsgDelete((NwGtpv1uStackHandleT)thiz, hMsg);
NW_ASSERT(NW_GTPV1U_OK == rc); NW_ASSERT(NW_GTPV1U_OK == rc);
return rc; return rc;
} }
...@@ -688,11 +636,9 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz, ...@@ -688,11 +636,9 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
*--------------------------------------------------------------------------*/ *--------------------------------------------------------------------------*/
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t stackType) nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t stackType) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz; NwGtpv1uStackT *thiz;
thiz = (NwGtpv1uStackT *) malloc( sizeof(NwGtpv1uStackT)); thiz = (NwGtpv1uStackT *) malloc( sizeof(NwGtpv1uStackT));
if(thiz) { if(thiz) {
...@@ -714,7 +660,6 @@ nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t st ...@@ -714,7 +660,6 @@ nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t st
rc = NW_GTPV1U_FAILURE; rc = NW_GTPV1U_FAILURE;
} }
*hGtpuStackHandle = (NwGtpv1uStackHandleT) thiz; *hGtpuStackHandle = (NwGtpv1uStackHandleT) thiz;
return rc; return rc;
} }
...@@ -725,8 +670,7 @@ nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t st ...@@ -725,8 +670,7 @@ nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t st
*--------------------------------------------------------------------------*/ *--------------------------------------------------------------------------*/
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uFinalize( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle) nwGtpv1uFinalize( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
if(hGtpuStackHandle) { if(hGtpuStackHandle) {
...@@ -746,8 +690,7 @@ nwGtpv1uFinalize( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle) ...@@ -746,8 +690,7 @@ nwGtpv1uFinalize( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle)
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uSetUlpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, nwGtpv1uSetUlpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uUlpEntityT *pUlpEntity) NW_IN NwGtpv1uUlpEntityT *pUlpEntity) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle; NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
...@@ -764,8 +707,7 @@ nwGtpv1uSetUlpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -764,8 +707,7 @@ nwGtpv1uSetUlpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uSetUdpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, nwGtpv1uSetUdpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uUdpEntityT *pUdpEntity) NW_IN NwGtpv1uUdpEntityT *pUdpEntity) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle; NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
...@@ -781,8 +723,7 @@ nwGtpv1uSetUdpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -781,8 +723,7 @@ nwGtpv1uSetUdpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uSetMemMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, nwGtpv1uSetMemMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uMemMgrEntityT *pMemMgrEntity) NW_IN NwGtpv1uMemMgrEntityT *pMemMgrEntity) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle; NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
...@@ -799,8 +740,7 @@ nwGtpv1uSetMemMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -799,8 +740,7 @@ nwGtpv1uSetMemMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uSetTimerMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, nwGtpv1uSetTimerMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uTimerMgrEntityT *pTmrMgrEntity) NW_IN NwGtpv1uTimerMgrEntityT *pTmrMgrEntity) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle; NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
...@@ -817,8 +757,7 @@ nwGtpv1uSetTimerMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -817,8 +757,7 @@ nwGtpv1uSetTimerMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uSetLogMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, nwGtpv1uSetLogMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uLogMgrEntityT *pLogMgrEntity) NW_IN NwGtpv1uLogMgrEntityT *pLogMgrEntity) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle; NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
...@@ -834,8 +773,7 @@ nwGtpv1uSetLogMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -834,8 +773,7 @@ nwGtpv1uSetLogMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uSetLogLevel( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, nwGtpv1uSetLogLevel( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint32_t logLevel) NW_IN uint32_t logLevel) {
{
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle; NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
thiz->logLevel = logLevel; thiz->logLevel = logLevel;
return NW_GTPV1U_OK; return NW_GTPV1U_OK;
...@@ -850,19 +788,15 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -850,19 +788,15 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint8_t *udpData, NW_IN uint8_t *udpData,
NW_IN uint32_t udpDataLen, NW_IN uint32_t udpDataLen,
NW_IN uint16_t peerPort, NW_IN uint16_t peerPort,
NW_IN uint32_t peerIp) NW_IN uint32_t peerIp) {
{
NwGtpv1uRcT ret = NW_GTPV1U_FAILURE; NwGtpv1uRcT ret = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz; NwGtpv1uStackT *thiz;
uint16_t msgType; uint16_t msgType;
#if defined(ENB_MODE) #if defined(ENB_MODE)
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_UDP_REQ, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_UDP_REQ, VCD_FUNCTION_IN);
#endif #endif
thiz = (NwGtpv1uStackT *) hGtpuStackHandle; thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
NW_ASSERT(thiz); NW_ASSERT(thiz);
msgType = *((uint8_t *)(udpData + 1)); msgType = *((uint8_t *)(udpData + 1));
switch(msgType) { switch(msgType) {
...@@ -881,7 +815,6 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -881,7 +815,6 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
peerPort, peerPort,
udpData, udpData,
udpDataLen); udpDataLen);
NW_ASSERT(ret == NW_GTPV1U_OK); NW_ASSERT(ret == NW_GTPV1U_OK);
break; break;
...@@ -899,10 +832,12 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -899,10 +832,12 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
case NW_GTP_END_MARKER: case NW_GTP_END_MARKER:
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
for(int i =1; i<= udpDataLen; i++){ for(int i =1; i<= udpDataLen; i++) {
printf("%02x ", udpData[i-1]); printf("%02x ", udpData[i-1]);
if(i % 20 == 0)printf("\n"); if(i % 20 == 0)printf("\n");
} }
#endif #endif
GTPU_INFO("NW_GTP_END_MARKER\n"); GTPU_INFO("NW_GTP_END_MARKER\n");
ret = nwGtpv1uProcessGpdu(thiz, udpData, udpDataLen, peerIp); ret = nwGtpv1uProcessGpdu(thiz, udpData, udpDataLen, peerIp);
...@@ -930,14 +865,11 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -930,14 +865,11 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uUlpApiT *pUlpReq) NW_IN NwGtpv1uUlpApiT *pUlpReq) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle; NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
NW_ASSERT(thiz); NW_ASSERT(thiz);
NW_ASSERT(pUlpReq != NULL); NW_ASSERT(pUlpReq != NULL);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz); NW_ENTER(thiz);
#endif #endif
...@@ -989,25 +921,18 @@ nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, ...@@ -989,25 +921,18 @@ nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
*--------------------------------------------------------------------------*/ *--------------------------------------------------------------------------*/
NwGtpv1uRcT NwGtpv1uRcT
nwGtpv1uProcessTimeout(void *timeoutInfo) nwGtpv1uProcessTimeout(void *timeoutInfo) {
{
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE; NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz; __attribute__ ((unused)) NwGtpv1uStackT *thiz;
NW_ASSERT(timeoutInfo != NULL); NW_ASSERT(timeoutInfo != NULL);
thiz = (NwGtpv1uStackT *) (((NwGtpv1uTimeoutInfoT *) timeoutInfo)->hStack); thiz = (NwGtpv1uStackT *) (((NwGtpv1uTimeoutInfoT *) timeoutInfo)->hStack);
NW_ASSERT(thiz != NULL); NW_ASSERT(thiz != NULL);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz); NW_ENTER(thiz);
#endif #endif
GTPU_DEBUG("Received timeout event from ULP with timeoutInfo 0x%p!\n", GTPU_DEBUG("Received timeout event from ULP with timeoutInfo 0x%p!\n",
timeoutInfo); timeoutInfo);
rc = (((NwGtpv1uTimeoutInfoT *) timeoutInfo)->timeoutCallbackFunc) (timeoutInfo); rc = (((NwGtpv1uTimeoutInfoT *) timeoutInfo)->timeoutCallbackFunc) (timeoutInfo);
#if defined(LOG_GTPU) && LOG_GTPU > 0 #if defined(LOG_GTPU) && LOG_GTPU > 0
NW_LEAVE(thiz); NW_LEAVE(thiz);
#endif #endif
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
#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++) { for (int i = 0; i < networks.size; i++) {
if (strcmp(networks.items[i].conf.mcc, mcc) == 0) { if (strcmp(networks.items[i].conf.mcc, mcc) == 0) {
if (strcmp(networks.items[i].conf.mnc, mnc) == 0) { if (strcmp(networks.items[i].conf.mnc, mnc) == 0) {
...@@ -17,36 +18,34 @@ int get_plmn_index(const char * mccmnc, const networks_t networks) { ...@@ -17,36 +18,34 @@ int get_plmn_index(const char * mccmnc, const networks_t networks) {
} }
} }
} }
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); snprintf(num, 6, "%s%s", plmn_conf->mcc, plmn_conf->mnc);
plmn.MCCdigit2 = plmn_conf->mcc[1]; plmn.MCCdigit2 = plmn_conf->mcc[1];
plmn.MCCdigit1 = plmn_conf->mcc[0]; plmn.MCCdigit1 = plmn_conf->mcc[0];
plmn.MCCdigit3 = plmn_conf->mcc[2]; plmn.MCCdigit3 = plmn_conf->mcc[2];
plmn.MNCdigit2 = plmn_conf->mnc[1]; plmn.MNCdigit2 = plmn_conf->mnc[1];
plmn.MNCdigit1 = plmn_conf->mnc[0]; plmn.MNCdigit1 = plmn_conf->mnc[0];
if (strlen(plmn_conf->mnc) > 2) { if (strlen(plmn_conf->mnc) > 2) {
plmn.MNCdigit3 = 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->plmn = make_plmn_from_conf(conf);
record->tac_end = 0xfffd; record->tac_end = 0xfffd;
record->tac_start = 0x0001; record->tac_start = 0x0001;
...@@ -55,46 +54,54 @@ void gen_network_record_from_conf(const plmn_conf_param_t *conf, network_record_ ...@@ -55,46 +54,54 @@ void gen_network_record_from_conf(const plmn_conf_param_t *conf, network_record_
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) { if (rc != 1) {
printf("Error on FULLNAME\n"); printf("Error on FULLNAME\n");
return false; return false;
} }
rc = config_setting_lookup_string(plmn_setting, SHORTNAME, &conf->shortname); rc = config_setting_lookup_string(plmn_setting, SHORTNAME, &conf->shortname);
if (rc != 1) { if (rc != 1) {
printf("Error on SHORTNAME\n"); printf("Error on SHORTNAME\n");
return false; return false;
} }
rc = config_setting_lookup_string(plmn_setting, MNC, &conf->mnc); rc = config_setting_lookup_string(plmn_setting, MNC, &conf->mnc);
if (rc != 1 || strlen(conf->mnc) > 3 if (rc != 1 || strlen(conf->mnc) > 3
|| strlen(conf->mnc) < 2) { || strlen(conf->mnc) < 2) {
printf("Error ond MNC. Exiting\n"); printf("Error ond MNC. Exiting\n");
return false; return false;
} }
rc = config_setting_lookup_string(plmn_setting, MCC, &conf->mcc); rc = config_setting_lookup_string(plmn_setting, MCC, &conf->mcc);
if (rc != 1 || strlen(conf->mcc) != 3) { if (rc != 1 || strlen(conf->mcc) != 3) {
printf("Error on MCC\n"); printf("Error on MCC\n");
return false; return false;
} }
return true; 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->size = size;
networks->items = malloc(sizeof(network_t) * 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;
...@@ -103,9 +110,11 @@ bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) { ...@@ -103,9 +110,11 @@ bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) {
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); gen_network_record_from_conf(&network->conf, &network->record);
network->plmn = network->record.plmn; network->plmn = network->record.plmn;
} }
return true; return true;
} }
......
...@@ -9,24 +9,23 @@ ...@@ -9,24 +9,23 @@
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); root_setting = config_root_setting(&cfg);
ue_nb = config_setting_length(root_setting) - 1; ue_nb = config_setting_length(root_setting) - 1;
all_plmn_setting = config_setting_get_member(root_setting, PLMN); all_plmn_setting = config_setting_get_member(root_setting, PLMN);
if (all_plmn_setting == NULL) { if (all_plmn_setting == NULL) {
printf("NO PLMN SECTION...EXITING...\n"); printf("NO PLMN SECTION...EXITING...\n");
return (false); return (false);
...@@ -38,18 +37,14 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou ...@@ -38,18 +37,14 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou
for (int i = 0; i < ue_nb; i++) { for (int i = 0; i < ue_nb; i++) {
emm_nvdata_t emm_data; emm_nvdata_t emm_data;
user_nvdata_t user_data; user_nvdata_t user_data;
user_data_conf_t user_data_conf; user_data_conf_t user_data_conf;
usim_data_t usim_data; usim_data_t usim_data;
usim_data_conf_t usim_data_conf; usim_data_conf_t usim_data_conf;
user_plmns_t user_plmns; user_plmns_t user_plmns;
sprintf(user, "%s%d", UE, i); sprintf(user, "%s%d", UE, i);
ue_setting = config_setting_get_member(root_setting, user); ue_setting = config_setting_get_member(root_setting, user);
if (ue_setting == NULL) { if (ue_setting == NULL) {
printf("Check UE%d settings\n", i); printf("Check UE%d settings\n", i);
return false; return false;
...@@ -60,19 +55,21 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou ...@@ -60,19 +55,21 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou
} }
rc = parse_ue_user_data(ue_setting, i, &user_data_conf); rc = parse_ue_user_data(ue_setting, i, &user_data_conf);
if (rc != true) { if (rc != true) {
printf("Problem in USER section for UE%d. EXITING...\n", i); printf("Problem in USER section for UE%d. EXITING...\n", i);
return false; return false;
} }
gen_user_data(&user_data_conf, &user_data);
gen_user_data(&user_data_conf, &user_data);
rc = parse_ue_sim_param(ue_setting, i, &usim_data_conf); rc = parse_ue_sim_param(ue_setting, i, &usim_data_conf);
if (rc != true) { if (rc != true) {
printf("Problem in SIM section for UE%d. EXITING...\n", i); printf("Problem in SIM section for UE%d. EXITING...\n", i);
return false; return false;
} }
gen_usim_data(&usim_data_conf, &usim_data, &user_plmns, networks);
gen_usim_data(&usim_data_conf, &usim_data, &user_plmns, networks);
gen_emm_data(&emm_data, usim_data_conf.hplmn, usim_data_conf.msin, gen_emm_data(&emm_data, usim_data_conf.hplmn, usim_data_conf.msin,
&user_plmns.equivalents_home, networks); &user_plmns.equivalents_home, networks);
...@@ -89,8 +86,8 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou ...@@ -89,8 +86,8 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou
} }
user_plmns_free(&user_plmns); user_plmns_free(&user_plmns);
} }
free(networks.items); free(networks.items);
networks.size=0; networks.size=0;
config_destroy(&cfg); config_destroy(&cfg);
...@@ -99,6 +96,7 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou ...@@ -99,6 +96,7 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou
bool get_config_from_file(const char *filename, config_t *config) { bool get_config_from_file(const char *filename, config_t *config) {
config_init(config); config_init(config);
if (filename == NULL) { if (filename == NULL) {
// XXX write error message ? // XXX write error message ?
return(false); return(false);
...@@ -108,12 +106,15 @@ bool get_config_from_file(const char *filename, config_t *config) { ...@@ -108,12 +106,15 @@ bool get_config_from_file(const char *filename, config_t *config) {
if (!config_read_file(config, filename)) { if (!config_read_file(config, filename)) {
fprintf(stderr, "Cant read config file '%s': %s\n", filename, fprintf(stderr, "Cant read config file '%s': %s\n", filename,
config_error_text(config)); config_error_text(config));
if ( config_error_type(config) == CONFIG_ERR_PARSE ) { if ( config_error_type(config) == CONFIG_ERR_PARSE ) {
fprintf(stderr, "This is line %d\n", config_error_line(config)); fprintf(stderr, "This is line %d\n", config_error_line(config));
} }
config_destroy(config); config_destroy(config);
return (false); return (false);
} }
return true; 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