Commit 65b399fc authored by laurent's avatar laurent

fix bugs in config module and config usage

fix bug from this MR

fix bug from this MR

stupid-mistake
parent 61312ca6
......@@ -53,13 +53,15 @@ int parse_stringlist(paramdef_t *cfgoptions, char *val) {
}
free(tmpval);
config_check_valptr(cfgoptions,(char **)&(cfgoptions->strlistptr), sizeof(char *) * numelt);
AssertFatal(MAX_LIST_SIZE > numelt, "");
config_check_valptr(cfgoptions, sizeof(char*), numelt);
cfgoptions->numelt=numelt;
atoken=strtok_r(val, ",",&tokctx);
for( int i=0; i<cfgoptions->numelt && atoken != NULL ; i++) {
config_check_valptr(cfgoptions,&(cfgoptions->strlistptr[i]),strlen(atoken)+1);
sprintf(cfgoptions->strlistptr[i],"%s",atoken);
snprintf(cfgoptions->strlistptr[i],DEFAULT_EXTRA_SZ,"%s",atoken);
printf_params("[LIBCONFIG] %s[%i]: %s\n", cfgoptions->optname,i,cfgoptions->strlistptr[i]);
atoken=strtok_r(NULL, ",",&tokctx);
}
......@@ -84,13 +86,14 @@ int processoption(paramdef_t *cfgoptions, char *value) {
char *charptr;
case TYPE_STRING:
if (cfgoptions->numelt == 0 ) {
config_check_valptr(cfgoptions, cfgoptions->strptr, strlen(tmpval)+1);
sprintf(*(cfgoptions->strptr), "%s",tmpval);
} else {
sprintf( (char *)(cfgoptions->strptr), "%s",tmpval);
if (cfgoptions->numelt == 0 )
config_check_valptr(cfgoptions, 1,
strlen(tmpval)+1);
if (cfgoptions->numelt < (strlen(tmpval)+1)) {
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);
optisset=1;
break;
......@@ -105,7 +108,7 @@ int processoption(paramdef_t *cfgoptions, char *value) {
case TYPE_INT16:
case TYPE_UINT8:
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));
if( *charptr != 0) {
......@@ -117,14 +120,14 @@ int processoption(paramdef_t *cfgoptions, char *value) {
case TYPE_UINT64:
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);
if( *charptr != 0) {
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;
break;
......@@ -133,8 +136,8 @@ int processoption(paramdef_t *cfgoptions, char *value) {
break;
case TYPE_DOUBLE:
config_check_valptr(cfgoptions, (char **)&(cfgoptions->dblptr),sizeof(double));
*(cfgoptions->dblptr) = strtof(tmpval,&charptr);
config_check_valptr(cfgoptions, sizeof(*cfgoptions->dblptr), 1);
*cfgoptions->dblptr = strtof(tmpval,&charptr);
if( *charptr != 0) {
CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires a double argument\n",cfgoptions->optname);
......
......@@ -336,17 +336,18 @@ void end_configmodule(void) {
cfgptr->end();
}
pthread_mutex_lock(&cfgptr->memBlocks_mutex);
printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs);
for(int i=0; i<cfgptr->numptrs ; i++) {
if (cfgptr->ptrs[i] != NULL && cfgptr->ptrsAllocated[i] == true) {
free(cfgptr->ptrs[i]);
cfgptr->ptrs[i]=NULL;
cfgptr->ptrsAllocated[i] = false;
if (cfgptr->oneBlock[i].ptrs != NULL && cfgptr->oneBlock[i].ptrsAllocated== true && cfgptr->oneBlock[i].toFree) {
free(cfgptr->oneBlock[i].ptrs);
memset(&cfgptr->oneBlock[i], 0, sizeof(cfgptr->oneBlock[i]));
}
}
cfgptr->numptrs=0;
pthread_mutex_unlock(&cfgptr->memBlocks_mutex);
}
}
......
......@@ -41,7 +41,7 @@
#include "common/config/config_paramdesc.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_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 */
#define CONFIG_LIBCONFIGFILE "libconfig" // use libconfig file
......@@ -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_getlistfunc_t)(paramlist_def_t *, paramdef_t *,int numparams, char *prefix);
typedef void(*configmodule_endfunc_t)(void);
typedef struct oneBlock_s{
void *ptrs;
int sz;
bool toFree;
bool ptrsAllocated;
} oneBlock_t;
typedef struct configmodule_interface {
int argc;
char **argv;
......@@ -73,10 +81,10 @@ typedef struct configmodule_interface {
configmodule_getfunc_t get;
configmodule_getlistfunc_t getlist;
configmodule_endfunc_t end;
pthread_mutex_t memBlocks_mutex;
uint32_t numptrs;
uint32_t rtflags;
char *ptrs[CONFIG_MAX_ALLOCATEDPTRS];
bool ptrsAllocated[CONFIG_MAX_ALLOCATEDPTRS];
oneBlock_t oneBlock[CONFIG_MAX_ALLOCATEDPTRS];
} configmodule_interface_t;
#ifdef CONFIG_LOADCONFIG_MAIN
......
......@@ -96,11 +96,13 @@ typedef union checkedparam {
/* 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 */
#define MAX_LIST_SIZE 32
#define DEFAULT_EXTRA_SZ 256
typedef struct paramdef {
char optname[MAX_OPTNAME_SIZE]; /* parameter name, can be used as long command line option */
char *helpstr; /* help string */
unsigned int paramflags; /* value is a "ored" combination of above PARAMFLAG_XXXX values */
union { /* pointer to the parameter value, completed by the config module */
union { /* pointer to the parameter value, completed by the config module */
char **strptr;
char **strlistptr;
uint8_t *u8ptr;
......
This diff is collapsed.
......@@ -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 */
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 int config_process_cmdline(paramdef_t *params,int numparams, char *prefix);
extern void config_assign_processedint(paramdef_t *cfgoption, int val);
......@@ -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_double(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])
#ifdef __cplusplus
......
......@@ -29,6 +29,7 @@
* \warning
*/
#define _GNU_SOURCE
#include <pthread.h>
#include <libconfig.h>
#include <string.h>
......@@ -41,6 +42,7 @@
#include "config_libconfig_private.h"
#include "../config_userapi.h"
#include "errno.h"
#include "assertions.h"
#if ( LIBCONFIG_VER_MAJOR == 1 && LIBCONFIG_VER_MINOR < 5)
#define config_setting_lookup config_lookup_from
......@@ -53,17 +55,16 @@ int read_strlist(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpath
int st;
int numelt;
numelt=config_setting_length(setting);
config_check_valptr(cfgoptions,(char **)&(cfgoptions->strlistptr), sizeof(char *) * numelt);
config_check_valptr(cfgoptions, sizeof(char *), numelt);
st=0;
AssertFatal(MAX_LIST_SIZE > numelt, "");
for (int i=0; i< numelt ; i++) {
str=config_setting_get_string_elem(setting,i);
if (str==NULL) {
printf("[LIBCONFIG] %s%i not found in config file\n", cfgoptions->optname,i);
} else {
config_check_valptr(cfgoptions,&(cfgoptions->strlistptr[i]),strlen(str)+1);
sprintf(cfgoptions->strlistptr[i],"%s",str);
snprintf(cfgoptions->strlistptr[i], DEFAULT_EXTRA_SZ, "%s",str);
st++;
printf_params("[LIBCONFIG] %s%i: %s\n", cfgpath,i,cfgoptions->strlistptr[i]);
}
......@@ -77,7 +78,8 @@ int read_intarray(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpat
cfgoptions->numelt=config_setting_length(setting);
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++) {
cfgoptions->iptr[i]=config_setting_get_int_elem(setting,i);
......@@ -123,23 +125,14 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
switch(cfgoptions[i].type) {
case TYPE_STRING:
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",
cfgpath,str,cfgoptions[i].numelt);
str[strlen(str)-1] = 0;
}
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 {
sprintf( (char *)(cfgoptions[i].strptr) , "%s", str);
printf_params("[LIBCONFIG] %s: \"%s\"\n", cfgpath,(char *)cfgoptions[i].strptr );
}
snprintf( *cfgoptions[i].strptr , cfgoptions[i].numelt, "%s", str);
printf_params("[LIBCONFIG] %s: \"%s\"\n", cfgpath, *cfgoptions[i].strptr);
} else {
defval=config_setdefault_string(&(cfgoptions[i]),prefix);
defval=config_setdefault_string(&cfgoptions[i],prefix);
}
break;
......@@ -163,7 +156,7 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
case TYPE_INT32:
case TYPE_MASK:
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);
} else {
defval=config_setdefault_int(&(cfgoptions[i]),prefix);
......@@ -174,14 +167,14 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
case TYPE_UINT64:
case TYPE_INT64:
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) {
*(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 {
*(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 {
defval=config_setdefault_int64(&(cfgoptions[i]),prefix);
......@@ -203,8 +196,8 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
case TYPE_DOUBLE:
if ( config_lookup_float(&(libconfig_privdata.cfg),cfgpath, &dbl)) {
config_check_valptr(&(cfgoptions[i]), (char **)&(cfgoptions[i].dblptr),sizeof(double));
*(cfgoptions[i].dblptr) = dbl;
config_check_valptr(&cfgoptions[i],sizeof(*cfgoptions[i].dblptr), 1);
*cfgoptions[i].dblptr = dbl;
printf_params("[LIBCONFIG] %s: %lf\n", cfgpath,*(cfgoptions[i].dblptr) );
} else {
defval=config_setdefault_double(&(cfgoptions[i]),prefix);
......@@ -304,27 +297,10 @@ int config_libconfig_getlist(paramlist_def_t *ParamList,
}
if (ParamList->numelt > 0 && params != NULL) {
ParamList->paramarray = malloc(ParamList->numelt * sizeof(paramdef_t *));
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);
}
ParamList->paramarray = config_allocate_new(ParamList->numelt * sizeof(paramdef_t *), true);
for (i=0 ; i < ParamList->numelt ; i++) {
ParamList->paramarray[i] = malloc(numparams * sizeof(paramdef_t));
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);
}
ParamList->paramarray[i] = config_allocate_new(numparams * sizeof(paramdef_t), true);
memcpy(ParamList->paramarray[i], params, sizeof(paramdef_t)*numparams);
for (j=0; j<numparams; j++) {
......@@ -346,8 +322,8 @@ int config_libconfig_init(char *cfgP[], int numP) {
config_init(&(libconfig_privdata.cfg));
libconfig_privdata.configfile = strdup((char *)cfgP[0]);
config_get_if()->numptrs=0;
memset(config_get_if()->ptrs,0,sizeof(void *) * CONFIG_MAX_ALLOCATEDPTRS);
memset(config_get_if()->ptrsAllocated, 0, sizeof(config_get_if()->ptrsAllocated));
pthread_mutex_init(&config_get_if()->memBlocks_mutex, NULL);
memset(config_get_if()->oneBlock,0,sizeof(config_get_if()->oneBlock));
/* search for include path parameter and set config file include path accordingly */
for (int i=0; i<numP; i++) {
if (strncmp(cfgP[i],"incp",4) == 0) {
......
......@@ -325,6 +325,7 @@ void log_getconfig(log_t *g_log)
logparams_logfile[i].numelt = 0;
logparams_level[i].numelt = 0;
logparams_level[i].type = TYPE_STRING;
logparams_level[i].defstrval= "error";
logparams_logfile[i].type = TYPE_UINT;
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
/* optname help paramflags XXXptr defXXXval type numelt */
/*-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#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_OPTIONS, LOG_CONFIG_HELP_OPTIONS, 0, strlistptr:NULL, defstrlistval:NULL, TYPE_STRINGLIST, 0} \
}
......
......@@ -79,8 +79,8 @@ loader_data_t loader_data;
/* optname helpstr paramflags XXXptr defXXXval type numelt check func*/
/*----------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define LOADER_PARAMS_DESC { \
{"shlibpath", NULL, PARAMFLAG_NOFREE, strptr:(char **)&(loader_data.shlibpath), defstrval:DEFAULT_PATH, TYPE_STRING, 0, NULL},\
{"maxshlibs", NULL, 0, uptr:&(loader_data.maxshlibs), defintval:DEFAULT_MAXSHLIBS, TYPE_UINT32, 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}\
}
/*-------------------------------------------------------------------------------------------------------------*/
......
......@@ -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.
......
......@@ -29,7 +29,7 @@
{"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}, \
{"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}, \
}
......
......@@ -29,15 +29,15 @@
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*------------------------------------------------------------------------------------------------------------------------------------------*/
#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}, \
{"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}, \
{"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}, \
{"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}, \
{"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", 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:&rrc_config_path, defstrval:"./", TYPE_STRING, 0}, \
{"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0} \
}
......
......@@ -137,9 +137,9 @@ extern "C"
extern int usrp_tx_thread;
#define CMDLINE_PARAMS_DESC { \
{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, sizeof(RF_CONFIG_FILE)},\
{"split73", CONFIG_HLP_SPLIT73, 0, strptr:(char **)&SPLIT73, defstrval:NULL, TYPE_STRING, sizeof(SPLIT73)}, \
{"thread-pool", CONFIG_HLP_TPOOL, 0, strptr:(char **)&TP_CONFIG, defstrval:"n", TYPE_STRING, sizeof(TP_CONFIG)}, \
{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:&RF_CONFIG_FILE, defstrval:NULL, TYPE_STRING, 0},\
{"split73", CONFIG_HLP_SPLIT73, 0, strptr:&SPLIT73, defstrval:NULL, TYPE_STRING, 0}, \
{"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}, \
{"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}, \
......@@ -157,8 +157,8 @@ extern int usrp_tx_thread;
{"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}, \
{"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}, \
{"worker-config", CONFIG_HLP_WORKER_CMD, 0, strptr:(char **)&worker_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:&worker_config, defstrval:NULL, TYPE_STRING, 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}, \
{"nokrnmod", CONFIG_HLP_NOKRNMOD, PARAMFLAG_BOOL, uptr:&nokrnmod, defintval:0, TYPE_INT, 0}, \
......@@ -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_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}, \
{"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}, \
}
......@@ -242,9 +242,9 @@ extern int usrp_tx_thread;
typedef struct {
uint64_t optmask;
//THREAD_STRUCT thread_struct;
char rf_config_file[1024];
char split73[1024];
char threadPoolConfig[1024];
char *rf_config_file;
char *split73;
char *threadPoolConfig;
int phy_test;
int do_ra;
int sa;
......
......@@ -62,7 +62,7 @@ static double snr_dB=25;
static double sinr_dB=0;
static unsigned int max_chan;
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,
......
......@@ -253,7 +253,7 @@ typedef enum {
{"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},\
{"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 */
......
......@@ -323,7 +323,7 @@ int RCconfig_RRC(uint32_t i, eNB_RRC_INST *rrc, int macrlc_has_f1) {
srb1_params_t srb1_params;
memset((void *)&srb1_params,0,sizeof(srb1_params_t));
paramdef_t SRB1Params[] = SRB1PARAMS_DESC(srb1_params);
paramdef_t SLParams[] = CCPARAMS_SIDELINK_DESC(SLconfig);
paramdef_t SLParams[] = CCPARAMS_SIDELINK_DESC(SLconfig);
/* map parameter checking array instances to parameter definition array instances */
for (int I=0; I< ( sizeof(CCsParams)/ sizeof(paramdef_t) ) ; I++) {
......@@ -2860,9 +2860,9 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) {
X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C = (uint32_t)*(NETParams[ENB_PORT_FOR_X2C_IDX].uptr);
if ((NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr == NULL) || (X2AP_REGISTER_ENB_REQ (msg_p).enb_port_for_X2C == 0)) {
LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n");
exit(1);
}
LOG_E(RRC,"Add eNB IPv4 address and/or port for X2C in the CONF file!\n");
exit(1);
}
cidr = *(NETParams[ENB_IPV4_ADDR_FOR_X2C_IDX].strptr);
address = strtok(cidr, "/");
......
......@@ -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_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_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_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}, \
......
This diff is collapsed.
......@@ -238,8 +238,8 @@ void mac_top_init_gNB(ngran_node_t node_type)
RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0);
}
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);
}//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
......
......@@ -56,7 +56,9 @@ char *broadcastAddr ;
#define NASHLP_NETMASK "<NAS network mask>\n"
#define NASHLP_BROADCASTADDR "<NAS network broadcast address>\n"
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 */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
......
......@@ -74,9 +74,9 @@ typedef guint8 gboolean;
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*---------------------------------------------------------------------------------------------------------------------------------------------*/
#define OPT_PARAMS_DESC { \
{"type" , CONFIG_HLP_TYPEMON, 0, strptr:(char**)&in_type, defstrval:"none", TYPE_STRING, 0}, \
{"ip" , CONFIG_HLP_L2MONIP, 0, strptr:(char**)&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}, \
{"type" , CONFIG_HLP_TYPEMON, 0, strptr:&in_type, defstrval:"none", 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:&in_path,defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \
}
#define OPTTYPE_IDX 0
......
......@@ -540,9 +540,6 @@ void trace_pdu_implementation(int nr, int direction, uint8_t *pdu_buffer, unsign
/*---------------------------------------------------*/
int init_opt(void) {
in_type=malloc(200);
in_ip=malloc(200);
in_path=malloc(200);
paramdef_t opt_params[] = OPT_PARAMS_DESC ;
checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC;
config_set_checkfunctions(opt_params, opt_checkParams,
......
......@@ -35,16 +35,16 @@ extern uint16_t NB_UE_INST;
/* configuration parameters for the rfsimulator device */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#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 }, \
#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 }, \
};
static uicc_t** uiccArray=NULL;
......
......@@ -95,7 +95,7 @@ typedef struct {
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#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_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}, \
......@@ -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}, \
}/*! \brief Record Player Configuration and state */
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_loops ; // number of loops in replay mode
unsigned int u_sf_read_delay; // read delay in replay mode
......
......@@ -77,11 +77,11 @@
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define simOpt PARAMFLAG_NOFREE|PARAMFLAG_CMDLINE_NOPREFIXENABLED
#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 },\
{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 },\
{"modelname", "<channel model name>\n", simOpt, strptr:&(modelname), defstrval:"AWGN", 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 },\
{"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 },\
{"offset", "<channel offset in samps>\n", simOpt, iptr:&(rfsimulator->chan_offset), defintval:0, TYPE_INT, 0 }\
......
......@@ -107,7 +107,7 @@
{"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}, \
{"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}, \
{"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}, \
......
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