Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Black
OpenXG-RAN
Commits
698e7fee
Commit
698e7fee
authored
Apr 22, 2022
by
frtabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display array fix
parent
291533dd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
21 deletions
+26
-21
common/utils/telnetsrv/telnetsrv.h
common/utils/telnetsrv/telnetsrv.h
+1
-0
common/utils/telnetsrv/telnetsrv_proccmd.c
common/utils/telnetsrv/telnetsrv_proccmd.c
+3
-3
common/utils/telnetsrv/telnetsrv_proccmd.h
common/utils/telnetsrv/telnetsrv_proccmd.h
+2
-2
common/utils/websrv/websrv.c
common/utils/websrv/websrv.c
+20
-16
No files found.
common/utils/telnetsrv/telnetsrv.h
View file @
698e7fee
...
...
@@ -84,6 +84,7 @@ typedef int(*qcmdfunc_t)(char*, int, telnet_printfunc_t prnt,void *arg);
#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
typedef
struct
cmddef
{
char
cmdname
[
TELNET_CMD_MAXSIZE
];
char
helpstr
[
TELNET_HELPSTR_SIZE
];
...
...
common/utils/telnetsrv/telnetsrv_proccmd.c
View file @
698e7fee
...
...
@@ -198,7 +198,7 @@ int proccmd_websrv_getdata(char *cmdbuff, int debug, void *data) {
logsdata
->
numcols
=
4
;
logsdata
->
numlines
=
0
;
snprintf
(
logsdata
->
columns
[
0
].
coltitle
,
TELNET_CMD_MAXSIZE
,
"component"
);
logsdata
->
columns
[
0
].
coltype
=
TELNET_VARTYPE_STRING
;
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"
);
...
...
@@ -223,7 +223,7 @@ int proccmd_websrv_getdata(char *cmdbuff, int debug, void *data) {
logsdata
->
numcols
=
3
;
logsdata
->
numlines
=
0
;
snprintf
(
logsdata
->
columns
[
0
].
coltitle
,
TELNET_CMD_MAXSIZE
,
"module"
);
logsdata
->
columns
[
0
].
coltype
=
TELNET_VARTYPE_STRING
;
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"
);
...
...
@@ -242,7 +242,7 @@ int proccmd_websrv_getdata(char *cmdbuff, int debug, void *data) {
logsdata
->
numcols
=
2
;
logsdata
->
numlines
=
0
;
snprintf
(
logsdata
->
columns
[
0
].
coltitle
,
TELNET_CMD_MAXSIZE
,
"option"
);
logsdata
->
columns
[
0
].
coltype
=
TELNET_VARTYPE_STRING
;
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
;
...
...
common/utils/telnetsrv/telnetsrv_proccmd.h
View file @
698e7fee
...
...
@@ -77,8 +77,8 @@ telnetshell_cmddef_t proc_cmdarray[] = {
{
"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_GETWEBDATA
,
NULL
},
{
"show logopt"
,
""
,
proccmd_log
,{(
webfunc_t
)
proccmd_websrv_getdata
},
TELNETSRV_CMDFLAG_WEBSRVONLY
|
TELNETSRV_CMDFLAG_GETWEBDATA
,
NULL
},
{
"show dbgopt"
,
""
,
proccmd_log
,{(
webfunc_t
)
proccmd_websrv_getdata
},
TELNETSRV_CMDFLAG_WEBSRVONLY
|
TELNETSRV_CMDFLAG_GETWEBDATA
,
NULL
},
{
"show logopt"
,
""
,
proccmd_log
,{(
webfunc_t
)
proccmd_websrv_getdata
},
TELNETSRV_CMDFLAG_WEBSRVONLY
|
TELNETSRV_CMDFLAG_GETWEB
TBL
DATA
,
NULL
},
{
"show dbgopt"
,
""
,
proccmd_log
,{(
webfunc_t
)
proccmd_websrv_getdata
},
TELNETSRV_CMDFLAG_WEBSRVONLY
|
TELNETSRV_CMDFLAG_GETWEB
TBL
DATA
,
NULL
},
{
"thread"
,
"(enter help for details)"
,
proccmd_thread
,{(
webfunc_t
)
proccmd_websrv_getdata
},
0
,
NULL
},
{
"exit"
,
""
,
proccmd_exit
,{
NULL
},
TELNETSRV_CMDFLAG_CONFEXEC
,
NULL
},
{
""
,
""
,
NULL
},
...
...
common/utils/websrv/websrv.c
View file @
698e7fee
...
...
@@ -155,7 +155,7 @@ void websrv_getdata_response(struct _u_response * response,webdatadef_t * wdata)
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
)
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]));
...
...
@@ -165,45 +165,43 @@ void websrv_getdata_response(struct _u_response * response,webdatadef_t * wdata)
}
json_array_append_new
(
jdata
,
kv
);
}
json_t
*
jbody
=
json_pack
(
"{s:
o,s:o}"
,
"display"
,
json_string
(
""
),
"logs"
,
jdata
);
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
*
jcols
=
json_array
();
json_t
*
jdata
=
json_array
();
char
*
coltype
;
for
(
int
i
=
0
;
i
<
wdata
->
numcols
;
i
++
)
{
json_t *jval;
if(wdata->columns[j].coltype & TELNET_CHECKVAL_BOOL)
if
(
wdata
->
columns
[
i
].
coltype
&
TELNET_CHECKVAL_BOOL
)
coltype
=
"boolean"
;
else if (wdata->columns[
j].coltype ==
TELNET_VARTYPE_STRING)
else
if
(
wdata
->
columns
[
i
].
coltype
&
TELNET_VARTYPE_STRING
)
coltype
=
"string"
;
else
coltype
=
"number"
;
json_t acol=json_pack("{name:s,type:s,modifiable:b}",wdata->columns[j].coltitle,coltype,);
json_t
*
acol
=
json_pack
(
"{name:s,type:s,modifiable:b}"
,
wdata
->
columns
[
i
].
coltitle
,
coltype
,
(
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 *kv=json_object();
for (int j=0; j<wdata->numcols; j++) {
json_t *jval;
json_t
*
jval
;
for
(
int
j
=
0
;
j
<
wdata
->
numcols
;
j
++
)
{
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)
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
,
jval
);
}
json_array_append_new(jdata,kv);
}
json_t *jbody=json_pack("{s:o,s:o}","columns",
,"rows",
);
websrv_jbody(response,jbody);
*/
json_t
*
jbody
=
json_pack
(
"{s:o,s:o}"
,
"columns"
,
jcols
,
"rows"
,
jdata
);
websrv_jbody
(
response
,
jbody
);
}
/*----------------------------------------------------------------------------------------------------------*/
/* callbacks and utility functions to stream a file */
...
...
@@ -437,11 +435,17 @@ int websrv_callback_set_softmodemvar(const struct _u_request * request, struct _
/* 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
);
cmd
->
cmdfunc
(
""
,
websrvparams
.
dbglvl
,
websrv_printf
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment