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
littleBu
OpenXG-RAN
Commits
28f1035e
Commit
28f1035e
authored
3 years ago
by
frtabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config module fixes and websrv modif
parent
6e3f09a3
Branches unavailable
setparam
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
48 deletions
+101
-48
common/config/config_cmdline.c
common/config/config_cmdline.c
+2
-0
common/config/config_load_configmodule.c
common/config/config_load_configmodule.c
+3
-1
common/config/config_load_configmodule.h
common/config/config_load_configmodule.h
+1
-0
common/config/libconfig/config_libconfig.c
common/config/libconfig/config_libconfig.c
+49
-21
common/utils/LOG/log.c
common/utils/LOG/log.c
+2
-2
common/utils/websrv/websrv.c
common/utils/websrv/websrv.c
+44
-24
No files found.
common/config/config_cmdline.c
View file @
28f1035e
...
...
@@ -88,6 +88,8 @@ int processoption(paramdef_t *cfgoptions, char *value) {
config_check_valptr
(
cfgoptions
,
cfgoptions
->
strptr
,
strlen
(
tmpval
)
+
1
);
sprintf
(
*
(
cfgoptions
->
strptr
),
"%s"
,
tmpval
);
}
else
{
AssertFatal
(
(
strlen
(
*
(
cfgoptions
->
strptr
))
<
cfgoptions
->
numelt
),
"[CONFIG] Error: %s too long, %s value cannot exceed %i bytes
\n
"
,
cfgoptions
->
optname
,
tmpval
,
cfgoptions
->
numelt
)
;
sprintf
(
(
char
*
)(
cfgoptions
->
strptr
),
"%s"
,
tmpval
);
}
...
...
This diff is collapsed.
Click to expand it.
common/config/config_load_configmodule.c
View file @
28f1035e
...
...
@@ -360,10 +360,12 @@ configmodule_interface_t *load_configmodule(int argc,
/* config module could be initialized again after this call */
void
end_configmodule
(
void
)
{
if
(
cfgptr
->
status
&&
(
cfgptr
->
rtflags
&
CONFIG_SAVERUNCFG
))
{
printf_params
(
"[CONFIG] Runtime params creation status: %i null values, %i errors, %i
successfull
\n
"
,
printf_params
(
"[CONFIG] Runtime params creation status: %i null values, %i errors, %i
empty list or array, %i successfull
\n
"
,
cfgptr
->
status
->
num_err_nullvalue
,
cfgptr
->
status
->
num_err_write
,
cfgptr
->
status
->
emptyla
,
cfgptr
->
status
->
num_write
);
}
if
(
cfgptr
!=
NULL
)
{
if
(
cfgptr
->
end
!=
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
common/config/config_load_configmodule.h
View file @
28f1035e
...
...
@@ -68,6 +68,7 @@ typedef struct configmodule_status {
int
num_paramgroups
;
char
**
paramgroups_names
;
int
num_err_nullvalue
;
int
emptyla
;
union
{
int
num_err_read
;
int
num_err_write
;
...
...
This diff is collapsed.
Click to expand it.
common/config/libconfig/config_libconfig.c
View file @
28f1035e
...
...
@@ -36,7 +36,9 @@
#include <unistd.h>
#include <time.h>
#include <libgen.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "config_libconfig.h"
#include "config_libconfig_private.h"
...
...
@@ -92,21 +94,23 @@ int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_se
int
status
;
int
errors
=
0
;
int
notused
=
0
;
int
emptyla
=
0
;
#define LIBCONFIG_NOTUSED_PARAMS "Not used? (NULL value ptr)"
char
*
secprefix
=
(
prefix
==
NULL
)
?
""
:
prefix
;
for
(
int
i
=
0
;
i
<
numoptions
;
i
++
)
{
if
(
cfgoptions
[
i
].
paramflags
&
PARAMFLAG_CMDLINEONLY
)
{
continue
;
printf_params
(
"[LIBCONFIG] setting %s.%s skipped (command line only)
\n
"
,
(
prefix
==
NULL
)
?
""
:
prefix
,
cfgoptions
[
i
].
optname
);
printf_params
(
"[LIBCONFIG] setting %s.%s skipped (command line only)
\n
"
,
sec
prefix
,
cfgoptions
[
i
].
optname
);
}
status
=
CONFIG_FALSE
;
config_setting_t
*
psetting
;
char
*
spath
=
malloc
(((
prefix
==
NULL
)
?
0
:
strlen
(
prefix
))
+
strlen
(
cfgoptions
[
i
].
optname
)
+
10
);
sprintf
(
spath
,
"%s%s%s"
,
(
prefix
==
NULL
)
?
""
:
prefix
,
(
prefix
==
NULL
)
?
""
:
"."
,
cfgoptions
[
i
].
optname
);
sprintf
(
spath
,
"%s%s%s"
,
sec
prefix
,
(
prefix
==
NULL
)
?
""
:
"."
,
cfgoptions
[
i
].
optname
);
psetting
=
config_lookup
(
&
(
libconfig_privdata
.
runtcfg
),
spath
);
free
(
spath
);
if
(
psetting
!=
NULL
)
{
printf_params
(
"[LIBCONFIG] setting %s.%s already created
\n
"
,
(
prefix
==
NULL
)
?
""
:
prefix
,
cfgoptions
[
i
].
optname
);
printf_params
(
"[LIBCONFIG] setting %s.%s already created
\n
"
,
sec
prefix
,
cfgoptions
[
i
].
optname
);
continue
;
}
switch
(
cfgoptions
[
i
].
type
)
{
...
...
@@ -130,14 +134,21 @@ int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_se
case
TYPE_STRINGLIST
:
psetting
=
config_setting_add
(
asetting
,
cfgoptions
[
i
].
optname
,
CONFIG_TYPE_LIST
);
if
(
psetting
!=
NULL
)
{
if
(
cfgoptions
[
i
].
numelt
<=
0
)
{
emptyla
++
;
printf_params
(
"[LIBCONFIG], no element in list %s
\n
"
,
cfgoptions
[
i
].
optname
);
status
=
CONFIG_TRUE
;
}
for
(
int
j
=
0
;
j
<
cfgoptions
[
i
].
numelt
;
j
++
)
{
config_setting_t
*
elemsetting
=
config_setting_set_string_elem
(
psetting
,
-
1
,
cfgoptions
[
i
].
strptr
[
j
]
);
if
(
elemsetting
==
NULL
)
{
fprintf
(
stderr
,
"[LIBCONFIG] Error: Creating list %s element %i value %s
\n
"
,
cfgoptions
[
i
].
optname
,
j
,
cfgoptions
[
i
].
strptr
[
j
]);
break
;
}
}
fprintf
(
stderr
,
"[LIBCONFIG] Error: Creating list %s element %i value %s
\n
"
,
cfgoptions
[
i
].
optname
,
j
,
cfgoptions
[
i
].
strptr
[
j
]);
break
;
}
else
status
=
CONFIG_TRUE
;
}
}
break
;
case
TYPE_UINT8
:
...
...
@@ -162,16 +173,22 @@ int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_se
case
TYPE_UINTARRAY
:
case
TYPE_INTARRAY
:
psetting
=
config_setting_add
(
asetting
,
cfgoptions
[
i
].
optname
,
CONFIG_TYPE_ARRAY
);
if
(
psetting
!=
NULL
)
if
(
psetting
!=
NULL
)
{
if
(
cfgoptions
[
i
].
numelt
<=
0
)
{
emptyla
++
;
printf_params
(
"[LIBCONFIG], no element in array %s.%s
\n
"
,
secprefix
,
cfgoptions
[
i
].
optname
);
status
=
CONFIG_TRUE
;
}
for
(
int
j
=
0
;
j
<
cfgoptions
[
i
].
numelt
;
j
++
)
{
config_setting_t
*
elemsetting
=
config_setting_set_int_elem
(
psetting
,
-
1
,(
int
)(
cfgoptions
[
i
].
iptr
[
j
])
);
if
(
elemsetting
==
NULL
)
{
fprintf
(
stderr
,
"[LIBCONFIG] Error: Creating array %s
, at index %i value %i
\n
"
,
cfgoptions
[
i
].
optname
,
j
,(
int
)(
cfgoptions
[
i
].
iptr
[
j
]));
fprintf
(
stderr
,
"[LIBCONFIG] Error: Creating array %s
.%s, at index %i value %i
\n
"
,
secprefix
,
cfgoptions
[
i
].
optname
,
j
,(
int
)(
cfgoptions
[
i
].
iptr
[
j
]));
break
;
}
else
status
=
CONFIG_TRUE
;
}
}
break
;
break
;
case
TYPE_DOUBLE
:
psetting
=
config_setting_add
(
asetting
,
cfgoptions
[
i
].
optname
,
CONFIG_TYPE_FLOAT
);
...
...
@@ -180,33 +197,44 @@ int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_se
break
;
case
TYPE_IPV4ADDR
:
psetting
=
config_setting_add
(
asetting
,
cfgoptions
[
i
].
optname
,
CONFIG_TYPE_STRING
);
if
(
psetting
!=
NULL
)
{
char
ipstr
[
INET_ADDRSTRLEN
];
if
(
inet_ntop
(
AF_INET
,
cfgoptions
[
i
].
uptr
,
ipstr
,
INET_ADDRSTRLEN
)
==
NULL
)
{
notused
++
;
sprintf
(
ipstr
,
"undef"
);
}
else
{
status
=
config_setting_set_string
(
psetting
,
ipstr
);
}
}
break
;
case
TYPE_LIST
:
break
;
default:
fprintf
(
stderr
,
"[LIBCONFIG] %s
type %i not supported
\n
"
,
cfgoptions
[
i
].
optname
,
cfgoptions
[
i
].
type
);
fprintf
(
stderr
,
"[LIBCONFIG] %s
.%s type %i not supported
\n
"
,
secprefix
,
cfgoptions
[
i
].
optname
,
cfgoptions
[
i
].
type
);
status
=
CONFIG_FALSE
;
break
;
}
/* switch on param type */
if
(
status
!=
CONFIG_TRUE
)
{
errors
++
;
fprintf
(
stderr
,
"[LIBCONFIG] Error creating setting %i: %s
type %i
\n
"
,
i
,
cfgoptions
[
i
].
optname
,
cfgoptions
[
i
].
type
);
fprintf
(
stderr
,
"[LIBCONFIG] Error creating setting %i: %s
.%s type %i
\n
"
,
i
,
secprefix
,
cfgoptions
[
i
].
optname
,
cfgoptions
[
i
].
type
);
}
}
printf_params
(
"[LIBCONFIG], in group
\"
%s
\"
%i settings
\n
"
,
secprefix
,
numoptions
);
if
(
notused
>
0
)
printf_params
(
"[LIBCONFIG], %i settings with NULL value pointer
\n
"
,
notused
);
if
(
errors
==
0
)
{
printf_params
(
"[LIBCONFIG], %i settings set successfully
\n
"
,
numoptions
);
}
else
{
fprintf
(
stderr
,
"[LIBCONFIG] ...%i/%i settings creation errors
\n
"
,
errors
,
numoptions
);
}
printf_params
(
"[LIBCONFIG], ..... %i settings with NULL value pointer
\n
"
,
notused
);
if
(
errors
>
0
)
fprintf
(
stderr
,
"[LIBCONFIG] .....%i settings creation errors
\n
"
,
errors
);
if
(
emptyla
>
0
)
fprintf
(
stderr
,
"[LIBCONFIG] .....%i empty lists or arrays settings
\n
"
,
emptyla
);
if
(
cfgptr
->
status
)
{
cfgptr
->
status
->
num_err_nullvalue
+=
notused
;
cfgptr
->
status
->
num_err_write
+=
errors
;
cfgptr
->
status
->
num_write
+=
numoptions
;
cfgptr
->
status
->
emptyla
+=
emptyla
;
}
return
errors
;
}
...
...
This diff is collapsed.
Click to expand it.
common/utils/LOG/log.c
View file @
28f1035e
...
...
@@ -302,8 +302,8 @@ void log_getconfig(log_t *g_log)
for
(
int
i
=
MIN_LOG_COMPONENTS
;
i
<
MAX_LOG_PREDEF_COMPONENTS
;
i
++
)
{
if
(
g_log
->
log_component
[
i
].
name
==
NULL
)
{
g_log
->
log_component
[
i
].
name
=
malloc
(
16
);
s
printf
((
char
*
)
g_log
->
log_component
[
i
].
name
,
"comp%i?
"
,
i
);
g_log
->
log_component
[
i
].
name
=
calloc
(
1
,
16
);
s
nprintf
((
char
*
)
g_log
->
log_component
[
i
].
name
,
15
,
"undefcomp%i
"
,
i
);
logparams_logfile
[
i
].
paramflags
=
PARAMFLAG_DONOTREAD
;
logparams_level
[
i
].
paramflags
=
PARAMFLAG_DONOTREAD
;
}
...
...
This diff is collapsed.
Click to expand it.
common/utils/websrv/websrv.c
View file @
28f1035e
...
...
@@ -223,12 +223,9 @@ int websrv_callback_get_softmodemcmd(const struct _u_request * request, struct _
return
U_CALLBACK_CONTINUE
;
}
/* callback processing initial url (<address>/oaisoftmodem)*/
int
websrv_callback_get_softmodeminfo
(
const
struct
_u_request
*
request
,
struct
_u_response
*
response
,
void
*
user_data
)
{
int
websrv_callback_get_softmodemmodules
(
const
struct
_u_request
*
request
,
struct
_u_response
*
response
,
void
*
user_data
)
{
telnetsrv_params_t
*
telnetparams
=
get_telnetsrv_params
();
char
*
cfgfile
=
CONFIG_GETCONFFILE
;
char
*
execfunc
=
get_softmodem_function
(
NULL
);
json_t
*
cmdnames
=
json_array
();
...
...
@@ -236,38 +233,60 @@ int websrv_callback_get_softmodeminfo(const struct _u_request * request, struct
json_t
*
acmd
=
json_string
(
telnetparams
->
CmdParsers
[
i
].
module
);
json_array_append
(
cmdnames
,
acmd
);
ulfius_add_endpoint_by_val
(
websrvparams
.
instance
,
"GET"
,
"oaisoftmodem/module"
,
telnetparams
->
CmdParsers
[
i
].
module
,
0
,
&
websrv_callback_get_softmodemcmd
,
telnetparams
->
CmdParsers
[
i
].
module
);
// client_printf(" module %i = %s:\n",i,telnetparams.CmdParsers[i].module);
// for(j=0; telnetparams.CmdParsers[i].var[j].varvalptr != NULL ; j++) {
// client_printf(" %s [get set] %s <value>\n",
// telnetparams.CmdParsers[i].module, telnetparams.CmdParsers[i].var[j].varname);
// }
// for(j=0; telnetparams.CmdParsers[i].cmd[j].cmdfunc != NULL ; j++) {
// client_printf(" %s %s %s\n",
// telnetparams.CmdParsers[i].module,telnetparams.CmdParsers[i].cmd[j].cmdname,
// telnetparams.CmdParsers[i].cmd[j].helpstr);
// }
}
json_t
*
body
=
json_pack
(
"{s:{s:s,s:s},s:o}"
,
"display_status"
,
"config_file"
,
cfgfile
,
"executable_function"
,
execfunc
,
json_t
*
body
=
json_pack
(
"{s:o}"
,
"menu_cmds"
,
cmdnames
);
if
(
body
==
NULL
)
{
LOG_E
(
UTIL
,
"websrv cannot encode body response
\n
"
);
LOG_E
(
UTIL
,
"websrv cannot encode
modules
body response
\n
"
);
}
else
{
websrv_printjson
(
"body"
,
body
);
websrv_printjson
(
"
modules
body"
,
body
);
}
int
us
=
ulfius_add_header_to_response
(
response
,
"content-type"
,
"application/json"
);
if
(
us
!=
U_OK
){
ulfius_set_string_body_response
(
response
,
501
,
"Internal server error (ulfius_add_header_to_response)"
);
LOG_E
(
UTIL
,
"websrv cannot set response header type ulfius error %d
\n
"
,
us
);
LOG_E
(
UTIL
,
"websrv cannot set
modules
response header type ulfius error %d
\n
"
,
us
);
}
us
=
ulfius_set_json_body_response
(
response
,
200
,
body
);
if
(
us
!=
U_OK
){
ulfius_set_string_body_response
(
response
,
501
,
"Internal server error (ulfius_set_json_body_response)"
);
LOG_E
(
UTIL
,
"websrv cannot set body response ulfius error %d
\n
"
,
us
);
LOG_E
(
UTIL
,
"websrv cannot set modules body response ulfius error %d
\n
"
,
us
);
}
// ulfius_set_string_body_response(response, 200, cfgfile);
return
U_CALLBACK_CONTINUE
;
}
/* callback processing initial url (<address>/oaisoftmodem)*/
int
websrv_callback_get_softmodemstatus
(
const
struct
_u_request
*
request
,
struct
_u_response
*
response
,
void
*
user_data
)
{
char
*
cfgfile
=
CONFIG_GETCONFFILE
;
char
*
execfunc
=
get_softmodem_function
(
NULL
);
char
*
strbool
=
"false"
;
json_t
*
moduleactions
=
json_array
();
json_t
*
body1
=
json_pack
(
"{s:s,s:s,s:s,s:s}"
,
"type"
,
"variable"
,
"name"
,
"config_file"
,
"value"
,
cfgfile
,
"modifiable"
,
strbool
);
if
(
body1
==
NULL
)
{
LOG_E
(
UTIL
,
"websrv cannot encode status body1 response
\n
"
);
}
else
{
websrv_printjson
(
"status body1"
,
body1
);
}
json_t
*
body2
=
json_pack
(
"{s:s,s:s,s:s,s:s}"
,
"type"
,
"variable"
,
"name"
,
"config_file"
,
"value"
,
execfunc
,
"modifiable"
,
strbool
);
if
(
body2
==
NULL
)
{
LOG_E
(
UTIL
,
"websrv cannot encode status body1 response
\n
"
);
}
else
{
websrv_printjson
(
"status body2"
,
body2
);
}
json_array_append
(
moduleactions
,
body1
);
json_array_append
(
moduleactions
,
body2
);
int
us
=
ulfius_add_header_to_response
(
response
,
"content-type"
,
"application/json"
);
if
(
us
!=
U_OK
){
ulfius_set_string_body_response
(
response
,
501
,
"Internal server error (ulfius_add_header_to_response)"
);
LOG_E
(
UTIL
,
"websrv cannot set status response header type ulfius error %d
\n
"
,
us
);
}
us
=
ulfius_set_json_body_response
(
response
,
200
,
moduleactions
);
if
(
us
!=
U_OK
){
ulfius_set_string_body_response
(
response
,
501
,
"Internal server error (ulfius_set_json_body_response)"
);
LOG_E
(
UTIL
,
"websrv cannot set status body response ulfius error %d
\n
"
,
us
);
}
// ulfius_set_string_body_response(response, 200, cfgfile);
return
U_CALLBACK_CONTINUE
;
...
...
@@ -297,7 +316,8 @@ int websrv_callback_get_softmodeminfo(const struct _u_request * request, struct
//1: load the frontend code: files contained in the websrvparams.url directory
ulfius_add_endpoint_by_val
(
websrvparams
.
instance
,
"GET"
,
websrvparams
.
url
,
NULL
,
0
,
&
websrv_callback_get_mainurl
,
NULL
);
//2: build the first page, when receiving the "oaisoftmodem" url
ulfius_add_endpoint_by_val
(
websrvparams
.
instance
,
"GET"
,
"oaisoftmodem"
,
NULL
,
0
,
&
websrv_callback_get_softmodeminfo
,
NULL
);
ulfius_add_endpoint_by_val
(
websrvparams
.
instance
,
"GET"
,
"oaisoftmodem"
,
"status"
,
0
,
&
websrv_callback_get_softmodemstatus
,
NULL
);
ulfius_add_endpoint_by_val
(
websrvparams
.
instance
,
"GET"
,
"oaisoftmodem"
,
"modules"
,
0
,
&
websrv_callback_get_softmodemmodules
,
NULL
);
//ulfius_add_endpoint_by_val(&instance, "GET", "softmodem", "", 0, &callback_get_empty_response, NULL);
// ulfius_add_endpoint_by_val(&instance, "GET", PREFIX, "/multiple/:multiple/:multiple/:not_multiple", 0, &callback_all_test_foo, NULL);
// ulfius_add_endpoint_by_val(&instance, "POST", PREFIX, NULL, 0, &callback_post_test, NULL);
...
...
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