Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
oai
openairinterface5G
Commits
d413de0a
Commit
d413de0a
authored
Oct 23, 2017
by
Cédric Roux
Browse files
Merge remote-tracking branch 'origin/RU-RAU-split' into develop
parents
61234aae
b4a48e19
Changes
314
Hide whitespace changes
Inline
Side-by-side
cmake_targets/CMakeLists.txt
View file @
d413de0a
...
...
@@ -27,6 +27,8 @@ cmake_minimum_required (VERSION 2.8)
# Base directories, compatible with legacy OAI building
################################################
set
(
OPENAIR_DIR $ENV{OPENAIR_DIR}
)
#set (NFAPI_DIR $ENV{NFAPI_DIR})
set
(
NFAPI_DIR
${
OPENAIR_DIR
}
/nfapi
)
set
(
OPENAIR1_DIR
${
OPENAIR_DIR
}
/openair1
)
set
(
OPENAIR2_DIR
${
OPENAIR_DIR
}
/openair2
)
set
(
OPENAIR3_DIR
${
OPENAIR_DIR
}
/openair3
)
...
...
@@ -310,11 +312,11 @@ if (NOT ${ret} STREQUAL 0)
message
(
FATAL_ERROR
"
${
fix_asn1c_call
}
: error"
)
endif
(
NOT
${
ret
}
STREQUAL 0
)
file
(
GLOB rrc_source
${
RRC_FULL_DIR
}
/*.c
)
set
(
rrc_source
${
rrc_source
}
${
OPENAIR2_DIR
}
/RRC/LITE/MESSAGES/asn1_msg.c
)
file
(
GLOB rrc_h
${
RRC_FULL_DIR
}
/*.h
)
set
(
rrc_h
${
rrc_h
}
${
RRC_FULL_DIR
}
/asn1_constants.h
)
set_source_files_properties
(
${
rrc_source
}
PROPERTIES COMPILE_FLAGS -w
)
# suppress warnings from generated code
add_library
(
RRC_LIB
${
rrc_h
}
${
rrc_source
}
)
add_library
(
RRC_LIB
${
rrc_h
}
${
rrc_source
}
${
OPENAIR2_DIR
}
/RRC/LITE/MESSAGES/asn1_msg.c
)
include_directories
(
"
${
RRC_FULL_DIR
}
"
)
# add the command to generate the source code
...
...
@@ -487,8 +489,24 @@ add_list1_option(NB_ANTENNAS_TXRX "2" "Number of antennas in ????" "1" "2" "4")
add_list2_option
(
RF_BOARD
"EXMIMO"
"RF head type"
"None"
"EXMIMO"
"OAI_USRP"
"OAI_BLADERF"
"CPRIGW"
"OAI_LMSSDR"
)
add_list2_option
(
TRANSP_PRO
"None"
"Transport protocol type"
"None"
"ETHERNET"
)
#NOKIA config enhancement
set
(
CONFIG_ROOTDIR
${
OPENAIR_DIR
}
/common/config
)
set
(
CONFIG_SOURCES
${
CONFIG_ROOTDIR
}
/config_load_configmodule.c
${
CONFIG_ROOTDIR
}
/config_userapi.c
${
CONFIG_ROOTDIR
}
/config_cmdline.c
)
set
(
CONFIG_LIBCONFIG_SOURCES
${
CONFIG_ROOTDIR
}
/libconfig/config_libconfig.c
)
add_library
(
params_libconfig MODULE
${
CONFIG_LIBCONFIG_SOURCES
}
)
target_link_libraries
(
params_libconfig config
)
# shared library loader
set
(
SHLIB_LOADER_SOURCES
${
OPENAIR_DIR
}
/common/utils/load_module_shlib.c
)
# include RF devices / transport protocols library modules
######################################################################
...
...
@@ -546,6 +564,15 @@ add_library(oai_mobipass MODULE ${TPLIB_MOBIPASS_SOURCE} )
get_target_property
(
mobipas_cflags oai_mobipass COMPILE_FLAGS
)
set_target_properties
(
oai_mobipass PROPERTIES COMPILE_FLAGS
"
${
mobipass_cflags
}
-fvisibility=hidden"
)
set
(
HWLIB_TCP_BRIDGE_SOURCE
${
OPENAIR_TARGETS
}
/ARCH/tcp_bridge/tcp_bridge.c
)
add_library
(
oai_tcp_bridge MODULE
${
HWLIB_TCP_BRIDGE_SOURCE
}
)
#get_target_property(tcp_bridge_cflags oai_tcp_bridge COMPILE_FLAGS)
#set_target_properties(oai_tcp_bridge PROPERTIES COMPILE_FLAGS "${tcp_bridge_cflags} -fvisibility=hidden")
set_target_properties
(
oai_tcp_bridge PROPERTIES COMPILE_FLAGS
"-fvisibility=hidden"
)
##########################################################
include_directories
(
"
${
OPENAIR_TARGETS
}
/ARCH/COMMON"
)
...
...
@@ -741,6 +768,7 @@ else()
include_directories
(
"
${
OPENAIR2_DIR
}
/UTIL"
)
include_directories
(
"
${
OPENAIR2_DIR
}
/UTIL/LOG"
)
endif
()
include_directories
(
"
${
NFAPI_DIR
}
"
)
include_directories
(
"
${
OPENAIR1_DIR
}
"
)
include_directories
(
"
${
OPENAIR2_DIR
}
/NAS"
)
include_directories
(
"
${
OPENAIR2_DIR
}
"
)
...
...
@@ -970,10 +998,12 @@ add_library(SECU_CN ${SECU_CN_SRC})
# Scheduler
################################"
set
(
SCHED_SRC
${
OPENAIR1_DIR
}
/SCHED/fapi_l1.c
${
OPENAIR1_DIR
}
/SCHED/phy_procedures_lte_eNb.c
${
OPENAIR1_DIR
}
/SCHED/phy_procedures_lte_ue.c
${
OPENAIR1_DIR
}
/SCHED/phy_procedures_lte_common.c
${
OPENAIR1_DIR
}
/SCHED/phy_mac_stub.c
${
OPENAIR1_DIR
}
/SCHED/ru_procedures.c
# ${OPENAIR1_DIR}/SCHED/phy_mac_stub.c
${
OPENAIR1_DIR
}
/SCHED/pucch_pc.c
${
OPENAIR1_DIR
}
/SCHED/pusch_pc.c
${
OPENAIR1_DIR
}
/SCHED/srs_pc.c
...
...
@@ -1002,6 +1032,7 @@ set(PHY_SRC
${
OPENAIR1_DIR
}
/PHY/LTE_TRANSPORT/lte_mcs.c
${
OPENAIR1_DIR
}
/PHY/LTE_TRANSPORT/pbch.c
${
OPENAIR1_DIR
}
/PHY/LTE_TRANSPORT/dci.c
${
OPENAIR1_DIR
}
/PHY/LTE_TRANSPORT/edci.c
${
OPENAIR1_DIR
}
/PHY/LTE_TRANSPORT/phich.c
${
OPENAIR1_DIR
}
/PHY/LTE_TRANSPORT/pcfich.c
${
OPENAIR1_DIR
}
/PHY/LTE_TRANSPORT/pucch.c
...
...
@@ -1054,7 +1085,6 @@ set(PHY_SRC
${
OPENAIR1_DIR
}
/PHY/CODING/3gpplte_turbo_decoder_sse_16bit.c
${
OPENAIR1_DIR
}
/PHY/CODING/3gpplte_turbo_decoder_avx2_16bit.c
${
OPENAIR1_DIR
}
/PHY/CODING/lte_rate_matching.c
${
OPENAIR1_DIR
}
/PHY/CODING/rate_matching.c
${
OPENAIR1_DIR
}
/PHY/CODING/viterbi.c
${
OPENAIR1_DIR
}
/PHY/CODING/viterbi_lte.c
${
OPENAIR1_DIR
}
/PHY/INIT/lte_init.c
...
...
@@ -1086,6 +1116,7 @@ add_library(PHY ${PHY_SRC})
#Layer 2 library
#####################
set
(
MAC_DIR
${
OPENAIR2_DIR
}
/LAYER2/MAC
)
set
(
PHY_INTERFACE_DIR
${
OPENAIR2_DIR
}
/PHY_INTERFACE
)
set
(
RLC_DIR
${
OPENAIR2_DIR
}
/LAYER2/RLC
)
set
(
RLC_UM_DIR
${
OPENAIR2_DIR
}
/LAYER2/RLC/UM_v9.3.0
)
set
(
RLC_AM_DIR
${
OPENAIR2_DIR
}
/LAYER2/RLC/AM_v9.3.0
)
...
...
@@ -1136,7 +1167,7 @@ set(L2_SRC
${
RRC_DIR
}
/L2_interface.c
)
set
(
MAC_SRC
${
M
AC_DIR
}
/
lte_transport_init
.c
${
PHY_INTERF
AC
E
_DIR
}
/
IF_Module
.c
${
MAC_DIR
}
/main.c
${
MAC_DIR
}
/ue_procedures.c
${
MAC_DIR
}
/ra_procedures.c
...
...
@@ -1571,6 +1602,7 @@ ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_tv_channel.c
${
OPENAIR1_DIR
}
/SIMULATION/RF/rf.c
${
OPENAIR1_DIR
}
/SIMULATION/RF/dac.c
${
OPENAIR1_DIR
}
/SIMULATION/RF/adc.c
${
OPENAIR1_DIR
}
/SIMULATION/ETH_TRANSPORT/netlink_init.c
)
add_library
(
SIMU_ETH
...
...
@@ -1578,7 +1610,7 @@ ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c
${
OPENAIR1_DIR
}
/SIMULATION/ETH_TRANSPORT/multicast_link.c
${
OPENAIR1_DIR
}
/SIMULATION/ETH_TRANSPORT/socket.c
${
OPENAIR1_DIR
}
/SIMULATION/ETH_TRANSPORT/bypass_session_layer.c
${
OPENAIR1_DIR
}
/SIMULATION/ETH_TRANSPORT/emu_transport.c
#
${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/emu_transport.c
${
OPENAIR1_DIR
}
/SIMULATION/ETH_TRANSPORT/pgm_link.c
)
...
...
@@ -1733,6 +1765,7 @@ add_executable(lte-softmodem
${
OPENAIR_TARGETS
}
/RT/USER/rt_wrapper.c
${
OPENAIR_TARGETS
}
/RT/USER/lte-ue.c
${
OPENAIR_TARGETS
}
/RT/USER/lte-enb.c
${
OPENAIR_TARGETS
}
/RT/USER/lte-ru.c
${
OPENAIR_TARGETS
}
/RT/USER/lte-softmodem.c
${
OPENAIR1_DIR
}
/SIMULATION/TOOLS/taus.c
${
OPENAIR_TARGETS
}
/SIMU/USER/init_lte.c
...
...
@@ -1747,9 +1780,11 @@ add_executable(lte-softmodem
${
XFORMS_SOURCE
}
${
XFORMS_SOURCE_SOFTMODEM
}
${
T_SOURCE
}
${
CONFIG_SOURCES
}
${
SHLIB_LOADER_SOURCES
}
)
target_link_libraries
(
lte-softmodem -ldl
target_link_libraries
(
lte-softmodem -ldl
-Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2
${
MSC_LIB
}
${
RAL_LIB
}
${
NAS_UE_LIB
}
${
ITTI_LIB
}
${
MIH_LIB
}
${
FLPT_MSG_LIB
}
${
ASYNC_IF_LIB
}
${
FLEXRAN_AGENT_LIB
}
LFDS7
-Wl,--end-group
)
...
...
@@ -1781,6 +1816,8 @@ add_executable(lte-softmodem-nos1
${
XFORMS_SOURCE
}
${
XFORMS_SOURCE_SOFTMODEM
}
${
T_SOURCE
}
${
CONFIG_SOURCES
}
${
SHLIB_LOADER_SOURCES
}
)
target_link_libraries
(
lte-softmodem-nos1
-Wl,--start-group
...
...
@@ -1848,7 +1885,7 @@ add_executable(oaisim
${
x2ap_h
}
${
OPENAIR_BIN_DIR
}
/messages_xml.h
${
OPENAIR_TARGETS
}
/RT/USER/lte-ue.c
${
OPENAIR_TARGETS
}
/RT/USER/lte-
enb
.c
${
OPENAIR_TARGETS
}
/RT/USER/lte-
ru
.c
${
OPENAIR_TARGETS
}
/RT/USER/rt_wrapper.c
${
OPENAIR_TARGETS
}
/SIMU/USER/channel_sim.c
${
OPENAIR_TARGETS
}
/SIMU/USER/init_lte.c
...
...
@@ -1868,13 +1905,15 @@ add_executable(oaisim
${
OPENAIR_TARGETS
}
/COMMON/create_tasks.c
${
XFORMS_SOURCE
}
${
T_SOURCE
}
${
CONFIG_SOURCES
}
${
SHLIB_LOADER_SOURCES
}
)
target_include_directories
(
oaisim PUBLIC
${
OPENAIR_TARGETS
}
/SIMU/USER
)
target_link_libraries
(
oaisim
-Wl,-ldl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS
${
MSC_LIB
}
L2
${
RAL_LIB
}
LIB_NAS_UE SIMU
SIMU_ETH
SECU_OSA
${
ITTI_LIB
}
${
MIH_LIB
}
RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB GTPV1U SECU_CN UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS
${
MSC_LIB
}
L2
${
RAL_LIB
}
LIB_NAS_UE SIMU SECU_OSA
${
ITTI_LIB
}
${
MIH_LIB
}
-Wl,--end-group
)
target_link_libraries
(
oaisim
${
LIBXML2_LIBRARIES
}
${
LAPACK_LIBRARIES
}
)
...
...
@@ -1911,11 +1950,13 @@ add_executable(oaisim_nos1
${
OPENAIR_DIR
}
/common/utils/system.c
${
XFORMS_SOURCE
}
${
T_SOURCE
}
${
CONFIG_SOURCES
}
${
SHLIB_LOADER_SOURCES
}
)
target_include_directories
(
oaisim_nos1 PUBLIC
${
OPENAIR_TARGETS
}
/SIMU/USER
)
target_link_libraries
(
oaisim_nos1
-Wl,--start-group
RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_LIB PHY LFDS
${
MSC_LIB
}
L2
${
RAL_LIB
}
SIMU
SIMU_ETH
SECU_OSA
${
ITTI_LIB
}
${
MIH_LIB
}
${
FLPT_MSG_LIB
}
${
ASYNC_IF_LIB
}
${
FLEXRAN_AGENT_LIB
}
LFDS7
RRC_LIB X2AP_LIB SECU_CN UTIL HASHTABLE SCHED_LIB PHY LFDS
${
MSC_LIB
}
L2
${
RAL_LIB
}
SIMU SECU_OSA
${
ITTI_LIB
}
${
MIH_LIB
}
${
FLPT_MSG_LIB
}
${
ASYNC_IF_LIB
}
${
FLEXRAN_AGENT_LIB
}
LFDS7
-Wl,--end-group
)
target_link_libraries
(
oaisim_nos1
${
LIBXML2_LIBRARIES
}
${
LAPACK_LIBRARIES
}
)
...
...
@@ -2032,7 +2073,7 @@ if (${T_TRACER})
oai_eth_transpro
FLPT_MSG ASYNC_IF FLEXRAN_AGENT HASHTABLE MSC UTIL OMG_SUMO SECU_OSA
SECU_CN SCHED_LIB PHY L2 default_sched remote_sched RAL MIH CN_UTILS
GTPV1U SCTP_CLIENT UDP LIB_NAS_UE LFDS LFDS7 SIMU
SIMU_ETH
OPENAIR0_LIB
)
GTPV1U SCTP_CLIENT UDP LIB_NAS_UE LFDS LFDS7 SIMU OPENAIR0_LIB
)
if
(
TARGET
${
i
}
)
add_dependencies
(
${
i
}
generate_T
)
endif
()
...
...
cmake_targets/autotests/v2/actions/3276.txt
0 → 100644
View file @
d413de0a
When running lsusb, if you have:
Bus 001 Device 002: ID 12d1:14fe Huawei Technologies Co., Ltd. Modem (Mass Storage Mode)
You need to run:
usb_modeswitch -v 12d1 -p 14fe -M '55534243123456780000000000000011062000000100000000000000000000'
After what, running lsusb should give:
Bus 001 Device 004: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
Values of 'Bus' and 'Device' may differ of course.
cmake_targets/autotests/v2/actions/bandrich.txt
View file @
d413de0a
...
...
@@ -13,6 +13,16 @@ containing lines:
SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MODEL_ID}=="100d", ENV{ID_SERIAL_SHORT}=="357473040068155", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="bandrich.data", MODE="0666"
SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MODEL_ID}=="100d", ENV{ID_SERIAL_SHORT}=="357473040068155", ENV{ID_USB_INTERFACE_NUM}=="02", SYMLINK+="bandrich.control", MODE="0666"
To avoid NetworkManager to play with the bandrich, add also the line:
ENV{ID_VENDOR_ID}=="1a8d", ENV{ID_MM_DEVICE_IGNORE}="1"
Maybe also add; , ENV{ID_MM_DEVICE_IGNORE}="1"
to the two other lines.
Then run: udevadm control --reload-rules
And: service network-manager restart
Change vendor_id/model_id/serial/interface num to match yours.
Use lsusb -v to find values.
...
...
cmake_targets/build_oai
View file @
d413de0a
...
...
@@ -345,7 +345,11 @@ function main() {
BUILD_ECLIPSE
=
1
CMAKE_CMD
=
"
$CMAKE_CMD
"
' -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE -G"Eclipse CDT4 - Unix Makefiles"'
echo_info
"Enabling build eclipse project support"
shift
1
;;
shift
1
;;
--build-telnetsrv
)
BUILD_TELNETSRV
=
1
echo_info
"Build embedded telnet server"
shift
;;
-h
|
--help
)
print_help
exit
1
;;
...
...
@@ -504,6 +508,9 @@ function main() {
lte_exec
=
lte-softmodem
fi
# configuration module libraries, one currently available, using libconfig
config_libconfig_shlib
=
params_libconfig
# first generate the CMakefile in the right directory
if
[
"
$eNB
"
=
"1"
-o
"
$UE
"
=
"1"
-o
"
$HW
"
=
"EXMIMO"
]
;
then
...
...
@@ -549,6 +556,11 @@ function main() {
$lte_build_dir
$lte_exec
\
$lte_exec
$dbin
/
$lte_exec
.
$REL
# mandatory shared lib
compilations
\
$lte_build_dir
$config_libconfig_shlib
\
lib
$config_libconfig_shlib
.so
$dbin
/lib
$config_libconfig_shlib
.so
if
[
"
$NOS1
"
=
"1"
]
;
then
compilations
\
$lte_build_dir
nasmesh
\
...
...
@@ -803,7 +815,22 @@ function main() {
rrh_gw
$dbin
/rrh_gw
fi
# Telnet server compilation
#####################
if
[
"
$BUILD_TELNETSRV
"
=
"1"
]
;
then
telnetsrv_build_dir
=
telnetsrv
mkdir
-p
$DIR
/
$telnetsrv_build_dir
/build
cd
$DIR
/
$telnetsrv_build_dir
/build
echo_info
"Compiling telnet server library ..."
[
"
$CLEAN
"
=
"1"
]
&&
rm
-rf
$DIR
/
$telnetsrv_build_dir
cmake_file
=
$OPENAIR_DIR
/common/utils/
$telnetsrv_build_dir
/CMakeLists.txt
cd
$DIR
/
$telnetsrv_build_dir
/build
eval
"
$CMAKE_CMD
$OPENAIR_DIR
/common/utils/
$telnetsrv_build_dir
/"
make
fi
# build RF device and transport protocol libraries
#####################################
if
[
"
$eNB
"
=
"1"
-o
"
$UE
"
=
"1"
-o
"
$RRH
"
=
"1"
]
;
then
...
...
@@ -829,11 +856,9 @@ function main() {
ln
-sf
$dbin
/liboai_exmimodevif.so.
$REL
$dbin
/liboai_device.so
echo_info
"liboai_device.so is linked to EXMIMO device library"
elif
[
"
$HW
"
==
"OAI_USRP"
]
;
then
if
[
-d
"/usr/include/uhd"
]
;
then
compilations
\
$build_dir
oai_usrpdevif
\
liboai_usrpdevif.so
$dbin
/liboai_usrpdevif.so.
$REL
fi
compilations
\
$build_dir
oai_usrpdevif
\
liboai_usrpdevif.so
$dbin
/liboai_usrpdevif.so.
$REL
ln
-sf
liboai_usrpdevif.so liboai_device.so
ln
-sf
$dbin
/liboai_usrpdevif.so.
$REL
$dbin
/liboai_device.so
...
...
common/config/config_cmdline.c
0 → 100644
View file @
d413de0a
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file common/config/cmdline/config_libconfig.c
* \brief configuration module, command line parsing implementation
* \author Francois TABURET
* \date 2017
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#include
<string.h>
#include
<stdlib.h>
#include
<stdio.h>
#include
<errno.h>
#include
"config_userapi.h"
int
processoption
(
paramdef_t
*
cfgoptions
,
char
*
value
)
{
char
*
tmpval
=
value
;
int
optisset
=
0
;
char
defbool
[
2
]
=
"1"
;
if
(
value
==
NULL
)
{
if
(
(
cfgoptions
->
paramflags
&
PARAMFLAG_BOOL
)
==
0
)
{
/* not a boolean, argument required */
fprintf
(
stderr
,
"[CONFIG] command line, option %s requires an argument
\n
"
,
cfgoptions
->
optname
);
return
0
;
}
else
{
/* boolean value option without argument, set value to true*/
tmpval
=
defbool
;
}
}
switch
(
cfgoptions
->
type
)
{
case
TYPE_STRING
:
config_check_valptr
(
cfgoptions
,
(
char
**
)(
cfgoptions
->
strptr
),
sizeof
(
char
*
));
config_check_valptr
(
cfgoptions
,
cfgoptions
->
strptr
,
strlen
(
tmpval
+
1
));
sprintf
(
*
(
cfgoptions
->
strptr
),
"%s"
,
tmpval
);
printf_cmdl
(
"[CONFIG] %s set to %s from command line
\n
"
,
cfgoptions
->
optname
,
tmpval
);
optisset
=
1
;
break
;
case
TYPE_STRINGLIST
:
break
;
case
TYPE_UINT32
:
case
TYPE_INT32
:
case
TYPE_UINT16
:
case
TYPE_INT16
:
case
TYPE_UINT8
:
case
TYPE_INT8
:
config_check_valptr
(
cfgoptions
,
(
char
**
)
&
(
cfgoptions
->
iptr
),
sizeof
(
int32_t
));
config_assign_int
(
cfgoptions
,
cfgoptions
->
optname
,(
int32_t
)
strtol
(
tmpval
,
NULL
,
0
));
optisset
=
1
;
break
;
case
TYPE_UINT64
:
case
TYPE_INT64
:
config_check_valptr
(
cfgoptions
,
(
char
**
)
&
(
cfgoptions
->
i64ptr
),
sizeof
(
uint64_t
));
*
(
cfgoptions
->
i64ptr
)
=
strtoll
(
tmpval
,
NULL
,
0
);
printf_cmdl
(
"[CONFIG] %s set to %lli from command line
\n
"
,
cfgoptions
->
optname
,
(
long
long
)
*
(
cfgoptions
->
i64ptr
));
optisset
=
1
;
break
;
case
TYPE_UINTARRAY
:
case
TYPE_INTARRAY
:
break
;
case
TYPE_DOUBLE
:
config_check_valptr
(
cfgoptions
,
(
char
**
)
&
(
cfgoptions
->
dblptr
),
sizeof
(
double
));
*
(
cfgoptions
->
dblptr
)
=
strtof
(
tmpval
,
NULL
);
printf_cmdl
(
"[CONFIG] %s set to %lf from command line
\n
"
,
cfgoptions
->
optname
,
*
(
cfgoptions
->
dblptr
));
optisset
=
1
;
break
;
case
TYPE_IPV4ADDR
:
break
;
default:
fprintf
(
stderr
,
"[CONFIG] command line, %s type %i not supported
\n
"
,
cfgoptions
->
optname
,
cfgoptions
->
type
);
break
;
}
/* switch on param type */
if
(
optisset
==
1
)
{
cfgoptions
->
paramflags
=
cfgoptions
->
paramflags
|
PARAMFLAG_PARAMSET
;
}
return
optisset
;
}
int
config_process_cmdline
(
paramdef_t
*
cfgoptions
,
int
numoptions
,
char
*
prefix
)
{
char
**
p
=
config_get_if
()
->
argv
;
int
c
=
config_get_if
()
->
argc
;
int
j
;
char
*
pp
;
char
*
cfgpath
;
j
=
(
prefix
==
NULL
)
?
0
:
strlen
(
prefix
);
cfgpath
=
malloc
(
j
+
MAX_OPTNAME_SIZE
+
1
);
if
(
cfgpath
==
NULL
)
{
fprintf
(
stderr
,
"[CONFIG] %s %i malloc error, %s
\n
"
,
__FILE__
,
__LINE__
,
strerror
(
errno
));
return
-
1
;
}
j
=
0
;
p
++
;
c
--
;
while
(
c
>
0
&&
*
p
!=
NULL
)
{
if
(
strcmp
(
*
p
,
"-h"
)
==
0
||
strcmp
(
*
p
,
"--help"
)
==
0
)
{
config_printhelp
(
cfgoptions
,
numoptions
);
}
if
(
*
p
[
0
]
==
'-'
)
{
for
(
int
i
=
0
;
i
<
numoptions
;
i
++
)
{
if
(
(
cfgoptions
[
i
].
paramflags
&
PARAMFLAG_DISABLECMDLINE
)
!=
0
)
{
continue
;
}
if
(
prefix
!=
NULL
)
{
sprintf
(
cfgpath
,
"%s.%s"
,
prefix
,
cfgoptions
[
i
].
optname
);
}
else
{
sprintf
(
cfgpath
,
"%s"
,
cfgoptions
[
i
].
optname
);
}
if
(
((
strlen
(
*
p
)
==
2
)
&&
(
strcmp
(
*
p
+
1
,
cfgpath
)
==
0
))
||
((
strlen
(
*
p
)
>
2
)
&&
(
strcmp
(
*
p
+
2
,
cfgpath
)
==
0
))
)
{
pp
=
*
(
p
+
1
);
if
(
(
pp
!=
NULL
)
&&
(
c
>
1
)
&&
(
pp
[
0
]
!=
'-'
)
)
{
j
+=
processoption
(
&
(
cfgoptions
[
i
]),
pp
);
}
else
{
j
+=
processoption
(
&
(
cfgoptions
[
i
]),
NULL
);
}
break
;
}
}
/* for */
}
/* if (*p[0] == '-') */
p
++
;
c
--
;
}
/* fin du while */
printf_cmdl
(
"[CONFIG] %s %i options set from command line
\n
"
,((
prefix
==
NULL
)
?
""
:
prefix
),
j
);
free
(
cfgpath
);
return
j
;
}
/* parse_cmdline*/
common/config/config_load_configmodule.c
0 → 100644
View file @
d413de0a
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file common/config/config_load_configmodule.c
* \brief configuration module, load the shared library implementing the configuration module
* \author Francois TABURET
* \date 2017
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#define _GNU_SOURCE
#include
<string.h>
#include
<stdlib.h>
#include
<stdio.h>
#include
<unistd.h>
#include
<errno.h>
#include
<dlfcn.h>
#define CONFIG_LOADCONFIG_MAIN
#include
"config_load_configmodule.h"
#include
"config_userapi.h"
#define CONFIG_SHAREDLIBFORMAT "libparams_%s.so"
int
load_config_sharedlib
(
configmodule_interface_t
*
cfgptr
)
{
void
*
lib_handle
;
char
fname
[
128
];
char
libname
[
FILENAME_MAX
];
int
st
;
st
=
0
;
sprintf
(
libname
,
CONFIG_SHAREDLIBFORMAT
,
cfgptr
->
cfgmode
);
lib_handle
=
dlopen
(
libname
,
RTLD_NOW
|
RTLD_GLOBAL
|
RTLD_NODELETE
);
if
(
!
lib_handle
)
{
fprintf
(
stderr
,
"[CONFIG] %s %d Error calling dlopen(%s): %s
\n
"
,
__FILE__
,
__LINE__
,
libname
,
dlerror
());
st
=
-
1
;
}
else
{
sprintf
(
fname
,
"config_%s_init"
,
cfgptr
->
cfgmode
);
cfgptr
->
init
=
dlsym
(
lib_handle
,
fname
);
if
(
cfgptr
->
init
==
NULL
)
{
printf
(
"[CONFIG] %s %d no function %s for config mode %s
\n
"
,
__FILE__
,
__LINE__
,
fname
,
cfgptr
->
cfgmode
);
}
else
{
st
=
cfgptr
->
init
(
cfgptr
->
cfgP
,
cfgptr
->
num_cfgP
);
printf
(
"[CONFIG] function %s returned %i
\n
"
,
fname
,
st
);
}
sprintf
(
fname
,
"config_%s_get"
,
cfgptr
->
cfgmode
);
cfgptr
->
get
=
dlsym
(
lib_handle
,
fname
);
if
(
cfgptr
->
get
==
NULL
)
{
printf
(
"[CONFIG] %s %d no function %s for config mode %s
\n
"
,
__FILE__
,
__LINE__
,
fname
,
cfgptr
->
cfgmode
);
st
=
-
1
;
}
sprintf
(
fname
,
"config_%s_getlist"
,
cfgptr
->
cfgmode
);
cfgptr
->
getlist
=
dlsym
(
lib_handle
,
fname
);
if
(
cfgptr
->
getlist
==
NULL
)
{
printf
(
"[CONFIG] %s %d no function %s for config mode %s
\n
"
,
__FILE__
,
__LINE__
,
fname
,
cfgptr
->
cfgmode
);
st
=
-
1
;
}
sprintf
(
fname
,
"config_%s_end"
,
cfgptr
->
cfgmode
);
cfgptr
->
end
=
dlsym
(
lib_handle
,
fname
);
if
(
cfgptr
->
getlist
==
NULL
)
{
printf
(
"[CONFIG] %s %d no function %s for config mode %s
\n
"
,
__FILE__
,
__LINE__
,
fname
,
cfgptr
->
cfgmode
);
}
}
return
st
;
}
/*-----------------------------------------------------------------------------------*/
/* from here: interface implementtion of the configuration module */
configmodule_interface_t
*
load_configmodule
(
int
argc
,
char
**
argv
)
{
char
*
cfgparam
=
NULL
;
char
*
modeparams
=
NULL
;
char
*
cfgmode
=
NULL
;
char
*
strtokctx
=
NULL
;
char
*
atoken
;
uint32_t
tmpflags
=
0
;
int
i
;
/* first parse the command line to look for the -O option */
opterr
=
0
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
if
(
strlen
(
argv
[
i
])
<
2
)
continue
;
if
(
argv
[
i
][
1
]
==
'O'
&&
i
<
(
argc
-
1
))
{
cfgparam
=
argv
[
i
+
1
];
}
if
(
argv
[
i
][
1
]
==
'h'
)
{
tmpflags
=
CONFIG_HELP
;
}
}
optind
=
1
;
/* look for the OAI_CONFIGMODULE environement variable */
if
(
cfgparam
==
NULL
)
{
cfgparam
=
getenv
(
"OAI_CONFIGMODULE"
);
}
/* default */
if
(
cfgparam
==
NULL
)
{
cfgparam
=
"libconfig:oaisoftmodem.conf"
;
}
/* parse the config parameters to set the config source */
i
=
sscanf
(
cfgparam
,
"%m[^':']:%ms"
,
&
cfgmode
,
&
modeparams
);
if
(
i
<
0
)
{
fprintf
(
stderr
,
"[CONFIG] %s, %d, sscanf error parsing config source %s: %s
\n
"
,
__FILE__
,
__LINE__
,
cfgparam
,
strerror
(
errno
));
cfgmode
=
strdup
(
"libconfig"
);
modeparams
=