Commit 298de921 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge remote-tracking branch 'origin/issue390_configmodule_cmdlinebug' into...

Merge remote-tracking branch 'origin/issue390_configmodule_cmdlinebug' into develop_integration_2019_w04
parents 5e35d909 5aeb00d3
# OAI configuration module # OAI configuration module
The configuration module provides an api that other oai components can use to get parameters at init time. It defines a parameter structure, used to describe parameters attributes (for example name and type). The same structure includes a pointer to the variable where the configuration module writes the parameter value, at run time, when calling config_get or config_getlist functions. For each parameter a function to check the value can be specified and pre-defined functions are provided for some common parameter validations (integer in a range or in a list, string in a list). The module also include a mechanism to check that no unknown options have been entered on the command line The configuration module provides an api that other oai components can use to get parameters at init time. It defines a parameter structure, used to describe parameters attributes (for example name and type). The same structure includes a pointer to the variable where the configuration module writes the parameter value, at run time, when calling config_get or config_getlist functions. For each parameter a function to check the value can be specified and pre-defined functions are provided for some common parameter validations (integer in a range or in a list, string in a list). The module also include an api to check that no unknown options have been entered on the command line and a a mechanism to display a help text for suppoted parameters.
## Documentation ## Documentation
......
```c ```c
configmodule_interface_t *load_configmodule(int argc, char **argv) configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags)
``` ```
* Parses the command line options, looking for the –O argument * Parses the command line options, looking for the –O argument
* Loads the `libparams_<configsource>.so` (today `libparams_libconfig.so`) shared library * Loads the `libparams_<configsource>.so` (today `libparams_libconfig.so`) shared library
* Looks for `config_<config source>_init` symbol and calls it , passing it an array of string corresponding to the « : » separated strings used in the –O option * Looks for `config_<config source>_init` symbol and calls it , passing it an array of string corresponding to the « : » separated strings used in the –O option
* Looks for `config_<config source>_get`, `config_<config source>_getlist` and `config_<config source>_end` symbols which are the three functions a configuration library should implement. Get and getlist are mandatory, end is optional. * Looks for `config_<config source>_get`, `config_<config source>_getlist` and `config_<config source>_end` symbols which are the three functions a configuration library should implement. Get and getlist are mandatory, end is optional.
* Stores all the necessary information in a `configmodule_interface_t structure`, which is of no use for caller as long as we only use one configuration source. * Stores all the necessary information in a `configmodule_interface_t structure`, which is of no use for caller as long as we only use one configuration source.
* 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)
......
...@@ -27,6 +27,63 @@ $ ./lte-softmodem -O libconfig:<config>:dbgl1 ...@@ -27,6 +27,63 @@ $ ./lte-softmodem -O libconfig:<config>:dbgl1
```bash ```bash
$ ./lte-uesoftmodem -O cmdlineonly:dbgl1 $ ./lte-uesoftmodem -O cmdlineonly:dbgl1
``` ```
To get help on supported parameters you can use specific options:
* ---help: print help for command line only parameters and for parameters not defined in a specific section
* ---help_< prefix > : print help for parameters defined under the section < prefix >
```
./lte-softmodem -O libconfig:/usr/local/oai/conf/enb.nbiot.band7.tm1.50PRB.usrpb210.conf --help
[CONFIG] get parameters from libconfig /usr/local/oai/conf/enb.nbiot.band7.tm1.50PRB.usrpb210.conf , debug flags: 0x00000000
.............................................
[LIBCONFIG] (root): 19/19 parameters successfully set, (16 to default value)
-----Help for section (root section) : 019 entries------
--rf-config-file: Configuration file for front-end (e.g. LMS7002M)
--ulsch-max-errors: set the eNodeB max ULSCH erros
--phy-test: test UE phy layer, mac disabled
--usim-test: use XOR autentication algo in case of test usim mode
--emulate-rf: Emulated RF enabled(disable by defult)
--clock: tells hardware to use a clock reference (0:internal, 1:external, 2:gpsdo)
--wait-for-sync: Help string not specified
--single-thread-enable: Disables single-thread mode in lte-softmodem
-C: Set the downlink frequency for all component carriers
-a: Channel id offset
-d: Enable soft scope and L1 and L2 stats (Xforms)
-q: Enable processing timing measurement of lte softmodem on per subframe basis
-S: Skip the missed slots/subframes
--numerology: adding numerology for 5G
--parallel-config: three config for level of parallelism 'PARALLEL_SINGLE_THREAD', 'PARALLEL_RU_L1_SPLIT', or 'PARALLEL_RU_L1_TRX_SPLIT'
--worker-config: two option for worker 'WORKER_DISABLE' or 'WORKER_ENABLE'
--nbiot-disable: disable nb-iot, even if defined in config
--noS1: Disable s1 interface
--nokrnmod: (noS1 only): Use tun instead of namesh module
--------------------------------------------------------------------
[LIBCONFIG] (root): 4/4 parameters successfully set, (4 to default value)
-----Help for section (root section) : 004 entries------
-R: Enable online log
-g: Set the global log level, valide options: (4:trace, 3:debug, 2:info, 1:warn, (0:error))
--telnetsrv: Start embedded telnet server
--msc: Enable the MSC tracing utility
--------------------------------------------------------------------
[LIBCONFIG] loader: 2/2 parameters successfully set, (2 to default value)
[LIBCONFIG] loader.telnetsrv: 2/2 parameters successfully set, (1 to default value)
[LOADER] library libtelnetsrv.so is not loaded: libtelnetsrv.so: cannot open shared object file: No such file or directory
Getting ENBSParams
[LIBCONFIG] (root): 3/3 parameters successfully set, (1 to default value)
-----Help for section (root section) : 003 entries------
--Asn1_verbosity: Help string not specified
--Active_eNBs: Help string not specified
--noS1: Help string not specified
--------------------------------------------------------------------
/usr/local/oai/issue390_configmodule_cmdlinebug/openairinterface5g/common/config/config_cmdline.c:224 config_process_cmdline() Exiting OAI softmodem: [CONFIG] Exiting after displaying help
```
For the lte-softmodem (the eNodeB) The config source parameter defaults to libconfig, preserving the initial -O option format. In this case you cannot specify the debug level. For the lte-softmodem (the eNodeB) The config source parameter defaults to libconfig, preserving the initial -O option format. In this case you cannot specify the debug level.
```bash ```bash
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <errno.h> #include <errno.h>
#include <platform_types.h> #include <platform_types.h>
#include "config_userapi.h" #include "config_userapi.h"
#include "../utils/LOG/log.h"
int parse_stringlist(paramdef_t *cfgoptions, char *val) { int parse_stringlist(paramdef_t *cfgoptions, char *val) {
char *atoken; char *atoken;
...@@ -74,15 +74,15 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -74,15 +74,15 @@ int processoption(paramdef_t *cfgoptions, char *value) {
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); CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires an argument\n",cfgoptions->optname);
exit_fun("[CONFIG] command line parsing fatal error");
return 0;
} else { /* boolean value option without argument, set value to true*/ } else { /* boolean value option without argument, set value to true*/
tmpval = defbool; tmpval = defbool;
} }
} }
switch(cfgoptions->type) { switch(cfgoptions->type) {
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, cfgoptions->strptr, strlen(tmpval)+1);
...@@ -106,14 +106,24 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -106,14 +106,24 @@ int processoption(paramdef_t *cfgoptions, char *value) {
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, (char **)&(cfgoptions->iptr),sizeof(int32_t));
config_assign_int(cfgoptions,cfgoptions->optname,(int32_t)strtol(tmpval,NULL,0)); config_assign_int(cfgoptions,cfgoptions->optname,(int32_t)strtol(tmpval,&charptr,0));
if( *charptr != 0) {
CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires an integer argument\n",cfgoptions->optname);
}
optisset=1; optisset=1;
break; break;
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, (char **)&(cfgoptions->i64ptr),sizeof(uint64_t));
*(cfgoptions->i64ptr)=strtoll(tmpval,NULL,0); *(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; optisset=1;
break; break;
...@@ -124,7 +134,12 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -124,7 +134,12 @@ int processoption(paramdef_t *cfgoptions, char *value) {
case TYPE_DOUBLE: case TYPE_DOUBLE:
config_check_valptr(cfgoptions, (char **)&(cfgoptions->dblptr),sizeof(double)); config_check_valptr(cfgoptions, (char **)&(cfgoptions->dblptr),sizeof(double));
*(cfgoptions->dblptr) = strtof(tmpval,NULL); *(cfgoptions->dblptr) = strtof(tmpval,&charptr);
if( *charptr != 0) {
CONFIG_PRINTF_ERROR("[CONFIG] command line, option %s requires a double argument\n",cfgoptions->optname);
}
printf_cmdl("[CONFIG] %s set to %lf from command line\n", cfgoptions->optname, *(cfgoptions->dblptr)); printf_cmdl("[CONFIG] %s set to %lf from command line\n", cfgoptions->optname, *(cfgoptions->dblptr));
optisset=1; optisset=1;
break; break;
...@@ -133,7 +148,7 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -133,7 +148,7 @@ int processoption(paramdef_t *cfgoptions, char *value) {
break; break;
default: default:
fprintf(stderr,"[CONFIG] command line, %s type %i not supported\n",cfgoptions->optname, cfgoptions->type); CONFIG_PRINTF_ERROR("[CONFIG] command line, %s type %i not supported\n",cfgoptions->optname, cfgoptions->type);
break; break;
} /* switch on param type */ } /* switch on param type */
...@@ -149,14 +164,15 @@ int processoption(paramdef_t *cfgoptions, char *value) { ...@@ -149,14 +164,15 @@ int processoption(paramdef_t *cfgoptions, char *value) {
*/ */
int config_check_unknown_cmdlineopt(char *prefix) { int config_check_unknown_cmdlineopt(char *prefix) {
int unknowndetected=0; int unknowndetected=0;
char testprefix[CONFIG_MAXOPTLENGTH]=""; char testprefix[CONFIG_MAXOPTLENGTH];
int finalcheck = 0; int finalcheck = 0;
memset(testprefix,0,sizeof(testprefix));
if (prefix != NULL) { if (prefix != NULL) {
if (strcmp(prefix,CONFIG_CHECKALLSECTIONS) == 0) if (strcmp(prefix,CONFIG_CHECKALLSECTIONS) == 0)
finalcheck = 1; finalcheck = 1;
else if (strlen(prefix) > 0) { else if (strlen(prefix) > 0) {
sprintf(testprefix,"--%s.",prefix); sprintf(testprefix,"--%.*s.",CONFIG_MAXOPTLENGTH-1,prefix);
} }
} }
...@@ -176,8 +192,11 @@ int config_check_unknown_cmdlineopt(char *prefix) { ...@@ -176,8 +192,11 @@ int config_check_unknown_cmdlineopt(char *prefix) {
} }
} }
printf_cmdl("[CONFIG] %i unknown option(s) in command line starting with %s (section %s)\n", if (unknowndetected > 0) {
CONFIG_PRINTF_ERROR("[CONFIG] %i unknown option(s) in command line starting with %s (section %s)\n",
unknowndetected,testprefix,((prefix==NULL)?"":prefix)); unknowndetected,testprefix,((prefix==NULL)?"":prefix));
}
return unknowndetected; return unknowndetected;
} /* config_check_unknown_cmdlineopt */ } /* config_check_unknown_cmdlineopt */
...@@ -200,7 +219,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) ...@@ -200,7 +219,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix)
if (pp == NULL || strcasecmp(pp,config_get_if()->argv[i] ) == 0 ) { if (pp == NULL || strcasecmp(pp,config_get_if()->argv[i] ) == 0 ) {
if( prefix == NULL) { if( prefix == NULL) {
config_printhelp(cfgoptions,numoptions); config_printhelp(cfgoptions,numoptions,"(root section)");
if ( ! ( CONFIG_ISFLAGSET(CONFIG_NOEXITONHELP))) if ( ! ( CONFIG_ISFLAGSET(CONFIG_NOEXITONHELP)))
exit_fun("[CONFIG] Exiting after displaying help\n"); exit_fun("[CONFIG] Exiting after displaying help\n");
...@@ -209,8 +228,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) ...@@ -209,8 +228,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix)
pp=strtok_r(NULL, " ",&tokctx); pp=strtok_r(NULL, " ",&tokctx);
if ( prefix != NULL && pp != NULL && strncasecmp(prefix,pp,strlen(pp)) == 0 ) { if ( prefix != NULL && pp != NULL && strncasecmp(prefix,pp,strlen(pp)) == 0 ) {
printf ("Help for %s section:\n",prefix); config_printhelp(cfgoptions,numoptions,prefix);
config_printhelp(cfgoptions,numoptions);
if ( ! (CONFIG_ISFLAGSET(CONFIG_NOEXITONHELP))) { if ( ! (CONFIG_ISFLAGSET(CONFIG_NOEXITONHELP))) {
fprintf(stderr,"[CONFIG] %s %i section %s:", __FILE__, __LINE__, prefix); fprintf(stderr,"[CONFIG] %s %i section %s:", __FILE__, __LINE__, prefix);
...@@ -273,16 +291,5 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) ...@@ -273,16 +291,5 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix)
} /* fin du while */ } /* fin du while */
printf_cmdl("[CONFIG] %s %i options set from command line\n",((prefix == NULL) ? "(root)":prefix),j); printf_cmdl("[CONFIG] %s %i options set from command line\n",((prefix == NULL) ? "(root)":prefix),j);
if ( !(CONFIG_ISFLAGSET( CONFIG_NOCHECKUNKOPT )) ) {
i=config_check_unknown_cmdlineopt(prefix);
if (i > 0) {
fprintf(stderr,"[CONFIG] %i unknown options for section %s detected in command line\n",
i,((prefix==NULL)?"\"root section\"":prefix));
exit_fun(" Exiting after detecting errors in command line \n");
}
}
return j; return j;
} /* parse_cmdline*/ } /* parse_cmdline*/
...@@ -36,12 +36,15 @@ ...@@ -36,12 +36,15 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <platform_types.h>
#define CONFIG_LOADCONFIG_MAIN #define CONFIG_LOADCONFIG_MAIN
#include "config_load_configmodule.h" #include "config_load_configmodule.h"
#include "config_userapi.h" #include "config_userapi.h"
#include "../utils/LOG/log.h"
#define CONFIG_SHAREDLIBFORMAT "libparams_%s.so" #define CONFIG_SHAREDLIBFORMAT "libparams_%s.so"
int load_config_sharedlib(configmodule_interface_t *cfgptr) { int load_config_sharedlib(configmodule_interface_t *cfgptr) {
void *lib_handle; void *lib_handle;
char fname[128]; char fname[128];
...@@ -198,7 +201,7 @@ configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t init ...@@ -198,7 +201,7 @@ configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t init
} }
if ( strstr(argv[i], "help_config") != NULL ) { if ( strstr(argv[i], "help_config") != NULL ) {
config_printhelp(Config_Params,CONFIG_PARAMLENGTH(Config_Params)); config_printhelp(Config_Params,CONFIG_PARAMLENGTH(Config_Params),CONFIG_SECTIONNAME);
exit(0); exit(0);
} }
...@@ -304,7 +307,7 @@ configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t init ...@@ -304,7 +307,7 @@ configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t init
if (cfgmode != NULL) free(cfgmode); if (cfgmode != NULL) free(cfgmode);
if (CONFIG_ISFLAGSET(CONFIG_ABORT)) { if (CONFIG_ISFLAGSET(CONFIG_ABORT)) {
config_printhelp(Config_Params,CONFIG_PARAMLENGTH(Config_Params)); config_printhelp(Config_Params,CONFIG_PARAMLENGTH(Config_Params),CONFIG_SECTIONNAME );
// exit(-1); // exit(-1);
} }
...@@ -342,7 +345,7 @@ void free_configmodule(void) { ...@@ -342,7 +345,7 @@ void free_configmodule(void) {
if( cfgptr->cfgmode != NULL) free(cfgptr->cfgmode); if( cfgptr->cfgmode != NULL) free(cfgptr->cfgmode);
printf ("[CONFIG] free %u config parameter pointers\n",cfgptr->num_cfgP); printf ("[CONFIG] free %i config parameter pointers\n",cfgptr->num_cfgP);
for (int i=0; i<cfgptr->num_cfgP; i++) { for (int i=0; i<cfgptr->num_cfgP; i++) {
if ( cfgptr->cfgP[i] != NULL) free(cfgptr->cfgP[i]); if ( cfgptr->cfgP[i] != NULL) free(cfgptr->cfgP[i]);
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#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_NOCHECKUNKOPT (1<<3) // disable check unprocessed (so invalid) command line options
#define CONFIG_NOABORTONCHKF (1<<4) // disable abort execution when parameter checking function fails #define CONFIG_NOABORTONCHKF (1<<4) // disable abort execution when parameter checking function fails
#define CONFIG_NOEXITONHELP (1<<19) // do not exit after printing help #define CONFIG_NOEXITONHELP (1<<19) // do not exit after printing help
#define CONFIG_HELP (1<<20) // print help message #define CONFIG_HELP (1<<20) // print help message
...@@ -109,5 +108,7 @@ extern configmodule_interface_t *cfgptr; ...@@ -109,5 +108,7 @@ 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);
extern void end_configmodule(void); extern void end_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");
#endif /* INCLUDE_CONFIG_LOADCONFIGMODULE_H */ #endif /* INCLUDE_CONFIG_LOADCONFIGMODULE_H */
...@@ -39,15 +39,13 @@ ...@@ -39,15 +39,13 @@
#include <errno.h> #include <errno.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <platform_types.h> #include <platform_types.h>
#include "config_userapi.h" #include "config_userapi.h"
#include "../utils/LOG/log.h"
configmodule_interface_t *config_get_if(void) { configmodule_interface_t *config_get_if(void) {
if (cfgptr == NULL) { if (cfgptr == NULL) {
fprintf(stderr,"[CONFIG] %s %d config module not initialized\n",__FILE__, __LINE__); CONFIG_PRINTF_ERROR("[CONFIG] %s %d config module not initialized\n",__FILE__,__LINE__);
exit(-1);
} }
return cfgptr; return cfgptr;
...@@ -66,9 +64,8 @@ char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) { ...@@ -66,9 +64,8 @@ char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) {
config_get_if()->numptrs++; config_get_if()->numptrs++;
} }
} else { } else {
fprintf(stderr, "[CONFIG] %s %d option %s, cannot allocate pointer: %s \n", CONFIG_PRINTF_ERROR("[CONFIG] %s %d option %s, cannot allocate pointer: %s \n",
__FILE__, __LINE__, cfgoptions->optname, strerror(errno)); __FILE__, __LINE__, cfgoptions->optname, strerror(errno));
exit(-1);
} }
} }
...@@ -78,9 +75,8 @@ char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) { ...@@ -78,9 +75,8 @@ char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) {
if (*ptr != NULL) { if (*ptr != NULL) {
return *ptr; return *ptr;
} else { } else {
fprintf(stderr,"[CONFIG] %s %d option %s, definition error: value pointer is NULL, declared as %i bytes allocated\n", CONFIG_PRINTF_ERROR("[CONFIG] %s %d option %s, definition error: value pointer is NULL, declared as %i bytes allocated\n",
__FILE__, __LINE__,cfgoptions->optname, cfgoptions->numelt); __FILE__, __LINE__,cfgoptions->optname, cfgoptions->numelt);
exit(-1);
} }
} }
...@@ -95,8 +91,7 @@ char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) { ...@@ -95,8 +91,7 @@ char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) {
config_get_if()->numptrs++; config_get_if()->numptrs++;
} }
} else { } else {
fprintf (stderr,"[CONFIG] %s %d malloc error\n",__FILE__, __LINE__); CONFIG_PRINTF_ERROR("[CONFIG] %s %d malloc error\n",__FILE__, __LINE__);
exit(-1);
} }
} }
...@@ -157,8 +152,7 @@ void config_assign_processedint(paramdef_t *cfgoption, int val) { ...@@ -157,8 +152,7 @@ void config_assign_processedint(paramdef_t *cfgoption, int val) {
if ( cfgoption->processedvalue != NULL) { if ( cfgoption->processedvalue != NULL) {
*(cfgoption->processedvalue) = val; *(cfgoption->processedvalue) = val;
} else { } else {
fprintf (stderr,"[CONFIG] %s %d malloc error\n",__FILE__, __LINE__); CONFIG_PRINTF_ERROR("[CONFIG] %s %d malloc error\n",__FILE__, __LINE__);
exit(-1);
} }
} }
...@@ -177,15 +171,17 @@ int config_get_processedint(paramdef_t *cfgoption) { ...@@ -177,15 +171,17 @@ int config_get_processedint(paramdef_t *cfgoption) {
return ret; return ret;
} }
void config_printhelp(paramdef_t *params,int numparams) { void config_printhelp(paramdef_t *params,int numparams, char *prefix) {
printf("\n-----Help for section %-26s: %03i entries------\n",(prefix==NULL)?"(root section)":prefix ,numparams);
for (int i=0 ; i<numparams ; i++) { for (int i=0 ; i<numparams ; i++) {
if ( params[i].helpstr != NULL) { printf(" %s%s: %s",
printf("%s%s: %s",
(strlen(params[i].optname) <= 1) ? "-" : "--", (strlen(params[i].optname) <= 1) ? "-" : "--",
params[i].optname, params[i].optname,
params[i].helpstr); (params[i].helpstr != NULL)?params[i].helpstr:"Help string not specified\n");
} } /* for on params entries */
}
printf("--------------------------------------------------------------------\n\n");
} }
int config_execcheck(paramdef_t *params,int numparams, char *prefix) { int config_execcheck(paramdef_t *params,int numparams, char *prefix) {
...@@ -202,11 +198,7 @@ int config_execcheck(paramdef_t *params,int numparams, char *prefix) { ...@@ -202,11 +198,7 @@ int config_execcheck(paramdef_t *params,int numparams, char *prefix) {
} }
if (st != 0) { if (st != 0) {
fprintf(stderr,"[CONFIG] config_execcheck: section %s %i parameters with wrong value\n", prefix, -st); CONFIG_PRINTF_ERROR("[CONFIG] config_execcheck: section %s %i parameters with wrong value\n", prefix, -st);
if ( CONFIG_ISFLAGSET(CONFIG_NOABORTONCHKF) == 0) {
exit_fun("exit because configuration failed\n");
}
} }
return st; return st;
...@@ -263,6 +255,7 @@ int config_getlist(paramlist_def_t *ParamList, paramdef_t *params, int numparams ...@@ -263,6 +255,7 @@ int config_getlist(paramlist_def_t *ParamList, paramdef_t *params, int numparams
for (int i = 0; i < ParamList->numelt; ++i) { for (int i = 0; i < ParamList->numelt; ++i) {
// TODO config_process_cmdline? // TODO config_process_cmdline?
sprintf(cfgpath, "%s.[%i]", newprefix, i); sprintf(cfgpath, "%s.[%i]", newprefix, i);
config_process_cmdline(ParamList->paramarray[i],numparams,cfgpath);
config_execcheck(ParamList->paramarray[i], numparams, cfgpath); config_execcheck(ParamList->paramarray[i], numparams, cfgpath);
} }
......
...@@ -49,7 +49,7 @@ extern "C" ...@@ -49,7 +49,7 @@ extern "C"
/* 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) ; extern char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) ;
extern void config_printhelp(paramdef_t *,int numparams); 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);
extern void config_assign_int(paramdef_t *cfgoptions, char *fullname, int val); extern void config_assign_int(paramdef_t *cfgoptions, char *fullname, int val);
......
...@@ -219,7 +219,6 @@ void log_getconfig(log_t *g_log) { ...@@ -219,7 +219,6 @@ void log_getconfig(log_t *g_log) {
paramdef_t logparams_logfile[MAX_LOG_PREDEF_COMPONENTS]; paramdef_t logparams_logfile[MAX_LOG_PREDEF_COMPONENTS];
paramdef_t logparams_debug[sizeof(log_maskmap)/sizeof(mapping)]; paramdef_t logparams_debug[sizeof(log_maskmap)/sizeof(mapping)];
paramdef_t logparams_dump[sizeof(log_maskmap)/sizeof(mapping)]; paramdef_t logparams_dump[sizeof(log_maskmap)/sizeof(mapping)];
CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT);
int ret = config_get( logparams_defaults,sizeof(logparams_defaults)/sizeof(paramdef_t),CONFIG_STRING_LOG_PREFIX); int ret = config_get( logparams_defaults,sizeof(logparams_defaults)/sizeof(paramdef_t),CONFIG_STRING_LOG_PREFIX);
if (ret <0) { if (ret <0) {
...@@ -305,8 +304,8 @@ void log_getconfig(log_t *g_log) { ...@@ -305,8 +304,8 @@ void log_getconfig(log_t *g_log) {
} }
config_get( logparams_debug,(sizeof(log_maskmap)/sizeof(mapping)) - 1 ,CONFIG_STRING_LOG_PREFIX); config_get( logparams_debug,(sizeof(log_maskmap)/sizeof(mapping)) - 1 ,CONFIG_STRING_LOG_PREFIX);
CONFIG_CLEARRTFLAG(CONFIG_NOCHECKUNKOPT);
config_get( logparams_dump,(sizeof(log_maskmap)/sizeof(mapping)) - 1 ,CONFIG_STRING_LOG_PREFIX); config_get( logparams_dump,(sizeof(log_maskmap)/sizeof(mapping)) - 1 ,CONFIG_STRING_LOG_PREFIX);
config_check_unknown_cmdlineopt(CONFIG_STRING_LOG_PREFIX);
/* set the debug mask according to the debug parameters values */ /* set the debug mask according to the debug parameters values */
for (int i=0; log_maskmap[i].name != NULL ; i++) { for (int i=0; log_maskmap[i].name != NULL ; i++) {
......
...@@ -345,6 +345,8 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int ...@@ -345,6 +345,8 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
} }
#define LOG_OPTIONS_IDX 2 #define LOG_OPTIONS_IDX 2
/*----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------*/
/** @defgroup _debugging debugging macros /** @defgroup _debugging debugging macros
* @ingroup _macro * @ingroup _macro
......
...@@ -14,13 +14,15 @@ ...@@ -14,13 +14,15 @@
#define QUIT(x) do { \ #define QUIT(x) do { \
printf("T tracer: QUIT: %s\n", x); \ printf("T tracer: QUIT: %s\n", x); \
exit(1); \ exit(1); \
} while (0) } while (0)
/* array used to activate/disactivate a log */ /* array used to activate/disactivate a log */
static int T_IDs[T_NUMBER_OF_IDS]; static int T_IDs[T_NUMBER_OF_IDS];
int *T_active = T_IDs; int *T_active = T_IDs;
int T_stdout = 1; int T_stdout = 1;
static int T_socket; static int T_socket;
/* T_cache /* T_cache
...@@ -32,67 +34,90 @@ volatile int *T_freelist_head = &_T_freelist_head; ...@@ -32,67 +34,90 @@ volatile int *T_freelist_head = &_T_freelist_head;
T_cache_t *T_cache; T_cache_t *T_cache;
#if BASIC_SIMULATOR #if BASIC_SIMULATOR
/* global variables used by T_GET_SLOT, see in T.h */ /* global variables used by T_GET_SLOT, see in T.h */
volatile uint64_t T_next_id; volatile uint64_t T_next_id;
volatile uint64_t T_active_id; volatile uint64_t T_active_id;
#endif #endif
static void get_message(int s) static void get_message(int s) {
{
char t; char t;
int l; int l;
int id; int id;
int is_on; int is_on;
if (read(s, &t, 1) != 1) QUIT("get_message fails"); if (read(s, &t, 1) != 1) QUIT("get_message fails");
printf("T tracer: got mess %d\n", t);
printf("T tracer: got mess %d\n", t);
switch (t) { switch (t) {
case 0: case 0:
/* toggle all those IDs */ /* toggle all those IDs */
/* optimze? (too much syscalls) */ /* optimze? (too much syscalls) */
if (read(s, &l, sizeof(int)) != sizeof(int)) QUIT("get_message fails"); if (read(s, &l, sizeof(int)) != sizeof(int)) QUIT("get_message fails");
while (l) { while (l) {
if (read(s, &id, sizeof(int)) != sizeof(int)) QUIT("get_message fails"); if (read(s, &id, sizeof(int)) != sizeof(int)) QUIT("get_message fails");
T_IDs[id] = 1 - T_IDs[id]; T_IDs[id] = 1 - T_IDs[id];
l--; l--;
} }
break; break;
case 1: case 1:
/* set IDs as given */ /* set IDs as given */
/* optimize? */ /* optimize? */
if (read(s, &l, sizeof(int)) != sizeof(int)) QUIT("get_message fails"); if (read(s, &l, sizeof(int)) != sizeof(int)) QUIT("get_message fails");
id = 0; id = 0;
while (l) { while (l) {
if (read(s, &is_on, sizeof(int)) != sizeof(int)) if (read(s, &is_on, sizeof(int)) != sizeof(int))
QUIT("get_message fails"); QUIT("get_message fails");
T_IDs[id] = is_on; T_IDs[id] = is_on;
id++; id++;
l--; l--;
} }
break; break;
case 2: break; /* do nothing, this message is to wait for local tracer */
case 2:
break; /* do nothing, this message is to wait for local tracer */
} }
} }
static void *T_receive_thread(void *_) static void *T_receive_thread(void *_) {
{
while (1) get_message(T_socket); while (1) get_message(T_socket);
return NULL; return NULL;
} }
static void new_thread(void *(*f)(void *), void *data) static void new_thread(void *(*f)(void *), void *data) {
{
pthread_t t; pthread_t t;
pthread_attr_t att; pthread_attr_t att;
if (pthread_attr_init(&att)) if (pthread_attr_init(&att)) {
{ fprintf(stderr, "pthread_attr_init err\n"); exit(1); } fprintf(stderr, "pthread_attr_init err\n");
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) exit(1);
{ fprintf(stderr, "pthread_attr_setdetachstate err\n"); exit(1); } }
if (pthread_create(&t, &att, f, data))
{ fprintf(stderr, "pthread_create err\n"); exit(1); } if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
if (pthread_attr_destroy(&att)) fprintf(stderr, "pthread_attr_setdetachstate err\n");
{ fprintf(stderr, "pthread_attr_destroy err\n"); exit(1); } exit(1);
}
if (pthread_create(&t, &att, f, data)) {
fprintf(stderr, "pthread_create err\n");
exit(1);
}
if (pthread_attr_destroy(&att)) {
fprintf(stderr, "pthread_attr_destroy err\n");
exit(1);
}
} }
/* defined in local_tracer.c */ /* defined in local_tracer.c */
...@@ -104,53 +129,64 @@ void T_local_tracer_main(int remote_port, int wait_for_tracer, ...@@ -104,53 +129,64 @@ void T_local_tracer_main(int remote_port, int wait_for_tracer,
*/ */
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
static void monitor_and_kill(int child1, int child2) static void monitor_and_kill(int child1, int child2) {
{
int child; int child;
int status; int status;
child = wait(&status); child = wait(&status);
if (child == -1) perror("wait"); if (child == -1) perror("wait");
kill(child1, SIGKILL); kill(child1, SIGKILL);
kill(child2, SIGKILL); kill(child2, SIGKILL);
exit(0); exit(0);
} }
void T_init(int remote_port, int wait_for_tracer, int dont_fork) void T_init(int remote_port, int wait_for_tracer, int dont_fork) {
{
int socket_pair[2]; int socket_pair[2];
int s; int s;
int child1, child2; int child1, child2;
int i; int i;
if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair)) if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair)) {
{ perror("socketpair"); abort(); } perror("socketpair");
abort();
}
/* setup shared memory */ /* setup shared memory */
T_cache = mmap(NULL, T_CACHE_SIZE * sizeof(T_cache_t), T_cache = mmap(NULL, T_CACHE_SIZE * sizeof(T_cache_t),
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
if (T_cache == MAP_FAILED)
{ perror("mmap"); abort(); } if (T_cache == MAP_FAILED) {
perror("mmap");
abort();
}
/* let's garbage the memory to catch some potential problems /* let's garbage the memory to catch some potential problems
* (think multiprocessor sync issues, barriers, etc.) * (think multiprocessor sync issues, barriers, etc.)
*/ */
memset(T_cache, 0x55, T_CACHE_SIZE * sizeof(T_cache_t)); memset(T_cache, 0x55, T_CACHE_SIZE * sizeof(T_cache_t));
for (i = 0; i < T_CACHE_SIZE; i++) T_cache[i].busy = 0; for (i = 0; i < T_CACHE_SIZE; i++) T_cache[i].busy = 0;
/* child1 runs the local tracer and child2 (or main) runs the tracee */ /* child1 runs the local tracer and child2 (or main) runs the tracee */
child1 = fork();
if (child1 == -1) abort();
child1 = fork(); if (child1 == -1) abort();
if (child1 == 0) { if (child1 == 0) {
close(socket_pair[1]); close(socket_pair[1]);
T_local_tracer_main(remote_port, wait_for_tracer, socket_pair[0], T_local_tracer_main(remote_port, wait_for_tracer, socket_pair[0],
T_cache); T_cache);
exit(0); exit(0);
} }
close(socket_pair[0]); close(socket_pair[0]);
if (dont_fork == 0) { if (dont_fork == 0) {
child2 = fork(); if (child2 == -1) abort(); child2 = fork();
if (child2 == -1) abort();
if (child2 != 0) { if (child2 != 0) {
close(socket_pair[1]); close(socket_pair[1]);
munmap(T_cache, T_CACHE_SIZE * sizeof(T_cache_t)); munmap(T_cache, T_CACHE_SIZE * sizeof(T_cache_t));
...@@ -161,27 +197,21 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork) ...@@ -161,27 +197,21 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork)
s = socket_pair[1]; s = socket_pair[1];
/* wait for first message - initial list of active T events */ /* wait for first message - initial list of active T events */
get_message(s); get_message(s);
T_socket = s; T_socket = s;
new_thread(T_receive_thread, NULL); new_thread(T_receive_thread, NULL);
} }
void T_Config_Init(void) void T_Config_Init(void) {
{ int T_port=TTRACER_DEFAULT_PORTNUM; /* by default we wait for the tracer */
int T_port; /* by default we wait for the tracer */ int T_nowait=0; /* default port to listen to to wait for the tracer */
int T_nowait; /* default port to listen to to wait for the tracer */ int T_dont_fork=0; /* default is to fork, see 'T_init' to understand */
int T_dont_fork; /* default is to fork, see 'T_init' to understand */
paramdef_t ttraceparams[] = CMDLINE_TTRACEPARAMS_DESC; paramdef_t ttraceparams[] = CMDLINE_TTRACEPARAMS_DESC;
/* for a cleaner config file, TTracer params should be defined in a /* for a cleaner config file, TTracer params should be defined in a
* specific section... * specific section...
*/ */
config_get(ttraceparams, config_get(ttraceparams,
sizeof(ttraceparams) / sizeof(paramdef_t), sizeof(ttraceparams) / sizeof(paramdef_t),
TTRACER_CONFIG_PREFIX); TTRACER_CONFIG_PREFIX);
/* compatibility: look for TTracer command line options in root section */ /* compatibility: look for TTracer command line options in root section */
config_process_cmdline(ttraceparams, config_process_cmdline(ttraceparams,
sizeof(ttraceparams) / sizeof(paramdef_t), sizeof(ttraceparams) / sizeof(paramdef_t),
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "T_defs.h" #include "T_defs.h"
#ifdef T_SEND_TIME #ifdef T_SEND_TIME
#include <time.h> #include <time.h>
#endif #endif
/* T message IDs */ /* T message IDs */
...@@ -598,20 +598,21 @@ extern int *T_active; ...@@ -598,20 +598,21 @@ extern int *T_active;
#define TTRACER_CONFIG_PREFIX "TTracer" #define TTRACER_CONFIG_PREFIX "TTracer"
/*------------------------------------------------------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------------------------------------------------------------*/
/* configuration parameters for TTRACE utility */ /* configuration parameters for TTRACE utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*------------------------------------------------------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------------------------------------------------------------*/
#define TTRACER_DEFAULT_PORTNUM 2021
#define CMDLINE_TTRACEPARAMS_DESC { \ #define CMDLINE_TTRACEPARAMS_DESC { \
{"T_port", CONFIG_HLP_TPORT, 0, iptr:&T_port, defintval:2021, TYPE_INT, 0}, \ {"T_port", CONFIG_HLP_TPORT, 0, iptr:&T_port, defintval:TTRACER_DEFAULT_PORTNUM, TYPE_INT, 0},\
{"T_nowait", CONFIG_HLP_NOTWAIT, PARAMFLAG_BOOL, iptr:&T_nowait, defintval:0, TYPE_INT, 0}, \ {"T_nowait", CONFIG_HLP_NOTWAIT, PARAMFLAG_BOOL, iptr:&T_nowait, defintval:0, TYPE_INT, 0},\
{"T_dont_fork", CONFIG_HLP_TNOFORK, PARAMFLAG_BOOL, iptr:&T_dont_fork, defintval:0, TYPE_INT, 0}, \ {"T_dont_fork", CONFIG_HLP_TNOFORK, PARAMFLAG_BOOL, iptr:&T_dont_fork, defintval:0, TYPE_INT, 0},\
{"T_stdout", CONFIG_HLP_STDOUT, PARAMFLAG_BOOL, iptr:&T_stdout, defintval:1, TYPE_INT, 0}, \ {"T_stdout", CONFIG_HLP_STDOUT, PARAMFLAG_BOOL, iptr:&T_stdout, defintval:1, TYPE_INT, 0},\
} }
/* log on stdout */ /* log on stdout */
void T_init(int remote_port, int wait_for_tracer, int dont_fork); void T_init(int remote_port, int wait_for_tracer, int dont_fork);
void T_Config_Init(void); void T_Config_Init(void);
#else /* T_TRACER */ #else /* T_TRACER */
......
This diff is collapsed.
This diff is collapsed.
...@@ -270,6 +270,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re ...@@ -270,6 +270,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re
for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i) for(int i = 0; i < resp->pnf_phy.number_of_phys; ++i)
{ {
phy_info phy; phy_info phy;
memset(&phy,0,sizeof(phy));
phy.index = resp->pnf_phy.phy[i].phy_config_index; phy.index = resp->pnf_phy.phy[i].phy_config_index;
printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index); printf("[VNF] (PHY:%d) phy_config_idx:%d\n", i, resp->pnf_phy.phy[i].phy_config_index);
...@@ -287,6 +288,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re ...@@ -287,6 +288,7 @@ int pnf_param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_pnf_param_re
for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) { for(int i = 0; i < resp->pnf_rf.number_of_rfs; ++i) {
rf_info rf; rf_info rf;
memset(&rf,0,sizeof(rf));
rf.index = resp->pnf_rf.rf[i].rf_config_index; rf.index = resp->pnf_rf.rf[i].rf_config_index;
printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index); printf("[VNF] (RF:%d) rf_config_idx:%d\n", i, resp->pnf_rf.rf[i].rf_config_index);
...@@ -897,7 +899,7 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t ...@@ -897,7 +899,7 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t
// for now just 1 // for now just 1
printf("[VNF] %d.%d pnf p7 %s:%d timing %d %d %d %d\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, p7_vnf->periodic_timing_period); printf("[VNF] %d.%d pnf p7 %s:%d timing %u %u %u %u\n", p5_idx, phy->id, phy->remote_addr, phy->remote_port, p7_vnf->timing_window, p7_vnf->periodic_timing_period, p7_vnf->aperiodic_timing_enabled, p7_vnf->periodic_timing_period);
req->header.message_id = NFAPI_CONFIG_REQUEST; req->header.message_id = NFAPI_CONFIG_REQUEST;
req->header.phy_id = phy->id; req->header.phy_id = phy->id;
...@@ -919,7 +921,7 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t ...@@ -919,7 +921,7 @@ int param_resp_cb(nfapi_vnf_config_t* config, int p5_idx, nfapi_param_response_t
req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG; req->nfapi_config.timing_window.tl.tag = NFAPI_NFAPI_TIMING_WINDOW_TAG;
req->nfapi_config.timing_window.value = p7_vnf->timing_window; req->nfapi_config.timing_window.value = p7_vnf->timing_window;
printf("[VNF] Timing window:%d\n", p7_vnf->timing_window); printf("[VNF] Timing window:%u\n", p7_vnf->timing_window);
req->num_tlv++; req->num_tlv++;
if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) { if(p7_vnf->periodic_timing_enabled || p7_vnf->aperiodic_timing_enabled) {
......
This diff is collapsed.
...@@ -47,27 +47,20 @@ void ...@@ -47,27 +47,20 @@ void
ccodedot11_encode (unsigned int numbytes, ccodedot11_encode (unsigned int numbytes,
unsigned char *inPtr, unsigned char *inPtr,
unsigned char *outPtr, unsigned char *outPtr,
unsigned char puncturing) unsigned char puncturing) {
{
unsigned int state; unsigned int state;
unsigned char c, out, shiftbit =0; unsigned char c, out, shiftbit =0;
// printf("In ccodedot11_encode (%d,%p,%p,%d)\n",numbytes,inPtr,outPtr,puncturing); // printf("In ccodedot11_encode (%d,%p,%p,%d)\n",numbytes,inPtr,outPtr,puncturing);
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
unsigned int dummy; unsigned int dummy;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
int bit_index; int bit_index;
/* The input bit is shifted in position 8 of the state. /* The input bit is shifted in position 8 of the state.
Shiftbit will take values between 1 and 8 */ Shiftbit will take values between 1 and 8 */
state = 0; state = 0;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
dummy = 0; dummy = 0;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
/* Do not increment inPtr until we read the next octet */ /* Do not increment inPtr until we read the next octet */
bit_index=0; bit_index=0;
...@@ -80,7 +73,6 @@ ccodedot11_encode (unsigned int numbytes, ...@@ -80,7 +73,6 @@ ccodedot11_encode (unsigned int numbytes,
switch (puncturing) { switch (puncturing) {
case 0: //rate 1/2 case 0: //rate 1/2
for (shiftbit = 0; shiftbit<8; shiftbit++) { for (shiftbit = 0; shiftbit<8; shiftbit++) {
state >>= 1; state >>= 1;
if ((c&(1<<shiftbit)) != 0) { if ((c&(1<<shiftbit)) != 0) {
...@@ -88,22 +80,18 @@ ccodedot11_encode (unsigned int numbytes, ...@@ -88,22 +80,18 @@ ccodedot11_encode (unsigned int numbytes,
} }
out = ccodedot11_table[state]; out = ccodedot11_table[state];
*outPtr++ = out & 1; *outPtr++ = out & 1;
*outPtr++ = (out>>1)&1; *outPtr++ = (out>>1)&1;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
printf("%d: %d -> %d (%d)\n",dummy,state,out,ccodedot11_table[state]); printf("%u: %u -> %d (%u)\n",dummy,state,out,ccodedot11_table[state]);
dummy+=2; dummy+=2;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
} }
break; break;
case 1: // rate 3/4 case 1: // rate 3/4
for (shiftbit = 0; shiftbit<8; shiftbit++) { for (shiftbit = 0; shiftbit<8; shiftbit++) {
state >>= 1; state >>= 1;
if ((c&(1<<shiftbit)) != 0) { if ((c&(1<<shiftbit)) != 0) {
...@@ -119,10 +107,9 @@ ccodedot11_encode (unsigned int numbytes, ...@@ -119,10 +107,9 @@ ccodedot11_encode (unsigned int numbytes,
*outPtr++ = (out>>1)&1; *outPtr++ = (out>>1)&1;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
printf("%d: %d -> %d (%d)\n",dummy,state,out,ccodedot11_table[state]); printf("%u: %u -> %d (%u)\n",dummy,state,out,ccodedot11_table[state]);
dummy+=2; dummy+=2;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
bit_index=(bit_index==2)?0:(bit_index+1); bit_index=(bit_index==2)?0:(bit_index+1);
} }
...@@ -130,7 +117,6 @@ ccodedot11_encode (unsigned int numbytes, ...@@ -130,7 +117,6 @@ ccodedot11_encode (unsigned int numbytes,
case 2: // rate 2/3 case 2: // rate 2/3
for (shiftbit = 0; shiftbit<8; shiftbit++) { for (shiftbit = 0; shiftbit<8; shiftbit++) {
state >>= 1; state >>= 1;
if ((c&(1<<shiftbit)) != 0) { if ((c&(1<<shiftbit)) != 0) {
...@@ -138,19 +124,16 @@ ccodedot11_encode (unsigned int numbytes, ...@@ -138,19 +124,16 @@ ccodedot11_encode (unsigned int numbytes,
} }
out = ccodedot11_table[state]; out = ccodedot11_table[state];
*outPtr++ = out & 1; *outPtr++ = out & 1;
if (bit_index==0) if (bit_index==0)
*outPtr++ = (out>>1)&1; *outPtr++ = (out>>1)&1;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
printf("%d: %d -> %d (%d)\n",dummy,state,out,ccodedot11_table[state]); printf("%d: %u -> %d (%u)\n",dummy,state,out,ccodedot11_table[state]);
dummy+=2; dummy+=2;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
bit_index=(bit_index==0)?1:0; bit_index=(bit_index==0)?1:0;
} }
break; break;
...@@ -181,8 +164,6 @@ ccodedot11_encode (unsigned int numbytes, ...@@ -181,8 +164,6 @@ ccodedot11_encode (unsigned int numbytes,
} }
*/ */
} }
...@@ -197,8 +178,7 @@ ccodedot11_encode (unsigned int numbytes, ...@@ -197,8 +178,7 @@ ccodedot11_encode (unsigned int numbytes,
/* Basic code table initialization for constraint length 7 */ /* Basic code table initialization for constraint length 7 */
/* Input in MSB, followed by state in 6 LSBs */ /* Input in MSB, followed by state in 6 LSBs */
void ccodedot11_init(void) void ccodedot11_init(void) {
{
unsigned int i, j, k, sum; unsigned int i, j, k, sum;
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
...@@ -219,8 +199,7 @@ void ccodedot11_init(void) ...@@ -219,8 +199,7 @@ void ccodedot11_init(void)
} }
/* Input in LSB, followed by state in 6 MSBs */ /* Input in LSB, followed by state in 6 MSBs */
void ccodedot11_init_inv(void) void ccodedot11_init_inv(void) {
{
unsigned int i, j, k, sum; unsigned int i, j, k, sum;
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
...@@ -251,21 +230,15 @@ void ccodedot11_init_inv(void) ...@@ -251,21 +230,15 @@ void ccodedot11_init_inv(void)
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
#include <stdio.h> #include <stdio.h>
main() main() {
{
unsigned char test[] = "0Thebigredfox"; unsigned char test[] = "0Thebigredfox";
unsigned char output[512], *inPtr, *outPtr; unsigned char output[512], *inPtr, *outPtr;
unsigned int i; unsigned int i;
test[0] = 128; test[0] = 128;
test[1] = 0; test[1] = 0;
ccodedot11_init(); ccodedot11_init();
inPtr = test; inPtr = test;
outPtr = output; outPtr = output;
ccodedot11_encode(16, inPtr, outPtr,0); ccodedot11_encode(16, inPtr, outPtr,0);
for (i = 0; i < 32; i++) printf("%x ", output[i]); for (i = 0; i < 32; i++) printf("%x ", output[i]);
......
...@@ -52,20 +52,16 @@ ccodelte_encode (int32_t numbits, ...@@ -52,20 +52,16 @@ ccodelte_encode (int32_t numbits,
uint8_t add_crc, uint8_t add_crc,
uint8_t *inPtr, uint8_t *inPtr,
uint8_t *outPtr, uint8_t *outPtr,
uint16_t rnti) uint16_t rnti) {
{
uint32_t state; uint32_t state;
uint8_t c, out, first_bit; uint8_t c, out, first_bit;
int8_t shiftbit=0; int8_t shiftbit=0;
uint16_t c16; uint16_t c16;
uint16_t next_last_byte=0; uint16_t next_last_byte=0;
uint32_t crc=0; uint32_t crc=0;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
uint32_t dummy=0; uint32_t dummy=0;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
/* The input bit is shifted in position 8 of the state. /* The input bit is shifted in position 8 of the state.
Shiftbit will take values between 1 and 8 */ Shiftbit will take values between 1 and 8 */
state = 0; state = 0;
...@@ -137,17 +133,12 @@ ccodelte_encode (int32_t numbits, ...@@ -137,17 +133,12 @@ ccodelte_encode (int32_t numbits,
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
/* Do not increment inPtr until we read the next octet */ /* Do not increment inPtr until we read the next octet */
while (numbits > 0) { while (numbits > 0) {
c = *inPtr++; c = *inPtr++;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
printf("** %x **\n",c); printf("** %x **\n",c);
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
// for (shiftbit = 0; (shiftbit<8) && (numbits>0);shiftbit++,numbits--) { // for (shiftbit = 0; (shiftbit<8) && (numbits>0);shiftbit++,numbits--) {
for (shiftbit = 7; (shiftbit>=0) && (numbits>0); shiftbit--,numbits--) { for (shiftbit = 7; (shiftbit>=0) && (numbits>0); shiftbit--,numbits--) {
state >>= 1; state >>= 1;
...@@ -157,23 +148,18 @@ ccodelte_encode (int32_t numbits, ...@@ -157,23 +148,18 @@ ccodelte_encode (int32_t numbits,
} }
out = ccodelte_table[state]; out = ccodelte_table[state];
*outPtr++ = out & 1; *outPtr++ = out & 1;
*outPtr++ = (out>>1)&1; *outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1; *outPtr++ = (out>>2)&1;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
printf("numbits %d, input %d, outbit %d: %d -> %d (%d%d%d)\n",numbits,state>>6,dummy,state,out,out&1,(out>>1)&1,(out>>2)&1); printf("numbits %d, input %d, outbit %d: %d -> %d (%d%d%d)\n",numbits,state>>6,dummy,state,out,out&1,(out>>1)&1,(out>>2)&1);
dummy+=3; dummy+=3;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
} }
} }
// now code 8-bit CRC for UCI // now code 8-bit CRC for UCI
if (add_crc == 1) { if (add_crc == 1) {
c = (uint8_t)(crc>>24); c = (uint8_t)(crc>>24);
// for (shiftbit = 0; (shiftbit<8);shiftbit++) { // for (shiftbit = 0; (shiftbit<8);shiftbit++) {
...@@ -185,22 +171,18 @@ ccodelte_encode (int32_t numbits, ...@@ -185,22 +171,18 @@ ccodelte_encode (int32_t numbits,
} }
out = ccodelte_table[state]; out = ccodelte_table[state];
*outPtr++ = out & 1; *outPtr++ = out & 1;
*outPtr++ = (out>>1)&1; *outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1; *outPtr++ = (out>>2)&1;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
printf("crc bit %d input %d, outbit %d: %d -> %d (%d)\n",shiftbit,state>>6,dummy,state,out,ccodelte_table[state]); printf("crc bit %d input %d, outbit %d: %d -> %d (%u)\n",shiftbit,state>>6,dummy,state,out,ccodelte_table[state]);
dummy+=3; dummy+=3;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
} }
} }
// now code 16-bit CRC for DCI // now code 16-bit CRC for DCI
if (add_crc == 2) { if (add_crc == 2) {
c16 = (uint16_t)(crc>>16); c16 = (uint16_t)(crc>>16);
// for (shiftbit = 0; (shiftbit<16);shiftbit++) { // for (shiftbit = 0; (shiftbit<16);shiftbit++) {
...@@ -212,16 +194,13 @@ ccodelte_encode (int32_t numbits, ...@@ -212,16 +194,13 @@ ccodelte_encode (int32_t numbits,
} }
out = ccodelte_table[state]; out = ccodelte_table[state];
*outPtr++ = out & 1; *outPtr++ = out & 1;
*outPtr++ = (out>>1)&1; *outPtr++ = (out>>1)&1;
*outPtr++ = (out>>2)&1; *outPtr++ = (out>>2)&1;
#ifdef DEBUG_CCODE #ifdef DEBUG_CCODE
printf("crc bit %d input %d, outbit %d: %d -> %d (%d)\n",shiftbit,state>>6,dummy,state,out,ccodelte_table[state]); printf("crc bit %d input %d, outbit %d: %d -> %d (%u)\n",shiftbit,state>>6,dummy,state,out,ccodelte_table[state]);
dummy+=3; dummy+=3;
#endif //DEBUG_CCODE #endif //DEBUG_CCODE
} }
} }
} }
...@@ -238,8 +217,7 @@ ccodelte_encode (int32_t numbits, ...@@ -238,8 +217,7 @@ ccodelte_encode (int32_t numbits,
/* Basic code table initialization for constraint length 7 */ /* Basic code table initialization for constraint length 7 */
/* Input in MSB, followed by state in 6 LSBs */ /* Input in MSB, followed by state in 6 LSBs */
void ccodelte_init(void) void ccodelte_init(void) {
{
unsigned int i, j, k, sum; unsigned int i, j, k, sum;
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
...@@ -260,8 +238,7 @@ void ccodelte_init(void) ...@@ -260,8 +238,7 @@ void ccodelte_init(void)
} }
/* Input in LSB, followed by state in 6 MSBs */ /* Input in LSB, followed by state in 6 MSBs */
void ccodelte_init_inv(void) void ccodelte_init_inv(void) {
{
unsigned int i, j, k, sum; unsigned int i, j, k, sum;
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
...@@ -281,8 +258,7 @@ void ccodelte_init_inv(void) ...@@ -281,8 +258,7 @@ void ccodelte_init_inv(void)
} }
} }
void ccodedab_init(void) void ccodedab_init(void) {
{
unsigned int i, j, k, sum; unsigned int i, j, k, sum;
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
...@@ -303,8 +279,7 @@ void ccodedab_init(void) ...@@ -303,8 +279,7 @@ void ccodedab_init(void)
} }
/* Input in LSB, followed by state in 6 MSBs */ /* Input in LSB, followed by state in 6 MSBs */
void ccodedab_init_inv(void) void ccodedab_init_inv(void) {
{
unsigned int i, j, k, sum; unsigned int i, j, k, sum;
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
...@@ -334,21 +309,15 @@ void ccodedab_init_inv(void) ...@@ -334,21 +309,15 @@ void ccodedab_init_inv(void)
#ifdef CCODE_MAIN #ifdef CCODE_MAIN
#include <stdio.h> #include <stdio.h>
main() main() {
{
unsigned char test[] = "Thebigredfox"; unsigned char test[] = "Thebigredfox";
unsigned char output[512], *inPtr, *outPtr; unsigned char output[512], *inPtr, *outPtr;
unsigned int i; unsigned int i;
test[0] = 128; test[0] = 128;
test[1] = 0; test[1] = 0;
ccodelte_init(); ccodelte_init();
inPtr = test; inPtr = test;
outPtr = output; outPtr = output;
ccodelte_encode(21, inPtr, outPtr); ccodelte_encode(21, inPtr, outPtr);
for (i = 0; i < 21*3; i++) printf("%x ", output[i]); for (i = 0; i < 21*3; i++) printf("%x ", output[i]);
......
This diff is collapsed.
...@@ -38,9 +38,7 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -38,9 +38,7 @@ int lte_segmentation(unsigned char *input_buffer,
unsigned int *Cminus, unsigned int *Cminus,
unsigned int *Kplus, unsigned int *Kplus,
unsigned int *Kminus, unsigned int *Kminus,
unsigned int *F) unsigned int *F) {
{
unsigned int L,Bprime,Bprime_by_C,r,Kr,k,s,crc; unsigned int L,Bprime,Bprime_by_C,r,Kr,k,s,crc;
if (B<=6144) { if (B<=6144) {
...@@ -56,7 +54,7 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -56,7 +54,7 @@ int lte_segmentation(unsigned char *input_buffer,
Bprime = B+((*C)*L); Bprime = B+((*C)*L);
#ifdef DEBUG_SEGMENTATION #ifdef DEBUG_SEGMENTATION
printf("Bprime %d\n",Bprime); printf("Bprime %u\n",Bprime);
#endif #endif
} }
...@@ -68,7 +66,7 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -68,7 +66,7 @@ int lte_segmentation(unsigned char *input_buffer,
// Find K+ // Find K+
Bprime_by_C = Bprime/(*C); Bprime_by_C = Bprime/(*C);
#ifdef DEBUG_SEGMENTATION #ifdef DEBUG_SEGMENTATION
printf("Bprime_by_C %d\n",Bprime_by_C); printf("Bprime_by_C %u\n",Bprime_by_C);
#endif #endif
// Bprime = Bprime_by_C>>3; // Bprime = Bprime_by_C>>3;
...@@ -93,17 +91,16 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -93,17 +91,16 @@ int lte_segmentation(unsigned char *input_buffer,
*Kminus = (*Kplus - 32); *Kminus = (*Kplus - 32);
} else if (Bprime_by_C <=6144 ) { // increase by 8 bytes til here } else if (Bprime_by_C <=6144 ) { // increase by 8 bytes til here
*Kplus = (Bprime_by_C>>6)<<6; *Kplus = (Bprime_by_C>>6)<<6;
#ifdef DEBUG_SEGMENTATION #ifdef DEBUG_SEGMENTATION
printf("Bprime_by_C_by_C %d , Kplus %d\n",Bprime_by_C,*Kplus); printf("Bprime_by_C_by_C %u , Kplus %u\n",Bprime_by_C,*Kplus);
#endif #endif
if (*Kplus < Bprime_by_C) if (*Kplus < Bprime_by_C)
*Kplus = *Kplus + 64; *Kplus = *Kplus + 64;
#ifdef DEBUG_SEGMENTATION #ifdef DEBUG_SEGMENTATION
printf("Bprime_by_C_by_C %d , Kplus2 %d\n",Bprime_by_C,*Kplus); printf("Bprime_by_C_by_C %u , Kplus2 %u\n",Bprime_by_C,*Kplus);
#endif #endif
*Kminus = (*Kplus - 64); *Kminus = (*Kplus - 64);
} else { } else {
...@@ -116,25 +113,21 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -116,25 +113,21 @@ int lte_segmentation(unsigned char *input_buffer,
*Kminus = 0; *Kminus = 0;
*Cminus = 0; *Cminus = 0;
} else { } else {
// printf("More than one segment (%d), exiting \n",*C); // printf("More than one segment (%d), exiting \n",*C);
// exit(-1); // exit(-1);
*Cminus = ((*C)*(*Kplus) - (Bprime))/((*Kplus) - (*Kminus)); *Cminus = ((*C)*(*Kplus) - (Bprime))/((*Kplus) - (*Kminus));
*Cplus = (*C) - (*Cminus); *Cplus = (*C) - (*Cminus);
} }
AssertFatal(Bprime <= (*Cplus)*(*Kplus) + (*Cminus)*(*Kminus), AssertFatal(Bprime <= (*Cplus)*(*Kplus) + (*Cminus)*(*Kminus),
"Bprime %d < (*Cplus %d)*(*Kplus %d) + (*Cminus %d)*(*Kminus %d)\n", "Bprime %d < (*Cplus %d)*(*Kplus %d) + (*Cminus %d)*(*Kminus %d)\n",
Bprime,*Cplus,*Kplus,*Cminus,*Kminus); Bprime,*Cplus,*Kplus,*Cminus,*Kminus);
*F = ((*Cplus)*(*Kplus) + (*Cminus)*(*Kminus) - (Bprime)); *F = ((*Cplus)*(*Kplus) + (*Cminus)*(*Kminus) - (Bprime));
#ifdef DEBUG_SEGMENTATION #ifdef DEBUG_SEGMENTATION
printf("C %d, Cplus %d, Cminus %d, Kplus %d, Kminus %d, Bprime_bytes %d, Bprime %d, F %d\n",*C,*Cplus,*Cminus,*Kplus,*Kminus,Bprime>>3,Bprime,*F); printf("C %u, Cplus %u, Cminus %u, Kplus %u, Kminus %u, Bprime_bytes %u, Bprime %u, F %u\n",*C,*Cplus,*Cminus,*Kplus,*Kminus,Bprime>>3,Bprime,*F);
#endif #endif
if ((input_buffer) && (output_buffers)) { if ((input_buffer) && (output_buffers)) {
for (k=0; k<*F>>3; k++) { for (k=0; k<*F>>3; k++) {
output_buffers[0][k] = 0; output_buffers[0][k] = 0;
} }
...@@ -142,7 +135,6 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -142,7 +135,6 @@ int lte_segmentation(unsigned char *input_buffer,
s=0; s=0;
for (r=0; r<*C; r++) { for (r=0; r<*C; r++) {
if (r<*Cminus) if (r<*Cminus)
Kr = *Kminus; Kr = *Kminus;
else else
...@@ -157,11 +149,11 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -157,11 +149,11 @@ int lte_segmentation(unsigned char *input_buffer,
if (*C > 1) { // add CRC if (*C > 1) { // add CRC
crc = crc24b(output_buffers[r],Kr-24)>>8; crc = crc24b(output_buffers[r],Kr-24)>>8;
output_buffers[r][(Kr-24)>>3] = ((uint8_t*)&crc)[2]; output_buffers[r][(Kr-24)>>3] = ((uint8_t *)&crc)[2];
output_buffers[r][1+((Kr-24)>>3)] = ((uint8_t*)&crc)[1]; output_buffers[r][1+((Kr-24)>>3)] = ((uint8_t *)&crc)[1];
output_buffers[r][2+((Kr-24)>>3)] = ((uint8_t*)&crc)[0]; output_buffers[r][2+((Kr-24)>>3)] = ((uint8_t *)&crc)[0];
#ifdef DEBUG_SEGMENTATION #ifdef DEBUG_SEGMENTATION
printf("Segment %d : CRC %x\n",r,crc); printf("Segment %u : CRC %x\n",r,crc);
#endif #endif
} }
...@@ -175,9 +167,7 @@ int lte_segmentation(unsigned char *input_buffer, ...@@ -175,9 +167,7 @@ int lte_segmentation(unsigned char *input_buffer,
#ifdef MAIN #ifdef MAIN
main() main() {
{
unsigned int Kplus,Kminus,C,Cplus,Cminus,F,Bbytes; unsigned int Kplus,Kminus,C,Cplus,Cminus,F,Bbytes;
for (Bbytes=5; Bbytes<2*768; Bbytes++) { for (Bbytes=5; Bbytes<2*768; Bbytes++) {
......
This diff is collapsed.
...@@ -33,26 +33,23 @@ This header file must be included */ ...@@ -33,26 +33,23 @@ This header file must be included */
#define OPT_H_ #define OPT_H_
#ifndef sys_include #ifndef sys_include
#define sys_include #define sys_include
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#endif #endif
#ifndef project_include #ifndef project_include
#define project_include #define project_include
#include "common/utils/LOG/log_if.h" #include "common/utils/LOG/log_if.h"
// #include "UTIL/LOG/log_extern.h" #include "PHY/impl_defs_lte.h"
//#include "PHY/defs.h"
//#include "PHY/extern.h"
#include "PHY/impl_defs_lte.h"
#endif #endif
#define PACKET_MAC_LTE_DEFAULT_UDP_PORT (9999) #define PACKET_MAC_LTE_DEFAULT_UDP_PORT (9999)
...@@ -65,6 +62,32 @@ typedef guint8 gboolean; ...@@ -65,6 +62,32 @@ typedef guint8 gboolean;
#include "packet-mac-lte.h" #include "packet-mac-lte.h"
#include "mac_pcap.h" #include "mac_pcap.h"
/* OPT parameters definitions */
#define OPT_CONFIGPREFIX "opt"
#define CONFIG_HLP_TYPEMON "Type of L2 monitoring messages: none,pcap,wireshark \n"
#define CONFIG_HLP_L2MONIP "ip address for wireshark messages \n"
#define CONFIG_HLP_L2MONPATH "file path for pcap messages on localhost \n"
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters for LOG utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define OPT_PARAMS_DESC { \
{"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
/* check function for opt parameters */
#define OPTTYPE_OKSTRINGS {"none","pcap","wireshark"}
#define OPTTYPE_VALUES {OPT_NONE,OPT_PCAP,OPT_WIRESHARK}
#define OPTPARAMS_CHECK_DESC { \
{ .s3a= { config_checkstr_assign_integer, OPTTYPE_OKSTRINGS,OPTTYPE_VALUES ,3}} ,\
{ .s5= {NULL }} , \
{ .s5= {NULL }} , \
}
#ifdef OCP_FRAMEWORK #ifdef OCP_FRAMEWORK
#include <enums.h> #include <enums.h>
#else #else
...@@ -82,9 +105,7 @@ typedef enum radio_type_e { ...@@ -82,9 +105,7 @@ typedef enum radio_type_e {
RADIO_TYPE_MAX RADIO_TYPE_MAX
} radio_type_t; } radio_type_t;
extern trace_mode_t opt_type;
extern char in_ip[40];
extern char in_path[FILENAME_MAX];
/** /**
* function def * function def
...@@ -94,7 +115,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size, ...@@ -94,7 +115,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe, int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe,
int oob_event, int oob_event_value); int oob_event, int oob_event_value);
int init_opt(char *path, char *ip); int init_opt(void);
void terminate_opt(void); void terminate_opt(void);
......
This diff is collapsed.
...@@ -47,46 +47,33 @@ uint64_t set_softmodem_optmask(uint64_t bitmask) { ...@@ -47,46 +47,33 @@ uint64_t set_softmodem_optmask(uint64_t bitmask) {
return softmodem_params.optmask; return softmodem_params.optmask;
} }
softmodem_params_t* get_softmodem_params(void) { softmodem_params_t *get_softmodem_params(void) {
return &softmodem_params; return &softmodem_params;
} }
void get_common_options(void) void get_common_options(void) {
{ uint32_t online_log_messages;
uint32_t glog_level ;
uint32_t start_telnetsrv;
uint32_t online_log_messages; uint32_t noS1;
uint32_t glog_level ; uint32_t nokrnmod;
uint32_t start_telnetsrv; uint32_t nonbiot;
uint32_t noS1; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ;
uint32_t nokrnmod; paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ;
uint32_t nonbiot; checkedparam_t cmdline_log_CheckParams[] = CMDLINE_LOGPARAMS_CHECK_DESC;
paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; config_get( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; config_set_checkfunctions(cmdline_logparams, cmdline_log_CheckParams,
sizeof(cmdline_logparams)/sizeof(paramdef_t));
config_get( cmdline_logparams,sizeof(cmdline_logparams)/sizeof(paramdef_t),NULL);
config_process_cmdline( cmdline_params,sizeof(cmdline_params)/sizeof(paramdef_t),NULL);
if (strlen(in_path) > 0) {
opt_type = OPT_PCAP;
opt_enabled=1;
printf("Enabling OPT for PCAP with the following file %s \n",in_path);
}
if (strlen(in_ip) > 0) {
opt_enabled=1;
opt_type = OPT_WIRESHARK;
printf("Enabling OPT for wireshark for local interface");
}
config_process_cmdline( cmdline_logparams,sizeof(cmdline_logparams)/sizeof(paramdef_t),NULL);
if(config_isparamset(cmdline_logparams,CMDLINE_ONLINELOG_IDX)) { if(config_isparamset(cmdline_logparams,CMDLINE_ONLINELOG_IDX)) {
set_glog_onlinelog(online_log_messages); set_glog_onlinelog(online_log_messages);
} }
if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) { if(config_isparamset(cmdline_logparams,CMDLINE_GLOGLEVEL_IDX)) {
set_glog(glog_level); set_glog(glog_level);
} }
if (start_telnetsrv) { if (start_telnetsrv) {
load_module_shlib("telnetsrv",NULL,0,NULL); load_module_shlib("telnetsrv",NULL,0,NULL);
} }
...@@ -94,12 +81,16 @@ paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; ...@@ -94,12 +81,16 @@ paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ;
if (noS1) { if (noS1) {
set_softmodem_optmask(SOFTMODEM_NOS1_BIT); set_softmodem_optmask(SOFTMODEM_NOS1_BIT);
} }
if (nokrnmod) { if (nokrnmod) {
set_softmodem_optmask(SOFTMODEM_NOKRNMOD_BIT); set_softmodem_optmask(SOFTMODEM_NOKRNMOD_BIT);
} }
if (nonbiot) { if (nonbiot) {
set_softmodem_optmask(SOFTMODEM_NONBIOT_BIT); set_softmodem_optmask(SOFTMODEM_NONBIOT_BIT);
} }
if(parallel_config != NULL) set_parallel_conf(parallel_config); if(parallel_config != NULL) set_parallel_conf(parallel_config);
if(worker_config != NULL) set_worker_conf(worker_config); if(worker_config != NULL) set_worker_conf(worker_config);
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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