rules
This commit is contained in:
parent
79eded8c96
commit
b3a51adc95
@ -400,29 +400,28 @@ handle_cast({policy_request, Sock, {ClientIp, ClientPort}, #sdl_policy_request{c
|
|||||||
maybe
|
maybe
|
||||||
{ok, #endpoint{client_id = ClientId, session_token = ST}} ?= maps:find(Mac, Endpoints),
|
{ok, #endpoint{client_id = ClientId, session_token = ST}} ?= maps:find(Mac, Endpoints),
|
||||||
|
|
||||||
|
%% todo
|
||||||
Bin = <<1, 80:16, 2, 9090:16>>,
|
Bin = <<1, 80:16, 2, 9090:16>>,
|
||||||
RulesBin = iolist_to_binary(lists:map(fun(_Id) -> Bin end, lists:seq(1, 1000))),
|
RulesBin = iolist_to_binary(lists:map(fun(_Id) -> Bin end, lists:seq(1, 1000))),
|
||||||
case byte_size(RulesBin) > 1200 of
|
case byte_size(RulesBin) > 1200 of
|
||||||
true ->
|
true ->
|
||||||
%% 分组
|
%% 分组
|
||||||
Groups = chunk_rules(RulesBin, 1200),
|
Groups = chunk_rules(RulesBin, 1200),
|
||||||
logger:debug("[sdlan_network] policy_response, groups: ~p", [Groups]),
|
|
||||||
TotalNum = length(Groups),
|
TotalNum = length(Groups),
|
||||||
Fragments = lists:zip(lists:seq(0, TotalNum - 1), Groups),
|
Fragments = lists:zip(lists:seq(0, TotalNum - 1), Groups),
|
||||||
lists:foreach(fun({Idx, ChunkRulesBin}) ->
|
[begin
|
||||||
FragmentPolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response {
|
FragmentPolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response {
|
||||||
network_id = NetworkId,
|
network_id = NetworkId,
|
||||||
src_identity_id = SrcIdentityId,
|
src_identity_id = SrcIdentityId,
|
||||||
dst_identity_id = DstIdentityId,
|
dst_identity_id = DstIdentityId,
|
||||||
version = Version,
|
version = Version,
|
||||||
total_num = TotalNum,
|
total_num = TotalNum,
|
||||||
index = Idx,
|
index = Idx,
|
||||||
rules = ChunkRulesBin
|
rules = ChunkRulesBin
|
||||||
}),
|
}),
|
||||||
FragmentPolicyResponsePkt = <<?PACKET_POLICY_RESPONSE, FragmentPolicyResponse/binary>>,
|
FragmentPolicyResponsePkt = <<?PACKET_POLICY_RESPONSE, FragmentPolicyResponse/binary>>,
|
||||||
logger:debug("[sdlan_network] will send policy response: ~p", [FragmentPolicyResponsePkt]),
|
gen_udp:send(Sock, ClientIp, ClientPort, FragmentPolicyResponsePkt)
|
||||||
gen_udp:send(Sock, ClientIp, ClientPort, FragmentPolicyResponsePkt)
|
end || {Idx, ChunkRulesBin} <- Fragments];
|
||||||
end, Fragments);
|
|
||||||
false ->
|
false ->
|
||||||
%% 小于1200字节不分组
|
%% 小于1200字节不分组
|
||||||
PolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response {
|
PolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user