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()
#set(CMAKE_BUILD_TYPE "Debug")
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
set(CMAKE_BUILD_TYPE "Release")
endif()
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)
......@@ -330,14 +330,14 @@ add_custom_target (
${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" "NR_" "-findirect-choice"
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}
${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c
)
add_dependencies(NR_RRC_LIB nr_rrc_flag)
include_directories ("${NR_RRC_FULL_DIR}")
# S1AP
# Same limitation as described in RRC: unknown generated file list
# so we generate it at cmake time
......@@ -371,6 +371,8 @@ add_library(S1AP_LIB
${S1AP_DIR}/s1ap_common.c
)
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_DIR}")
......@@ -424,6 +426,8 @@ add_library(X2AP_LIB
${X2AP_DIR}/x2ap_common.c
)
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_DIR}")
......@@ -447,7 +451,7 @@ add_dependencies(X2AP_ENB rrc_flag x2_flag)
add_list1_option(F1AP_RELEASE R15 "F1AP ASN.1 grammar version" R15)
set(F1AP_DIR ${OPENAIR2_DIR}/F1AP)
if (${F1AP_RELEASE} STREQUAL "R15")
make_version(F1AP_VERSION 15 2 1)
make_version(_VERSION 15 2 1)
set (ASN1RELDIR R15.2.1)
endif(${F1AP_RELEASE} STREQUAL "R15")
add_definitions(-DF1AP_VERSION=${F1AP_VERSION})
......@@ -477,7 +481,8 @@ file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c)
add_library(F1AP_LIB
${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_DIR}")
......
......@@ -91,8 +91,11 @@ Options
-i | --install-system-files
Install OpenAirInterface required files in Linux system
This option will require root password
-g | --run-with-gdb
Add debugging symbols to compilation directives. It also disables any compiler optimization. Only for debugging. Do not use in normal operation!
-g | --run-with-gdb <Release | RelWithDebInfo | MinSizeRel | Debug
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
Makes the LTE softmodem
--gNB
......@@ -193,10 +196,41 @@ function main() {
echo_info "Will copy OpenAirInterface files in Linux directories"
shift;;
-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
CMAKE_BUILD_TYPE="Debug"
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;;
--eNB)
eNB=1
......
......@@ -39,28 +39,26 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
unsigned char symbol,
unsigned char Ns,
int sample_offset,
int no_prefix)
{
int no_prefix) {
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
NR_UE_COMMON *common_vars = &ue->common_vars;
unsigned char aa;
unsigned int nb_prefix_samples;
unsigned int nb_prefix_samples0;
if (ue->is_synchronized) {
nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
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_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
}
//unsigned int subframe_offset;//,subframe_offset_F;
unsigned int slot_offset;
//int i;
unsigned int frame_length_samples = frame_parms->samples_per_subframe * 10;
unsigned int rx_offset;
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
......@@ -102,6 +100,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
break;
default:
dft=0;
printf("unsupported ofdm symbol size \n");
assert(0);
}
......@@ -124,11 +123,9 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
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));
rx_offset = sample_offset + slot_offset + nb_prefix_samples0 - SOFFSET;
// Align with 256 bit
// rx_offset = rx_offset&0xfffffff8;
#ifdef DEBUG_FEP
// 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",
......@@ -136,10 +133,9 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
#endif
if (symbol==0) {
if (rx_offset > (frame_length_samples - frame_parms->ofdm_symbol_size))
memcpy((short*) &common_vars->rxdata[aa][frame_length_samples],
(short*) &common_vars->rxdata[aa][0],
memcpy((short *) &common_vars->rxdata[aa][frame_length_samples],
(short *) &common_vars->rxdata[aa][0],
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
......@@ -152,7 +148,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
#if UE_TIMING_TRACE
start_meas(&ue->rx_dft_stats);
#endif
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);
#if UE_TIMING_TRACE
......@@ -160,7 +155,6 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
#endif
}
} else {
rx_offset += (frame_parms->ofdm_symbol_size+nb_prefix_samples)*symbol;
// + (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1);
......@@ -168,6 +162,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
memcpy((void *) &common_vars->rxdata[aa][frame_length_samples],
(void *) &common_vars->rxdata[aa][0],
frame_parms->ofdm_symbol_size*sizeof(int));
#if UE_TIMING_TRACE
start_meas(&ue->rx_dft_stats);
#endif
......@@ -179,24 +174,21 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
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);
} else { // use dft input from RX buffer directly
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);
}
#if UE_TIMING_TRACE
stop_meas(&ue->rx_dft_stats);
#endif
}
#ifdef DEBUG_FEP
#ifdef DEBUG_FEP
// 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);
#endif
#endif
}
#ifdef DEBUG_FEP
printf("slot_fep: done\n");
#endif
......@@ -210,14 +202,11 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
unsigned char symbol,
unsigned char Ns,
int sample_offset,
int no_prefix)
{
int no_prefix) {
uint32_t slot_offset;
uint32_t rxdata_offset;
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);
void (*dft)(int16_t *,int16_t *, int);
switch (frame_parms->ofdm_symbol_size) {
......@@ -260,7 +249,6 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
slot_offset = Ns * frame_parms->samples_per_slot;
if(symbol == 0)
rxdata_offset = slot_offset + nb_prefix_samples0 - SOFFSET;
else
......@@ -268,6 +256,5 @@ int nr_slot_fep_ul(NR_DL_FRAME_PARMS *frame_parms,
dft((int16_t *)&rxdata[rxdata_offset],
(int16_t *)&rxdataF[symbol * frame_parms->ofdm_symbol_size], 1);
return(0);
}
......@@ -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_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_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;
int i;
LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability;
......
......@@ -51,8 +51,8 @@
#include "gtpv1u.h"
#if defined(ENB_MODE)
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#endif
#ifdef __cplusplus
......@@ -68,8 +68,7 @@ extern "C" {
void
nwGtpv1uDisplayBanner(void)
{
nwGtpv1uDisplayBanner(void) {
printf(" *----------------------------------------------------------------------------*\n");
printf(" * *\n");
printf(" * n w - g t p v 2 u *\n");
......@@ -102,7 +101,6 @@ nwGtpv1uDisplayBanner(void)
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(" *----------------------------------------------------------------------------*\n\n");
}
/*---------------------------------------------------------------------------
* RBTree Search Functions
......@@ -144,8 +142,7 @@ RB_GENERATE(NwGtpv1uTunnelEndPointIdentifierMap, NwGtpv1uTunnelEndPoint,
static inline NwS32T
nwGtpv1uCompareTeid(struct NwGtpv1uTunnelEndPoint *a,
struct NwGtpv1uTunnelEndPoint *b)
{
struct NwGtpv1uTunnelEndPoint *b) {
if(a->teid > b->teid) {
return 1;
}
......@@ -167,8 +164,7 @@ nwGtpv1uCompareTeid(struct NwGtpv1uTunnelEndPoint *a,
*/
static inline NwS32T
nwGtpv1uCompareSeqNum(struct NwGtpv1uTrxn *a, struct NwGtpv1uTrxn *b)
{
nwGtpv1uCompareSeqNum(struct NwGtpv1uTrxn *a, struct NwGtpv1uTrxn *b) {
if(a->seqNum > b->seqNum) {
return 1;
}
......@@ -197,31 +193,24 @@ nwGtpv1uCompareSeqNum(struct NwGtpv1uTrxn *a, struct NwGtpv1uTrxn *b)
static NwGtpv1uRcT
nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPort,
NwGtpv1uMsgT *pMsg)
{
NwGtpv1uMsgT *pMsg) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
uint8_t *msgHdr;
NW_ASSERT(thiz);
NW_ASSERT(pMsg);
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz);
#endif
msgHdr = &pMsg->msgBuf[pMsg->msgBufOffset];
NW_ASSERT(msgHdr != NULL);
*(msgHdr++) = (pMsg->version << 5) |
(pMsg->protocolType << 4) |
(pMsg->extHdrFlag << 2) |
(pMsg->seqNumFlag << 1) |
(pMsg->npduNumFlag);
*(msgHdr++) = (pMsg->msgType);
*((uint16_t *) msgHdr) = htons(pMsg->msgLen);
msgHdr += 2;
*((uint32_t *) msgHdr) = htonl(pMsg->teid);
msgHdr += 4;
#if defined(LOG_GTPU) && LOG_GTPU > 0
......@@ -234,10 +223,8 @@ nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPo
if(pMsg->seqNumFlag || pMsg->extHdrFlag || pMsg->npduNumFlag) {
*((uint16_t *) msgHdr) = (pMsg->seqNumFlag ? htons(pMsg->seqNum) : 0x0000);
msgHdr += 2;
*((uint8_t *) msgHdr) = (pMsg->npduNumFlag ? htons(pMsg->npduNum) : 0x00);
msgHdr++;
*((uint8_t *) msgHdr) = (pMsg->extHdrFlag ? htons(pMsg->nextExtHdrType) : 0x00);
msgHdr++;
}
......@@ -248,7 +235,6 @@ nwGtpv1uCreateAndSendMsg( NwGtpv1uStackT *thiz, uint32_t peerIp, uint16_t peerPo
pMsg->msgBufOffset,
peerIp,
peerPort);
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_LEAVE(thiz);
#endif
......@@ -270,15 +256,12 @@ nwGtpv1uSendUlpMessageIndication( NW_IN NwGtpv1uStackT *thiz,
NW_IN uint32_t peerIp,
NW_IN uint16_t peerPort,
NW_IN uint8_t *pMsgBuf,
NW_IN uint16_t msgLength)
{
NW_IN uint16_t msgLength) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uUlpApiT ulpApi;
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz);
#endif
ulpApi.apiType = apiType;
ulpApi.apiInfo.recvMsgInfo.msgType = msgType;
ulpApi.apiInfo.recvMsgInfo.hUlpTrxn = hUlpTrxn;
......@@ -293,23 +276,18 @@ nwGtpv1uSendUlpMessageIndication( NW_IN NwGtpv1uStackT *thiz,
rc = thiz->ulp.ulpReqCallback(thiz->ulp.hUlp, &ulpApi);
NW_ASSERT(rc == NW_GTPV1U_OK);
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_LEAVE(thiz);
#endif
return rc;
}
NwGtpv1uRcT
nwGtpv1uPeerRspTimeout(void *arg)
{
nwGtpv1uPeerRspTimeout(void *arg) {
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTrxnT *thiz;
NwGtpv1uTimeoutInfoT *timeoutInfo = arg;
GTPU_WARNING( "Retransmission timer expired\n");
thiz = ((NwGtpv1uTrxnT *)timeoutInfo->timeoutArg);
rc = thiz->pStack->udp.udpDataReqCallback(thiz->pStack->udp.hUdp,
thiz->pMsg->msgBuf,
......@@ -346,23 +324,19 @@ static NwGtpv1uRcT
NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz,
NW_IN uint32_t teid,
NW_IN NwGtpv1uUlpSessionHandleT hUlpSession,
NW_OUT NwGtpv1uStackSessionHandleT *phStackSession )
{
NW_OUT NwGtpv1uStackSessionHandleT *phStackSession ) {
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTunnelEndPointT *pTunnelEndPoint;
NwGtpv1uTunnelEndPointT *pCollision;
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz);
#endif
pTunnelEndPoint = nwGtpTunnelEndPointNew(thiz);
if(pTunnelEndPoint) {
pTunnelEndPoint->teid = teid;
pTunnelEndPoint->pStack = thiz;
pTunnelEndPoint->hUlpSession = hUlpSession;
pCollision = RB_INSERT(NwGtpv1uTunnelEndPointIdentifierMap, &(thiz->teidMap),
pTunnelEndPoint);
......@@ -378,6 +352,7 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz,
*phStackSession = (NwGtpv1uStackSessionHandleT) pTunnelEndPoint;
pTunnelEndPoint = RB_FIND(NwGtpv1uTunnelEndPointIdentifierMap,
&(thiz->teidMap), pTunnelEndPoint);
//NW_ASSERT(pTunnelEndPoint);
if (!pTunnelEndPoint) {
GTPU_ERROR("Tunnel end-point cannot be NULL");
......@@ -387,7 +362,6 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz,
pTunnelEndPoint, (unsigned int)teid, (unsigned int)teid);
}
}
} else {
*phStackSession = (NwGtpv1uStackSessionHandleT) NULL;
rc = NW_GTPV1U_FAILURE;
......@@ -409,10 +383,9 @@ NwGtpv1uCreateTunnelEndPoint( NW_IN NwGtpv1uStackT *thiz,
static NwGtpv1uRcT
nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz,
NW_IN NwGtpv1uUlpApiT *pUlpReq)
{
NW_IN NwGtpv1uUlpApiT *pUlpReq) {
NwGtpv1uRcT rc = NW_GTPV1U_OK;
NwGtpv1uTunnelEndPointT *pRemovedTeid;
__attribute__ ((unused)) NwGtpv1uTunnelEndPointT *pRemovedTeid;
if(pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle) {
GTPU_DEBUG( "Destroying Tunnel end-point '%lx'",
......@@ -420,10 +393,8 @@ nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz,
pRemovedTeid = RB_REMOVE(NwGtpv1uTunnelEndPointIdentifierMap, &(thiz->teidMap),
(NwGtpv1uTunnelEndPointT *)(
pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle));
NW_ASSERT(pRemovedTeid == (NwGtpv1uTunnelEndPointT *)(
pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle));
rc = nwGtpTunnelEndPointDestroy(thiz,
(NwGtpv1uTunnelEndPointT *)
pUlpReq->apiInfo.destroyTunnelEndPointInfo.hStackSessionHandle);
......@@ -444,11 +415,9 @@ nwGtpv1uDestroyTunnelEndPoint( NwGtpv1uStackT *thiz,
*/
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;
NwGtpv1uTrxnT *pTrxn;
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz);
#endif
......@@ -487,23 +456,18 @@ nwGtpv1uInitialReq( NW_IN NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq)
*/
static NwGtpv1uRcT
nwGtpv1uSendto( NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq)
{
nwGtpv1uSendto( NwGtpv1uStackT *thiz, NW_IN NwGtpv1uUlpApiT *pUlpReq) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NW_ASSERT(thiz);
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz);
#endif
(void) nwGtpv1uMsgSetTeid(pUlpReq->apiInfo.sendtoInfo.hMsg,
pUlpReq->apiInfo.sendtoInfo.teid);
rc = nwGtpv1uCreateAndSendMsg(thiz,
pUlpReq->apiInfo.sendtoInfo.ipAddr,
2152,
(NwGtpv1uMsgT *) (NwGtpv1uMsgT *) pUlpReq->apiInfo.sendtoInfo.hMsg);
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_LEAVE(thiz);
#endif
......@@ -530,22 +494,17 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
NwGtpv1uTunnelEndPointT *pTunnelEndPoint = NULL;
NwGtpv1uTunnelEndPointT tunnelEndPointKey;
// uint16_t hdr_len = 0;
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz);
#endif
// no buffer offset
msgHdr = (NwGtpv1uMsgHeaderT *) gpdu;
tunnelEndPointKey.teid = ntohl(msgHdr->teid);
pTunnelEndPoint = RB_FIND(NwGtpv1uTunnelEndPointIdentifierMap,
&(thiz->teidMap), &tunnelEndPointKey);
if(pTunnelEndPoint) {
NwGtpv1uMsgHandleT hMsg;
rc = nwGtpv1uMsgFromBufferNew( (NwGtpv1uStackHandleT)thiz,
(uint8_t *)gpdu,
gpduLen,
......@@ -570,7 +529,6 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz,
" G-PDU ltid %u size %u",
tunnelEndPointKey.teid,
gpduLen);
rc = nwGtpSessionSendMsgApiToUlpEntity(pTunnelEndPoint, pMsg);
}
} else {
......@@ -604,15 +562,12 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
NW_IN uint8_t *msgBuf,
NW_IN uint32_t msgBufLen,
NW_IN uint16_t peerPort,
NW_IN uint32_t peerIp)
{
NW_IN uint32_t peerIp) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
uint16_t seqNum = 0;
NwGtpv1uMsgHandleT hMsg = 0;
int bufLen = 0;
seqNum = ntohs(*(uint16_t *) (msgBuf + (((*msgBuf) & 0x02) ? 8 : 4)));
MSC_LOG_RX_MESSAGE(
(thiz->stackType == GTPU_STACK_ENB) ? MSC_GTPU_ENB:MSC_GTPU_SGW,
(thiz->stackType == GTPU_STACK_ENB) ? MSC_GTPU_SGW:MSC_GTPU_ENB,
......@@ -621,7 +576,6 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
MSC_AS_TIME_FMT" ECHO-REQ seq %u size %u",
0,0,seqNum, msgBufLen);
/* Send Echo Response */
rc = nwGtpv1uMsgNew( (NwGtpv1uStackHandleT)thiz,
NW_TRUE, /* SeqNum flag */
NW_FALSE,
......@@ -632,28 +586,24 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
0,
0,
(&hMsg));
bufLen = sizeof(NwGtpv1uIeTv1T)+ ((NwGtpv1uMsgT*)hMsg)->msgLen;
//#warning CROUX DIRTY +16, TO BE FIXED!!!
bufLen = sizeof(NwGtpv1uIeTv1T)+ ((NwGtpv1uMsgT *)hMsg)->msgLen;
//#warning CROUX DIRTY +16, TO BE FIXED!!!
/* 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
* 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_UDP,
bufLen + 16 /* CROUX - dirty +16, to be fixed! */);
((NwGtpv1uMsgT*)hMsg)->msgBufLen = bufLen;
((NwGtpv1uMsgT *)hMsg)->msgBufLen = bufLen;
NW_ASSERT(NW_GTPV1U_OK == rc);
/*
* 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
* ignored by the receiver.
*/
rc = nwGtpv1uMsgAddIeTV1(hMsg, NW_GTPV1U_IE_RECOVERY, 0x00);
#if defined(LOG_GTPU) && LOG_GTPU > 0
GTPU_INFO("Sending NW_GTP_ECHO_RSP message to %x:%x with seq %u\n",
peerIp,
......@@ -672,10 +622,8 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
peerIp,
peerPort,
(NwGtpv1uMsgT *) hMsg);
rc = nwGtpv1uMsgDelete((NwGtpv1uStackHandleT)thiz, hMsg);
NW_ASSERT(NW_GTPV1U_OK == rc);
return rc;
}
......@@ -688,11 +636,9 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz,
*--------------------------------------------------------------------------*/
NwGtpv1uRcT
nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t stackType)
{
nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t stackType) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz;
thiz = (NwGtpv1uStackT *) malloc( sizeof(NwGtpv1uStackT));
if(thiz) {
......@@ -714,7 +660,6 @@ nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t st
rc = NW_GTPV1U_FAILURE;
}
*hGtpuStackHandle = (NwGtpv1uStackHandleT) thiz;
return rc;
}
......@@ -725,8 +670,7 @@ nwGtpv1uInitialize( NW_INOUT NwGtpv1uStackHandleT *hGtpuStackHandle, uint32_t st
*--------------------------------------------------------------------------*/
NwGtpv1uRcT
nwGtpv1uFinalize( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle)
{
nwGtpv1uFinalize( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
if(hGtpuStackHandle) {
......@@ -746,8 +690,7 @@ nwGtpv1uFinalize( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle)
NwGtpv1uRcT
nwGtpv1uSetUlpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uUlpEntityT *pUlpEntity)
{
NW_IN NwGtpv1uUlpEntityT *pUlpEntity) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
......@@ -764,8 +707,7 @@ nwGtpv1uSetUlpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT
nwGtpv1uSetUdpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uUdpEntityT *pUdpEntity)
{
NW_IN NwGtpv1uUdpEntityT *pUdpEntity) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
......@@ -781,8 +723,7 @@ nwGtpv1uSetUdpEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT
nwGtpv1uSetMemMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uMemMgrEntityT *pMemMgrEntity)
{
NW_IN NwGtpv1uMemMgrEntityT *pMemMgrEntity) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
......@@ -799,8 +740,7 @@ nwGtpv1uSetMemMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT
nwGtpv1uSetTimerMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uTimerMgrEntityT *pTmrMgrEntity)
{
NW_IN NwGtpv1uTimerMgrEntityT *pTmrMgrEntity) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
......@@ -817,8 +757,7 @@ nwGtpv1uSetTimerMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT
nwGtpv1uSetLogMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uLogMgrEntityT *pLogMgrEntity)
{
NW_IN NwGtpv1uLogMgrEntityT *pLogMgrEntity) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
......@@ -834,8 +773,7 @@ nwGtpv1uSetLogMgrEntity( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT
nwGtpv1uSetLogLevel( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint32_t logLevel)
{
NW_IN uint32_t logLevel) {
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
thiz->logLevel = logLevel;
return NW_GTPV1U_OK;
......@@ -850,19 +788,15 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN uint8_t *udpData,
NW_IN uint32_t udpDataLen,
NW_IN uint16_t peerPort,
NW_IN uint32_t peerIp)
{
NW_IN uint32_t peerIp) {
NwGtpv1uRcT ret = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz;
uint16_t msgType;
#if defined(ENB_MODE)
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_UDP_REQ, VCD_FUNCTION_IN);
#endif
thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
NW_ASSERT(thiz);
msgType = *((uint8_t *)(udpData + 1));
switch(msgType) {
......@@ -881,7 +815,6 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
peerPort,
udpData,
udpDataLen);
NW_ASSERT(ret == NW_GTPV1U_OK);
break;
......@@ -899,10 +832,12 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
case NW_GTP_END_MARKER:
#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]);
if(i % 20 == 0)printf("\n");
}
#endif
GTPU_INFO("NW_GTP_END_MARKER\n");
ret = nwGtpv1uProcessGpdu(thiz, udpData, udpDataLen, peerIp);
......@@ -930,14 +865,11 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NwGtpv1uRcT
nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
NW_IN NwGtpv1uUlpApiT *pUlpReq)
{
NW_IN NwGtpv1uUlpApiT *pUlpReq) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz = (NwGtpv1uStackT *) hGtpuStackHandle;
NW_ASSERT(thiz);
NW_ASSERT(pUlpReq != NULL);
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz);
#endif
......@@ -989,25 +921,18 @@ nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
*--------------------------------------------------------------------------*/
NwGtpv1uRcT
nwGtpv1uProcessTimeout(void *timeoutInfo)
{
nwGtpv1uProcessTimeout(void *timeoutInfo) {
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
NwGtpv1uStackT *thiz;
__attribute__ ((unused)) NwGtpv1uStackT *thiz;
NW_ASSERT(timeoutInfo != NULL);
thiz = (NwGtpv1uStackT *) (((NwGtpv1uTimeoutInfoT *) timeoutInfo)->hStack);
NW_ASSERT(thiz != NULL);
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_ENTER(thiz);
#endif
GTPU_DEBUG("Received timeout event from ULP with timeoutInfo 0x%p!\n",
timeoutInfo);
rc = (((NwGtpv1uTimeoutInfoT *) timeoutInfo)->timeoutCallbackFunc) (timeoutInfo);
#if defined(LOG_GTPU) && LOG_GTPU > 0
NW_LEAVE(thiz);
#endif
......
......@@ -3,13 +3,14 @@
#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 mnc[strlen(mccmnc) - 2];
strncpy(mcc, mccmnc, 3);
mcc[3] = '\0';
strncpy(mnc, mccmnc + 3, 3);
mnc[strlen(mccmnc) - 3] = '\0';
for (int i = 0; i < networks.size; i++) {
if (strcmp(networks.items[i].conf.mcc, mcc) == 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) {
}
}
}
return -1;
}
plmn_t make_plmn_from_conf(const plmn_conf_param_t *plmn_conf) {
plmn_t plmn;
char num[6];
memset(&plmn, 0xff, sizeof(plmn));
snprintf(num, 6, "%s%s", plmn_conf->mcc, plmn_conf->mnc);
plmn.MCCdigit2 = plmn_conf->mcc[1];
plmn.MCCdigit1 = plmn_conf->mcc[0];
plmn.MCCdigit3 = plmn_conf->mcc[2];
plmn.MNCdigit2 = plmn_conf->mnc[1];
plmn.MNCdigit1 = plmn_conf->mnc[0];
if (strlen(plmn_conf->mnc) > 2) {
plmn.MNCdigit3 = plmn_conf->mnc[2];
}
return plmn;
}
void gen_network_record_from_conf(const plmn_conf_param_t *conf, network_record_t *record) {
strcpy(record->fullname, conf->fullname);
strcpy(record->shortname, conf->shortname);
char num[6];
char num[10];
sprintf(num, "%s%s", conf->mcc, conf->mnc);
record->num = atoi(num);
record->plmn = make_plmn_from_conf(conf);
record->tac_end = 0xfffd;
record->tac_start = 0x0001;
......@@ -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) {
int rc = 0;
rc = config_setting_lookup_string(plmn_setting, FULLNAME, &conf->fullname);
if (rc != 1) {
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");
return false;
}
rc = config_setting_lookup_string(plmn_setting, MNC, &conf->mnc);
if (rc != 1 || strlen(conf->mnc) > 3
|| strlen(conf->mnc) < 2) {
printf("Error ond MNC. Exiting\n");
return false;
}
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) {
config_setting_t *plmn_setting = NULL;
char plmn[10];
char plmn[16];
int size = 0;
size = config_setting_length(all_plmn_setting);
networks->size = size;
networks->items = malloc(sizeof(network_t) * size);
for (int i = 0; i < size; i++) {
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];
sprintf(plmn, "%s%d", PLMN, i);
plmn_setting = config_setting_get_member(all_plmn_setting, plmn);
if (plmn_setting == NULL) {
printf("PLMN%d not fouund\n", i);
return false;
......@@ -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 ) {
return false;
}
gen_network_record_from_conf(&network->conf, &network->record);
network->plmn = network->record.plmn;
}
return true;
}
......
......@@ -9,24 +9,23 @@
bool parse_config_file(const char *output_dir, const char *conf_filename, int output_flags) {
int rc = true;
int ret;
int ue_nb = 0;
short ue_nb = 0;
config_setting_t *root_setting = NULL;
config_setting_t *ue_setting = NULL;
config_setting_t *all_plmn_setting = NULL;
char user[10];
char user[16];
config_t cfg;
networks_t networks;;
ret = get_config_from_file(conf_filename, &cfg);
if (ret == false) {
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);
......@@ -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++) {
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;
......@@ -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);
if (rc != true) {
printf("Problem in USER section for UE%d. EXITING...\n", i);
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);
if (rc != true) {
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_usim_data(&usim_data_conf, &usim_data, &user_plmns, networks);
gen_emm_data(&emm_data, usim_data_conf.hplmn, usim_data_conf.msin,
&user_plmns.equivalents_home, networks);
......@@ -89,8 +86,8 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou
}
user_plmns_free(&user_plmns);
}
free(networks.items);
networks.size=0;
config_destroy(&cfg);
......@@ -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) {
config_init(config);
if (filename == NULL) {
// XXX write error message ?
return(false);
......@@ -108,12 +106,15 @@ bool get_config_from_file(const char *filename, config_t *config) {
if (!config_read_file(config, filename)) {
fprintf(stderr, "Cant read config file '%s': %s\n", filename,
config_error_text(config));
if ( config_error_type(config) == CONFIG_ERR_PARSE ) {
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