Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
17
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
5ec46205
Commit
5ec46205
authored
4 years ago
by
alexander.lysikov
Browse files
Options
Downloads
Patches
Plain Diff
added command 'order recheck'
parent
4394a051
No related branches found
No related tags found
1 merge request
!247
added command 'order recheck'
Pipeline
#6238
passed with stage
in 13 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/net/srv/dap_chain_net_srv.c
+45
-18
45 additions, 18 deletions
modules/net/srv/dap_chain_net_srv.c
with
45 additions
and
18 deletions
modules/net/srv/dap_chain_net_srv.c
+
45
−
18
View file @
5ec46205
...
...
@@ -110,6 +110,9 @@ int dap_chain_net_srv_init(dap_config_t * a_cfg)
"
\t
Order create
\n
"
"net_srv -net <chain net name> order static [save | delete]
\\\n
"
"
\t
Static nodelist create/delete
\n
"
"net_srv -net <chain net name> order recheck
\\\n
"
"
\t
Check the availability of orders
\n
"
);
s_load_all
();
...
...
@@ -175,6 +178,29 @@ void dap_chain_net_srv_deinit(void)
dap_chain_net_srv_del_all
();
}
static
void
*
get_cdb_func
(
const
char
*
func_name
)
{
void
*
l_ref_func
=
NULL
;
// find func from dynamic library
#if defined (DAP_OS_LINUX) && !defined (__ANDROID__)
const
char
*
s_default_path_modules
=
"var/modules"
;
const
char
*
l_cdb_so_name
=
"libcellframe-node-cdb.so"
;
char
*
l_lib_path
=
dap_strdup_printf
(
"%s/%s/%s"
,
g_sys_dir_path
,
s_default_path_modules
,
l_cdb_so_name
);
void
*
l_cdb_handle
=
NULL
;
l_cdb_handle
=
dlopen
(
l_lib_path
,
RTLD_NOW
);
DAP_DELETE
(
l_lib_path
);
if
(
!
l_cdb_handle
)
{
log_it
(
L_ERROR
,
"Can't load %s module: %s"
,
l_cdb_so_name
,
dlerror
());
}
else
{
l_ref_func
=
dlsym
(
l_cdb_handle
,
func_name
);
dlclose
(
l_cdb_handle
);
}
#endif
return
l_ref_func
;
}
/**
* @brief s_cli_net_srv
* @param argc
...
...
@@ -526,6 +552,14 @@ static int s_cli_net_srv( int argc, char **argv, void *arg_func, char **a_str_re
dap_string_append_printf
(
l_string_ret
,
"Missed some required params
\n
"
);
ret
=-
5
;
}
}
else
if
(
dap_strcmp
(
l_order_str
,
"recheck"
)
==
0
){
//int dap_chain_net_srv_vpn_cdb_server_list_check_orders(dap_chain_net_t *a_net);
int
(
*
dap_chain_net_srv_vpn_cdb_server_list_check_orders
)(
dap_chain_net_t
*
a_net
)
=
NULL
;
*
(
void
**
)
(
&
dap_chain_net_srv_vpn_cdb_server_list_check_orders
)
=
get_cdb_func
(
"dap_chain_net_srv_vpn_cdb_server_list_check_orders"
);
int
l_init_res
=
dap_chain_net_srv_vpn_cdb_server_list_check_orders
?
(
*
dap_chain_net_srv_vpn_cdb_server_list_check_orders
)(
l_net
)
:
-
5
;
//int l_init_res = dap_chain_net_srv_vpn_cdb_server_list_check_orders(l_net);
ret
=
-
10
;
}
else
if
(
dap_strcmp
(
l_order_str
,
"static"
)
==
0
){
// find the subcommand directly after the 'order' command
int
l_subcmd_save
=
dap_chain_node_cli_find_option_val
(
argv
,
l_order_arg_pos
+
1
,
l_order_arg_pos
+
2
,
"save"
,
NULL
);
...
...
@@ -536,44 +570,37 @@ static int s_cli_net_srv( int argc, char **argv, void *arg_func, char **a_str_re
int
(
*
dap_chain_net_srv_vpn_cdb_server_list_static_delete
)(
dap_chain_net_t
*
a_net
)
=
NULL
;
// find func from dinamic library
if
(
l_subcmd_save
||
l_subcmd_del
)
{
#if defined (DAP_OS_LINUX) && !defined (__ANDROID__)
const
char
*
s_default_path_modules
=
"var/modules"
;
const
char
*
l_cdb_so_name
=
"libcellframe-node-cdb.so"
;
char
*
l_lib_path
=
dap_strdup_printf
(
"%s/%s/%s"
,
g_sys_dir_path
,
s_default_path_modules
,
l_cdb_so_name
);
void
*
l_cdb_handle
=
NULL
;
l_cdb_handle
=
dlopen
(
l_lib_path
,
RTLD_NOW
);
DAP_DELETE
(
l_lib_path
);
if
(
!
l_cdb_handle
)
{
log_it
(
L_ERROR
,
"Can't load %s module: %s"
,
l_cdb_so_name
,
dlerror
());
}
else
{
*
(
void
**
)
(
&
dap_chain_net_srv_vpn_cdb_server_list_static_create
)
=
dlsym
(
l_cdb_handle
,
"dap_chain_net_srv_vpn_cdb_server_list_static_create"
);
*
(
void
**
)
(
&
dap_chain_net_srv_vpn_cdb_server_list_static_delete
)
=
dlsym
(
l_cdb_handle
,
"dap_chain_net_srv_vpn_cdb_server_list_static_delete"
);
}
#endif
*
(
void
**
)
(
&
dap_chain_net_srv_vpn_cdb_server_list_static_create
)
=
get_cdb_func
(
"dap_chain_net_srv_vpn_cdb_server_list_static_create"
);
*
(
void
**
)
(
&
dap_chain_net_srv_vpn_cdb_server_list_static_delete
)
=
get_cdb_func
(
"dap_chain_net_srv_vpn_cdb_server_list_static_delete"
);
}
if
(
l_subcmd_save
)
{
int
l_init_res
=
dap_chain_net_srv_vpn_cdb_server_list_static_create
?
(
*
dap_chain_net_srv_vpn_cdb_server_list_static_create
)(
l_net
)
:
-
5
;
//int l_init_res = dap_chain_net_srv_vpn_cdb_server_list_static_create(l_net);
if
(
l_init_res
>=
0
)
if
(
l_init_res
>=
0
)
{
dap_string_append_printf
(
l_string_ret
,
"Static node list saved, %d orders in list
\n
"
,
l_init_res
);
else
ret
=
0
;
}
else
{
dap_string_append_printf
(
l_string_ret
,
"Static node list not saved, error code %d
\n
"
,
l_init_res
);
ret
=
-
11
;
}
}
else
if
(
l_subcmd_del
)
{
int
l_init_res
=
dap_chain_net_srv_vpn_cdb_server_list_static_delete
?
(
*
dap_chain_net_srv_vpn_cdb_server_list_static_delete
)(
l_net
)
:
-
5
;
//int l_init_res = dap_chain_net_srv_vpn_cdb_server_list_static_delete(l_net);
if
(
!
l_init_res
){
dap_string_append_printf
(
l_string_ret
,
"Static node list deleted
\n
"
);
ret
=
0
;
}
else
if
(
l_init_res
>
0
){
dap_string_append_printf
(
l_string_ret
,
"Static node list already deleted
\n
"
);
ret
=
-
12
;
}
else
dap_string_append_printf
(
l_string_ret
,
"Static node list not deleted, error code %d
\n
"
,
l_init_res
);
}
else
{
dap_string_append
(
l_string_ret
,
"not found subcommand 'save' or 'delete'
\n
"
);
ret
=
-
1
0
;
ret
=
-
1
3
;
}
}
else
{
dap_string_append_printf
(
l_string_ret
,
"Unknown subcommand '%s'
\n
"
,
l_order_str
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment