Commit 5ebe2856 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/fix-config-module' into integration_2022_wk33

parents 84f76348 d6d4d87e
...@@ -11,10 +11,11 @@ configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t init ...@@ -11,10 +11,11 @@ configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t init
* if the bit CONFIG_ENABLECMDLINEONLY is set in `initflags` then the module allows parameters to be set only via the command line. This is used for the oai UE. * if the bit CONFIG_ENABLECMDLINEONLY is set in `initflags` then the module allows parameters to be set only via the command line. This is used for the oai UE.
```c ```c
void End_configmodule(void) void end_configmodule(void)
``` ```
* Free memory which has been allocated by the configuration module since its initialization. * Free memory which has been allocated by the configuration module for storing parameters values, when `PARAMFLAG_NOFREE` flag is not specified in the parameter definition.
* Possibly calls the `config_<config source>_end` function * Possibly calls the `config_<config source>_end` function
This call should be used when all configurations have been read. The program will still be able to use parameter values allocated by the config module WHEN THE `PARAMFLAG_NOFREE` flag has been specified in the parameter definition. The config module can be reloaded later in the program (not fully tested as not used today)
## Retrieving parameter's values ## Retrieving parameter's values
......
...@@ -53,13 +53,17 @@ int parse_stringlist(paramdef_t *cfgoptions, char *val) { ...@@ -53,13 +53,17 @@ int parse_stringlist(paramdef_t *cfgoptions, char *val) {
} }
free(tmpval); free(tmpval);
config_check_valptr(cfgoptions,(char **)&(cfgoptions->strlistptr), sizeof(char *) * numelt);
AssertFatal(MAX_LIST_SIZE > numelt,
"This piece of code use fixed size arry of constant #define MAX_LIST_SIZE %d\n",
MAX_LIST_SIZE );
config_check_valptr(cfgoptions, sizeof(char*), numelt);
cfgoptions->numelt=numelt; cfgoptions->numelt=numelt;
atoken=strtok_r(val, ",",&tokctx); atoken=strtok_r(val, ",",&tokctx);
for( int i=0; i<cfgoptions->numelt && atoken != NULL ; i++) { for( int i=0; i<cfgoptions->numelt && atoken != NULL ; i++) {
config_check_valptr(cfgoptions,&(cfgoptions->strlistptr[i]),strlen(atoken)+1); snprintf(cfgoptions->strlistptr[i],DEFAULT_EXTRA_SZ,"%s",atoken);
sprintf(cfgoptions->strlistptr[i],"%s",atoken);
printf_params("[LIBCONFIG] %s[%i]: %s\n", cfgoptions->optname,i,cfgoptions->strlistptr[i]); printf_params("[LIBCONFIG] %s[%i]: %s\n", cfgoptions->optname,i,cfgoptions->strlistptr[i]);
atoken=strtok_r(NULL, ",",&tokctx); atoken=strtok_r(NULL, ",",&tokctx);
} }
...@@ -84,13 +88,14 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -84,13 +88,14 @@ int processoption(paramdef_t *cfgoptions, char *value) {
char *charptr; char *charptr;
case TYPE_STRING: case TYPE_STRING:
if (cfgoptions->numelt == 0 ) { if (cfgoptions->numelt == 0 )
config_check_valptr(cfgoptions, cfgoptions->strptr, strlen(tmpval)+1); config_check_valptr(cfgoptions, 1,
sprintf(*(cfgoptions->strptr), "%s",tmpval); strlen(tmpval)+1);
} else { if (cfgoptions->numelt < (strlen(tmpval)+1)) {
sprintf( (char *)(cfgoptions->strptr), "%s",tmpval); CONFIG_PRINTF_ERROR("[CONFIG] command line option %s value too long\n",
cfgoptions->optname);
} }
snprintf(*cfgoptions->strptr, cfgoptions->numelt ,"%s",tmpval);
printf_cmdl("[CONFIG] %s set to %s from command line\n", cfgoptions->optname, tmpval); printf_cmdl("[CONFIG] %s set to %s from command line\n", cfgoptions->optname, tmpval);
optisset=1; optisset=1;
break; break;
...@@ -105,7 +110,7 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -105,7 +110,7 @@ int processoption(paramdef_t *cfgoptions, char *value) {
case TYPE_INT16: case TYPE_INT16:
case TYPE_UINT8: case TYPE_UINT8:
case TYPE_INT8: case TYPE_INT8:
config_check_valptr(cfgoptions, (char **)&(cfgoptions->iptr),sizeof(int32_t)); config_check_valptr(cfgoptions, sizeof(*cfgoptions->iptr), 1);
config_assign_int(cfgoptions,cfgoptions->optname,(int32_t)strtol(tmpval,&charptr,0)); config_assign_int(cfgoptions,cfgoptions->optname,(int32_t)strtol(tmpval,&charptr,0));
if( *charptr != 0) { if( *charptr != 0) {
...@@ -117,14 +122,14 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -117,14 +122,14 @@ int processoption(paramdef_t *cfgoptions, char *value) {
case TYPE_UINT64: case TYPE_UINT64:
case TYPE_INT64: case TYPE_INT64:
config_check_valptr(cfgoptions, (char **)&(cfgoptions->i64ptr),sizeof(uint64_t)); config_check_valptr(cfgoptions, sizeof(*cfgoptions->i64ptr), 1);
*(cfgoptions->i64ptr)=strtoll(tmpval,&charptr,0); *(cfgoptions->i64ptr)=strtoll(tmpval,&charptr,0);
if( *charptr != 0) { if( *charptr != 0) {
CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires an integer argument\n",cfgoptions->optname); CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires an integer argument\n",cfgoptions->optname);
} }
printf_cmdl("[CONFIG] %s set to %lli from command line\n", cfgoptions->optname, (long long)*(cfgoptions->i64ptr)); printf_cmdl("[CONFIG] %s set to %lli from command line\n", cfgoptions->optname, (long long)*cfgoptions->i64ptr);
optisset=1; optisset=1;
break; break;
...@@ -133,8 +138,8 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -133,8 +138,8 @@ int processoption(paramdef_t *cfgoptions, char *value) {
break; break;
case TYPE_DOUBLE: case TYPE_DOUBLE:
config_check_valptr(cfgoptions, (char **)&(cfgoptions->dblptr),sizeof(double)); config_check_valptr(cfgoptions, sizeof(*cfgoptions->dblptr), 1);
*(cfgoptions->dblptr) = strtof(tmpval,&charptr); *cfgoptions->dblptr = strtof(tmpval,&charptr);
if( *charptr != 0) { if( *charptr != 0) {
CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires a double argument\n",cfgoptions->optname); CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires a double argument\n",cfgoptions->optname);
......
...@@ -250,7 +250,7 @@ configmodule_interface_t *load_configmodule(int argc, ...@@ -250,7 +250,7 @@ configmodule_interface_t *load_configmodule(int argc,
modeparams=cfgmode; modeparams=cfgmode;
cfgmode=strdup(CONFIG_LIBCONFIGFILE); cfgmode=strdup(CONFIG_LIBCONFIGFILE);
} }
if (cfgptr == NULL) {
cfgptr = calloc(sizeof(configmodule_interface_t),1); cfgptr = calloc(sizeof(configmodule_interface_t),1);
/* argv_info is used to memorize command line options which have been recognized */ /* argv_info is used to memorize command line options which have been recognized */
/* and to detect unrecognized command line options which might have been specified */ /* and to detect unrecognized command line options which might have been specified */
...@@ -289,7 +289,7 @@ configmodule_interface_t *load_configmodule(int argc, ...@@ -289,7 +289,7 @@ configmodule_interface_t *load_configmodule(int argc,
} }
printf("[CONFIG] get parameters from %s ",cfgmode); printf("[CONFIG] get parameters from %s ",cfgmode);
}
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]);
} }
...@@ -336,33 +336,23 @@ void end_configmodule(void) { ...@@ -336,33 +336,23 @@ void end_configmodule(void) {
cfgptr->end(); cfgptr->end();
} }
pthread_mutex_lock(&cfgptr->memBlocks_mutex);
printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs); printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs);
for(int i=0; i<cfgptr->numptrs ; i++) { for(int i=0; i<cfgptr->numptrs ; i++) {
if (cfgptr->ptrs[i] != NULL && cfgptr->ptrsAllocated[i] == true) { if (cfgptr->oneBlock[i].ptrs != NULL && cfgptr->oneBlock[i].ptrsAllocated== true && cfgptr->oneBlock[i].toFree) {
free(cfgptr->ptrs[i]); free(cfgptr->oneBlock[i].ptrs);
cfgptr->ptrs[i]=NULL; memset(&cfgptr->oneBlock[i], 0, sizeof(cfgptr->oneBlock[i]));
cfgptr->ptrsAllocated[i] = false;
} }
} }
cfgptr->numptrs=0; cfgptr->numptrs=0;
} pthread_mutex_unlock(&cfgptr->memBlocks_mutex);
} if ( cfgptr->cfgmode )
free(cfgptr->cfgmode);
/* free all memory used by config module */ if ( cfgptr->argv_info )
/* should be called only at program exit */ free( cfgptr->argv_info );
void free_configmodule(void) {
if (cfgptr != NULL) {
end_configmodule();
if( cfgptr->cfgmode != NULL) free(cfgptr->cfgmode);
printf ("[CONFIG] free %i config parameter pointers\n",cfgptr->num_cfgP);
for (int i=0; i<cfgptr->num_cfgP; i++) {
if ( cfgptr->cfgP[i] != NULL) free(cfgptr->cfgP[i]);
}
free(cfgptr); free(cfgptr);
cfgptr=NULL; cfgptr=NULL;
...@@ -372,3 +362,4 @@ void free_configmodule(void) { ...@@ -372,3 +362,4 @@ void free_configmodule(void) {
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include "common/config/config_paramdesc.h" #include "common/config/config_paramdesc.h"
#include "common/utils/T/T.h" #include "common/utils/T/T.h"
#define CONFIG_MAX_OOPT_PARAMS 10 // maximum number of parameters in the -O option (-O <cfgmode>:P1:P2... #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 allocated in the config module #define CONFIG_MAX_ALLOCATEDPTRS 2048 // 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 CONFIG_LIBCONFIGFILE "libconfig" // use libconfig file #define CONFIG_LIBCONFIGFILE "libconfig" // use libconfig file
...@@ -62,6 +62,14 @@ typedef int(*configmodule_initfunc_t)(char *cfgP[],int numP); ...@@ -62,6 +62,14 @@ 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);
typedef void(*configmodule_endfunc_t)(void); typedef void(*configmodule_endfunc_t)(void);
typedef struct oneBlock_s{
void *ptrs;
int sz;
bool toFree;
bool ptrsAllocated;
} oneBlock_t;
typedef struct configmodule_interface { typedef struct configmodule_interface {
int argc; int argc;
char **argv; char **argv;
...@@ -73,10 +81,10 @@ typedef struct configmodule_interface { ...@@ -73,10 +81,10 @@ typedef struct configmodule_interface {
configmodule_getfunc_t get; configmodule_getfunc_t get;
configmodule_getlistfunc_t getlist; configmodule_getlistfunc_t getlist;
configmodule_endfunc_t end; configmodule_endfunc_t end;
pthread_mutex_t memBlocks_mutex;
uint32_t numptrs; uint32_t numptrs;
uint32_t rtflags; uint32_t rtflags;
char *ptrs[CONFIG_MAX_ALLOCATEDPTRS]; oneBlock_t oneBlock[CONFIG_MAX_ALLOCATEDPTRS];
bool ptrsAllocated[CONFIG_MAX_ALLOCATEDPTRS];
} configmodule_interface_t; } configmodule_interface_t;
#ifdef CONFIG_LOADCONFIG_MAIN #ifdef CONFIG_LOADCONFIG_MAIN
...@@ -112,7 +120,15 @@ extern configmodule_interface_t *cfgptr; ...@@ -112,7 +120,15 @@ extern configmodule_interface_t *cfgptr;
#define CONFIG_ENABLECMDLINEONLY (1<<1) #define CONFIG_ENABLECMDLINEONLY (1<<1)
extern configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags); extern configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags);
/* free ressources used to read parameters, keep memory
* allocated for parameters values which has been defined with the PARAMFLAG_NOFREE flag
* should be used as soon as there is no need to read parameters but doesn't prevent
* a new config module init
*/
extern void end_configmodule(void); extern void end_configmodule(void);
/* free all config module memory, to be used at end of program as
* it will free parameters values even those specified with the PARAMFLAG_NOFREE flag */
extern void free_configmodule(void);
#define CONFIG_PRINTF_ERROR(f, x... ) if (isLogInitDone ()) { LOG_E(ENB_APP,f,x);} else {printf(f,x);}; if ( !CONFIG_ISFLAGSET(CONFIG_NOABORTONCHKF) ) exit_fun("exit because configuration failed\n"); #define CONFIG_PRINTF_ERROR(f, x... ) if (isLogInitDone ()) { LOG_E(ENB_APP,f,x);} else {printf(f,x);}; if ( !CONFIG_ISFLAGSET(CONFIG_NOABORTONCHKF) ) exit_fun("exit because configuration failed\n");
......
...@@ -96,6 +96,8 @@ typedef union checkedparam { ...@@ -96,6 +96,8 @@ typedef union checkedparam {
/* paramdef is used to describe a parameter, array of paramdef_t strustures is used as the main parameter in */ /* paramdef is used to describe a parameter, array of paramdef_t strustures is used as the main parameter in */
/* config apis used to retrieve parameters values */ /* config apis used to retrieve parameters values */
#define MAX_LIST_SIZE 32
#define DEFAULT_EXTRA_SZ 256
typedef struct paramdef { typedef struct paramdef {
char optname[MAX_OPTNAME_SIZE]; /* parameter name, can be used as long command line option */ char optname[MAX_OPTNAME_SIZE]; /* parameter name, can be used as long command line option */
char *helpstr; /* help string */ char *helpstr; /* help string */
......
This diff is collapsed.
...@@ -51,7 +51,7 @@ extern int config_paramidx_fromname(paramdef_t *params,int numparams, char *name ...@@ -51,7 +51,7 @@ extern int config_paramidx_fromname(paramdef_t *params,int numparams, char *name
/* utility functions, to be used by configuration module and/or configuration libraries */ /* utility functions, to be used by configuration module and/or configuration libraries */
extern configmodule_interface_t *config_get_if(void); extern configmodule_interface_t *config_get_if(void);
extern char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) ; void config_check_valptr(paramdef_t *cfgoptions, int elt_sz, int nb_elt);
extern void config_printhelp(paramdef_t *,int numparams, char *prefix); extern void config_printhelp(paramdef_t *,int numparams, char *prefix);
extern int config_process_cmdline(paramdef_t *params,int numparams, char *prefix); extern int config_process_cmdline(paramdef_t *params,int numparams, char *prefix);
extern void config_assign_processedint(paramdef_t *cfgoption, int val); extern void config_assign_processedint(paramdef_t *cfgoption, int val);
...@@ -86,7 +86,7 @@ extern int config_setdefault_int64(paramdef_t *cfgoptions, char *prefix); ...@@ -86,7 +86,7 @@ extern int config_setdefault_int64(paramdef_t *cfgoptions, char *prefix);
extern int config_setdefault_intlist(paramdef_t *cfgoptions, char *prefix); extern int config_setdefault_intlist(paramdef_t *cfgoptions, char *prefix);
extern int config_setdefault_double(paramdef_t *cfgoptions, char *prefix); extern int config_setdefault_double(paramdef_t *cfgoptions, char *prefix);
extern int config_setdefault_ipv4addr(paramdef_t *cfgoptions, char *prefix); extern int config_setdefault_ipv4addr(paramdef_t *cfgoptions, char *prefix);
void *config_allocate_new(int sz, bool autoFree);
#define CONFIG_GETCONFFILE (config_get_if()->cfgP[0]) #define CONFIG_GETCONFFILE (config_get_if()->cfgP[0])
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* \warning * \warning
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
#include <pthread.h>
#include <libconfig.h> #include <libconfig.h>
#include <string.h> #include <string.h>
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
#include "config_libconfig_private.h" #include "config_libconfig_private.h"
#include "../config_userapi.h" #include "../config_userapi.h"
#include "errno.h" #include "errno.h"
#include "assertions.h"
#if ( LIBCONFIG_VER_MAJOR == 1 && LIBCONFIG_VER_MINOR < 5) #if ( LIBCONFIG_VER_MAJOR == 1 && LIBCONFIG_VER_MINOR < 5)
#define config_setting_lookup config_lookup_from #define config_setting_lookup config_lookup_from
...@@ -53,17 +55,18 @@ int read_strlist(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpath ...@@ -53,17 +55,18 @@ int read_strlist(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpath
int st; int st;
int numelt; int numelt;
numelt=config_setting_length(setting); numelt=config_setting_length(setting);
config_check_valptr(cfgoptions,(char **)&(cfgoptions->strlistptr), sizeof(char *) * numelt); config_check_valptr(cfgoptions, sizeof(char *), numelt);
st=0; st=0;
AssertFatal(MAX_LIST_SIZE > numelt,
"This piece of code use fixed size arry of constant #define MAX_LIST_SIZE %d\n",
MAX_LIST_SIZE );
for (int i=0; i< numelt ; i++) { for (int i=0; i< numelt ; i++) {
str=config_setting_get_string_elem(setting,i); str=config_setting_get_string_elem(setting,i);
if (str==NULL) { if (str==NULL) {
printf("[LIBCONFIG] %s%i not found in config file\n", cfgoptions->optname,i); printf("[LIBCONFIG] %s%i not found in config file\n", cfgoptions->optname,i);
} else { } else {
config_check_valptr(cfgoptions,&(cfgoptions->strlistptr[i]),strlen(str)+1); snprintf(cfgoptions->strlistptr[i], DEFAULT_EXTRA_SZ, "%s",str);
sprintf(cfgoptions->strlistptr[i],"%s",str);
st++; st++;
printf_params("[LIBCONFIG] %s%i: %s\n", cfgpath,i,cfgoptions->strlistptr[i]); printf_params("[LIBCONFIG] %s%i: %s\n", cfgpath,i,cfgoptions->strlistptr[i]);
} }
...@@ -77,7 +80,8 @@ int read_intarray(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpat ...@@ -77,7 +80,8 @@ int read_intarray(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpat
cfgoptions->numelt=config_setting_length(setting); cfgoptions->numelt=config_setting_length(setting);
if (cfgoptions->numelt > 0) { if (cfgoptions->numelt > 0) {
cfgoptions->iptr=malloc(sizeof(int) * (cfgoptions->numelt)); cfgoptions->iptr=config_allocate_new(cfgoptions->numelt*sizeof(*cfgoptions->iptr),
!(cfgoptions->paramflags & PARAMFLAG_NOFREE) );
for (int i=0; i< cfgoptions->numelt && cfgoptions->iptr != NULL; i++) { for (int i=0; i< cfgoptions->numelt && cfgoptions->iptr != NULL; i++) {
cfgoptions->iptr[i]=config_setting_get_int_elem(setting,i); cfgoptions->iptr[i]=config_setting_get_int_elem(setting,i);
...@@ -123,23 +127,14 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { ...@@ -123,23 +127,14 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
switch(cfgoptions[i].type) { switch(cfgoptions[i].type) {
case TYPE_STRING: case TYPE_STRING:
if ( config_lookup_string(&(libconfig_privdata.cfg), cfgpath, (const char**)&str)) { if ( config_lookup_string(&(libconfig_privdata.cfg), cfgpath, (const char**)&str)) {
if ( cfgoptions[i].numelt > 0 && str != NULL && strlen(str) >= cfgoptions[i].numelt ) { config_check_valptr(&(cfgoptions[i]), 1, strlen(str)+1);
if ( strlen(str)+1 > cfgoptions[i].numelt )
fprintf(stderr,"[LIBCONFIG] %s: %s exceeds maximum length of %i bytes, value truncated\n", fprintf(stderr,"[LIBCONFIG] %s: %s exceeds maximum length of %i bytes, value truncated\n",
cfgpath,str,cfgoptions[i].numelt); cfgpath,str,cfgoptions[i].numelt);
str[strlen(str)-1] = 0; snprintf( *cfgoptions[i].strptr , cfgoptions[i].numelt, "%s", str);
} printf_params("[LIBCONFIG] %s: \"%s\"\n", cfgpath, *cfgoptions[i].strptr);
if (cfgoptions[i].numelt == 0 ) {
// config_check_valptr(&(cfgoptions[i]), (char **)(&(cfgoptions[i].strptr)), sizeof(char *));
config_check_valptr(&(cfgoptions[i]), cfgoptions[i].strptr, strlen(str)+1);
sprintf( *(cfgoptions[i].strptr) , "%s", str);
printf_params("[LIBCONFIG] %s: \"%s\"\n", cfgpath,*(cfgoptions[i].strptr) );
} else { } else {
sprintf( (char *)(cfgoptions[i].strptr) , "%s", str); defval=config_setdefault_string(&cfgoptions[i],prefix);
printf_params("[LIBCONFIG] %s: \"%s\"\n", cfgpath,(char *)cfgoptions[i].strptr );
}
} else {
defval=config_setdefault_string(&(cfgoptions[i]),prefix);
} }
break; break;
...@@ -163,7 +158,7 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { ...@@ -163,7 +158,7 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
case TYPE_INT32: case TYPE_INT32:
case TYPE_MASK: case TYPE_MASK:
if ( config_lookup_int(&(libconfig_privdata.cfg),cfgpath, &u)) { if ( config_lookup_int(&(libconfig_privdata.cfg),cfgpath, &u)) {
config_check_valptr(&(cfgoptions[i]), (char **)(&(cfgoptions[i].iptr)),sizeof(int32_t)); config_check_valptr(&(cfgoptions[i]), sizeof(*cfgoptions[i].iptr), 1);
config_assign_int(&(cfgoptions[i]),cfgpath,u); config_assign_int(&(cfgoptions[i]),cfgpath,u);
} else { } else {
defval=config_setdefault_int(&(cfgoptions[i]),prefix); defval=config_setdefault_int(&(cfgoptions[i]),prefix);
...@@ -174,14 +169,14 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { ...@@ -174,14 +169,14 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
case TYPE_UINT64: case TYPE_UINT64:
case TYPE_INT64: case TYPE_INT64:
if ( config_lookup_int64(&(libconfig_privdata.cfg),cfgpath, &llu)) { if ( config_lookup_int64(&(libconfig_privdata.cfg),cfgpath, &llu)) {
config_check_valptr(&(cfgoptions[i]), (char **)&(cfgoptions[i].i64ptr),sizeof(long long)); config_check_valptr(&cfgoptions[i], sizeof(*cfgoptions[i].i64ptr), 1);
if(cfgoptions[i].type==TYPE_UINT64) { if(cfgoptions[i].type==TYPE_UINT64) {
*(cfgoptions[i].u64ptr) = (uint64_t)llu; *(cfgoptions[i].u64ptr) = (uint64_t)llu;
printf_params("[LIBCONFIG] %s: %llu\n", cfgpath,(long long unsigned)(*(cfgoptions[i].u64ptr)) ); printf_params("[LIBCONFIG] %s: %lu\n", cfgpath,*cfgoptions[i].u64ptr);
} else { } else {
*(cfgoptions[i].i64ptr) = llu; *(cfgoptions[i].i64ptr) = llu;
printf_params("[LIBCONFIG] %s: %lld\n", cfgpath,(long long)(*(cfgoptions[i].i64ptr)) ); printf_params("[LIBCONFIG] %s: %ld\n", cfgpath,*cfgoptions[i].i64ptr);
} }
} else { } else {
defval=config_setdefault_int64(&(cfgoptions[i]),prefix); defval=config_setdefault_int64(&(cfgoptions[i]),prefix);
...@@ -203,8 +198,8 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { ...@@ -203,8 +198,8 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
case TYPE_DOUBLE: case TYPE_DOUBLE:
if ( config_lookup_float(&(libconfig_privdata.cfg),cfgpath, &dbl)) { if ( config_lookup_float(&(libconfig_privdata.cfg),cfgpath, &dbl)) {
config_check_valptr(&(cfgoptions[i]), (char **)&(cfgoptions[i].dblptr),sizeof(double)); config_check_valptr(&cfgoptions[i],sizeof(*cfgoptions[i].dblptr), 1);
*(cfgoptions[i].dblptr) = dbl; *cfgoptions[i].dblptr = dbl;
printf_params("[LIBCONFIG] %s: %lf\n", cfgpath,*(cfgoptions[i].dblptr) ); printf_params("[LIBCONFIG] %s: %lf\n", cfgpath,*(cfgoptions[i].dblptr) );
} else { } else {
defval=config_setdefault_double(&(cfgoptions[i]),prefix); defval=config_setdefault_double(&(cfgoptions[i]),prefix);
...@@ -304,27 +299,10 @@ int config_libconfig_getlist(paramlist_def_t *ParamList, ...@@ -304,27 +299,10 @@ int config_libconfig_getlist(paramlist_def_t *ParamList,
} }
if (ParamList->numelt > 0 && params != NULL) { if (ParamList->numelt > 0 && params != NULL) {
ParamList->paramarray = malloc(ParamList->numelt * sizeof(paramdef_t *)); ParamList->paramarray = config_allocate_new(ParamList->numelt * sizeof(paramdef_t *), true);
if ( ParamList->paramarray != NULL) {
config_get_if()->ptrs[config_get_if()->numptrs] = (char *)(ParamList->paramarray);
config_get_if()->numptrs++;
} else {
fprintf (stderr,"[LIBCONFIG] %s %d malloc error\n",__FILE__, __LINE__);
exit(-1);
}
for (i=0 ; i < ParamList->numelt ; i++) { for (i=0 ; i < ParamList->numelt ; i++) {
ParamList->paramarray[i] = malloc(numparams * sizeof(paramdef_t)); ParamList->paramarray[i] = config_allocate_new(numparams * sizeof(paramdef_t), true);
if ( ParamList->paramarray[i] != NULL) {
config_get_if()->ptrs[config_get_if()->numptrs] = (char *)(ParamList->paramarray[i]);
config_get_if()->numptrs++;
} else {
fprintf (stderr,"[LIBCONFIG] %s %d malloc error\n",__FILE__, __LINE__);
exit(-1);
}
memcpy(ParamList->paramarray[i], params, sizeof(paramdef_t)*numparams); memcpy(ParamList->paramarray[i], params, sizeof(paramdef_t)*numparams);
for (j=0; j<numparams; j++) { for (j=0; j<numparams; j++) {
...@@ -346,8 +324,8 @@ int config_libconfig_init(char *cfgP[], int numP) { ...@@ -346,8 +324,8 @@ int config_libconfig_init(char *cfgP[], int numP) {
config_init(&(libconfig_privdata.cfg)); config_init(&(libconfig_privdata.cfg));
libconfig_privdata.configfile = strdup((char *)cfgP[0]); libconfig_privdata.configfile = strdup((char *)cfgP[0]);
config_get_if()->numptrs=0; config_get_if()->numptrs=0;
memset(config_get_if()->ptrs,0,sizeof(void *) * CONFIG_MAX_ALLOCATEDPTRS); pthread_mutex_init(&config_get_if()->memBlocks_mutex, NULL);
memset(config_get_if()->ptrsAllocated, 0, sizeof(config_get_if()->ptrsAllocated)); memset(config_get_if()->oneBlock,0,sizeof(config_get_if()->oneBlock));
/* search for include path parameter and set config file include path accordingly */ /* search for include path parameter and set config file include path accordingly */
for (int i=0; i<numP; i++) { for (int i=0; i<numP; i++) {
if (strncmp(cfgP[i],"incp",4) == 0) { if (strncmp(cfgP[i],"incp",4) == 0) {
......
...@@ -325,6 +325,7 @@ void log_getconfig(log_t *g_log) ...@@ -325,6 +325,7 @@ void log_getconfig(log_t *g_log)
logparams_logfile[i].numelt = 0; logparams_logfile[i].numelt = 0;
logparams_level[i].numelt = 0; logparams_level[i].numelt = 0;
logparams_level[i].type = TYPE_STRING; logparams_level[i].type = TYPE_STRING;
logparams_level[i].defstrval= "error";
logparams_logfile[i].type = TYPE_UINT; logparams_logfile[i].type = TYPE_UINT;
logparams_logfile[i].paramflags = logparams_logfile[i].paramflags|PARAMFLAG_BOOL; logparams_logfile[i].paramflags = logparams_logfile[i].paramflags|PARAMFLAG_BOOL;
} }
......
...@@ -393,7 +393,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int ...@@ -393,7 +393,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
/* optname help paramflags XXXptr defXXXval type numelt */ /* optname help paramflags XXXptr defXXXval type numelt */
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define LOG_GLOBALPARAMS_DESC { \ #define LOG_GLOBALPARAMS_DESC { \
{LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, "Default log level for all componemts\n", 0, strptr:(char **)&gloglevel, defstrval:log_level_names[3].name, TYPE_STRING, 0}, \ {LOG_CONFIG_STRING_GLOBAL_LOG_LEVEL, "Default log level for all componemts\n", 0, strptr:&gloglevel, defstrval:log_level_names[3].name, TYPE_STRING, 0}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, "Default console output option, for all components\n", 0, iptr:&(consolelog), defintval:1, TYPE_INT, 0}, \ {LOG_CONFIG_STRING_GLOBAL_LOG_ONLINE, "Default console output option, for all components\n", 0, iptr:&(consolelog), defintval:1, TYPE_INT, 0}, \
{LOG_CONFIG_STRING_GLOBAL_LOG_OPTIONS, LOG_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0} \ {LOG_CONFIG_STRING_GLOBAL_LOG_OPTIONS, LOG_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0} \
} }
......
...@@ -281,5 +281,9 @@ void loader_reset() ...@@ -281,5 +281,9 @@ void loader_reset()
shlib->numfunc = 0; shlib->numfunc = 0;
shlib->len_funcarray = 0; shlib->len_funcarray = 0;
} }
if(loader_data.shlibpath){
free(loader_data.shlibpath);
loader_data.shlibpath=NULL;
}
free(loader_data.shlibs); free(loader_data.shlibs);
} }
...@@ -79,8 +79,8 @@ loader_data_t loader_data; ...@@ -79,8 +79,8 @@ loader_data_t loader_data;
/* optname helpstr paramflags XXXptr defXXXval type numelt check func*/ /* optname helpstr paramflags XXXptr defXXXval type numelt check func*/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define LOADER_PARAMS_DESC { \ #define LOADER_PARAMS_DESC { \
{"shlibpath", NULL, PARAMFLAG_NOFREE, strptr:(char **)&(loader_data.shlibpath), defstrval:DEFAULT_PATH, TYPE_STRING, 0, NULL},\ {"shlibpath", NULL, PARAMFLAG_NOFREE, strptr:&loader_data.shlibpath, defstrval:DEFAULT_PATH, TYPE_STRING, 0, NULL},\
{"maxshlibs", NULL, 0, uptr:&(loader_data.maxshlibs), defintval:DEFAULT_MAXSHLIBS, TYPE_UINT32, 0, NULL}\ {"maxshlibs", NULL, 0, uptr:&(loader_data.maxshlibs),defintval:DEFAULT_MAXSHLIBS, TYPE_UINT32, 0, NULL}\
} }
/*-------------------------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------------------------*/
......
...@@ -181,21 +181,6 @@ nssai_sd=1; ...@@ -181,21 +181,6 @@ nssai_sd=1;
} }
``` ```
Alternatively, the values can be hardcoded/edited in source file ***openair3/UICC/usim_interface.c*** through the following lines:
```bash
#define UICC_PARAMS_DESC {\
{"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsiStr), defstrval:"2089900007487", TYPE_STRING, 0 },\
{"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\
{"key", "USIM Ki\n", 0, strptr:&(uicc->keyStr), defstrval:"fec86ba6eb707ed08905757b1bb44b8f", TYPE_STRING, 0 },\
{"opc", "USIM OPc\n", 0, strptr:&(uicc->opcStr), defstrval:"c42449363bbad02b66d16bc975d77cc1", TYPE_STRING, 0 },\
{"amf", "USIM amf\n", 0, strptr:&(uicc->amfStr), defstrval:"8000", TYPE_STRING, 0 },\
{"sqn", "USIM sqn\n", 0, strptr:&(uicc->sqnStr), defstrval:"000000", TYPE_STRING, 0 },\
{"dnn", "UE dnn (apn)\n", 0, strptr:&(uicc->dnnStr), defstrval:"oai", TYPE_STRING, 0 },\
{"nssai_sst", "UE nssai\n", 0, iptr:&(uicc->nssai_sst), defintval:1, TYPE_INT, 0 }, \
{"nssai_sd", "UE nssai\n", 0, iptr:&(uicc->nssai_sd), defintval:1, TYPE_INT, 0 }, \
};
```
For interoperability with OAI or other CNs, it should be ensured that the configuration of the aforementioned parameters match the configuration of the corresponding subscribed user at the core network. For interoperability with OAI or other CNs, it should be ensured that the configuration of the aforementioned parameters match the configuration of the corresponding subscribed user at the core network.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
{"D" , CONFIG_HLP_DLBM_PHYTEST,0, u64ptr:&dlsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \ {"D" , CONFIG_HLP_DLBM_PHYTEST,0, u64ptr:&dlsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \
{"U" , CONFIG_HLP_ULBM_PHYTEST,0, u64ptr:&ulsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \ {"U" , CONFIG_HLP_ULBM_PHYTEST,0, u64ptr:&ulsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \
{"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \
{"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \
{"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \ {"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \
} }
......
...@@ -29,15 +29,15 @@ ...@@ -29,15 +29,15 @@
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*------------------------------------------------------------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_NRUEPARAMS_DESC { \ #define CMDLINE_NRUEPARAMS_DESC { \
{"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200", TYPE_STRING, 0}, \ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:&usrp_args, defstrval:"type=b200", TYPE_STRING, 0}, \
{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ {"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \
{"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, u8ptr:&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \ {"dlsch-parallel", CONFIG_HLP_DLSCH_PARA, 0, u8ptr:&nrUE_params.nr_dlsch_parallel, defintval:0, TYPE_UINT8, 0}, \
{"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:&nrUE_params.ofdm_offset_divisor, defuintval:8, TYPE_UINT32, 0}, \ {"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:&nrUE_params.ofdm_offset_divisor, defuintval:8, TYPE_UINT32, 0}, \
{"max-ldpc-iterations", CONFIG_HLP_MAX_LDPC_ITERATIONS, 0, u8ptr:&nrUE_params.max_ldpc_iterations, defuintval:5, TYPE_UINT8, 0}, \ {"max-ldpc-iterations", CONFIG_HLP_MAX_LDPC_ITERATIONS, 0, u8ptr:&nrUE_params.max_ldpc_iterations, defuintval:5, TYPE_UINT8, 0}, \
{"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \
{"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \ {"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \
{"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0}, \ {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:&rrc_config_path, defstrval:"./", TYPE_STRING, 0}, \
{"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0} \ {"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0} \
} }
......
...@@ -137,9 +137,9 @@ extern "C" ...@@ -137,9 +137,9 @@ extern "C"
extern int usrp_tx_thread; extern int usrp_tx_thread;
#define CMDLINE_PARAMS_DESC { \ #define CMDLINE_PARAMS_DESC { \
{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, sizeof(RF_CONFIG_FILE)},\ {"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, 0},\
{"split73", CONFIG_HLP_SPLIT73, 0, strptr:(char **)&SPLIT73, defstrval:NULL, TYPE_STRING, sizeof(SPLIT73)}, \ {"split73", CONFIG_HLP_SPLIT73, 0, strptr:&SPLIT73, defstrval:NULL, TYPE_STRING, 0}, \
{"thread-pool", CONFIG_HLP_TPOOL, 0, strptr:(char **)&TP_CONFIG, defstrval:"n", TYPE_STRING, sizeof(TP_CONFIG)}, \ {"thread-pool", CONFIG_HLP_TPOOL, 0, strptr:&TP_CONFIG, defstrval:"n", TYPE_STRING, 0}, \
{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&PHY_TEST, defintval:0, TYPE_INT, 0}, \ {"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&PHY_TEST, defintval:0, TYPE_INT, 0}, \
{"do-ra", CONFIG_HLP_DORA, PARAMFLAG_BOOL, iptr:&DO_RA, defintval:0, TYPE_INT, 0}, \ {"do-ra", CONFIG_HLP_DORA, PARAMFLAG_BOOL, iptr:&DO_RA, defintval:0, TYPE_INT, 0}, \
{"sa", CONFIG_HLP_SA, PARAMFLAG_BOOL, iptr:&SA, defintval:0, TYPE_INT, 0}, \ {"sa", CONFIG_HLP_SA, PARAMFLAG_BOOL, iptr:&SA, defintval:0, TYPE_INT, 0}, \
...@@ -157,8 +157,8 @@ extern int usrp_tx_thread; ...@@ -157,8 +157,8 @@ extern int usrp_tx_thread;
{"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&NUMEROLOGY, defintval:1, TYPE_INT, 0}, \ {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&NUMEROLOGY, defintval:1, TYPE_INT, 0}, \
{"band" , CONFIG_HLP_BAND, PARAMFLAG_BOOL, iptr:&BAND, defintval:78, TYPE_INT, 0}, \ {"band" , CONFIG_HLP_BAND, PARAMFLAG_BOOL, iptr:&BAND, defintval:78, TYPE_INT, 0}, \
{"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&EMULATE_RF, defintval:0, TYPE_INT, 0}, \ {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&EMULATE_RF, defintval:0, TYPE_INT, 0}, \
{"parallel-config", CONFIG_HLP_PARALLEL_CMD, 0, strptr:(char **)&parallel_config, defstrval:NULL, TYPE_STRING, 0}, \ {"parallel-config", CONFIG_HLP_PARALLEL_CMD, 0, strptr:&parallel_config, defstrval:NULL, TYPE_STRING, 0}, \
{"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_config, defstrval:NULL, TYPE_STRING, 0}, \ {"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:&worker_config, defstrval:NULL, TYPE_STRING, 0}, \
{"noS1", CONFIG_HLP_NOS1, PARAMFLAG_BOOL, uptr:&noS1, defintval:0, TYPE_INT, 0}, \ {"noS1", CONFIG_HLP_NOS1, PARAMFLAG_BOOL, uptr:&noS1, defintval:0, TYPE_INT, 0}, \
{"rfsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&rfsim, defintval:0, TYPE_INT, 0}, \ {"rfsim", CONFIG_HLP_RFSIM, PARAMFLAG_BOOL, uptr:&rfsim, defintval:0, TYPE_INT, 0}, \
{"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \ {"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \
...@@ -189,7 +189,7 @@ extern int usrp_tx_thread; ...@@ -189,7 +189,7 @@ extern int usrp_tx_thread;
{CONFIG_FLOG_OPT , CONFIG_HLP_FLOG, 0, uptr:&online_log_messages, defintval:1, TYPE_INT, 0}, \ {CONFIG_FLOG_OPT , CONFIG_HLP_FLOG, 0, uptr:&online_log_messages, defintval:1, TYPE_INT, 0}, \
{CONFIG_LOGL_OPT , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \ {CONFIG_LOGL_OPT , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \
{"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \ {"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \
{"log-mem", NULL, 0, strptr:(char **)&logmem_filename, defstrval:NULL, TYPE_STRING, 0}, \ {"log-mem", NULL, 0, strptr:&logmem_filename, defstrval:NULL, TYPE_STRING, 0}, \
{"telnetclt", NULL, 0, uptr:&start_telnetclt, defstrval:NULL, TYPE_UINT, 0}, \ {"telnetclt", NULL, 0, uptr:&start_telnetclt, defstrval:NULL, TYPE_UINT, 0}, \
} }
...@@ -242,9 +242,9 @@ extern int usrp_tx_thread; ...@@ -242,9 +242,9 @@ extern int usrp_tx_thread;
typedef struct { typedef struct {
uint64_t optmask; uint64_t optmask;
//THREAD_STRUCT thread_struct; //THREAD_STRUCT thread_struct;
char rf_config_file[1024]; char *rf_config_file;
char split73[1024]; char *split73;
char threadPoolConfig[1024]; char *threadPoolConfig;
int phy_test; int phy_test;
int do_ra; int do_ra;
int sa; int sa;
......
...@@ -658,7 +658,7 @@ int main(int argc, char **argv) ...@@ -658,7 +658,7 @@ int main(int argc, char **argv)
if (ouput_vcd) if (ouput_vcd)
vcd_signal_dumper_close(); vcd_signal_dumper_close();
end_configmodule();
loader_reset(); loader_reset();
logTerm(); logTerm();
......
...@@ -62,7 +62,7 @@ static double snr_dB=25; ...@@ -62,7 +62,7 @@ static double snr_dB=25;
static double sinr_dB=0; static double sinr_dB=0;
static unsigned int max_chan; static unsigned int max_chan;
static channel_desc_t **defined_channels; static channel_desc_t **defined_channels;
static char modellist_name[MAX_OPTNAME_SIZE]= {0}; static char *modellist_name;
void fill_channel_desc(channel_desc_t *chan_desc, void fill_channel_desc(channel_desc_t *chan_desc,
......
...@@ -253,7 +253,7 @@ typedef enum { ...@@ -253,7 +253,7 @@ typedef enum {
{"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0},\ {"s" , CONFIG_HLP_SNR, PARAMFLAG_CMDLINE_NOPREFIXENABLED, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0},\
{"sinr_dB", NULL, 0, dblptr:&sinr_dB, defdblval:0 , TYPE_DOUBLE, 0},\ {"sinr_dB", NULL, 0, dblptr:&sinr_dB, defdblval:0 , TYPE_DOUBLE, 0},\
{"max_chan", "Max number of runtime models", 0, uptr:&max_chan, defintval:10, TYPE_UINT, 0},\ {"max_chan", "Max number of runtime models", 0, uptr:&max_chan, defintval:10, TYPE_UINT, 0},\
{CHANNELMOD_MODELLIST_PARANAME, CHANNELMOD_HELP_MODELLIST, 0, strptr:(char **)&modellist_name, defstrval:"DefaultChannelList", TYPE_STRING, 60 },\ {CHANNELMOD_MODELLIST_PARANAME, CHANNELMOD_HELP_MODELLIST, 0, strptr:&modellist_name, defstrval:"DefaultChannelList", TYPE_STRING, 0},\
} }
/* parameters for one model */ /* parameters for one model */
......
...@@ -220,7 +220,7 @@ typedef struct ccparams_eMTC_s { ...@@ -220,7 +220,7 @@ typedef struct ccparams_eMTC_s {
{ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE, NULL, 0, iptr:&eMTCconfig->ccparams.pcch_defaultPagingCycle, defintval:128, TYPE_INT, 0}, \ {ENB_CONFIG_STRING_PCCH_DEFAULT_PAGING_CYCLE, NULL, 0, iptr:&eMTCconfig->ccparams.pcch_defaultPagingCycle, defintval:128, TYPE_INT, 0}, \
{ENB_CONFIG_STRING_PCCH_NB, NULL, 0, strptr:&eMTCconfig->ccparams.pcch_nB, defstrval:"oneT", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_PCCH_NB, NULL, 0, strptr:&eMTCconfig->ccparams.pcch_nB, defstrval:"oneT", TYPE_STRING, 0}, \
{ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF, NULL, 0, iptr:&eMTCconfig->ccparams.bcch_modificationPeriodCoeff, defintval:2, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_BCCH_MODIFICATIONPERIODCOEFF, NULL, 0, iptr:&eMTCconfig->ccparams.bcch_modificationPeriodCoeff, defintval:2, TYPE_UINT, 0}, \
{ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG, NULL, 0, strptr:&eMTCconfig->ccparams.rach_preamblesGroupAConfig, defstrval:"", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_RACH_PREAMBLESGROUPACONFIG, NULL, 0, strptr:&eMTCconfig->ccparams.rach_preamblesGroupAConfig, defstrval:"DISABLE", TYPE_STRING, 0}, \
{ENB_CONFIG_STRING_UETIMERS_T300, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t300, defintval:1000, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_UETIMERS_T300, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t300, defintval:1000, TYPE_UINT, 0}, \
{ENB_CONFIG_STRING_UETIMERS_T301, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t301, defintval:1000, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_UETIMERS_T301, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t301, defintval:1000, TYPE_UINT, 0}, \
{ENB_CONFIG_STRING_UETIMERS_T310, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t310, defintval:1000, TYPE_UINT, 0}, \ {ENB_CONFIG_STRING_UETIMERS_T310, NULL, 0, iptr:&eMTCconfig->ccparams.ue_TimersAndConstants_t310, defintval:1000, TYPE_UINT, 0}, \
......
This diff is collapsed.
...@@ -238,8 +238,7 @@ void mac_top_init_gNB(ngran_node_t node_type) ...@@ -238,8 +238,7 @@ void mac_top_init_gNB(ngran_node_t node_type)
RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0); RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0);
} }
if (!IS_SOFTMODEM_NOSTATS_BIT) if (!IS_SOFTMODEM_NOSTATS_BIT)
pthread_create(&RC.nrmac[i]->stats_thread, NULL, nrmac_stats_thread, (void*)RC.nrmac[i]); threadCreate(&RC.nrmac[i]->stats_thread, nrmac_stats_thread, (void*)RC.nrmac[i], "MAC_STATS", -1, sched_get_priority_min(SCHED_OAI)+1 );
mac_rrc_init(RC.nrmac[i], node_type); mac_rrc_init(RC.nrmac[i], node_type);
}//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
......
...@@ -56,7 +56,9 @@ char *broadcastAddr ; ...@@ -56,7 +56,9 @@ char *broadcastAddr ;
#define NASHLP_NETMASK "<NAS network mask>\n" #define NASHLP_NETMASK "<NAS network mask>\n"
#define NASHLP_BROADCASTADDR "<NAS network broadcast address>\n" #define NASHLP_BROADCASTADDR "<NAS network broadcast address>\n"
void nas_getparams(void) { void nas_getparams(void) {
paramdef_t nasoptions[] = { // this datamodel require this static because we partially keep data like baseNetAddress (malloc on a global)
// but we loose the opther attributes in nasoptions between two calls if is is not static !
static paramdef_t nasoptions[] = {
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* configuration parameters for netlink, includes network parameters when running in noS1 mode */ /* configuration parameters for netlink, includes network parameters when running in noS1 mode */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
......
...@@ -74,9 +74,9 @@ typedef guint8 gboolean; ...@@ -74,9 +74,9 @@ typedef guint8 gboolean;
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*---------------------------------------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------------------------------------*/
#define OPT_PARAMS_DESC { \ #define OPT_PARAMS_DESC { \
{"type" , CONFIG_HLP_TYPEMON, 0, strptr:(char**)&in_type, defstrval:"none", TYPE_STRING, 0}, \ {"type" , CONFIG_HLP_TYPEMON, 0, strptr:&in_type, defstrval:"none", TYPE_STRING, 0}, \
{"ip" , CONFIG_HLP_L2MONIP, 0, strptr:(char**)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, 0}, \ {"ip" , CONFIG_HLP_L2MONIP, 0, strptr:&in_ip, defstrval:"127.0.0.1", TYPE_STRING, 0}, \
{"path" , CONFIG_HLP_L2MONPATH, 0, strptr:(char**)&in_path,defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \ {"path" , CONFIG_HLP_L2MONPATH, 0, strptr:&in_path,defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \
} }
#define OPTTYPE_IDX 0 #define OPTTYPE_IDX 0
......
...@@ -540,9 +540,6 @@ void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsign ...@@ -540,9 +540,6 @@ void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsign
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int init_opt(void) { int init_opt(void) {
in_type=malloc(200);
in_ip=malloc(200);
in_path=malloc(200);
paramdef_t opt_params[] = OPT_PARAMS_DESC ; paramdef_t opt_params[] = OPT_PARAMS_DESC ;
checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC; checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC;
config_set_checkfunctions(opt_params, opt_checkParams, config_set_checkfunctions(opt_params, opt_checkParams,
......
...@@ -35,16 +35,16 @@ extern uint16_t NB_UE_INST; ...@@ -35,16 +35,16 @@ extern uint16_t NB_UE_INST;
/* configuration parameters for the rfsimulator device */ /* configuration parameters for the rfsimulator device */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define UICC_PARAMS_DESC {\ #define UICC_PARAMS_DESC { \
{"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsiStr), defstrval:"2089900007487", TYPE_STRING, 0 },\ {"imsi", "USIM IMSI\n", 0, strptr:&uicc->imsiStr, defstrval:"2089900007487", TYPE_STRING, 0 }, \
{"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\ {"nmc_size" "number of digits in NMC", 0, iptr:&uicc->nmc_size, defintval:2, TYPE_INT, 0 }, \
{"key", "USIM Ki\n", 0, strptr:&(uicc->keyStr), defstrval:"fec86ba6eb707ed08905757b1bb44b8f", TYPE_STRING, 0 },\ {"key", "USIM Ki\n", 0, strptr:&uicc->keyStr, defstrval:"fec86ba6eb707ed08905757b1bb44b8f", TYPE_STRING, 0 }, \
{"opc", "USIM OPc\n", 0, strptr:&(uicc->opcStr), defstrval:"c42449363bbad02b66d16bc975d77cc1", TYPE_STRING, 0 },\ {"opc", "USIM OPc\n", 0, strptr:&uicc->opcStr, defstrval:"c42449363bbad02b66d16bc975d77cc1", TYPE_STRING, 0 }, \
{"amf", "USIM amf\n", 0, strptr:&(uicc->amfStr), defstrval:"8000", TYPE_STRING, 0 },\ {"amf", "USIM amf\n", 0, strptr:&uicc->amfStr, defstrval:"8000", TYPE_STRING, 0 }, \
{"sqn", "USIM sqn\n", 0, strptr:&(uicc->sqnStr), defstrval:"000000", TYPE_STRING, 0 },\ {"sqn", "USIM sqn\n", 0, strptr:&uicc->sqnStr, defstrval:"000000", TYPE_STRING, 0 }, \
{"dnn", "UE dnn (apn)\n", 0, strptr:&(uicc->dnnStr), defstrval:"oai", TYPE_STRING, 0 },\ {"dnn", "UE dnn (apn)\n", 0, strptr:&uicc->dnnStr, defstrval:"oai", TYPE_STRING, 0 }, \
{"nssai_sst", "UE nssai\n", 0, iptr:&(uicc->nssai_sst), defintval:1, TYPE_INT, 0 }, \ {"nssai_sst", "UE nssai\n", 0, iptr:&uicc->nssai_sst, defintval:1, TYPE_INT, 0 }, \
{"nssai_sd", "UE nssai\n", 0, iptr:&(uicc->nssai_sd), defintval:1, TYPE_INT, 0 }, \ {"nssai_sd", "UE nssai\n", 0, iptr:&uicc->nssai_sd, defintval:1, TYPE_INT, 0 }, \
}; };
static uicc_t** uiccArray=NULL; static uicc_t** uiccArray=NULL;
......
...@@ -95,7 +95,7 @@ typedef struct { ...@@ -95,7 +95,7 @@ typedef struct {
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define DEVICE_RECPLAY_PARAMS_DESC { \ #define DEVICE_RECPLAY_PARAMS_DESC { \
{CONFIG_OPT_SF_FILE, CONFIG_HLP_SF_FILE, 0, strptr:(char **)((*recplay_conf)->u_sf_filename), defstrval:DEF_SF_FILE, TYPE_STRING, 1024}, \ {CONFIG_OPT_SF_FILE, CONFIG_HLP_SF_FILE, 0, strptr:&((*recplay_conf)->u_sf_filename), defstrval:DEF_SF_FILE, TYPE_STRING, 0}, \
{CONFIG_OPT_SF_REC, CONFIG_HLP_SF_REC, PARAMFLAG_BOOL, uptr:&(u_sf_record), defuintval:0, TYPE_UINT, 0}, \ {CONFIG_OPT_SF_REC, CONFIG_HLP_SF_REC, PARAMFLAG_BOOL, uptr:&(u_sf_record), defuintval:0, TYPE_UINT, 0}, \
{CONFIG_OPT_SF_REP, CONFIG_HLP_SF_REP, PARAMFLAG_BOOL, uptr:&(u_sf_replay), defuintval:0, TYPE_UINT, 0}, \ {CONFIG_OPT_SF_REP, CONFIG_HLP_SF_REP, PARAMFLAG_BOOL, uptr:&(u_sf_replay), defuintval:0, TYPE_UINT, 0}, \
{CONFIG_OPT_SF_MAX, CONFIG_HLP_SF_MAX, 0, uptr:&((*recplay_conf)->u_sf_max), defintval:DEF_NB_SF, TYPE_UINT, 0}, \ {CONFIG_OPT_SF_MAX, CONFIG_HLP_SF_MAX, 0, uptr:&((*recplay_conf)->u_sf_max), defintval:DEF_NB_SF, TYPE_UINT, 0}, \
...@@ -105,7 +105,7 @@ typedef struct { ...@@ -105,7 +105,7 @@ typedef struct {
{CONFIG_OPT_USE_MMAP, CONFIG_HLP_USE_MMAP, PARAMFLAG_BOOL, uptr:&((*recplay_conf)->use_mmap), defuintval:1, TYPE_UINT, 0}, \ {CONFIG_OPT_USE_MMAP, CONFIG_HLP_USE_MMAP, PARAMFLAG_BOOL, uptr:&((*recplay_conf)->use_mmap), defuintval:1, TYPE_UINT, 0}, \
}/*! \brief Record Player Configuration and state */ }/*! \brief Record Player Configuration and state */
typedef struct { typedef struct {
char u_sf_filename[1024]; // subframes file path char *u_sf_filename; // subframes file path
unsigned int u_sf_max ; // max number of recorded subframes unsigned int u_sf_max ; // max number of recorded subframes
unsigned int u_sf_loops ; // number of loops in replay mode unsigned int u_sf_loops ; // number of loops in replay mode
unsigned int u_sf_read_delay; // read delay in replay mode unsigned int u_sf_read_delay; // read delay in replay mode
......
...@@ -77,11 +77,11 @@ ...@@ -77,11 +77,11 @@
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define simOpt PARAMFLAG_NOFREE|PARAMFLAG_CMDLINE_NOPREFIXENABLED #define simOpt PARAMFLAG_NOFREE|PARAMFLAG_CMDLINE_NOPREFIXENABLED
#define RFSIMULATOR_PARAMS_DESC { \ #define RFSIMULATOR_PARAMS_DESC { \
{"serveraddr", "<ip address to connect to>\n", simOpt, strptr:&(rfsimulator->ip), defstrval:"127.0.0.1", TYPE_STRING, 0 },\ {"serveraddr", "<ip address to connect to>\n", simOpt, strptr:&rfsimulator->ip, defstrval:"127.0.0.1", TYPE_STRING, 0 },\
{"serverport", "<port to connect to>\n", simOpt, u16ptr:&(rfsimulator->port), defuintval:PORT, TYPE_UINT16, 0 },\ {"serverport", "<port to connect to>\n", simOpt, u16ptr:&(rfsimulator->port), defuintval:PORT, TYPE_UINT16, 0 },\
{RFSIMU_OPTIONS_PARAMNAME, RFSIM_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST,0 },\ {RFSIMU_OPTIONS_PARAMNAME, RFSIM_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST,0 },\
{"IQfile", "<file path to use when saving IQs>\n",simOpt, strptr:&(saveF), defstrval:"/tmp/rfsimulator.iqs",TYPE_STRING, 0 },\ {"IQfile", "<file path to use when saving IQs>\n",simOpt, strptr:&saveF, defstrval:"/tmp/rfsimulator.iqs",TYPE_STRING, 0 },\
{"modelname", "<channel model name>\n", simOpt, strptr:&(modelname), defstrval:"AWGN", TYPE_STRING, 0 },\ {"modelname", "<channel model name>\n", simOpt, strptr:&modelname, defstrval:"AWGN", TYPE_STRING, 0 },\
{"ploss", "<channel path loss in dB>\n", simOpt, dblptr:&(rfsimulator->chan_pathloss), defdblval:0, TYPE_DOUBLE, 0 },\ {"ploss", "<channel path loss in dB>\n", simOpt, dblptr:&(rfsimulator->chan_pathloss), defdblval:0, TYPE_DOUBLE, 0 },\
{"forgetfact", "<channel forget factor ((0 to 1)>\n", simOpt, dblptr:&(rfsimulator->chan_forgetfact), defdblval:0, TYPE_DOUBLE, 0 },\ {"forgetfact", "<channel forget factor ((0 to 1)>\n", simOpt, dblptr:&(rfsimulator->chan_forgetfact), defdblval:0, TYPE_DOUBLE, 0 },\
{"offset", "<channel offset in samps>\n", simOpt, iptr:&(rfsimulator->chan_offset), defintval:0, TYPE_INT, 0 }\ {"offset", "<channel offset in samps>\n", simOpt, iptr:&(rfsimulator->chan_offset), defintval:0, TYPE_INT, 0 }\
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
{"nums_ue_thread", NULL, 0, u16ptr:&(NB_THREAD_INST), defuintval:1, TYPE_UINT16, 0}, \ {"nums_ue_thread", NULL, 0, u16ptr:&(NB_THREAD_INST), defuintval:1, TYPE_UINT16, 0}, \
{"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \ {"r" , CONFIG_HLP_PRB, 0, u8ptr:&(frame_parms[0]->N_RB_DL), defintval:25, TYPE_UINT8, 0}, \
{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ {"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
{"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:(char **)&usrp_args, defstrval:"type=b200",TYPE_STRING, 0}, \ {"usrp-args", CONFIG_HLP_USRP_ARGS, 0, strptr:&usrp_args, defstrval:"type=b200",TYPE_STRING, 0}, \
{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ {"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \
{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \
{"A", CONFIG_HLP_TADV, 0, iptr:&(timingadv), defintval:0, TYPE_INT, 0}, \ {"A", CONFIG_HLP_TADV, 0, iptr:&(timingadv), defintval:0, TYPE_INT, 0}, \
......
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