Commit 108d9a96 authored by El Mghazli Yacine's avatar El Mghazli Yacine

Merge branch 'websrv' of gitlab.eurecom.fr:oai/openairinterface5g into websrv

parents 6686076f afdbca2a
...@@ -94,14 +94,14 @@ int setparam(char *buff, int debug, telnet_printfunc_t prnt); ...@@ -94,14 +94,14 @@ int setparam(char *buff, int debug, telnet_printfunc_t prnt);
int history_cmd(char *buff, int debug, telnet_printfunc_t prnt); int history_cmd(char *buff, int debug, telnet_printfunc_t prnt);
telnetshell_vardef_t telnet_vardef[] = { telnetshell_vardef_t telnet_vardef[] = {
{"debug",TELNET_VARTYPE_INT32,&telnetparams.telnetdbg}, {"debug",TELNET_VARTYPE_INT32,0,&telnetparams.telnetdbg},
{"prio",TELNET_VARTYPE_INT32,&telnetparams.priority}, {"prio",TELNET_VARTYPE_INT32,0,&telnetparams.priority},
{"loopc",TELNET_VARTYPE_INT32,&telnetparams.loopcount}, {"loopc",TELNET_VARTYPE_INT32,0,&telnetparams.loopcount},
{"loopd",TELNET_VARTYPE_INT32,&telnetparams.loopdelay}, {"loopd",TELNET_VARTYPE_INT32,0,&telnetparams.loopdelay},
{"phypb",TELNET_VARTYPE_INT32,&telnetparams.phyprntbuff_size}, {"phypb",TELNET_VARTYPE_INT32,0,&telnetparams.phyprntbuff_size},
{"hsize",TELNET_VARTYPE_INT32,&telnetparams.histsize}, {"hsize",TELNET_VARTYPE_INT32,0,&telnetparams.histsize},
{"hfile",TELNET_VARTYPE_STRING,&telnetparams.histfile}, {"hfile",TELNET_VARTYPE_STRING,TELNET_CHECKVAL_RDONLY,&telnetparams.histfile},
{"",0,NULL} {"",0,0,NULL}
}; };
telnetshell_cmddef_t telnet_cmdarray[] = { telnetshell_cmddef_t telnet_cmdarray[] = {
...@@ -344,46 +344,46 @@ int history_cmd(char *buff, int debug, telnet_printfunc_t prnt) { ...@@ -344,46 +344,46 @@ int history_cmd(char *buff, int debug, telnet_printfunc_t prnt) {
/* /*
generic commands available for all modules loaded by the server generic commands available for all modules loaded by the server
*/ */
char *telnet_getvarvalue(int moduleindex, int varindex) { char *telnet_getvarvalue(telnetshell_vardef_t *var, int varindex) {
char *val; char *val;
switch(telnetparams.CmdParsers[moduleindex].var[varindex].vartype) { switch(var[varindex].vartype) {
case TELNET_VARTYPE_INT32: case TELNET_VARTYPE_INT32:
val=malloc(64); val=malloc(64);
snprintf(val,64,"%i",*(int32_t *)(telnetparams.CmdParsers[moduleindex].var[varindex].varvalptr)); snprintf(val,64,"%i",*(int32_t *)(var[varindex].varvalptr));
break; break;
case TELNET_VARTYPE_INT64: case TELNET_VARTYPE_INT64:
val=malloc(128); val=malloc(128);
snprintf(val,128,"%lli",(long long)*(int64_t *)(telnetparams.CmdParsers[moduleindex].var[varindex].varvalptr)); snprintf(val,128,"%lli",(long long)*(int64_t *)(var[varindex].varvalptr));
break; break;
case TELNET_VARTYPE_INT16: case TELNET_VARTYPE_INT16:
val=malloc(16); val=malloc(16);
snprintf(val,16,"%hi",*(short *)(telnetparams.CmdParsers[moduleindex].var[varindex].varvalptr)); snprintf(val,16,"%hi",*(short *)(var[varindex].varvalptr));
break; break;
case TELNET_VARTYPE_INT8: case TELNET_VARTYPE_INT8:
val=malloc(16); val=malloc(16);
snprintf(val,16,"%i",(int)(*(int8_t *)(telnetparams.CmdParsers[moduleindex].var[varindex].varvalptr))); snprintf(val,16,"%i",(int)(*(int8_t *)(var[varindex].varvalptr)));
break; break;
case TELNET_VARTYPE_UINT: case TELNET_VARTYPE_UINT:
val=malloc(64); val=malloc(64);
snprintf(val,64,"%u",*(unsigned int *)(telnetparams.CmdParsers[moduleindex].var[varindex].varvalptr)); snprintf(val,64,"%u",*(unsigned int *)(var[varindex].varvalptr));
break; break;
case TELNET_VARTYPE_DOUBLE: case TELNET_VARTYPE_DOUBLE:
val=malloc(32); val=malloc(32);
snprintf(val,32,"%g\n",*(double *)(telnetparams.CmdParsers[moduleindex].var[varindex].varvalptr)); snprintf(val,32,"%g\n",*(double *)(var[varindex].varvalptr));
break; break;
case TELNET_VARTYPE_STRING: case TELNET_VARTYPE_STRING:
val = strdup(*(char **)(telnetparams.CmdParsers[moduleindex].var[varindex].varvalptr)); val = strdup(*(char **)(var[varindex].varvalptr));
break; break;
default: default:
val=malloc(64); val=malloc(64);
snprintf(val,64,"ERR:%s var %i unknown type",telnetparams.CmdParsers[moduleindex].module,varindex); snprintf(val,64,"ERR:var %i unknown type",varindex);
break; break;
} }
return val; return val;
...@@ -401,7 +401,7 @@ int setgetvar(int moduleindex,char getorset,char *params) { ...@@ -401,7 +401,7 @@ int setgetvar(int moduleindex,char getorset,char *params) {
if (n > 0 && (getorset == 'g' || getorset == 'G')) { if (n > 0 && (getorset == 'g' || getorset == 'G')) {
client_printf("%s, %s = ", telnetparams.CmdParsers[moduleindex].module, client_printf("%s, %s = ", telnetparams.CmdParsers[moduleindex].module,
telnetparams.CmdParsers[moduleindex].var[i].varname ); telnetparams.CmdParsers[moduleindex].var[i].varname );
char *strval=telnet_getvarvalue(moduleindex, i); char *strval=telnet_getvarvalue(telnetparams.CmdParsers[moduleindex].var, i);
client_printf("%s\n",strval); client_printf("%s\n",strval);
free(strval); free(strval);
} }
......
...@@ -85,10 +85,15 @@ typedef struct telnetsrv_qmsg { ...@@ -85,10 +85,15 @@ typedef struct telnetsrv_qmsg {
#define TELNET_VARTYPE_DOUBLE 5 #define TELNET_VARTYPE_DOUBLE 5
#define TELNET_VARTYPE_INT8 6 #define TELNET_VARTYPE_INT8 6
#define TELNET_VARTYPE_UINT 7 #define TELNET_VARTYPE_UINT 7
#define TELNET_CHECKVAL_RDONLY 1
#define TELNET_CHECKVAL_BOOL 2
typedef struct variabledef { typedef struct variabledef {
char varname[TELNET_CMD_MAXSIZE]; char varname[TELNET_CMD_MAXSIZE];
char vartype; char vartype;
char checkval;
void *varvalptr; void *varvalptr;
} telnetshell_vardef_t; } telnetshell_vardef_t;
...@@ -157,6 +162,6 @@ extern int get_phybsize(void); ...@@ -157,6 +162,6 @@ extern int get_phybsize(void);
#endif #endif
#ifdef WEBSERVERCODE #ifdef WEBSERVERCODE
extern telnetsrv_params_t *get_telnetsrv_params(void); extern telnetsrv_params_t *get_telnetsrv_params(void);
extern char *telnet_getvarvalue(int moduleindex, int varindex); extern char *telnet_getvarvalue(telnetshell_vardef_t *var, int varindex);
#endif #endif
#endif #endif
...@@ -39,11 +39,11 @@ ...@@ -39,11 +39,11 @@
telnetshell_vardef_t loader_globalvardef[] = { telnetshell_vardef_t loader_globalvardef[] = {
{"mainversion",TELNET_VARTYPE_STRING,&(loader_data.mainexec_buildversion)}, {"mainversion",TELNET_VARTYPE_STRING,TELNET_CHECKVAL_RDONLY, &(loader_data.mainexec_buildversion)},
{"defpath",TELNET_VARTYPE_STRING,&(loader_data.shlibpath)}, {"defpath",TELNET_VARTYPE_STRING,TELNET_CHECKVAL_RDONLY,&(loader_data.shlibpath)},
{"maxshlibs",TELNET_VARTYPE_INT32,&(loader_data.maxshlibs)}, {"maxshlibs",TELNET_VARTYPE_INT32,TELNET_CHECKVAL_RDONLY,&(loader_data.maxshlibs)},
{"numshlibs",TELNET_VARTYPE_INT32,&(loader_data.numshlibs)}, {"numshlibs",TELNET_VARTYPE_INT32,TELNET_CHECKVAL_RDONLY,&(loader_data.numshlibs)},
{"",0,NULL} {"",0,0,NULL}
}; };
telnetshell_vardef_t *loader_modulesvardef; telnetshell_vardef_t *loader_modulesvardef;
......
...@@ -92,7 +92,7 @@ telnetshell_cmddef_t measur_cmdarray[] = { ...@@ -92,7 +92,7 @@ telnetshell_cmddef_t measur_cmdarray[] = {
}; };
telnetshell_vardef_t measur_vardef[] = { telnetshell_vardef_t measur_vardef[] = {
{"",0,NULL} {"",0,0,NULL}
}; };
/* function to be implemented in any telnetsrv_xxx_measurements.c sources /* function to be implemented in any telnetsrv_xxx_measurements.c sources
to allow common measurment code to access measurments data */ to allow common measurment code to access measurments data */
......
...@@ -53,7 +53,7 @@ telnetshell_vardef_t phy_vardef[] = { ...@@ -53,7 +53,7 @@ telnetshell_vardef_t phy_vardef[] = {
//{"txshift",TELNET_VARTYPE_INT32,NULL}, //{"txshift",TELNET_VARTYPE_INT32,NULL},
//{"rachemin",TELNET_VARTYPE_INT32,NULL}, //{"rachemin",TELNET_VARTYPE_INT32,NULL},
//{"rachdmax",TELNET_VARTYPE_INT32,NULL}, //{"rachdmax",TELNET_VARTYPE_INT32,NULL},
{"",0,NULL} {"",0,0,NULL}
}; };
#else #else
......
...@@ -46,7 +46,7 @@ extern int proccmd_thread(char *buf, int debug, telnet_printfunc_t prnt); ...@@ -46,7 +46,7 @@ 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_exit(char *buf, int debug, telnet_printfunc_t prnt);
extern int proccmd_log(char *buf, int debug, telnet_printfunc_t prnt); extern int proccmd_log(char *buf, int debug, telnet_printfunc_t prnt);
telnetshell_vardef_t proc_vardef[] = { telnetshell_vardef_t proc_vardef[] = {
{"",0,NULL} {"",0,0,NULL}
}; };
#define PROCCMD_LOG_HELP_STRING " log sub commands: \n\ #define PROCCMD_LOG_HELP_STRING " log sub commands: \n\
show: display current log configuration \n\ show: display current log configuration \n\
......
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)
# 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)
# 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)
This diff is collapsed.
...@@ -45,8 +45,8 @@ static telnetshell_cmddef_t coding_cmdarray[] = { ...@@ -45,8 +45,8 @@ static telnetshell_cmddef_t coding_cmdarray[] = {
{"","",NULL}, {"","",NULL},
}; };
telnetshell_vardef_t coding_vardef[] = { telnetshell_vardef_t coding_vardef[] = {
{"maxiter",TELNET_VARTYPE_INT32,&max_turbo_iterations}, {"maxiter",TELNET_VARTYPE_INT32,0,&max_turbo_iterations},
{"",0,NULL} {"",0,0,NULL}
}; };
/* PHY/defs.h contains MODE_DECODE_XXX macros, following table must match */ /* PHY/defs.h contains MODE_DECODE_XXX macros, following table must match */
static char *modedesc[] = {"none","sse","C","avx2"}; static char *modedesc[] = {"none","sse","C","avx2"};
......
...@@ -55,7 +55,7 @@ static telnetshell_cmddef_t channelmod_cmdarray[] = { ...@@ -55,7 +55,7 @@ static telnetshell_cmddef_t channelmod_cmdarray[] = {
}; };
static telnetshell_vardef_t channelmod_vardef[] = { static telnetshell_vardef_t channelmod_vardef[] = {
{"",0,NULL} {"",0,0,NULL}
}; };
static double snr_dB=25; static double snr_dB=25;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment