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
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
OpenXG
OpenXG-RAN
Commits
e1dc1d9d
Commit
e1dc1d9d
authored
2 years ago
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly implement option to load additional SOs for telnet
parent
6c6ce912
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
common/utils/telnetsrv/telnetsrv.c
common/utils/telnetsrv/telnetsrv.c
+15
-16
No files found.
common/utils/telnetsrv/telnetsrv.c
View file @
e1dc1d9d
...
@@ -821,14 +821,14 @@ void poll_telnetcmdq(void *qid, void *arg) {
...
@@ -821,14 +821,14 @@ void poll_telnetcmdq(void *qid, void *arg) {
*
*
*
*
*/
*/
void
exec_moduleinit
(
char
*
modname
)
{
static
bool
exec_moduleinit
(
char
*
modname
)
{
void
(
*
fptr
)(
void
);
void
(
*
fptr
)(
void
);
char
initfunc
[
TELNET_CMD_MAXSIZE
+
10
];
char
initfunc
[
TELNET_CMD_MAXSIZE
+
10
];
if
(
strlen
(
modname
)
>
TELNET_CMD_MAXSIZE
)
{
if
(
strlen
(
modname
)
>
TELNET_CMD_MAXSIZE
)
{
fprintf
(
stderr
,
"[TELNETSRV] module %s not loaded, name exceeds the %i size limit
\n
"
,
fprintf
(
stderr
,
"[TELNETSRV] module %s not loaded, name exceeds the %i size limit
\n
"
,
modname
,
TELNET_CMD_MAXSIZE
);
modname
,
TELNET_CMD_MAXSIZE
);
return
;
return
false
;
}
}
sprintf
(
initfunc
,
"add_%s_cmds"
,
modname
);
sprintf
(
initfunc
,
"add_%s_cmds"
,
modname
);
...
@@ -836,37 +836,35 @@ void exec_moduleinit(char *modname) {
...
@@ -836,37 +836,35 @@ void exec_moduleinit(char *modname) {
if
(
fptr
!=
NULL
)
{
if
(
fptr
!=
NULL
)
{
fptr
();
fptr
();
}
else
{
return
true
;
fprintf
(
stderr
,
"[TELNETSRV] couldn't find %s for module %s
\n
"
,
initfunc
,
modname
);
}
}
fprintf
(
stderr
,
"[TELNETSRV] couldn't find %s for module %s
\n
"
,
initfunc
,
modname
);
return
false
;
}
}
int
add_embeddedmodules
(
void
)
{
int
add_embeddedmodules
(
void
)
{
int
ret
=
0
;
int
ret
=
0
;
int
pindex
=
config_paramidx_fromname
(
telnetoptions
,
sizeof
(
telnetoptions
)
/
sizeof
(
paramdef_t
),
TELNETSRV_OPTNAME_STATICMOD
);
int
pindex
=
config_paramidx_fromname
(
telnetoptions
,
sizeof
(
telnetoptions
)
/
sizeof
(
paramdef_t
),
TELNETSRV_OPTNAME_STATICMOD
);
for
(
int
i
=
0
;
i
<
telnetoptions
[
pindex
].
numelt
;
i
++
)
{
for
(
int
i
=
0
;
i
<
telnetoptions
[
pindex
].
numelt
;
i
++
)
{
ret
++
;
bool
success
=
exec_moduleinit
(
telnetoptions
[
pindex
].
strlistptr
[
i
]);
exec_moduleinit
(
telnetoptions
[
pindex
].
strlistptr
[
i
]);
if
(
success
)
ret
++
;
}
}
return
ret
;
return
ret
;
}
}
int
add_sharedmodules
(
void
)
{
int
add_sharedmodules
(
void
)
{
char
initfunc
[
TELNET_CMD_MAXSIZE
+
9
];
void
(
*
fptr
)(
void
);
int
ret
=
0
;
int
ret
=
0
;
int
pindex
=
config_paramidx_fromname
(
telnetoptions
,
sizeof
(
telnetoptions
)
/
sizeof
(
paramdef_t
),
TELNETSRV_OPTNAME_SHRMOD
);
int
pindex
=
config_paramidx_fromname
(
telnetoptions
,
sizeof
(
telnetoptions
)
/
sizeof
(
paramdef_t
),
TELNETSRV_OPTNAME_SHRMOD
);
for
(
int
i
=
0
;
i
<
telnetoptions
[
pindex
].
numelt
;
i
++
)
{
for
(
int
i
=
0
;
i
<
telnetoptions
[
pindex
].
numelt
;
i
++
)
{
sprintf
(
initfunc
,
"add_%s_cmds"
,
telnetoptions
[
pindex
].
strlistptr
[
i
]);
char
*
name
=
telnetoptions
[
pindex
].
strlistptr
[
i
];
fptr
=
dlsym
(
RTLD_DEFAULT
,
initfunc
);
char
libname
[
256
];
snprintf
(
libname
,
sizeof
(
libname
),
"telnetsrv_%s"
,
name
);
if
(
fptr
!=
NULL
)
{
load_module_shlib
(
libname
,
NULL
,
0
,
NULL
);
fptr
();
bool
success
=
exec_moduleinit
(
name
);
if
(
success
)
ret
++
;
ret
++
;
}
else
{
fprintf
(
stderr
,
"[TELNETSRV] couldn't find %s for module %s
\n
"
,
initfunc
,
telnetoptions
[
pindex
].
strlistptr
[
i
]);
}
}
}
return
ret
;
return
ret
;
...
@@ -890,6 +888,7 @@ int telnetsrv_autoinit(void) {
...
@@ -890,6 +888,7 @@ int telnetsrv_autoinit(void) {
add_telnetcmd
(
"telnet"
,
telnet_vardef
,
telnet_cmdarray
);
add_telnetcmd
(
"telnet"
,
telnet_vardef
,
telnet_cmdarray
);
add_embeddedmodules
();
add_embeddedmodules
();
add_sharedmodules
();
if
(
telnetparams
.
listenstdin
)
{
if
(
telnetparams
.
listenstdin
)
{
if
(
pthread_create
(
&
telnetparams
.
telnetclt_pthread
,
NULL
,
(
void
*
(
*
)(
void
*
))
run_telnetclt
,
NULL
)
!=
0
)
{
if
(
pthread_create
(
&
telnetparams
.
telnetclt_pthread
,
NULL
,
(
void
*
(
*
)(
void
*
))
run_telnetclt
,
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"[TELNETSRV] Error %s on pthread_create f() run_telnetclt
\n
"
,
strerror
(
errno
));
fprintf
(
stderr
,
"[TELNETSRV] Error %s on pthread_create f() run_telnetclt
\n
"
,
strerror
(
errno
));
...
...
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