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
lizhongxiao
OpenXG-RAN
Commits
80bf0358
Commit
80bf0358
authored
Apr 21, 2022
by
frtabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test table reslt with log command
parent
86f36e80
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
7 deletions
+36
-7
common/utils/telnetsrv/telnetsrv.h
common/utils/telnetsrv/telnetsrv.h
+5
-3
common/utils/telnetsrv/telnetsrv_proccmd.c
common/utils/telnetsrv/telnetsrv_proccmd.c
+9
-1
common/utils/websrv/websrv.c
common/utils/websrv/websrv.c
+20
-1
targets/ARCH/rfsimulator/simulator.c
targets/ARCH/rfsimulator/simulator.c
+2
-2
No files found.
common/utils/telnetsrv/telnetsrv.h
View file @
80bf0358
...
...
@@ -50,7 +50,7 @@
/* definitions to store 2 dim table, used to store command results before */
/* displaying them either on console or web page */
#define TELNET_MAXLINE_NUM
5
0
#define TELNET_MAXLINE_NUM
10
0
#define TELNET_MAXCOL_NUM 5
typedef
struct
col
{
...
...
@@ -108,6 +108,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
...
...
@@ -116,8 +118,8 @@ typedef struct telnetsrv_qmsg {
#define TELNET_VARTYPE_INT8 6
#define TELNET_VARTYPE_UINT 7
#define TELNET_CHECKVAL_RDONLY 1
#define TELNET_CHECKVAL_BOOL 2
#define TELNET_CHECKVAL_RDONLY 1
6
#define TELNET_CHECKVAL_BOOL
3
2
typedef
struct
variabledef
{
char
varname
[
TELNET_CMD_MAXSIZE
];
char
vartype
;
...
...
common/utils/telnetsrv/telnetsrv_proccmd.c
View file @
80bf0358
...
...
@@ -196,16 +196,24 @@ 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
;
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
[
2
]
=
(
g_log
->
log_component
[
i
].
level
>=
0
)
?
0xFFFFFFFF
:
NULL
;
logsdata
->
lines
[
i
].
val
[
3
]
=
(
g_log
->
log_component
[
i
].
filelog
>
0
)
?
g_log
->
log_component
[
i
].
filelog_name
:
"stdout"
;
}
}
...
...
common/utils/websrv/websrv.c
View file @
80bf0358
...
...
@@ -66,6 +66,7 @@ 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
);
}
/*-----------------------------------*/
/* build a json body in a response */
...
...
@@ -146,7 +147,24 @@ void websrv_printf_end(int httpstatus ) {
/*--------------------------------------------------------------------------------------------------*/
/* 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
*
jbody
=
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
((
int
)(
wdata
->
lines
[
i
].
val
[
j
]));
json_object_set_new
(
kv
,
wdata
->
columns
[
j
].
coltitle
,
jval
);
}
json_array_append_new
(
jbody
,
kv
);
}
websrv_jbody
(
response
,
jbody
);
}
/*----------------------------------------------------------------------------------------------------------*/
/* callbacks and utility functions to stream a file */
...
...
@@ -382,6 +400,7 @@ int websrv_processwebfunc(struct _u_response * response, cmdparser_t * modulestr
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
->
helpstr
,
websrvparams
.
dbglvl
,(
webdatadef_t
*
)
&
wdata
);
websrv_getdata_response
(
response
,
&
wdata
);
}
else
{
...
...
targets/ARCH/rfsimulator/simulator.c
View file @
80bf0358
...
...
@@ -91,8 +91,8 @@
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
,
NULL
,
TELNETSRV_CMDFLAG_PUSHINTPOOLQ
},
{
""
,
""
,
NULL
,
NULL
,
0
},
{
"setmodel"
,
"<model name> <model type>"
,(
cmdfunc_t
)
rfsimu_setchanmod_cmd
,
{
NULL
},
TELNETSRV_CMDFLAG_PUSHINTPOOLQ
,
NULL
},
{
""
,
""
,
NULL
,
{
NULL
},
0
,
NULL
},
};
static
telnetshell_vardef_t
rfsimu_vardef
[]
=
{
...
...
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