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
07735d51
Commit
07735d51
authored
4 years ago
by
Roman Khlopkov
🔜
Browse files
Options
Downloads
Patches
Plain Diff
[+] Hostinfo to DNS reply
parent
019b1276
No related branches found
Branches containing commit
No related tags found
5 merge requests
!251
Master
,
!250
Master
,
!162
Bugs-4158
,
!159
Bugs-4158
,
!156
bugs-4158
Pipeline
#4035
passed with stage
Stage: analyze
in 19 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/net/dap_chain_net.c
+6
-4
6 additions, 4 deletions
modules/net/dap_chain_net.c
modules/net/dap_dns_server.c
+23
-17
23 additions, 17 deletions
modules/net/dap_dns_server.c
modules/net/include/dap_dns_server.h
+1
-1
1 addition, 1 deletion
modules/net/include/dap_dns_server.h
with
30 additions
and
22 deletions
modules/net/dap_chain_net.c
+
6
−
4
View file @
07735d51
...
@@ -512,11 +512,13 @@ static int s_net_states_proc(dap_chain_net_t * l_net)
...
@@ -512,11 +512,13 @@ static int s_net_states_proc(dap_chain_net_t * l_net)
log_it
(
L_DEBUG
,
"%s.state: NET_STATE_LINKS_CONNECTING"
,
l_net
->
pub
.
name
);
log_it
(
L_DEBUG
,
"%s.state: NET_STATE_LINKS_CONNECTING"
,
l_net
->
pub
.
name
);
log_it
(
L_DEBUG
,
"Establishing connection with "
NODE_ADDR_FP_STR
,
log_it
(
L_DEBUG
,
"Establishing connection with "
NODE_ADDR_FP_STR
,
NODE_ADDR_FP_ARGS_S
(
l_pvt_net
->
links_addrs
[
l_links_count
])
);
NODE_ADDR_FP_ARGS_S
(
l_pvt_net
->
links_addrs
[
l_links_count
])
);
dap_chain_node_info_t
*
l_link_node_info
=
dap_chain_node_info_read
(
l_net
,
&
l_pvt_net
->
links_addrs
[
l_links_count
]);
dap_chain_node_info_t
l_link_node_info
;
if
(
l_link_node_info
)
{
int
res
=
dap_dns_client_get_addr
(
inet_addr
(
"192.168.10.10"
),
l_net
->
pub
.
name
,
&
l_link_node_info
);
dap_chain_node_client_t
*
l_node_client
=
dap_chain_node_client_connect
(
l_link_node_info
);
// = dap_chain_node_info_read(l_net, &l_pvt_net->links_addrs[l_links_count]);
if
(
res
)
{
dap_chain_node_client_t
*
l_node_client
=
dap_chain_node_client_connect
(
&
l_link_node_info
);
if
(
!
l_node_client
)
{
if
(
!
l_node_client
)
{
DAP_DELETE
(
l_link_node_info
);
//
DAP_DELETE(l_link_node_info);
ret
=
-
1
;
ret
=
-
1
;
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/net/dap_dns_server.c
+
23
−
17
View file @
07735d51
...
@@ -102,13 +102,16 @@ void dap_dns_buf_put_uint64(dap_dns_buf_t *buf, uint64_t val) {
...
@@ -102,13 +102,16 @@ void dap_dns_buf_put_uint64(dap_dns_buf_t *buf, uint64_t val) {
dap_chain_node_info_t
*
dap_dns_resolve_hostname
(
char
*
str
)
{
dap_chain_node_info_t
*
dap_dns_resolve_hostname
(
char
*
str
)
{
log_it
(
L_DEBUG
,
"DNS parser retrieve hostname %s"
,
str
);
log_it
(
L_DEBUG
,
"DNS parser retrieve hostname %s"
,
str
);
uint16_t
l_nets_count
;
dap_chain_net_t
*
l_net
=
dap_chain_net_by_name
(
str
);
dap_chain_net_t
**
l_nets
=
dap_chain_net_list
(
&
l_nets_count
);
if
(
l_net
==
NULL
)
{
if
(
!
l_nets_count
)
{
uint16_t
l_nets_count
;
log_it
(
L_WARNING
,
"No chain network present"
);
dap_chain_net_t
**
l_nets
=
dap_chain_net_list
(
&
l_nets_count
);
return
0
;
if
(
!
l_nets_count
)
{
log_it
(
L_WARNING
,
"No chain network present"
);
return
0
;
}
l_net
=
l_nets
[
rand
()
%
l_nets_count
];
}
}
dap_chain_net_t
*
l_net
=
l_nets
[
rand
()
%
l_nets_count
];
// get nodes list from global_db
// get nodes list from global_db
dap_global_db_obj_t
*
l_objs
=
NULL
;
dap_global_db_obj_t
*
l_objs
=
NULL
;
size_t
l_nodes_count
=
0
;
size_t
l_nodes_count
=
0
;
...
@@ -368,7 +371,7 @@ void dap_dns_server_stop() {
...
@@ -368,7 +371,7 @@ void dap_dns_server_stop() {
DAP_DELETE
(
s_dns_server
);
DAP_DELETE
(
s_dns_server
);
}
}
int
s
_dns_
get_ip
(
uint32_t
a_addr
,
char
*
a_name
,
uint32
_t
*
a_result
)
int
dap
_dns_
client_get_addr
(
uint32_t
a_addr
,
char
*
a_name
,
dap_chain_node_info
_t
*
a_result
)
{
{
const
size_t
l_buf_size
=
1024
;
const
size_t
l_buf_size
=
1024
;
uint8_t
l_buf
[
l_buf_size
];
uint8_t
l_buf
[
l_buf_size
];
...
@@ -463,17 +466,20 @@ int s_dns_get_ip(uint32_t a_addr, char *a_name, uint32_t *a_result)
...
@@ -463,17 +466,20 @@ int s_dns_get_ip(uint32_t a_addr, char *a_name, uint32_t *a_result)
}
}
l_cur
=
l_buf
+
l_addr_point
;
l_cur
=
l_buf
+
l_addr_point
;
if
(
a_result
)
{
if
(
a_result
)
{
*
a_result
=
ntohl
(
*
(
uint32_t
*
)
l_cur
);
a_result
->
hdr
.
ext_addr_v4
.
s_addr
=
ntohl
(
*
(
uint32_t
*
)
l_cur
);
}
l_cur
=
l_buf
+
5
*
sizeof
(
uint16_t
);
int
l_additions_count
=
ntohs
(
*
(
uint16_t
*
)
l_cur
);
if
(
l_additions_count
==
1
)
{
l_cur
=
l_buf
+
l_addr_point
+
DNS_ANSWER_SIZE
;
if
(
a_result
)
{
a_result
->
hdr
.
ext_port
=
ntohs
(
*
(
uint16_t
*
)
l_cur
);
}
l_cur
+=
sizeof
(
uint16_t
);
if
(
a_result
)
{
a_result
->
hdr
.
address
.
uint64
=
be64toh
(
*
(
uint64_t
*
)
l_cur
);
}
}
}
closesocket
(
l_sock
);
closesocket
(
l_sock
);
return
0
;
return
0
;
}
}
uint32_t
dap_dns_client_get_addr
(
uint32_t
a_dns_addr
)
{
uint32_t
l_res
;
if
(
s_dns_get_ip
(
a_dns_addr
,
"kelvin.sync"
,
&
l_res
))
{
return
0
;
}
return
l_res
;
}
This diff is collapsed.
Click to expand it.
modules/net/include/dap_dns_server.h
+
1
−
1
View file @
07735d51
...
@@ -124,4 +124,4 @@ void dap_dns_server_start();
...
@@ -124,4 +124,4 @@ void dap_dns_server_start();
void
dap_dns_server_stop
();
void
dap_dns_server_stop
();
int
dap_dns_zone_register
(
char
*
zone
,
dap_dns_zone_callback_t
callback
);
int
dap_dns_zone_register
(
char
*
zone
,
dap_dns_zone_callback_t
callback
);
int
dap_dns_zone_unregister
(
char
*
zone
);
int
dap_dns_zone_unregister
(
char
*
zone
);
u
int
32_t
dap_dns_client_get_addr
(
uint32_t
a_
dns_
addr
);
int
dap_dns_client_get_addr
(
uint32_t
a_addr
,
char
*
a_name
,
dap_chain_node_info_t
*
a_result
);
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