mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-16 14:10:28 +00:00
Compare commits
84 Commits
fujitsu_nr
...
setparam
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51ce2fb17f | ||
|
|
4ca7dafb64 | ||
|
|
a3b05f0bd6 | ||
|
|
61dab4c7fd | ||
|
|
afb85855a9 | ||
|
|
eb68baaaa6 | ||
|
|
b4e0280228 | ||
|
|
16fc6028f9 | ||
|
|
2051e652fb | ||
|
|
6dc9440bd1 | ||
|
|
51f2a75bac | ||
|
|
1fadb0c11e | ||
|
|
9d2b747586 | ||
|
|
12099a910e | ||
|
|
9cca19e2b4 | ||
|
|
698e7fee1f | ||
|
|
857094e95c | ||
|
|
39a8aa3455 | ||
|
|
291533dd71 | ||
|
|
e18753db6e | ||
|
|
4cfa385ae0 | ||
|
|
2761d013d7 | ||
|
|
b112ed2c6b | ||
|
|
abb59447b3 | ||
|
|
e3d38b5cbe | ||
|
|
3b282d7fb9 | ||
|
|
80bf03581d | ||
|
|
86f36e8098 | ||
|
|
273ce8cb49 | ||
|
|
93126750ea | ||
|
|
7a7b2ff48a | ||
|
|
dac3bc1af5 | ||
|
|
32e49924b0 | ||
|
|
b203d4aebc | ||
|
|
dfa7579857 | ||
|
|
f2af6c26fa | ||
|
|
c4cf67f04b | ||
|
|
9dbcab30c8 | ||
|
|
24e878148e | ||
|
|
8d74ea3809 | ||
|
|
a3ac83a1bf | ||
|
|
5ef05129e1 | ||
|
|
8de026f86e | ||
|
|
3127898899 | ||
|
|
3c6b21e9c0 | ||
|
|
2afae81592 | ||
|
|
fa03569f1f | ||
|
|
108d9a965e | ||
|
|
6686076f06 | ||
|
|
afdbca2a48 | ||
|
|
a3b64c4a7e | ||
|
|
564bcde637 | ||
|
|
2027d77b18 | ||
|
|
28f1035e27 | ||
|
|
6e3f09a35d | ||
|
|
9ca2d78f2e | ||
|
|
14321bfe6f | ||
|
|
1fee616d62 | ||
|
|
1eb79272a1 | ||
|
|
79b8586432 | ||
|
|
9301d8a7f0 | ||
|
|
8ad4c7b75c | ||
|
|
36e1715f18 | ||
|
|
310245ef78 | ||
|
|
64e33694ef | ||
|
|
8c355a08a7 | ||
|
|
b575a95144 | ||
|
|
c239d99f1c | ||
|
|
fc3319c9dc | ||
|
|
f1e87cab8f | ||
|
|
e5a96b5d01 | ||
|
|
77b4022bbf | ||
|
|
d007295a34 | ||
|
|
6bcd3006b0 | ||
|
|
7acc5e967b | ||
|
|
426b99211d | ||
|
|
c7b2c19f0c | ||
|
|
317559806a | ||
|
|
51362d9c6c | ||
|
|
8ead6ae767 | ||
|
|
6e915cd64e | ||
|
|
190f90e35d | ||
|
|
7f19b9453e | ||
|
|
5861a7019b |
30
.vscode/launch.json
vendored
30
.vscode/launch.json
vendored
@@ -10,7 +10,8 @@
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/cmake_targets/ran_build/build/lte-softmodem",
|
||||
"args": [
|
||||
"-O", "../ci-scripts/conf_files/rcc.band7.tm1.nfapi.conf",
|
||||
"-O",
|
||||
"../ci-scripts/conf_files/rcc.band7.tm1.nfapi.conf",
|
||||
"--noS1"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
@@ -26,6 +27,31 @@
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Launch Chrome (4200 ng serve)",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"url": "http://localhost:4200",
|
||||
"webRoot": "${workspaceFolder}/common/utils/websrv/frontend"
|
||||
},
|
||||
{
|
||||
"name": "Launch Chrome (localhost)",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"url": "http://localhost",
|
||||
"webRoot": "${workspaceFolder}",
|
||||
"sourceMapPathOverrides": {
|
||||
"webpack:/*": "${webRoot}/*",
|
||||
"/./*": "${webRoot}/*",
|
||||
"/src/*": "${webRoot}/*",
|
||||
"/*": "*",
|
||||
"/./~/*": "${webRoot}/node_modules/*"
|
||||
},
|
||||
"trace": true,
|
||||
"runtimeArgs": [
|
||||
"--remote-debugging-port=9222"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -2763,7 +2763,6 @@ add_executable(nr-uesoftmodem
|
||||
${OPENAIR_DIR}/executables/nr-uesoftmodem.c
|
||||
${OPENAIR_DIR}/executables/nr-ue.c
|
||||
${OPENAIR_DIR}/executables/softmodem-common.c
|
||||
${OPENAIR_DIR}/executables/prometheus_exporter.c
|
||||
${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c
|
||||
${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c
|
||||
${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c
|
||||
@@ -3179,3 +3178,4 @@ ADD_CUSTOM_TARGET(oarf
|
||||
)
|
||||
|
||||
include (${OPENAIR_DIR}/common/utils/telnetsrv/telnetsrv_CMakeLists.txt)
|
||||
include (${OPENAIR_DIR}/common/utils/websrv/websrv_CMakeLists.txt)
|
||||
|
||||
@@ -57,7 +57,7 @@ CMAKE_BUILD_TYPE="RelWithDebInfo"
|
||||
CMAKE_CMD="$CMAKE"
|
||||
BUILD_ECLIPSE=0
|
||||
NR="False"
|
||||
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope"
|
||||
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope websrv"
|
||||
RU=0
|
||||
trap handle_ctrl_c INT
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// Monitoring Items
|
||||
// real time monotoring
|
||||
pbch_iq
|
||||
pbch_ch
|
||||
pdcch_iq
|
||||
pdcch_ch
|
||||
rar_iq
|
||||
rar_ch
|
||||
sib_iq
|
||||
sib_ch
|
||||
sss_iq
|
||||
pdsch_iq
|
||||
pdsch_chest
|
||||
// prometheus monitor
|
||||
pdcch_pow
|
||||
dl_freq_resource
|
||||
ul_freq_resource
|
||||
dl_mcs
|
||||
dl_tbs
|
||||
ul_mcs
|
||||
ul_tbs
|
||||
pss_peak_power
|
||||
|
||||
@@ -88,6 +88,8 @@ int processoption(paramdef_t *cfgoptions, char *value) {
|
||||
config_check_valptr(cfgoptions, cfgoptions->strptr, strlen(tmpval)+1);
|
||||
sprintf(*(cfgoptions->strptr), "%s",tmpval);
|
||||
} else {
|
||||
AssertFatal( ( strlen(*(cfgoptions->strptr)) < cfgoptions->numelt), "[CONFIG] Error: %s too long, %s value cannot exceed %i bytes\n",
|
||||
cfgoptions->optname,tmpval, cfgoptions->numelt) ;
|
||||
sprintf( (char *)(cfgoptions->strptr), "%s",tmpval);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,10 +88,21 @@ int load_config_sharedlib(configmodule_interface_t *cfgptr) {
|
||||
st = -1;
|
||||
}
|
||||
|
||||
if ( cfgptr->rtflags & CONFIG_SAVERUNCFG ) {
|
||||
sprintf (fname,"config_%s_set",cfgptr->cfgmode);
|
||||
cfgptr->set = dlsym(lib_handle,fname);
|
||||
|
||||
if (cfgptr->set == NULL ) {
|
||||
printf("[CONFIG] %s %d no function %s for config mode %s\n",
|
||||
__FILE__, __LINE__,fname, cfgptr->cfgmode);
|
||||
st = -1;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf (fname,"config_%s_end",cfgptr->cfgmode);
|
||||
cfgptr->end = dlsym(lib_handle,fname);
|
||||
|
||||
if (cfgptr->getlist == NULL ) {
|
||||
if (cfgptr->end == NULL ) {
|
||||
printf("[CONFIG] %s %d no function %s for config mode %s\n",
|
||||
__FILE__, __LINE__,fname, cfgptr->cfgmode);
|
||||
}
|
||||
@@ -186,6 +197,7 @@ configmodule_interface_t *load_configmodule(int argc,
|
||||
uint32_t initflags)
|
||||
{
|
||||
char *cfgparam=NULL;
|
||||
|
||||
char *modeparams=NULL;
|
||||
char *cfgmode=NULL;
|
||||
char *strtokctx=NULL;
|
||||
@@ -193,7 +205,8 @@ configmodule_interface_t *load_configmodule(int argc,
|
||||
uint32_t tmpflags=0;
|
||||
int i;
|
||||
int OoptIdx=-1;
|
||||
|
||||
int OWoptIdx=-1;
|
||||
|
||||
printf("CMDLINE: ");
|
||||
for (int i=0; i<argc; i++)
|
||||
printf("\"%s\" ", argv[i]);
|
||||
@@ -208,7 +221,11 @@ configmodule_interface_t *load_configmodule(int argc,
|
||||
cfgparam = argv[i+1];
|
||||
OoptIdx=i;
|
||||
}
|
||||
|
||||
|
||||
char *OWopt = strstr(argv[i],"OW");
|
||||
if ( OWopt == argv[i]+2) {
|
||||
OWoptIdx=i;
|
||||
}
|
||||
if ( strstr(argv[i], "help_config") != NULL ) {
|
||||
config_printhelp(Config_Params,CONFIG_PARAMLENGTH(Config_Params),CONFIG_SECTIONNAME);
|
||||
exit(0);
|
||||
@@ -258,6 +275,11 @@ configmodule_interface_t *load_configmodule(int argc,
|
||||
/* argv[0] is the exec name, always Ok */
|
||||
cfgptr->argv_info[0] |= CONFIG_CMDLINEOPT_PROCESSED;
|
||||
|
||||
/* When reuested _(_--OW or rtflag is 5), a file with config parameters, as defined after all processing, will be created */
|
||||
if (OWoptIdx >= 0) {
|
||||
cfgptr->argv_info[OWoptIdx] |= CONFIG_CMDLINEOPT_PROCESSED;
|
||||
cfgptr->rtflags |= CONFIG_SAVERUNCFG ;
|
||||
}
|
||||
/* when OoptIdx is >0, -O option has been detected at position OoptIdx
|
||||
* we must memorize arv[OoptIdx is Ok */
|
||||
if (OoptIdx >= 0) {
|
||||
@@ -294,14 +316,18 @@ configmodule_interface_t *load_configmodule(int argc,
|
||||
printf("%s ",cfgptr->cfgP[i]);
|
||||
}
|
||||
|
||||
printf(", debug flags: 0x%08x\n",cfgptr->rtflags);
|
||||
|
||||
if (cfgptr->rtflags & CONFIG_PRINTPARAMS) {
|
||||
cfgptr->status = malloc(sizeof(configmodule_status_t));
|
||||
}
|
||||
if (strstr(cfgparam,CONFIG_CMDLINEONLY) == NULL) {
|
||||
i=load_config_sharedlib(cfgptr);
|
||||
|
||||
if (i == 0) {
|
||||
printf("[CONFIG] config module %s loaded\n",cfgmode);
|
||||
Config_Params[CONFIGPARAM_DEBUGFLAGS_IDX].uptr=&(cfgptr->rtflags);
|
||||
int idx = config_paramidx_fromname(Config_Params, CONFIG_PARAMLENGTH(Config_Params), CONFIGP_DEBUGFLAGS);
|
||||
Config_Params[idx].uptr=&(cfgptr->rtflags);
|
||||
idx = config_paramidx_fromname(Config_Params, CONFIG_PARAMLENGTH(Config_Params), CONFIGP_TMPDIR);
|
||||
Config_Params[idx].strptr=&(cfgptr->tmpdir);
|
||||
config_get(Config_Params,CONFIG_PARAMLENGTH(Config_Params), CONFIG_SECTIONNAME );
|
||||
} else {
|
||||
fprintf(stderr,"[CONFIG] %s %d config module \"%s\" couldn't be loaded\n", __FILE__, __LINE__,cfgmode);
|
||||
@@ -313,7 +339,10 @@ configmodule_interface_t *load_configmodule(int argc,
|
||||
cfgptr->getlist = config_cmdlineonly_getlist;
|
||||
cfgptr->end = (configmodule_endfunc_t)nooptfunc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("[CONFIG] debug flags: 0x%08x\n",cfgptr->rtflags);
|
||||
|
||||
if (modeparams != NULL) free(modeparams);
|
||||
|
||||
if (cfgmode != NULL) free(cfgmode);
|
||||
@@ -330,6 +359,14 @@ configmodule_interface_t *load_configmodule(int argc,
|
||||
/* free memory allocated when reading parameters */
|
||||
/* config module could be initialized again after this call */
|
||||
void end_configmodule(void) {
|
||||
if ( cfgptr->status && (cfgptr->rtflags & CONFIG_SAVERUNCFG)) {
|
||||
printf_params("[CONFIG] Runtime params creation status: %i null values, %i errors, %i empty list or array, %i successfull \n",
|
||||
cfgptr->status->num_err_nullvalue,
|
||||
cfgptr->status->num_err_write,
|
||||
cfgptr->status->emptyla,
|
||||
cfgptr->status->num_write);
|
||||
|
||||
}
|
||||
if (cfgptr != NULL) {
|
||||
if (cfgptr->end != NULL) {
|
||||
printf ("[CONFIG] calling config module end function...\n");
|
||||
@@ -355,7 +392,7 @@ void end_configmodule(void) {
|
||||
void free_configmodule(void) {
|
||||
if (cfgptr != NULL) {
|
||||
end_configmodule();
|
||||
|
||||
if( cfgptr->status != NULL) free(cfgptr->status);
|
||||
if( cfgptr->cfgmode != NULL) free(cfgptr->cfgmode);
|
||||
|
||||
printf ("[CONFIG] free %i config parameter pointers\n",cfgptr->num_cfgP);
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#define CONFIG_DEBUGPTR (1<<1) // print memory allocation/free debug messages
|
||||
#define CONFIG_DEBUGCMDLINE (1<<2) // print command line processing messages
|
||||
#define CONFIG_NOABORTONCHKF (1<<4) // disable abort execution when parameter checking function fails
|
||||
#define CONFIG_SAVERUNCFG (1<<5) // create config file with running values, as after cfg file + command line processing
|
||||
#define CONFIG_NOEXITONHELP (1<<19) // do not exit after printing help
|
||||
#define CONFIG_HELP (1<<20) // print help message
|
||||
#define CONFIG_ABORT (1<<21) // config failed,abort execution
|
||||
@@ -61,7 +62,23 @@
|
||||
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 int(*configmodule_setfunc_t)(paramdef_t *cfgoptions, int numoptions, char *prefix );
|
||||
typedef void(*configmodule_endfunc_t)(void);
|
||||
typedef struct configmodule_status {
|
||||
int num_paramgroups;
|
||||
char ** paramgroups_names;
|
||||
int num_err_nullvalue;
|
||||
int emptyla;
|
||||
union {
|
||||
int num_err_read;
|
||||
int num_err_write;
|
||||
};
|
||||
union {
|
||||
int num_read;
|
||||
int num_write;
|
||||
} ;
|
||||
}configmodule_status_t;
|
||||
|
||||
typedef struct configmodule_interface {
|
||||
int argc;
|
||||
char **argv;
|
||||
@@ -72,11 +89,14 @@ typedef struct configmodule_interface {
|
||||
configmodule_initfunc_t init;
|
||||
configmodule_getfunc_t get;
|
||||
configmodule_getlistfunc_t getlist;
|
||||
configmodule_setfunc_t set;
|
||||
configmodule_endfunc_t end;
|
||||
uint32_t numptrs;
|
||||
uint32_t rtflags;
|
||||
char *ptrs[CONFIG_MAX_ALLOCATEDPTRS];
|
||||
bool ptrsAllocated[CONFIG_MAX_ALLOCATEDPTRS];
|
||||
char *tmpdir;
|
||||
configmodule_status_t *status; // allocated in debug mode only
|
||||
} configmodule_interface_t;
|
||||
|
||||
#ifdef CONFIG_LOADCONFIG_MAIN
|
||||
@@ -89,16 +109,19 @@ static char config_helpstr [] = "\n lte-softmodem -O [config mode]<:dbgl[debugfl
|
||||
incp parameter can be used to define the include path used for config files (@include directive)\n \
|
||||
defaults is set to the path of the main config file.\n";
|
||||
|
||||
#define CONFIG_SECTIONNAME "config"
|
||||
#define CONFIGPARAM_DEBUGFLAGS_IDX 0
|
||||
#define CONFIG_HELP_TMPDIR "<Repository to create temporary file>"
|
||||
|
||||
#define CONFIG_SECTIONNAME "config"
|
||||
#define CONFIGP_DEBUGFLAGS "debugflags"
|
||||
#define CONFIGP_TMPDIR "tmpdir"
|
||||
|
||||
static paramdef_t Config_Params[] = {
|
||||
/*-----------------------------------------------------------------------------------------------------------------------*/
|
||||
/* config parameters for config module */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
/*-----------------------------------------------------------------------------------------------------------------------*/
|
||||
{"debugflags", config_helpstr, 0, uptr:NULL, defintval:0, TYPE_MASK, 0},
|
||||
/*--------------------------------------------------------------------------------------------------------------------------*/
|
||||
/* config parameters for config module */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
/*--------------------------------------------------------------------------------------------------------------------------*/
|
||||
{CONFIGP_DEBUGFLAGS, config_helpstr, 0, uptr:NULL, defintval:0, TYPE_MASK, 0},
|
||||
{CONFIGP_TMPDIR, CONFIG_HELP_TMPDIR,PARAMFLAG_NOFREE, strptr:NULL, defstrval:"/tmp" ,TYPE_STRING, 0},
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#define PARAMFLAG_NOFREE (1 << 3) // don't free parameter in end function
|
||||
#define PARAMFLAG_BOOL (1 << 4) // integer param can be 0 or 1
|
||||
#define PARAMFLAG_CMDLINE_NOPREFIXENABLED (1 << 5) // on the command line, allow a parameter to be specified without the prefix
|
||||
#define PARAMFLAG_CMDLINEONLY (1 << 6) // this parameter cannot be specified in config file
|
||||
|
||||
/* Flags used by config modules to return info to calling modules and/or to for internal usage*/
|
||||
#define PARAMFLAG_MALLOCINCONFIG (1 << 15) // parameter allocated in config module
|
||||
|
||||
@@ -237,6 +237,9 @@ int config_get(paramdef_t *params, int numparams, char *prefix) {
|
||||
|
||||
if (ret >= 0) {
|
||||
config_process_cmdline(params, numparams, prefix);
|
||||
if ( cfgif->rtflags & CONFIG_SAVERUNCFG ) {
|
||||
config_get_if()->set(params, numparams, prefix);
|
||||
}
|
||||
config_execcheck(params, numparams, prefix);
|
||||
}
|
||||
|
||||
@@ -271,9 +274,11 @@ int config_getlist(paramlist_def_t *ParamList, paramdef_t *params, int numparams
|
||||
char cfgpath[MAX_OPTNAME_SIZE*2 + 6]; /* prefix.listname.[listindex] */
|
||||
|
||||
for (int i = 0; i < ParamList->numelt; ++i) {
|
||||
// TODO config_process_cmdline?
|
||||
sprintf(cfgpath, "%s.[%i]", newprefix, i);
|
||||
config_process_cmdline(ParamList->paramarray[i],numparams,cfgpath);
|
||||
if ( config_get_if()->rtflags & CONFIG_SAVERUNCFG ) {
|
||||
config_get_if()->set(ParamList->paramarray[i], numparams,cfgpath );
|
||||
}
|
||||
config_execcheck(ParamList->paramarray[i], numparams, cfgpath);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,11 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <libgen.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "config_libconfig.h"
|
||||
#include "config_libconfig_private.h"
|
||||
@@ -87,8 +90,222 @@ int read_intarray(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpat
|
||||
|
||||
return cfgoptions->numelt;
|
||||
}
|
||||
int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_setting_t * asetting, char * prefix) {
|
||||
int status;
|
||||
int errors=0;
|
||||
int notused=0;
|
||||
int emptyla=0;
|
||||
#define LIBCONFIG_NOTUSED_PARAMS "Not used? (NULL value ptr)"
|
||||
char *secprefix=(prefix==NULL)?"":prefix;
|
||||
|
||||
for(int i=0; i<numoptions; i++) {
|
||||
if (cfgoptions[i].paramflags & PARAMFLAG_CMDLINEONLY) {
|
||||
continue;
|
||||
printf_params("[LIBCONFIG] setting %s.%s skipped (command line only) \n",secprefix,cfgoptions[i].optname);
|
||||
}
|
||||
status=CONFIG_FALSE;
|
||||
config_setting_t * psetting;
|
||||
char *spath=malloc(((prefix==NULL)?0:strlen(prefix))+strlen(cfgoptions[i].optname)+10);
|
||||
sprintf(spath,"%s%s%s",secprefix, (prefix==NULL)?"":".", cfgoptions[i].optname);
|
||||
psetting = config_lookup(&(libconfig_privdata.runtcfg),spath);
|
||||
free(spath);
|
||||
if (psetting != NULL) {
|
||||
printf_params("[LIBCONFIG] setting %s.%s already created \n",secprefix,cfgoptions[i].optname);
|
||||
continue;
|
||||
}
|
||||
switch(cfgoptions[i].type) {
|
||||
case TYPE_STRING:
|
||||
psetting =config_setting_add(asetting,cfgoptions[i].optname,CONFIG_TYPE_STRING);
|
||||
if (psetting!= NULL) {
|
||||
char *value;
|
||||
if (cfgoptions[i].strptr == NULL) {
|
||||
notused++;
|
||||
value=LIBCONFIG_NOTUSED_PARAMS;
|
||||
} else {
|
||||
if (cfgoptions[i].numelt == 0 ) {
|
||||
value = *(cfgoptions[i].strptr);
|
||||
} else {
|
||||
value = (char *)(cfgoptions[i].strptr);
|
||||
}
|
||||
}
|
||||
status=config_setting_set_string(psetting, value);
|
||||
}
|
||||
break;
|
||||
case TYPE_STRINGLIST:
|
||||
psetting =config_setting_add(asetting,cfgoptions[i].optname,CONFIG_TYPE_LIST);
|
||||
if (psetting!= NULL)
|
||||
{
|
||||
if(cfgoptions[i].numelt <= 0) {
|
||||
emptyla++;
|
||||
printf_params("[LIBCONFIG], no element in list %s\n",cfgoptions[i].optname);
|
||||
status=CONFIG_TRUE;
|
||||
}
|
||||
for (int j=0; j<cfgoptions[i].numelt ; j++) {
|
||||
config_setting_t *elemsetting=config_setting_set_string_elem(psetting, -1,cfgoptions[i].strptr[j] );
|
||||
if (elemsetting == NULL) {
|
||||
fprintf(stderr,"[LIBCONFIG] Error: Creating list %s element %i value %s\n",cfgoptions[i].optname,j,cfgoptions[i].strptr[j]);
|
||||
break;
|
||||
} else
|
||||
status=CONFIG_TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_UINT8:
|
||||
case TYPE_INT8:
|
||||
case TYPE_UINT16:
|
||||
case TYPE_INT16:
|
||||
case TYPE_UINT32:
|
||||
case TYPE_INT32:
|
||||
case TYPE_MASK:
|
||||
psetting =config_setting_add(asetting,cfgoptions[i].optname,CONFIG_TYPE_INT);
|
||||
if (psetting!= NULL)
|
||||
status=config_setting_set_int(psetting, (int)*(cfgoptions[i].iptr) );
|
||||
break;
|
||||
|
||||
case TYPE_UINT64:
|
||||
case TYPE_INT64:
|
||||
psetting =config_setting_add(asetting,cfgoptions[i].optname,CONFIG_TYPE_INT64);
|
||||
if (psetting!= NULL)
|
||||
status=config_setting_set_int64(psetting, (int64_t)*(cfgoptions[i].i64ptr) );
|
||||
break;
|
||||
|
||||
case TYPE_UINTARRAY:
|
||||
case TYPE_INTARRAY:
|
||||
psetting =config_setting_add(asetting,cfgoptions[i].optname,CONFIG_TYPE_ARRAY);
|
||||
if (psetting!= NULL) {
|
||||
if(cfgoptions[i].numelt <= 0) {
|
||||
emptyla++;
|
||||
printf_params("[LIBCONFIG], no element in array %s.%s\n",secprefix,cfgoptions[i].optname);
|
||||
status=CONFIG_TRUE;
|
||||
}
|
||||
for (int j=0; j<cfgoptions[i].numelt ; j++) {
|
||||
config_setting_t *elemsetting=config_setting_set_int_elem(psetting, -1,(int)(cfgoptions[i].iptr[j]) );
|
||||
if (elemsetting == NULL) {
|
||||
fprintf(stderr,"[LIBCONFIG] Error: Creating array %s.%s, at index %i value %i\n",secprefix,cfgoptions[i].optname,j,(int)(cfgoptions[i].iptr[j]));
|
||||
break;
|
||||
} else
|
||||
status=CONFIG_TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_DOUBLE:
|
||||
psetting =config_setting_add(asetting,cfgoptions[i].optname,CONFIG_TYPE_FLOAT);
|
||||
if (psetting!= NULL)
|
||||
status=config_setting_set_float(psetting, (double)*(cfgoptions[i].dblptr) );
|
||||
break;
|
||||
|
||||
case TYPE_IPV4ADDR:
|
||||
psetting =config_setting_add(asetting,cfgoptions[i].optname,CONFIG_TYPE_STRING);
|
||||
if (psetting!= NULL) {
|
||||
char ipstr[INET_ADDRSTRLEN];
|
||||
if (inet_ntop(AF_INET, cfgoptions[i].uptr, ipstr, INET_ADDRSTRLEN) == NULL) {
|
||||
notused++;
|
||||
sprintf(ipstr,"undef");
|
||||
} else {
|
||||
status=config_setting_set_string(psetting, ipstr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_LIST:
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,"[LIBCONFIG] %s.%s type %i not supported\n",secprefix,cfgoptions[i].optname ,cfgoptions[i].type);
|
||||
status=CONFIG_FALSE;
|
||||
break;
|
||||
} /* switch on param type */
|
||||
if (status != CONFIG_TRUE) {
|
||||
errors++;
|
||||
fprintf(stderr,"[LIBCONFIG] Error creating setting %i: %s.%s type %i\n",i,secprefix,cfgoptions[i].optname ,cfgoptions[i].type);
|
||||
}
|
||||
}
|
||||
printf_params("[LIBCONFIG], in group \"%s\" %i settings \n",secprefix,numoptions);
|
||||
if (notused > 0)
|
||||
printf_params("[LIBCONFIG], ..... %i settings with NULL value pointer\n",notused);
|
||||
if (errors >0)
|
||||
fprintf(stderr,"[LIBCONFIG] .....%i settings creation errors \n",errors);
|
||||
if (emptyla >0)
|
||||
fprintf(stderr,"[LIBCONFIG] .....%i empty lists or arrays settings \n",emptyla);
|
||||
|
||||
if ( cfgptr->status ) {
|
||||
cfgptr->status->num_err_nullvalue += notused;
|
||||
cfgptr->status->num_err_write += errors;
|
||||
cfgptr->status->num_write += numoptions;
|
||||
cfgptr->status->emptyla += emptyla;
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
int config_libconfig_set(paramdef_t *cfgoptions, int numoptions, char *prefix ) {
|
||||
char *tokctx1=NULL;
|
||||
int listidx=-1;
|
||||
char *prefixbck=NULL;
|
||||
char *prefix_elem1=NULL;
|
||||
config_setting_t * asetting = config_root_setting (&(libconfig_privdata.runtcfg));
|
||||
if (prefix != NULL) {
|
||||
prefixbck=strdup(prefix);
|
||||
prefix_elem1 = strtok_r(prefixbck, ".", &tokctx1);
|
||||
}
|
||||
printf_params("[LIBCONFIG], processing prefix %s\n",(prefix==NULL)?"NULL":prefix);
|
||||
|
||||
/* parse the prefix , possibly creating groups, lists and list elements */
|
||||
while (prefix_elem1 != NULL) {
|
||||
int n1=strlen(prefix_elem1);
|
||||
char *prefix_elem2 = prefix_elem1+n1+1 ;
|
||||
printf_params("[LIBCONFIG], processing elem1 %s elem2 %s\n",prefix_elem1,prefix_elem2);
|
||||
/* prefix (the path to the parameter name) may contain groups and elements from a list, which are specified with [] */
|
||||
if (prefix_elem2[0] != '[') { // not a list
|
||||
|
||||
config_setting_t *tmpset = config_setting_lookup(asetting,prefix_elem1);
|
||||
if (tmpset == NULL)
|
||||
asetting = config_setting_add (asetting, prefix_elem1, CONFIG_TYPE_GROUP);
|
||||
else
|
||||
asetting = tmpset;
|
||||
printf_params("[LIBCONFIG], creating or looking for group %s: %s\n",prefix_elem1,(asetting==NULL)?"NOK":"OK");
|
||||
} else { // a list
|
||||
listidx=(int)strtol(prefix_elem2+1,NULL,10);
|
||||
if (errno == EINVAL || errno == ERANGE) {
|
||||
printf_params("[LIBCONFIG], Error %s looking for list index in %s \n",strerror(errno), prefix_elem2);
|
||||
break;
|
||||
}
|
||||
config_setting_t *tmpset = config_setting_lookup(asetting,prefix_elem1);
|
||||
if (tmpset == NULL)
|
||||
asetting = config_setting_add (asetting, prefix_elem1, CONFIG_TYPE_LIST);
|
||||
else
|
||||
asetting = tmpset;
|
||||
printf_params("[LIBCONFIG], creating or looking for list %s: %s\n",prefix_elem1,(asetting==NULL)?"NOK":"OK");
|
||||
if (asetting != NULL) {
|
||||
tmpset = config_setting_get_elem (asetting, listidx);
|
||||
if (tmpset == NULL)
|
||||
asetting = config_setting_add (asetting, NULL, CONFIG_TYPE_GROUP);
|
||||
else
|
||||
asetting = tmpset;
|
||||
printf_params("[LIBCONFIG], creating or looking for list element %i: %s\n",listidx,(asetting==NULL)?"NOK":"OK");
|
||||
}
|
||||
prefix_elem1 = strtok_r(NULL, ".", &tokctx1); //skip the [x] elements we already took care of it
|
||||
if (prefix_elem1 == NULL) {
|
||||
fprintf(stderr, "[LICONFIG] End of parsing %s \n",prefix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (asetting == NULL) {
|
||||
fprintf(stderr,"[LIBCONFIG] Error creating setting %s %s %i\n",prefix_elem1,prefix_elem2,listidx);
|
||||
}
|
||||
prefix_elem1 = strtok_r(NULL, ".", &tokctx1);
|
||||
}
|
||||
free(prefixbck);
|
||||
if (asetting != NULL) {
|
||||
config_libconfig_setparams(cfgoptions, numoptions,asetting,prefix);
|
||||
printf_params("[LIBCONFIG] %i settings added in group %s\n",numoptions,(prefix==NULL)?"":prefix);
|
||||
return 0;
|
||||
} else {
|
||||
fprintf(stderr,"[LIBCONFIG] Error parsing %s params, skipped...\n",(prefix==NULL)?"":prefix);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) {
|
||||
@@ -376,6 +593,12 @@ int config_libconfig_init(char *cfgP[], int numP) {
|
||||
free(tmppath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* possibly init a libconfig struct for saving really used params */
|
||||
if( cfgptr->rtflags & CONFIG_SAVERUNCFG ) {
|
||||
config_init ( &(libconfig_privdata.runtcfg));
|
||||
// config_set_options (&(libconfig_privdata.runtcfg), CONFIG_OPTION_ALLOW_OVERRIDES, CONFIG_TRUE);
|
||||
}
|
||||
free(tmppath);
|
||||
return 0;
|
||||
}
|
||||
@@ -383,7 +606,25 @@ int config_libconfig_init(char *cfgP[], int numP) {
|
||||
|
||||
void config_libconfig_end(void ) {
|
||||
config_destroy(&(libconfig_privdata.cfg));
|
||||
|
||||
if( cfgptr->rtflags & CONFIG_SAVERUNCFG ) {
|
||||
char *fname=strdup(libconfig_privdata.configfile);
|
||||
int newcfgflen = strlen( libconfig_privdata.configfile) + strlen(cfgptr->tmpdir) + 20;
|
||||
char *newcfgf = malloc( newcfgflen);
|
||||
time_t t = time(NULL);
|
||||
struct tm tm = *localtime(&t);
|
||||
snprintf (newcfgf,newcfgflen, "%s/%s-run%d_%02d_%02d_%02d%02d",cfgptr->tmpdir,basename(fname),
|
||||
tm.tm_year + 1900,tm.tm_mon + 1,tm.tm_mday, tm.tm_hour, tm.tm_min);
|
||||
if ( config_write_file (&(libconfig_privdata.runtcfg) , newcfgf) != CONFIG_TRUE) {
|
||||
fprintf(stderr,"[LIBCONFIG] %s %d file %s - line %d: %s\n",__FILE__, __LINE__,
|
||||
newcfgf, config_error_line(&(libconfig_privdata.runtcfg)),
|
||||
config_error_text(&(libconfig_privdata.runtcfg)));
|
||||
} else {
|
||||
printf("[LIBCONFIG] file %s created successfully\n", newcfgf);
|
||||
}
|
||||
config_destroy(&(libconfig_privdata.runtcfg));
|
||||
free(fname);
|
||||
free(newcfgf);
|
||||
}
|
||||
if ( libconfig_privdata.configfile != NULL ) {
|
||||
free(libconfig_privdata.configfile);
|
||||
libconfig_privdata.configfile=NULL;
|
||||
|
||||
@@ -40,12 +40,11 @@ extern "C"
|
||||
|
||||
#include "common/config/config_paramdesc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct libconfig_privatedata {
|
||||
char *configfile;
|
||||
config_t cfg;
|
||||
config_t runtcfg;
|
||||
} libconfig_privatedata_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "common/config/config_userapi.h"
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
extern int disable_shm_log ;
|
||||
|
||||
// main log variables
|
||||
|
||||
@@ -62,21 +61,17 @@ volatile int log_mem_write_side=0;
|
||||
char __log_mem_filename[1024]={0};
|
||||
char * log_mem_filename = &__log_mem_filename[0];
|
||||
char logmem_filename[1024] = {0};
|
||||
FILE* dbg_fp;
|
||||
|
||||
mapping log_level_names[] = {
|
||||
{"error", OAILOG_ERR},
|
||||
{"warn", OAILOG_WARNING},
|
||||
{"analysis", OAILOG_ANALYSIS},
|
||||
{"info", OAILOG_INFO},
|
||||
{"extra", OAILOG_EXTRA},
|
||||
{"debug", OAILOG_DEBUG},
|
||||
{"trace", OAILOG_TRACE},
|
||||
{NULL, -1}
|
||||
};
|
||||
|
||||
char dbgKind[][8]={"[E]","[W]","[A]","[I]","[X]","[D]","[T]"};
|
||||
|
||||
mapping log_options[] = {
|
||||
{"nocolor", FLAG_NOCOLOR },
|
||||
{"level", FLAG_LEVEL },
|
||||
@@ -91,8 +86,8 @@ mapping log_options[] = {
|
||||
|
||||
mapping log_maskmap[] = LOG_MASKMAP_INIT;
|
||||
|
||||
char *log_level_highlight_start[] = {LOG_RED, LOG_ORANGE, LOG_GREEN, "","", LOG_BLUE, LOG_CYBL}; /*!< \brief Optional start-format strings for highlighting */
|
||||
char *log_level_highlight_end[] = {LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET}; /*!< \brief Optional end-format strings for highlighting */
|
||||
char *log_level_highlight_start[] = {LOG_RED, LOG_ORANGE, LOG_GREEN, "", LOG_BLUE, LOG_CYBL}; /*!< \brief Optional start-format strings for highlighting */
|
||||
char *log_level_highlight_end[] = {LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET}; /*!< \brief Optional end-format strings for highlighting */
|
||||
static void log_output_memory(log_component_t *c, const char *file, const char *func, int line, int comp, int level, const char* format,va_list args);
|
||||
|
||||
|
||||
@@ -307,8 +302,8 @@ void log_getconfig(log_t *g_log)
|
||||
|
||||
for (int i=MIN_LOG_COMPONENTS; i < MAX_LOG_PREDEF_COMPONENTS; i++) {
|
||||
if(g_log->log_component[i].name == NULL) {
|
||||
g_log->log_component[i].name = malloc(16);
|
||||
sprintf((char *)g_log->log_component[i].name,"comp%i?",i);
|
||||
g_log->log_component[i].name = calloc(1,16);
|
||||
snprintf((char *)g_log->log_component[i].name,15,"undefcomp%i",i);
|
||||
logparams_logfile[i].paramflags = PARAMFLAG_DONOTREAD;
|
||||
logparams_level[i].paramflags = PARAMFLAG_DONOTREAD;
|
||||
}
|
||||
@@ -343,7 +338,7 @@ void log_getconfig(log_t *g_log)
|
||||
g_log->log_component[i].level = map_str_to_int(log_level_names, *(logparams_level[i].strptr));
|
||||
set_log(i, g_log->log_component[i].level);
|
||||
|
||||
if ((*(logparams_logfile[i].uptr) == 1) && (disable_shm_log ==0))
|
||||
if (*(logparams_logfile[i].uptr) == 1)
|
||||
set_component_filelog(i);
|
||||
}
|
||||
|
||||
@@ -379,11 +374,9 @@ void log_getconfig(log_t *g_log)
|
||||
if (*(logparams_dump[i].uptr) )
|
||||
g_log->dump_mask = g_log->dump_mask | log_maskmap[i].value;
|
||||
}
|
||||
// g_log->debug_mask = g_log->debug_mask | DEBUG_ASN1 ;
|
||||
|
||||
/* log globally enabled/disabled */
|
||||
set_glog_onlinelog(consolelog);
|
||||
if (disable_shm_log == 0) set_glog_filelog(1);
|
||||
}
|
||||
|
||||
int register_log_component(char *name,
|
||||
@@ -506,8 +499,7 @@ int logInit (void)
|
||||
for (int i=0 ; log_level_names[i].name != NULL ; i++)
|
||||
g_log->level2string[i] = toupper(log_level_names[i].name[0]); // uppercased first letter of level name
|
||||
|
||||
// g_log->filelog_name = "/tmp/openair.log";
|
||||
g_log->filelog_name = "/dev/shm/nrue";
|
||||
g_log->filelog_name = "/tmp/openair.log";
|
||||
log_getconfig(g_log);
|
||||
|
||||
// set all unused component items to 0, they are for non predefined components
|
||||
@@ -516,7 +508,6 @@ int logInit (void)
|
||||
}
|
||||
|
||||
g_log->flag = g_log->flag | FLAG_INITIALIZED;
|
||||
// g_log->flag = g_log->flag | FLAG_INITIALIZED | FLAG_NOCOLOR ;
|
||||
printf("log init done\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -558,8 +549,7 @@ static inline int log_header(log_component_t *c,
|
||||
else
|
||||
l[0] = 0;
|
||||
|
||||
char timeString[48];
|
||||
#if 0
|
||||
char timeString[32];
|
||||
if ( flag & FLAG_TIME ) {
|
||||
struct timespec t;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &t) == -1)
|
||||
@@ -570,15 +560,6 @@ static inline int log_header(log_component_t *c,
|
||||
} else {
|
||||
timeString[0] = 0;
|
||||
}
|
||||
#endif
|
||||
struct timeval oaiTime;
|
||||
struct tm *time_st;
|
||||
/* get time */
|
||||
gettimeofday(&oaiTime, NULL);
|
||||
time_st = localtime(&oaiTime.tv_sec);
|
||||
snprintf(timeString, sizeof(timeString), "%s %d/%02d/%02d %02d:%02d:%02d.%06d ", dbgKind[level],
|
||||
time_st->tm_year+1900, time_st->tm_mon+1, time_st->tm_mday,
|
||||
time_st->tm_hour, time_st->tm_min, time_st->tm_sec, oaiTime.tv_usec);
|
||||
|
||||
char threadIdString[32];
|
||||
if (flag & FLAG_THREAD_ID) {
|
||||
@@ -587,7 +568,6 @@ static inline int log_header(log_component_t *c,
|
||||
threadIdString[0] = 0;
|
||||
}
|
||||
return snprintf(log_buffer, buffsize, "%s%s%s[%s] %c %s%s",
|
||||
// ((flag & FLAG_NOCOLOR) || (level == OAILOG_INFO) || ( level == OAILOG_DEBUG)) ? "" : log_level_highlight_start[level],
|
||||
flag & FLAG_NOCOLOR ? "" : log_level_highlight_start[level],
|
||||
timeString,
|
||||
threadIdString,
|
||||
@@ -669,8 +649,7 @@ void log_dump(int component,
|
||||
if ( flag & FLAG_NOCOLOR )
|
||||
sprintf(wbuf+pos,"\n");
|
||||
else
|
||||
// sprintf(wbuf+pos,"%s\n",log_level_highlight_end[OAILOG_INFO]);
|
||||
sprintf(wbuf+pos,"%s\n",log_level_highlight_end[OAILOG_EXTRA]);
|
||||
sprintf(wbuf+pos,"%s\n",log_level_highlight_end[OAILOG_INFO]);
|
||||
c->print(c->stream,wbuf);
|
||||
free(wbuf);
|
||||
}
|
||||
@@ -719,22 +698,11 @@ void set_glog_filelog(int enable)
|
||||
static FILE *fptr;
|
||||
|
||||
if ( enable ) {
|
||||
// fptr = fopen(g_log->filelog_name,"w");
|
||||
time_t t = time(NULL);
|
||||
struct tm *local = localtime(&t);
|
||||
char buf[128],buf2[128];
|
||||
strftime(buf,sizeof(buf),"_%Y%m%d%H%M%S.log",local);
|
||||
strcpy(buf2,g_log->filelog_name);
|
||||
strcat(buf2,buf);
|
||||
fptr = fopen(buf2,"w");
|
||||
// fptr = fopen("/dev/shm/nrue_proc.log","w");
|
||||
fptr = fopen(g_log->filelog_name,"w");
|
||||
|
||||
for (int c=0; c< MAX_LOG_COMPONENTS; c++ ) {
|
||||
close_component_filelog(c);
|
||||
// g_log->log_component[c].stream = fptr;
|
||||
g_log->log_component[c].stream_ram = fptr;
|
||||
dbg_fp = fptr;
|
||||
g_log->log_component[c].vprint_ram = vfprintf;
|
||||
g_log->log_component[c].stream = fptr;
|
||||
g_log->log_component[c].filelog = 1;
|
||||
}
|
||||
} else {
|
||||
@@ -885,7 +853,6 @@ const char logmem_log_level[NUM_LOG_LEVEL] = {
|
||||
[OAILOG_WARNING] = 'W',
|
||||
[OAILOG_ANALYSIS] = 'A',
|
||||
[OAILOG_INFO] = 'I',
|
||||
[OAILOG_INFO] = 'X',
|
||||
[OAILOG_DEBUG] = 'D',
|
||||
[OAILOG_TRACE] = 'T',
|
||||
};
|
||||
@@ -964,13 +931,7 @@ static void log_output_memory(log_component_t *c, const char *file, const char *
|
||||
}
|
||||
}else{
|
||||
AssertFatal(len >= 0 && len <= MAX_LOG_TOTAL, "Bad len %d\n", len);
|
||||
if ((level <= OAILOG_INFO ) && (level != OAILOG_EXTRA)){
|
||||
if (write(fileno(c->stream), log_buffer, len)) {};
|
||||
}
|
||||
if ((level <= OAILOG_INFO) || (level == OAILOG_DEBUG) || (level == OAILOG_EXTRA)){
|
||||
if (disable_shm_log == 0)
|
||||
if (write(fileno(c->stream_ram), log_buffer, len)) {};
|
||||
}
|
||||
if (write(fileno(c->stream), log_buffer, len)) {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,7 +975,7 @@ int logInit_log_mem (void)
|
||||
|
||||
void close_log_mem(void){
|
||||
int fp;
|
||||
char f_name[1024]="nrue_proc.log";
|
||||
char f_name[1024];
|
||||
|
||||
if(log_mem_flag==1){
|
||||
log_mem_d[0].enable_flag=0;
|
||||
@@ -1024,7 +985,7 @@ void close_log_mem(void){
|
||||
usleep(100);
|
||||
}
|
||||
if(log_mem_multi==1){
|
||||
// snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt);a
|
||||
snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt);
|
||||
fp=open(f_name, O_WRONLY | O_CREAT, 0666);
|
||||
int ret = write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index);
|
||||
if ( ret < 0) {
|
||||
@@ -1068,21 +1029,21 @@ int test_log(void) {
|
||||
LOG_ENTER(MAC); // because the default level is DEBUG
|
||||
LOG_I(EMU, "1 Starting OAI logs version %s Build date: %s on %s\n",
|
||||
BUILD_VERSION, BUILD_DATE, BUILD_HOST);
|
||||
LOG_X(MAC, "1 debug MAC \n");
|
||||
LOG_D(MAC, "1 debug MAC \n");
|
||||
LOG_W(MAC, "1 warning MAC \n");
|
||||
set_log(EMU, OAILOG_INFO);
|
||||
set_log(MAC, OAILOG_WARNING);
|
||||
LOG_I(EMU, "2 Starting OAI logs version %s Build date: %s on %s\n",
|
||||
BUILD_VERSION, BUILD_DATE, BUILD_HOST);
|
||||
LOG_E(MAC, "2 error MAC\n");
|
||||
LOG_X(MAC, "2 debug MAC \n");
|
||||
LOG_D(MAC, "2 debug MAC \n");
|
||||
LOG_W(MAC, "2 warning MAC \n");
|
||||
LOG_I(MAC, "2 info MAC \n");
|
||||
set_log(MAC, OAILOG_NOTICE);
|
||||
LOG_ENTER(MAC);
|
||||
LOG_I(EMU, "3 Starting OAI logs version %s Build date: %s on %s\n",
|
||||
BUILD_VERSION, BUILD_DATE, BUILD_HOST);
|
||||
LOG_X(MAC, "3 debug MAC \n");
|
||||
LOG_D(MAC, "3 debug MAC \n");
|
||||
LOG_W(MAC, "3 warning MAC \n");
|
||||
LOG_I(MAC, "3 info MAC \n");
|
||||
set_log(MAC, LOG_DEBUG);
|
||||
@@ -1090,14 +1051,14 @@ int test_log(void) {
|
||||
LOG_ENTER(MAC);
|
||||
LOG_I(EMU, "4 Starting OAI logs version %s Build date: %s on %s\n",
|
||||
BUILD_VERSION, BUILD_DATE, BUILD_HOST);
|
||||
LOG_X(MAC, "4 debug MAC \n");
|
||||
LOG_D(MAC, "4 debug MAC \n");
|
||||
LOG_W(MAC, "4 warning MAC \n");
|
||||
LOG_I(MAC, "4 info MAC \n");
|
||||
set_log(MAC, LOG_DEBUG);
|
||||
set_log(EMU, LOG_DEBUG);
|
||||
LOG_I(LOG, "5 Starting OAI logs version %s Build date: %s on %s\n",
|
||||
BUILD_VERSION, BUILD_DATE, BUILD_HOST);
|
||||
LOG_X(MAC, "5 debug MAC \n");
|
||||
LOG_D(MAC, "5 debug MAC \n");
|
||||
LOG_W(MAC, "5 warning MAC \n");
|
||||
LOG_I(MAC, "5 info MAC \n");
|
||||
set_log(MAC, LOG_TRACE);
|
||||
@@ -1105,7 +1066,7 @@ int test_log(void) {
|
||||
LOG_ENTER(MAC);
|
||||
LOG_I(LOG, "6 Starting OAI logs version %s Build date: %s on %s\n",
|
||||
BUILD_VERSION, BUILD_DATE, BUILD_HOST);
|
||||
LOG_X(MAC, "6 debug MAC \n");
|
||||
LOG_D(MAC, "6 debug MAC \n");
|
||||
LOG_W(MAC, "6 warning MAC \n");
|
||||
LOG_I(MAC, "6 info MAC \n");
|
||||
LOG_EXIT(MAC);
|
||||
|
||||
@@ -92,11 +92,10 @@ extern "C" {
|
||||
# define OAILOG_WARNING 1 /*!< \brief warning conditions, shouldn't happen but doesn't impact "must have" functionalities */
|
||||
# define OAILOG_ANALYSIS 2 /*!< \brief informational messages most people don't need, shouldn't impact real-time behavior */
|
||||
# define OAILOG_INFO 3 /*!< \brief informational messages most people don't need, shouldn't impact real-time behavior */
|
||||
# define OAILOG_EXTRA 4 /*!< \brief extra debug-level messages, for developers, may impact real-time behavior */
|
||||
# define OAILOG_DEBUG 5 /*!< \brief first level debug-level messages, for developers, may impact real-time behavior */
|
||||
# define OAILOG_TRACE 6 /*!< \brief second level debug-level messages, for developers, likely impact real-time behavior*/
|
||||
# define OAILOG_DEBUG 4 /*!< \brief first level debug-level messages, for developers, may impact real-time behavior */
|
||||
# define OAILOG_TRACE 5 /*!< \brief second level debug-level messages, for developers, likely impact real-time behavior*/
|
||||
|
||||
#define NUM_LOG_LEVEL 7 /*!< \brief the number of message levels users have with LOG (OAILOG_DISABLE is not available to user as a level, so it is not included)*/
|
||||
#define NUM_LOG_LEVEL 6 /*!< \brief the number of message levels users have with LOG (OAILOG_DISABLE is not available to user as a level, so it is not included)*/
|
||||
/* @}*/
|
||||
|
||||
|
||||
@@ -270,9 +269,7 @@ typedef struct {
|
||||
int filelog;
|
||||
char *filelog_name;
|
||||
FILE *stream;
|
||||
FILE *stream_ram;
|
||||
log_vprint_func_t vprint;
|
||||
log_vprint_func_t vprint_ram;
|
||||
log_print_func_t print;
|
||||
/* SR: make the log buffer component relative */
|
||||
char log_buffer[MAX_LOG_TOTAL];
|
||||
@@ -288,7 +285,7 @@ typedef struct {
|
||||
uint64_t dump_mask;
|
||||
} log_t;
|
||||
|
||||
extern FILE* dbg_fp;
|
||||
|
||||
|
||||
#ifdef LOG_MAIN
|
||||
log_t *g_log;
|
||||
@@ -419,7 +416,6 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
|
||||
# define LOG_W(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_WARNING) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ;} else { T(T_LEGACY_ ## c ## _WARNING, T_PRINTF(x)) ;}} while (0)
|
||||
# define LOG_A(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_ANALYSIS) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ANALYSIS, x) ;} else { T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) ;}} while (0)
|
||||
# define LOG_I(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} else { T(T_LEGACY_ ## c ## _INFO, T_PRINTF(x)) ;}} while (0)
|
||||
# define LOG_X(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_EXTRA ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_EXTRA, x) ;} else { T(T_LEGACY_ ## c ## _DEBUG, T_PRINTF(x)) ;}} while (0)
|
||||
# define LOG_D(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} else { T(T_LEGACY_ ## c ## _DEBUG, T_PRINTF(x)) ;}} while (0)
|
||||
# define LOG_T(c, x...) do { if (T_stdout) { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} else { T(T_LEGACY_ ## c ## _TRACE, T_PRINTF(x)) ;}} while (0)
|
||||
# define VLOG(c,l, f, args) do { if (T_stdout) { if( g_log->log_component[c].level >= l ) vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, l, f, args) ;} } while (0)
|
||||
@@ -439,7 +435,6 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
|
||||
# define LOG_W(c, x...) do { if( g_log->log_component[c].level >= OAILOG_WARNING) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ;} while (0)
|
||||
# define LOG_A(c, x...) do { if( g_log->log_component[c].level >= OAILOG_ANALYSIS) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ANALYSIS, x);} while (0)
|
||||
# define LOG_I(c, x...) do { if( g_log->log_component[c].level >= OAILOG_INFO ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ;} while (0)
|
||||
# define LOG_X(c, x...) do { if( g_log->log_component[c].level >= OAILOG_EXTRA ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_EXTRA, x) ;} while (0)
|
||||
# define LOG_D(c, x...) do { if( g_log->log_component[c].level >= OAILOG_DEBUG ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ;} while (0)
|
||||
# define LOG_T(c, x...) do { if( g_log->log_component[c].level >= OAILOG_TRACE ) logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_TRACE, x) ;} while (0)
|
||||
# define VLOG(c,l, f, args) do { if( g_log->log_component[c].level >= l ) vlogRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, l, f, args) ; } while (0)
|
||||
|
||||
@@ -100,7 +100,7 @@ int16_t estimate_ue_tx_power(int norm,uint32_t tbs, uint32_t nb_rb, uint8_t cont
|
||||
delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch_x8)>>3))/100.0);
|
||||
|
||||
bw_factor = (norm!=0) ? 0 : (hundred_times_log10_NPRB[nb_rb-1]/100.0);
|
||||
LOG_X(PHY,"estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n",
|
||||
LOG_D(PHY,"estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n",
|
||||
(int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor);
|
||||
return (int16_t)ceil(delta_mcs + bw_factor);
|
||||
|
||||
|
||||
@@ -311,11 +311,6 @@ int get_nb_periods_per_frame(uint8_t tdd_period) {
|
||||
nb_periods_per_frame = 1; // 10ms/10ms
|
||||
break;
|
||||
|
||||
//TODO L5G
|
||||
case 10:
|
||||
nb_periods_per_frame = 2; // 10ms/5ms
|
||||
break;
|
||||
|
||||
default:
|
||||
AssertFatal(1==0,"Undefined tdd period %d\n", tdd_period);
|
||||
}
|
||||
@@ -503,7 +498,7 @@ int get_nr_table_idx(int nr_bandP, uint8_t scs_index) {
|
||||
}
|
||||
|
||||
AssertFatal(i > 0 && i < sizeofArray(nr_bandtable), "band is not existing: %d\n",nr_bandP);
|
||||
LOG_X(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min);
|
||||
LOG_D(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -90,25 +90,28 @@ int get_phybsize(void) {
|
||||
};
|
||||
int add_telnetcmd(char *modulename,telnetshell_vardef_t *var, telnetshell_cmddef_t *cmd );
|
||||
int setoutput(char *buff, int debug, telnet_printfunc_t prnt);
|
||||
int wsetoutput(char *buff, int debug, telnet_printfunc_t prnt, ... );
|
||||
int setparam(char *buff, int debug, telnet_printfunc_t prnt);
|
||||
int wsetparam(char *buff, int debug, telnet_printfunc_t prnt, ... );
|
||||
int history_cmd(char *buff, int debug, telnet_printfunc_t prnt);
|
||||
|
||||
|
||||
telnetshell_vardef_t telnet_vardef[] = {
|
||||
{"debug",TELNET_VARTYPE_INT32,&telnetparams.telnetdbg},
|
||||
{"prio",TELNET_VARTYPE_INT32,&telnetparams.priority},
|
||||
{"loopc",TELNET_VARTYPE_INT32,&telnetparams.loopcount},
|
||||
{"loopd",TELNET_VARTYPE_INT32,&telnetparams.loopdelay},
|
||||
{"phypb",TELNET_VARTYPE_INT32,&telnetparams.phyprntbuff_size},
|
||||
{"hsize",TELNET_VARTYPE_INT32,&telnetparams.histsize},
|
||||
{"hfile",TELNET_VARTYPE_STRING,&telnetparams.histfile},
|
||||
{"",0,NULL}
|
||||
{"debug",TELNET_VARTYPE_INT32,0,&telnetparams.telnetdbg},
|
||||
{"prio",TELNET_VARTYPE_INT32,0,&telnetparams.priority},
|
||||
{"loopc",TELNET_VARTYPE_INT32,0,&telnetparams.loopcount},
|
||||
{"loopd",TELNET_VARTYPE_INT32,0,&telnetparams.loopdelay},
|
||||
{"phypb",TELNET_VARTYPE_INT32,0,&telnetparams.phyprntbuff_size},
|
||||
{"hsize",TELNET_VARTYPE_INT32,0,&telnetparams.histsize},
|
||||
{"hfile",TELNET_VARTYPE_STRING,TELNET_CHECKVAL_RDONLY,&telnetparams.histfile},
|
||||
{"",0,0,NULL}
|
||||
};
|
||||
|
||||
telnetshell_cmddef_t telnet_cmdarray[] = {
|
||||
{"redirlog","[here,file,off]",setoutput},
|
||||
{"param","[prio]",setparam},
|
||||
{"history","[list,reset]",history_cmd},
|
||||
{"","",NULL},
|
||||
{"redirlog","[here,file,off]",setoutput,{wsetoutput},0,NULL},
|
||||
{"param","[prio]",setparam,{wsetparam},0,NULL},
|
||||
{"history","[list,reset]",history_cmd,{NULL},TELNETSRV_CMDFLAG_TELNETONLY,NULL},
|
||||
{"","",NULL,{NULL},0,NULL},
|
||||
};
|
||||
|
||||
|
||||
@@ -245,6 +248,11 @@ void redirstd(char *newfname,telnet_printfunc_t prnt ) {
|
||||
prnt("ERROR: stderr redir to %s error %s",strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
int wsetoutput(char *buffer, int debug, telnet_printfunc_t prnt, ... ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setoutput(char *buff, int debug, telnet_printfunc_t prnt) {
|
||||
char cmds[TELNET_MAX_MSGLENGTH/TELNET_CMD_MAXSIZE][TELNET_CMD_MAXSIZE];
|
||||
char *logfname;
|
||||
@@ -281,6 +289,10 @@ int setoutput(char *buff, int debug, telnet_printfunc_t prnt) {
|
||||
return CMDSTATUS_FOUND;
|
||||
} /* setoutput */
|
||||
|
||||
int wsetparam(char *buff, int debug, telnet_printfunc_t prnt, ...) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setparam(char *buff, int debug, telnet_printfunc_t prnt) {
|
||||
char cmds[TELNET_MAX_MSGLENGTH/TELNET_CMD_MAXSIZE][TELNET_CMD_MAXSIZE];
|
||||
memset(cmds,0,sizeof(cmds));
|
||||
@@ -344,6 +356,98 @@ int history_cmd(char *buff, int debug, telnet_printfunc_t prnt) {
|
||||
/*
|
||||
generic commands available for all modules loaded by the server
|
||||
*/
|
||||
char *telnet_getvarvalue(telnetshell_vardef_t *var, int varindex) {
|
||||
char *val;
|
||||
switch(var[varindex].vartype) {
|
||||
case TELNET_VARTYPE_INT32:
|
||||
val=malloc(64);
|
||||
snprintf(val,64,"%i",*(int32_t *)(var[varindex].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT64:
|
||||
val=malloc(128);
|
||||
snprintf(val,128,"%lli",(long long)*(int64_t *)(var[varindex].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT16:
|
||||
val=malloc(16);
|
||||
snprintf(val,16,"%hi",*(short *)(var[varindex].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT8:
|
||||
val=malloc(16);
|
||||
snprintf(val,16,"%i",(int)(*(int8_t *)(var[varindex].varvalptr)));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_UINT:
|
||||
val=malloc(64);
|
||||
snprintf(val,64,"%u",*(unsigned int *)(var[varindex].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_DOUBLE:
|
||||
val=malloc(32);
|
||||
snprintf(val,32,"%g\n",*(double *)(var[varindex].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_STRING:
|
||||
val = strdup(*(char **)(var[varindex].varvalptr));
|
||||
break;
|
||||
|
||||
default:
|
||||
val=malloc(64);
|
||||
snprintf(val,64,"ERR:var %i unknown type",varindex);
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
int telnet_setvarvalue(telnetshell_vardef_t *var,char *strval, telnet_printfunc_t prnt ) {
|
||||
int st=0;
|
||||
switch(var->vartype) {
|
||||
case TELNET_VARTYPE_INT32:
|
||||
*(int *)(var->varvalptr) = (int)strtol(strval,NULL,0);
|
||||
if (prnt != NULL)
|
||||
prnt("%i\n",*(int *)(var->varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT16:
|
||||
*(short *)(var->varvalptr) = (short)strtol(strval,NULL,0);
|
||||
if (prnt != NULL)
|
||||
prnt("%hi\n",*(short *)(var->varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT8:
|
||||
*(char *)(var->varvalptr) = (char)strtol(strval,NULL,0);
|
||||
if (prnt != NULL)
|
||||
prnt("%i\n",*(int *)(var->varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_UINT:
|
||||
*(unsigned int *)(var->varvalptr) = (unsigned int)strtol(strval,NULL,0);
|
||||
if (prnt != NULL)
|
||||
prnt("%u\n",*(unsigned int *)(var->varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_DOUBLE:
|
||||
*(double *)(var->varvalptr) = strtod(strval,NULL);
|
||||
if (prnt != NULL)
|
||||
prnt("%g\n",*(double *)(var->varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_STRING:
|
||||
sprintf(*(char **)(var->varvalptr),"%s", strval);
|
||||
if (prnt != NULL)
|
||||
prnt("\"%s\"\n",*(char **)(var->varvalptr));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (prnt != NULL)
|
||||
prnt("unknown type\n");
|
||||
st=-1;
|
||||
break;
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
int setgetvar(int moduleindex,char getorset,char *params) {
|
||||
int n,i;
|
||||
@@ -357,81 +461,15 @@ int setgetvar(int moduleindex,char getorset,char *params) {
|
||||
if (n > 0 && (getorset == 'g' || getorset == 'G')) {
|
||||
client_printf("%s, %s = ", telnetparams.CmdParsers[moduleindex].module,
|
||||
telnetparams.CmdParsers[moduleindex].var[i].varname );
|
||||
|
||||
switch(telnetparams.CmdParsers[moduleindex].var[i].vartype) {
|
||||
case TELNET_VARTYPE_INT32:
|
||||
client_printf("%i\n",*(int32_t *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT64:
|
||||
client_printf("%lli\n",*(int64_t *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT16:
|
||||
client_printf("%hi\n",*(short *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT8:
|
||||
client_printf("%i\n",(int)(*(int8_t *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr)));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_UINT:
|
||||
client_printf("%u\n",*(unsigned int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_DOUBLE:
|
||||
client_printf("%g\n",*(double *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_STRING:
|
||||
client_printf("\"%s\"\n",*(char **)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
default:
|
||||
client_printf("unknown type\n");
|
||||
break;
|
||||
}
|
||||
char *strval=telnet_getvarvalue(telnetparams.CmdParsers[moduleindex].var, i);
|
||||
client_printf("%s\n",strval);
|
||||
free(strval);
|
||||
}
|
||||
|
||||
if (n > 1 && (getorset == 's' || getorset == 'S')) {
|
||||
client_printf("%s, %s set to \n", telnetparams.CmdParsers[moduleindex].module,
|
||||
telnetparams.CmdParsers[moduleindex].var[i].varname);
|
||||
telnet_setvarvalue(&(telnetparams.CmdParsers[moduleindex].var[i]),varval, client_printf);
|
||||
|
||||
switch(telnetparams.CmdParsers[moduleindex].var[i].vartype) {
|
||||
case TELNET_VARTYPE_INT32:
|
||||
*(int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = (int)strtol(varval,NULL,0);
|
||||
client_printf("%i\n",*(int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT16:
|
||||
*(short *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = (short)strtol(varval,NULL,0);
|
||||
client_printf("%hi\n",*(short *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_INT8:
|
||||
*(char *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = (char)strtol(varval,NULL,0);
|
||||
client_printf("%i\n",*(int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_UINT:
|
||||
*(unsigned int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = (unsigned int)strtol(varval,NULL,0);
|
||||
client_printf("%u\n",*(unsigned int *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_DOUBLE:
|
||||
*(double *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr) = strtod(varval,NULL);
|
||||
client_printf("%g\n",*(double *)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
case TELNET_VARTYPE_STRING:
|
||||
sprintf(*(char **)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr),"%s", varval);
|
||||
client_printf("\"%s\"\n",*(char **)(telnetparams.CmdParsers[moduleindex].var[i].varvalptr));
|
||||
break;
|
||||
|
||||
default:
|
||||
client_printf("unknown type\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -474,6 +512,8 @@ int process_command(char *buf) {
|
||||
}
|
||||
|
||||
for(j=0; telnetparams.CmdParsers[i].cmd[j].cmdfunc != NULL ; j++) {
|
||||
if ( telnetparams.CmdParsers[i].cmd[j].cmdflags & TELNETSRV_CMDFLAG_WEBSRVONLY )
|
||||
continue;
|
||||
client_printf(" %s %s %s\n",
|
||||
telnetparams.CmdParsers[i].module,telnetparams.CmdParsers[i].cmd[j].cmdname,
|
||||
telnetparams.CmdParsers[i].cmd[j].helpstr);
|
||||
@@ -489,7 +529,7 @@ int process_command(char *buf) {
|
||||
j = sscanf(buf,"%19s %19s %m[^\t\n]",modulename,cmd,&cmdb);
|
||||
|
||||
if (telnetparams.telnetdbg > 0)
|
||||
printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb);
|
||||
printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,(cmdb==NULL)?"":cmdb);
|
||||
|
||||
for (i=0; j>=2 && telnetparams.CmdParsers[i].var != NULL && telnetparams.CmdParsers[i].cmd != NULL; i++) {
|
||||
if ( (strncasecmp(telnetparams.CmdParsers[i].module,modulename,strlen(telnetparams.CmdParsers[i].module)) == 0)) {
|
||||
@@ -504,13 +544,16 @@ int process_command(char *buf) {
|
||||
} else {
|
||||
for (k=0 ; telnetparams.CmdParsers[i].cmd[k].cmdfunc != NULL ; k++) {
|
||||
if (strncasecmp(cmd, telnetparams.CmdParsers[i].cmd[k].cmdname,sizeof(telnetparams.CmdParsers[i].cmd[k].cmdname)) == 0) {
|
||||
if (telnetparams.CmdParsers[i].cmd[k].cmdflags & TELNETSRV_CMDFLAG_WEBSRVONLY)
|
||||
continue;
|
||||
if (telnetparams.CmdParsers[i].cmd[k].qptr != NULL) {
|
||||
notifiedFIFO_elt_t *msg =newNotifiedFIFO_elt(sizeof(telnetsrv_qmsg_t),0,NULL,NULL);
|
||||
telnetsrv_qmsg_t *cmddata=NotifiedFifoData(msg);
|
||||
cmddata->cmdfunc=(qcmdfunc_t)telnetparams.CmdParsers[i].cmd[k].cmdfunc;
|
||||
cmddata->prnt=client_printf;
|
||||
cmddata->debug=telnetparams.telnetdbg;
|
||||
cmddata->cmdbuff=strdup(cmdb);
|
||||
if (cmdb != NULL)
|
||||
cmddata->cmdbuff=strdup(cmdb);
|
||||
pushNotifiedFIFO(telnetparams.CmdParsers[i].cmd[k].qptr, msg);
|
||||
} else {
|
||||
telnetparams.CmdParsers[i].cmd[k].cmdfunc(cmdb, telnetparams.telnetdbg, client_printf);
|
||||
@@ -901,3 +944,7 @@ int telnetsrv_getfarray(loader_shlibfunc_t **farray) {
|
||||
(*farray)[1].fptr=(int (*)(void) )poll_telnetcmdq;
|
||||
return ( 2);
|
||||
}
|
||||
/* for webserver interface, needs access to some telnet server paramaters */
|
||||
telnetsrv_params_t *get_telnetsrv_params(void) {
|
||||
return &telnetparams;
|
||||
}
|
||||
|
||||
@@ -48,19 +48,52 @@
|
||||
#define CMDSTATUS_VARNOTFOUND 3
|
||||
#define CMDSTATUS_NOTFOUND 4
|
||||
|
||||
/* definitions to store 2 dim table, used to store command results before */
|
||||
/* displaying them either on console or web page */
|
||||
#define TELNET_MAXLINE_NUM 100
|
||||
#define TELNET_MAXCOL_NUM 5
|
||||
|
||||
typedef struct col {
|
||||
char coltitle[TELNET_CMD_MAXSIZE];
|
||||
unsigned int coltype;
|
||||
} acol_t;
|
||||
|
||||
typedef struct line {
|
||||
char *val[TELNET_MAXCOL_NUM];
|
||||
} aline_t;
|
||||
|
||||
typedef struct webdatadef {
|
||||
char tblname[TELNET_HELPSTR_SIZE];
|
||||
int numlines;
|
||||
int numcols;
|
||||
acol_t columns[TELNET_MAXCOL_NUM];
|
||||
aline_t lines[TELNET_MAXLINE_NUM];
|
||||
} webdatadef_t;
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* structure to be used when adding a module to the telnet server */
|
||||
/* This is the second parameter of the add_telnetcmd function, which can be used */
|
||||
/* to add a set of new command to the telnet server shell */
|
||||
typedef void(*telnet_printfunc_t)(const char* format, ...);
|
||||
typedef int(*cmdfunc_t)(char*, int, telnet_printfunc_t prnt);
|
||||
typedef int(*webfunc_t)(char *cmdbuff, int debug, telnet_printfunc_t prnt, ... );
|
||||
typedef int(*webfunc_getdata_t)(char *cmdbuff, int debug, void *data);
|
||||
typedef int(*qcmdfunc_t)(char*, int, telnet_printfunc_t prnt,void *arg);
|
||||
|
||||
#define TELNETSRV_CMDFLAG_PUSHINTPOOLQ (1<<0) // ask the telnet server to push the command in a thread pool queue
|
||||
#define TELNETSRV_CMDFLAG_PUSHINTPOOLQ (1<<0) // ask the telnet server to push the command in a thread pool queue
|
||||
#define TELNETSRV_CMDFLAG_GETWEBDATA (1<<1) // When called from web server, use the getdata variant of the function
|
||||
#define TELNETSRV_CMDFLAG_TELNETONLY (1<<2) // Only for telnet client connections
|
||||
#define TELNETSRV_CMDFLAG_WEBSRVONLY (1<<3) // Only for web server connections
|
||||
#define TELNETSRV_CMDFLAG_CONFEXEC (1<<4) // Ask for confirm before exec
|
||||
#define TELNETSRV_CMDFLAG_GETWEBTBLDATA (1<<8) // When called from web server, use the get table data variant of the function
|
||||
#define TELNETSRV_CMDFLAG_PRINTWEBTBLDATA (1<<9) // Print as a single column table
|
||||
typedef struct cmddef {
|
||||
char cmdname[TELNET_CMD_MAXSIZE];
|
||||
char helpstr[TELNET_HELPSTR_SIZE];
|
||||
cmdfunc_t cmdfunc;
|
||||
cmdfunc_t cmdfunc;
|
||||
union {
|
||||
webfunc_t webfunc;
|
||||
webfunc_getdata_t webfunc_getdata;
|
||||
};
|
||||
unsigned int cmdflags;
|
||||
void *qptr;
|
||||
} telnetshell_cmddef_t;
|
||||
@@ -78,6 +111,8 @@ typedef struct telnetsrv_qmsg {
|
||||
/*structure to be used when adding a module to the telnet server */
|
||||
/* This is the first parameter of the add_telnetcmd function, which can be used */
|
||||
/* to add a set of new variables which can be got/set from the telnet server shell */
|
||||
/* var type: bits 0-3, type value (1 to 15)
|
||||
* type modifier, bits 4-31 */
|
||||
#define TELNET_VARTYPE_INT32 1
|
||||
#define TELNET_VARTYPE_INT16 2
|
||||
#define TELNET_VARTYPE_INT64 3
|
||||
@@ -85,10 +120,15 @@ typedef struct telnetsrv_qmsg {
|
||||
#define TELNET_VARTYPE_DOUBLE 5
|
||||
#define TELNET_VARTYPE_INT8 6
|
||||
#define TELNET_VARTYPE_UINT 7
|
||||
|
||||
#define TELNET_CHECKVAL_RDONLY 16
|
||||
#define TELNET_CHECKVAL_BOOL 32
|
||||
typedef struct variabledef {
|
||||
char varname[TELNET_CMD_MAXSIZE];
|
||||
char vartype;
|
||||
char checkval;
|
||||
void *varvalptr;
|
||||
|
||||
} telnetshell_vardef_t;
|
||||
|
||||
|
||||
@@ -155,4 +195,9 @@ void set_sched(pthread_t tid, int pid,int priority);
|
||||
void set_affinity(pthread_t tid, int pid, int coreid);
|
||||
extern int get_phybsize(void);
|
||||
#endif
|
||||
#ifdef WEBSERVERCODE
|
||||
extern telnetsrv_params_t *get_telnetsrv_params(void);
|
||||
extern char *telnet_getvarvalue(telnetshell_vardef_t *var, int varindex);
|
||||
extern int telnet_setvarvalue(telnetshell_vardef_t *var,char *strval, telnet_printfunc_t prnt ) ;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -30,6 +30,6 @@ endforeach()
|
||||
|
||||
install(TARGETS telnetsrv DESTINATION bin)
|
||||
|
||||
if (EXISTS "${OPENAIR_BUILD_DIR}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_BUILD_DIR}/ran_build/build")
|
||||
install(TARGETS telnetsrv DESTINATION ${OPENAIR_BUILD_DIR}/ran_build/build)
|
||||
endif (EXISTS "${OPENAIR_BUILD_DIR}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_BUILD_DIR}/ran_build/build")
|
||||
if (EXISTS "${OPENAIR_CMAKE}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_CMAKE}/ran_build/build")
|
||||
install(TARGETS telnetsrv DESTINATION ${OPENAIR_CMAKE}/ran_build/build)
|
||||
endif (EXISTS "${OPENAIR_CMAKE}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_CMAKE}/ran_build/build")
|
||||
|
||||
@@ -110,9 +110,8 @@ int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) {
|
||||
|
||||
|
||||
telnetshell_cmddef_t phy_cmdarray[] = {
|
||||
{"disp","[phycnt,uedump,uestat UE<x>]", dump_phyvars},
|
||||
|
||||
{"","",NULL},
|
||||
{"disp","[phycnt,uedump,uestat UE<x>]", dump_phyvars,{NULL},0,NULL},
|
||||
{"","",NULL,{NULL},0,NULL},
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -42,24 +42,29 @@
|
||||
|
||||
int loader_show_cmd(char *buff, int debug, telnet_printfunc_t prnt);
|
||||
telnetshell_cmddef_t loader_cmdarray[] = {
|
||||
{"show","[params,modules]",loader_show_cmd},
|
||||
{"","",NULL},
|
||||
{"show","[params,modules]",loader_show_cmd,{(webfunc_t)loader_show_cmd},0,NULL},
|
||||
{"","",NULL,{NULL},0,NULL},
|
||||
};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
int loader_show_cmd(char *buff, int debug, telnet_printfunc_t prnt)
|
||||
{
|
||||
if (buff == NULL) {
|
||||
prnt("ERROR wrong loader SHOW command...\n");
|
||||
return 0;
|
||||
}
|
||||
if (debug > 0)
|
||||
prnt( "loader_show_cmd received %s\n",buff);
|
||||
|
||||
|
||||
if (strcasestr(buff,"params") != NULL) {
|
||||
prnt( "loader parameters:\n");
|
||||
prnt( " Main executable build version: \"%s\"\n", loader_data.mainexec_buildversion);
|
||||
prnt( " Default shared lib path: \"%s\"\n", loader_data.shlibpath);
|
||||
prnt( " Max number of shared lib : %i\n", loader_data.maxshlibs);
|
||||
}
|
||||
else if (strcasestr(buff,"modules") != NULL) {
|
||||
else if (strcasestr(buff,"modules") != NULL || buff[0]==0 || strcasestr(buff,"show") != NULL) {
|
||||
prnt( "%i shared lib have been dynamicaly loaded by the oai loader\n", loader_data.numshlibs);
|
||||
for (int i=0 ; i<loader_data.numshlibs ; i++) {
|
||||
prnt( " Module %i: %s\n", i,loader_data.shlibs[i].name);
|
||||
|
||||
@@ -39,11 +39,11 @@
|
||||
|
||||
|
||||
telnetshell_vardef_t loader_globalvardef[] = {
|
||||
{"mainversion",TELNET_VARTYPE_STRING,&(loader_data.mainexec_buildversion)},
|
||||
{"defpath",TELNET_VARTYPE_STRING,&(loader_data.shlibpath)},
|
||||
{"maxshlibs",TELNET_VARTYPE_INT32,&(loader_data.maxshlibs)},
|
||||
{"numshlibs",TELNET_VARTYPE_INT32,&(loader_data.numshlibs)},
|
||||
{"",0,NULL}
|
||||
{"mainversion",TELNET_VARTYPE_STRING,TELNET_CHECKVAL_RDONLY, &(loader_data.mainexec_buildversion)},
|
||||
{"defpath",TELNET_VARTYPE_STRING,TELNET_CHECKVAL_RDONLY,&(loader_data.shlibpath)},
|
||||
{"maxshlibs",TELNET_VARTYPE_INT32,TELNET_CHECKVAL_RDONLY,&(loader_data.maxshlibs)},
|
||||
{"numshlibs",TELNET_VARTYPE_INT32,TELNET_CHECKVAL_RDONLY,&(loader_data.numshlibs)},
|
||||
{"",0,0,NULL}
|
||||
};
|
||||
telnetshell_vardef_t *loader_modulesvardef;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ telnetshell_cmddef_t measur_cmdarray[] = {
|
||||
};
|
||||
|
||||
telnetshell_vardef_t measur_vardef[] = {
|
||||
{"",0,NULL}
|
||||
{"",0,0,NULL}
|
||||
};
|
||||
/* function to be implemented in any telnetsrv_xxx_measurements.c sources
|
||||
to allow common measurment code to access measurments data */
|
||||
|
||||
@@ -53,7 +53,7 @@ telnetshell_vardef_t phy_vardef[] = {
|
||||
//{"txshift",TELNET_VARTYPE_INT32,NULL},
|
||||
//{"rachemin",TELNET_VARTYPE_INT32,NULL},
|
||||
//{"rachdmax",TELNET_VARTYPE_INT32,NULL},
|
||||
{"",0,NULL}
|
||||
{"",0,0,NULL}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
@@ -139,7 +139,9 @@ char toksep[2];
|
||||
prnt("%s\n",prntline);
|
||||
} /*decode_procstat */
|
||||
|
||||
void read_statfile(char *fname,int debug, telnet_printfunc_t prnt)
|
||||
|
||||
|
||||
void read_statfile(char *fname,int debug, telnet_printfunc_t prnt, void *data)
|
||||
{
|
||||
FILE *procfile;
|
||||
char arecord[1024];
|
||||
@@ -169,9 +171,9 @@ struct dirent *entry;
|
||||
|
||||
|
||||
|
||||
prnt(" id name state USRmod KRNmod prio nice vsize proc pol \n\n");
|
||||
prnt("\n id name state USRmod KRNmod prio nice vsize proc pol \n\n");
|
||||
snprintf(aname, sizeof(aname), "/proc/%d/stat", getpid());
|
||||
read_statfile(aname,debug,prnt);
|
||||
read_statfile(aname,debug,prnt,NULL);
|
||||
prnt("\n");
|
||||
snprintf(aname, sizeof(aname), "/proc/%d/task", getpid());
|
||||
proc_dir = opendir(aname);
|
||||
@@ -183,18 +185,86 @@ struct dirent *entry;
|
||||
|
||||
while ((entry = readdir(proc_dir)) != NULL)
|
||||
{
|
||||
if(entry->d_name[0] == '.')
|
||||
continue;
|
||||
snprintf(aname, sizeof(aname), "/proc/%d/task/%.*s/stat", getpid(),(int)(sizeof(aname)-24),entry->d_name);
|
||||
read_statfile(aname,debug,prnt);
|
||||
if(entry->d_name[0] != '.')
|
||||
{
|
||||
snprintf(aname, sizeof(aname), "/proc/%d/task/%.*s/stat", getpid(),(int)(sizeof(aname)-24),entry->d_name);
|
||||
read_statfile(aname,debug,prnt,NULL);
|
||||
}
|
||||
} /* while entry != NULL */
|
||||
closedir(proc_dir);
|
||||
} /* print_threads */
|
||||
|
||||
int proccmd_websrv_getdata(char *cmdbuff, int debug, void *data) {
|
||||
|
||||
if (strcasestr(cmdbuff,"loglvl") != NULL) {
|
||||
webdatadef_t *logsdata = ( webdatadef_t *) data;
|
||||
logsdata->numcols=4;
|
||||
logsdata->numlines=0;
|
||||
snprintf(logsdata->columns[0].coltitle,TELNET_CMD_MAXSIZE,"component");
|
||||
logsdata->columns[0].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY;
|
||||
snprintf(logsdata->columns[1].coltitle,TELNET_CMD_MAXSIZE,"level");
|
||||
logsdata->columns[1].coltype = TELNET_VARTYPE_STRING;
|
||||
snprintf(logsdata->columns[2].coltitle,TELNET_CMD_MAXSIZE,"enabled");
|
||||
logsdata->columns[2].coltype = TELNET_CHECKVAL_BOOL;
|
||||
snprintf(logsdata->columns[3].coltitle,TELNET_CMD_MAXSIZE,"output");
|
||||
logsdata->columns[3].coltype = TELNET_VARTYPE_STRING;
|
||||
|
||||
|
||||
for (int i=MIN_LOG_COMPONENTS; i < MAX_LOG_COMPONENTS; i++) {
|
||||
if (g_log->log_component[i].name != NULL) {
|
||||
logsdata->numlines++;
|
||||
logsdata->lines[i].val[0]= (char *)(g_log->log_component[i].name);
|
||||
|
||||
logsdata->lines[i].val[1]=map_int_to_str(log_level_names,(g_log->log_component[i].level>=0)?g_log->log_component[i].level:g_log->log_component[i].savedlevel);
|
||||
logsdata->lines[i].val[2]=(g_log->log_component[i].level>=0)?"true":"false";
|
||||
logsdata->lines[i].val[3]=(g_log->log_component[i].filelog>0)?g_log->log_component[i].filelog_name:"stdout";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strcasestr(cmdbuff,"dbgopt") != NULL) {
|
||||
webdatadef_t *logsdata = ( webdatadef_t *) data;
|
||||
logsdata->numcols=3;
|
||||
logsdata->numlines=0;
|
||||
snprintf(logsdata->columns[0].coltitle,TELNET_CMD_MAXSIZE,"module");
|
||||
logsdata->columns[0].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY;
|
||||
snprintf(logsdata->columns[1].coltitle,TELNET_CMD_MAXSIZE,"debug");
|
||||
logsdata->columns[1].coltype = TELNET_CHECKVAL_BOOL;
|
||||
snprintf(logsdata->columns[2].coltitle,TELNET_CMD_MAXSIZE,"dump");
|
||||
logsdata->columns[2].coltype = TELNET_CHECKVAL_BOOL;
|
||||
|
||||
for (int i=0; log_maskmap[i].name != NULL ; i++) {
|
||||
logsdata->numlines++;
|
||||
logsdata->lines[i].val[0]= log_maskmap[i].name;
|
||||
logsdata->lines[i].val[1]= (g_log->debug_mask & log_maskmap[i].value)?"true":"false";
|
||||
logsdata->lines[i].val[2]=(g_log->dump_mask & log_maskmap[i].value)?"true":"false";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcasestr(cmdbuff,"logopt") != NULL) {
|
||||
webdatadef_t *logsdata = ( webdatadef_t *) data;
|
||||
logsdata->numcols=2;
|
||||
logsdata->numlines=0;
|
||||
snprintf(logsdata->columns[0].coltitle,TELNET_CMD_MAXSIZE,"option");
|
||||
logsdata->columns[0].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY;
|
||||
snprintf(logsdata->columns[1].coltitle,TELNET_CMD_MAXSIZE,"enabled");
|
||||
logsdata->columns[1].coltype = TELNET_CHECKVAL_BOOL;
|
||||
|
||||
for (int i=0; log_options[i].name != NULL; i++) {
|
||||
logsdata->numlines++;
|
||||
logsdata->lines[i].val[0]=log_options[i].name;
|
||||
logsdata->lines[i].val[1]=(g_log->flag & log_options[i].value)?"true":"false";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int proccmd_show(char *buf, int debug, telnet_printfunc_t prnt)
|
||||
{
|
||||
|
||||
if (buf == NULL) {
|
||||
prnt("ERROR wrong softmodem SHOW command...\n");
|
||||
return 0;
|
||||
}
|
||||
if (debug > 0)
|
||||
prnt(" proccmd_show received %s\n",buf);
|
||||
if (strcasestr(buf,"thread") != NULL) {
|
||||
@@ -270,6 +340,10 @@ int bv1,bv2;
|
||||
int res;
|
||||
char sv1[64];
|
||||
|
||||
if (buf == NULL) {
|
||||
prnt("ERROR wrong thread command...\n");
|
||||
return 0;
|
||||
}
|
||||
bv1=0;
|
||||
bv2=0;
|
||||
sv1[0]=0;
|
||||
@@ -284,7 +358,7 @@ char sv1[64];
|
||||
prnt(" proccmd_thread: %i params = %i,%s,%i\n",res,bv1,sv1,bv2);
|
||||
if(res != 3)
|
||||
{
|
||||
prnt("softmodem thread needs 3 params, %i received\n",res);
|
||||
print_threads(buf, debug, prnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -307,7 +381,7 @@ int proccmd_exit(char *buf, int debug, telnet_printfunc_t prnt)
|
||||
{
|
||||
if (debug > 0)
|
||||
prnt("process module received %s\n",buf);
|
||||
|
||||
end_configmodule();
|
||||
exit_fun("telnet server received exit command\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,9 @@ extern int proccmd_show(char *buf, int debug, telnet_printfunc_t prnt);
|
||||
extern int proccmd_thread(char *buf, int debug, telnet_printfunc_t prnt);
|
||||
extern int proccmd_exit(char *buf, int debug, telnet_printfunc_t prnt);
|
||||
extern int proccmd_log(char *buf, int debug, telnet_printfunc_t prnt);
|
||||
extern int proccmd_websrv_getdata(char *cmdbuff, int debug, void *data);
|
||||
telnetshell_vardef_t proc_vardef[] = {
|
||||
{"",0,NULL}
|
||||
{"",0,0,NULL}
|
||||
};
|
||||
#define PROCCMD_LOG_HELP_STRING " log sub commands: \n\
|
||||
show: display current log configuration \n\
|
||||
@@ -73,10 +74,14 @@ telnetshell_vardef_t proc_vardef[] = {
|
||||
|
||||
|
||||
telnetshell_cmddef_t proc_cmdarray[] = {
|
||||
{"show","loglvl|thread|config", proccmd_show},
|
||||
{"log","(enter help for details)", proccmd_log},
|
||||
{"thread","(enter help for details)", proccmd_thread},
|
||||
{"exit","", proccmd_exit},
|
||||
{"show","loglvl|thread|config", proccmd_show,{(webfunc_t)proccmd_websrv_getdata},TELNETSRV_CMDFLAG_TELNETONLY,NULL},
|
||||
{"log","(enter help for details)", proccmd_log, {NULL},TELNETSRV_CMDFLAG_TELNETONLY,NULL},
|
||||
{"show loglvl","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBTBLDATA,NULL},
|
||||
{"show logopt","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBTBLDATA,NULL},
|
||||
{"show dbgopt","", proccmd_log,{(webfunc_t)proccmd_websrv_getdata}, TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_GETWEBTBLDATA,NULL},
|
||||
{"show config","", proccmd_show,{(webfunc_t)proccmd_show}, TELNETSRV_CMDFLAG_WEBSRVONLY,NULL},
|
||||
{"show thread","", proccmd_thread,{(webfunc_t)proccmd_show},TELNETSRV_CMDFLAG_WEBSRVONLY|TELNETSRV_CMDFLAG_PRINTWEBTBLDATA,NULL},
|
||||
{"exit","", proccmd_exit,{NULL},TELNETSRV_CMDFLAG_CONFEXEC,NULL},
|
||||
{"","",NULL},
|
||||
};
|
||||
#else
|
||||
|
||||
@@ -133,13 +133,13 @@ void initNamedTpool(char *params,tpool_t *pool, bool performanceMeas, char *name
|
||||
ptr=pool->allthreads;
|
||||
pool->allthreads=(struct one_thread *)malloc(sizeof(struct one_thread));
|
||||
pool->allthreads->next=ptr;
|
||||
printf("create a thread for core %d\n", atoi(curptr));
|
||||
pool->allthreads->coreID=atoi(curptr);
|
||||
pool->allthreads->id=pool->nbThreads;
|
||||
pool->allthreads->pool=pool;
|
||||
//Configure the thread scheduler policy for Linux
|
||||
// set the thread name for debugging
|
||||
sprintf(pool->allthreads->name,"%s%d_%d",tname,pool->nbThreads,pool->allthreads->coreID);
|
||||
printf("thread %s created @cpu %d\n",pool->allthreads->name,pool->allthreads->coreID);
|
||||
threadCreate(&pool->allthreads->threadID, one_thread, (void *)pool->allthreads,
|
||||
pool->allthreads->name, pool->allthreads->coreID, OAI_PRIORITY_RT);
|
||||
pool->nbThreads++;
|
||||
|
||||
@@ -38,7 +38,6 @@ static time_stats_t **measur_table;
|
||||
notifiedFIFO_t measur_fifo;
|
||||
double get_cpu_freq_GHz(void)
|
||||
{
|
||||
#if 0
|
||||
if (cpu_freq_GHz <1 ) {
|
||||
time_stats_t ts = {0};
|
||||
reset_meas(&ts);
|
||||
@@ -49,16 +48,6 @@ double get_cpu_freq_GHz(void)
|
||||
cpu_freq_GHz = (double)ts.diff/1000000000;
|
||||
printf("CPU Freq is %f \n", cpu_freq_GHz);
|
||||
}
|
||||
#else
|
||||
char buf[128];
|
||||
system("lscpu | grep 'CPU MHz' | awk '{ print $3}' > /dev/shm/@tmp");
|
||||
FILE* fp=fopen("/dev/shm/@tmp","r");
|
||||
fgets(buf,sizeof(buf),fp);
|
||||
fclose(fp);
|
||||
cpu_freq_GHz = atof(buf)/1000.0;
|
||||
printf("CPU Freq is %f \n", cpu_freq_GHz);
|
||||
#endif
|
||||
|
||||
return cpu_freq_GHz;
|
||||
}
|
||||
|
||||
@@ -161,7 +150,6 @@ int print_meas_log(time_stats_t *ts,
|
||||
((ts->diff/ts->trials/cpu_freq_GHz/1000.0)/(sf_exec_time->diff/sf_exec_time->trials/cpu_freq_GHz/1000.0))*100, // percentage
|
||||
ts->trials);
|
||||
}
|
||||
ts->max = 0;
|
||||
}
|
||||
return stroff;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ static inline void *malloc_or_fail(size_t size) {
|
||||
}
|
||||
|
||||
#if !defined (msg)
|
||||
# define msg(aRGS...) LOG_X(PHY, ##aRGS)
|
||||
# define msg(aRGS...) LOG_D(PHY, ##aRGS)
|
||||
#endif
|
||||
#ifndef malloc16
|
||||
# ifdef __AVX2__
|
||||
|
||||
7
common/utils/websrv/DOC/websrv.md
Normal file
7
common/utils/websrv/DOC/websrv.md
Normal file
@@ -0,0 +1,7 @@
|
||||
The oai embedded telnet server is an optional monitoring and debugging tool. It provides a simple Command Line Interface to the oai softmem. New commands can easily be added by developers to the telnet server.
|
||||
|
||||
* [Using the telnet server](telnetusage.md)
|
||||
* [Adding commands to the oai telnet server](telnetaddcmd.md)
|
||||
* [telnet server architecture ](telnetarch.md)
|
||||
|
||||
[oai Wikis home](https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/home)
|
||||
31
common/utils/websrv/DOC/websrvarch.md
Normal file
31
common/utils/websrv/DOC/websrvarch.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# telnet server principles
|
||||
|
||||
The oai telnet server is implemented in shared libraries to be loaded by the [oai shared library loader](loader). `libtelnetsrv.so ` contains the code common to all oai softmodem executables, where `libtelnetsrv_<app>.so` contains the code specific to the executable identified by `app`.
|
||||
|
||||
| `<app>` | executable |
|
||||
| :-----: | :---------------: |
|
||||
| enb | `lte-softmodem` |
|
||||
| gnb | `nr-softmodem` |
|
||||
| 4Gue | `lte-uesoftmodem` |
|
||||
| 5Gue | `nr-uesoftmodem` |
|
||||
|
||||
The implementation includes a `telnetsrv_autoinit` function which is automatically called at load time, starts the telnet server and registers a first set of commands, which are delivered with the server (telnet, softmodem, loader). it also uses the `get_softmodem_function` call to retrieve the running executable id and possibly loads the corresponding `libtelnetsrv_<app>.so`library.
|
||||
|
||||
Currently the telnet server only supports one user connection. The same dedicated thread is used to wait for a user connection and process the input received from this connection.
|
||||
|
||||
The telnet server provides an API which can be used by any oai component to add new CLI commands to the server. A pre-defined command can be used to get or set a list of variables.
|
||||
|
||||
|
||||
|
||||
# telnet server source files
|
||||
|
||||
telnet server source files are located in [common/utils/telnetsrv](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv)
|
||||
|
||||
1. [telnetsrv.c](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv/telnetsrv.c) contains the telnet server implementation, including the implementation of the `telnet` CLI command. This implementation is compatible with all softmodem executables and is in charge of loading any additional `libtelnetsrv_<app> .so` containing code specific to the running executables.
|
||||
1. [telnetsrv.h](https://gitlab.eurecom.fr/oai/openairinterface5g/tree/develop/common/utils/telnetsrv/telnetsrv.h) is the telnet server include file containing both private and public data type definitions. It also contains API prototypes for functions that are used to register a new command in the server.
|
||||
1. `telnetsrv_<XXX\>.c`: implementation of \<XXX\> CLI command which are delivered with the telnet server and are common to all softmodem executables.
|
||||
1. `telnetsrv_<XXX\>.h`: include file for the implementation of XXX CLI command. Usually included only in the corresponding `.c`file
|
||||
1. `telnetsrv_<app>_<XXX>.c`: implementation of \<XXX\> CLI command specific to the executable identified by \<app\>.These sources are used to create `libtelnetsrv_<app>.so` at build time.
|
||||
1. [telnetsrv_CMakeLists.txt](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/utils/telnetsrv/telnetsrv_CMakeLists.txt): CMakelists file containing the cmake instructions to build the telnet server. this file is included in the [global oai CMakelists](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/cmake_targets/CMakeLists.txt).
|
||||
|
||||
[oai telnet server home](telnetsrv.md)
|
||||
40
common/utils/websrv/DOC/websrvuse.md
Normal file
40
common/utils/websrv/DOC/websrvuse.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# starting the softmodem with the telnet server
|
||||
By default the embedded telnet server, which is implemented in a shared library, is not built. It can be built after compiling the softmodem executable using the `build_oai` script:
|
||||
|
||||
```bash
|
||||
cd \<oai repository\>/openairinterface5g
|
||||
source oaienv
|
||||
cd cmake_targets
|
||||
./build_oai --build-lib telnetsrv
|
||||
```
|
||||
|
||||
This will create the `libtelnetsrv.so` and `libtelnetsrv_<app> file in the `targets/bin` and `cmake_targets/ran_build/build` sub directories of the oai repository. <app> can be "enb", "gnb", "4GUE" or "5GUE", each library containing functions specific to a given executable.
|
||||
|
||||
When starting the softmodem, you must specify the **_\-\-telnetsrv_** option to load and start the telnet server. The telnet server is loaded via the [oai shared library loader](loader).
|
||||
|
||||
# using the Command Line Interface
|
||||
By default the telnet server listen on all the ip addresses configured on the system and on port 9090. This behavior can be changed using the `listenaddr` and `listenport` parameters.
|
||||
The telnet server includes a basic help, listing available commands and some commands also provide a specific detailed help sub-command.
|
||||
Below are examples of telnet sessions:
|
||||
|
||||
* [getting help](telnethelp.md)
|
||||
* [using the history](telnethist.md)
|
||||
* [using the get and set commands](telnetgetset.md)
|
||||
* [using the loop command](telnetloop.md)
|
||||
* [loader command](telnetloader.md)
|
||||
* [log command](telnetlog.md)
|
||||
* [measur command](telnetmeasur.md)
|
||||
|
||||
# telnet server parameters
|
||||
The telnet server is using the [oai configuration module](Config/Rtusage). Telnet parameters must be specified in the `telnetsrv` section. Some parameters can be modified via the telnet telnet server command, as specified in the last column of the following table.
|
||||
|
||||
| name | type | default | description | dynamic |
|
||||
|:---:|:---:|:---:|:----|:----:|
|
||||
| `listenaddr` | `ipV4 address, ascii format` | "0.0.0.0" | local address the server is listening on| N |
|
||||
| `listenport` | `integer` | 9090 | port number the server is listening on | N |
|
||||
| `loopcount` | `integer` | 10 | number of iterations for the loop command | Y |
|
||||
| `loopdelay` | `integer` | 5000 | delay (in ms) between 2 loop command iterations | Y |
|
||||
| `histfile` | `character string` | "oaitelnet.history" | file used for command history persistency | Y |
|
||||
| `histfsize` | `integer` | 50 | maximum number of commands saved in the history | Y |
|
||||
|
||||
[oai telnet server home](telnetsrv.md)
|
||||
17
common/utils/websrv/frontend/.browserslistrc
Normal file
17
common/utils/websrv/frontend/.browserslistrc
Normal file
@@ -0,0 +1,17 @@
|
||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
|
||||
# For the full list of supported browsers by the Angular framework, please see:
|
||||
# https://angular.io/guide/browser-support
|
||||
|
||||
# You can see what browsers were selected by your queries by running:
|
||||
# npx browserslist
|
||||
|
||||
last 1 Chrome version
|
||||
last 1 Firefox version
|
||||
last 2 Edge major versions
|
||||
last 2 Safari major versions
|
||||
last 2 iOS major versions
|
||||
Firefox ESR
|
||||
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
|
||||
16
common/utils/websrv/frontend/.editorconfig
Normal file
16
common/utils/websrv/frontend/.editorconfig
Normal file
@@ -0,0 +1,16 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.ts]
|
||||
quote_type = single
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
50
common/utils/websrv/frontend/.eslintrc.json
Normal file
50
common/utils/websrv/frontend/.eslintrc.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"root": true,
|
||||
"ignorePatterns": [
|
||||
"projects/**/*"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.ts"
|
||||
],
|
||||
"parserOptions": {
|
||||
"project": [
|
||||
"common/utils/websrv/frontend/tsconfig.json"
|
||||
],
|
||||
"createDefaultProgram": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:@angular-eslint/recommended",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "app",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "app",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.html"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:@angular-eslint/template/recommended"
|
||||
],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
49
common/utils/websrv/frontend/.gitignore
vendored
Normal file
49
common/utils/websrv/frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
/artifacts
|
||||
/builds
|
||||
# Only exists if Bazel was run
|
||||
/bazel-out
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# profiling files
|
||||
chrome-profiler-events*.json
|
||||
speed-measure-plugin*.json
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
config.toml
|
||||
31
common/utils/websrv/frontend/.gitlab-ci.yml
Normal file
31
common/utils/websrv/frontend/.gitlab-ci.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
stages:
|
||||
- install
|
||||
- build
|
||||
|
||||
variables:
|
||||
TRION_CLI_VERSION: 12.2.4
|
||||
|
||||
#
|
||||
#jobs
|
||||
#
|
||||
|
||||
install:
|
||||
stage: install
|
||||
image: trion/ng-cli:${TRION_CLI_VERSION}
|
||||
script:
|
||||
- npm ci
|
||||
only:
|
||||
changes:
|
||||
- package-lock.json
|
||||
|
||||
build:
|
||||
stage: build
|
||||
extends: .install
|
||||
image: trion/ng-cli-karma:${TRION_CLI_VERSION}
|
||||
script:
|
||||
- npm run lint
|
||||
- npm run build
|
||||
artifacts:
|
||||
expire_in: 1 day
|
||||
paths:
|
||||
- dist/softmodem-ngx
|
||||
1
common/utils/websrv/frontend/README.md
Normal file
1
common/utils/websrv/frontend/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# SoftModemNgx
|
||||
107
common/utils/websrv/frontend/angular.json
Normal file
107
common/utils/websrv/frontend/angular.json
Normal file
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"cli": {
|
||||
"analytics": false,
|
||||
"defaultCollection": "@angular-eslint/schematics"
|
||||
},
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"softmodemngx": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:application": {
|
||||
"strict": true
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "dist/softmodem-ngx",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"./node_modules/@angular/material/prebuilt-themes/purple-green.css",
|
||||
"src/styles.css"
|
||||
],
|
||||
"scripts": [],
|
||||
"allowedCommonJsDependencies": [
|
||||
"@firebase/auth",
|
||||
"firebase"
|
||||
]
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "2mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"optimization": false,
|
||||
"vendorChunk": true,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true,
|
||||
"namedChunks": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "softmodemngx:build:production"
|
||||
},
|
||||
"development": {
|
||||
"browserTarget": "softmodemngx:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "softmodemngx:build"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-eslint/builder:lint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.html"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "softmodemngx"
|
||||
}
|
||||
40
common/utils/websrv/frontend/e2e/protractor-ci.conf.js
Normal file
40
common/utils/websrv/frontend/e2e/protractor-ci.conf.js
Normal file
@@ -0,0 +1,40 @@
|
||||
// @ts-check
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
|
||||
|
||||
/**
|
||||
* @type { import("protractor").Config }
|
||||
*/
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
specs: [
|
||||
'./src/**/*.e2e-spec.ts'
|
||||
],
|
||||
capabilities: {
|
||||
browserName: 'chrome',
|
||||
chromeOptions: {
|
||||
args: ['--headless', '--no-sandbox']
|
||||
}
|
||||
},
|
||||
directConnect: true,
|
||||
SELENIUM_PROMISE_MANAGER: true,
|
||||
baseUrl: 'http://localhost:4200/',
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function () { }
|
||||
},
|
||||
onPrepare() {
|
||||
require('ts-node').register({
|
||||
project: require('path').join(__dirname, './tsconfig.json')
|
||||
});
|
||||
jasmine.getEnv().addReporter(new SpecReporter({
|
||||
spec: {
|
||||
displayStacktrace: StacktraceOption.PRETTY
|
||||
}
|
||||
}));
|
||||
}
|
||||
};
|
||||
37
common/utils/websrv/frontend/e2e/protractor.conf.js
Normal file
37
common/utils/websrv/frontend/e2e/protractor.conf.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// @ts-check
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
|
||||
|
||||
/**
|
||||
* @type { import("protractor").Config }
|
||||
*/
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
specs: [
|
||||
'./src/**/*.e2e-spec.ts'
|
||||
],
|
||||
capabilities: {
|
||||
browserName: 'chrome'
|
||||
},
|
||||
directConnect: true,
|
||||
SELENIUM_PROMISE_MANAGER: false,
|
||||
baseUrl: 'http://localhost:4200/',
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function () { }
|
||||
},
|
||||
onPrepare() {
|
||||
require('ts-node').register({
|
||||
project: require('path').join(__dirname, './tsconfig.json')
|
||||
});
|
||||
jasmine.getEnv().addReporter(new SpecReporter({
|
||||
spec: {
|
||||
displayStacktrace: StacktraceOption.PRETTY
|
||||
}
|
||||
}));
|
||||
}
|
||||
};
|
||||
23
common/utils/websrv/frontend/e2e/src/app.e2e-spec.ts
Normal file
23
common/utils/websrv/frontend/e2e/src/app.e2e-spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { browser, logging } from 'protractor';
|
||||
import { AppPage } from './app.po';
|
||||
|
||||
describe('workspace-project App', () => {
|
||||
let page: AppPage;
|
||||
|
||||
beforeEach(() => {
|
||||
page = new AppPage();
|
||||
});
|
||||
|
||||
// it('should display welcome message', async () => {
|
||||
// await page.navigateTo();
|
||||
// expect(await page.getTitleText()).toEqual('example app is running!');
|
||||
// });
|
||||
|
||||
afterEach(async () => {
|
||||
// Assert that there are no errors emitted from the browser
|
||||
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
|
||||
expect(logs).not.toContain(jasmine.objectContaining({
|
||||
level: logging.Level.SEVERE,
|
||||
} as logging.Entry));
|
||||
});
|
||||
});
|
||||
11
common/utils/websrv/frontend/e2e/src/app.po.ts
Normal file
11
common/utils/websrv/frontend/e2e/src/app.po.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { browser, by, element } from 'protractor';
|
||||
|
||||
export class AppPage {
|
||||
async navigateTo(): Promise<unknown> {
|
||||
return browser.get(browser.baseUrl);
|
||||
}
|
||||
|
||||
async getTitleText(): Promise<string> {
|
||||
return element(by.css('app-root .content span')).getText();
|
||||
}
|
||||
}
|
||||
10
common/utils/websrv/frontend/e2e/tsconfig.json
Normal file
10
common/utils/websrv/frontend/e2e/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/e2e",
|
||||
"module": "commonjs",
|
||||
"target": "es2018",
|
||||
"types": ["jasmine", "node"]
|
||||
}
|
||||
}
|
||||
31289
common/utils/websrv/frontend/package-lock.json
generated
Normal file
31289
common/utils/websrv/frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
62
common/utils/websrv/frontend/package.json
Normal file
62
common/utils/websrv/frontend/package.json
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "softmodemngx",
|
||||
"version": "2.0.0",
|
||||
"scripts": {
|
||||
"lint": "ng lint",
|
||||
"build": "ng build",
|
||||
"dev": "ng serve --configuration=development",
|
||||
"prod": "ng serve --configuration=production"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "~12.2.4",
|
||||
"@angular/cdk": "~12.2.4",
|
||||
"@angular/common": "~12.2.4",
|
||||
"@angular/compiler": "~12.2.4",
|
||||
"@angular/core": "~12.2.4",
|
||||
"@angular/flex-layout": "^12.0.0-beta.34",
|
||||
"@angular/forms": "~12.2.4",
|
||||
"@angular/material": "^12.2.4",
|
||||
"@angular/platform-browser": "~12.2.4",
|
||||
"@angular/platform-browser-dynamic": "~12.2.4",
|
||||
"@angular/router": "~12.2.4",
|
||||
"moment": "^2.29.1",
|
||||
"rxjs": "^6.6.6",
|
||||
"tslib": "^2.0.0",
|
||||
"zone.js": "^0.11.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/architect": "^0.1200.0",
|
||||
"@angular-devkit/build-angular": "~12.2.4",
|
||||
"@angular-eslint/builder": "12.1.0",
|
||||
"@angular-eslint/eslint-plugin": "12.1.0",
|
||||
"@angular-eslint/eslint-plugin-template": "12.1.0",
|
||||
"@angular-eslint/schematics": "12.5.0",
|
||||
"@angular-eslint/template-parser": "12.1.0",
|
||||
"@angular/cli": "~12.2.4",
|
||||
"@angular/compiler-cli": "~12.2.4",
|
||||
"@angular/language-service": "^12.2.4",
|
||||
"@types/node": "^12.20.23",
|
||||
"@typescript-eslint/eslint-plugin": "4.23.0",
|
||||
"@typescript-eslint/parser": "4.23.0",
|
||||
"eslint": "^7.26.0",
|
||||
"fs-extra": "^10.0.0",
|
||||
"fuzzy": "^0.1.3",
|
||||
"husky": "^5.1.3",
|
||||
"inquirer": "^6.2.2",
|
||||
"inquirer-autocomplete-prompt": "^1.0.1",
|
||||
"jasmine-core": "~3.7.1",
|
||||
"jasmine-spec-reporter": "~5.0.0",
|
||||
"jsonc-parser": "^3.0.0",
|
||||
"open": "^7.0.3",
|
||||
"ts-node": "^8.10.2",
|
||||
"tslint-angular": "^3.0.3",
|
||||
"typescript": "~4.2.4"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged && ng lint && ng test",
|
||||
"pre-push": "ng build --aot true"
|
||||
}
|
||||
}
|
||||
}
|
||||
85
common/utils/websrv/frontend/src/app/api/commands.api.ts
Normal file
85
common/utils/websrv/frontend/src/app/api/commands.api.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { Param, ParamFC } from '../controls/param.control';
|
||||
|
||||
|
||||
export interface IVariable {
|
||||
name: string;
|
||||
value: string;
|
||||
type: IArgType;
|
||||
modifiable: boolean; //set command ?
|
||||
}
|
||||
|
||||
export enum ILogLvl {
|
||||
error = "error",
|
||||
warn = "warn",
|
||||
analysis = "analysis",
|
||||
info = "info",
|
||||
debug = "debug",
|
||||
trace = "trace"
|
||||
}
|
||||
|
||||
export enum ILogOutput {
|
||||
stdout = "stdout",
|
||||
telnet = "telnet",
|
||||
web = "web",
|
||||
file = "/tmp/<component>.log",
|
||||
}
|
||||
|
||||
export enum IArgType {
|
||||
boolean = "boolean",
|
||||
list = "list",
|
||||
range = "range",
|
||||
number = "number",
|
||||
string = "string"
|
||||
}
|
||||
|
||||
export interface ICommand {
|
||||
name: string;
|
||||
confirm?: string;
|
||||
}
|
||||
|
||||
|
||||
export interface IColumn { //should use IVariable ?
|
||||
name: string;
|
||||
type: IArgType;
|
||||
modifiable: boolean; //set command ?
|
||||
}
|
||||
|
||||
export type IRow = string[]
|
||||
export interface ITable {
|
||||
columns: IColumn[];
|
||||
rows: IRow[];
|
||||
}
|
||||
export interface IResp {
|
||||
display: string[],
|
||||
table?: ITable
|
||||
}
|
||||
|
||||
const route = '/oaisoftmodem';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CommandsApi {
|
||||
constructor(private httpClient: HttpClient) { }
|
||||
|
||||
public readVariables$ = (moduleName?: string) => this.httpClient.get<IVariable[]>(environment.backend + route + '/' + (moduleName ? ('/' + moduleName) : "") + '/variables/');
|
||||
|
||||
public readCommands$ = (moduleName?: string) => this.httpClient.get<ICommand[]>(environment.backend + route + '/' + (moduleName ? ('/' + moduleName) : "") + '/commands/');
|
||||
|
||||
public runCommand$ = (command: ICommand, moduleName: string) => this.httpClient.post<IResp>(environment.backend + route + '/' + moduleName + '/commands/', command);
|
||||
|
||||
public setVariable$ = (variable: IVariable, moduleName?: string) => this.httpClient.post<IResp>(environment.backend + route + (moduleName ? ('/' + moduleName) : "") + '/variables/', variable);
|
||||
|
||||
public setParam$ = (param: Param) => this.httpClient.post<IResp>(environment.backend + route + '/' + param.moduleName + '/set',
|
||||
{
|
||||
cmdName: param.cmdName,
|
||||
colName: param.col.name,
|
||||
rawIndex: param.rawIndex,
|
||||
value: param.value
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
15
common/utils/websrv/frontend/src/app/app-routing.module.ts
Normal file
15
common/utils/websrv/frontend/src/app/app-routing.module.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { CommandsComponent } from './components/commands/commands.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/commands', pathMatch: 'full' },
|
||||
{ path: 'commands', component: CommandsComponent },
|
||||
{ path: '**', redirectTo: '' },
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
1
common/utils/websrv/frontend/src/app/app.component.html
Normal file
1
common/utils/websrv/frontend/src/app/app.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<app-commands></app-commands>
|
||||
10
common/utils/websrv/frontend/src/app/app.component.ts
Normal file
10
common/utils/websrv/frontend/src/app/app.component.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.css'],
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'softmodem-ngx';
|
||||
}
|
||||
78
common/utils/websrv/frontend/src/app/app.module.ts
Normal file
78
common/utils/websrv/frontend/src/app/app.module.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { ClipboardModule } from '@angular/cdk/clipboard/';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
import { MatNativeDateModule } from '@angular/material/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatGridListModule } from '@angular/material/grid-list';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSidenavModule } from '@angular/material/sidenav';
|
||||
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { CommandsApi } from './api/commands.api';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
import { CommandsComponent } from './components/commands/commands.component';
|
||||
import { ConfirmDialogComponent } from './components/confirm/confirm.component';
|
||||
import { ErrorDialogComponent } from './components/error-dialog/error-dialog.component';
|
||||
import { InterceptorProviders } from './interceptors/interceptors';
|
||||
import { LoadingService } from './services/loading.service';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
ErrorDialogComponent,
|
||||
CommandsComponent,
|
||||
ConfirmDialogComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
BrowserAnimationsModule,
|
||||
HttpClientModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
ReactiveFormsModule,
|
||||
// MatChipsModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatButtonModule,
|
||||
FlexLayoutModule,
|
||||
MatToolbarModule,
|
||||
// MatListModule,
|
||||
MatTableModule,
|
||||
MatSelectModule,
|
||||
MatDialogModule,
|
||||
MatSnackBarModule,
|
||||
MatSlideToggleModule,
|
||||
MatGridListModule,
|
||||
MatCardModule,
|
||||
// MatMenuModule,
|
||||
],
|
||||
providers: [
|
||||
// services
|
||||
LoadingService,
|
||||
// api
|
||||
CommandsApi,
|
||||
// interceptors
|
||||
InterceptorProviders,
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
entryComponents: [ErrorDialogComponent],
|
||||
})
|
||||
export class AppModule { }
|
||||
@@ -0,0 +1,34 @@
|
||||
mat-form-field {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.status {
|
||||
color: green;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.ng-invalid .status {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.grid-container {
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
.dashboard-card {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
left: 15px;
|
||||
right: 15px;
|
||||
bottom: 15px;
|
||||
}
|
||||
|
||||
.more-button {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
.dashboard-card-content {
|
||||
text-align: start;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<div class="grid-container">
|
||||
<mat-grid-list cols="2" rowHeight="200px">
|
||||
<mat-grid-tile [colspan]="1" [rowspan]="2">
|
||||
<mat-card class="dashboard-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>Softmodem variables</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content class="dashboard-card-content">
|
||||
<div *ngIf="vars$ | async as vars">
|
||||
<div *ngFor="let variable of vars">
|
||||
<mat-form-field>
|
||||
<mat-label>{{ variable.nameFC.value }}</mat-label>
|
||||
<input input matInput [formControl]="variable.valueFC" />
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value"
|
||||
(click)="onVarSubmit(variable)">
|
||||
set
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-grid-tile>
|
||||
|
||||
<mat-grid-tile [colspan]="1" [rowspan]="2">
|
||||
<mat-card class="dashboard-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>Softmodem commands</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content class="dashboard-card-content">
|
||||
<div *ngIf="modules$ | async as modules" fxLaypout="row">
|
||||
<mat-form-field>
|
||||
<mat-label>Module</mat-label>
|
||||
<mat-select (selectionChange)="onModuleSelect($event.value)">
|
||||
<mat-option *ngFor="let module of modules" [value]="module"> {{ module.nameFC.value }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div *ngIf="modulecmds$ | async as cmds">
|
||||
<div *ngIf="cmds.length">
|
||||
<div *ngFor="let cmd of cmds" fxLayoutGap="10px" fxLayoutAlign="start start">
|
||||
<button mat-raised-button color="primary" (click)="onCmdSubmit(cmd)"> {{cmd.nameFC.value}} </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-grid-tile>
|
||||
|
||||
<mat-grid-tile *ngIf="modulevars$ | async as modulevars" [colspan]="1" [rowspan]="6">
|
||||
<mat-card *ngIf="modulevars.length" class="dashboard-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ selectedModule!.nameFC.value }} variables</mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content class="dashboard-card-content">
|
||||
<div *ngFor="let variable of modulevars">
|
||||
<mat-form-field>
|
||||
<mat-label>{{ variable.nameFC.value }}</mat-label>
|
||||
<input input matInput [formControl]="variable.valueFC" />
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" [disabled]="!variable.modifiableFC.value"
|
||||
(click)="onModuleVarsubmit(variable)">
|
||||
set
|
||||
</button>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-grid-tile>
|
||||
|
||||
<mat-grid-tile *ngIf="selectedCmd" [colspan]="1" [rowspan]="10">
|
||||
<mat-card class="dashboard-card">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{ selectedModule!.nameFC.value }} {{ selectedCmd.name }} </mat-card-title>
|
||||
</mat-card-header>
|
||||
<mat-card-content class="dashboard-card-content">
|
||||
|
||||
<mat-table mat-table [dataSource]="rows$" multiTemplateDataRows class="mat-elevation-z8">
|
||||
|
||||
<!-- For anyone who has set the multiTemplateDataRows property of mat-table to true,
|
||||
you can't use index. Instead you have use either dataIndex or renderIndex.
|
||||
See https://github.com/angular/material2/issues/12793 -->
|
||||
|
||||
|
||||
<div *ngFor="let col of columns; index as colIndex" matColumnDef="{{col.name}}">
|
||||
<mat-header-cell *matHeaderCellDef>
|
||||
<div>
|
||||
<h4>{{ col.name }}</h4>
|
||||
</div>
|
||||
</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row; dataIndex as rowIndex">
|
||||
|
||||
<div *ngIf="col.type === IOptionType.boolean; then toggle else default"> </div>
|
||||
<!-- <button mat-raised-button color="primary" (click)="onParamSubmit(row)"> set </button> -->
|
||||
|
||||
<ng-template #toggle>
|
||||
<mat-slide-toggle [formControl]="row[colIndex]" [checked]="row[colIndex].value"
|
||||
[disabled]="!col.modifiable" (change)="onParamSubmit(row)">
|
||||
</mat-slide-toggle>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #default>
|
||||
<mat-form-field>
|
||||
<input matInput [formControl]="row[colIndex]" [disabled]="!col.modifiable" />
|
||||
</mat-form-field>
|
||||
</ng-template>
|
||||
|
||||
</mat-cell>
|
||||
</div>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns" (keydown.enter)="onParamSubmit(row)"></mat-row>
|
||||
|
||||
</mat-table>
|
||||
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</mat-grid-tile>
|
||||
|
||||
</mat-grid-list>
|
||||
</div>
|
||||
@@ -0,0 +1,121 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { of } from 'rxjs/internal/observable/of';
|
||||
import { map } from 'rxjs/internal/operators/map';
|
||||
import { mergeMap } from 'rxjs/internal/operators/mergeMap';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { CommandsApi, IArgType, IColumn, ICommand } from 'src/app/api/commands.api';
|
||||
import { CmdCtrl } from 'src/app/controls/cmd.control';
|
||||
import { Param, ParamFC } from 'src/app/controls/param.control';
|
||||
import { VarCtrl } from 'src/app/controls/var.control';
|
||||
import { DialogService } from 'src/app/services/dialog.service';
|
||||
import { LoadingService } from 'src/app/services/loading.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-commands',
|
||||
templateUrl: './commands.component.html',
|
||||
styleUrls: ['./commands.component.css'],
|
||||
})
|
||||
export class CommandsComponent {
|
||||
|
||||
IOptionType = IArgType;
|
||||
|
||||
vars$: Observable<VarCtrl[]>
|
||||
modules$: Observable<CmdCtrl[]>
|
||||
selectedModule?: CmdCtrl
|
||||
selectedCmd?: ICommand
|
||||
|
||||
modulevars$?: Observable<VarCtrl[]>
|
||||
modulecmds$?: Observable<CmdCtrl[]>
|
||||
|
||||
//table columns
|
||||
displayedColumns: string[] = []
|
||||
rows$: Observable<ParamFC[][]> = new Observable<ParamFC[][]>()
|
||||
columns: IColumn[] = []
|
||||
|
||||
constructor(
|
||||
public commandsApi: CommandsApi,
|
||||
public loadingService: LoadingService,
|
||||
public dialogService: DialogService
|
||||
) {
|
||||
this.vars$ = this.commandsApi.readVariables$().pipe(
|
||||
map((vars) => vars.map(ivar => new VarCtrl(ivar)))
|
||||
);
|
||||
|
||||
this.modules$ = this.commandsApi.readCommands$().pipe(
|
||||
map((cmds) => cmds.map(icmd => new CmdCtrl(icmd)))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
onModuleSelect(control: CmdCtrl) {
|
||||
|
||||
this.selectedModule = control
|
||||
|
||||
this.modulecmds$ = this.commandsApi.readCommands$(`${control.nameFC.value}`).pipe(
|
||||
map(icmds => icmds.map(icmd => new CmdCtrl(icmd)))
|
||||
)
|
||||
|
||||
this.modulevars$ = this.commandsApi.readVariables$(`${control.nameFC.value}`).pipe(
|
||||
map(ivars => ivars.map(ivar => new VarCtrl(ivar))),
|
||||
)
|
||||
}
|
||||
|
||||
onVarSubmit(control: VarCtrl) {
|
||||
this.commandsApi.setVariable$(control.api()).subscribe();
|
||||
}
|
||||
|
||||
onModuleVarsubmit(control: VarCtrl) {
|
||||
this.commandsApi.setVariable$(control.api(), `${this.selectedModule!.nameFC.value}`)
|
||||
.pipe(
|
||||
map(resp => this.dialogService.openRespDialog(resp))
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
onCmdSubmit(control: CmdCtrl) {
|
||||
this.selectedCmd = control.api()
|
||||
|
||||
const obs = control.confirm
|
||||
? this.dialogService.openConfirmDialog(control.confirm).pipe(
|
||||
filter(confirmed => confirmed)
|
||||
)
|
||||
: of(null)
|
||||
|
||||
this.rows$ = obs.pipe(
|
||||
mergeMap(() => this.commandsApi.runCommand$(control.api(), `${this.selectedModule!.nameFC.value}`)),
|
||||
mergeMap(resp => {
|
||||
if (resp.display[0]) return this.dialogService.openRespDialog(resp, 'cmd ' + control.nameFC.value + ' response:')
|
||||
else return of(resp)
|
||||
}),
|
||||
map(resp => {
|
||||
this.columns = resp.table!.columns
|
||||
this.displayedColumns = this.columns.map(col => col.name)
|
||||
|
||||
let rows = [];
|
||||
|
||||
for (let i = 0; i < resp.table!.rows.length; i++) {
|
||||
let row: Param[] = []
|
||||
|
||||
for (let j = 0; j < this.columns.length; j++) {
|
||||
row[j] = new Param(
|
||||
resp.table!.rows[i][j],
|
||||
this.columns[j],
|
||||
j,
|
||||
this.selectedModule!.nameFC.value,
|
||||
this.selectedCmd!.name
|
||||
)
|
||||
}
|
||||
rows[i] = row.map(param => new ParamFC(param))
|
||||
}
|
||||
return rows
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
onParamSubmit(row: ParamFC[]) {
|
||||
row.map(paramFC => this.commandsApi.setParam$(paramFC.api()).subscribe());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<h3>{{ data.title }}</h3>
|
||||
<div fxLayoutGap="10px" mat-dialog-actions fxLayout="row" fxLayoutAlign="center start">
|
||||
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Ok</button>
|
||||
<button mat-button (click)="onNoClick()">Cancel</button>
|
||||
</div>
|
||||
@@ -0,0 +1,21 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
|
||||
@Component({
|
||||
selector: 'app-confirm',
|
||||
templateUrl: './confirm.component.html',
|
||||
styleUrls: ['./confirm.component.css']
|
||||
})
|
||||
export class ConfirmDialogComponent {
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<void>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||
}
|
||||
|
||||
onNoClick() {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<div fxLayout="column" fxLayoutAlign="center center">
|
||||
<h3>{{ data.title }}</h3>
|
||||
<pre [innerHTML]="data.body"></pre>
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
|
||||
@Component({
|
||||
selector: 'app-error-dialog',
|
||||
templateUrl: './error-dialog.component.html',
|
||||
styleUrls: ['./error-dialog.component.css'],
|
||||
})
|
||||
export class ErrorDialogComponent {
|
||||
JSON = JSON
|
||||
title = 'Angular-Interceptor';
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||
}
|
||||
}
|
||||
36
common/utils/websrv/frontend/src/app/controls/cmd.control.ts
Normal file
36
common/utils/websrv/frontend/src/app/controls/cmd.control.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { ICommand } from '../api/commands.api';
|
||||
|
||||
const enum CmdFCN {
|
||||
name = 'name',
|
||||
confirm = 'confirm'
|
||||
}
|
||||
|
||||
export class CmdCtrl extends FormGroup {
|
||||
|
||||
confirm?: string
|
||||
|
||||
constructor(cmd: ICommand) {
|
||||
super({});
|
||||
|
||||
this.addControl(CmdFCN.name, new FormControl(cmd.name));
|
||||
this.confirm = cmd.confirm
|
||||
}
|
||||
|
||||
api() {
|
||||
const doc: ICommand = {
|
||||
name: this.nameFC.value
|
||||
};
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
get nameFC() {
|
||||
return this.get(CmdFCN.name) as FormControl;
|
||||
}
|
||||
|
||||
set nameFC(fc: FormControl) {
|
||||
this.setControl(CmdFCN.name, fc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { IArgType, IColumn } from '../api/commands.api';
|
||||
|
||||
export class Param {
|
||||
|
||||
constructor(
|
||||
public value: string,
|
||||
public col: IColumn,
|
||||
public rawIndex: number,
|
||||
public moduleName: string,
|
||||
public cmdName: string) { }
|
||||
}
|
||||
|
||||
export class ParamFC extends FormControl {
|
||||
|
||||
constructor(public param: Param) {
|
||||
super(param.value);
|
||||
}
|
||||
|
||||
api() {
|
||||
this.param.value = this.value
|
||||
return this.param
|
||||
}
|
||||
}
|
||||
|
||||
67
common/utils/websrv/frontend/src/app/controls/var.control.ts
Normal file
67
common/utils/websrv/frontend/src/app/controls/var.control.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { IVariable } from '../api/commands.api';
|
||||
|
||||
|
||||
const enum VariablesFCN {
|
||||
name = 'name',
|
||||
value = "value",
|
||||
type = "type",
|
||||
modifiable = "modifiable"
|
||||
}
|
||||
|
||||
|
||||
export class VarCtrl extends FormGroup {
|
||||
|
||||
constructor(ivar: IVariable) {
|
||||
super({});
|
||||
|
||||
this.addControl(VariablesFCN.name, new FormControl(ivar.name));
|
||||
this.addControl(VariablesFCN.value, new FormControl(ivar.value));
|
||||
this.addControl(VariablesFCN.type, new FormControl(ivar.type));
|
||||
this.addControl(VariablesFCN.modifiable, new FormControl(ivar.modifiable));
|
||||
}
|
||||
|
||||
api() {
|
||||
const doc: IVariable = {
|
||||
name: this.nameFC.value,
|
||||
value: String(this.valueFC.value), //FIXME
|
||||
type: this.typeFC.value,
|
||||
modifiable: this.modifiableFC.value
|
||||
};
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
get nameFC() {
|
||||
return this.get(VariablesFCN.name) as FormControl;
|
||||
}
|
||||
|
||||
set nameFC(control: FormControl) {
|
||||
this.setControl(VariablesFCN.name, control);
|
||||
}
|
||||
|
||||
get valueFC() {
|
||||
return this.get(VariablesFCN.value) as FormControl;
|
||||
}
|
||||
|
||||
set valueFC(control: FormControl) {
|
||||
this.setControl(VariablesFCN.value, control);
|
||||
}
|
||||
|
||||
get typeFC() {
|
||||
return this.get(VariablesFCN.type) as FormControl;
|
||||
}
|
||||
|
||||
set typeFC(control: FormControl) {
|
||||
this.setControl(VariablesFCN.type, control);
|
||||
}
|
||||
|
||||
get modifiableFC() {
|
||||
return this.get(VariablesFCN.modifiable) as FormControl;
|
||||
}
|
||||
|
||||
set modifiableFC(control: FormControl) {
|
||||
this.setControl(VariablesFCN.modifiable, control);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import { DialogService as DialogService } from '../services/dialog.service';
|
||||
|
||||
@Injectable()
|
||||
export class ErrorInterceptor implements HttpInterceptor {
|
||||
constructor(public dialogService: DialogService) { }
|
||||
|
||||
intercept(request: HttpRequest<unknown>, next: HttpHandler) {
|
||||
return next.handle(request).pipe(
|
||||
// tap((event: HttpEvent<any>) => {
|
||||
// if (event instanceof HttpResponse) {
|
||||
// switch (event.status) {
|
||||
// case 200:
|
||||
// case 201:
|
||||
// this.log(GREEN, request.method + ' ' + event.status + ' Success');
|
||||
// this.dialogService.openSnackBar(request.method + ' ' + event.status + ' Success');
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// // return throwError(event.body);
|
||||
// }
|
||||
// }),
|
||||
catchError((error: HttpErrorResponse) => {
|
||||
switch (error.status) {
|
||||
case 400:
|
||||
case 403:
|
||||
case 501:
|
||||
case 500:
|
||||
this.log(YELLOW, request.method + ' ' + error.status + ' Error: ' + error.error);
|
||||
this.dialogService.openErrorDialog(error);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return throwError(error.error);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
private log = (color: string, txt: string) => console.log(color, '[API] ' + txt);
|
||||
}
|
||||
|
||||
const RED = '\x1b[31m%s\x1b[0m';
|
||||
const GREEN = '\x1b[32m%s\x1b[0m';
|
||||
const YELLOW = '\x1b[33m%s\x1b[0m';
|
||||
const MAGENTA = '\x1b[35m%s\x1b[0m';
|
||||
const CYAN = '\x1b[36m%s%s\x1b[0m';
|
||||
@@ -0,0 +1,8 @@
|
||||
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { ErrorInterceptor } from './error.interceptor';
|
||||
import { SpinnerInterceptor } from './spinner.interceptor';
|
||||
|
||||
export const InterceptorProviders = [
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: SpinnerInterceptor, multi: true },
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
|
||||
];
|
||||
@@ -0,0 +1,29 @@
|
||||
import { finalize } from 'rxjs/operators';
|
||||
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { LoadingService } from '../services/loading.service';
|
||||
|
||||
@Injectable()
|
||||
export class SpinnerInterceptor implements HttpInterceptor {
|
||||
activeRequests = 0;
|
||||
|
||||
constructor(private loadingService: LoadingService) { }
|
||||
|
||||
intercept(request: HttpRequest<unknown>, next: HttpHandler) {
|
||||
if (this.activeRequests === 0) {
|
||||
this.loadingService.startLoading();
|
||||
}
|
||||
|
||||
this.activeRequests++;
|
||||
|
||||
return next.handle(request).pipe(
|
||||
finalize(() => {
|
||||
this.activeRequests--;
|
||||
if (this.activeRequests === 0) {
|
||||
this.loadingService.stopLoading();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { of } from 'rxjs/internal/observable/of';
|
||||
import { tap } from 'rxjs/internal/operators/tap';
|
||||
import { IResp } from '../api/commands.api';
|
||||
import { ConfirmDialogComponent } from '../components/confirm/confirm.component';
|
||||
import { ErrorDialogComponent } from '../components/error-dialog/error-dialog.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DialogService {
|
||||
public isDialogOpen = false;
|
||||
|
||||
constructor(
|
||||
private _dialog: MatDialog,
|
||||
private _snackBar: MatSnackBar,
|
||||
) { }
|
||||
|
||||
openErrorDialog(error: HttpErrorResponse): Observable<any> {
|
||||
if (this.isDialogOpen) {
|
||||
return of(undefined);
|
||||
}
|
||||
|
||||
this.isDialogOpen = true;
|
||||
|
||||
return this._dialog.open(ErrorDialogComponent, {
|
||||
width: '900px',
|
||||
data: {
|
||||
title: error.status + ' Error',
|
||||
body: error.error,
|
||||
},
|
||||
}).afterClosed()
|
||||
.pipe(tap(() => this.isDialogOpen = false));
|
||||
}
|
||||
|
||||
openRespDialog(resp: IResp, title?: string): Observable<IResp> {
|
||||
if (this.isDialogOpen || !resp.display.length) {
|
||||
return of(resp);
|
||||
}
|
||||
|
||||
this.isDialogOpen = true;
|
||||
|
||||
const dialogRef = this._dialog.open(ErrorDialogComponent, {
|
||||
width: '900px',
|
||||
height: '80%',
|
||||
data: {
|
||||
title: title,
|
||||
body: resp.display!.join("</p><p>")
|
||||
},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((_) => {
|
||||
console.log('The dialog was closed');
|
||||
this.isDialogOpen = false;
|
||||
});
|
||||
|
||||
return of(resp)
|
||||
}
|
||||
|
||||
openSnackBar(title: string): void {
|
||||
this._snackBar.open(title, undefined, {
|
||||
duration: 500,
|
||||
horizontalPosition: 'center',
|
||||
verticalPosition: 'bottom',
|
||||
});
|
||||
}
|
||||
|
||||
openConfirmDialog(question: string) {
|
||||
if (this.isDialogOpen) {
|
||||
return of(undefined);
|
||||
}
|
||||
|
||||
this.isDialogOpen = true;
|
||||
|
||||
return this._dialog.open(ConfirmDialogComponent, {
|
||||
width: '300px',
|
||||
data: { title: question }
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(tap(() => this.isDialogOpen = false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LoadingService {
|
||||
isLoading$ = new Subject<boolean>();
|
||||
|
||||
constructor() { }
|
||||
|
||||
startLoading() {
|
||||
this.isLoading$.next(true);
|
||||
}
|
||||
|
||||
stopLoading() {
|
||||
this.isLoading$.next(false);
|
||||
}
|
||||
}
|
||||
0
common/utils/websrv/frontend/src/assets/.gitkeep
Normal file
0
common/utils/websrv/frontend/src/assets/.gitkeep
Normal file
@@ -0,0 +1,8 @@
|
||||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||
// The list of file replacements can be found in `angular.json`.
|
||||
|
||||
export const environment = {
|
||||
production: true,
|
||||
backend: 'http://localhost:8090' //FIXME
|
||||
};
|
||||
19
common/utils/websrv/frontend/src/environments/environment.ts
Normal file
19
common/utils/websrv/frontend/src/environments/environment.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||
// The list of file replacements can be found in `angular.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
backend: 'http://192.168.1.67:8090'
|
||||
// backend: 'http://10.133.10.152:8090'
|
||||
// backend: 'http://10.130.163.206:8090'
|
||||
};
|
||||
|
||||
/*
|
||||
* For easier debugging in development mode, you can import the following file
|
||||
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
|
||||
*
|
||||
* This import should be commented out in production mode because it will have a negative impact
|
||||
* on performance if an error is thrown.
|
||||
*/
|
||||
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
||||
BIN
common/utils/websrv/frontend/src/favicon.ico
Normal file
BIN
common/utils/websrv/frontend/src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
18
common/utils/websrv/frontend/src/index.html
Normal file
18
common/utils/websrv/frontend/src/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>SoftmodemNgx</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet" />
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|
||||
</head>
|
||||
|
||||
<body class="mat-typography">
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
13
common/utils/websrv/frontend/src/main.ts
Normal file
13
common/utils/websrv/frontend/src/main.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic()
|
||||
.bootstrapModule(AppModule)
|
||||
.catch((err) => console.error(err));
|
||||
65
common/utils/websrv/frontend/src/polyfills.ts
Normal file
65
common/utils/websrv/frontend/src/polyfills.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* This file includes polyfills needed by Angular and is loaded before the app.
|
||||
* You can add your own extra polyfills to this file.
|
||||
*
|
||||
* This file is divided into 2 sections:
|
||||
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
|
||||
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
|
||||
* file.
|
||||
*
|
||||
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
|
||||
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
|
||||
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
|
||||
*
|
||||
* Learn more in https://angular.io/guide/browser-support
|
||||
*/
|
||||
|
||||
/***************************************************************************************************
|
||||
* BROWSER POLYFILLS
|
||||
*/
|
||||
|
||||
/**
|
||||
* IE11 requires the following for NgClass support on SVG elements
|
||||
*/
|
||||
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
||||
|
||||
/**
|
||||
* Web Animations `@angular/platform-browser/animations`
|
||||
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
||||
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
||||
*/
|
||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
||||
|
||||
/**
|
||||
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||
* because those flags need to be set before `zone.js` being loaded, and webpack
|
||||
* will put import in the top of bundle, so user need to create a separate file
|
||||
* in this directory (for example: zone-flags.ts), and put the following flags
|
||||
* into that file, and then add the following code before importing zone.js.
|
||||
* import './zone-flags';
|
||||
*
|
||||
* The flags allowed in zone-flags.ts are listed here.
|
||||
*
|
||||
* The following flags will work for all browsers.
|
||||
*
|
||||
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||
*
|
||||
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||
*
|
||||
* (window as any).__Zone_enable_cross_context_check = true;
|
||||
*
|
||||
*/
|
||||
|
||||
/***************************************************************************************************
|
||||
* Zone JS is required by default for Angular itself.
|
||||
*/
|
||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
* APPLICATION IMPORTS
|
||||
*/
|
||||
10
common/utils/websrv/frontend/src/styles.css
Normal file
10
common/utils/websrv/frontend/src/styles.css
Normal file
@@ -0,0 +1,10 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: Roboto, 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
23
common/utils/websrv/frontend/src/test.ts
Normal file
23
common/utils/websrv/frontend/src/test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: {
|
||||
context(
|
||||
path: string,
|
||||
deep?: boolean,
|
||||
filter?: RegExp,
|
||||
): {
|
||||
keys(): string[];
|
||||
<T>(id: string): T;
|
||||
};
|
||||
};
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
||||
10
common/utils/websrv/frontend/tsconfig.app.json
Normal file
10
common/utils/websrv/frontend/tsconfig.app.json
Normal file
@@ -0,0 +1,10 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
},
|
||||
"files": ["src/main.ts", "src/polyfills.ts"],
|
||||
"include": ["src/**/*.d.ts"]
|
||||
}
|
||||
30
common/utils/websrv/frontend/tsconfig.json
Normal file
30
common/utils/websrv/frontend/tsconfig.json
Normal file
@@ -0,0 +1,30 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"outDir": "./dist/out-tsc",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"downlevelIteration": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"target": "es2015",
|
||||
"module": "es2020",
|
||||
"lib": [
|
||||
"es2018",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
10
common/utils/websrv/frontend/tsconfig.spec.json
Normal file
10
common/utils/websrv/frontend/tsconfig.spec.json
Normal file
@@ -0,0 +1,10 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": ["jasmine"]
|
||||
},
|
||||
"files": ["src/test.ts", "src/polyfills.ts"],
|
||||
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
|
||||
}
|
||||
805
common/utils/websrv/websrv.c
Normal file
805
common/utils/websrv/websrv.c
Normal file
@@ -0,0 +1,805 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file common/utils/websrv/websrv.c
|
||||
* \brief: implementation of web API
|
||||
* \author Francois TABURET
|
||||
* \date 2022
|
||||
* \version 0.1
|
||||
* \company NOKIA BellLabs France
|
||||
* \email: francois.taburet@nokia-bell-labs.com
|
||||
* \note
|
||||
* \warning
|
||||
*/
|
||||
#include <libgen.h>
|
||||
#include <jansson.h>
|
||||
#include <ulfius.h>
|
||||
#include "common/config/config_userapi.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "common/utils/websrv/websrv.h"
|
||||
#include "executables/softmodem-common.h"
|
||||
#define WEBSERVERCODE
|
||||
#include "common/utils/telnetsrv/telnetsrv.h"
|
||||
|
||||
|
||||
static websrv_params_t websrvparams;
|
||||
static websrv_printf_t websrv_printf_buff;
|
||||
paramdef_t websrvoptions[] = {
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/* configuration parameters for telnet utility */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
{"listenaddr", "<listen ip address>\n", 0, uptr:&websrvparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
|
||||
{"listenport", "<local port>\n", 0, uptr:&(websrvparams.listenport), defuintval:8090, TYPE_UINT, 0 },
|
||||
{"priority", "<scheduling policy (0-99)\n", 0, iptr:&websrvparams.priority, defuintval:0, TYPE_INT, 0 },
|
||||
{"debug", "<debug level>\n", 0, uptr:&websrvparams.dbglvl, defuintval:0, TYPE_UINT, 0 },
|
||||
{"url", "<server url>\n", 0, strptr:&websrvparams.url, defstrval:"index.html", TYPE_STRING, 0 },
|
||||
{"cert", "<cert file>\n", 0, strptr:&websrvparams.certfile, defstrval:NULL, TYPE_STRING, 0 },
|
||||
{"key", "<key file>\n", 0, strptr:&websrvparams.keyfile, defstrval:NULL, TYPE_STRING, 0 },
|
||||
};
|
||||
int websrv_add_endpoint( char **http_method, int num_method, const char * url_prefix,const char * url_format,
|
||||
int (* callback_function[])(const struct _u_request * request,
|
||||
struct _u_response * response,
|
||||
void * user_data),
|
||||
void * user_data) ;
|
||||
|
||||
void register_module_endpoints(cmdparser_t *module) ;
|
||||
|
||||
void websrv_printjson(char * label, json_t *jsonobj){
|
||||
char *jstr = json_dumps(jsonobj,0);
|
||||
LOG_I(UTIL,"[websrv] %s:%s\n", label, (jstr==NULL)?"??\n":jstr);
|
||||
free(jstr);
|
||||
}
|
||||
void websrv_gettbldata_response(struct _u_response * response,webdatadef_t * wdata) ;
|
||||
/*-----------------------------------*/
|
||||
/* build a json body in a response */
|
||||
void websrv_jbody( struct _u_response * response, json_t *jbody) {
|
||||
websrv_printjson( (char *)__FUNCTION__ , jbody);
|
||||
int us=ulfius_add_header_to_response(response,"content-type" ,"application/json");
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 500, "Internal server error (ulfius_add_header_to_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set response header type ulfius error %d \n",us);
|
||||
}
|
||||
us=ulfius_set_json_body_response(response, 200, jbody);
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 500, "Internal server error (ulfius_set_json_body_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set body response ulfius error %d \n",us);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/* format a json string array in a response body */
|
||||
int websrv_string_response(char *astring, struct _u_response * response, int httpstatus) {
|
||||
json_t *jstr = json_array();
|
||||
char *tokctx;
|
||||
char *aline=strtok_r(astring,"\n",&tokctx);
|
||||
while(aline != NULL) {
|
||||
json_t *jline=json_string(aline);
|
||||
json_array_append_new(jstr,jline);
|
||||
aline=strtok_r(NULL,"\n",&tokctx);
|
||||
}
|
||||
json_t *jbody = json_pack("{s:o}","display",jstr);
|
||||
websrv_jbody(response,jbody);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* */
|
||||
void websrv_printf_start(struct _u_response * response, int buffsize ) {
|
||||
pthread_mutex_lock(&(websrv_printf_buff.mutex));
|
||||
websrv_printf_buff.buff = malloc(buffsize);
|
||||
websrv_printf_buff.buffptr = websrv_printf_buff.buff;
|
||||
websrv_printf_buff.buffsize = buffsize;
|
||||
websrv_printf_buff.response = response;
|
||||
}
|
||||
|
||||
void websrv_printf_atpos( int pos, const char *message, ...) {
|
||||
va_list va_args;
|
||||
va_start(va_args, message);
|
||||
|
||||
websrv_printf_buff.buffptr = websrv_printf_buff.buff + pos + vsnprintf( websrv_printf_buff.buff + pos, websrv_printf_buff.buffsize - pos -1,message, va_args );
|
||||
|
||||
va_end(va_args);
|
||||
return ;
|
||||
}
|
||||
|
||||
void websrv_printf( const char *message, ...) {
|
||||
va_list va_args;
|
||||
va_start(va_args, message);
|
||||
websrv_printf_buff.buffptr += vsnprintf( websrv_printf_buff.buffptr,
|
||||
websrv_printf_buff.buffsize - (websrv_printf_buff.buffptr - websrv_printf_buff.buff) - 1,message, va_args );
|
||||
|
||||
va_end(va_args);
|
||||
return ;
|
||||
}
|
||||
|
||||
void websrv_printf_end(int httpstatus ) {
|
||||
if (httpstatus >= 200 && httpstatus < 300) {
|
||||
LOG_I(UTIL,"[websrv] %s\n",websrv_printf_buff.buff);
|
||||
websrv_string_response(websrv_printf_buff.buff, websrv_printf_buff.response, httpstatus) ;
|
||||
} else {
|
||||
LOG_W(UTIL,"[websrv] %s\n",websrv_printf_buff.buff);
|
||||
ulfius_set_binary_body_response(websrv_printf_buff.response,httpstatus , websrv_printf_buff.buff,websrv_printf_buff.buffptr - websrv_printf_buff.buff);
|
||||
}
|
||||
|
||||
free(websrv_printf_buff.buff);
|
||||
websrv_printf_buff.buff=NULL;
|
||||
pthread_mutex_unlock(&(websrv_printf_buff.mutex));
|
||||
|
||||
}
|
||||
|
||||
/* buid a response via a webdatadef_t structure containing one string column */
|
||||
void websrv_printf_tbl_end(int httpstatus ) {
|
||||
webdatadef_t pdata;
|
||||
char *tokctx;
|
||||
|
||||
pdata.numcols=1;
|
||||
pdata.numlines=0;
|
||||
pdata.columns[0].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY;
|
||||
pdata.columns[0].coltitle[0]=0;
|
||||
for ( char *alineptr=strtok_r(websrv_printf_buff.buff,"\n",&tokctx); alineptr != NULL ; alineptr=strtok_r(NULL,"\n",&tokctx) ) {
|
||||
pdata.lines[pdata.numlines].val[0]=alineptr;
|
||||
pdata.numlines++;
|
||||
}
|
||||
websrv_gettbldata_response(websrv_printf_buff.response,&pdata);
|
||||
free(websrv_printf_buff.buff);
|
||||
websrv_printf_buff.buff=NULL;
|
||||
pthread_mutex_unlock(&(websrv_printf_buff.mutex));
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------*/
|
||||
/* format a json response from a result table returned from a call to a telnet server command */
|
||||
void websrv_getdata_response(struct _u_response * response,webdatadef_t * wdata) {
|
||||
json_t *jdata = json_array();
|
||||
|
||||
for (int i=0; i<wdata->numlines ; i++) {
|
||||
json_t *kv=json_object();
|
||||
for (int j=0; j<wdata->numcols; j++) {
|
||||
json_t *jval;
|
||||
if(wdata->columns[j].coltype & TELNET_CHECKVAL_BOOL)
|
||||
jval=json_boolean(wdata->lines[i].val[j]);
|
||||
else if (wdata->columns[j].coltype & TELNET_VARTYPE_STRING)
|
||||
jval=json_string(wdata->lines[i].val[j]);
|
||||
// else if (wdata->columns[j].coltype == TELNET_VARTYPE_DOUBLE)
|
||||
// jval=json_real((double)(wdata->lines[i].val[j]));
|
||||
else
|
||||
jval=json_integer((long)(wdata->lines[i].val[j]));
|
||||
json_object_set_new(kv, wdata->columns[j].coltitle, jval);
|
||||
}
|
||||
json_array_append_new(jdata,kv);
|
||||
}
|
||||
json_t *jbody=json_pack("{s:[o],s:o}","display",json_null(),"logs",jdata);
|
||||
websrv_jbody(response,jbody);
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------------------*/
|
||||
/* format a json response from a result table returned from a call to a telnet server command */
|
||||
void websrv_gettbldata_response(struct _u_response * response,webdatadef_t * wdata) {
|
||||
json_t *jcols = json_array();
|
||||
json_t *jdata = json_array();
|
||||
char *coltype;
|
||||
for (int i=0; i<wdata->numcols; i++) {
|
||||
if(wdata->columns[i].coltype & TELNET_CHECKVAL_BOOL)
|
||||
coltype="boolean";
|
||||
else if (wdata->columns[i].coltype & TELNET_VARTYPE_STRING)
|
||||
coltype="string";
|
||||
else
|
||||
coltype="number";
|
||||
json_t *acol=json_pack("{s:s,s:s,s:b}","name",wdata->columns[i].coltitle,"type",coltype,
|
||||
"modifiable",( wdata->columns[i].coltype & TELNET_CHECKVAL_RDONLY)?0:1 );
|
||||
json_array_append_new(jcols,acol);
|
||||
}
|
||||
for (int i=0; i<wdata->numlines ; i++) {
|
||||
json_t *jval;
|
||||
json_t *jline=json_array();
|
||||
for (int j=0; j<wdata->numcols; j++) {
|
||||
if(wdata->columns[j].coltype & TELNET_CHECKVAL_BOOL)
|
||||
jval=json_string(wdata->lines[i].val[j]);
|
||||
else if (wdata->columns[j].coltype & TELNET_VARTYPE_STRING)
|
||||
jval=json_string(wdata->lines[i].val[j]);
|
||||
// else if (wdata->columns[j].coltype == TELNET_VARTYPE_DOUBLE)
|
||||
// jval=json_real((double)(wdata->lines[i].val[j]));
|
||||
else
|
||||
jval=json_integer((long)(wdata->lines[i].val[j]));
|
||||
json_array_append_new(jline,jval);
|
||||
}
|
||||
json_array_append_new(jdata,jline);
|
||||
}
|
||||
json_t *jbody=json_pack("{s:[],s:{s:o,s:o}}","display","table","columns",jcols,"rows",jdata);
|
||||
websrv_jbody(response,jbody);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*/
|
||||
/* callbacks and utility functions to stream a file */
|
||||
char * websrv_read_file(const char * filename) {
|
||||
char * buffer = NULL;
|
||||
long length;
|
||||
FILE * f = fopen (filename, "rb");
|
||||
if (f != NULL) {
|
||||
fseek (f, 0, SEEK_END);
|
||||
length = ftell (f);
|
||||
fseek (f, 0, SEEK_SET);
|
||||
buffer = malloc (length + 1);
|
||||
if (buffer != NULL) {
|
||||
int rlen = fread (buffer, 1, length, f);
|
||||
if (rlen !=length) {
|
||||
free(buffer);
|
||||
LOG_E(UTIL,"[websrv] couldn't read %s_\n",filename);
|
||||
return NULL;
|
||||
}
|
||||
buffer[length] = '\0';
|
||||
}
|
||||
fclose (f);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
/* callbacks to send static streams */
|
||||
static ssize_t callback_stream(void * cls, uint64_t pos, char * buf, size_t max) {
|
||||
if (cls != NULL) {
|
||||
return fread (buf, sizeof(char), max, (FILE *)cls);
|
||||
} else {
|
||||
return U_STREAM_END;
|
||||
}
|
||||
}
|
||||
|
||||
static void callback_stream_free(void * cls) {
|
||||
if (cls != NULL) {
|
||||
fclose((FILE *)cls);
|
||||
}
|
||||
}
|
||||
|
||||
FILE *websrv_getfile(char *filename, struct _u_response * response) {
|
||||
FILE *f = fopen (filename, "rb");
|
||||
int length;
|
||||
|
||||
if (f) {
|
||||
fseek (f, 0, SEEK_END);
|
||||
length = ftell (f);
|
||||
fseek (f, 0, SEEK_SET);
|
||||
LOG_I(UTIL,"[websrv] sending %d bytes from %s\n", length, filename);
|
||||
} else {
|
||||
LOG_E(UTIL,"[websrv] couldn't open %s\n",filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *content_type="text/html";
|
||||
size_t nl = strlen(filename);
|
||||
if ( nl >= 3 && !strcmp(filename + nl - 3, "css"))
|
||||
content_type="text/css";
|
||||
|
||||
int ust=ulfius_add_header_to_response(response,"content-type" ,content_type);
|
||||
if (ust != U_OK){
|
||||
ulfius_set_string_body_response(response, 501, "Internal server error (ulfius_add_header_to_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set response header type ulfius error %d \n",ust);
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ust=ulfius_set_stream_response(response, 200, callback_stream, callback_stream_free, length, 1024, f);
|
||||
if(ust != U_OK) {
|
||||
LOG_E(UTIL,"[websrv] ulfius_set_stream_response error %d\n",ust);
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
return f;
|
||||
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* callback processing main ((initial) url (<address>/<websrvparams.url> */
|
||||
int websrv_callback_get_mainurl(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
LOG_I(UTIL,"[websrv] Requested file is: %s\n",request->http_url);
|
||||
|
||||
FILE *f = websrv_getfile(websrvparams.url,response) ;
|
||||
if (f == NULL)
|
||||
return U_CALLBACK_ERROR;
|
||||
return U_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
/* default callback tries to find a file in the web server repo (path exctracted from <websrvparams.url>) and if found streams it */
|
||||
int websrv_callback_default (const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
LOG_I(UTIL,"[websrv] Requested file is: %s %s\n",request->http_verb,request->http_url);
|
||||
if (request->map_post_body != NULL)
|
||||
for (int i=0; i<u_map_count(request->map_post_body) ; i++)
|
||||
LOG_I(UTIL,"[websrv] POST parameter %i %s : %s\n",i,u_map_enum_keys(request->map_post_body)[i], u_map_enum_values(request->map_post_body)[i] );
|
||||
char *tmpurl = strdup(websrvparams.url);
|
||||
char *srvdir = dirname(tmpurl);
|
||||
if (srvdir==NULL) {
|
||||
LOG_E(UTIL,"[websrv] Cannot extract dir name from %s requested file is %s\n",websrvparams.url,request->http_url);
|
||||
return U_CALLBACK_ERROR;
|
||||
}
|
||||
char *fpath = malloc( strlen(request->http_url)+strlen(srvdir)+2);
|
||||
sprintf(fpath,"%s/%s",srvdir, request->http_url);
|
||||
FILE *f = websrv_getfile(fpath,response) ;
|
||||
free(fpath);
|
||||
free(tmpurl);
|
||||
if (f == NULL)
|
||||
return U_CALLBACK_ERROR;
|
||||
return U_CALLBACK_CONTINUE;
|
||||
}
|
||||
/* callback processing url (<address>/oaisoftmodem/:module/variables or <address>/oaisoftmodem/:module/commands) */
|
||||
int websrv_callback_newmodule(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
LOG_I(UTIL,"[websrv] callback_newmodule received %s %s\n",request->http_verb,request->http_url);
|
||||
if (user_data == NULL) {
|
||||
ulfius_set_string_body_response(response, 500, "Cannot access oai softmodem data");
|
||||
LOG_E(UTIL,"[websrv] callback_newmodule: user-data is NULL");
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
telnetsrv_params_t *telnetparams = (telnetsrv_params_t *)user_data;
|
||||
for (int i=0; i<u_map_count(request->map_url) ; i++) {
|
||||
LOG_I(UTIL,"[websrv] url element %i %s : %s\n",i,u_map_enum_keys(request->map_url)[i], u_map_enum_values(request->map_url)[i] );
|
||||
if ( strcmp(u_map_enum_keys(request->map_url)[i],"module") == 0) {
|
||||
for (int j=0; telnetparams->CmdParsers[j].cmd != NULL; j++) {
|
||||
/* found the module in the telnet server module array, it was likely not registered at init time */
|
||||
if (strcmp(telnetparams->CmdParsers[j].module, u_map_enum_values(request->map_url)[i]) == 0) {
|
||||
register_module_endpoints( &(telnetparams->CmdParsers[j]) );
|
||||
return U_CALLBACK_CONTINUE;
|
||||
}
|
||||
} /* for j */
|
||||
}
|
||||
} /* for i */
|
||||
ulfius_set_string_body_response(response, 500, "Request for an unknown module");
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
|
||||
/* callback processing url (<address>/oaisoftmodem/module/variables or <address>/oaisoftmodem/module/commands), options method */
|
||||
int websrv_callback_okset_softmodem_cmdvar(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
LOG_I(UTIL,"[websrv] : callback_okset_softmodem_cmdvar received %s %s\n",request->http_verb,request->http_url);
|
||||
for (int i=0; i<u_map_count(request->map_header) ; i++)
|
||||
LOG_I(UTIL,"[websrv] header variable %i %s : %s\n",i,u_map_enum_keys(request->map_header)[i], u_map_enum_values(request->map_header)[i] );
|
||||
int us=ulfius_add_header_to_response(response,"Access-Control-Request-Method" ,"POST");
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 501, "Internal server error (ulfius_add_header_to_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set response header type ulfius error %d \n",us);
|
||||
}
|
||||
us=ulfius_add_header_to_response(response,"Access-Control-Allow-Headers", "content-type");
|
||||
us=ulfius_set_empty_body_response(response, 200);
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 501, "Internal server error (ulfius_set_empty_body_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set empty body response ulfius error %d \n",us);
|
||||
}
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
int websrv_callback_set_softmodemvar(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
LOG_I(UTIL,"[websrv] : callback_set_softmodemvar received %s %s\n",request->http_verb,request->http_url);
|
||||
websrv_printf_start(response,256);
|
||||
json_error_t jserr;
|
||||
json_t* jsbody = ulfius_get_json_body_request (request, &jserr);
|
||||
int httpstatus=404;
|
||||
if (jsbody == NULL) {
|
||||
websrv_printf("cannot find json body in %s %s\n",request->http_url, jserr.text );
|
||||
httpstatus=400;
|
||||
} else {
|
||||
websrv_printjson("callback_set_softmodemvar: ",jsbody);
|
||||
if (user_data == NULL) {
|
||||
httpstatus=500;
|
||||
websrv_printf("%s: NULL user data",request->http_url);
|
||||
} else {
|
||||
cmdparser_t * modulestruct = (cmdparser_t *)user_data;
|
||||
json_t *J=json_object_get(jsbody, "name");
|
||||
const char *vname=json_string_value(J);
|
||||
for ( telnetshell_vardef_t *var = modulestruct->var; var->varvalptr!= NULL ;var++) {
|
||||
if (strncmp(var->varname,vname,TELNET_CMD_MAXSIZE) == 0){
|
||||
J=json_object_get(jsbody, "value");
|
||||
if(J!=NULL) {
|
||||
if (json_is_string(J)) {
|
||||
const char *vval=json_string_value(J);
|
||||
websrv_printf("var %s set to ",var->varname);
|
||||
int st=telnet_setvarvalue(var,(char *)vval, websrv_printf );
|
||||
if (st>=0) {
|
||||
httpstatus=200;
|
||||
} else {
|
||||
httpstatus=500;
|
||||
}
|
||||
} else if (json_is_integer(J)) {
|
||||
json_int_t i = json_integer_value(J);
|
||||
switch(var->vartype) {
|
||||
case TELNET_VARTYPE_INT64:
|
||||
*(int64_t *)var->varvalptr=(int64_t)i;
|
||||
break;
|
||||
case TELNET_VARTYPE_INT32:
|
||||
*(int32_t *)var->varvalptr=(int32_t)i;
|
||||
break;
|
||||
case TELNET_VARTYPE_INT16:
|
||||
*(int16_t *)var->varvalptr=(int16_t)i;
|
||||
break;
|
||||
case TELNET_VARTYPE_INT8:
|
||||
*(int8_t *)var->varvalptr=(int8_t)i;
|
||||
break;
|
||||
case TELNET_VARTYPE_UINT:
|
||||
*(unsigned int *)var->varvalptr=(unsigned int)i;
|
||||
break;
|
||||
default:
|
||||
httpstatus=500;
|
||||
websrv_printf(" Cannot set var %s, integer type mismatch\n",vname );
|
||||
break;
|
||||
}
|
||||
} else if (json_is_real(J)) {
|
||||
double lf = json_real_value(J);
|
||||
if(var->vartype==TELNET_VARTYPE_DOUBLE) {
|
||||
*(double *)var->varvalptr = lf;
|
||||
httpstatus=200;
|
||||
websrv_printf(" Var %s, set to %g\n",vname, *(double *)var->varvalptr );
|
||||
} else {
|
||||
httpstatus=500;
|
||||
websrv_printf(" Cannot set var %s, real type mismatch\n",vname );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
httpstatus=500;
|
||||
websrv_printf("Cannot set var %s, json object is NULL\n",vname );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}//for
|
||||
}//user_data
|
||||
} //sbody
|
||||
websrv_printf_end(httpstatus);
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
/* callback processing module url (<address>/oaisoftmodem/module/commands), post method */
|
||||
int websrv_processwebfunc(struct _u_response * response, cmdparser_t * modulestruct ,telnetshell_cmddef_t *cmd) {
|
||||
LOG_I(UTIL,"[websrv] : executing command %s %s\n",modulestruct->module,cmd->cmdname);
|
||||
|
||||
if ( cmd->cmdflags & TELNETSRV_CMDFLAG_GETWEBDATA ) {
|
||||
webdatadef_t wdata;
|
||||
memset(&wdata,0,sizeof(wdata));
|
||||
cmd->webfunc_getdata(cmd->cmdname,websrvparams.dbglvl,(webdatadef_t *)&wdata);
|
||||
websrv_getdata_response(response,&wdata);
|
||||
} else if (cmd->cmdflags & TELNETSRV_CMDFLAG_GETWEBTBLDATA) {
|
||||
webdatadef_t wdata;
|
||||
memset(&wdata,0,sizeof(wdata));
|
||||
cmd->webfunc_getdata(cmd->cmdname,websrvparams.dbglvl,(webdatadef_t *)&wdata);
|
||||
websrv_gettbldata_response(response,&wdata);
|
||||
} else {
|
||||
websrv_printf_start(response,16384);
|
||||
char *sptr=index(cmd->cmdname,' ');
|
||||
cmd->cmdfunc((sptr==NULL)?cmd->cmdname:sptr,websrvparams.dbglvl,websrv_printf);
|
||||
if (cmd->cmdflags & TELNETSRV_CMDFLAG_PRINTWEBTBLDATA)
|
||||
websrv_printf_tbl_end(200);
|
||||
else
|
||||
websrv_printf_end(200);
|
||||
}
|
||||
return 200;
|
||||
}
|
||||
|
||||
int websrv_callback_exec_softmodemcmd(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
LOG_I(UTIL,"[websrv] : callback_exec_softmodemcmd received %s %s\n",request->http_verb,request->http_url);
|
||||
if (user_data == NULL) {
|
||||
ulfius_set_string_body_response(response, 500, "Cannot access oai softmodem data");
|
||||
LOG_E(UTIL,"[websrv] callback_exec_softmodemcmd: user-data is NULL");
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
cmdparser_t * modulestruct = (cmdparser_t *)user_data;
|
||||
json_t* jsbody = ulfius_get_json_body_request (request, NULL);
|
||||
int httpstatus=404;
|
||||
char *msg="";
|
||||
if (jsbody == NULL) {
|
||||
msg="Unproperly formatted request body";
|
||||
httpstatus=400;
|
||||
} else {
|
||||
websrv_printjson("callback_exec_softmodemcmd: ",jsbody);
|
||||
json_t *J=json_object_get(jsbody, "name");
|
||||
const char *vname = json_string_value(J);
|
||||
if (vname == NULL ) {
|
||||
msg="No command name in request body";
|
||||
LOG_E(UTIL,"[websrv] command name not found in body\n");
|
||||
httpstatus=400;
|
||||
} else {
|
||||
httpstatus=501;
|
||||
msg="Unknown command in request body";
|
||||
for ( telnetshell_cmddef_t *cmd = modulestruct->cmd ; cmd->cmdfunc != NULL ;cmd++) {
|
||||
if ( strcmp(cmd->cmdname,vname) == 0 && (( cmd->cmdflags & TELNETSRV_CMDFLAG_TELNETONLY) == 0) ){
|
||||
httpstatus=websrv_processwebfunc(response,modulestruct,cmd);
|
||||
break;
|
||||
}
|
||||
}//for
|
||||
}
|
||||
} //sbody
|
||||
if (httpstatus >= 300)
|
||||
ulfius_set_string_body_response(response, httpstatus, msg);
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
/* callback processing module url (<address>/oaisoftmodem/module/variables), get method*/
|
||||
int websrv_callback_get_softmodemvar(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
|
||||
LOG_I(UTIL,"[websrv] : callback_get_softmodemvar received %s %s module %s\n",request->http_verb,request->http_url,
|
||||
(user_data==NULL)?"NULL":((cmdparser_t *)user_data)->module);
|
||||
if (user_data == NULL) {
|
||||
ulfius_set_string_body_response(response, 500, "No variables defined for this module");
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
cmdparser_t * modulestruct = (cmdparser_t *)user_data;
|
||||
LOG_I(UTIL,"[websrv] received %s variables request\n", modulestruct->module);
|
||||
json_t *modulevars = json_array();
|
||||
|
||||
for(int j=0; modulestruct->var[j].varvalptr != NULL ; j++) {
|
||||
char*strval=telnet_getvarvalue(modulestruct->var, j);
|
||||
int modifiable=1;
|
||||
if (modulestruct->var[j].checkval & TELNET_CHECKVAL_RDONLY)
|
||||
modifiable=0;
|
||||
json_t *oneaction;
|
||||
switch(modulestruct->var[j].vartype) {
|
||||
case TELNET_VARTYPE_DOUBLE:
|
||||
oneaction =json_pack("{s:s,s:s,s:g,s:b}","type","number","name",modulestruct->var[j].varname,"value",*(double *)(modulestruct->var[j].varvalptr),"modifiable",modifiable);
|
||||
case TELNET_VARTYPE_INT32:
|
||||
case TELNET_VARTYPE_INT16:
|
||||
case TELNET_VARTYPE_INT8:
|
||||
case TELNET_VARTYPE_UINT:
|
||||
oneaction =json_pack("{s:s,s:s,s:i,s:b}","type","number","name",modulestruct->var[j].varname,"value",(int)(*(int *)(modulestruct->var[j].varvalptr)),"modifiable",modifiable);
|
||||
break;
|
||||
case TELNET_VARTYPE_INT64:
|
||||
oneaction =json_pack("{s:s,s:s,s:lli,s:b}","type","number","name",modulestruct->var[j].varname,"value",(int64_t)(*(int64_t *)(modulestruct->var[j].varvalptr)),"modifiable",modifiable);
|
||||
break;
|
||||
case TELNET_VARTYPE_STRING:
|
||||
oneaction =json_pack("{s:s,s:s,s:s,s:b}","type","string","name",modulestruct->var[j].varname,"value",strval,"modifiable",modifiable);
|
||||
break;
|
||||
default:
|
||||
oneaction =json_pack("{s:s,s:s,s:s,s:b}","type","???","name",modulestruct->var[j].varname,"value","???","modifiable",modifiable);
|
||||
break;
|
||||
}
|
||||
if (oneaction==NULL) {
|
||||
LOG_E(UTIL,"[websrv] cannot encode oneaction %s/%s\n",modulestruct->module,modulestruct->var[j].varname);
|
||||
} else {
|
||||
websrv_printjson("oneaction",oneaction);
|
||||
}
|
||||
free(strval);
|
||||
json_array_append(modulevars , oneaction);
|
||||
}
|
||||
if (json_array_size(modulevars) == 0) {
|
||||
LOG_I(UTIL,"[websrv] no defined variables for %s\n",modulestruct->module);
|
||||
} else {
|
||||
websrv_printjson("modulevars",modulevars);
|
||||
}
|
||||
|
||||
int us=ulfius_add_header_to_response(response,"content-type" ,"application/json");
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 500, "Internal server error (ulfius_add_header_to_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set response header type ulfius error %d \n",us);
|
||||
}
|
||||
us=ulfius_set_json_body_response(response, 200, modulevars);
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 500, "Internal server error (ulfius_set_json_body_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set body response ulfius error %d \n",us);
|
||||
}
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
|
||||
/* callback processing module url (<address>/oaisoftmodem/module/commands)*/
|
||||
int websrv_callback_get_softmodemcmd(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
LOG_I(UTIL,"[websrv] : callback_get_softmodemcmd received %s %s module %s\n",request->http_verb,request->http_url,
|
||||
(user_data==NULL)?"NULL":((cmdparser_t *)user_data)->module);
|
||||
if (user_data == NULL) {
|
||||
ulfius_set_string_body_response(response, 500, "No commands defined for this module");
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
cmdparser_t *modulestruct = (cmdparser_t *)user_data;
|
||||
|
||||
LOG_I(UTIL,"[websrv] received %s commands request\n", modulestruct->module);
|
||||
json_t *modulesubcom = json_array();
|
||||
for(int j=0; modulestruct->cmd[j].cmdfunc != NULL ; j++) {
|
||||
if(strcasecmp("help",modulestruct->cmd[j].cmdname) == 0 || ( modulestruct->cmd[j].cmdflags & TELNETSRV_CMDFLAG_TELNETONLY ) ) {
|
||||
continue;
|
||||
}
|
||||
json_t *acmd;
|
||||
if (modulestruct->cmd[j].cmdflags & TELNETSRV_CMDFLAG_CONFEXEC) {
|
||||
char confstr[256];
|
||||
snprintf(confstr,sizeof(confstr),"Execute %s ?",modulestruct->cmd[j].cmdname);
|
||||
acmd =json_pack( "{s:s,s:s}", "name",modulestruct->cmd[j].cmdname,"confirm", confstr);
|
||||
} else {
|
||||
acmd =json_pack( "{s:s}", "name",modulestruct->cmd[j].cmdname);
|
||||
}
|
||||
json_array_append(modulesubcom , acmd);
|
||||
}
|
||||
if (modulesubcom==NULL) {
|
||||
LOG_E(UTIL,"[websrv] cannot encode modulesubcom response for %s\n",modulestruct->module);
|
||||
} else {
|
||||
websrv_printjson("modulesubcom",modulesubcom);
|
||||
}
|
||||
int us=ulfius_add_header_to_response(response,"content-type" ,"application/json");
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 500, "Internal server error (ulfius_add_header_to_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set response header type ulfius error %d \n",us);
|
||||
}
|
||||
us=ulfius_set_json_body_response(response, 200, modulesubcom);
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 500, "Internal server error (ulfius_set_json_body_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set body response ulfius error %d \n",us);
|
||||
}
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
|
||||
int websrv_callback_get_softmodemmodules(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
telnetsrv_params_t *telnetparams= get_telnetsrv_params();
|
||||
|
||||
json_t *cmdnames = json_array();
|
||||
for (int i=0; telnetparams->CmdParsers[i].var != NULL && telnetparams->CmdParsers[i].cmd != NULL; i++) {
|
||||
json_t *acmd =json_pack( "{s:s}", "name",telnetparams->CmdParsers[i].module);
|
||||
json_array_append(cmdnames, acmd);
|
||||
}
|
||||
|
||||
|
||||
int us=ulfius_add_header_to_response(response,"content-type" ,"application/json");
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 501, "Internal server error (ulfius_add_header_to_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set modules response header type ulfius error %d \n",us);
|
||||
}
|
||||
|
||||
us=ulfius_set_json_body_response(response, 200, cmdnames);
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 501, "Internal server error (ulfius_set_json_body_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set modules body response ulfius error %d \n",us);
|
||||
} else {
|
||||
websrv_printjson("cmdnames",cmdnames);
|
||||
}
|
||||
// ulfius_set_string_body_response(response, 200, cfgfile);
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
/* callback processing initial url (<address>/oaisoftmodem)*/
|
||||
int websrv_callback_get_softmodemstatus(const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||
char *cfgfile=CONFIG_GETCONFFILE ;
|
||||
char *execfunc=get_softmodem_function(NULL);
|
||||
char *strtype="string";
|
||||
json_t *modulevars = json_array();
|
||||
json_t *body1=json_pack("{s:s,s:s,s:s,s:b}","name","config_file", "value",cfgfile, "type",strtype,"modifiable",0);
|
||||
if (body1==NULL) {
|
||||
LOG_E(UTIL,"[websrv] cannot encode status body1 response\n");
|
||||
} else {
|
||||
websrv_printjson("status body1",body1);
|
||||
}
|
||||
|
||||
json_t *body2=json_pack("{s:s,s:s,s:s,s:b}","name","exec_function", "value",execfunc, "type", strtype, "modifiable",0);
|
||||
if (body2==NULL) {
|
||||
LOG_E(UTIL,"[websrv] cannot encode status body1 response\n");
|
||||
} else {
|
||||
websrv_printjson("status body2",body2);
|
||||
}
|
||||
|
||||
json_array_append(modulevars , body1);
|
||||
json_array_append(modulevars , body2);
|
||||
|
||||
int us=ulfius_add_header_to_response(response,"content-type" ,"application/json");
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 501, "Internal server error (ulfius_add_header_to_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set status response header type ulfius error %d \n",us);
|
||||
}
|
||||
|
||||
us=ulfius_set_json_body_response(response, 200, modulevars);
|
||||
if (us != U_OK){
|
||||
ulfius_set_string_body_response(response, 501, "Internal server error (ulfius_set_json_body_response)");
|
||||
LOG_E(UTIL,"[websrv] cannot set status body response ulfius error %d \n",us);
|
||||
}
|
||||
// ulfius_set_string_body_response(response, 200, cfgfile);
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
|
||||
|
||||
int websrv_add_endpoint( char **http_method, int num_method, const char * url_prefix,const char * url_format,
|
||||
int (* callback_function[])(const struct _u_request * request,
|
||||
struct _u_response * response,
|
||||
void * user_data),
|
||||
void * user_data) {
|
||||
int status;
|
||||
int j=0;
|
||||
int priority = (user_data == NULL)?10:0;
|
||||
for (int i=0; i<num_method; i++) {
|
||||
status=ulfius_add_endpoint_by_val(&(websrvparams.instance),http_method[i],url_prefix,url_format,priority,callback_function[i],user_data);
|
||||
if (status != U_OK) {
|
||||
LOG_E(UTIL,"[websrv] cannot add endpoint %s %s/%s\n",http_method[i],url_prefix,url_format);
|
||||
} else {
|
||||
j++;
|
||||
LOG_I(UTIL,"[websrv] endpoint %s %s/%s added\n",http_method[i],url_prefix,url_format);
|
||||
}
|
||||
}
|
||||
return j;
|
||||
}
|
||||
/* add endpoints for a module, as defined in cmdparser_t telnet server structure */
|
||||
void register_module_endpoints(cmdparser_t *module) {
|
||||
int (* callback_functions_var[3])(const struct _u_request * request,
|
||||
struct _u_response * response,
|
||||
void * user_data) ={websrv_callback_get_softmodemvar,websrv_callback_okset_softmodem_cmdvar,websrv_callback_set_softmodemvar};
|
||||
char *http_methods[3]={"GET","OPTIONS","POST"};
|
||||
|
||||
|
||||
int (* callback_functions_cmd[3])(const struct _u_request * request,
|
||||
struct _u_response * response,
|
||||
void * user_data) ={websrv_callback_get_softmodemcmd,websrv_callback_okset_softmodem_cmdvar,websrv_callback_exec_softmodemcmd};
|
||||
char prefixurl[TELNET_CMD_MAXSIZE+20];
|
||||
snprintf(prefixurl,TELNET_CMD_MAXSIZE+19,"oaisoftmodem/%s",module->module);
|
||||
LOG_I(UTIL,"[websrv] add endpoints %s/[variables or commands] \n",prefixurl);
|
||||
|
||||
websrv_add_endpoint(http_methods,3,prefixurl,"commands" ,callback_functions_cmd , module );
|
||||
websrv_add_endpoint(http_methods,3,prefixurl,"variables" ,callback_functions_var, module);
|
||||
}
|
||||
|
||||
|
||||
void* websrv_autoinit() {
|
||||
int ret;
|
||||
telnetsrv_params_t *telnetparams= get_telnetsrv_params();
|
||||
memset(&websrvparams,0,sizeof(websrvparams));
|
||||
config_get( websrvoptions,sizeof(websrvoptions)/sizeof(paramdef_t),"websrv");
|
||||
|
||||
|
||||
|
||||
if (ulfius_init_instance(&(websrvparams.instance), websrvparams.listenport, NULL, NULL) != U_OK) {
|
||||
LOG_W(UTIL, "[websrv] Error,cannot init websrv\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
u_map_put(websrvparams.instance.default_headers, "Access-Control-Allow-Origin", "*");
|
||||
|
||||
// Maximum body size sent by the client is 1 Kb
|
||||
websrvparams.instance.max_post_body_size = 1024;
|
||||
|
||||
// Endpoint list declaration
|
||||
//1: load the frontend code: files contained in the websrvparams.url directory
|
||||
ulfius_add_endpoint_by_val(&(websrvparams.instance), "GET", websrvparams.url, NULL, 0, &websrv_callback_get_mainurl, NULL);
|
||||
//2: build the first page, when receiving the "oaisoftmodem" url
|
||||
// ulfius_add_endpoint_by_val(&(websrvparams.instance), "GET", "oaisoftmodem", "variables", 0, &websrv_callback_get_softmodemstatus, NULL);
|
||||
ulfius_add_endpoint_by_val(&(websrvparams.instance), "GET", "oaisoftmodem", "commands", 0, &websrv_callback_get_softmodemmodules, NULL);
|
||||
|
||||
//3 default_endpoint declaration, it tries to open the file with the url name as specified in the request.It looks for the file
|
||||
ulfius_set_default_endpoint(&(websrvparams.instance), &websrv_callback_default, NULL);
|
||||
|
||||
// endpoints
|
||||
int (* callback_functions_var[3])(const struct _u_request * request,
|
||||
struct _u_response * response,
|
||||
void * user_data) ={websrv_callback_get_softmodemstatus,websrv_callback_okset_softmodem_cmdvar,websrv_callback_set_softmodemvar};
|
||||
char *http_methods[3]={"GET","OPTIONS","POST"};
|
||||
|
||||
websrv_add_endpoint(http_methods,3,"oaisoftmodem","variables" ,callback_functions_var,NULL);
|
||||
|
||||
for (int i=0; telnetparams->CmdParsers[i].cmd != NULL; i++) {
|
||||
register_module_endpoints( &(telnetparams->CmdParsers[i]) );
|
||||
}
|
||||
ulfius_add_endpoint_by_val(&(websrvparams.instance), "GET", "oaisoftmodem", "@module/commands", 10, websrv_callback_newmodule, telnetparams);
|
||||
ulfius_add_endpoint_by_val(&(websrvparams.instance), "GET", "oaisoftmodem", "@module/variables", 10, websrv_callback_newmodule, telnetparams);
|
||||
// Start the framework
|
||||
ret=U_ERROR;
|
||||
if (websrvparams.keyfile!=NULL && websrvparams.certfile!=NULL) {
|
||||
char * key_pem = websrv_read_file(websrvparams.keyfile);
|
||||
char * cert_pem = websrv_read_file(websrvparams.certfile);
|
||||
if ( key_pem == NULL && cert_pem != NULL) {
|
||||
ret = ulfius_start_secure_framework(&(websrvparams.instance), key_pem, cert_pem);
|
||||
free(key_pem);
|
||||
free(cert_pem);
|
||||
} else {
|
||||
LOG_E(UTIL,"[websrv] Unable to load key %s and cert %s_\n",websrvparams.keyfile,websrvparams.certfile);
|
||||
}
|
||||
} else {
|
||||
ret = ulfius_start_framework(&(websrvparams.instance));
|
||||
}
|
||||
|
||||
if (ret == U_OK) {
|
||||
LOG_I(UTIL, "[websrv] Web server started on port %d", websrvparams.instance.port);
|
||||
} else {
|
||||
LOG_W(UTIL,"[websrv] Error starting web server on port %d\n",websrvparams.instance.port);
|
||||
}
|
||||
return &(websrvparams.instance);
|
||||
|
||||
}
|
||||
|
||||
void websrv_end(void *webinst) {
|
||||
ulfius_stop_framework((struct _u_instance *)webinst);
|
||||
ulfius_clean_instance((struct _u_instance *)webinst);
|
||||
return;
|
||||
}
|
||||
65
common/utils/websrv/websrv.h
Normal file
65
common/utils/websrv/websrv.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file common/utils/websrv/websrv.h
|
||||
* \brief: implementation of web API
|
||||
* \author Francois TABURET
|
||||
* \date 2022
|
||||
* \version 0.1
|
||||
* \company NOKIA BellLabs France
|
||||
* \email: francois.taburet@nokia-bell-labs.com
|
||||
* \note
|
||||
* \warning
|
||||
*/
|
||||
|
||||
#ifndef WEBSRV_H
|
||||
#define WEBSRV_H
|
||||
|
||||
#define WEBSRV_MODNAME "websrv"
|
||||
|
||||
#define WEBSRV_PORT 8090
|
||||
/* websrv_printf_t is an internal structure storing messages while processing a request */
|
||||
/* The meaage is used to fill a response body */
|
||||
typedef struct {
|
||||
pthread_mutex_t mutex; // protect the message betwween the websrv_printf_start and websrv_print_end calls
|
||||
struct _u_response * response; // the ulfius response structure, used to send the message
|
||||
char *buff; // a buffer to store the message, allocated in websrv_printf_start, free in websrv_print_end
|
||||
int buffsize; //
|
||||
char *buffptr; // pointer to free portion of buff
|
||||
} websrv_printf_t;
|
||||
|
||||
/* websrv_params_t is an internal structure storing all the current parameters and */
|
||||
/* global variables used by the web server */
|
||||
typedef struct {
|
||||
struct _u_instance instance; // ulfius (web server) instance
|
||||
unsigned int dbglvl; // debug level of the server
|
||||
int priority; // server running priority
|
||||
unsigned int listenport; // ip port the telnet server is listening on
|
||||
unsigned int listenaddr; // ip address the telnet server is listening on
|
||||
unsigned int listenstdin; // enable command input from stdin
|
||||
char *url; // url for the main (initial) web page
|
||||
char *certfile; // cert file
|
||||
char *keyfile; // key file
|
||||
} websrv_params_t;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
47
common/utils/websrv/websrv_CMakeLists.txt
Normal file
47
common/utils/websrv/websrv_CMakeLists.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
if ( "${OPENAIR_CMAKE}" STREQUAL "")
|
||||
message( FATAL_ERROR "oai Environment variables not set")
|
||||
endif ( "${OPENAIR_CMAKE}" STREQUAL "")
|
||||
set(WEBSRVROOT ${OPENAIR_DIR}/common/utils/websrv )
|
||||
# websrv dependencies
|
||||
#set( ULFIUS "")
|
||||
find_library(ULFIUS NAMES "libulfius.so" REQUIRED NO_CACHE)
|
||||
if ("${ULFIUS}" STREQUAL "")
|
||||
message( FATAL_ERROR "ulfius library (https://github.com/babelouest/ulfius) not found, install libulfius-dev (ubuntu) ")
|
||||
endif("${ULFIUS}" STREQUAL "")
|
||||
|
||||
#set (NPM "")
|
||||
find_program(NPM NAMES npm NO_CACHE)
|
||||
if ("${NPM}" STREQUAL "")
|
||||
message( ERROR " npm is not installed, frontend won't be built. Possibly install npm, package is available for ubuntu and fedora")
|
||||
endif("${NPM}" STREQUAL "")
|
||||
|
||||
# build the backend ( the embedded web server)
|
||||
set(WEBSRV_SOURCE
|
||||
${WEBSRVROOT}/websrv.c
|
||||
)
|
||||
add_library(websrv MODULE ${WEBSRV_SOURCE} )
|
||||
target_link_libraries(websrv PRIVATE ulfius jansson)
|
||||
|
||||
|
||||
# build the frontend ( loaded from web server by browsers)
|
||||
add_custom_target (
|
||||
websrvfront_installjsdep
|
||||
WORKING_DIRECTORY ${WEBSRVROOT}/frontend
|
||||
COMMAND npm install
|
||||
DEPENDS ${WEBSRVROOT}/frontend/package-lock.json
|
||||
)
|
||||
|
||||
add_custom_target (
|
||||
websrvfront
|
||||
WORKING_DIRECTORY ${WEBSRVROOT}/frontend
|
||||
COMMAND npm run build
|
||||
DEPENDS websrvfront_installjsdep
|
||||
)
|
||||
#install built files, required at exec time
|
||||
install(TARGETS websrv DESTINATION bin)
|
||||
if (EXISTS "${OPENAIR_CMAKE}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_CMAKE}/ran_build/build")
|
||||
add_custom_command(TARGET websrvfront
|
||||
POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${WEBSRVROOT}/frontend/dist/softmodem-ngx ${OPENAIR_CMAKE}/ran_build/build/websrv
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${WEBSRVROOT}/frontend/dist/softmodem-ngx ${OPENAIR_TARGETS}/bin/websrv
|
||||
COMMENT "Moving frontend files to:\n ${OPENAIR_CMAKE}/ran_build/build/websrv\n ${OPENAIR_TARGETS}/bin/websrv" )
|
||||
endif (EXISTS "${OPENAIR_CMAKE}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_CMAKE}/ran_build/build")
|
||||
@@ -265,7 +265,7 @@ void prach_eNB_tosplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *eNB, L1_r
|
||||
true
|
||||
);
|
||||
*/
|
||||
LOG_X(PHY,"RACH detection index 0: max preamble: %u, energy: %u, delay: %u, avg energy: %u\n",
|
||||
LOG_D(PHY,"RACH detection index 0: max preamble: %u, energy: %u, delay: %u, avg energy: %u\n",
|
||||
header->max_preamble[0],
|
||||
header->max_preamble_energy[0],
|
||||
header->max_preamble_delay[0],
|
||||
@@ -348,7 +348,7 @@ void prach_eNB_fromsplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *eNB, L1
|
||||
eNB->preamble_list[0].instance_length = 0; //don't know exactly what this is
|
||||
|
||||
if (NFAPI_MODE==NFAPI_MODE_PNF) { // If NFAPI PNF then we need to send the message to the VNF
|
||||
LOG_X(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n",
|
||||
LOG_D(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n",
|
||||
NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf),
|
||||
eNB->preamble_list[0].preamble_rel8.timing_advance,
|
||||
eNB->preamble_list[0].preamble_rel8.preamble,
|
||||
@@ -399,7 +399,7 @@ void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *
|
||||
curBlock++;
|
||||
}
|
||||
|
||||
LOG_X(PHY,"FS6 du, block: %d: adding ul harq/sr: %d, rnti: %d, ueid: %d\n",
|
||||
LOG_D(PHY,"FS6 du, block: %d: adding ul harq/sr: %d, rnti: %d, ueid: %d\n",
|
||||
curBlock, type, rnti, UEid);
|
||||
commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte;
|
||||
fs6_ul_uespec_uci_element_t *tmp=(fs6_ul_uespec_uci_element_t *)(hULUEuci(newUDPheader)+1);
|
||||
@@ -481,7 +481,7 @@ void pusch_procedures_tosplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *eN
|
||||
LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
|
||||
|
||||
if (ulsch->rnti>0)
|
||||
LOG_X(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d active: %d handled:%d]\n",
|
||||
LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d active: %d handled:%d]\n",
|
||||
i, harq_pid, frame,subframe,i,ulsch->rnti,
|
||||
ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->status, ulsch_harq->handled);
|
||||
|
||||
@@ -499,14 +499,14 @@ void pusch_procedures_tosplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *eN
|
||||
eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31));
|
||||
}
|
||||
|
||||
LOG_X(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n",
|
||||
LOG_D(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n",
|
||||
eNB->Mod_id, frame, subframe, i);
|
||||
uint8_t nPRS= fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1];
|
||||
ulsch->cyclicShift = (ulsch_harq->n_DMRS2 +
|
||||
fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift +
|
||||
nPRS)%12;
|
||||
AssertFatal(ulsch_harq->TBS>0,"illegal TBS %d\n",ulsch_harq->TBS);
|
||||
LOG_X(PHY,
|
||||
LOG_D(PHY,
|
||||
"[eNB %d][PUSCH %d] Frame %d Subframe %d Demodulating PUSCH: dci_alloc %d, rar_alloc %d, round %d, first_rb %d, nb_rb %d, Qm %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, ), O_ACK %d, beta_cqi %d \n",
|
||||
eNB->Mod_id,harq_pid,frame,subframe,
|
||||
ulsch_harq->dci_alloc,
|
||||
@@ -664,7 +664,7 @@ void fill_rx_indication_from_split(uint8_t *bufferZone, PHY_VARS_eNB *eNB,int UE
|
||||
else
|
||||
pdu->rx_indication_rel8.ul_cqi = (640 + SNRtimes10) / 5;
|
||||
|
||||
LOG_X(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n",
|
||||
LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n",
|
||||
harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance,
|
||||
timing_advance_update);
|
||||
eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++;
|
||||
@@ -688,7 +688,7 @@ void pusch_procedures_fromsplit(uint8_t *bufferZone, int bufSize, PHY_VARS_eNB *
|
||||
LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
|
||||
|
||||
if (ulsch->rnti>0)
|
||||
LOG_X(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n",
|
||||
LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n",
|
||||
i, harq_pid, frame,subframe,i,ulsch->rnti,
|
||||
ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled);
|
||||
|
||||
@@ -768,14 +768,14 @@ void recvFs6Ul(uint8_t *bufferZone, int nbBlocks, PHY_VARS_eNB *eNB, ul_propagat
|
||||
sizeof(ulsch_harq->o_ACK));
|
||||
memcpy(ulsch_harq->o,hULUE(bufPtr)->o, sizeof(ulsch_harq->o));
|
||||
ul_propa[hULUE(bufPtr)->UE_id].ta=hULUE(bufPtr)->ta;
|
||||
LOG_X(PHY,"Received ulsch data for: rnti:%x, cqi_crc_status %d O_ACK: %d, segment: %d, seglen: %d \n",
|
||||
LOG_D(PHY,"Received ulsch data for: rnti:%x, cqi_crc_status %d O_ACK: %d, segment: %d, seglen: %d \n",
|
||||
ulsch->rnti, ulsch_harq->cqi_crc_status, ulsch_harq->O_ACK,hULUE(bufPtr)->segment, hULUE(bufPtr)->segLen);
|
||||
} else if ( type == fs6ULcch ) {
|
||||
int nb_uci=hULUEuci(bufPtr)->nb_active_ue;
|
||||
fs6_ul_uespec_uci_element_t *tmp=(fs6_ul_uespec_uci_element_t *)(hULUEuci(bufPtr)+1);
|
||||
|
||||
for (int j=0; j < nb_uci ; j++) {
|
||||
LOG_X(PHY,"FS6 cu, block: %d/%d: received ul harq/sr: %d, rnti: %d, ueid: %d\n",
|
||||
LOG_D(PHY,"FS6 cu, block: %d/%d: received ul harq/sr: %d, rnti: %d, ueid: %d\n",
|
||||
i, j, type, tmp->rnti, tmp->UEid);
|
||||
eNB->measurements.n0_subband_power_dB[0][0]=tmp->n0_subband_power_dB;
|
||||
|
||||
@@ -850,7 +850,7 @@ void rcvFs6DL(uint8_t *bufferZone, int nbBlocks, PHY_VARS_eNB *eNB, int frame, i
|
||||
#endif
|
||||
fs6Dlunpack(dlsch_harq->eDL,
|
||||
hDLUE(bufPtr)+1, hDLUE(bufPtr)->dataLen);
|
||||
LOG_X(PHY,"received %d bits, in harq id: %di fsf: %d.%d, sum %d\n",
|
||||
LOG_D(PHY,"received %d bits, in harq id: %di fsf: %d.%d, sum %d\n",
|
||||
hDLUE(bufPtr)->dataLen, hDLUE(bufPtr)->harq_pid, frame, subframe, sum(dlsch_harq->eDL, hDLUE(bufPtr)->dataLen));
|
||||
} else if (type == fs6UlConfig) {
|
||||
int nbUE=(((commonUDP_t *)bufPtr)->contentBytes - sizeof(fs6_dl_t)) / sizeof( fs6_dl_ulsched_t ) ;
|
||||
@@ -919,7 +919,7 @@ void rcvFs6DL(uint8_t *bufferZone, int nbBlocks, PHY_VARS_eNB *eNB, int frame, i
|
||||
cpyVal(delta_TF);
|
||||
cpyVal(repetition_number );
|
||||
cpyVal(total_number_of_repetitions);
|
||||
LOG_X(PHY,"Received request to perform ulsch for: rnti:%d, fsf: %d/%d, O_ACK: %d\n",
|
||||
LOG_D(PHY,"Received request to perform ulsch for: rnti:%d, fsf: %d/%d, O_ACK: %d\n",
|
||||
ulsch->rnti, frame, subframe, ulsch_harq->O_ACK);
|
||||
}
|
||||
} else if ( type == fs6ULConfigCCH ) {
|
||||
@@ -1025,7 +1025,7 @@ void phy_procedures_eNB_TX_fromsplit(uint8_t *bufferZone, int nbBlocks, PHY_VARS
|
||||
i++)
|
||||
sum+=((int32_t *)(eNB->common_vars.txdataF[0]))[i];
|
||||
|
||||
LOG_X(PHY,"frame: %d, subframe: %d, sum of dlsch mod v1: %lx\n", frame, subframe, sum);
|
||||
LOG_D(PHY,"frame: %d, subframe: %d, sum of dlsch mod v1: %lx\n", frame, subframe, sum);
|
||||
int harq_pid=dlsch0->harq_ids[frame%2][subframe];
|
||||
pdsch_procedures(eNB,
|
||||
proc,
|
||||
@@ -1130,7 +1130,7 @@ void appendFs6TxULUE(uint8_t *bufferZone, LTE_DL_FRAME_PARMS *fp, int curUE, LTE
|
||||
memcpyToDuHarq(delta_TF);
|
||||
memcpyToDuHarq(repetition_number );
|
||||
memcpyToDuHarq(total_number_of_repetitions);
|
||||
LOG_X(PHY,"Added request to perform ulsch for: rnti:%x, fsf: %d/%d\n", ulsch->rnti, frame, subframe);
|
||||
LOG_D(PHY,"Added request to perform ulsch for: rnti:%x, fsf: %d/%d\n", ulsch->rnti, frame, subframe);
|
||||
}
|
||||
|
||||
void appendFs6DLUE(uint8_t *bufferZone, LTE_DL_FRAME_PARMS *fp, int UE_id, int8_t harq_pid, LTE_eNB_DLSCH_t *dlsch0, LTE_DL_eNB_HARQ_t *harqData, int frame, int subframe) {
|
||||
@@ -1181,10 +1181,10 @@ void appendFs6DLUE(uint8_t *bufferZone, LTE_DL_FRAME_PARMS *fp, int UE_id, int8_
|
||||
#endif
|
||||
hDLUE(newUDPheader)->dataLen=UEdataLen;
|
||||
fs6Dlpack(hDLUE(newUDPheader)+1, harqData->eDL, UEdataLen);
|
||||
LOG_X(PHY,"sending %d bits, in harq id: %di fsf: %d.%d, sum %d\n",
|
||||
LOG_D(PHY,"sending %d bits, in harq id: %di fsf: %d.%d, sum %d\n",
|
||||
UEdataLen, harq_pid, frame, subframe, sum(harqData->eDL, UEdataLen));
|
||||
//for (int i=0; i < UEdataLen; i++)
|
||||
//LOG_X(PHY,"buffer ei[%d]:%hhx\n", i, ( (uint8_t *)(hDLUE(newUDPheader)+1) )[i]);
|
||||
//LOG_D(PHY,"buffer ei[%d]:%hhx\n", i, ( (uint8_t *)(hDLUE(newUDPheader)+1) )[i]);
|
||||
}
|
||||
|
||||
void appendFs6DLUEcch(uint8_t *bufferZone, PHY_VARS_eNB *eNB, int frame, int subframe) {
|
||||
@@ -1206,7 +1206,7 @@ void appendFs6DLUEcch(uint8_t *bufferZone, PHY_VARS_eNB *eNB, int frame, int sub
|
||||
LTE_eNB_UCI *uci = &(eNB->uci_vars[i]);
|
||||
|
||||
if ((uci->active == 1) && (uci->frame == frame) && (uci->subframe == subframe)) {
|
||||
LOG_X(PHY,"Frame %d, subframe %d: adding uci procedures (type %d) for %d \n",
|
||||
LOG_D(PHY,"Frame %d, subframe %d: adding uci procedures (type %d) for %d \n",
|
||||
frame,
|
||||
subframe,
|
||||
uci->type,
|
||||
@@ -1262,7 +1262,7 @@ void phy_procedures_eNB_TX_tosplit(uint8_t *bufferZone, PHY_VARS_eNB *eNB, L1_rx
|
||||
LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
|
||||
|
||||
if (ulsch->rnti>0) {
|
||||
LOG_X(PHY,"check in UL scheduled harq %d: rnti %d, tx frame %d/%d, ulsch: %d, %d/%d (handled: %d)\n",
|
||||
LOG_D(PHY,"check in UL scheduled harq %d: rnti %d, tx frame %d/%d, ulsch: %d, %d/%d (handled: %d)\n",
|
||||
harq_pid, ulsch->rnti, frame, subframe, ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled);
|
||||
}
|
||||
|
||||
@@ -1298,7 +1298,7 @@ void phy_procedures_eNB_TX_tosplit(uint8_t *bufferZone, PHY_VARS_eNB *eNB, L1_rx
|
||||
memcpy(hDL(bufferZone)->pbch_pdu,eNB->pbch_pdu,4);
|
||||
|
||||
if ( num_dci <= 8 )
|
||||
LOG_X(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci);
|
||||
LOG_D(PHY,"num_pdcch_symbols %"PRIu8",number dci %"PRIu8"\n",num_pdcch_symbols, num_dci);
|
||||
else {
|
||||
LOG_E(PHY, "Num dci too large for current FS6 implementation, reducing to 8 dci (was %d)\n", num_dci);
|
||||
num_dci=8;
|
||||
@@ -1313,7 +1313,7 @@ void phy_procedures_eNB_TX_tosplit(uint8_t *bufferZone, PHY_VARS_eNB *eNB, L1_rx
|
||||
for (int i=0; i< hDL(bufferZone)->num_dci; i++)
|
||||
hDL(bufferZone)->dci_alloc[i]=eNB->pdcch_vars[subframe&1].dci_alloc[i];
|
||||
|
||||
LOG_X(PHY, "pbch configured: %d\n", eNB->pbch_configured);
|
||||
LOG_D(PHY, "pbch configured: %d\n", eNB->pbch_configured);
|
||||
}
|
||||
|
||||
if (do_meas==1) stop_meas(&eNB->dlsch_common_and_dci);
|
||||
|
||||
@@ -162,18 +162,18 @@ void init_transport(PHY_VARS_eNB *eNB) {
|
||||
LOG_I(PHY, "Initialise transport\n");
|
||||
|
||||
for (int i=0; i<NUMBER_OF_DLSCH_MAX; i++) {
|
||||
LOG_X(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i);
|
||||
LOG_D(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i);
|
||||
|
||||
for (int j=0; j<2; j++) {
|
||||
AssertFatal( (eNB->dlsch[i][j] = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL,0,fp)) != NULL,
|
||||
"Can't get eNB dlsch structures for UE %d \n", i);
|
||||
eNB->dlsch[i][j]->rnti=0;
|
||||
LOG_X(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,eNB->dlsch[i][j], eNB->dlsch[i][j]->rnti);
|
||||
LOG_D(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,eNB->dlsch[i][j], eNB->dlsch[i][j]->rnti);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<NUMBER_OF_ULSCH_MAX; i++) {
|
||||
LOG_X(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i);
|
||||
LOG_D(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i);
|
||||
AssertFatal((eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0)) != NULL,
|
||||
"Can't get eNB ulsch structures\n");
|
||||
// this is the transmission mode for the signalling channels
|
||||
@@ -185,11 +185,11 @@ void init_transport(PHY_VARS_eNB *eNB) {
|
||||
AssertFatal( (eNB->ulsch[0] = new_eNB_ulsch(MAX_TURBO_ITERATIONS, fp->N_RB_UL, 0)) !=NULL,
|
||||
"Can't get eNB ulsch structures\n");
|
||||
eNB->dlsch_SI = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp);
|
||||
LOG_X(PHY,"eNB %d.%d : SI %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_SI);
|
||||
LOG_D(PHY,"eNB %d.%d : SI %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_SI);
|
||||
eNB->dlsch_ra = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp);
|
||||
LOG_X(PHY,"eNB %d.%d : RA %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_ra);
|
||||
LOG_D(PHY,"eNB %d.%d : RA %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_ra);
|
||||
eNB->dlsch_MCH = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp);
|
||||
LOG_X(PHY,"eNB %d.%d : MCH %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_MCH);
|
||||
LOG_D(PHY,"eNB %d.%d : MCH %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_MCH);
|
||||
eNB->rx_total_gain_dB=130;
|
||||
|
||||
for(int i=0; i<NUMBER_OF_UE_MAX; i++)
|
||||
@@ -521,7 +521,7 @@ void prach_procedures_ocp(PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, int br_flag)
|
||||
0
|
||||
,br_flag
|
||||
);
|
||||
LOG_X(PHY,"RACH detection index 0: max preamble: %u, energy: %u, delay: %u, avg energy: %u\n",
|
||||
LOG_D(PHY,"RACH detection index 0: max preamble: %u, energy: %u, delay: %u, avg energy: %u\n",
|
||||
max_preamble[0],
|
||||
max_preamble_energy[0],
|
||||
max_preamble_delay[0],
|
||||
@@ -591,7 +591,7 @@ void prach_procedures_ocp(PHY_VARS_eNB *eNB, L1_rxtx_proc_t *proc, int br_flag)
|
||||
eNB->preamble_list[0].instance_length = 0; //don't know exactly what this is
|
||||
|
||||
if (NFAPI_MODE==NFAPI_MODE_PNF) { // If NFAPI PNF then we need to send the message to the VNF
|
||||
LOG_X(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n",
|
||||
LOG_D(PHY,"Filling NFAPI indication for RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x, rach_resource_type %d\n",
|
||||
NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf),
|
||||
eNB->preamble_list[0].preamble_rel8.timing_advance,
|
||||
eNB->preamble_list[0].preamble_rel8.preamble,
|
||||
@@ -745,7 +745,7 @@ void ocp_tx_rf(RU_t *ru, L1_rxtx_proc_t *proc) {
|
||||
siglen+sf_extension,
|
||||
ru->nb_tx,
|
||||
flags);
|
||||
LOG_X(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, subframe %d\n",ru->idx,
|
||||
LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, subframe %d\n",ru->idx,
|
||||
(long long unsigned int)proc->timestamp_tx,proc->frame_tx,proc->subframe_tx);
|
||||
}
|
||||
|
||||
@@ -836,7 +836,7 @@ void ocp_init_RU(RU_t *ru, char *rf_config_file, int send_dmrssync) {
|
||||
for (CC_id=0; CC_id<RC.nb_CC[i]; CC_id++)
|
||||
RC.eNB[i][CC_id]->num_RU=0;
|
||||
|
||||
LOG_X(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU);
|
||||
LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU);
|
||||
ru->rf_config_file = rf_config_file;
|
||||
ru->idx = 0;
|
||||
ru->ts_offset = 0;
|
||||
@@ -919,7 +919,7 @@ void ocpRCconfig_RU(RU_t *ru) {
|
||||
|
||||
if (config_isparamset(vals, RU_SDR_CLK_SRC)) {
|
||||
char *paramVal=*(vals[RU_SDR_CLK_SRC].strptr);
|
||||
LOG_X(PHY, "RU clock source set as %s\n", paramVal);
|
||||
LOG_D(PHY, "RU clock source set as %s\n", paramVal);
|
||||
|
||||
if (strcmp(paramVal, "internal") == 0) {
|
||||
ru->openair0_cfg.clock_source = internal;
|
||||
|
||||
@@ -197,13 +197,13 @@ int main ( int argc, char **argv )
|
||||
if (config_isparamset(RUParamList.paramarray[j], RU_SDR_CLK_SRC)) {
|
||||
if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "internal") == 0) {
|
||||
ru->openair0_cfg.clock_source = internal;
|
||||
LOG_X(PHY, "RU clock source set as internal\n");
|
||||
LOG_D(PHY, "RU clock source set as internal\n");
|
||||
} else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "external") == 0) {
|
||||
ru->openair0_cfg.clock_source = external;
|
||||
LOG_X(PHY, "RU clock source set as external\n");
|
||||
LOG_D(PHY, "RU clock source set as external\n");
|
||||
} else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "gpsdo") == 0) {
|
||||
ru->openair0_cfg.clock_source = gpsdo;
|
||||
LOG_X(PHY, "RU clock source set as gpsdo\n");
|
||||
LOG_D(PHY, "RU clock source set as gpsdo\n");
|
||||
} else {
|
||||
LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr));
|
||||
}
|
||||
@@ -215,13 +215,13 @@ int main ( int argc, char **argv )
|
||||
if (config_isparamset(RUParamList.paramarray[j], RU_SDR_TME_SRC)) {
|
||||
if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "internal") == 0) {
|
||||
ru->openair0_cfg.time_source = internal;
|
||||
LOG_X(PHY, "RU time source set as internal\n");
|
||||
LOG_D(PHY, "RU time source set as internal\n");
|
||||
} else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "external") == 0) {
|
||||
ru->openair0_cfg.time_source = external;
|
||||
LOG_X(PHY, "RU time source set as external\n");
|
||||
LOG_D(PHY, "RU time source set as external\n");
|
||||
} else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "gpsdo") == 0) {
|
||||
ru->openair0_cfg.time_source = gpsdo;
|
||||
LOG_X(PHY, "RU time source set as gpsdo\n");
|
||||
LOG_D(PHY, "RU time source set as gpsdo\n");
|
||||
} else {
|
||||
LOG_E(PHY, "Erroneous RU time source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr));
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ void rx_func(void *param) {
|
||||
|
||||
if (NFAPI_MODE == NFAPI_MODE_PNF) {
|
||||
// I am a PNF and I need to let nFAPI know that we have a (sub)frame tick
|
||||
//LOG_X(PHY, "oai_nfapi_slot_ind(frame:%u, slot:%d) ********\n", frame_rx, slot_rx);
|
||||
//LOG_D(PHY, "oai_nfapi_slot_ind(frame:%u, slot:%d) ********\n", frame_rx, slot_rx);
|
||||
start_meas(&nfapi_meas);
|
||||
handle_nr_slot_ind(frame_rx, slot_rx);
|
||||
stop_meas(&nfapi_meas);
|
||||
@@ -149,7 +149,7 @@ void rx_func(void *param) {
|
||||
gNB->UL_INFO.rach_ind.number_of_pdus ||
|
||||
gNB->UL_INFO.cqi_ind.number_of_cqis
|
||||
) {
|
||||
LOG_X(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d rach_pdus:%0d.%d:%d cqis:%d] RX:%04d%d TX:%04d%d \n",
|
||||
LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d rach_pdus:%0d.%d:%d cqis:%d] RX:%04d%d TX:%04d%d \n",
|
||||
NFAPI_SFNSF2DEC(gNB->UL_INFO.rx_ind.sfn_sf), gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus,
|
||||
NFAPI_SFNSF2DEC(gNB->UL_INFO.harq_ind.sfn_sf), gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs,
|
||||
NFAPI_SFNSF2DEC(gNB->UL_INFO.crc_ind.sfn_sf), gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs,
|
||||
@@ -232,7 +232,7 @@ void rx_func(void *param) {
|
||||
}
|
||||
|
||||
stop_meas( &softmodem_stats_rxtx_sf );
|
||||
LOG_X(PHY,"%s() Exit proc[rx:%d%d tx:%d%d]\n", __FUNCTION__, frame_rx, slot_rx, frame_tx, slot_tx);
|
||||
LOG_D(PHY,"%s() Exit proc[rx:%d%d tx:%d%d]\n", __FUNCTION__, frame_rx, slot_rx, frame_tx, slot_tx);
|
||||
|
||||
// Call the scheduler
|
||||
start_meas(&gNB->ul_indication_stats);
|
||||
@@ -259,7 +259,7 @@ void rx_func(void *param) {
|
||||
}
|
||||
|
||||
#if 0
|
||||
LOG_X(PHY, "rxtx:%lld nfapi:%lld phy:%lld tx:%lld rx:%lld prach:%lld ofdm:%lld ",
|
||||
LOG_D(PHY, "rxtx:%lld nfapi:%lld phy:%lld tx:%lld rx:%lld prach:%lld ofdm:%lld ",
|
||||
softmodem_stats_rxtx_sf.diff_now, nfapi_meas.diff_now,
|
||||
TICK_TO_US(gNB->phy_proc),
|
||||
TICK_TO_US(gNB->phy_proc_tx),
|
||||
@@ -267,7 +267,7 @@ void rx_func(void *param) {
|
||||
TICK_TO_US(gNB->rx_prach),
|
||||
TICK_TO_US(gNB->ofdm_mod_stats),
|
||||
softmodem_stats_rxtx_sf.diff_now, nfapi_meas.diff_now);
|
||||
LOG_X(PHY,
|
||||
LOG_D(PHY,
|
||||
"dlsch[enc:%lld mod:%lld scr:%lld rm:%lld t:%lld i:%lld] rx_dft:%lld ",
|
||||
TICK_TO_US(gNB->dlsch_encoding_stats),
|
||||
TICK_TO_US(gNB->dlsch_modulation_stats),
|
||||
@@ -276,19 +276,19 @@ void rx_func(void *param) {
|
||||
TICK_TO_US(gNB->dlsch_turbo_encoding_stats),
|
||||
TICK_TO_US(gNB->dlsch_interleaving_stats),
|
||||
TICK_TO_US(gNB->rx_dft_stats));
|
||||
LOG_X(PHY," ulsch[ch:%lld freq:%lld dec:%lld demod:%lld ru:%lld ",
|
||||
LOG_D(PHY," ulsch[ch:%lld freq:%lld dec:%lld demod:%lld ru:%lld ",
|
||||
TICK_TO_US(gNB->ulsch_channel_estimation_stats),
|
||||
TICK_TO_US(gNB->ulsch_freq_offset_estimation_stats),
|
||||
TICK_TO_US(gNB->ulsch_decoding_stats),
|
||||
TICK_TO_US(gNB->ulsch_demodulation_stats),
|
||||
TICK_TO_US(gNB->ulsch_rate_unmatching_stats));
|
||||
LOG_X(PHY, "td:%lld dei:%lld dem:%lld llr:%lld tci:%lld ",
|
||||
LOG_D(PHY, "td:%lld dei:%lld dem:%lld llr:%lld tci:%lld ",
|
||||
TICK_TO_US(gNB->ulsch_turbo_decoding_stats),
|
||||
TICK_TO_US(gNB->ulsch_deinterleaving_stats),
|
||||
TICK_TO_US(gNB->ulsch_demultiplexing_stats),
|
||||
TICK_TO_US(gNB->ulsch_llr_stats),
|
||||
TICK_TO_US(gNB->ulsch_tc_init_stats));
|
||||
LOG_X(PHY, "tca:%lld tcb:%lld tcg:%lld tce:%lld l1:%lld l2:%lld]\n\n",
|
||||
LOG_D(PHY, "tca:%lld tcb:%lld tcg:%lld tce:%lld l1:%lld l2:%lld]\n\n",
|
||||
TICK_TO_US(gNB->ulsch_tc_alpha_stats),
|
||||
TICK_TO_US(gNB->ulsch_tc_beta_stats),
|
||||
TICK_TO_US(gNB->ulsch_tc_gamma_stats),
|
||||
|
||||
@@ -288,7 +288,7 @@ void fh_if4p5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp) {
|
||||
|
||||
if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
|
||||
|
||||
LOG_X(PHY,"Sending IF4p5 for frame %d subframe %d\n",ru->proc.frame_tx,ru->proc.tti_tx);
|
||||
LOG_D(PHY,"Sending IF4p5 for frame %d subframe %d\n",ru->proc.frame_tx,ru->proc.tti_tx);
|
||||
|
||||
if ((nr_slot_select(cfg,ru->proc.frame_tx,ru->proc.tti_tx)&NR_DOWNLINK_SLOT) > 0)
|
||||
send_IF4p5(ru,frame, slot, IF4p5_PDLFFT);
|
||||
@@ -311,7 +311,7 @@ void fh_if5_south_in(RU_t *ru,
|
||||
proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx-ru->ts_offset,fp);
|
||||
//(idx_sf * fp->slots_per_subframe + (int)round((float)(proc->timestamp_rx % fp->samples_per_subframe) / fp->samples_per_slot0))%(fp->slots_per_frame);
|
||||
ts_rx[*tti] = proc->timestamp_rx;
|
||||
LOG_X(PHY,"IF5 %d.%d => RX %d.%d first_rx %d\n",*frame,*tti,proc->frame_rx,proc->tti_rx,proc->first_rx);
|
||||
LOG_D(PHY,"IF5 %d.%d => RX %d.%d first_rx %d\n",*frame,*tti,proc->frame_rx,proc->tti_rx,proc->first_rx);
|
||||
|
||||
if (proc->first_rx == 0) {
|
||||
if (proc->tti_rx != *tti) {
|
||||
@@ -364,7 +364,7 @@ void fh_if4p5_south_in(RU_t *ru,
|
||||
// nothing in RU for RAU
|
||||
}
|
||||
|
||||
LOG_X(PHY,"rx_fh_if4p5: subframe %d symbol mask %x\n",*slot,proc->symbol_mask[sl]);
|
||||
LOG_D(PHY,"rx_fh_if4p5: subframe %d symbol mask %x\n",*slot,proc->symbol_mask[sl]);
|
||||
} while(proc->symbol_mask[sl] != symbol_mask_full);
|
||||
|
||||
//caculate timestamp_rx, timestamp_tx based on frame and subframe
|
||||
@@ -400,7 +400,7 @@ void fh_if4p5_south_in(RU_t *ru,
|
||||
|
||||
proc->symbol_mask[proc->tti_rx] = 0;
|
||||
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff );
|
||||
LOG_X(PHY,"RU %d: fh_if4p5_south_in sleeping ...\n",ru->idx);
|
||||
LOG_D(PHY,"RU %d: fh_if4p5_south_in sleeping ...\n",ru->idx);
|
||||
}
|
||||
|
||||
// asynchronous inbound if4p5 fronthaul from south
|
||||
@@ -503,7 +503,7 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
|
||||
uint16_t packet_type;
|
||||
uint32_t symbol_number,symbol_mask,symbol_mask_full=0;
|
||||
int slot_tx,frame_tx;
|
||||
LOG_X(PHY, "%s(ru:%p frame, subframe)\n", __FUNCTION__, ru);
|
||||
LOG_D(PHY, "%s(ru:%p frame, subframe)\n", __FUNCTION__, ru);
|
||||
symbol_number = 0;
|
||||
symbol_mask = 0;
|
||||
|
||||
@@ -513,7 +513,7 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
|
||||
|
||||
if (((nr_slot_select(cfg,frame_tx,slot_tx) & NR_DOWNLINK_SLOT) > 0) && (symbol_number == 0)) start_meas(&ru->rx_fhaul);
|
||||
|
||||
LOG_X(PHY,"slot %d (%d): frame %d, slot %d, symbol %d\n",
|
||||
LOG_D(PHY,"slot %d (%d): frame %d, slot %d, symbol %d\n",
|
||||
*slot,nr_slot_select(cfg,frame_tx,*slot),frame_tx,slot_tx,symbol_number);
|
||||
|
||||
if (proc->first_tx != 0) {
|
||||
@@ -541,7 +541,7 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
|
||||
if ((frame_tx == 0)&&(slot_tx == 0)) proc->frame_tx_unwrap += 1024;
|
||||
|
||||
proc->timestamp_tx = (((uint64_t)frame_tx + (uint64_t)proc->frame_tx_unwrap) * fp->samples_per_subframe * 10) + fp->get_samples_slot_timestamp(slot_tx, fp, 0);
|
||||
LOG_X(PHY,"RU %d/%d TST %llu, frame %d, subframe %d\n",ru->idx,0,(long long unsigned int)proc->timestamp_tx,frame_tx,slot_tx);
|
||||
LOG_D(PHY,"RU %d/%d TST %llu, frame %d, subframe %d\n",ru->idx,0,(long long unsigned int)proc->timestamp_tx,frame_tx,slot_tx);
|
||||
|
||||
// dump VCD output for first RU in list
|
||||
if (ru == RC.ru[0]) {
|
||||
@@ -618,7 +618,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
|
||||
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 );
|
||||
old_ts = proc->timestamp_rx;
|
||||
LOG_X(PHY,"Reading %d samples for slot %d (%p)\n",samples_per_slot,*slot,rxp[0]);
|
||||
LOG_D(PHY,"Reading %d samples for slot %d (%p)\n",samples_per_slot,*slot,rxp[0]);
|
||||
|
||||
if(emulate_rf) {
|
||||
wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread");
|
||||
@@ -647,7 +647,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
|
||||
samples_per_slot_prev = fp->get_samples_per_slot((*slot-1)%fp->slots_per_frame,fp);
|
||||
|
||||
if (proc->timestamp_rx - old_ts != samples_per_slot_prev) {
|
||||
LOG_X(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - samples_per_slot_prev,ru->ts_offset);
|
||||
LOG_D(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - samples_per_slot_prev,ru->ts_offset);
|
||||
ru->ts_offset += (proc->timestamp_rx - old_ts - samples_per_slot_prev);
|
||||
proc->timestamp_rx = ts-ru->ts_offset;
|
||||
}
|
||||
@@ -656,7 +656,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
|
||||
proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_subframe*10))&1023;
|
||||
proc->tti_rx = fp->get_slot_from_timestamp(proc->timestamp_rx,fp);
|
||||
// synchronize first reception to frame 0 subframe 0
|
||||
LOG_X(PHY,"RU %d/%d TS %llu , frame %d, slot %d.%d / %d\n",
|
||||
LOG_D(PHY,"RU %d/%d TS %llu , frame %d, slot %d.%d / %d\n",
|
||||
ru->idx,
|
||||
0,
|
||||
(unsigned long long int)(proc->timestamp_rx+ru->ts_offset),
|
||||
@@ -782,7 +782,7 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) {
|
||||
siglen+sf_extension,
|
||||
ru->nb_tx,
|
||||
flags);
|
||||
LOG_X(PHY,"[TXPATH] RU %d aa %d tx_rf, writing to TS %llu, %d.%d, unwrapped_frame %d, slot %d, flags %d, siglen+sf_extension %d, returned %d, E %f\n",ru->idx,i,
|
||||
LOG_D(PHY,"[TXPATH] RU %d aa %d tx_rf, writing to TS %llu, %d.%d, unwrapped_frame %d, slot %d, flags %d, siglen+sf_extension %d, returned %d, E %f\n",ru->idx,i,
|
||||
(long long unsigned int)(timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension),frame,slot,proc->frame_tx_unwrap,slot, flags, siglen+sf_extension, txs,10*log10((double)signal_energy(txp[0],siglen+sf_extension)));
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
|
||||
//AssertFatal(txs == 0,"trx write function error %d\n", txs);
|
||||
@@ -1361,7 +1361,7 @@ void *ru_thread( void *param ) {
|
||||
}
|
||||
|
||||
// synchronization on input FH interface, acquire signals/data and block
|
||||
LOG_X(PHY,"[RU_thread] read data: frame_rx = %d, tti_rx = %d\n", frame, slot);
|
||||
LOG_D(PHY,"[RU_thread] read data: frame_rx = %d, tti_rx = %d\n", frame, slot);
|
||||
|
||||
if (ru->fh_south_in) ru->fh_south_in(ru,&frame,&slot);
|
||||
else AssertFatal(1==0, "No fronthaul interface at south port");
|
||||
@@ -1382,7 +1382,7 @@ void *ru_thread( void *param ) {
|
||||
proc->timestamp_tx = proc->timestamp_rx + (sf_ahead*fp->samples_per_subframe);
|
||||
proc->frame_tx = (proc->tti_rx > (fp->slots_per_frame-1-(fp->slots_per_subframe*sf_ahead))) ? (proc->frame_rx+1)&1023 : proc->frame_rx;
|
||||
proc->tti_tx = (proc->tti_rx + (fp->slots_per_subframe*sf_ahead))%fp->slots_per_frame;
|
||||
LOG_X(PHY,"AFTER fh_south_in - SFN/SL:%d%d RU->proc[RX:%d.%d TX:%d.%d] RC.gNB[0]:[RX:%d%d TX(SFN):%d]\n",
|
||||
LOG_D(PHY,"AFTER fh_south_in - SFN/SL:%d%d RU->proc[RX:%d.%d TX:%d.%d] RC.gNB[0]:[RX:%d%d TX(SFN):%d]\n",
|
||||
frame,slot,
|
||||
proc->frame_rx,proc->tti_rx,
|
||||
proc->frame_tx,proc->tti_tx,
|
||||
@@ -1398,9 +1398,9 @@ void *ru_thread( void *param ) {
|
||||
if (ru->feprx) {
|
||||
ru->feprx(ru,proc->tti_rx);
|
||||
//LOG_M("rxdata.m","rxs",ru->common.rxdata[0],1228800,1,1);
|
||||
LOG_X(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx);
|
||||
LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx);
|
||||
/*
|
||||
LOG_X(PHY,"Copying rxdataF from RU to gNB\n");
|
||||
LOG_D(PHY,"Copying rxdataF from RU to gNB\n");
|
||||
|
||||
for (int aa=0; aa<ru->nb_rx; aa++)
|
||||
memcpy((void *)RC.gNB[0]->common_vars.rxdataF[aa],
|
||||
@@ -1494,7 +1494,8 @@ int start_rf(RU_t *ru) {
|
||||
}
|
||||
|
||||
int stop_rf(RU_t *ru) {
|
||||
ru->rfdevice.trx_end_func(&ru->rfdevice);
|
||||
if (ru->rfdevice.trx_end_func )
|
||||
ru->rfdevice.trx_end_func(&ru->rfdevice);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1537,7 +1538,7 @@ void init_RU_proc(RU_t *ru) {
|
||||
void kill_NR_RU_proc(int inst) {
|
||||
RU_t *ru = RC.ru[inst];
|
||||
RU_proc_t *proc = &ru->proc;
|
||||
LOG_X(PHY, "Joining pthread_FH\n");
|
||||
LOG_D(PHY, "Joining pthread_FH\n");
|
||||
pthread_join(proc->pthread_FH, NULL);
|
||||
|
||||
if (get_nprocs() >= 2) {
|
||||
@@ -1546,7 +1547,7 @@ void kill_NR_RU_proc(int inst) {
|
||||
proc->instance_cnt_fep = 0;
|
||||
pthread_mutex_unlock(&proc->mutex_fep);
|
||||
pthread_cond_signal(&proc->cond_fep);
|
||||
LOG_X(PHY, "Joining pthread_fep\n");
|
||||
LOG_D(PHY, "Joining pthread_fep\n");
|
||||
pthread_join(proc->pthread_fep, NULL);
|
||||
pthread_mutex_destroy(&proc->mutex_fep);
|
||||
pthread_cond_destroy(&proc->cond_fep);
|
||||
@@ -1557,7 +1558,7 @@ void kill_NR_RU_proc(int inst) {
|
||||
proc->instance_cnt_feptx = 0;
|
||||
pthread_mutex_unlock(&proc->mutex_feptx);
|
||||
pthread_cond_signal(&proc->cond_feptx);
|
||||
LOG_X(PHY, "Joining pthread_feptx\n");
|
||||
LOG_D(PHY, "Joining pthread_feptx\n");
|
||||
pthread_join(proc->pthread_feptx, NULL);
|
||||
pthread_mutex_destroy(&proc->mutex_feptx);
|
||||
pthread_cond_destroy(&proc->cond_feptx);
|
||||
@@ -1565,7 +1566,7 @@ void kill_NR_RU_proc(int inst) {
|
||||
}
|
||||
|
||||
if (opp_enabled) {
|
||||
LOG_X(PHY, "Joining ru_stats_thread\n");
|
||||
LOG_D(PHY, "Joining ru_stats_thread\n");
|
||||
pthread_join(ru->ru_stats_thread, NULL);
|
||||
}
|
||||
}
|
||||
@@ -1907,10 +1908,10 @@ void init_NR_RU(char *rf_config_file) {
|
||||
printf("configuring RU from file\n");
|
||||
NRRCconfig_RU();
|
||||
LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n",RC.nb_nr_L1_inst,RC.nb_RU,get_nprocs());
|
||||
LOG_X(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU);
|
||||
LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU);
|
||||
|
||||
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
|
||||
LOG_X(PHY,"Process RC.ru[%d]\n",ru_id);
|
||||
LOG_D(PHY,"Process RC.ru[%d]\n",ru_id);
|
||||
ru = RC.ru[ru_id];
|
||||
ru->rf_config_file = rf_config_file;
|
||||
ru->idx = ru_id;
|
||||
@@ -1919,7 +1920,7 @@ void init_NR_RU(char *rf_config_file) {
|
||||
// NOTE: multiple CC_id are not handled here yet!
|
||||
|
||||
if (ru->num_gNB > 0) {
|
||||
LOG_X(PHY, "%s() RC.ru[%d].num_gNB:%d ru->gNB_list[0]:%p RC.gNB[0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_gNB, ru->gNB_list[0], RC.gNB[0], ru->rf_config_file);
|
||||
LOG_D(PHY, "%s() RC.ru[%d].num_gNB:%d ru->gNB_list[0]:%p RC.gNB[0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_gNB, ru->gNB_list[0], RC.gNB[0], ru->rf_config_file);
|
||||
|
||||
if (ru->gNB_list[0] == 0) {
|
||||
LOG_E(PHY,"%s() DJP - ru->gNB_list ru->num_gNB are not initialized - so do it manually\n", __FUNCTION__);
|
||||
@@ -1936,7 +1937,7 @@ void init_NR_RU(char *rf_config_file) {
|
||||
gNB_RC = RC.gNB[0];
|
||||
gNB0 = ru->gNB_list[0];
|
||||
fp = ru->nr_frame_parms;
|
||||
LOG_X(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south);
|
||||
LOG_D(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south);
|
||||
|
||||
if (gNB0) {
|
||||
if ((ru->function != NGFI_RRU_IF5) && (ru->function != NGFI_RRU_IF4p5))
|
||||
@@ -1948,7 +1949,7 @@ void init_NR_RU(char *rf_config_file) {
|
||||
memcpy((void *)fp,&gNB_RC->frame_parms,sizeof(NR_DL_FRAME_PARMS));
|
||||
memcpy((void *)&gNB0->frame_parms,(void *)&gNB_RC->frame_parms,sizeof(NR_DL_FRAME_PARMS));
|
||||
// attach all RU to all gNBs in its list/
|
||||
LOG_X(PHY,"ru->num_gNB:%d gNB0->num_RU:%d\n", ru->num_gNB, gNB0->num_RU);
|
||||
LOG_D(PHY,"ru->num_gNB:%d gNB0->num_RU:%d\n", ru->num_gNB, gNB0->num_RU);
|
||||
|
||||
for (i=0; i<ru->num_gNB; i++) {
|
||||
gNB0 = ru->gNB_list[i];
|
||||
|
||||
@@ -90,11 +90,6 @@
|
||||
#define CONFIG_HLP_DISABLETIMECORR "disable UE timing correction\n"
|
||||
#define CONFIG_HLP_RRC_CFG_PATH "path for RRC configuration\n"
|
||||
#define CONFIG_HLP_UECAP_FILE "path for UE Capabilities file\n"
|
||||
// L5G_IOT
|
||||
#define CONFIG_HLP_EN_PROM "Enable Prometheus monitoring\n"
|
||||
#define CONFIG_HLP_PROM_PORT "Specify TCP-IP port for prmetheus\n"
|
||||
#define CONFIG_HLP_PARA_PULL "Enable parallel pulling thread pool\n"
|
||||
#define CONFIG_HLP_DIS_SHMLOG "disable duplicate console log to shared memory"
|
||||
|
||||
#define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n"
|
||||
#define CONFIG_HLP_EMULATE_RF "Emulated RF enabled(disable by defult)\n"
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include "LAYER2/nr_pdcp/nr_pdcp_entity.h"
|
||||
#include "SCHED_NR_UE/pucch_uci_ue_nr.h"
|
||||
#include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h"
|
||||
// L5G_IOT
|
||||
#include "prometheus_exporter.h"
|
||||
|
||||
/*
|
||||
* NR SLOT PROCESSING SEQUENCE
|
||||
@@ -93,6 +91,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define RX_JOB_ID 0x1010
|
||||
#define TX_JOB_ID 100
|
||||
|
||||
@@ -131,7 +130,7 @@ static void *nrL1_UE_stats_thread(void *param)
|
||||
const int max_len = 16384;
|
||||
char output[max_len];
|
||||
char filename[30];
|
||||
snprintf(filename, 29, "/dev/shm/nrL1_UE_stats-%d.log", ue->Mod_id);
|
||||
snprintf(filename, 29, "nrL1_UE_stats-%d.log", ue->Mod_id);
|
||||
filename[29] = 0;
|
||||
FILE *fd = fopen(filename, "w");
|
||||
AssertFatal(fd != NULL, "Cannot open %s\n", filename);
|
||||
@@ -140,15 +139,9 @@ static void *nrL1_UE_stats_thread(void *param)
|
||||
sleep(1);
|
||||
const int len = dump_L1_UE_meas_stats(ue, output, max_len);
|
||||
AssertFatal(len < max_len, "exceeded length\n");
|
||||
time_t t = time(NULL);
|
||||
struct tm *local = localtime(&t);
|
||||
char buf[128];
|
||||
strftime(buf,sizeof(buf),"%Y/%m/%d/ %H:%M:%S\n",local);
|
||||
fprintf(fd,"%s",buf);
|
||||
fprintf(fd,"%s\n",output); // + 1 for terminating NULL byte
|
||||
// fwrite(output, len + 1, 1, fd); // + 1 for terminating NULL byte
|
||||
fwrite(output, len + 1, 1, fd); // + 1 for terminating NULL byte
|
||||
fflush(fd);
|
||||
// fseek(fd, 0, SEEK_SET);
|
||||
fseek(fd, 0, SEEK_SET);
|
||||
}
|
||||
fclose(fd);
|
||||
|
||||
@@ -242,7 +235,7 @@ static void L1_nsa_prach_procedures(frame_t frame, int slot, fapi_nr_ul_config_p
|
||||
free(rach_ind->pdu_list);
|
||||
free(rach_ind);
|
||||
}
|
||||
LOG_X(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n");
|
||||
LOG_D(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n");
|
||||
}
|
||||
|
||||
static bool sfn_slot_matcher(void *wanted, void *candidate)
|
||||
@@ -316,12 +309,12 @@ static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn_slot)
|
||||
nfapi_nr_dl_tti_request_t *dl_tti_request = get_queue(&nr_dl_tti_req_queue);
|
||||
nfapi_nr_ul_dci_request_t *ul_dci_request = get_queue(&nr_ul_dci_req_queue);
|
||||
|
||||
LOG_X(NR_MAC, "Try to get a ul_tti_req for sfn/slot %d %d from queue with %lu items\n",
|
||||
LOG_D(NR_MAC, "Try to get a ul_tti_req for sfn/slot %d %d from queue with %lu items\n",
|
||||
NFAPI_SFNSLOT2SFN(mac->nr_ue_emul_l1.active_harq_sfn_slot),NFAPI_SFNSLOT2SLOT(mac->nr_ue_emul_l1.active_harq_sfn_slot), nr_ul_tti_req_queue.num_items);
|
||||
nfapi_nr_ul_tti_request_t *ul_tti_request = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.active_harq_sfn_slot);
|
||||
if (!ul_tti_request)
|
||||
{
|
||||
LOG_X(NR_MAC, "Try to get a ul_tti_req from seprate queue because dl_tti_req was late\n");
|
||||
LOG_D(NR_MAC, "Try to get a ul_tti_req from seprate queue because dl_tti_req was late\n");
|
||||
ul_tti_request = unqueue_matching(&nr_wait_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &mac->nr_ue_emul_l1.active_harq_sfn_slot);
|
||||
}
|
||||
|
||||
@@ -460,7 +453,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
|
||||
nr_phy_channel_params_t *ch_info = get_queue(&nr_chan_param_queue);
|
||||
if (!slot_ind && !ch_info)
|
||||
{
|
||||
LOG_X(MAC, "get nr_sfn_slot_queue and nr_chan_param_queue == NULL!\n");
|
||||
LOG_D(MAC, "get nr_sfn_slot_queue and nr_chan_param_queue == NULL!\n");
|
||||
continue;
|
||||
}
|
||||
if (slot_ind) {
|
||||
@@ -474,26 +467,26 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
|
||||
int slot = NFAPI_SFNSLOT2SLOT(sfn_slot);
|
||||
if (sfn_slot == last_sfn_slot)
|
||||
{
|
||||
LOG_X(NR_MAC, "repeated sfn_sf = %d.%d\n",
|
||||
LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n",
|
||||
frame, slot);
|
||||
continue;
|
||||
}
|
||||
last_sfn_slot = sfn_slot;
|
||||
|
||||
LOG_X(NR_MAC, "The received sfn/slot [%d %d] from proxy\n",
|
||||
LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n",
|
||||
frame, slot);
|
||||
|
||||
module_id_t mod_id = 0;
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
|
||||
if (get_softmodem_params()->sa && mac->mib == NULL)
|
||||
{
|
||||
LOG_X(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n");
|
||||
LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n");
|
||||
nr_ue_dl_indication(&mac->dl_info, &ul_time_alignment);
|
||||
process_queued_nr_nfapi_msgs(mac, sfn_slot);
|
||||
}
|
||||
if (mac->scc == NULL && mac->scc_SIB == NULL)
|
||||
{
|
||||
LOG_X(MAC, "[NSA] mac->scc == NULL and [SA] mac->scc_SIB == NULL!\n");
|
||||
LOG_D(MAC, "[NSA] mac->scc == NULL and [SA] mac->scc_SIB == NULL!\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -539,7 +532,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
|
||||
mac->scc_SIB->tdd_UL_DL_ConfigurationCommon,
|
||||
ul_info.slot_tx, mac->frame_type))
|
||||
{
|
||||
LOG_X(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", ul_info.slot_tx, __FUNCTION__);
|
||||
LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind() from %s\n", ul_info.slot_tx, __FUNCTION__);
|
||||
nr_ue_ul_indication(&ul_info);
|
||||
check_nr_prach(mac, &ul_info, &prach_resources);
|
||||
}
|
||||
@@ -711,7 +704,7 @@ void processSlotTX(void *arg) {
|
||||
int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_slot_tx);
|
||||
uint8_t gNB_id = 0;
|
||||
|
||||
// LOG_X(PHY,"%d.%d => slot type %d\n",proc->frame_tx,proc->nr_slot_tx,tx_slot_type);
|
||||
LOG_D(PHY,"%d.%d => slot type %d\n",proc->frame_tx,proc->nr_slot_tx,tx_slot_type);
|
||||
if (tx_slot_type == NR_UPLINK_SLOT || tx_slot_type == NR_MIXED_SLOT){
|
||||
|
||||
// trigger L2 to run ue_scheduler thru IF module
|
||||
@@ -775,7 +768,7 @@ void processSlotRX(void *arg) {
|
||||
#else
|
||||
uint64_t a=rdtsc_oai();
|
||||
phy_procedures_nrUE_RX(UE, proc, gNB_id, get_nrUE_params()->nr_dlsch_parallel, &rxtxD->txFifo);
|
||||
LOG_X(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500);
|
||||
LOG_D(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500);
|
||||
#endif
|
||||
|
||||
if(IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa){
|
||||
@@ -784,9 +777,7 @@ void processSlotRX(void *arg) {
|
||||
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO, mac->crnti, proc->frame_rx, proc->nr_slot_rx, 0);
|
||||
pdcp_run(&ctxt);
|
||||
}
|
||||
// TODO L5G
|
||||
|
||||
#if 0
|
||||
// Wait for PUSCH processing to finish
|
||||
notifiedFIFO_elt_t *res;
|
||||
res = pullTpool(&rxtxD->txFifo,&(get_nrUE_params()->Tpool));
|
||||
@@ -794,34 +785,19 @@ void processSlotRX(void *arg) {
|
||||
|
||||
// calling UL_indication to schedule things other than PUSCH (eg, PUCCH)
|
||||
rxtxD->ue_sched_mode = NOT_PUSCH;
|
||||
if(tx_slot_type==NR_MIXED_SLOT) rxtxD->ue_sched_mode = SCHED_ALL;
|
||||
processSlotTX(rxtxD);
|
||||
#else
|
||||
// calling UL_indication to schedule things other than PUSCH (eg, PUCCH)
|
||||
rxtxD->ue_sched_mode = NOT_PUSCH;
|
||||
// if(tx_slot_type==NR_MIXED_SLOT) rxtxD->ue_sched_mode = SCHED_ALL;
|
||||
processSlotTX(rxtxD);
|
||||
|
||||
// Wait for PUSCH processing to finish
|
||||
notifiedFIFO_elt_t *res;
|
||||
res = pullTpool(&rxtxD->txFifo,&(get_nrUE_params()->Tpool));
|
||||
delNotifiedFIFO_elt(res);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
// UL Slot
|
||||
rxtxD->ue_sched_mode = SCHED_ALL;
|
||||
processSlotTX(rxtxD);
|
||||
}
|
||||
|
||||
//LOG_X(RLC,"tx_slot_type %d ( NR_UPLINK_SLOT %d NR_MIXED_SLOT %d )\n", tx_slot_type, NR_UPLINK_SLOT, NR_MIXED_SLOT);
|
||||
if (tx_slot_type == NR_UPLINK_SLOT || tx_slot_type == NR_MIXED_SLOT){
|
||||
if (UE->UE_mode[gNB_id] <= PUSCH) {
|
||||
if (get_softmodem_params()->usim_test==0) {
|
||||
pucch_procedures_ue_nr(UE,
|
||||
gNB_id,
|
||||
proc);
|
||||
//LOG_X(RLC,"pucch_procedures_ue_nr finished @ %d : %d \n",proc->frame_tx, proc->nr_slot_tx);
|
||||
}
|
||||
|
||||
LOG_D(PHY, "Sending Uplink data \n");
|
||||
@@ -856,8 +832,7 @@ void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockS
|
||||
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
|
||||
free(dummy_tx[i]);
|
||||
}
|
||||
int global_readframe=0;
|
||||
int temp_sync_frame=0;
|
||||
|
||||
void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, bool toTrash) {
|
||||
|
||||
void *rxp[NB_ANTENNAS_RX];
|
||||
@@ -873,15 +848,12 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, bool toTrash)
|
||||
UE->frame_parms.get_samples_slot_timestamp(slot,&UE->frame_parms,0));
|
||||
}
|
||||
|
||||
if ( UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms) !=
|
||||
UE->rfdevice.trx_read_func(&UE->rfdevice,
|
||||
timestamp,
|
||||
rxp,
|
||||
UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms),
|
||||
UE->frame_parms.nb_antennas_rx)) {
|
||||
LOG_E(PHY, "get_samples_per_slot != trx_read_func \n");
|
||||
UE->lost_sync=1;
|
||||
}
|
||||
AssertFatal( UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms) ==
|
||||
UE->rfdevice.trx_read_func(&UE->rfdevice,
|
||||
timestamp,
|
||||
rxp,
|
||||
UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms),
|
||||
UE->frame_parms.nb_antennas_rx), "");
|
||||
|
||||
if (IS_SOFTMODEM_RFSIM)
|
||||
dummyWrite(UE,*timestamp, UE->frame_parms.get_samples_per_slot(slot,&UE->frame_parms));
|
||||
@@ -890,8 +862,7 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, bool toTrash)
|
||||
free(rxp[i]);
|
||||
}
|
||||
}
|
||||
if(!toTrash) temp_sync_frame=global_readframe;
|
||||
global_readframe++;
|
||||
|
||||
}
|
||||
|
||||
void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
|
||||
@@ -916,7 +887,6 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
|
||||
}
|
||||
|
||||
int computeSamplesShift(PHY_VARS_NR_UE *UE) {
|
||||
#if 0 // L5G debug
|
||||
int samples_shift = -(UE->rx_offset>>1);
|
||||
UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame
|
||||
UE->max_pos_fil = 0; // reset IIR filter when sample shift is applied
|
||||
@@ -924,13 +894,6 @@ int computeSamplesShift(PHY_VARS_NR_UE *UE) {
|
||||
LOG_I(NR_PHY,"Adjusting frame in time by %i samples\n", samples_shift);
|
||||
}
|
||||
return samples_shift;
|
||||
#else
|
||||
if ( UE->rx_offset > 0 ) {
|
||||
return -1 ;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int get_firstSymSamp(uint16_t slot, NR_DL_FRAME_PARMS *fp) {
|
||||
@@ -949,23 +912,9 @@ static inline int get_readBlockSize(uint16_t slot, NR_DL_FRAME_PARMS *fp) {
|
||||
return rem_samples + next_slot_first_symbol;
|
||||
}
|
||||
|
||||
int nbSlotProcessing;
|
||||
notifiedFIFO_t nf;
|
||||
int decoded_frame_rx;
|
||||
NR_UE_MAC_INST_t *mac;
|
||||
notifiedFIFO_t freeBlocks;
|
||||
nr_rxtx_thread_data_t *curMsg;
|
||||
notifiedFIFO_elt_t *msgToPush;
|
||||
int absolute_slot;
|
||||
PHY_VARS_NR_UE *UE;
|
||||
int nb_slot_frame;
|
||||
|
||||
volatile int ready_1 = 0;
|
||||
volatile int ready_2 = 0;
|
||||
|
||||
void *UE_thread(void *arg) {
|
||||
//this thread should be over the processing thread to keep in real time
|
||||
UE = (PHY_VARS_NR_UE *) arg; // PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg; // L5G_IOT
|
||||
PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg;
|
||||
// int tx_enabled = 0;
|
||||
openair0_timestamp timestamp, writeTimestamp;
|
||||
void *rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX];
|
||||
@@ -976,34 +925,24 @@ void *UE_thread(void *arg) {
|
||||
UE->is_synchronized = 0;
|
||||
AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0, "Could not start the device\n");
|
||||
|
||||
// L5G_IOT
|
||||
if (enable_parallel_pull != 0) LOG_I(PHY,"pull thread enabled ( %d )\n",enable_parallel_pull);
|
||||
else LOG_I(PHY,"pull thread disabled ( %d ) (Original Mode)\n",enable_parallel_pull);
|
||||
|
||||
// notifiedFIFO_t nf; // L5G_IOT
|
||||
notifiedFIFO_t nf;
|
||||
initNotifiedFIFO(&nf);
|
||||
|
||||
// notifiedFIFO_t freeBlocks; // L5G_IOT
|
||||
notifiedFIFO_t freeBlocks;
|
||||
initNotifiedFIFO_nothreadSafe(&freeBlocks);
|
||||
|
||||
nbSlotProcessing=0; // int nbSlotProcessing=0; // L5G_IOT
|
||||
int nbSlotProcessing=0;
|
||||
int thread_idx=0;
|
||||
mac = get_mac_inst(0); // NR_UE_MAC_INST_t *mac = get_mac_inst(0); // L5G_IOT
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
|
||||
int timing_advance = UE->timing_advance;
|
||||
|
||||
bool syncRunning=false;
|
||||
// const int nb_slot_frame = UE->frame_parms.slots_per_frame; // L5G_IOT
|
||||
nb_slot_frame = UE->frame_parms.slots_per_frame; // L5G_IOT
|
||||
absolute_slot=0; // int absolute_slot=0; // L5G_IOT
|
||||
int decoded_frame_rx=INT_MAX, trashed_frames=0; // int decoded_frame_rx=INT_MAX, trashed_frames=0; // L5G_IOT
|
||||
if(usrp_tx_thread == 1) {
|
||||
UE->rfdevice.trx_write_init(&UE->rfdevice);
|
||||
}
|
||||
const int nb_slot_frame = UE->frame_parms.slots_per_frame;
|
||||
int absolute_slot=0, decoded_frame_rx=INT_MAX, trashed_frames=0;
|
||||
|
||||
for (int i=0; i<NR_RX_NB_TH+1; i++) {// NR_RX_NB_TH working + 1 we are making to be pushed
|
||||
notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), RX_JOB_ID,&nf,processSlotRX);
|
||||
// L5G_IOT // nr_rxtx_thread_data_t *curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(newElt);
|
||||
curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(newElt);
|
||||
nr_rxtx_thread_data_t *curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(newElt);
|
||||
initNotifiedFIFO(&curMsg->txFifo);
|
||||
pushNotifiedFIFO_nothreadSafe(&freeBlocks, newElt);
|
||||
}
|
||||
@@ -1043,10 +982,6 @@ void *UE_thread(void *arg) {
|
||||
AssertFatal( !syncRunning, "At this point synchronization can't be running\n");
|
||||
|
||||
if (!UE->is_synchronized) {
|
||||
if(((global_readframe-temp_sync_frame)%2)==0){
|
||||
LOG_E(PHY, "dummy read\n");
|
||||
readFrame(UE, ×tamp, true);
|
||||
}
|
||||
readFrame(UE, ×tamp, false);
|
||||
notifiedFIFO_elt_t *Msg=newNotifiedFIFO_elt(sizeof(syncData_t),0,&nf,UE_synch);
|
||||
syncData_t *syncMsg=(syncData_t *)NotifiedFifoData(Msg);
|
||||
@@ -1081,37 +1016,26 @@ void *UE_thread(void *arg) {
|
||||
|
||||
absolute_slot++;
|
||||
|
||||
// L5G_IOT
|
||||
int thread_idx = absolute_slot % NR_RX_NB_TH;
|
||||
// whatever means thread_idx
|
||||
// Fix me: will be wrong when slot 1 is slow, as slot 2 finishes
|
||||
// Slot 3 will overlap if NR_RX_NB_TH is 2
|
||||
// this is general failure in UE !!!
|
||||
thread_idx = absolute_slot % NR_RX_NB_TH;
|
||||
int slot_nr = absolute_slot % nb_slot_frame;
|
||||
// L5G_IOT
|
||||
if (enable_parallel_pull != 0){
|
||||
ready_1 = 1;
|
||||
} else {
|
||||
notifiedFIFO_elt_t *msgToPush;
|
||||
AssertFatal((msgToPush=pullNotifiedFIFO_nothreadSafe(&freeBlocks)) != NULL,"chained list failure");
|
||||
nr_rxtx_thread_data_t *curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(msgToPush);
|
||||
curMsg->UE=UE;
|
||||
// update thread index for received subframe
|
||||
curMsg->proc.thread_id = thread_idx;
|
||||
curMsg->proc.CC_id = UE->CC_id;
|
||||
curMsg->proc.nr_slot_rx = slot_nr;
|
||||
curMsg->proc.nr_slot_tx = (absolute_slot + DURATION_RX_TO_TX) % nb_slot_frame;
|
||||
curMsg->proc.frame_rx = (absolute_slot/nb_slot_frame) % MAX_FRAME_NUMBER;
|
||||
curMsg->proc.frame_tx = ((absolute_slot+DURATION_RX_TO_TX)/nb_slot_frame) % MAX_FRAME_NUMBER;
|
||||
curMsg->proc.decoded_frame_rx=-1;
|
||||
//LOG_I(PHY,"Process slot %d thread Idx %d total gain %d\n", slot_nr, thread_idx, UE->rx_total_gain_dB);
|
||||
|
||||
// whatever means thread_idx
|
||||
// Fix me: will be wrong when slot 1 is slow, as slot 2 finishes
|
||||
// Slot 3 will overlap if NR_RX_NB_TH is 2
|
||||
// this is general failure in UE !!!
|
||||
|
||||
// L5G_IOT
|
||||
// thread_idx = absolute_slot % NR_RX_NB_TH;
|
||||
// int slot_nr = absolute_slot % nb_slot_frame;
|
||||
|
||||
// notifiedFIFO_elt_t *msgToPush; // L5G_IOT
|
||||
AssertFatal((msgToPush=pullNotifiedFIFO_nothreadSafe(&freeBlocks)) != NULL,"chained list failure");
|
||||
nr_rxtx_thread_data_t *curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(msgToPush);
|
||||
curMsg->UE=UE;
|
||||
// update thread index for received subframe
|
||||
curMsg->proc.thread_id = thread_idx;
|
||||
curMsg->proc.CC_id = UE->CC_id;
|
||||
curMsg->proc.nr_slot_rx = slot_nr;
|
||||
curMsg->proc.nr_slot_tx = (absolute_slot + DURATION_RX_TO_TX) % nb_slot_frame;
|
||||
curMsg->proc.frame_rx = (absolute_slot/nb_slot_frame) % MAX_FRAME_NUMBER;
|
||||
curMsg->proc.frame_tx = ((absolute_slot+DURATION_RX_TO_TX)/nb_slot_frame) % MAX_FRAME_NUMBER;
|
||||
curMsg->proc.decoded_frame_rx=-1;
|
||||
//LOG_I(PHY,"Process slot %d thread Idx %d total gain %d\n", slot_nr, thread_idx, UE->rx_total_gain_dB);
|
||||
}
|
||||
#ifdef OAI_ADRV9371_ZC706
|
||||
/*uint32_t total_gain_dB_prev = 0;
|
||||
if (total_gain_dB_prev != UE->rx_total_gain_dB) {
|
||||
@@ -1142,33 +1066,25 @@ void *UE_thread(void *arg) {
|
||||
writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms)- UE->rx_offset_diff;
|
||||
}
|
||||
|
||||
if(readBlockSize !=
|
||||
AssertFatal(readBlockSize ==
|
||||
UE->rfdevice.trx_read_func(&UE->rfdevice,
|
||||
×tamp,
|
||||
rxp,
|
||||
readBlockSize,
|
||||
UE->frame_parms.nb_antennas_rx)){
|
||||
LOG_E(PHY, "get_samples_per_slot != trx_read_func \n");
|
||||
UE->lost_sync=1;
|
||||
}
|
||||
// LOG_X(RLC,"Got USRP data!\n");
|
||||
// L5G_IOT
|
||||
PROM_METRICS(RX_OFFSET,"rx_offset",UE->rx_offset)
|
||||
UE->frame_parms.nb_antennas_rx),"");
|
||||
|
||||
if( slot_nr==(nb_slot_frame-1)) {
|
||||
// read in first symbol of next frame and adjust for timing drift
|
||||
int first_symbols=UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0; // first symbol of every frames
|
||||
|
||||
if ( first_symbols > 0 ) {
|
||||
openair0_timestamp ignore_timestamp;
|
||||
if(first_symbols !=
|
||||
AssertFatal(first_symbols ==
|
||||
UE->rfdevice.trx_read_func(&UE->rfdevice,
|
||||
&ignore_timestamp,
|
||||
(void **)UE->common_vars.rxdata,
|
||||
first_symbols,
|
||||
UE->frame_parms.nb_antennas_rx)){
|
||||
LOG_E(PHY, "get_samples_per_slot != trx_read_func \n");
|
||||
UE->lost_sync=1;
|
||||
}
|
||||
UE->frame_parms.nb_antennas_rx),"");
|
||||
} else
|
||||
LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
|
||||
}
|
||||
@@ -1176,37 +1092,31 @@ void *UE_thread(void *arg) {
|
||||
curMsg->proc.timestamp_tx = timestamp+
|
||||
UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX)
|
||||
- firstSymSamp;
|
||||
|
||||
// L5G_IOT
|
||||
if (enable_parallel_pull !=0){
|
||||
ready_2 = 1;
|
||||
} else { // L5G_IOT
|
||||
notifiedFIFO_elt_t *res;
|
||||
|
||||
while (nbSlotProcessing >= NR_RX_NB_TH) {
|
||||
res=pullTpool(&nf, &(get_nrUE_params()->Tpool));
|
||||
nbSlotProcessing--;
|
||||
nr_rxtx_thread_data_t *tmp=(nr_rxtx_thread_data_t *)res->msgData;
|
||||
notifiedFIFO_elt_t *res;
|
||||
|
||||
if (tmp->proc.decoded_frame_rx != -1)
|
||||
decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx);
|
||||
else
|
||||
decoded_frame_rx=-1;
|
||||
|
||||
pushNotifiedFIFO_nothreadSafe(&freeBlocks,res);
|
||||
}
|
||||
while (nbSlotProcessing >= NR_RX_NB_TH) {
|
||||
res=pullTpool(&nf, &(get_nrUE_params()->Tpool));
|
||||
nbSlotProcessing--;
|
||||
nr_rxtx_thread_data_t *tmp=(nr_rxtx_thread_data_t *)res->msgData;
|
||||
|
||||
if (decoded_frame_rx>0 && decoded_frame_rx != curMsg->proc.frame_rx)
|
||||
LOG_E(PHY,"Decoded frame index (%d) is not compatible with current context (%d), UE should go back to synch mode\n",
|
||||
decoded_frame_rx, curMsg->proc.frame_rx);
|
||||
} // L5G_IOT
|
||||
if (tmp->proc.decoded_frame_rx != -1)
|
||||
decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx);
|
||||
else
|
||||
decoded_frame_rx=-1;
|
||||
|
||||
pushNotifiedFIFO_nothreadSafe(&freeBlocks,res);
|
||||
}
|
||||
|
||||
if (decoded_frame_rx>0 && decoded_frame_rx != curMsg->proc.frame_rx)
|
||||
LOG_E(PHY,"Decoded frame index (%d) is not compatible with current context (%d), UE should go back to synch mode\n",
|
||||
decoded_frame_rx, curMsg->proc.frame_rx);
|
||||
|
||||
// use previous timing_advance value to compute writeTimestamp
|
||||
writeTimestamp = timestamp+
|
||||
UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX
|
||||
- NR_RX_NB_TH) - firstSymSamp - openair0_cfg[0].tx_sample_advance -
|
||||
// UE->N_TA_offset - timing_advance - (-3*32);
|
||||
UE->N_TA_offset - 192;
|
||||
UE->N_TA_offset - timing_advance;
|
||||
|
||||
// but use current UE->timing_advance value to compute writeBlockSize
|
||||
if (UE->timing_advance != timing_advance) {
|
||||
@@ -1214,92 +1124,51 @@ void *UE_thread(void *arg) {
|
||||
timing_advance = UE->timing_advance;
|
||||
}
|
||||
|
||||
mac = get_mac_inst(0);
|
||||
int flags = 0;
|
||||
int slot_tx_usrp = slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH;
|
||||
|
||||
int scc_flag=0;
|
||||
if(mac->scc != NULL)
|
||||
scc_flag=1;
|
||||
else if( mac->scc_SIB != NULL)
|
||||
scc_flag=2;
|
||||
|
||||
if(scc_flag==0){
|
||||
flags=0;
|
||||
} else if (openair0_cfg[0].duplex_mode == duplex_mode_TDD) {
|
||||
if (openair0_cfg[0].duplex_mode == duplex_mode_TDD) {
|
||||
|
||||
uint8_t tdd_period = mac->phy_config.config_req.tdd_table.tdd_period_in_slots;
|
||||
int nrofUplinkSlots, nrofUplinkSymbols;
|
||||
int nrofDownlinkSlots, nrofDownlinkSymbols;
|
||||
if (scc_flag==1) {
|
||||
if (mac->scc) {
|
||||
nrofUplinkSlots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
|
||||
nrofUplinkSymbols = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols;
|
||||
nrofDownlinkSlots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots;
|
||||
nrofDownlinkSymbols = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
nrofUplinkSlots = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots;
|
||||
nrofUplinkSymbols = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols;
|
||||
nrofDownlinkSlots = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSlots;
|
||||
nrofDownlinkSymbols = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofDownlinkSymbols;
|
||||
}
|
||||
uint8_t num_UL_slots = nrofUplinkSlots + (nrofUplinkSymbols != 0);
|
||||
|
||||
uint8_t first_tx_slot = tdd_period - num_UL_slots;
|
||||
|
||||
if (scc_flag==1) {
|
||||
if( (mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1 != NULL) &&
|
||||
(mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 != NULL) ){
|
||||
if(*mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530==0){
|
||||
uint8_t first_num_DL_slots = nrofDownlinkSlots + (nrofDownlinkSymbols != 0);
|
||||
first_tx_slot = first_num_DL_slots + (nrofUplinkSymbols != 0);
|
||||
}else{
|
||||
AssertFatal(1==0, "not implemented dl_UL_TransmissionPeriodicity_v1530 %d\n",*mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530);
|
||||
}
|
||||
}
|
||||
}else if(scc_flag==2){
|
||||
if( (mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.ext1 != NULL) &&
|
||||
(mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530 != NULL) ){
|
||||
if(*mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530==0){
|
||||
uint8_t first_num_DL_slots = nrofDownlinkSlots + (nrofDownlinkSymbols != 0);
|
||||
first_tx_slot = first_num_DL_slots - (nrofUplinkSymbols*nrofDownlinkSymbols != 0);
|
||||
}else{
|
||||
AssertFatal(1==0, "not implemented dl_UL_TransmissionPeriodicity_v1530 %d\n",*mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.ext1->dl_UL_TransmissionPeriodicity_v1530);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slot_tx_usrp % tdd_period == first_tx_slot)
|
||||
flags = 2;
|
||||
else if (slot_tx_usrp % tdd_period == first_tx_slot + num_UL_slots - 1)
|
||||
flags = 3;
|
||||
else if ( (slot_tx_usrp % tdd_period > first_tx_slot) && ( ((slot_tx_usrp % tdd_period) - first_tx_slot) < num_UL_slots ) )
|
||||
else if (slot_tx_usrp % tdd_period > first_tx_slot)
|
||||
flags = 1;
|
||||
|
||||
} else {
|
||||
flags = 1;
|
||||
}
|
||||
|
||||
if (enable_parallel_pull !=0){
|
||||
usleep(150); // wait for ul to finish
|
||||
}
|
||||
|
||||
//LOG_X(RLC,"-----> slot to send: %d\n",((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame) - UE->rx_offset_diff);
|
||||
|
||||
if (flags || IS_SOFTMODEM_RFSIM)
|
||||
AssertFatal(writeBlockSize ==
|
||||
UE->rfdevice.trx_write_func(&UE->rfdevice,
|
||||
writeTimestamp,
|
||||
txp,
|
||||
writeBlockSize,
|
||||
UE->frame_parms.nb_antennas_tx,
|
||||
flags);
|
||||
flags),"");
|
||||
|
||||
//TODO L5G
|
||||
//for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
|
||||
// memset(txp[i], 0, writeBlockSize);
|
||||
if (enable_parallel_pull == 0){ // L5G_IOT
|
||||
nbSlotProcessing++;
|
||||
LOG_X(PHY,"Number of slots being processed at the moment: %d\n",nbSlotProcessing);
|
||||
pushTpool(&(get_nrUE_params()->Tpool), msgToPush);
|
||||
} // L5G_IOT
|
||||
for (int i=0; i<UE->frame_parms.nb_antennas_tx; i++)
|
||||
memset(txp[i], 0, writeBlockSize);
|
||||
|
||||
nbSlotProcessing++;
|
||||
LOG_D(PHY,"Number of slots being processed at the moment: %d\n",nbSlotProcessing);
|
||||
pushTpool(&(get_nrUE_params()->Tpool), msgToPush);
|
||||
|
||||
} // while !oai_exit
|
||||
|
||||
return NULL;
|
||||
@@ -1333,116 +1202,6 @@ void init_NR_UE_threads(int nb_inst) {
|
||||
threadCreate(&stat_pthread, nrL1_UE_stats_thread, UE, "L1_UE_stats", -1, OAI_PRIORITY_RT_LOW);
|
||||
}
|
||||
}
|
||||
// L5G_IOT
|
||||
void *pullthread(void* arg){
|
||||
struct timespec loc_ts,te,loc_prev_ts;
|
||||
long loc_lstart, loc_lend;
|
||||
notifiedFIFO_elt_t *res;
|
||||
int slot_offset = 0;
|
||||
|
||||
while(1){
|
||||
#ifdef READY_LOG
|
||||
if (ready_1 == 1){
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &loc_ts);
|
||||
LOG_I(PHY,"%s already ready_1 ( %ld %ld ) \n",__FUNCTION__,loc_ts.tv_sec, loc_ts.tv_nsec);
|
||||
} else LOG_I(PHY,"%s ready_1 not set (OK) ( %ld %ld ) \n",__FUNCTION__,loc_ts.tv_sec, loc_ts.tv_nsec);
|
||||
#endif
|
||||
while (!ready_1){
|
||||
usleep(10);
|
||||
}
|
||||
ready_1 = 0;
|
||||
|
||||
{
|
||||
// whatever means thread_idx
|
||||
// Fix me: will be wrong when slot 1 is slow, as slot 2 finishes
|
||||
// Slot 3 will overlap if NR_RX_NB_TH is 2
|
||||
// this is general failure in UE !!!
|
||||
int thread_idx = (absolute_slot - slot_offset) % NR_RX_NB_TH;
|
||||
int slot_nr = (absolute_slot - slot_offset) % nb_slot_frame;
|
||||
// notifiedFIFO_elt_t *msgToPush;
|
||||
AssertFatal((msgToPush=pullNotifiedFIFO_nothreadSafe(&freeBlocks)) != NULL,"chained list failure");
|
||||
#ifdef FIFO_LOG
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &loc_ts);
|
||||
LOG_I(PHY,"%s ( %ld %ld ) pullNotifiedFIFO_nothreadSafe key = %ld (thread : %d slot : %d )\n",
|
||||
__FUNCTION__,loc_ts.tv_sec, loc_ts.tv_nsec, msgToPush->key, thread_idx, slot_nr);
|
||||
#endif
|
||||
// nr_rxtx_thread_data_t *curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(msgToPush);
|
||||
curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(msgToPush);
|
||||
curMsg->UE=UE;
|
||||
// update thread index for received subframe
|
||||
curMsg->proc.thread_id = thread_idx;
|
||||
curMsg->proc.CC_id = UE->CC_id;
|
||||
curMsg->proc.nr_slot_rx = slot_nr;
|
||||
curMsg->proc.nr_slot_tx = ((absolute_slot - slot_offset) + DURATION_RX_TO_TX) % nb_slot_frame;
|
||||
curMsg->proc.frame_rx = ((absolute_slot - slot_offset) /nb_slot_frame) % MAX_FRAME_NUMBER;
|
||||
curMsg->proc.frame_tx = (((absolute_slot - slot_offset) +DURATION_RX_TO_TX)/nb_slot_frame) % MAX_FRAME_NUMBER;
|
||||
curMsg->proc.decoded_frame_rx=-1;
|
||||
//LOG_I(PHY,"Process slot %d thread Idx %d total gain %d\n", slot_nr, thread_idx, UE->rx_total_gain_dB);
|
||||
}
|
||||
#ifdef READY_LOG
|
||||
if (ready_2 == 1){
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &loc_ts);
|
||||
LOG_I(PHY,"%s already ready_2 ( %ld %ld ) slot : %d offset : %d \n",
|
||||
__FUNCTION__,loc_ts.tv_sec, loc_ts.tv_nsec, absolute_slot, slot_offset);
|
||||
} else LOG_I(PHY,"%s ready_2 not set (OK) ( %ld %ld ) slot : %d offset : %d\n",
|
||||
__FUNCTION__,loc_ts.tv_sec, loc_ts.tv_nsec, absolute_slot, slot_offset);
|
||||
#endif
|
||||
while (!ready_2){
|
||||
usleep(10);
|
||||
}
|
||||
ready_2 = 0;
|
||||
// slot_offset = 0;
|
||||
|
||||
while (nbSlotProcessing >= NR_RX_NB_TH) {
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &loc_prev_ts); // nkob
|
||||
res=pullTpool(&nf, &(get_nrUE_params()->Tpool));
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &loc_ts);
|
||||
#ifdef FIFO_LOG
|
||||
LOG_I(PHY,"%s pullTpool key = %d\n",__FUNCTION__,res->key);
|
||||
#endif
|
||||
nbSlotProcessing--;
|
||||
nr_rxtx_thread_data_t *tmp=(nr_rxtx_thread_data_t *)res->msgData;
|
||||
loc_lstart = loc_prev_ts.tv_sec * 1E9 + loc_prev_ts.tv_nsec;
|
||||
loc_lend = loc_ts.tv_sec * 1E9 + loc_ts.tv_nsec;
|
||||
if ((loc_lend - loc_lstart) > 500000 ) {
|
||||
slot_offset += (int) ((loc_lend - loc_lstart)/500000);
|
||||
slot_offset = slot_offset % 20;
|
||||
LOG_I(PHY,"%ld -> %ld pullthread::pullTpool exec. time *** over 500uS *** : %ld (offset : %d )\n",
|
||||
loc_lstart, loc_lend , (loc_lend - loc_lstart), slot_offset);
|
||||
}
|
||||
|
||||
if (tmp->proc.decoded_frame_rx != -1)
|
||||
decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx);
|
||||
else
|
||||
decoded_frame_rx=-1;
|
||||
|
||||
pushNotifiedFIFO_nothreadSafe(&freeBlocks,res);
|
||||
}
|
||||
if (decoded_frame_rx>0 && decoded_frame_rx != curMsg->proc.frame_rx)
|
||||
LOG_E(PHY,"Decoded frame index (%d) is not compatible with current context (%d), UE should go back to synch mode\n",
|
||||
decoded_frame_rx, curMsg->proc.frame_rx);
|
||||
nbSlotProcessing++;
|
||||
LOG_X(PHY,"Number of slots being processed at the moment: %d\n",nbSlotProcessing);
|
||||
pushTpool(&(get_nrUE_params()->Tpool), msgToPush);
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &loc_ts);
|
||||
#ifdef FIFO_LOG
|
||||
LOG_I(PHY,"%s ( %ld %ld ) pushTpool key = %ld (decoded_frame : %d )\n",
|
||||
__FUNCTION__,loc_ts.tv_sec, loc_ts.tv_nsec, msgToPush->key, decoded_frame_rx);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// L5G_IOT
|
||||
void init_pull_thread( ){
|
||||
pthread_t thread_pull;
|
||||
int arg = 0;
|
||||
|
||||
threadCreate(
|
||||
&thread_pull, pullthread /* function */, (void *)&arg, "pullthread" /* name */, -1 /* affinity */, OAI_PRIORITY_RT_MAX /* priority */);
|
||||
pthread_setname_np(thread_pull, "pullThread");
|
||||
|
||||
LOG_I(PHY,"pullthread created ( %s )\n",__FUNCTION__);
|
||||
}
|
||||
|
||||
/* HACK: this function is needed to compile the UE
|
||||
* fix it somehow
|
||||
|
||||
@@ -98,12 +98,7 @@ pthread_cond_t sync_cond;
|
||||
pthread_mutex_t sync_mutex;
|
||||
int sync_var=-1; //!< protected by mutex \ref sync_mutex.
|
||||
int config_sync_var=-1;
|
||||
// L5G_IOT
|
||||
int use_prometheus = 0;
|
||||
int enable_parallel_pull = 0;
|
||||
int disable_shm_log = 0;
|
||||
int num_chest_threads = 14;
|
||||
int num_rxdlsh_threads = 14;
|
||||
|
||||
// not used in UE
|
||||
instance_t CUuniqInstance=0;
|
||||
instance_t DUuniqInstance=0;
|
||||
@@ -118,11 +113,6 @@ static int tx_max_power[MAX_NUM_CCs] = {0};
|
||||
int single_thread_flag = 1;
|
||||
int tddflag = 0;
|
||||
int vcdflag = 0;
|
||||
// L5G_IOT
|
||||
int prometheus_en_flag = 0;
|
||||
uint32_t prometheus_port = 1234;
|
||||
int para_pull_flag = 0;
|
||||
int shm_log_disable_flag = 0;
|
||||
|
||||
double rx_gain_off = 0.0;
|
||||
char *usrp_args = NULL;
|
||||
@@ -259,8 +249,6 @@ void init_tpools(uint8_t nun_dlsch_threads) {
|
||||
initTpool(params, &(nrUE_params.Tpool), false);
|
||||
free(params);
|
||||
init_dlsch_tpool( nun_dlsch_threads);
|
||||
init_dlsch_chest_tpool(num_chest_threads);
|
||||
init_rxdlsch_tpool(num_rxdlsh_threads);
|
||||
}
|
||||
|
||||
static void get_options(void) {
|
||||
@@ -269,10 +257,8 @@ static void get_options(void) {
|
||||
paramdef_t cmdline_params[] =CMDLINE_NRUEPARAMS_DESC ;
|
||||
int numparams = sizeof(cmdline_params)/sizeof(paramdef_t);
|
||||
config_process_cmdline( cmdline_params,numparams,NULL);
|
||||
// L5G_IOT
|
||||
if (prometheus_en_flag > 0) use_prometheus = 1;
|
||||
if (para_pull_flag > 0) enable_parallel_pull = 1;
|
||||
if (shm_log_disable_flag > 0) disable_shm_log = 1; else disable_shm_log = 0;
|
||||
|
||||
|
||||
|
||||
if (vcdflag > 0)
|
||||
ouput_vcd = 1;
|
||||
@@ -428,10 +414,11 @@ int main( int argc, char **argv ) {
|
||||
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
|
||||
memset(openair0_cfg,0,sizeof(openair0_config_t)*MAX_CARDS);
|
||||
memset(tx_max_power,0,sizeof(int)*MAX_NUM_CCs);
|
||||
// get options and fill parameters from configuration file
|
||||
get_options (); //Command-line options specific for NRUE
|
||||
// initialize logging
|
||||
logInit();
|
||||
// get options and fill parameters from configuration file
|
||||
|
||||
get_options (); //Command-line options specific for NRUE
|
||||
|
||||
get_common_options(SOFTMODEM_5GUE_BIT);
|
||||
CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
|
||||
@@ -458,8 +445,6 @@ int main( int argc, char **argv ) {
|
||||
LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
|
||||
|
||||
init_NR_UE(1,uecap_file,rrc_config_path);
|
||||
// L5G_IOT
|
||||
if (use_prometheus > 0) init_PrometheusNodeExporter_thread( );
|
||||
|
||||
int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1;
|
||||
uint16_t node_number = get_softmodem_params()->node_number;
|
||||
@@ -536,9 +521,6 @@ int main( int argc, char **argv ) {
|
||||
}
|
||||
|
||||
init_NR_UE_threads(1);
|
||||
// L5G_IOT
|
||||
if (enable_parallel_pull != 0) init_pull_thread( );
|
||||
|
||||
printf("UE threads created by %ld\n", gettid());
|
||||
}
|
||||
|
||||
|
||||
@@ -36,14 +36,10 @@
|
||||
{"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}, \
|
||||
{"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0}, \
|
||||
/* L5G_IOT */\
|
||||
{"enable_prometheus", CONFIG_HLP_EN_PROM, PARAMFLAG_BOOL, strptr:(char **)&prometheus_en_flag, defstrval:0, TYPE_INT, 0}, \
|
||||
{"prometheus_port", CONFIG_HLP_PROM_PORT, 0, strptr:(uint32_t*)&prometheus_port, defuintval:1234, TYPE_UINT32, 0}, \
|
||||
{"parallel_pull", CONFIG_HLP_PARA_PULL, PARAMFLAG_BOOL, strptr:(char **)¶_pull_flag, defstrval:0, TYPE_INT, 0}, \
|
||||
{"disable-shm-log", CONFIG_HLP_DIS_SHMLOG, PARAMFLAG_BOOL, strptr:(char **)&shm_log_disable_flag, defstrval:0, TYPE_INT, 0}, \
|
||||
{"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0} \
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/* command line parameters defining UE running mode */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
@@ -85,7 +81,7 @@ typedef struct {
|
||||
extern uint64_t get_nrUE_optmask(void);
|
||||
extern uint64_t set_nrUE_optmask(uint64_t bitmask);
|
||||
extern nrUE_params_t *get_nrUE_params(void);
|
||||
extern int enable_parallel_pull;
|
||||
|
||||
|
||||
// In nr-ue.c
|
||||
extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
|
||||
|
||||
@@ -1,524 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include "prometheus_exporter.h"
|
||||
#include "executables/softmodem-common.h"
|
||||
|
||||
prom_metrics_t prom_metrics;
|
||||
complex_metrics_t complex_metrics;
|
||||
uint8_t Prom_switch_state[NUM_PROM_SETTINGS];
|
||||
uint8_t Realtime_switch_state[NUM_REALTIME_SETTINGS];
|
||||
pthread_mutex_t mutex_prom;
|
||||
pthread_mutex_t mutex_real;
|
||||
|
||||
int parseHeader(char* in, char* Query, char* path, char* proto);
|
||||
int SendResponse(int sock, const char* msg, char* context);
|
||||
int GetSettings(int sock, const char* msg, char* inbuf);
|
||||
int SendSettings(int sock, const char* msg);
|
||||
int getMethodIndex(char* QueryType);
|
||||
|
||||
const char* PromMetricSwitchNames[] = {
|
||||
// prometheus monitor
|
||||
"pdcch_pow", "dl_freq_resource", "ul_freq_resource", "dl_mcs", "dl_tbs", "ul_mcs", "ul_tbs", "pss_peak_power",
|
||||
};
|
||||
const char* RealtimeMetricSwitchNames[] = {
|
||||
// real time monitor
|
||||
"pbch_iq", "pbch_ch", "pdcch_iq", "pdcch_ch", "rar_iq", "rar_ch", "sib_iq", "sib_ch", "sss_iq",
|
||||
"pdsch_iq", "pdsch_chest"
|
||||
};
|
||||
|
||||
const char* HttpMethod[]={ "GET","POST","PUT" };
|
||||
void *PrometheusNodeExporter_thread(void* arg){
|
||||
int sock0;
|
||||
struct sockaddr_in addr;
|
||||
struct sockaddr_in client;
|
||||
char buf[4096];
|
||||
char inbuf[2048];
|
||||
char inbuf_store[2048];
|
||||
int len;
|
||||
int sock;
|
||||
int yes = 1;
|
||||
struct tm *time_inf;
|
||||
char context[65536];
|
||||
char tm_buf[256];
|
||||
char cdate[512];
|
||||
char tmp_str[64];
|
||||
const char* msg1 = "HTTP/1.0 200 OK\r\n";
|
||||
const char* msg2 = "Content-Type: application/octet-stream\r\n";
|
||||
const char* msg_200 = "HTTP/1.0 200 OK\r\n";
|
||||
const char* msg_type = "Content-Type: application/octet-stream\r\n";
|
||||
const char* msg_cors = "Access-Control-Allow-Origin: *\r\n";
|
||||
const char* msg_400 = "HTTP/1.0 400 Bad Request\r\n";
|
||||
const char* msg_401 = "HTTP/1.0 401 Unauthorized\r\n";
|
||||
const char* msg_403 = "HTTP/1.0 403 Forbidden\r\n";
|
||||
const char* msg_404 = "HTTP/1.0 404 Not Found\r\n";
|
||||
const char* msg_405 = "HTTP/1.0 405 Method Not Allowed\r\n";
|
||||
|
||||
char QueryType[256];
|
||||
char DirPath[256];
|
||||
char Proto[256];
|
||||
|
||||
sock0 = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sock0 < 0) {
|
||||
perror("socket");
|
||||
return 1;
|
||||
}
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(prometheus_port);
|
||||
addr.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
setsockopt(sock0, SOL_SOCKET, SO_REUSEADDR, (const char *)&yes, sizeof(yes));
|
||||
|
||||
if (bind(sock0, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
|
||||
perror("bind");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (listen(sock0, 5) != 0) {
|
||||
perror("listen");
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
len = sizeof(client);
|
||||
sock = accept(sock0, (struct sockaddr *)&client, &len);
|
||||
if (sock < 0) {
|
||||
perror("accept");
|
||||
break;
|
||||
}
|
||||
|
||||
memset(inbuf, 0, sizeof(inbuf));
|
||||
recv(sock, inbuf, sizeof(inbuf), 0);
|
||||
strcpy(inbuf_store,inbuf);
|
||||
|
||||
// get query , directry path , protocol
|
||||
parseHeader(inbuf, QueryType,DirPath, Proto);
|
||||
// supported query ?
|
||||
if (getMethodIndex(QueryType) < 0){
|
||||
printf("un-supported query type : %s\n",QueryType);
|
||||
}
|
||||
|
||||
int metrics_to_monitor = 0;
|
||||
if (strstr(QueryType,"GET") != NULL){
|
||||
// prometheus interface '/metrics'
|
||||
if (strstr(DirPath,"metrics") != NULL){
|
||||
// printf("requsted metrics\n");
|
||||
metrics_to_monitor = PROMETHEUS;
|
||||
}
|
||||
|
||||
// PBCH '/iq/pbch
|
||||
if (strstr(DirPath,"iq/pbch") != NULL){
|
||||
// printf("requsted iq/pbch\n");
|
||||
metrics_to_monitor = PBCH_IQ;
|
||||
}
|
||||
// PBCH Channel Estimation '/chest/pbch
|
||||
if (strstr(DirPath,"chest/pbch") != NULL){
|
||||
// printf("requsted chest/pbch\n");
|
||||
metrics_to_monitor = PBCH_CHEST;
|
||||
}
|
||||
|
||||
// SI '/iq/sib
|
||||
if (strstr(DirPath,"iq/sib") != NULL){
|
||||
// printf("requsted iq/sib\n");
|
||||
metrics_to_monitor = SIB_IQ;
|
||||
}
|
||||
// SI Channel Estimation '/chest/sib
|
||||
if (strstr(DirPath,"chest/sib") != NULL){
|
||||
// printf("requsted iq/sib\n");
|
||||
metrics_to_monitor = SIB_CHEST;
|
||||
}
|
||||
|
||||
// pdcch '/iq/pdcch
|
||||
if (strstr(DirPath,"iq/pdcch") != NULL){
|
||||
// printf("requsted iq/pdcch\n");
|
||||
metrics_to_monitor = PDCCH_IQ;
|
||||
}
|
||||
// pdcch Channel Estimation '/chest/pdcch
|
||||
if (strstr(DirPath,"chest/pdcch") != NULL){
|
||||
// printf("requsted iq/pdcch\n");
|
||||
metrics_to_monitor = PDCCH_CHEST;
|
||||
}
|
||||
|
||||
// RAR '/iq/rar
|
||||
if (strstr(DirPath,"iq/rar") != NULL){
|
||||
// printf("requsted iq/pdcch\n");
|
||||
metrics_to_monitor = RAR_IQ;
|
||||
}
|
||||
// RAR Channel Estimation '/chest/rar
|
||||
if (strstr(DirPath,"chest/rar") != NULL){
|
||||
// printf("requsted iq/pdcch\n");
|
||||
metrics_to_monitor = RAR_CHEST;
|
||||
}
|
||||
// SSS Compensated I/Q '/iq/sss
|
||||
if (strstr(DirPath,"iq/sss") != NULL){
|
||||
// printf("requsted iq/pdcch\n");
|
||||
metrics_to_monitor = SSS_IQ;
|
||||
}
|
||||
// PDSCH Channel '/chest/pdsch
|
||||
if (strstr(DirPath,"chest/pdsch") != NULL){
|
||||
// printf("requsted iq/pdcch\n");
|
||||
metrics_to_monitor = PDSCH_CHEST;
|
||||
}
|
||||
// PDSCH Compensated I/Q '/iq/pdsch
|
||||
if (strstr(DirPath,"iq/pdsch") != NULL){
|
||||
// printf("requsted iq/pdcch\n");
|
||||
metrics_to_monitor = PDSCH_IQ;
|
||||
}
|
||||
// Get Current Settings
|
||||
if (strstr(DirPath,"settings") != NULL){
|
||||
metrics_to_monitor = SETTINGS;
|
||||
}
|
||||
|
||||
if (metrics_to_monitor == PROMETHEUS){
|
||||
bool bTop = true;
|
||||
strcpy(tmp_str,"");
|
||||
for (int i=0;i<NUM_PROM_ELEMENTS;i++){
|
||||
if ( strcmp(prom_metrics.metric_element[i].metric_name,"not_set")!=0 ){
|
||||
sprintf(tmp_str,"%s %d\n",
|
||||
prom_metrics.metric_element[i].metric_name,
|
||||
prom_metrics.metric_element[i].metric_value);
|
||||
} else {
|
||||
strcpy(tmp_str,"");
|
||||
}
|
||||
if (bTop){
|
||||
strcpy(context,tmp_str);
|
||||
bTop = false;
|
||||
} else {
|
||||
strcat(context,tmp_str);
|
||||
}
|
||||
}
|
||||
} else { // complex data (I/Q)
|
||||
if (metrics_to_monitor != SETTINGS){
|
||||
strcpy(buf,"");
|
||||
Report_IQ_Metric(buf,&complex_metrics.complex_element[metrics_to_monitor]);
|
||||
strcpy(context,buf);
|
||||
} else {
|
||||
char locBuf[256];
|
||||
strcpy(context,"");
|
||||
for (int i=0;i<NUM_REALTIME_SETTINGS;i++){
|
||||
sprintf(locBuf,"%s=%d\n",RealtimeMetricSwitchNames[i],Realtime_switch_state[i]);
|
||||
strcat(context,locBuf);
|
||||
}
|
||||
for (int i=0;i<NUM_PROM_SETTINGS;i++){
|
||||
sprintf(locBuf,"%s=%d\n",PromMetricSwitchNames[i],Prom_switch_state[i]);
|
||||
strcat(context,locBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (metrics_to_monitor == SETTINGS){
|
||||
SendSettings(sock, msg_200);
|
||||
} else {
|
||||
SendResponse(sock, msg_200, context);
|
||||
}
|
||||
} else if (strstr(QueryType,"POST") != NULL){ // response to post method
|
||||
strcpy(context,"");
|
||||
GetSettings(sock, msg_200, inbuf_store);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct thdata thdata[ NUM_MAX_COMPLEX_ELEMENTS ];
|
||||
void *cp_thread(void* arg){
|
||||
struct thdata* pth = (struct thdata*) arg;
|
||||
while(1){
|
||||
/* sync */
|
||||
sem_post(&pth->sync);
|
||||
sem_wait(&pth->start);
|
||||
|
||||
if (Realtime_switch_state[pth->index] != 0){
|
||||
strcpy(complex_metrics.complex_element[pth->index].label,pth->label);
|
||||
pthread_mutex_lock(&mutex_real);
|
||||
memcpy(complex_metrics.complex_element[pth->index].iq_data, pth->pdata, sizeof(int32_t)*pth->size);
|
||||
pthread_mutex_unlock(&mutex_real);
|
||||
complex_metrics.complex_element[pth->index].size = pth->size;
|
||||
}
|
||||
|
||||
/* sync */
|
||||
sem_post(&pth->sync);
|
||||
}
|
||||
|
||||
/* done */
|
||||
return (void *) NULL;
|
||||
}
|
||||
|
||||
void init_PrometheusNodeExporter_thread(void* arg){
|
||||
pthread_t thread_prom;
|
||||
char ThreadName[128][ NUM_MAX_COMPLEX_ELEMENTS ];
|
||||
for (int i=0;i<NUM_PROM_ELEMENTS;i++){
|
||||
strcpy(prom_metrics.metric_element[i].metric_name,"not_set");
|
||||
prom_metrics.metric_element[i].metric_value = 0;
|
||||
}
|
||||
|
||||
pthread_mutex_init(&mutex_prom, NULL);
|
||||
pthread_mutex_init(&mutex_real, NULL);
|
||||
|
||||
MonitoringConfig();
|
||||
|
||||
prom_metrics.num_metrics = 0;
|
||||
threadCreate(
|
||||
&thread_prom, PrometheusNodeExporter_thread /* function */, (void *) arg,
|
||||
"PrometheusNodeExporter_thread" /* name */, -1 /* affinity */, SCHED_OAI /* priority */);
|
||||
pthread_setname_np(thread_prom, "Prome_thread");
|
||||
|
||||
for (int i=0;i< NUM_MAX_COMPLEX_ELEMENTS; i++){
|
||||
thdata[i].index = i;
|
||||
// printf("copy thread create %d\n",i);
|
||||
sem_init(&thdata[i].sync, 0, 0);
|
||||
sem_init(&thdata[i].start, 0, 0);
|
||||
if (pthread_create(
|
||||
&thdata[i].th, NULL, cp_thread, (void*) &thdata[i]) != 0) {
|
||||
printf("pthread_create failed ");
|
||||
}
|
||||
sprintf(ThreadName,"PrmCP_Thread_%d",i);
|
||||
pthread_setname_np(thdata[i].th, ThreadName);
|
||||
}
|
||||
|
||||
printf("[PHY] PrometheusNodeExporter_thread created ( %s )\n",__FUNCTION__);
|
||||
}
|
||||
|
||||
int RegisterMetric(uint32_t key, char* name, uint32_t value){
|
||||
int ret_code = -1;
|
||||
// if (Prom_switch_state[key] == 0) return 1; // if monitoring operation disabled, skip this function
|
||||
|
||||
if (key < NUM_MAX_PROM_ELEMENTS){
|
||||
pthread_mutex_lock(&mutex_prom);
|
||||
strcpy(prom_metrics.metric_element[key].metric_name,name);
|
||||
prom_metrics.metric_element[key].metric_value = value;
|
||||
pthread_mutex_unlock(&mutex_prom);
|
||||
ret_code = 0;
|
||||
}
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
int RegisterComplexMetric(uint32_t key, char* label, int16_t* ptr, uint32_t size){
|
||||
int ret_code = -1;
|
||||
if (Realtime_switch_state[key] == 0) return 1; // if monitoring operation disabled, skip this function
|
||||
|
||||
if (key < NUM_MAX_COMPLEX_ELEMENTS){
|
||||
if (Realtime_switch_state[key] == 0) return ret_code;
|
||||
#if 0
|
||||
strcpy(complex_metrics.complex_element[key].label,label);
|
||||
pthread_mutex_lock(&mutex_real);
|
||||
memcpy(complex_metrics.complex_element[key].iq_data, ptr, sizeof(int32_t)*size);
|
||||
pthread_mutex_unlock(&mutex_real);
|
||||
complex_metrics.complex_element[key].size = size;
|
||||
#endif
|
||||
thdata[key].pdata = ptr;
|
||||
thdata[key].size = size;
|
||||
strcpy(thdata[key].label,label);
|
||||
sem_post(&thdata[key].start);
|
||||
ret_code = 0;
|
||||
}
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
int Report_IQ_Metric(char* buf,complex_metric_elm_t* elm){
|
||||
char tmp_buf[8192];
|
||||
char name[256];
|
||||
|
||||
for (int i = 0 ; i < elm->size * 2 ; i += 2){
|
||||
sprintf(tmp_buf,"%d,%d\n",
|
||||
elm->iq_data[i],elm->iq_data[i+1]);
|
||||
strcat(buf,tmp_buf);
|
||||
}
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
int parseHeader(char* in, char* Query, char* path, char* proto){
|
||||
char* ptr;
|
||||
char* firstLine;
|
||||
char* ptrLine1;
|
||||
char* lastLine;
|
||||
|
||||
int length = strlen(in);
|
||||
|
||||
// 1st line
|
||||
ptr = strtok(in,"\n"); if (ptr == NULL) return -1;
|
||||
//printf("(1) %s\n",ptr);
|
||||
firstLine = ptr;
|
||||
// Method
|
||||
ptrLine1 = strtok(firstLine," "); if (ptrLine1 == NULL) return -1;
|
||||
strcpy(Query,ptrLine1);
|
||||
// path
|
||||
ptrLine1 = strtok(NULL," "); if (ptrLine1 == NULL) return -1;
|
||||
strcpy(path,ptrLine1);
|
||||
// protocol
|
||||
ptrLine1 = strtok(NULL," "); if (ptrLine1 == NULL) return -1;
|
||||
strcpy(proto,ptrLine1);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
int SendResponse(int sock, const char* msg, char* context){
|
||||
char buf[16384];
|
||||
char tm_buf[256];
|
||||
char cdate[512];
|
||||
|
||||
const char* msg_type = "Content-Type: application/octet-stream\r\n";
|
||||
const char* msg_cors = "Access-Control-Allow-Origin: *\r\n";
|
||||
time_t timep = time(NULL);
|
||||
struct tm *time_inf = localtime(&timep);
|
||||
strftime(tm_buf,sizeof(tm_buf),"%c", time_inf);
|
||||
sprintf(cdate,"Date: %s\r\n",tm_buf);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf,sizeof(buf),
|
||||
"%s%s%s%s\r\n%s",
|
||||
msg, cdate, msg_type, msg_cors, context);
|
||||
// send message
|
||||
send(sock, buf, (int)strlen(buf), 0);
|
||||
close(sock);
|
||||
// printf("%s\n",buf);
|
||||
}
|
||||
|
||||
int GetSettingHTML(char* buf2){
|
||||
char tmp_buf[256];
|
||||
// Setting Result
|
||||
sprintf(buf2,"<html>\n");
|
||||
sprintf(buf2,"%s<body>\n",buf2);
|
||||
sprintf(buf2,"%s<h1>Current Settings</h1><br>\n",buf2);
|
||||
sprintf(buf2,"%s<ol>\n",buf2);
|
||||
for (int i=0;i<NUM_REALTIME_SETTINGS;i++){
|
||||
sprintf(tmp_buf,"<li>%s=%d</li>\n",RealtimeMetricSwitchNames[i],Realtime_switch_state[i]);
|
||||
strcat(buf2,tmp_buf);
|
||||
}
|
||||
for (int i=0;i<NUM_PROM_SETTINGS;i++){
|
||||
sprintf(tmp_buf,"<li>%s=%d</li>\n",PromMetricSwitchNames[i],Prom_switch_state[i]);
|
||||
strcat(buf2,tmp_buf);
|
||||
}
|
||||
sprintf(buf2,"%s</ol>\n",buf2);
|
||||
sprintf(buf2,"%s</body>\n",buf2);
|
||||
strcat(buf2,"</html>");
|
||||
}
|
||||
|
||||
int GetSettings(int sock, const char* msg, char* inbuf){
|
||||
char buf[4096];
|
||||
char buf2[4096];
|
||||
char tm_buf[256];
|
||||
char cdate[512];
|
||||
char* ptr;
|
||||
char* lastLine;
|
||||
|
||||
const char* msg_type = "Content-Type: text/plain\r\n";
|
||||
const char* msg_cors = "Access-Control-Allow-Origin: *\r\n";
|
||||
time_t timep = time(NULL);
|
||||
struct tm *time_inf = localtime(&timep);
|
||||
strftime(tm_buf,sizeof(tm_buf),"%c", time_inf);
|
||||
sprintf(cdate,"Date: %s\r\n",tm_buf);
|
||||
// Get posted parameter
|
||||
ptr = strtok(inbuf,"\n");
|
||||
while (ptr != NULL){
|
||||
lastLine = ptr;
|
||||
ptr = strtok(NULL,"\n");
|
||||
}
|
||||
// parse parameter
|
||||
for (int i=0;i<NUM_PROM_SETTINGS;i++){
|
||||
if (strstr(lastLine,PromMetricSwitchNames[i]) != NULL) Prom_switch_state[i] = 1;
|
||||
else Prom_switch_state[i] = 0;
|
||||
}
|
||||
for (int i=0;i<NUM_REALTIME_SETTINGS;i++){
|
||||
if (strstr(lastLine,RealtimeMetricSwitchNames[i]) != NULL) Realtime_switch_state[i] = 1;
|
||||
else Realtime_switch_state[i] = 0;
|
||||
}
|
||||
|
||||
GetSettingHTML(buf2);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf,sizeof(buf),
|
||||
"%s%s%s\r\n%s",
|
||||
msg, cdate, msg_cors,buf2);
|
||||
// 送信
|
||||
send(sock, buf, (int)strlen(buf), 0);
|
||||
close(sock);
|
||||
// printf("]]]]]]\n%s\n]]]]]]]\n",buf);
|
||||
}
|
||||
|
||||
int SendSettings(int sock, const char* msg){
|
||||
char buf[4096];
|
||||
char buf2[4096];
|
||||
char tm_buf[256];
|
||||
char cdate[512];
|
||||
char* ptr;
|
||||
char* lastLine;
|
||||
|
||||
const char* msg_type = "Content-Type: text/plain\r\n";
|
||||
const char* msg_cors = "Access-Control-Allow-Origin: *\r\n";
|
||||
time_t timep = time(NULL);
|
||||
struct tm *time_inf = localtime(&timep);
|
||||
strftime(tm_buf,sizeof(tm_buf),"%c", time_inf);
|
||||
sprintf(cdate,"Date: %s\r\n",tm_buf);
|
||||
|
||||
GetSettingHTML(buf2);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf,sizeof(buf),
|
||||
"%s%s%s\r\n%s",
|
||||
msg, cdate, msg_cors,buf2);
|
||||
// 送信
|
||||
send(sock, buf, (int)strlen(buf), 0);
|
||||
close(sock);
|
||||
// printf("]]]]]]\n%s\n]]]]]]]\n",buf);
|
||||
}
|
||||
|
||||
int getMethodIndex(char* QueryType){
|
||||
for (int i=0;i<NUM_METHOD;i++){
|
||||
if (strcmp(HttpMethod[i],QueryType)==0){
|
||||
// printf("matched : %s\n",QueryType);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int MonitoringConfig(){
|
||||
FILE* fp;
|
||||
char buf[256];
|
||||
int ret_code = 0;
|
||||
|
||||
if ((fp = fopen("./monitor.conf","r")) != NULL){
|
||||
printf("Monitring point is set to default.\n");
|
||||
}
|
||||
printf("Monitring point is loaded from monitor.conf\n");
|
||||
while (fgets(buf, 256, fp) != NULL) {
|
||||
if (strstr(buf,"//") == NULL){
|
||||
//
|
||||
for (int i=0;i<NUM_REALTIME_SETTINGS;i++){
|
||||
if (strstr(buf,RealtimeMetricSwitchNames[i]) != NULL){
|
||||
Realtime_switch_state[i] = 1;
|
||||
// printf("%s : %s ",RealtimeMetricSwitchNames[i],buf);
|
||||
}
|
||||
for (int i=0;i<NUM_PROM_SETTINGS;i++){
|
||||
// printf("%s : %s ",PromMetricSwitchNames[i],buf);
|
||||
if (strstr(buf,PromMetricSwitchNames[i]) != NULL){
|
||||
Prom_switch_state[i] = 1;
|
||||
// printf("-----> %s\n",PromMetricSwitchNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
#ifndef PROMETHEUS_EXPORTER_H
|
||||
#define PROMETHEUS_EXPORTER_H
|
||||
|
||||
#include "common/utils/system.h"
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define NUM_MAX_PROM_ELEMENTS 100
|
||||
#define MAX_COMPLEX_ELM_SIZE 8192
|
||||
#define NUM_MAX_COMPLEX_ELEMENTS 20
|
||||
#define MAX_DATA_SIZE 65536
|
||||
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef short int16_t;
|
||||
typedef struct {
|
||||
char metric_name[128];
|
||||
uint32_t metric_value;
|
||||
} metric_elm_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t num_metrics;
|
||||
metric_elm_t metric_element[NUM_MAX_PROM_ELEMENTS];
|
||||
} prom_metrics_t;
|
||||
|
||||
typedef struct {
|
||||
// char* buf;
|
||||
int16_t iq_data[MAX_DATA_SIZE];
|
||||
char label[256];
|
||||
uint32_t size;
|
||||
} complex_metric_elm_t;
|
||||
|
||||
typedef struct {
|
||||
complex_metric_elm_t complex_element[MAX_COMPLEX_ELM_SIZE];
|
||||
} complex_metrics_t;
|
||||
|
||||
enum metrics_key{
|
||||
RX_OFFSET = 0, // (1)
|
||||
RX_TBS,
|
||||
UL_BITS,
|
||||
PDCCH_LEVEL_0,
|
||||
PDCCH_LEVEL_1,
|
||||
DL_NUM_RB,
|
||||
DL_START_RB, // (7)
|
||||
UL_NUM_RB,
|
||||
UL_START_RB,
|
||||
DL_TBS,
|
||||
UL_TBS, // (11)
|
||||
DCI_1_1_RB,
|
||||
PDCP_UL_RB_ID,
|
||||
PDCP_UL_SDU_BUFF_SIZE,
|
||||
PDCP_DL_RB_ID,
|
||||
PDCP_DL_SDU_BUFF_SIZE,
|
||||
DL_MCS,
|
||||
UL_MCS,
|
||||
PSS_PEAK_POW, //19
|
||||
RESERVED_20,
|
||||
RESERVED_21,
|
||||
RESERVED_22,
|
||||
RESERVED_23,
|
||||
RESERVED_24,
|
||||
RESERVED_25,
|
||||
RESERVED_26,
|
||||
RESERVED_27,
|
||||
RESERVED_28,
|
||||
RESERVED_29,
|
||||
RESERVED_30,
|
||||
RESERVED_31,
|
||||
RESERVED_32,
|
||||
RESERVED_33,
|
||||
RESERVED_34,
|
||||
RESERVED_35,
|
||||
RESERVED_36,
|
||||
RESERVED_37,
|
||||
RESERVED_38,
|
||||
RESERVED_39,
|
||||
RESERVED_40,
|
||||
};
|
||||
#define NUM_PROM_ELEMENTS 19
|
||||
|
||||
enum complex_metrics_key{
|
||||
PBCH_IQ = 0, // 1
|
||||
PBCH_CHEST,
|
||||
PDCCH_IQ,
|
||||
PDCCH_CHEST, // 5
|
||||
RAR_IQ,
|
||||
RAR_CHEST,
|
||||
SIB_IQ,
|
||||
SIB_CHEST,
|
||||
SSS_IQ,
|
||||
PDSCH_IQ,
|
||||
PDSCH_CHEST,
|
||||
PROMETHEUS,
|
||||
SETTINGS
|
||||
};
|
||||
|
||||
#define NUM_COMPLEX_METRICS_ELEMENTS 1
|
||||
#define NUM_METHOD 5
|
||||
#define NUM_PROM_SETTINGS 8
|
||||
#define NUM_REALTIME_SETTINGS 11
|
||||
|
||||
enum MetricSwitchID {
|
||||
// real time monitor
|
||||
pbch_iq = 0, // 0
|
||||
pbch_ch,
|
||||
pdcch_iq,
|
||||
pdcch_ch,
|
||||
rar_iq,
|
||||
rar_ch, // 5
|
||||
sib_iq,
|
||||
sib_ch,
|
||||
sss_iq
|
||||
};
|
||||
|
||||
enum PromMetricSwitchID {
|
||||
// prometheus monitor
|
||||
pdcch_pow = 0,
|
||||
dl_freq_resource,
|
||||
ul_freq_resource,
|
||||
dl_mcs,
|
||||
dl_tbs,
|
||||
ul_mcs,
|
||||
ul_tbs, // 6
|
||||
pss_peak_power // 7
|
||||
};
|
||||
|
||||
struct thdata {
|
||||
pthread_t th;
|
||||
sem_t sync;
|
||||
sem_t start;
|
||||
int index;
|
||||
int16_t* pdata;
|
||||
int32_t size;
|
||||
char label[256];
|
||||
};
|
||||
|
||||
extern uint8_t Prom_switch_state[NUM_PROM_SETTINGS];
|
||||
extern uint8_t Realtime_switch_state[NUM_REALTIME_SETTINGS];
|
||||
|
||||
extern int RegisterMetric(uint32_t key, char* name, uint32_t value);
|
||||
extern void init_PrometheusNodeExporter_thread(void* arg);
|
||||
extern int RegisterComplexMetric(uint32_t key, char* label, int16_t* ptr, uint32_t size);
|
||||
extern int Report_IQ_Metric(char* buf,complex_metric_elm_t* elm);
|
||||
extern int MonitoringConfig();
|
||||
extern int use_prometheus;
|
||||
extern uint32_t prometheus_port;
|
||||
|
||||
#define PROM_METRICS(INDEX,NAME,VALUE) \
|
||||
if (use_prometheus > 0){ \
|
||||
RegisterMetric(INDEX,NAME,VALUE);\
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -88,6 +88,7 @@ void get_common_options(uint32_t execmask) {
|
||||
uint32_t online_log_messages=0;
|
||||
uint32_t glog_level=0 ;
|
||||
uint32_t start_telnetsrv = 0, start_telnetclt = 0;
|
||||
uint32_t start_websrv = 0;
|
||||
uint32_t noS1 = 0, nokrnmod = 1, nonbiot = 0;
|
||||
uint32_t rfsim = 0, basicsim = 0, do_forms = 0;
|
||||
char *logmem_filename = NULL;
|
||||
@@ -117,6 +118,10 @@ void get_common_options(uint32_t execmask) {
|
||||
set_softmodem_optmask(SOFTMODEM_TELNETCLT_BIT);
|
||||
}
|
||||
|
||||
if (start_telnetsrv) {
|
||||
load_module_shlib("websrv",NULL,0,NULL);
|
||||
}
|
||||
|
||||
if (logmem_filename != NULL && strlen(logmem_filename) > 0) {
|
||||
log_mem_filename = &logmem_filename[0];
|
||||
log_mem_flag = 1;
|
||||
@@ -197,6 +202,7 @@ void signal_handler(int sig) {
|
||||
softmodem_printresources(sig,(telnet_printfunc_t)printf);
|
||||
if (sig != SOFTMODEM_RTSIGNAL) {
|
||||
printf("Linux signal %s...\n",strsignal(sig));
|
||||
end_configmodule();
|
||||
exit_function(__FILE__, __FUNCTION__, __LINE__,"softmodem starting exit procedure\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,18 +170,20 @@ extern int usrp_tx_thread;
|
||||
#define CONFIG_HLP_FLOG "Enable online log \n"
|
||||
#define CONFIG_HLP_LOGL "Set the global log level, valid options: (4:trace, 3:debug, 2:info, 1:warn, (0:error))\n"
|
||||
#define CONFIG_HLP_TELN "Start embedded telnet server \n"
|
||||
#define CONFIG_HLP_WEB "Start embedded web server \n"
|
||||
#define CONFIG_FLOG_OPT "R"
|
||||
#define CONFIG_LOGL_OPT "g"
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/* command line parameters for LOG utility */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/* command line parameters for LOG utility */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
#define CMDLINE_LOGPARAMS_DESC { \
|
||||
{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}, \
|
||||
{"telnetclt", NULL, 0, uptr:&start_telnetclt, defstrval:NULL, TYPE_UINT, 0}, \
|
||||
{CONFIG_FLOG_OPT , CONFIG_HLP_FLOG, 0, uptr:&online_log_messages, defintval:1, TYPE_INT, 0}, \
|
||||
{CONFIG_LOGL_OPT , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \
|
||||
{"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL|PARAMFLAG_CMDLINEONLY, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \
|
||||
{"websrv", CONFIG_HLP_WEB, PARAMFLAG_BOOL|PARAMFLAG_CMDLINEONLY, uptr:&start_websrv, defintval:0, TYPE_UINT, 0}, \
|
||||
{"log-mem", NULL, 0, strptr:(char **)&logmem_filename, defstrval:NULL, TYPE_STRING, 0}, \
|
||||
{"telnetclt", NULL, 0, uptr:&start_telnetclt, defstrval:NULL, TYPE_UINT, 0}, \
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1109,7 +1109,7 @@ notifiedFIFO_elt_t *l1tx_message_extract(PHY_VARS_gNB *gNB, int frame, int slot)
|
||||
|
||||
int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_dci_request_t *req) {
|
||||
|
||||
// LOG_X(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi);
|
||||
// LOG_D(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi);
|
||||
|
||||
struct PHY_VARS_gNB_s *gNB = RC.gNB[0];
|
||||
|
||||
@@ -1138,7 +1138,7 @@ int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7,
|
||||
|
||||
int pnf_phy_hi_dci0_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_hi_dci0_request_t *req) {
|
||||
if (req->hi_dci0_request_body.number_of_dci == 0 && req->hi_dci0_request_body.number_of_hi == 0)
|
||||
LOG_X(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi);
|
||||
LOG_D(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi);
|
||||
|
||||
//phy_info* phy = (phy_info*)(pnf_p7->user_data);
|
||||
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
|
||||
@@ -1146,14 +1146,14 @@ int pnf_phy_hi_dci0_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfa
|
||||
proc = &eNB->proc.L1_proc;
|
||||
|
||||
for (int i=0; i<req->hi_dci0_request_body.number_of_dci + req->hi_dci0_request_body.number_of_hi; i++) {
|
||||
//LOG_X(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
|
||||
//LOG_D(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d]\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
|
||||
if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) {
|
||||
//LOG_X(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_DCI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
|
||||
//LOG_D(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_DCI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
|
||||
nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu = &req->hi_dci0_request_body.hi_dci0_pdu_list[i];
|
||||
handle_nfapi_hi_dci0_dci_pdu(eNB,NFAPI_SFNSF2SFN(req->sfn_sf),NFAPI_SFNSF2SF(req->sfn_sf),proc,hi_dci0_req_pdu);
|
||||
eNB->pdcch_vars[NFAPI_SFNSF2SF(req->sfn_sf)&1].num_dci++;
|
||||
} else if (req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) {
|
||||
LOG_X(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
|
||||
LOG_D(PHY,"[PNF] HI_DCI0_REQ sfn_sf:%d PDU[%d] - NFAPI_HI_DCI0_HI_PDU_TYPE\n", NFAPI_SFNSF2DEC(req->sfn_sf), i);
|
||||
nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu = &req->hi_dci0_request_body.hi_dci0_pdu_list[i];
|
||||
handle_nfapi_hi_dci0_hi_pdu(eNB, NFAPI_SFNSF2SFN(req->sfn_sf),NFAPI_SFNSF2SF(req->sfn_sf), proc, hi_dci0_req_pdu);
|
||||
} else {
|
||||
@@ -1345,11 +1345,11 @@ int pnf_phy_tx_data_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_tx_data_request_
|
||||
uint16_t slot = req->Slot;
|
||||
|
||||
if (req->Number_of_PDUs == 0)
|
||||
LOG_X(PHY,"%s() SFN/SLOT:%d%d PDUs:%d\n", __FUNCTION__, sfn, slot, req->Number_of_PDUs);
|
||||
LOG_D(PHY,"%s() SFN/SLOT:%d%d PDUs:%d\n", __FUNCTION__, sfn, slot, req->Number_of_PDUs);
|
||||
|
||||
//if (req->pdu_list[0].TLVs->tag == NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST) {
|
||||
for (int i=0; i<req->Number_of_PDUs; i++) {
|
||||
// LOG_X(PHY,"%s() SFN/SF:%d%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n",
|
||||
// LOG_D(PHY,"%s() SFN/SF:%d%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n",
|
||||
// __FUNCTION__,
|
||||
// sfn, sf,
|
||||
// req->tx_request_body.number_of_pdus,
|
||||
@@ -1372,11 +1372,11 @@ int pnf_phy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) {
|
||||
uint16_t sf = NFAPI_SFNSF2SF(req->sfn_sf);
|
||||
|
||||
if (req->tx_request_body.number_of_pdus==0)
|
||||
LOG_X(PHY,"%s() SFN/SF:%d%d PDUs:%d\n", __FUNCTION__, sfn, sf, req->tx_request_body.number_of_pdus);
|
||||
LOG_D(PHY,"%s() SFN/SF:%d%d PDUs:%d\n", __FUNCTION__, sfn, sf, req->tx_request_body.number_of_pdus);
|
||||
|
||||
if (req->tx_request_body.tl.tag==NFAPI_TX_REQUEST_BODY_TAG) {
|
||||
for (int i=0; i<req->tx_request_body.number_of_pdus; i++) {
|
||||
LOG_X(PHY,"%s() SFN/SF:%d%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n",
|
||||
LOG_D(PHY,"%s() SFN/SF:%d%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n",
|
||||
__FUNCTION__,
|
||||
sfn, sf,
|
||||
req->tx_request_body.number_of_pdus,
|
||||
@@ -1395,7 +1395,7 @@ int pnf_phy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) {
|
||||
|
||||
|
||||
int pnf_phy_ul_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_tti_request_t *req) {
|
||||
LOG_X(PHY,"[PNF] UL_TTI_REQ recvd, writing into structs, SFN/slot:%d.%d pdu:%d \n",
|
||||
LOG_D(PHY,"[PNF] UL_TTI_REQ recvd, writing into structs, SFN/slot:%d.%d pdu:%d \n",
|
||||
req->SFN,req->Slot,
|
||||
req->n_pdus
|
||||
);
|
||||
@@ -1428,16 +1428,16 @@ int pnf_phy_ul_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7,
|
||||
for (int i=0; i< req->n_pdus; i++) {
|
||||
switch (ul_tti_pdu_list[i].pdu_type) {
|
||||
case NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE:
|
||||
//LOG_X(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PUSCH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot);
|
||||
//LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PUSCH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot);
|
||||
//curr_sfn = curr_sfn + 3; //Gokul
|
||||
nr_fill_ulsch(gNB,curr_sfn, curr_slot, &ul_tti_pdu_list[i].pusch_pdu);
|
||||
break;
|
||||
case NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE:
|
||||
//LOG_X(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PUCCH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot);
|
||||
//LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PUCCH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot);
|
||||
nr_fill_pucch(gNB,curr_sfn, curr_slot, &ul_tti_pdu_list[i].pucch_pdu);
|
||||
break;
|
||||
case NFAPI_NR_UL_CONFIG_PRACH_PDU_TYPE:
|
||||
//LOG_X(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PRACH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot);
|
||||
//LOG_D(PHY,"frame %d, slot %d, Got NFAPI_NR_UL_TTI_PRACH_PDU_TYPE for %d.%d\n", frame, slot, UL_tti_req->SFN, UL_tti_req->Slot);
|
||||
nr_fill_prach(gNB, curr_sfn, curr_slot, &ul_tti_pdu_list[i].prach_pdu);
|
||||
if (gNB->RU_list[0]->if_south == LOCAL_RF) nr_fill_prach_ru(gNB->RU_list[0], curr_sfn, curr_slot, &ul_tti_pdu_list[i].prach_pdu);
|
||||
break;
|
||||
@@ -1446,14 +1446,14 @@ int pnf_phy_ul_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7,
|
||||
break;
|
||||
|
||||
}
|
||||
// //LOG_X(PHY, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, ul_config_pdu_list[i].pdu_size);
|
||||
// //LOG_D(PHY, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, ul_config_pdu_list[i].pdu_size);
|
||||
// if (
|
||||
// ul_tti_pdu_list[i].pdu_type == NFAPI_NR_UL_CONFIG_PRACH_PDU_TYPE ||
|
||||
// ul_tti_pdu_list[i].pdu_type == NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE ||
|
||||
// ul_tti_pdu_list[i].pdu_type == NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE ||
|
||||
// ul_tti_pdu_list[i].pdu_type == NFAPI_NR_UL_CONFIG_SRS_PDU_TYPE
|
||||
// ) {
|
||||
// //LOG_X(PHY, "%s() handle_nfapi_ul_pdu() for PDU:%d\n", __FUNCTION__, i);
|
||||
// //LOG_D(PHY, "%s() handle_nfapi_ul_pdu() for PDU:%d\n", __FUNCTION__, i);
|
||||
// // handle_nfapi_ul_pdu(eNB,proc,&ul_config_pdu_list[i],curr_sfn,curr_sf,req->ul_config_request_body.srs_present);
|
||||
|
||||
// // TODO: dont have an NR function for this, also srs_present flag not there
|
||||
@@ -1467,7 +1467,7 @@ int pnf_phy_ul_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7,
|
||||
}
|
||||
|
||||
int pnf_phy_ul_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_ul_config_request_t *req) {
|
||||
if (0)LOG_X(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n",
|
||||
if (0)LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n",
|
||||
__FUNCTION__,
|
||||
NFAPI_SFNSF2DEC(req->sfn_sf),
|
||||
req->ul_config_request_body.number_of_pdus,
|
||||
@@ -1497,7 +1497,7 @@ int pnf_phy_ul_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, n
|
||||
nfapi_ul_config_request_pdu_t *ul_config_pdu_list = req->ul_config_request_body.ul_config_pdu_list;
|
||||
|
||||
for (int i=0; i<req->ul_config_request_body.number_of_pdus; i++) {
|
||||
//LOG_X(PHY, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, ul_config_pdu_list[i].pdu_size);
|
||||
//LOG_D(PHY, "%s() sfn/sf:%d PDU[%d] size:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(req->sfn_sf), i, ul_config_pdu_list[i].pdu_size);
|
||||
if (
|
||||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE ||
|
||||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE ||
|
||||
@@ -1507,7 +1507,7 @@ int pnf_phy_ul_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, n
|
||||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE ||
|
||||
ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE
|
||||
) {
|
||||
//LOG_X(PHY, "%s() handle_nfapi_ul_pdu() for PDU:%d\n", __FUNCTION__, i);
|
||||
//LOG_D(PHY, "%s() handle_nfapi_ul_pdu() for PDU:%d\n", __FUNCTION__, i);
|
||||
handle_nfapi_ul_pdu(eNB,proc,&ul_config_pdu_list[i],curr_sfn,curr_sf,req->ul_config_request_body.srs_present);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s() PDU:%i UNKNOWN type :%d\n", __FUNCTION__, i, ul_config_pdu_list[i].pdu_type);
|
||||
@@ -2241,7 +2241,7 @@ void configure_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_addr,
|
||||
}
|
||||
|
||||
void oai_subframe_ind(uint16_t sfn, uint16_t sf) {
|
||||
//LOG_X(PHY,"%s(sfn:%d, sf:%d)\n", __FUNCTION__, sfn, sf);
|
||||
//LOG_D(PHY,"%s(sfn:%d, sf:%d)\n", __FUNCTION__, sfn, sf);
|
||||
|
||||
//TODO FIXME - HACK - DJP - using a global to bodge it in
|
||||
if (p7_config_g != NULL && sync_var==0) {
|
||||
@@ -2284,14 +2284,14 @@ void handle_nr_slot_ind(uint16_t sfn, uint16_t slot) {
|
||||
|
||||
int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) {
|
||||
rach_ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
LOG_X(PHY, "%s() sfn_sf:%d preambles:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(rach_ind->sfn_sf), rach_ind->rach_indication_body.number_of_preambles);
|
||||
LOG_D(PHY, "%s() sfn_sf:%d preambles:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(rach_ind->sfn_sf), rach_ind->rach_indication_body.number_of_preambles);
|
||||
return nfapi_pnf_p7_rach_ind(p7_config_g, rach_ind);
|
||||
}
|
||||
|
||||
int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind) {
|
||||
harq_ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
harq_ind->header.message_id = NFAPI_HARQ_INDICATION;
|
||||
LOG_X(PHY, "%s() sfn_sf:%d number_of_harqs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(harq_ind->sfn_sf), harq_ind->harq_indication_body.number_of_harqs);
|
||||
LOG_D(PHY, "%s() sfn_sf:%d number_of_harqs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(harq_ind->sfn_sf), harq_ind->harq_indication_body.number_of_harqs);
|
||||
int retval = nfapi_pnf_p7_harq_ind(p7_config_g, harq_ind);
|
||||
|
||||
if (retval != 0)
|
||||
@@ -2303,14 +2303,14 @@ int oai_nfapi_harq_indication(nfapi_harq_indication_t *harq_ind) {
|
||||
int oai_nfapi_crc_indication(nfapi_crc_indication_t *crc_ind) {
|
||||
crc_ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
crc_ind->header.message_id = NFAPI_CRC_INDICATION;
|
||||
//LOG_X(PHY, "%s() sfn_sf:%d number_of_crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(crc_ind->sfn_sf), crc_ind->crc_indication_body.number_of_crcs);
|
||||
//LOG_D(PHY, "%s() sfn_sf:%d number_of_crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(crc_ind->sfn_sf), crc_ind->crc_indication_body.number_of_crcs);
|
||||
return nfapi_pnf_p7_crc_ind(p7_config_g, crc_ind);
|
||||
}
|
||||
|
||||
int oai_nfapi_cqi_indication(nfapi_cqi_indication_t *ind) {
|
||||
ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
ind->header.message_id = NFAPI_RX_CQI_INDICATION;
|
||||
//LOG_X(PHY, "%s() sfn_sf:%d number_of_cqis:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis);
|
||||
//LOG_D(PHY, "%s() sfn_sf:%d number_of_cqis:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis);
|
||||
return nfapi_pnf_p7_cqi_ind(p7_config_g, ind);
|
||||
}
|
||||
|
||||
@@ -2318,7 +2318,7 @@ int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind) {
|
||||
ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
ind->header.message_id = NFAPI_RX_ULSCH_INDICATION;
|
||||
int retval = nfapi_pnf_p7_rx_ind(p7_config_g, ind);
|
||||
//LOG_X(PHY,"%s() SFN/SF:%d pdus:%d retval:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, retval);
|
||||
//LOG_D(PHY,"%s() SFN/SF:%d pdus:%d retval:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, retval);
|
||||
//free(ind.rx_indication_body.rx_pdu_list);
|
||||
return retval;
|
||||
}
|
||||
@@ -2326,7 +2326,7 @@ int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind) {
|
||||
int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind) {
|
||||
ind->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
int retval = nfapi_pnf_p7_sr_ind(p7_config_g, ind);
|
||||
//LOG_X(PHY,"%s() SFN/SF:%d srs:%d retval:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs, retval);
|
||||
//LOG_D(PHY,"%s() SFN/SF:%d srs:%d retval:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs, retval);
|
||||
//free(ind.rx_indication_body.rx_pdu_list);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -500,9 +500,9 @@ int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//LOG_X(PHY,"%s() About to attempt pthread_mutex_unlock\n", __FUNCTION__);
|
||||
//LOG_D(PHY,"%s() About to attempt pthread_mutex_unlock\n", __FUNCTION__);
|
||||
pthread_mutex_unlock( &L1_proc->mutex );
|
||||
//LOG_X(PHY,"%s() UNLOCKED pthread_mutex_unlock\n", __FUNCTION__);
|
||||
//LOG_D(PHY,"%s() UNLOCKED pthread_mutex_unlock\n", __FUNCTION__);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
|
||||
old_sfn = sfn;
|
||||
|
||||
if (old_sf == 0 && old_sfn % 100==0)
|
||||
LOG_X(PHY,
|
||||
LOG_D(PHY,
|
||||
"[eNB] sfn/sf:%d%d old_sfn/sf:%d%d proc[rx:%d%d]\n",
|
||||
sfn,
|
||||
sf,
|
||||
@@ -581,7 +581,7 @@ int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
|
||||
L1_proc->frame_tx = (L1_proc->subframe_rx > (9-sf_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
|
||||
L1_proc->subframe_tx = (L1_proc->subframe_rx + sf_ahead)%10;
|
||||
|
||||
//LOG_X(PHY, "sfn/sf:%d%d proc[rx:%d%d] L1_proc[instance_cnt_rxtx:%d rx:%d%d] About to wake rxtx thread\n\n", sfn, sf, proc->frame_rx, proc->subframe_rx, L1_proc->instance_cnt_rxtx, L1_proc->frame_rx, L1_proc->subframe_rx);
|
||||
//LOG_D(PHY, "sfn/sf:%d%d proc[rx:%d%d] L1_proc[instance_cnt_rxtx:%d rx:%d%d] About to wake rxtx thread\n\n", sfn, sf, proc->frame_rx, proc->subframe_rx, L1_proc->instance_cnt_rxtx, L1_proc->frame_rx, L1_proc->subframe_rx);
|
||||
|
||||
// the thread can now be woken up
|
||||
if (pthread_cond_signal(&L1_proc->cond) != 0) {
|
||||
@@ -624,7 +624,7 @@ int phy_slot_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uin
|
||||
if (RC.gNB && RC.gNB[0]->configured) {
|
||||
// uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf);
|
||||
// uint16_t sf = NFAPI_SFNSF2SF(sfn_sf);
|
||||
LOG_X(PHY,"[VNF] slot indication sfn:%d slot:%d\n", sfn, slot);
|
||||
LOG_D(PHY,"[VNF] slot indication sfn:%d slot:%d\n", sfn, slot);
|
||||
wake_gNB_rxtx(RC.gNB[0], sfn, slot); // DONE: find NR equivalent
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() RC.gNB:%p\n", __FUNCTION__, RC.gNB);
|
||||
@@ -646,7 +646,7 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id,
|
||||
if (RC.eNB && RC.eNB[0][0]->configured) {
|
||||
uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf);
|
||||
uint16_t sf = NFAPI_SFNSF2SF(sfn_sf);
|
||||
//LOG_X(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf);
|
||||
//LOG_D(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf);
|
||||
wake_eNB_rxtx(RC.eNB[0][0], sfn, sf);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] %s() RC.eNB:%p\n", __FUNCTION__, RC.eNB);
|
||||
@@ -658,9 +658,9 @@ int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id,
|
||||
}
|
||||
|
||||
int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indication_t *ind) {
|
||||
LOG_X(MAC, "%s() NFAPI SFN/SF:%d number_of_preambles:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles);
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_preambles:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles);
|
||||
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
|
||||
LOG_X(MAC, "[VNF] RACH_IND eNB:%p sfn_sf:%d number_of_preambles:%d\n", eNB, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles);
|
||||
LOG_D(MAC, "[VNF] RACH_IND eNB:%p sfn_sf:%d number_of_preambles:%d\n", eNB, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rach_indication_body.number_of_preambles);
|
||||
AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed");
|
||||
if(NFAPI_MODE == NFAPI_MODE_VNF){
|
||||
int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf);
|
||||
@@ -673,7 +673,7 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio
|
||||
for (int i=0; i<ind->rach_indication_body.number_of_preambles; i++) {
|
||||
if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) {
|
||||
|
||||
LOG_X(MAC, "preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
|
||||
LOG_D(MAC, "preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
|
||||
i,
|
||||
ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti,
|
||||
ind->rach_indication_body.preamble_list[i].preamble_rel8.preamble,
|
||||
@@ -681,7 +681,7 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio
|
||||
);
|
||||
}
|
||||
if(ind->rach_indication_body.preamble_list[i].preamble_rel13.tl.tag == NFAPI_PREAMBLE_REL13_TAG) {
|
||||
LOG_X(MAC, "RACH PREAMBLE REL13 present\n");
|
||||
LOG_D(MAC, "RACH PREAMBLE REL13 present\n");
|
||||
}
|
||||
|
||||
UL_RCC_INFO.rach_ind[index].rach_indication_body.preamble_list[i] = ind->rach_indication_body.preamble_list[i];
|
||||
@@ -692,7 +692,7 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio
|
||||
|
||||
for (int i=0; i<ind->rach_indication_body.number_of_preambles; i++) {
|
||||
if (ind->rach_indication_body.preamble_list[i].preamble_rel8.tl.tag == NFAPI_PREAMBLE_REL8_TAG) {
|
||||
LOG_X(MAC, "preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
|
||||
LOG_D(MAC, "preamble[%d]: rnti:%02x preamble:%d timing_advance:%d\n",
|
||||
i,
|
||||
ind->rach_indication_body.preamble_list[i].preamble_rel8.rnti,
|
||||
ind->rach_indication_body.preamble_list[i].preamble_rel8.preamble,
|
||||
@@ -701,7 +701,7 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio
|
||||
}
|
||||
|
||||
if(ind->rach_indication_body.preamble_list[i].preamble_rel13.tl.tag == NFAPI_PREAMBLE_REL13_TAG) {
|
||||
LOG_X(MAC, "RACH PREAMBLE REL13 present\n");
|
||||
LOG_D(MAC, "RACH PREAMBLE REL13 present\n");
|
||||
}
|
||||
|
||||
eNB->preamble_list[i] = ind->rach_indication_body.preamble_list[i];
|
||||
@@ -859,7 +859,7 @@ int phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind)
|
||||
|
||||
int phy_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_harq_indication_t *ind) {
|
||||
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
|
||||
LOG_X(MAC, "%s() NFAPI SFN/SF:%d number_of_harqs:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->harq_indication_body.number_of_harqs);
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_harqs:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->harq_indication_body.number_of_harqs);
|
||||
AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed");
|
||||
if(NFAPI_MODE == NFAPI_MODE_VNF){
|
||||
int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf);
|
||||
@@ -907,7 +907,7 @@ int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_
|
||||
for (int i=0; i<ind->crc_indication_body.number_of_crcs; i++) {
|
||||
memcpy(&UL_RCC_INFO.crc_ind[index].crc_indication_body.crc_pdu_list[i], &ind->crc_indication_body.crc_pdu_list[i], sizeof(ind->crc_indication_body.crc_pdu_list[0]));
|
||||
|
||||
LOG_X(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n",
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n",
|
||||
__FUNCTION__,
|
||||
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, UL_RCC_INFO.crc_ind[index].crc_indication_body.number_of_crcs,
|
||||
i,
|
||||
@@ -922,13 +922,13 @@ int phy_crc_indication(struct nfapi_vnf_p7_config *config, nfapi_crc_indication_
|
||||
dest_ind->crc_indication_body.crc_pdu_list = dest_pdu_list;
|
||||
|
||||
if (ind->crc_indication_body.number_of_crcs==0)
|
||||
LOG_X(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs,
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d IND:number_of_crcs:%u UL_INFO:crcs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs,
|
||||
eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs);
|
||||
|
||||
assert(ind->crc_indication_body.number_of_crcs <= NFAPI_CRC_IND_MAX_PDU);
|
||||
for (int i=0; i<ind->crc_indication_body.number_of_crcs; i++) {
|
||||
memcpy(&dest_ind->crc_indication_body.crc_pdu_list[i], &ind->crc_indication_body.crc_pdu_list[i], sizeof(ind->crc_indication_body.crc_pdu_list[0]));
|
||||
LOG_X(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n",
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d CRC_IND:number_of_crcs:%u UL_INFO:crcs:%d PDU[%d] rnti:%04x UL_INFO:rnti:%04x\n",
|
||||
__FUNCTION__,
|
||||
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->crc_indication_body.number_of_crcs, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs,
|
||||
i,
|
||||
@@ -988,7 +988,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t
|
||||
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
|
||||
|
||||
if (ind->rx_indication_body.number_of_pdus==0) {
|
||||
LOG_X(MAC, "%s() NFAPI SFN/SF:%d number_of_pdus:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus);
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_pdus:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus);
|
||||
}
|
||||
|
||||
AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed");
|
||||
@@ -1015,7 +1015,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t
|
||||
memcpy(dest_pdu->rx_ind_data, src_pdu->rx_ind_data, dest_pdu->rx_indication_rel8.length);
|
||||
}
|
||||
|
||||
LOG_X(PHY, "%s() NFAPI SFN/SF:%d PDUs:%zu [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n",
|
||||
LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%zu [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n",
|
||||
__FUNCTION__,
|
||||
NFAPI_SFNSF2DEC(ind->sfn_sf), number_of_pdus, i,
|
||||
dest_pdu->rx_ue_information.handle,
|
||||
@@ -1042,7 +1042,7 @@ int phy_rx_indication(struct nfapi_vnf_p7_config *config, nfapi_rx_indication_t
|
||||
assert(dest_pdu->rx_indication_rel8.length <= NFAPI_RX_IND_DATA_MAX);
|
||||
memcpy(dest_pdu->rx_ind_data, src_pdu->rx_ind_data, dest_pdu->rx_indication_rel8.length);
|
||||
|
||||
LOG_X(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n",
|
||||
LOG_D(PHY, "%s() NFAPI SFN/SF:%d PDUs:%d [PDU:%d] handle:%d rnti:%04x length:%d offset:%d ul_cqi:%d ta:%d data:%p\n",
|
||||
__FUNCTION__,
|
||||
NFAPI_SFNSF2DEC(ind->sfn_sf), ind->rx_indication_body.number_of_pdus, i,
|
||||
dest_pdu->rx_ue_information.handle,
|
||||
@@ -1110,13 +1110,13 @@ int phy_srs_indication(struct nfapi_vnf_p7_config *config, nfapi_srs_indication_
|
||||
|
||||
int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t *ind) {
|
||||
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
|
||||
LOG_X(MAC, "%s() NFAPI SFN/SF:%d srs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs);
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d srs:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->sr_indication_body.number_of_srs);
|
||||
AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed");
|
||||
if(NFAPI_MODE == NFAPI_MODE_VNF){
|
||||
int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf);
|
||||
|
||||
UL_RCC_INFO.sr_ind[index] = *ind;
|
||||
LOG_X(MAC,"%s() UL_INFO[%d].sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, index, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs);
|
||||
LOG_D(MAC,"%s() UL_INFO[%d].sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, index, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs);
|
||||
if (ind->sr_indication_body.number_of_srs > 0) {
|
||||
assert(ind->sr_indication_body.number_of_srs <= NFAPI_SR_IND_MAX_PDU);
|
||||
UL_RCC_INFO.sr_ind[index].sr_indication_body.sr_pdu_list = malloc(sizeof(nfapi_sr_indication_pdu_t) * NFAPI_SR_IND_MAX_PDU);
|
||||
@@ -1127,7 +1127,7 @@ int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t
|
||||
nfapi_sr_indication_pdu_t *dest_pdu = &UL_RCC_INFO.sr_ind[index].sr_indication_body.sr_pdu_list[i];
|
||||
nfapi_sr_indication_pdu_t *src_pdu = &ind->sr_indication_body.sr_pdu_list[i];
|
||||
|
||||
LOG_X(MAC, "SR_IND[PDU:%d %d][rnti:%x cqi:%d channel:%d]\n", index, i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel);
|
||||
LOG_D(MAC, "SR_IND[PDU:%d %d][rnti:%x cqi:%d channel:%d]\n", index, i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel);
|
||||
|
||||
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
|
||||
}
|
||||
@@ -1136,13 +1136,13 @@ int phy_sr_indication(struct nfapi_vnf_p7_config *config, nfapi_sr_indication_t
|
||||
nfapi_sr_indication_pdu_t *dest_pdu_list = eNB->sr_pdu_list;
|
||||
*dest_ind = *ind;
|
||||
dest_ind->sr_indication_body.sr_pdu_list = dest_pdu_list;
|
||||
LOG_X(MAC,"%s() eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs);
|
||||
LOG_D(MAC,"%s() eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs:%d\n", __FUNCTION__, eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs);
|
||||
|
||||
assert(eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs <= NFAPI_SR_IND_MAX_PDU);
|
||||
for (int i=0; i<eNB->UL_INFO.sr_ind.sr_indication_body.number_of_srs; i++) {
|
||||
nfapi_sr_indication_pdu_t *dest_pdu = &dest_ind->sr_indication_body.sr_pdu_list[i];
|
||||
nfapi_sr_indication_pdu_t *src_pdu = &ind->sr_indication_body.sr_pdu_list[i];
|
||||
LOG_X(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel);
|
||||
LOG_D(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti, src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel);
|
||||
memcpy(dest_pdu, src_pdu, sizeof(*src_pdu));
|
||||
}
|
||||
}
|
||||
@@ -1186,7 +1186,7 @@ int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_
|
||||
// vnf_p7_info* p7_vnf = (vnf_p7_info*)(config->user_data);
|
||||
//mac_cqi_ind(p7_vnf->mac, ind);
|
||||
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
|
||||
LOG_X(MAC, "%s() NFAPI SFN/SF:%d number_of_cqis:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis);
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_cqis:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->cqi_indication_body.number_of_cqis);
|
||||
AssertFatal(pthread_mutex_lock(&eNB->UL_INFO_mutex)==0, "Mutex lock failed");
|
||||
if(NFAPI_MODE == NFAPI_MODE_VNF){
|
||||
int8_t index = NFAPI_SFNSF2SF(ind->sfn_sf);
|
||||
@@ -1205,7 +1205,7 @@ int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_
|
||||
assert(ind->cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU);
|
||||
for (int i=0; i<ind->cqi_indication_body.number_of_cqis; i++) {
|
||||
nfapi_cqi_indication_pdu_t *src_pdu = &ind->cqi_indication_body.cqi_pdu_list[i];
|
||||
LOG_X(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti,
|
||||
LOG_D(MAC, "SR_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti,
|
||||
src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel);
|
||||
memcpy(&UL_RCC_INFO.cqi_ind[index].cqi_indication_body.cqi_pdu_list[i],
|
||||
src_pdu, sizeof(nfapi_cqi_indication_pdu_t));
|
||||
@@ -1221,7 +1221,7 @@ int phy_cqi_indication(struct nfapi_vnf_p7_config *config, nfapi_cqi_indication_
|
||||
assert(ind->cqi_indication_body.number_of_cqis <= NFAPI_CQI_IND_MAX_PDU);
|
||||
for(int i=0; i<ind->cqi_indication_body.number_of_cqis; i++) {
|
||||
nfapi_cqi_indication_pdu_t *src_pdu = &ind->cqi_indication_body.cqi_pdu_list[i];
|
||||
LOG_X(MAC, "CQI_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti,
|
||||
LOG_D(MAC, "CQI_IND[PDU:%d][rnti:%x cqi:%d channel:%d]\n", i, src_pdu->rx_ue_information.rnti,
|
||||
src_pdu->ul_cqi_information.ul_cqi, src_pdu->ul_cqi_information.channel);
|
||||
memcpy(&dest_ind->cqi_indication_body.cqi_pdu_list[i],
|
||||
src_pdu, sizeof(nfapi_cqi_indication_pdu_t));
|
||||
@@ -1241,7 +1241,7 @@ int phy_nr_slot_indication(nfapi_nr_slot_indication_scf_t *ind) {
|
||||
uint32_t vnf_sfn_slot = sfnslot_add_slot(ind->sfn, ind->slot, vnf_slot_ahead);
|
||||
uint16_t vnf_sfn = NFAPI_SFNSLOT2SFN(vnf_sfn_slot);
|
||||
uint8_t vnf_slot = NFAPI_SFNSLOT2SLOT(vnf_sfn_slot);
|
||||
LOG_X(MAC, "VNF SFN/Slot %d.%d \n", vnf_sfn, vnf_slot);
|
||||
LOG_D(MAC, "VNF SFN/Slot %d.%d \n", vnf_sfn, vnf_slot);
|
||||
|
||||
nfapi_nr_slot_indication_scf_t *nr_slot_ind = CALLOC(1, sizeof(*nr_slot_ind));
|
||||
nr_slot_ind->header = ind->header;
|
||||
@@ -1270,7 +1270,7 @@ int phy_nr_srs_indication(nfapi_nr_srs_indication_t *ind) {
|
||||
for (int i=0; i<ind->number_of_pdus; i++) {
|
||||
memcpy(&gNB->UL_INFO.srs_ind.pdu_list[i], &ind->pdu_list[i], sizeof(ind->pdu_list[0]));
|
||||
|
||||
LOG_X(MAC, "%s() NFAPI SFN/Slot:%d.%d SRS_IND:number_of_pdus:%d UL_INFO:pdus:%d\n",
|
||||
LOG_D(MAC, "%s() NFAPI SFN/Slot:%d.%d SRS_IND:number_of_pdus:%d UL_INFO:pdus:%d\n",
|
||||
__FUNCTION__,
|
||||
ind->sfn,ind->slot, ind->number_of_pdus, gNB->UL_INFO.srs_ind.number_of_pdus
|
||||
);
|
||||
@@ -1942,7 +1942,7 @@ int oai_nfapi_tx_data_req(nfapi_nr_tx_data_request_t *tx_data_req)
|
||||
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
|
||||
tx_data_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
tx_data_req->header.message_id = NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST;
|
||||
//LOG_X(PHY, "[VNF] %s() TX_REQ sfn_sf:%d number_of_pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(tx_req->sfn_sf), tx_req->tx_request_body.number_of_pdus);
|
||||
//LOG_D(PHY, "[VNF] %s() TX_REQ sfn_sf:%d number_of_pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(tx_req->sfn_sf), tx_req->tx_request_body.number_of_pdus);
|
||||
int retval = nfapi_vnf_p7_tx_data_req(p7_config, tx_data_req);
|
||||
|
||||
if (retval!=0) {
|
||||
@@ -1959,7 +1959,7 @@ int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req)
|
||||
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
|
||||
tx_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
tx_req->header.message_id = NFAPI_TX_REQUEST;
|
||||
//LOG_X(PHY, "[VNF] %s() TX_REQ sfn_sf:%d number_of_pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(tx_req->sfn_sf), tx_req->tx_request_body.number_of_pdus);
|
||||
//LOG_D(PHY, "[VNF] %s() TX_REQ sfn_sf:%d number_of_pdus:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(tx_req->sfn_sf), tx_req->tx_request_body.number_of_pdus);
|
||||
int retval = nfapi_vnf_p7_tx_req(p7_config, tx_req);
|
||||
|
||||
if (retval!=0) {
|
||||
@@ -1975,7 +1975,7 @@ int oai_nfapi_ul_dci_req(nfapi_nr_ul_dci_request_t *ul_dci_req) {
|
||||
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
|
||||
ul_dci_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
ul_dci_req->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST;
|
||||
//LOG_X(PHY, "[VNF] %s() HI_DCI0_REQ sfn_sf:%d dci:%d hi:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_hi);
|
||||
//LOG_D(PHY, "[VNF] %s() HI_DCI0_REQ sfn_sf:%d dci:%d hi:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_hi);
|
||||
int retval = nfapi_vnf_p7_ul_dci_req(p7_config, ul_dci_req);
|
||||
|
||||
if (retval!=0) {
|
||||
@@ -1991,7 +1991,7 @@ int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) {
|
||||
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
|
||||
hi_dci0_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST;
|
||||
//LOG_X(PHY, "[VNF] %s() HI_DCI0_REQ sfn_sf:%d dci:%d hi:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_hi);
|
||||
//LOG_D(PHY, "[VNF] %s() HI_DCI0_REQ sfn_sf:%d dci:%d hi:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req->hi_dci0_request_body.number_of_dci, hi_dci0_req->hi_dci0_request_body.number_of_hi);
|
||||
int retval = nfapi_vnf_p7_hi_dci0_req(p7_config, hi_dci0_req);
|
||||
|
||||
if (retval!=0) {
|
||||
@@ -2047,8 +2047,8 @@ int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) {
|
||||
nfapi_vnf_p7_config_t *p7_config = vnf.p7_vnfs[0].config;
|
||||
ul_config_req->header.phy_id = 1; // DJP HACK TODO FIXME - need to pass this around!!!!
|
||||
ul_config_req->header.message_id = NFAPI_UL_CONFIG_REQUEST;
|
||||
//LOG_X(PHY, "[VNF] %s() header message_id:%02x\n", __FUNCTION__, ul_config_req->header.message_id);
|
||||
//LOG_X(PHY, "[VNF] %s() UL_CONFIG sfn_sf:%d PDUs:%d rach_prach_frequency_resources:%d srs_present:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ul_config_req->sfn_sf), ul_config_req->ul_config_request_body.number_of_pdus, ul_config_req->ul_config_request_body.rach_prach_frequency_resources, ul_config_req->ul_config_request_body.srs_present);
|
||||
//LOG_D(PHY, "[VNF] %s() header message_id:%02x\n", __FUNCTION__, ul_config_req->header.message_id);
|
||||
//LOG_D(PHY, "[VNF] %s() UL_CONFIG sfn_sf:%d PDUs:%d rach_prach_frequency_resources:%d srs_present:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ul_config_req->sfn_sf), ul_config_req->ul_config_request_body.number_of_pdus, ul_config_req->ul_config_request_body.rach_prach_frequency_resources, ul_config_req->ul_config_request_body.srs_present);
|
||||
|
||||
int num_pdus = ul_config_req->ul_config_request_body.number_of_pdus;
|
||||
nfapi_ul_config_request_pdu_t *pdu_list = ul_config_req->ul_config_request_body.ul_config_pdu_list;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#define FAPI_NR_RX_PDU_TYPE_DLSCH 0x03
|
||||
#define FAPI_NR_DCI_IND 0x04
|
||||
#define FAPI_NR_RX_PDU_TYPE_RAR 0x05
|
||||
#define FAPI_NR_RX_PDU_TYPE_PCH 0x06
|
||||
|
||||
#define FAPI_NR_SIBS_MASK_SIB1 0x1
|
||||
|
||||
|
||||
@@ -1005,7 +1005,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
if(pnf_p7->_public.tx_data_req_fn)
|
||||
{
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Calling tx_data_req_fn in SFN/slot %d.%d \n",sfn,slot);
|
||||
LOG_X(PHY, "Process tx_data SFN/slot %d.%d buffer index: %d \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
LOG_D(PHY, "Process tx_data SFN/slot %d.%d buffer index: %d \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
(pnf_p7->_public.tx_data_req_fn)(&(pnf_p7->_public), tx_slot_buffer->tx_data_req);
|
||||
}
|
||||
}
|
||||
@@ -1025,7 +1025,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
{
|
||||
if(pnf_p7->_public.dl_tti_req_fn)
|
||||
{
|
||||
LOG_X(PHY, "Process dl_tti SFN/slot %d.%d buffer index: %d \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
LOG_D(PHY, "Process dl_tti SFN/slot %d.%d buffer index: %d \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
(pnf_p7->_public.dl_tti_req_fn)(NULL, &(pnf_p7->_public), tx_slot_buffer->dl_tti_req);
|
||||
}
|
||||
}
|
||||
@@ -1046,7 +1046,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
if(pnf_p7->_public.ul_dci_req_fn)
|
||||
{
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO, "Calling UL_dci_req_fn in SFN/slot %d.%d \n",sfn,slot);
|
||||
LOG_X(PHY, "Process ul_dci SFN/slot %d.%d buffer index: %d \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
LOG_D(PHY, "Process ul_dci SFN/slot %d.%d buffer index: %d \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
(pnf_p7->_public.ul_dci_req_fn)(NULL, &(pnf_p7->_public), tx_slot_buffer->ul_dci_req);
|
||||
}
|
||||
}
|
||||
@@ -1084,7 +1084,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
{
|
||||
deallocate_nfapi_dl_tti_request(tx_slot_buffer->dl_tti_req, pnf_p7);
|
||||
tx_slot_buffer->dl_tti_req = 0;
|
||||
LOG_X(PHY,"SFN/slot %d.%d Buffer index : %d freed \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
LOG_D(PHY,"SFN/slot %d.%d Buffer index : %d freed \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
}
|
||||
|
||||
if(tx_slot_buffer->tx_data_req != 0)
|
||||
@@ -1117,7 +1117,7 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
{
|
||||
pnf_p7->_public.dummy_slot.ul_tti_req->SFN = sfn;
|
||||
pnf_p7->_public.dummy_slot.ul_tti_req->Slot = slot;
|
||||
LOG_X(PHY, "Process ul_tti SFN/slot %d.%d buffer index: %d \n",sfn,slot,buffer_index_rx);
|
||||
LOG_D(PHY, "Process ul_tti SFN/slot %d.%d buffer index: %d \n",sfn,slot,buffer_index_rx);
|
||||
(pnf_p7->_public.ul_tti_req_fn)(NULL, &(pnf_p7->_public), pnf_p7->_public.dummy_slot.ul_tti_req);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user