Commit c4cf67f0 authored by frtabu's avatar frtabu

modify telnet server structure to support command execution from the webserver

parent 9dbcab30
......@@ -90,9 +90,12 @@ 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 *fname, ... );
int setparam(char *buff, int debug, telnet_printfunc_t prnt);
int wsetparam(char *pname, ... );
int history_cmd(char *buff, int debug, telnet_printfunc_t prnt);
telnetshell_vardef_t telnet_vardef[] = {
{"debug",TELNET_VARTYPE_INT32,0,&telnetparams.telnetdbg},
{"prio",TELNET_VARTYPE_INT32,0,&telnetparams.priority},
......@@ -105,10 +108,10 @@ telnetshell_vardef_t telnet_vardef[] = {
};
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,0,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 *fname, ... ) {
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 *pname, ... ) {
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));
......
......@@ -54,6 +54,7 @@
/* 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 *exec, ... );
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
......@@ -61,6 +62,7 @@ typedef struct cmddef {
char cmdname[TELNET_CMD_MAXSIZE];
char helpstr[TELNET_HELPSTR_SIZE];
cmdfunc_t cmdfunc;
webfunc_t webfunc;
unsigned int cmdflags;
void *qptr;
} telnetshell_cmddef_t;
......
......@@ -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},
};
......
This diff is collapsed.
......@@ -41,7 +41,7 @@
/* 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
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
......
......@@ -41,8 +41,8 @@
static int coding_setmod_cmd(char *buff, int debug, telnet_printfunc_t prnt);
static telnetshell_cmddef_t coding_cmdarray[] = {
{"mode","[sse,avx2,stdc,none]",coding_setmod_cmd},
{"","",NULL},
{"mode","[sse,avx2,stdc,none]",coding_setmod_cmd,NULL,0,NULL},
{"","",NULL,NULL,0,NULL},
};
telnetshell_vardef_t coding_vardef[] = {
{"maxiter",TELNET_VARTYPE_INT32,0,&max_turbo_iterations},
......
......@@ -48,10 +48,10 @@ static int channelmod_show_cmd(char *buff, int debug, telnet_printfunc_t prnt);
static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt);
static int channelmod_print_help(char *buff, int debug, telnet_printfunc_t prnt);
static telnetshell_cmddef_t channelmod_cmdarray[] = {
{"help","",channelmod_print_help},
{"show","<predef,current>",channelmod_show_cmd},
{"modify","<channelid> <param> <value>",channelmod_modify_cmd},
{"","",NULL},
{"help","",channelmod_print_help,NULL,0,NULL},
{"show","<predef,current>",channelmod_show_cmd,NULL,0,NULL},
{"modify","<channelid> <param> <value>",channelmod_modify_cmd,NULL,0,NULL},
{"","",NULL,NULL,0,NULL},
};
static telnetshell_vardef_t channelmod_vardef[] = {
......
......@@ -91,12 +91,12 @@
static int rfsimu_setchanmod_cmd(char *buff, int debug, telnet_printfunc_t prnt, void *arg);
static telnetshell_cmddef_t rfsimu_cmdarray[] = {
{"setmodel","<model name> <model type>",(cmdfunc_t)rfsimu_setchanmod_cmd,TELNETSRV_CMDFLAG_PUSHINTPOOLQ},
{"","",NULL},
{"setmodel","<model name> <model type>",(cmdfunc_t)rfsimu_setchanmod_cmd,NULL,TELNETSRV_CMDFLAG_PUSHINTPOOLQ},
{"","",NULL,NULL,0},
};
static telnetshell_vardef_t rfsimu_vardef[] = {
{"",0,NULL}
{"",0,0,NULL}
};
pthread_mutex_t Sockmutex;
......
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