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
16
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
5cfa3463
Commit
5cfa3463
authored
11 months ago
by
Roman Khlopkov
🔜
Browse files
Options
Downloads
Patches
Plain Diff
[*] Net accounting protocol changes
parent
31c9ca8d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#37321
failed with stage
in 9 minutes and 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/channel/chain-net/dap_stream_ch_chain_net.c
+26
-14
26 additions, 14 deletions
modules/channel/chain-net/dap_stream_ch_chain_net.c
modules/channel/chain-net/include/dap_stream_ch_chain_net_pkt.h
+8
-7
8 additions, 7 deletions
...s/channel/chain-net/include/dap_stream_ch_chain_net_pkt.h
with
34 additions
and
21 deletions
modules/channel/chain-net/dap_stream_ch_chain_net.c
+
26
−
14
View file @
5cfa3463
...
...
@@ -132,11 +132,6 @@ void s_stream_ch_packet_in(dap_stream_ch_t *a_ch, void* a_arg)
l_ch_pkt
->
hdr
.
data_size
,
l_ch_chain_net_pkt
->
hdr
.
data_size
+
sizeof
(
dap_stream_ch_chain_net_pkt_t
));
return
;
}
if
(
l_ch_pkt
->
hdr
.
type
==
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ERROR
)
{
char
*
l_err_str
=
(
char
*
)
l_ch_chain_net_pkt
->
data
;
log_it
(
L_WARNING
,
"Stream channel N for network communication got error on other side: %s"
,
l_err_str
);
return
;
}
dap_chain_net_t
*
l_net
=
dap_chain_net_by_id
(
l_ch_chain_net_pkt
->
hdr
.
net_id
);
if
(
!
l_net
)
{
log_it
(
L_ERROR
,
"Invalid net id in packet"
);
...
...
@@ -145,6 +140,15 @@ void s_stream_ch_packet_in(dap_stream_ch_t *a_ch, void* a_arg)
l_ch_chain_net_pkt
->
hdr
.
net_id
,
l_err_str
,
sizeof
(
l_err_str
));
return
;
}
if
(
l_ch_pkt
->
hdr
.
type
==
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ERROR
)
{
char
*
l_err_str
=
(
char
*
)
l_ch_chain_net_pkt
->
data
;
log_it
(
L_WARNING
,
"Stream channel N for network communication got error on other side: %s"
,
l_err_str
);
if
(
a_ch
->
stream
->
authorized
)
{
assert
(
!
dap_stream_node_addr_is_blank
(
&
a_ch
->
stream
->
node
));
dap_link_manager_accounting_link_in_net
(
l_net
->
pub
.
id
.
uint64
,
&
a_ch
->
stream
->
node
,
false
);
}
return
;
}
uint16_t
l_acl_idx
=
dap_chain_net_get_acl_idx
(
l_net
);
uint8_t
l_acl
=
a_ch
->
stream
->
session
->
acl
?
a_ch
->
stream
->
session
->
acl
[
l_acl_idx
]
:
1
;
if
(
!
l_acl
)
{
...
...
@@ -155,23 +159,31 @@ void s_stream_ch_packet_in(dap_stream_ch_t *a_ch, void* a_arg)
l_ch_chain_net_pkt
->
hdr
.
net_id
,
l_err_str
,
sizeof
(
l_err_str
));
return
;
}
/*if (dap_chain_net_get_state(l_net) == NET_STATE_OFFLINE) {
s_stream_ch_write_error_unsafe(a_ch, l_chain_pkt->hdr.net_id.uint64,
l_chain_pkt->hdr.chain_id.uint64, l_chain_pkt->hdr.cell_id.uint64,
"ERROR_NET_IS_OFFLINE");
a_ch->stream->esocket->flags |= DAP_SOCK_SIGNAL_CLOSE;
if
(
dap_chain_net_get_state
(
l_net
)
==
NET_STATE_OFFLINE
)
{
char
l_err_str
[]
=
"ERROR_NET_IS_OFFLINE"
;
dap_stream_ch_chain_net_pkt_write
(
a_ch
,
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ERROR
,
l_ch_chain_net_pkt
->
hdr
.
net_id
,
l_err_str
,
sizeof
(
l_err_str
));
return
;
}
*/
}
switch
(
l_ch_pkt
->
hdr
.
type
)
{
case
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ANNOUNCE
:
case
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ANNOUNCE_ACK
:
if
(
!
a_ch
->
stream
->
authorized
)
{
log_it
(
L_WARNING
,
"Trying to announce net from not authorized stream"
);
break
;
char
l_err_str
[]
=
"ERROR_STREAM_NOT_AUTHORIZED"
;
dap_stream_ch_chain_net_pkt_write
(
a_ch
,
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ERROR
,
l_ch_chain_net_pkt
->
hdr
.
net_id
,
l_err_str
,
sizeof
(
l_err_str
));
return
;
}
assert
(
!
dap_stream_node_addr_is_blank
(
&
a_ch
->
stream
->
node
));
dap_accounting_downlink_in_net
(
l_net
->
pub
.
id
.
uint64
,
&
a_ch
->
stream
->
node
);
dap_link_manager_accounting_link_in_net
(
l_net
->
pub
.
id
.
uint64
,
&
a_ch
->
stream
->
node
,
true
);
if
(
l_ch_pkt
->
hdr
.
type
==
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ANNOUNCE
)
dap_stream_ch_chain_net_pkt_write
(
a_ch
,
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ANNOUNCE_ACK
,
l_ch_chain_net_pkt
->
hdr
.
net_id
,
NULL
,
0
);
break
;
// received ping request - > send pong request
// received ping request - > send pong request
case
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_PING
:
//log_it(L_INFO, "Get CHAIN_CH_NET_PKT_TYPE_PING");
dap_stream_ch_chain_net_pkt_write
(
a_ch
,
DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_PONG
,
...
...
This diff is collapsed.
Click to expand it.
modules/channel/chain-net/include/dap_stream_ch_chain_net_pkt.h
+
8
−
7
View file @
5cfa3463
...
...
@@ -32,17 +32,18 @@
#define DAP_STREAM_CH_CHAIN_NET_PKT_VERSION 1
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_TEST 0x01
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_TEST
0x01
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_PING 0x02
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_PONG 0x03
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_PING
0x02
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_PONG
0x03
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_NODE_VALIDATOR_READY_REQUEST 0x30
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_NODE_VALIDATOR_READY 0x31
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_NODE_VALIDATOR_READY_REQUEST
0x30
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_NODE_VALIDATOR_READY
0x31
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ANNOUNCE 0x44
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ANNOUNCE 0x44
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ANNOUNCE_ACK 0x45
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ERROR 0xff
#define DAP_STREAM_CH_CHAIN_NET_PKT_TYPE_ERROR
0xff
typedef
struct
stream_ch_chain_net_pkt_hdr
{
uint8_t
version
;
...
...
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