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
8d74ea38
Commit
8d74ea38
authored
Apr 06, 2022
by
frtabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backend implementation of variable modifications
parent
a3ac83a1
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
96 deletions
+146
-96
common/utils/telnetsrv/telnetsrv.c
common/utils/telnetsrv/telnetsrv.c
+49
-35
common/utils/telnetsrv/telnetsrv.h
common/utils/telnetsrv/telnetsrv.h
+1
-0
common/utils/websrv/websrv.c
common/utils/websrv/websrv.c
+96
-61
No files found.
common/utils/telnetsrv/telnetsrv.c
View file @
8d74ea38
...
...
@@ -389,61 +389,75 @@ char *telnet_getvarvalue(telnetshell_vardef_t *var, int varindex) {
return
val
;
}
int
setgetvar
(
int
moduleindex
,
char
getorset
,
char
*
params
)
{
int
n
,
i
;
char
varname
[
TELNET_CMD_MAXSIZE
];
char
*
varval
=
NULL
;
memset
(
varname
,
0
,
sizeof
(
varname
));
n
=
sscanf
(
params
,
"%9s %ms"
,
varname
,
&
varval
);
for
(
i
=
0
;
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
!=
NULL
;
i
++
)
{
if
(
strncasecmp
(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varname
,
varname
,
strlen
(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varname
))
==
0
)
{
if
(
n
>
0
&&
(
getorset
==
'g'
||
getorset
==
'G'
))
{
client_printf
(
"%s, %s = "
,
telnetparams
.
CmdParsers
[
moduleindex
].
module
,
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varname
);
char
*
strval
=
telnet_getvarvalue
(
telnetparams
.
CmdParsers
[
moduleindex
].
var
,
i
);
client_printf
(
"%s
\n
"
,
strval
);
free
(
strval
);
}
if
(
n
>
1
&&
(
getorset
==
's'
||
getorset
==
'S'
))
{
client_printf
(
"%s, %s set to
\n
"
,
telnetparams
.
CmdParsers
[
moduleindex
].
module
,
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varname
);
switch
(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
vartype
)
{
int
telnet_setvarvalue
(
telnetshell_vardef_t
*
var
,
char
*
strval
,
telnet_printfunc_t
prnt
)
{
int
st
=
0
;
switch
(
var
->
vartype
)
{
case
TELNET_VARTYPE_INT32
:
*
(
int
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
)
=
(
int
)
strtol
(
varval
,
NULL
,
0
);
client_printf
(
"%i
\n
"
,
*
(
int
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
));
*
(
int
*
)(
var
->
varvalptr
)
=
(
int
)
strtol
(
strval
,
NULL
,
0
);
if
(
prnt
!=
NULL
)
prnt
(
"%i
\n
"
,
*
(
int
*
)(
var
->
varvalptr
));
break
;
case
TELNET_VARTYPE_INT16
:
*
(
short
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
)
=
(
short
)
strtol
(
varval
,
NULL
,
0
);
client_printf
(
"%hi
\n
"
,
*
(
short
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
));
*
(
short
*
)(
var
->
varvalptr
)
=
(
short
)
strtol
(
strval
,
NULL
,
0
);
if
(
prnt
!=
NULL
)
prnt
(
"%hi
\n
"
,
*
(
short
*
)(
var
->
varvalptr
));
break
;
case
TELNET_VARTYPE_INT8
:
*
(
char
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
)
=
(
char
)
strtol
(
varval
,
NULL
,
0
);
client_printf
(
"%i
\n
"
,
*
(
int
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
));
*
(
char
*
)(
var
->
varvalptr
)
=
(
char
)
strtol
(
strval
,
NULL
,
0
);
if
(
prnt
!=
NULL
)
prnt
(
"%i
\n
"
,
*
(
int
*
)(
var
->
varvalptr
));
break
;
case
TELNET_VARTYPE_UINT
:
*
(
unsigned
int
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
)
=
(
unsigned
int
)
strtol
(
varval
,
NULL
,
0
);
client_printf
(
"%u
\n
"
,
*
(
unsigned
int
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
));
*
(
unsigned
int
*
)(
var
->
varvalptr
)
=
(
unsigned
int
)
strtol
(
strval
,
NULL
,
0
);
if
(
prnt
!=
NULL
)
prnt
(
"%u
\n
"
,
*
(
unsigned
int
*
)(
var
->
varvalptr
));
break
;
case
TELNET_VARTYPE_DOUBLE
:
*
(
double
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
)
=
strtod
(
varval
,
NULL
);
client_printf
(
"%g
\n
"
,
*
(
double
*
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
));
*
(
double
*
)(
var
->
varvalptr
)
=
strtod
(
strval
,
NULL
);
if
(
prnt
!=
NULL
)
prnt
(
"%g
\n
"
,
*
(
double
*
)(
var
->
varvalptr
));
break
;
case
TELNET_VARTYPE_STRING
:
sprintf
(
*
(
char
**
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
),
"%s"
,
varval
);
client_printf
(
"
\"
%s
\"\n
"
,
*
(
char
**
)(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
));
sprintf
(
*
(
char
**
)(
var
->
varvalptr
),
"%s"
,
strval
);
if
(
prnt
!=
NULL
)
prnt
(
"
\"
%s
\"\n
"
,
*
(
char
**
)(
var
->
varvalptr
));
break
;
default:
client_printf
(
"unknown type
\n
"
);
if
(
prnt
!=
NULL
)
prnt
(
"unknown type
\n
"
);
st
=-
1
;
break
;
}
return
st
;
}
int
setgetvar
(
int
moduleindex
,
char
getorset
,
char
*
params
)
{
int
n
,
i
;
char
varname
[
TELNET_CMD_MAXSIZE
];
char
*
varval
=
NULL
;
memset
(
varname
,
0
,
sizeof
(
varname
));
n
=
sscanf
(
params
,
"%9s %ms"
,
varname
,
&
varval
);
for
(
i
=
0
;
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varvalptr
!=
NULL
;
i
++
)
{
if
(
strncasecmp
(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varname
,
varname
,
strlen
(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varname
))
==
0
)
{
if
(
n
>
0
&&
(
getorset
==
'g'
||
getorset
==
'G'
))
{
client_printf
(
"%s, %s = "
,
telnetparams
.
CmdParsers
[
moduleindex
].
module
,
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varname
);
char
*
strval
=
telnet_getvarvalue
(
telnetparams
.
CmdParsers
[
moduleindex
].
var
,
i
);
client_printf
(
"%s
\n
"
,
strval
);
free
(
strval
);
}
if
(
n
>
1
&&
(
getorset
==
's'
||
getorset
==
'S'
))
{
client_printf
(
"%s, %s set to
\n
"
,
telnetparams
.
CmdParsers
[
moduleindex
].
module
,
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
].
varname
);
telnet_setvarvalue
(
&
(
telnetparams
.
CmdParsers
[
moduleindex
].
var
[
i
]),
varval
,
client_printf
);
}
}
}
...
...
common/utils/telnetsrv/telnetsrv.h
View file @
8d74ea38
...
...
@@ -163,5 +163,6 @@ extern int get_phybsize(void);
#ifdef WEBSERVERCODE
extern
telnetsrv_params_t
*
get_telnetsrv_params
(
void
);
extern
char
*
telnet_getvarvalue
(
telnetshell_vardef_t
*
var
,
int
varindex
);
extern
int
telnet_setvarvalue
(
telnetshell_vardef_t
*
var
,
char
*
strval
,
telnet_printfunc_t
prnt
)
;
#endif
#endif
common/utils/websrv/websrv.c
View file @
8d74ea38
This diff is collapsed.
Click to expand it.
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