Commit e7ea9e76 authored by Cedric Roux's avatar Cedric Roux
Browse files

Merge remote-tracking branch 'origin/issue326_LOGreview' into develop_integration_2018_w29

Conflicts:
	cmake_targets/CMakeLists.txt
parents d89dbb48 3539761c
...@@ -244,7 +244,7 @@ add_boolean_option(TEST_OMG False "???") ...@@ -244,7 +244,7 @@ add_boolean_option(TEST_OMG False "???")
add_boolean_option(DEBUG_OMG False "???") add_boolean_option(DEBUG_OMG False "???")
add_boolean_option(XFORMS False "This adds the possibility to see the signal oscilloscope") add_boolean_option(XFORMS False "This adds the possibility to see the signal oscilloscope")
add_boolean_option(PRINT_STATS False "This adds the possibility to see the status") add_boolean_option(PRINT_STATS False "This adds the possibility to see the status")
add_boolean_option(T_TRACER False "Activate the T tracer, a debugging/monitoring framework" ) add_boolean_option(T_TRACER True "Activate the T tracer, a debugging/monitoring framework" )
add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs") add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs")
add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace") add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace")
add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace") add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace")
...@@ -899,7 +899,7 @@ set(UTIL_SRC ...@@ -899,7 +899,7 @@ set(UTIL_SRC
${OPENAIR2_DIR}/UTIL/LISTS/list.c ${OPENAIR2_DIR}/UTIL/LISTS/list.c
${OPENAIR2_DIR}/UTIL/LISTS/list2.c ${OPENAIR2_DIR}/UTIL/LISTS/list2.c
${OPENAIR2_DIR}/UTIL/LOG/log.c ${OPENAIR2_DIR}/UTIL/LOG/log.c
${OPENAIR2_DIR}/UTIL/LOG/vcd_signal_dumper.c # ${OPENAIR2_DIR}/UTIL/LOG/vcd_signal_dumper.c
${OPENAIR2_DIR}/UTIL/MATH/oml.c ${OPENAIR2_DIR}/UTIL/MATH/oml.c
${OPENAIR2_DIR}/UTIL/MEM/mem_block.c ${OPENAIR2_DIR}/UTIL/MEM/mem_block.c
# ${OPENAIR2_DIR}/UTIL/OCG/OCG.c # ${OPENAIR2_DIR}/UTIL/OCG/OCG.c
...@@ -2182,7 +2182,7 @@ endforeach(myExe) ...@@ -2182,7 +2182,7 @@ endforeach(myExe)
if (${T_TRACER}) if (${T_TRACER})
foreach(i foreach(i
#all "add_executable" definitions (except tests, rb_tool, updatefw) #all "add_executable" definitions (except tests, rb_tool, updatefw)
lte-softmodem lte-softmodem-nos1 lte-softmodem lte-softmodem-nos1 lte-uesoftmodem lte-uesoftmodem-nos1
dlsim_tm4 dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim dlsim_tm4 dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim
pdcchsim pucchsim prachsim syncsim pdcchsim pucchsim prachsim syncsim
#all "add_library" definitions #all "add_library" definitions
......
...@@ -58,7 +58,7 @@ CFLAGS_PROCESSOR_USER="" ...@@ -58,7 +58,7 @@ CFLAGS_PROCESSOR_USER=""
RUN_GROUP=0 RUN_GROUP=0
TEST_CASE_GROUP="" TEST_CASE_GROUP=""
BUILD_DOXYGEN=0 BUILD_DOXYGEN=0
T_TRACER="False" T_TRACER="True"
DISABLE_HARDWARE_DEPENDENCY="False" DISABLE_HARDWARE_DEPENDENCY="False"
CMAKE_BUILD_TYPE="" CMAKE_BUILD_TYPE=""
CMAKE_CMD="$CMAKE" CMAKE_CMD="$CMAKE"
...@@ -141,8 +141,8 @@ Options ...@@ -141,8 +141,8 @@ Options
Enable deadline scheduler of Linux kernel (>=3.14.x). Enable deadline scheduler of Linux kernel (>=3.14.x).
--disable-cpu-affinity --disable-cpu-affinity
Disables CPU Affinity between UHD/TX/RX Threads (Valid only when deadline scheduler is disabled). By defaulT, CPU Affinity is enabled when not using deadline scheduler. It is enabled only with >2 CPUs. For eNB, CPU_0-> Device library (UHD), CPU_1->TX Threads, CPU_2...CPU_MAX->Rx Threads. For UE, CPU_0->Device Library(UHD), CPU_1..CPU_MAX -> All the UE threads Disables CPU Affinity between UHD/TX/RX Threads (Valid only when deadline scheduler is disabled). By defaulT, CPU Affinity is enabled when not using deadline scheduler. It is enabled only with >2 CPUs. For eNB, CPU_0-> Device library (UHD), CPU_1->TX Threads, CPU_2...CPU_MAX->Rx Threads. For UE, CPU_0->Device Library(UHD), CPU_1..CPU_MAX -> All the UE threads
--T-tracer --disable-T-Tracer
Enables the T tracer. Disables the T tracer.
--disable-hardware-dependency --disable-hardware-dependency
Disable HW dependency during installation Disable HW dependency during installation
--ue-autotest-trace --ue-autotest-trace
...@@ -309,9 +309,9 @@ function main() { ...@@ -309,9 +309,9 @@ function main() {
CPU_AFFINITY_FLAG_USER="False" CPU_AFFINITY_FLAG_USER="False"
echo_info "Disabling CPU Affinity (only valid when not using deadline scheduler)" echo_info "Disabling CPU Affinity (only valid when not using deadline scheduler)"
shift 1;; shift 1;;
--T-tracer) --disable-T-Tracer)
T_TRACER="True" T_TRACER="False"
echo_info "Enabling the T tracer" echo_info "Disabling the T tracer"
shift 1;; shift 1;;
--disable-hardware-dependency) --disable-hardware-dependency)
echo_info "Disabling hardware dependency for compiling software" echo_info "Disabling hardware dependency for compiling software"
...@@ -879,7 +879,7 @@ fi ...@@ -879,7 +879,7 @@ fi
echo "set(PACKAGE_NAME \"simulator_ue\")" >> $cmake_file echo "set(PACKAGE_NAME \"simulator_ue\")" >> $cmake_file
echo "set (DEADLINE_SCHEDULER \"False\" )" >> $cmake_file echo "set (DEADLINE_SCHEDULER \"False\" )" >> $cmake_file
echo "set (CPU_AFFINITY \"False\" )" >> $cmake_file echo "set (CPU_AFFINITY \"False\" )" >> $cmake_file
echo "set ( T_TRACER \"False\" )" >> $cmake_file echo "set ( T_TRACER \"True\" )" >> $cmake_file
echo "set (UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE)" >> $cmake_file echo "set (UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE)" >> $cmake_file
echo "set (UE_DEBUG_TRACE $UE_DEBUG_TRACE)" >> $cmake_file echo "set (UE_DEBUG_TRACE $UE_DEBUG_TRACE)" >> $cmake_file
echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)" >> $cmake_file echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)" >> $cmake_file
......
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
* \note * \note
* \warning * \warning
*/ */
#define _GNU_SOURCE
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include "config_userapi.h" #include "config_userapi.h"
...@@ -41,6 +43,7 @@ char *tmpval = value; ...@@ -41,6 +43,7 @@ char *tmpval = value;
int optisset=0; int optisset=0;
char defbool[2]="1"; char defbool[2]="1";
if ( value == NULL) { if ( value == NULL) {
if( (cfgoptions->paramflags &PARAMFLAG_BOOL) == 0 ) { /* not a boolean, argument required */ if( (cfgoptions->paramflags &PARAMFLAG_BOOL) == 0 ) { /* not a boolean, argument required */
fprintf(stderr,"[CONFIG] command line, option %s requires an argument\n",cfgoptions->optname); fprintf(stderr,"[CONFIG] command line, option %s requires an argument\n",cfgoptions->optname);
...@@ -103,15 +106,15 @@ char defbool[2]="1"; ...@@ -103,15 +106,15 @@ char defbool[2]="1";
if (optisset == 1) { if (optisset == 1) {
cfgoptions->paramflags = cfgoptions->paramflags | PARAMFLAG_PARAMSET; cfgoptions->paramflags = cfgoptions->paramflags | PARAMFLAG_PARAMSET;
} }
return optisset; return optisset;
} }
int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix)
{ {
char **p = config_get_if()->argv;
int c = config_get_if()->argc; int c = config_get_if()->argc;
int j; int i,j;
char *pp; char *pp;
char *cfgpath; char *cfgpath;
...@@ -122,42 +125,72 @@ char *cfgpath; ...@@ -122,42 +125,72 @@ char *cfgpath;
return -1; return -1;
} }
j=0; j = 0;
p++; i = 0;
c--; while (c > 0 ) {
while (c > 0 && *p != NULL) { char *oneargv = strdup(config_get_if()->argv[i]); /* we use strtok_r which modifies its string paramater, and we don't want argv to be modified */
if (strcmp(*p, "-h") == 0 || strcmp(*p, "--help") == 0 ) { /* first check help options, either --help, -h or --help_<section> */
config_printhelp(cfgoptions,numoptions); if (strncmp(oneargv, "-h",2) == 0 || strncmp(oneargv, "--help",6) == 0 ) {
char *tokctx;
pp=strtok_r(oneargv, "_",&tokctx);
if (pp == NULL || strcasecmp(pp,config_get_if()->argv[i] ) == 0 ) {
if( prefix == NULL) {
config_printhelp(cfgoptions,numoptions);
if ( ! ( CONFIG_ISFLAGSET(CONFIG_NOEXITONHELP)))
exit_fun("[CONFIG] Exiting after displaying help\n");
}
} else {
pp=strtok_r(NULL, "_",&tokctx);
if ( prefix != NULL && pp != NULL && strncasecmp(prefix,pp,strlen(pp)) == 0 ) {
printf ("Help for %s section:\n",prefix);
config_printhelp(cfgoptions,numoptions);
if ( ! (CONFIG_ISFLAGSET(CONFIG_NOEXITONHELP))) {
fprintf(stderr,"[CONFIG] %s %i section %s:", __FILE__, __LINE__, prefix);
exit_fun(" Exiting after displaying help\n");
}
}
}
} }
if (*p[0] == '-') { /* now, check for non help options */
for(int i=0;i<numoptions;i++) { if (oneargv[0] == '-') {
if ( ( cfgoptions[i].paramflags & PARAMFLAG_DISABLECMDLINE) != 0) { for(int n=0;n<numoptions;n++) {
if ( ( cfgoptions[n].paramflags & PARAMFLAG_DISABLECMDLINE) != 0) {
continue; continue;
} }
if (prefix != NULL) { if (prefix != NULL) {
sprintf(cfgpath,"%s.%s",prefix,cfgoptions[i].optname); sprintf(cfgpath,"%s.%s",prefix,cfgoptions[n].optname);
} else { } else {
sprintf(cfgpath,"%s",cfgoptions[i].optname); sprintf(cfgpath,"%s",cfgoptions[n].optname);
} }
if ( ((strlen(oneargv) == 2) && (strcmp(oneargv + 1,cfgpath) == 0)) || /* short option, one "-" */
if ( ((strlen(*p) == 2) && (strcmp(*p + 1,cfgpath) == 0)) || ((strlen(oneargv) > 2) && (strcmp(oneargv + 2,cfgpath ) == 0 )) ) {
((strlen(*p) > 2) && (strcmp(*p + 2,cfgpath ) == 0 )) ) { char *valptr=NULL;
pp = *(p+1); int ret;
if ( ( pp != NULL ) && (c>1) && (pp[0]!= '-') ) { pp = config_get_if()->argv[i+1];
if (pp != NULL && c > 1) {
j += processoption(&(cfgoptions[i]), pp); ret = strlen(pp);
} else { if (ret > 0 ) {
j += processoption(&(cfgoptions[i]), NULL); if (pp[0] != '-')
} valptr=pp;
else if ( ret > 1 && pp[0] == '-' && isdigit(pp[1]) )
valptr=pp;
}
}
j += processoption(&(cfgoptions[n]), pp);
if ( valptr != NULL ) {
i++;
c--;
}
break; break;
} }
} /* for */ } /* for n... */
} /* if (*p[0] == '-') */ } /* if (oneargv[0] == '-') */
p++; free(oneargv);
i++;
c--; c--;
} /* fin du while */ } /* fin du while */
printf_cmdl("[CONFIG] %s %i options set from command line\n",((prefix == NULL) ? "":prefix),j); printf_cmdl("[CONFIG] %s %i options set from command line\n",((prefix == NULL) ? "(root)":prefix),j);
free(cfgpath); free(cfgpath);
return j; return j;
} /* parse_cmdline*/ } /* parse_cmdline*/
......
...@@ -97,7 +97,77 @@ int st; ...@@ -97,7 +97,77 @@ int st;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* from here: interface implementtion of the configuration module */ /* from here: interface implementtion of the configuration module */
int nooptfunc(void) {
return 0;
};
int config_cmdlineonly_getlist(paramlist_def_t *ParamList,
paramdef_t *params, int numparams, char *prefix)
{
ParamList->numelt = 0;
return 0;
}
int config_cmdlineonly_get(paramdef_t *cfgoptions,int numoptions, char *prefix )
{
int defval;
int fatalerror=0;
int numdefvals=0;
for(int i=0;i<numoptions;i++) {
defval=0;
switch(cfgoptions[i].type) {
case TYPE_STRING:
defval=config_setdefault_string(&(cfgoptions[i]), prefix);
break;
case TYPE_STRINGLIST:
defval=config_setdefault_stringlist(&(cfgoptions[i]), prefix);
break;
case TYPE_UINT8:
case TYPE_INT8:
case TYPE_UINT16:
case TYPE_INT16:
case TYPE_UINT32:
case TYPE_INT32:
case TYPE_MASK:
defval=config_setdefault_int(&(cfgoptions[i]), prefix);
break;
case TYPE_UINT64:
case TYPE_INT64:
defval=config_setdefault_int64(&(cfgoptions[i]), prefix);
break;
case TYPE_UINTARRAY:
case TYPE_INTARRAY:
defval=config_setdefault_intlist(&(cfgoptions[i]), prefix);
break;
case TYPE_DOUBLE:
defval=config_setdefault_double(&(cfgoptions[i]), prefix);
break;
case TYPE_IPV4ADDR:
defval=config_setdefault_ipv4addr(&(cfgoptions[i]), prefix);
break;
default:
fprintf(stderr,"[CONFIG] %s.%s type %i not supported\n",prefix, cfgoptions[i].optname,cfgoptions[i].type);
fatalerror=1;
break;
} /* switch on param type */
if (defval == 1) {
numdefvals++;
cfgoptions[i].paramflags = cfgoptions[i].paramflags | PARAMFLAG_PARAMSETDEF;
}
} /* for loop on options */
printf("[CONFIG] %s: %i/%i parameters successfully set \n",
((prefix == NULL)?"(root)":prefix),
numdefvals,numoptions );
if (fatalerror == 1) {
fprintf(stderr,"[CONFIG] fatal errors found when assigning %s parameters \n",
prefix);
}
return numdefvals;
}
configmodule_interface_t *load_configmodule(int argc, char **argv) configmodule_interface_t *load_configmodule(int argc, char **argv)
{ {
...@@ -110,17 +180,19 @@ uint32_t tmpflags=0; ...@@ -110,17 +180,19 @@ uint32_t tmpflags=0;
int i; int i;
/* first parse the command line to look for the -O option */ /* first parse the command line to look for the -O option */
opterr=0;
for (i = 0;i<argc;i++) { for (i = 0;i<argc;i++) {
if (strlen(argv[i]) < 2) continue; if (strlen(argv[i]) < 2) continue;
if ( argv[i][1] == 'O' && i < (argc -1)) { if ( argv[i][1] == 'O' && i < (argc -1)) {
cfgparam = argv[i+1]; cfgparam = argv[i+1];
} }
if ( argv[i][1] == 'h' ) { if ( strstr(argv[i], "help_config") != NULL ) {
config_printhelp(Config_Params,CONFIG_PARAMLENGTH(Config_Params));
exit(0);
}
if ( (strcmp(argv[i]+1, "h") == 0) || (strstr(argv[i]+1, "help_") != NULL ) ) {
tmpflags = CONFIG_HELP; tmpflags = CONFIG_HELP;
} }
} }
optind=1;
/* look for the OAI_CONFIGMODULE environement variable */ /* look for the OAI_CONFIGMODULE environement variable */
if ( cfgparam == NULL ) { if ( cfgparam == NULL ) {
...@@ -129,21 +201,25 @@ int i; ...@@ -129,21 +201,25 @@ int i;
/* default */ /* default */
if (cfgparam == NULL) { if (cfgparam == NULL) {
tmpflags = tmpflags | CONFIG_NOOOPT; tmpflags = tmpflags | CONFIG_NOOOPT;
cfgparam = DEFAULT_CFGMODE ":" DEFAULT_CFGFILENAME; if (strstr(argv[0],"uesoftmodem") == NULL) {
} cfgparam = CONFIG_LIBCONFIGFILE ":" DEFAULT_CFGFILENAME;
} else {
cfgparam = CONFIG_CMDLINEONLY ":dbgl0" ;
}
}
/* parse the config parameters to set the config source */ /* parse the config parameters to set the config source */
i = sscanf(cfgparam,"%m[^':']:%ms",&cfgmode,&modeparams); i = sscanf(cfgparam,"%m[^':']:%ms",&cfgmode,&modeparams);
if (i< 0) { if (i< 0) {
fprintf(stderr,"[CONFIG] %s, %d, sscanf error parsing config source %s: %s\n", __FILE__, __LINE__,cfgparam, strerror(errno)); fprintf(stderr,"[CONFIG] %s, %d, sscanf error parsing config source %s: %s\n", __FILE__, __LINE__,cfgparam, strerror(errno));
cfgmode=strdup(DEFAULT_CFGMODE); exit(-1);
modeparams = strdup(DEFAULT_CFGFILENAME);
} }
else if ( i == 1 ) { else if ( i == 1 ) {
/* -O argument doesn't contain ":" separator, assume -O <conf file> option, default cfgmode to libconfig /* -O argument doesn't contain ":" separator, assume -O <conf file> option, default cfgmode to libconfig
with one parameter, the path to the configuration file */ with one parameter, the path to the configuration file */
modeparams=cfgmode; modeparams=cfgmode;
cfgmode=strdup(DEFAULT_CFGMODE); cfgmode=strdup(CONFIG_LIBCONFIGFILE);
} }
cfgptr = malloc(sizeof(configmodule_interface_t)); cfgptr = malloc(sizeof(configmodule_interface_t));
...@@ -153,7 +229,6 @@ int i; ...@@ -153,7 +229,6 @@ int i;
cfgptr->argc = argc; cfgptr->argc = argc;
cfgptr->argv = argv; cfgptr->argv = argv;
cfgptr->cfgmode=strdup(cfgmode); cfgptr->cfgmode=strdup(cfgmode);
cfgptr->num_cfgP=0; cfgptr->num_cfgP=0;
atoken=strtok_r(modeparams,":",&strtokctx); atoken=strtok_r(modeparams,":",&strtokctx);
while ( cfgptr->num_cfgP< CONFIG_MAX_OOPT_PARAMS && atoken != NULL) { while ( cfgptr->num_cfgP< CONFIG_MAX_OOPT_PARAMS && atoken != NULL) {
...@@ -176,24 +251,33 @@ int i; ...@@ -176,24 +251,33 @@ int i;
for (i=0;i<cfgptr->num_cfgP; i++) { for (i=0;i<cfgptr->num_cfgP; i++) {
printf("%s ",cfgptr->cfgP[i]); printf("%s ",cfgptr->cfgP[i]);
} }
printf("\n"); printf(", debug flags: 0x%08x\n",cfgptr->rtflags);
if (strstr(cfgparam,CONFIG_CMDLINEONLY) == NULL) {
i=load_config_sharedlib(cfgptr); i=load_config_sharedlib(cfgptr);
if (i< 0) { if (i == 0) {
fprintf(stderr,"[CONFIG] %s %d config module %s couldn't be loaded\n", __FILE__, __LINE__,cfgmode); printf("[CONFIG] config module %s loaded\n",cfgmode);
cfgptr->rtflags = cfgptr->rtflags | CONFIG_HELP | CONFIG_ABORT; Config_Params[CONFIGPARAM_DEBUGFLAGS_IDX].uptr=&(cfgptr->rtflags);
config_get(Config_Params,CONFIG_PARAMLENGTH(Config_Params), CONFIG_SECTIONNAME );
} else {
fprintf(stderr,"[CONFIG] %s %d config module \"%s\" couldn't be loaded\n", __FILE__, __LINE__,cfgmode);
cfgptr->rtflags = cfgptr->rtflags | CONFIG_HELP | CONFIG_ABORT;
}
} else { } else {
printf("[CONFIG] config module %s loaded\n",cfgmode); cfgptr->init = (configmodule_initfunc_t)nooptfunc;
Config_Params[CONFIGPARAM_DEBUGFLAGS_IDX].uptr=&(cfgptr->rtflags); cfgptr->get = config_cmdlineonly_get;
config_get(Config_Params,CONFIG_PARAMLENGTH(Config_Params), CONFIG_SECTIONNAME ); cfgptr->getlist = config_cmdlineonly_getlist;
cfgptr->end = (configmodule_endfunc_t)nooptfunc;
} }
if (modeparams != NULL) free(modeparams); if (modeparams != NULL) free(modeparams);
if (cfgmode != NULL) free(cfgmode); if (cfgmode != NULL) free(cfgmode);
if (CONFIG_ISFLAGSET(CONFIG_ABORT)) config_printhelp(Config_Params,CONFIG_PARAMLENGTH(Config_Params)); if (CONFIG_ISFLAGSET(CONFIG_ABORT)) {
config_printhelp(Config_Params,CONFIG_PARAMLENGTH(Config_Params));
exit(-1);
}
return cfgptr; return cfgptr;
} }
......
...@@ -41,17 +41,19 @@ ...@@ -41,17 +41,19 @@
#define CONFIG_MAX_ALLOCATEDPTRS 1024 // maximum number of parameters that can be dynamicaly allocated in the config module #define CONFIG_MAX_ALLOCATEDPTRS 1024 // maximum number of parameters that can be dynamicaly allocated in the config module
/* default values for configuration module parameters */ /* default values for configuration module parameters */
#define DEFAULT_CFGMODE "libconfig" // use libconfig file #define CONFIG_LIBCONFIGFILE "libconfig" // use libconfig file
#define DEFAULT_CFGFILENAME "oai.conf" // default config file #define CONFIG_CMDLINEONLY "cmdline" // use only command line options
#define DEFAULT_CFGFILENAME "oai.conf" // default config file
/* rtflags bit position definitions */ /* rtflags bit position definitions */
#define CONFIG_PRINTPARAMS 1 // print parameters values while processing #define CONFIG_PRINTPARAMS 1 // print parameters values while processing
#define CONFIG_DEBUGPTR 1<<1 // print memory allocation/free debug messages #define CONFIG_DEBUGPTR (1<<1) // print memory allocation/free debug messages
#define CONFIG_DEBUGCMDLINE 1<<2 // print command line processing messages #define CONFIG_DEBUGCMDLINE (1<<2) // print command line processing messages
#define CONFIG_NOABORTONCHKF 1<<3 // disable abort execution when parameter checking function fails #define CONFIG_NOABORTONCHKF (1<<3) // disable abort execution when parameter checking function fails
#define CONFIG_HELP 1<<20 // print help message #define CONFIG_NOEXITONHELP (1<<19) // do not exit after printing help
#define CONFIG_ABORT 1<<21 // config failed,abort execution #define CONFIG_HELP (1<<20) // print help message
#define CONFIG_NOOOPT 1<<22 // no -O option found when parsing command line #define CONFIG_ABORT (1<<21) // config failed,abort execution
#define CONFIG_NOOOPT (1<<22) // no -O option found when parsing command line
typedef int(*configmodule_initfunc_t)(char *cfgP[],int numP); typedef int(*configmodule_initfunc_t)(char *cfgP[],int numP);
typedef int(*configmodule_getfunc_t)(paramdef_t *,int numparams, char *prefix); 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 int(*configmodule_getlistfunc_t)(paramlist_def_t *, paramdef_t *,int numparams, char *prefix);
...@@ -75,7 +77,7 @@ typedef struct configmodule_interface ...@@ -75,7 +77,7 @@ typedef struct configmodule_interface
#ifdef CONFIG_LOADCONFIG_MAIN #ifdef CONFIG_LOADCONFIG_MAIN
configmodule_interface_t *cfgptr=NULL; configmodule_interface_t *cfgptr=NULL;
static char config_helpstr [] = "\n lte-softmodem -O [config mode]<:dbg[debugflags]> \n \ static char config_helpstr [] = "\n lte-softmodem -O [config mode]<:dbgl[debugflags]> \n \
debugflags can also be defined in the config_libconfig section of the config file\n \ debugflags can also be defined in the config_libconfig section of the config file\n \
debugflags: mask, 1->print parameters, 2->print memory allocations debug messages\n \ debugflags: mask, 1->print parameters, 2->print memory allocations debug messages\n \
4->print command line processing debug messages\n "; 4->print command line processing debug messages\n ";
...@@ -97,9 +99,9 @@ extern configmodule_interface_t *cfgptr; ...@@ -97,9 +99,9 @@ extern configmodule_interface_t *cfgptr;
#endif #endif
#define printf_params(...) if ( (cfgptr->rtflags & CONFIG_PRINTPARAMS) != 0 ) { printf ( __VA_ARGS__ ); } #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_ptrs(...) if ( (cfgptr->rtflags & (CONFIG_DEBUGPTR)) != 0 ) { printf ( __VA_ARGS__ ); }
#define printf_cmdl(...) if ( (cfgptr->rtflags & CONFIG_DEBUGCMDLINE) != 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 configmodule_interface_t *load_configmodule(int argc, char **argv);
extern void end_configmodule(void); extern void end_configmodule(void);
......
...@@ -148,7 +148,10 @@ typedef struct paramdef ...@@ -148,7 +148,10 @@ typedef struct paramdef
#define TYPE_MASK 10 #define TYPE_MASK 10
#define TYPE_DOUBLE 16 #define TYPE_DOUBLE 16
#define TYPE_IPV4ADDR 20 #define TYPE_IPV4ADDR 20
#define TYPE_LASTSCALAR 25
#define PARAM_ISLISTORARRAY(P) (P->type > TYPE_LASTSCALAR )
#define PARAM_ISSCALAR(P) (P->type < TYPE_LASTSCALAR )
#define TYPE_STRINGLIST 50 #define TYPE_STRINGLIST 50
#define TYPE_INTARRAY 51 #define TYPE_INTARRAY 51
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <arpa/inet.h>
#include "config_userapi.h" #include "config_userapi.h"
extern void exit_fun(const char* s); // lte-softmodem clean exit function extern void exit_fun(const char* s); // lte-softmodem clean exit function
...@@ -50,10 +52,30 @@ configmodule_interface_t *config_get_if(void) ...@@ -50,10 +52,30 @@ configmodule_interface_t *config_get_if(void)
char * config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) char * config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length)
{ {
if (ptr == NULL ) {
ptr = malloc(sizeof(char *));
if (ptr != NULL) {
*ptr=NULL;
cfgoptions->strptr=ptr;
if ( (cfgoptions->paramflags & PARAMFLAG_NOFREE) == 0) {
config_get_if()->ptrs[config_get_if()->numptrs] = (char *)ptr;
config_get_if()->numptrs++;
}
} else {