Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-chain-net-srv-vpn
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap-chain-net-srv-vpn
Commits
9a9df935
Commit
9a9df935
authored
5 years ago
by
alexander.lysikov
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into 'feature-2557'
Master See merge request
!7
parents
847a971d
83de96c8
No related branches found
No related tags found
2 merge requests
!7
Master
,
!6
fixed initialize vpn service
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dap_chain_net_srv_vpn.c
+28
-16
28 additions, 16 deletions
dap_chain_net_srv_vpn.c
with
28 additions
and
16 deletions
dap_chain_net_srv_vpn.c
+
28
−
16
View file @
9a9df935
...
@@ -621,17 +621,24 @@ static void s_ch_packet_out(dap_stream_ch_t* a_ch, void* a_arg)
...
@@ -621,17 +621,24 @@ static void s_ch_packet_out(dap_stream_ch_t* a_ch, void* a_arg)
if
(
!
l_usage
){
if
(
!
l_usage
){
log_it
(
L_NOTICE
,
"No active usage in list, possible disconnected. Send nothin on this channel"
);
log_it
(
L_NOTICE
,
"No active usage in list, possible disconnected. Send nothin on this channel"
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
return
;
return
;
}
}
if
(
!
l_usage
->
is_active
){
if
(
!
l_usage
->
is_active
){
log_it
(
L_INFO
,
"Usage inactivation: switch off packet output channel"
);
log_it
(
L_INFO
,
"Usage inactivation: switch off packet output channel"
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
if
(
l_usage
->
clients
)
dap_stream_ch_pkt_write
(
l_usage
->
clients
->
ch
,
DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_NOTIFY_STOPPED
,
NULL
,
0
);
return
;
return
;
}
}
if
(
!
l_usage
->
receipt
){
if
(
!
l_usage
->
receipt
){
log_it
(
L_WARNING
,
"No active receipt, switching off"
);
log_it
(
L_WARNING
,
"No active receipt, switching off"
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
if
(
l_usage
->
clients
)
dap_stream_ch_pkt_write
(
l_usage
->
clients
->
ch
,
DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_NOTIFY_STOPPED
,
NULL
,
0
);
return
;
return
;
}
}
...
@@ -715,20 +722,21 @@ static void s_update_limits(dap_stream_ch_t * a_ch ,
...
@@ -715,20 +722,21 @@ static void s_update_limits(dap_stream_ch_t * a_ch ,
a_usage
->
receipt_next
=
NULL
;
a_usage
->
receipt_next
=
NULL
;
l_issue_new_receipt
=
true
;
l_issue_new_receipt
=
true
;
if
(
a_usage
->
receipt
){
// If there is next receipt add the time and request the next receipt
if
(
a_usage
->
receipt
){
// If there is next receipt add the time and request the next receipt
a_srv_session
->
limits_units_type
.
uint32
=
a_usage
->
receipt
->
receipt
.
units_type
.
uint32
;
a_srv_session
->
limits_units_type
.
uint32
=
a_usage
->
receipt
->
receipt
_info
.
units_type
.
uint32
;
switch
(
a_usage
->
receipt
->
receipt
.
units_type
.
enm
){
switch
(
a_usage
->
receipt
->
receipt
_info
.
units_type
.
enm
){
case
SERV_UNIT_DAY
:{
case
SERV_UNIT_DAY
:{
a_srv_session
->
limits_ts
=
time
(
NULL
)
+
(
time_t
)
a_usage
->
receipt
->
receipt
.
units
*
24
*
3600
;
a_srv_session
->
limits_ts
=
time
(
NULL
)
+
(
time_t
)
a_usage
->
receipt
->
receipt
_info
.
units
*
24
*
3600
;
log_it
(
L_INFO
,
"%llu days more for VPN usage"
,
a_usage
->
receipt
->
receipt
.
units
);
log_it
(
L_INFO
,
"%llu days more for VPN usage"
,
a_usage
->
receipt
->
receipt
_info
.
units
);
}
break
;
}
break
;
case
SERV_UNIT_SEC
:{
case
SERV_UNIT_SEC
:{
a_srv_session
->
limits_ts
=
time
(
NULL
)
+
(
time_t
)
a_usage
->
receipt
->
receipt
.
units
;
a_srv_session
->
limits_ts
=
time
(
NULL
)
+
(
time_t
)
a_usage
->
receipt
->
receipt
_info
.
units
;
log_it
(
L_INFO
,
"%llu seconds more for VPN usage"
,
a_usage
->
receipt
->
receipt
.
units
);
log_it
(
L_INFO
,
"%llu seconds more for VPN usage"
,
a_usage
->
receipt
->
receipt
_info
.
units
);
}
break
;
}
break
;
default:
{
default:
{
log_it
(
L_WARNING
,
"VPN doesnt accept serv unit type 0x%08X for limits_ts"
,
a_usage
->
receipt
->
receipt
.
units_type
.
uint32
);
log_it
(
L_WARNING
,
"VPN doesnt accept serv unit type 0x%08X for limits_ts"
,
a_usage
->
receipt
->
receipt
_info
.
units_type
.
uint32
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
dap_stream_ch_pkt_write
(
a_usage
->
clients
->
ch
,
DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_NOTIFY_STOPPED
,
NULL
,
0
);
}
}
}
}
...
@@ -737,6 +745,7 @@ static void s_update_limits(dap_stream_ch_t * a_ch ,
...
@@ -737,6 +745,7 @@ static void s_update_limits(dap_stream_ch_t * a_ch ,
log_it
(
L_NOTICE
,
"No activate receipt in usage, switch off write callback for channel"
);
log_it
(
L_NOTICE
,
"No activate receipt in usage, switch off write callback for channel"
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
dap_stream_ch_pkt_write
(
a_usage
->
clients
->
ch
,
DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_NOTIFY_STOPPED
,
NULL
,
0
);
}
}
}
}
}
else
if
(
a_srv_session
->
limits_bytes
){
}
else
if
(
a_srv_session
->
limits_bytes
){
...
@@ -750,24 +759,25 @@ static void s_update_limits(dap_stream_ch_t * a_ch ,
...
@@ -750,24 +759,25 @@ static void s_update_limits(dap_stream_ch_t * a_ch ,
a_usage
->
receipt_next
=
NULL
;
a_usage
->
receipt_next
=
NULL
;
l_issue_new_receipt
=
true
;
l_issue_new_receipt
=
true
;
if
(
a_usage
->
receipt
){
// If there is next receipt add the time and request the next receipt
if
(
a_usage
->
receipt
){
// If there is next receipt add the time and request the next receipt
a_srv_session
->
limits_units_type
.
uint32
=
a_usage
->
receipt
->
receipt
.
units_type
.
uint32
;
a_srv_session
->
limits_units_type
.
uint32
=
a_usage
->
receipt
->
receipt
_info
.
units_type
.
uint32
;
switch
(
a_usage
->
receipt
->
receipt
.
units_type
.
enm
){
switch
(
a_usage
->
receipt
->
receipt
_info
.
units_type
.
enm
){
case
SERV_UNIT_B
:{
case
SERV_UNIT_B
:{
a_srv_session
->
limits_bytes
+=
(
uint128_t
)
a_usage
->
receipt
->
receipt
.
units
;
a_srv_session
->
limits_bytes
+=
(
uint128_t
)
a_usage
->
receipt
->
receipt
_info
.
units
;
log_it
(
L_INFO
,
"%llu bytes more for VPN usage"
,
a_usage
->
receipt
->
receipt
.
units
);
log_it
(
L_INFO
,
"%llu bytes more for VPN usage"
,
a_usage
->
receipt
->
receipt
_info
.
units
);
}
break
;
}
break
;
case
SERV_UNIT_KB
:{
case
SERV_UNIT_KB
:{
a_srv_session
->
limits_bytes
+=
1000ull
*
(
(
uint128_t
)
a_usage
->
receipt
->
receipt
.
units
);
a_srv_session
->
limits_bytes
+=
1000ull
*
(
(
uint128_t
)
a_usage
->
receipt
->
receipt
_info
.
units
);
log_it
(
L_INFO
,
"%llu bytes more for VPN usage"
,
a_usage
->
receipt
->
receipt
.
units
);
log_it
(
L_INFO
,
"%llu bytes more for VPN usage"
,
a_usage
->
receipt
->
receipt
_info
.
units
);
}
break
;
}
break
;
case
SERV_UNIT_MB
:{
case
SERV_UNIT_MB
:{
a_srv_session
->
limits_bytes
+=
1000000ull
*
(
(
uint128_t
)
a_usage
->
receipt
->
receipt
.
units
);
a_srv_session
->
limits_bytes
+=
1000000ull
*
(
(
uint128_t
)
a_usage
->
receipt
->
receipt
_info
.
units
);
log_it
(
L_INFO
,
"%llu bytes more for VPN usage"
,
a_usage
->
receipt
->
receipt
.
units
);
log_it
(
L_INFO
,
"%llu bytes more for VPN usage"
,
a_usage
->
receipt
->
receipt
_info
.
units
);
}
break
;
}
break
;
default:
{
default:
{
log_it
(
L_WARNING
,
"VPN doesnt accept serv unit type 0x%08X for limits_bytes"
,
a_usage
->
receipt
->
receipt
.
units_type
.
uint32
);
log_it
(
L_WARNING
,
"VPN doesnt accept serv unit type 0x%08X for limits_bytes"
,
a_usage
->
receipt
->
receipt
_info
.
units_type
.
uint32
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
dap_stream_ch_pkt_write
(
a_usage
->
clients
->
ch
,
DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_NOTIFY_STOPPED
,
NULL
,
0
);
}
}
}
}
...
@@ -776,6 +786,8 @@ static void s_update_limits(dap_stream_ch_t * a_ch ,
...
@@ -776,6 +786,8 @@ static void s_update_limits(dap_stream_ch_t * a_ch ,
log_it
(
L_NOTICE
,
"No activate receipt in usage, switch off write callback for channel"
);
log_it
(
L_NOTICE
,
"No activate receipt in usage, switch off write callback for channel"
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_write
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
dap_stream_ch_set_ready_to_read
(
a_ch
,
false
);
dap_stream_ch_pkt_write
(
a_usage
->
clients
->
ch
,
DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_NOTIFY_STOPPED
,
NULL
,
0
);
}
}
}
}
...
...
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