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
eb68baaa
Commit
eb68baaa
authored
Apr 26, 2022
by
El Mghazli Yacine
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'websrv' of gitlab.eurecom.fr:oai/openairinterface5g into websrv
parents
b4e02802
16fc6028
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
29 deletions
+63
-29
common/utils/telnetsrv/telnetsrv.c
common/utils/telnetsrv/telnetsrv.c
+1
-1
common/utils/telnetsrv/telnetsrv.h
common/utils/telnetsrv/telnetsrv.h
+7
-6
common/utils/telnetsrv/telnetsrv_proccmd.c
common/utils/telnetsrv/telnetsrv_proccmd.c
+16
-12
common/utils/telnetsrv/telnetsrv_proccmd.h
common/utils/telnetsrv/telnetsrv_proccmd.h
+2
-2
common/utils/websrv/websrv.c
common/utils/websrv/websrv.c
+33
-6
openair1/SIMULATION/TOOLS/random_channel.c
openair1/SIMULATION/TOOLS/random_channel.c
+4
-2
No files found.
common/utils/telnetsrv/telnetsrv.c
View file @
eb68baaa
...
...
@@ -110,7 +110,7 @@ telnetshell_vardef_t telnet_vardef[] = {
telnetshell_cmddef_t
telnet_cmdarray
[]
=
{
{
"redirlog"
,
"[here,file,off]"
,
setoutput
,{
wsetoutput
},
0
,
NULL
},
{
"param"
,
"[prio]"
,
setparam
,{
wsetparam
},
0
,
NULL
},
{
"history"
,
"[list,reset]"
,
history_cmd
,{
NULL
},
0
,
NULL
},
{
"history"
,
"[list,reset]"
,
history_cmd
,{
NULL
},
TELNETSRV_CMDFLAG_TELNETONLY
,
NULL
},
{
""
,
""
,
NULL
,{
NULL
},
0
,
NULL
},
};
...
...
common/utils/telnetsrv/telnetsrv.h
View file @
eb68baaa
...
...
@@ -79,12 +79,13 @@ 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_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_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
];
...
...
common/utils/telnetsrv/telnetsrv_proccmd.c
View file @
eb68baaa
...
...
@@ -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,10 +185,11 @@ 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 */
...
...
@@ -213,7 +216,7 @@ int proccmd_websrv_getdata(char *cmdbuff, int debug, void *data) {
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
)
?
(
char
*
)
0xFFFFFFFF
:
NULL
;
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"
;
}
}
...
...
@@ -232,8 +235,8 @@ int proccmd_websrv_getdata(char *cmdbuff, int debug, void *data) {
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
)
?
(
char
*
)
0xFFFFFFFF
:
NULL
;
logsdata
->
lines
[
i
].
val
[
2
]
=
(
g_log
->
dump_mask
&
log_maskmap
[
i
].
value
)
?
(
char
*
)
0xFFFFFFFF
:
NULL
;
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"
;
}
}
...
...
@@ -249,9 +252,10 @@ int proccmd_websrv_getdata(char *cmdbuff, int debug, void *data) {
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
)
?
(
char
*
)
0xFFFFFFFF
:
NULL
;
logsdata
->
lines
[
i
].
val
[
1
]
=
(
g_log
->
flag
&
log_options
[
i
].
value
)
?
"true"
:
"false"
;
}
}
return
0
;
}
...
...
@@ -354,7 +358,7 @@ char sv1[64];
prnt
(
" proccmd_thread: %i params = %i,%s,%i
\n
"
,
res
,
bv1
,
sv1
,
bv2
);
if
(
res
!=
3
)
{
pr
nt
(
"softmodem thread needs 3 params, %i received
\n
"
,
res
);
pr
int_threads
(
buf
,
debug
,
prnt
);
return
0
;
}
...
...
common/utils/telnetsrv/telnetsrv_proccmd.h
View file @
eb68baaa
...
...
@@ -76,11 +76,11 @@ telnetshell_vardef_t proc_vardef[] = {
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 loglvl"
,
""
,
proccmd_log
,{(
webfunc_t
)
proccmd_websrv_getdata
},
TELNETSRV_CMDFLAG_WEBSRVONLY
|
TELNETSRV_CMDFLAG_GETWEB
TBL
DATA
,
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
},
{
"
thread"
,
"(enter help for details)"
,
proccmd_thread
,{(
webfunc_t
)
proccmd_websrv_getdata
},
0
,
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
},
};
...
...
common/utils/websrv/websrv.c
View file @
eb68baaa
...
...
@@ -57,8 +57,8 @@
};
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
),
struct
_u_response
*
response
,
void
*
user_data
),
void
*
user_data
)
;
void
register_module_endpoints
(
cmdparser_t
*
module
)
;
...
...
@@ -68,6 +68,7 @@ void websrv_printjson(char * label, json_t *jsonobj){
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
)
{
...
...
@@ -144,6 +145,27 @@ void websrv_printf_end(int httpstatus ) {
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
)
{
...
...
@@ -190,7 +212,7 @@ void websrv_gettbldata_response(struct _u_response * response,webdatadef_t * wda
json_t
*
jline
=
json_array
();
for
(
int
j
=
0
;
j
<
wdata
->
numcols
;
j
++
)
{
if
(
wdata
->
columns
[
j
].
coltype
&
TELNET_CHECKVAL_BOOL
)
jval
=
json_
boolean
(
wdata
->
lines
[
i
].
val
[
j
]);
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)
...
...
@@ -201,9 +223,10 @@ void websrv_gettbldata_response(struct _u_response * response,webdatadef_t * wda
}
json_array_append_new
(
jdata
,
jline
);
}
json_t
*
jbody
=
json_pack
(
"{s:
o,s:o}
"
,
"columns"
,
jcols
,
"rows"
,
jdata
);
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
)
{
...
...
@@ -449,8 +472,12 @@ int websrv_processwebfunc(struct _u_response * response, cmdparser_t * modulestr
websrv_gettbldata_response
(
response
,
&
wdata
);
}
else
{
websrv_printf_start
(
response
,
16384
);
cmd
->
cmdfunc
(
cmd
->
cmdname
,
websrvparams
.
dbglvl
,
websrv_printf
);
websrv_printf_end
(
200
);
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
;
}
...
...
openair1/SIMULATION/TOOLS/random_channel.c
View file @
eb68baaa
...
...
@@ -49,8 +49,10 @@ 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
,{
NULL
},
0
,
NULL
},
{
"show"
,
"<predef,current>"
,
channelmod_show_cmd
,{
NULL
},
0
,
NULL
},
{
"modify"
,
"<channelid> <param> <value>"
,
channelmod_modify_cmd
,{
NULL
},
0
,
NULL
},
{
"show"
,
"<predef,current>"
,
channelmod_show_cmd
,{
NULL
},
TELNETSRV_CMDFLAG_TELNETONLY
,
NULL
},
{
"show predef"
,
""
,
channelmod_show_cmd
,{
NULL
},
TELNETSRV_CMDFLAG_WEBSRVONLY
,
NULL
},
{
"show current"
,
""
,
channelmod_show_cmd
,{
NULL
},
TELNETSRV_CMDFLAG_WEBSRVONLY
,
NULL
},
{
"modify"
,
"<channelid> <param> <value>"
,
channelmod_modify_cmd
,{
NULL
},
TELNETSRV_CMDFLAG_TELNETONLY
,
NULL
},
{
""
,
""
,
NULL
,{
NULL
},
0
,
NULL
},
};
...
...
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