Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangwenhui
OpenXG-RAN
Commits
d2249d5c
Commit
d2249d5c
authored
Sep 14, 2017
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'RU-RAU-split' of
https://gitlab.eurecom.fr/oai/openairinterface5g
into RU-RAU-split
parents
362f584d
cdca16f6
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1783 additions
and
293 deletions
+1783
-293
cmake_targets/CMakeLists.txt
cmake_targets/CMakeLists.txt
+15
-2
cmake_targets/build_oai
cmake_targets/build_oai
+8
-0
common/config/config_cmdline.c
common/config/config_cmdline.c
+121
-0
common/config/config_load_configmodule.c
common/config/config_load_configmodule.c
+210
-0
common/config/config_load_configmodule.h
common/config/config_load_configmodule.h
+93
-0
common/config/config_paramdesc.h
common/config/config_paramdesc.h
+108
-0
common/config/config_userapi.c
common/config/config_userapi.c
+91
-0
common/config/config_userapi.h
common/config/config_userapi.h
+54
-0
common/config/libconfig/config_libconfig.c
common/config/libconfig/config_libconfig.c
+337
-0
common/config/libconfig/config_libconfig.h
common/config/libconfig/config_libconfig.h
+54
-0
common/config/libconfig/config_libconfig_private.h
common/config/libconfig/config_libconfig_private.h
+39
-0
openair2/ENB_APP/enb_config.c
openair2/ENB_APP/enb_config.c
+1
-291
openair2/ENB_APP/enb_paramdef.h
openair2/ENB_APP/enb_paramdef.h
+652
-0
No files found.
cmake_targets/CMakeLists.txt
View file @
d2249d5c
...
@@ -485,8 +485,20 @@ add_list1_option(NB_ANTENNAS_TXRX "2" "Number of antennas in ????" "1" "2" "4")
...
@@ -485,8 +485,20 @@ 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
(
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"
)
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
)
# include RF devices / transport protocols library modules
# include RF devices / transport protocols library modules
######################################################################
######################################################################
...
@@ -1721,6 +1733,7 @@ add_executable(lte-softmodem
...
@@ -1721,6 +1733,7 @@ add_executable(lte-softmodem
${
XFORMS_SOURCE
}
${
XFORMS_SOURCE
}
${
XFORMS_SOURCE_SOFTMODEM
}
${
XFORMS_SOURCE_SOFTMODEM
}
${
T_SOURCE
}
${
T_SOURCE
}
${
CONFIG_SOURCES
}
)
)
target_link_libraries
(
lte-softmodem -ldl
target_link_libraries
(
lte-softmodem -ldl
...
...
cmake_targets/build_oai
View file @
d2249d5c
...
@@ -478,6 +478,9 @@ function main() {
...
@@ -478,6 +478,9 @@ function main() {
lte_exec
=
lte-softmodem
lte_exec
=
lte-softmodem
fi
fi
# configuration module libraries, one currently available, using libconfig
config_libconfig_shlib
=
params_libconfig
# first generate the CMakefile in the right directory
# first generate the CMakefile in the right directory
if
[
"
$eNB
"
=
"1"
-o
"
$UE
"
=
"1"
-o
"
$HW
"
=
"EXMIMO"
]
;
then
if
[
"
$eNB
"
=
"1"
-o
"
$UE
"
=
"1"
-o
"
$HW
"
=
"EXMIMO"
]
;
then
...
@@ -520,6 +523,11 @@ function main() {
...
@@ -520,6 +523,11 @@ function main() {
$lte_build_dir
$lte_exec
\
$lte_build_dir
$lte_exec
\
$lte_exec
$dbin
/
$lte_exec
.
$REL
$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
if
[
"
$NOS1
"
=
"1"
]
;
then
compilations
\
compilations
\
$lte_build_dir
nasmesh
\
$lte_build_dir
nasmesh
\
...
...
common/config/config_cmdline.c
0 → 100644
View file @
d2249d5c
/*
* 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
)
{
int
ret
=
0
;
switch
(
cfgoptions
->
type
)
{
case
TYPE_STRING
:
check_valptr
(
cfgoptions
,
(
char
**
)(
cfgoptions
->
strptr
),
sizeof
(
char
*
));
check_valptr
(
cfgoptions
,
cfgoptions
->
strptr
,
strlen
(
value
+
1
));
sprintf
(
*
(
cfgoptions
->
strptr
),
"%s"
,
value
);
printf_cmdl
(
"[LIBCONFIG] %s set to %s from command line
\n
"
,
cfgoptions
->
optname
,
value
);
ret
++
;
break
;
case
TYPE_STRINGLIST
:
break
;
case
TYPE_UINT
:
case
TYPE_INT
:
case
TYPE_UINT64
:
case
TYPE_INT64
:
check_valptr
(
cfgoptions
,
(
char
**
)
&
(
cfgoptions
->
i64ptr
),
sizeof
(
uint64_t
));
*
(
cfgoptions
->
uptr
)
=
strtol
(
value
,
NULL
,
0
);
printf_cmdl
(
"[LIBCONFIG] %s set to %lli from command line
\n
"
,
cfgoptions
->
optname
,
(
long
long
)
*
(
cfgoptions
->
i64ptr
));
ret
++
;
break
;
case
TYPE_UINTARRAY
:
case
TYPE_INTARRAY
:
break
;
case
TYPE_IPV4ADDR
:
break
;
default:
fprintf
(
stderr
,
"[LIBCONFIG] command line, %s type %i not supported
\n
"
,
cfgoptions
->
optname
,
cfgoptions
->
type
);
break
;
}
/* switch on param type */
return
ret
;
}
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
*
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
);
}
for
(
int
i
=
0
;
i
<
numoptions
;
i
++
)
{
if
(
(
cfgoptions
[
i
].
paramflags
&
PARAMFLAG_DISABLECMDLINE
)
!=
0
)
{
continue
;
}
sprintf
(
cfgpath
,
"%s.%s"
,
prefix
,
cfgoptions
[
i
].
optname
);
if
(
strcmp
(
*
p
+
1
,
cfgoptions
[
i
].
shortopt
)
==
0
||
strcmp
(
*
p
+
2
,
cfgpath
)
==
0
)
{
p
++
;
j
=+
processoption
(
&
(
cfgoptions
[
i
]),
*
p
);
c
--
;
}
}
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 @
d2249d5c
/*
* 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
(
char
*
cfgmode
,
char
*
cfgP
[],
int
numP
,
configmodule_interface_t
*
cfgptr
)
{
void
*
lib_handle
;
char
fname
[
128
];
char
libname
[
FILENAME_MAX
];
int
st
;
st
=
0
;
sprintf
(
libname
,
CONFIG_SHAREDLIBFORMAT
,
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"
,
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
,
cfgmode
);
}
else
{
st
=
cfgptr
->
init
(
cfgP
,
numP
);
printf
(
"[CONFIG] function %s returned %i
\n
"
,
fname
,
st
);
}
sprintf
(
fname
,
"config_%s_get"
,
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
,
cfgmode
);
st
=
-
1
;
}
sprintf
(
fname
,
"config_%s_getlist"
,
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
,
cfgmode
);
st
=
-
1
;
}
sprintf
(
fname
,
"config_%s_end"
,
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
,
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
*
cfgP
[
CONFIG_MAX_OOPT_PARAMS
];
int
i
;
int
p
;
for
(
i
=
0
;
i
<
CONFIG_MAX_OOPT_PARAMS
;
i
++
)
{
cfgP
[
i
]
=
NULL
;
}
/* first parse the command line to look for the -O option */
opterr
=
0
;
while
((
i
=
getopt
(
argc
,
argv
,
"O:"
))
!=
-
1
)
{
if
(
i
==
'O'
)
{
cfgparam
=
optarg
;
}
}
/* 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
));
return
NULL
;
}
else
if
(
i
==
1
)
{
modeparams
=
cfgmode
;
cfgmode
=
strdup
(
"libconfig"
);
}
cfgptr
=
malloc
(
sizeof
(
configmodule_interface_t
));
p
=
0
;
cfgP
[
p
]
=
strtok_r
(
modeparams
,
":"
,
&
strtokctx
);
while
(
p
<
CONFIG_MAX_OOPT_PARAMS
&&
cfgP
[
p
]
!=
NULL
)
{
char
*
aptr
;
aptr
=
strcasestr
(
cfgP
[
p
],
"dbgl"
);
if
(
aptr
!=
NULL
)
{
cfgptr
->
rtflags
=
strtol
(
aptr
+
4
,
NULL
,
0
);
Config_Params
[
CONFIGPARAM_DEBUGFLAGS_IDX
].
paramflags
=
Config_Params
[
CONFIGPARAM_DEBUGFLAGS_IDX
].
paramflags
|
PARAMFLAG_DONOTREAD
;
for
(
int
j
=
p
;
j
<
(
CONFIG_MAX_OOPT_PARAMS
-
1
);
j
++
)
cfgP
[
j
]
=
cfgP
[
j
+
1
];
p
--
;
}
p
++
;
cfgP
[
p
]
=
strtok_r
(
NULL
,
":"
,
&
strtokctx
);
}
printf
(
"[CONFIG] get parameters from %s "
,
cfgmode
);
for
(
i
=
0
;
i
<
p
;
i
++
)
{
printf
(
"%s "
,
cfgP
[
i
]);
}
printf
(
"
\n
"
);
i
=
load_config_sharedlib
(
cfgmode
,
cfgP
,
p
,
cfgptr
);
if
(
i
<
0
)
{
fprintf
(
stderr
,
"[CONFIG] %s %d config module %s couldn't be loaded
\n
"
,
__FILE__
,
__LINE__
,
cfgmode
);
return
NULL
;
}
else
{
printf
(
"[CONFIG] config module %s loaded
\n
"
,
cfgmode
);
}
Config_Params
[
CONFIGPARAM_DEBUGFLAGS_IDX
].
uptr
=&
(
cfgptr
->
rtflags
);
config_get
(
Config_Params
,
CONFIG_PARAMLENGTH
(
Config_Params
),
CONFIG_SECTIONNAME
);
if
(
modeparams
!=
NULL
)
free
(
modeparams
);
if
(
cfgmode
!=
NULL
)
free
(
cfgmode
);
optind
=
1
;
cfgptr
->
argc
=
argc
;
cfgptr
->
argv
=
argv
;
return
cfgptr
;
}
void
end_configmodule
()
{
if
(
cfgptr
!=
NULL
)
{
printf
(
"[CONFIG] free %u pointers
\n
"
,
cfgptr
->
numptrs
);
for
(
int
i
=
0
;
i
<
cfgptr
->
numptrs
;
i
++
)
{
if
(
cfgptr
->
ptrs
[
i
]
!=
NULL
)
{
free
(
cfgptr
->
ptrs
[
i
]);
}
cfgptr
->
ptrs
[
i
]
=
NULL
;
}
if
(
cfgptr
->
end
!=
NULL
)
{
printf
(
"[CONFIG] calling config module end function...
\n
"
);
cfgptr
->
end
();
}
free
(
cfgptr
);
cfgptr
=
NULL
;
}
}
common/config/config_load_configmodule.h
0 → 100644
View file @
d2249d5c
/*
* 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.h
* \brief: configuration module, include file to be used by the source code calling the
* configuration module initialization
* \author Francois TABURET
* \date 2017
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#ifndef INCLUDE_CONFIG_LOADCONFIGMODULE_H
#define INCLUDE_CONFIG_LOADCONFIGMODULE_H
#include <string.h>
#include <stdlib.h>
#include "common/config/config_paramdesc.h"
#define CONFIG_MAX_OOPT_PARAMS 10 // maximum number of parameters in the -O option (-O <cfgmode>:P1:P2...
#define CONFIG_MAX_ALLOCATEDPTRS 1024 // maximum number of parameters that can be dynamicaly alloted in the config module
/* rtflags bit position definitions */
#define CONFIG_PRINTPARAMS 1 // print parameters values while processing
#define CONFIG_DEBUGPTR 2 // print memory allocation/free debug messages
#define CONFIG_DEBUGCMDLINE 4 // print command line processing messages
typedef
int
(
*
configmodule_initfunc_t
)(
char
*
cfgP
[],
int
numP
);
typedef
int
(
*
configmodule_getfunc_t
)(
paramdef_t
*
,
int
numparams
,
char
*
prefix
);
typedef
int
(
*
configmodule_getlistfunc_t
)(
paramlist_def_t
*
,
paramdef_t
*
,
int
numparams
,
char
*
prefix
);
typedef
void
(
*
configmodule_endfunc_t
)(
void
);
typedef
struct
configmodule_interface
{
int
argc
;
char
**
argv
;
configmodule_initfunc_t
init
;
configmodule_getfunc_t
get
;
configmodule_getlistfunc_t
getlist
;
configmodule_endfunc_t
end
;
uint32_t
numptrs
;
uint32_t
rtflags
;
char
*
ptrs
[
CONFIG_MAX_ALLOCATEDPTRS
];
}
configmodule_interface_t
;
#ifdef CONFIG_LOADCONFIG_MAIN
configmodule_interface_t
*
cfgptr
=
NULL
;
static
char
config_helpstr
[]
=
" \
config debugflags: mask, 1->print parameters, 2->print memory allocations debug messages \
4->print command line processing debug messages \
-O <config mode><:dbg> \
debugflags can also be defined in the config_libconfig section of the config file \
"
;
#define CONFIG_SECTIONNAME "config"
#define CONFIGPARAM_DEBUGFLAGS_IDX 0
static
paramdef_t
Config_Params
[]
=
{
{
"debugflags"
,
""
,
config_helpstr
,
0
,
uptr
:
NULL
,
defintval
:
0
,
TYPE_UINT
,
0
},
};
#else
extern
configmodule_interface_t
*
cfgptr
;
#endif
#define printf_params(...) if ( (cfgptr->rtflags & CONFIG_PRINTPARAMS) != 0 ) { printf ( __VA_ARGS__ ); }
#define printf_ptrs(...) if ( (cfgptr->rtflags & CONFIG_DEBUGPTR) != 0 ) { printf ( __VA_ARGS__ ); }
#define printf_cmdl(...) if ( (cfgptr->rtflags & CONFIG_DEBUGCMDLINE) != 0 ) { printf ( __VA_ARGS__ ); }
extern
configmodule_interface_t
*
load_configmodule
(
int
argc
,
char
**
argv
);
extern
void
end_configmodule
(
void
);
#endif
/* INCLUDE_CONFIG_LOADCONFIGMODULE_H */
common/config/config_paramdesc.h
0 → 100644
View file @
d2249d5c
/*
* 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_paramdesc.h
* \brief configuration module, include file describing parameters, common to all implementations
* \author Francois TABURET
* \date 2017
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#include <stdint.h>
#ifndef INCLUDE_CONFIG_PARAMDESC_H
#define INCLUDE_CONFIG_PARAMDESC_H
#define MAX_OPTNAME_SIZE 64
#define MAX_SHORTOPT_SIZE 8
/* parameter flags definitions */
/* Flags to be used by calling modules in their parameters definitions: */
#define PARAMFLAG_DISABLECMDLINE (1 << 0) // parameter can bet set from comand line
/* Flags used by config modules: */
/* flags to be used by caller modules when defining parameters */
#define PARAMFLAG_MANDATORY (1 << 1) // parameter must be explicitely set, default value ignored
/* flags used by config modules, at runtime to manage memory allocations */
#define PARAMFLAG_MALLOCINCONFIG (1 << 15) // parameter allocated in config module
#define PARAMFLAG_NOFREE (1 << 14) // don't free parameter in end function
/* flags to be used by caller modules to modify get behavior */
#define PARAMFLAG_DONOTREAD (1 << 20) // parameter must be ignored in get function
typedef
struct
paramdef
{
char
optname
[
MAX_OPTNAME_SIZE
];
char
shortopt
[
MAX_SHORTOPT_SIZE
];
char
*
helpstr
;
unsigned
int
paramflags
;
union
{
char
**
strptr
;
char
**
strlistptr
;
uint32_t
*
uptr
;
int32_t
*
iptr
;
uint64_t
*
u64ptr
;
int64_t
*
i64ptr
;
}
;
union
{
char
*
defstrval
;
char
**
defstrlistval
;
uint32_t
defuintval
;
int
defintval
;
uint64_t
defint64val
;
int
*
defintarrayval
;
}
;
char
type
;
int
numelt
;
}
paramdef_t
;
#define TYPE_STRING 1
#define TYPE_INT 2
#define TYPE_UINT 3
#define TYPE_INT64 4
#define TYPE_UINT64 5
#define TYPE_IPV4ADDR 20
#define TYPE_STRINGLIST 50
#define TYPE_INTARRAY 51
#define TYPE_UINTARRAY 52
#define TYPE_LIST 55
#define NO_UINTDEFAULT ((int)(-1))
#define ANY_IPV4ADDR_STRING "0.0.0.0"
typedef
struct
paramlist_def
{
char
listname
[
MAX_OPTNAME_SIZE
];
paramdef_t
**
paramarray
;
int
numelt
;
}
paramlist_def_t
;
/* macro helpers for module users */
#define CONFIG_PARAMLENGTH(A) (sizeof(A)/sizeof(paramdef_t))
#endif
/* INCLUDE_CONFIG_PARAMDESC_H */
common/config/config_userapi.c
0 → 100644
View file @
d2249d5c
/*
* 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_userapi.c
* \brief configuration module, api implementation to access configuration parameters
* \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 <unistd.h>
#include <errno.h>
#include <dlfcn.h>
#include "config_userapi.h"
configmodule_interface_t
*
config_get_if
(
void
)
{
if
(
cfgptr
==
NULL
)
{
fprintf
(
stderr
,
"[CONFIG] %s %d config module not initialized
\n
"
,
__FILE__
,
__LINE__
);
exit
(
-
1
);
}
return
cfgptr
;
}
char
*
check_valptr
(
paramdef_t
*
cfgoptions
,
char
**
ptr
,
int
length
)
{
printf_ptrs
(
"-- %s 0x%08lx %i
\n
"
,
cfgoptions
->
optname
,(
uintptr_t
)(
*
ptr
),
length
);
if
(
*
ptr
==
NULL
)
{
*
ptr
=
malloc
(
length
);
if
(
*
ptr
!=
NULL
)
{
memset
(
*
ptr
,
0
,
length
);
if
(
(
cfgoptions
->
paramflags
&
PARAMFLAG_NOFREE
)
!=
0
)
{
config_get_if
()
->
ptrs
[
config_get_if
()
->
numptrs
]
=
*
ptr
;
config_get_if
()
->
numptrs
++
;
}
}
else
{
fprintf
(
stderr
,
"[LIBCONFIG] %s %d malloc error
\n
"
,
__FILE__
,
__LINE__
);
exit
(
-
1
);
}
}
return
*
ptr
;
}
void
config_printhelp
(
paramdef_t
*
params
,
int
numparams
)
{
for
(
int
i
=
0
;
i
<
numparams
;
i
++
)
{
if
(
params
[
i
].
helpstr
!=
NULL
)
{
printf
(
"%s"
,
params
[
i
].
helpstr
);
}
}
}
int
config_get
(
paramdef_t
*
params
,
int
numparams
,
char
*
prefix
)
{
int
ret
=
-
1
;
configmodule_interface_t
*
cfgif
=
config_get_if
();
if
(
cfgif
!=
NULL
)
{
ret
=
config_get_if
()
->
get
(
params
,
numparams
,
prefix
);
if
(
ret
>=
0
)
{
config_process_cmdline
(
params
,
numparams
,
prefix
);
}
return
ret
;
}
return
ret
;
}
common/config/config_userapi.h
0 → 100644
View file @
d2249d5c
/*
* 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_userapi.h
* \brief: configuration module, include file to be used by the source code calling the
* configuration module to access configuration parameters
* \author Francois TABURET
* \date 2017
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#ifndef INCLUDE_CONFIG_USERAPI_H
#define INCLUDE_CONFIG_USERAPI_H
#include "config_load_configmodule.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
configmodule_interface_t
*
config_get_if
(
void
);
extern
char
*
check_valptr
(
paramdef_t
*
cfgoptions
,
char
**
ptr
,
int
length
)
;
extern
void
config_printhelp
(
paramdef_t
*
,
int
numparams
);
extern
int
config_process_cmdline
(
paramdef_t
*
params
,
int
numparams
,
char
*
prefix
);
extern
int
config_get
(
paramdef_t
*
params
,
int
numparams
,
char
*
prefix
);
#define config_getlist config_get_if()->getlist
#ifdef __cplusplus
}
#endif
#endif
common/config/libconfig/config_libconfig.c
0 → 100644
View file @
d2249d5c
This diff is collapsed.
Click to expand it.
common/config/libconfig/config_libconfig.h
0 → 100644
View file @
d2249d5c
/*
* 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/libconfig/config_libconfig.c
* \brief configuration module, include file for libconfig implementation
* \author Francois TABURET
* \date 2017
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#ifndef INCLUDE_CONFIG_LIBCONFIG_H
#define INCLUDE_CONFIG_LIBCONFIG_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "common/config/config_paramdesc.h"
typedef
struct
libconfig_privatedata
{
char
*
configfile
;
config_t
cfg
;
}
libconfig_privatedata_t
;
#ifdef __cplusplus
}
#endif
#endif
/* INCLUDE_CONFIG_LIBCONFIG_H */
common/config/libconfig/config_libconfig_private.h
0 → 100644
View file @
d2249d5c
/*
* 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/libconfig/config_libconfig_private.h
* \brief configuration module, include file for libconfig implementation
* \author Francois TABURET
* \date 2017
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
static
libconfig_privatedata_t
libconfig_privdata
;
openair2/ENB_APP/enb_config.c
View file @
d2249d5c
This diff is collapsed.
Click to expand it.
openair2/ENB_APP/enb_paramdef.h
0 → 100755
View file @
d2249d5c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment