diff --git a/apps/sdlan/src/sdlan_network.erl b/apps/sdlan/src/sdlan_network.erl index ed63a3e..fbe628a 100644 --- a/apps/sdlan/src/sdlan_network.erl +++ b/apps/sdlan/src/sdlan_network.erl @@ -400,29 +400,28 @@ handle_cast({policy_request, Sock, {ClientIp, ClientPort}, #sdl_policy_request{c maybe {ok, #endpoint{client_id = ClientId, session_token = ST}} ?= maps:find(Mac, Endpoints), + %% todo Bin = <<1, 80:16, 2, 9090:16>>, RulesBin = iolist_to_binary(lists:map(fun(_Id) -> Bin end, lists:seq(1, 1000))), case byte_size(RulesBin) > 1200 of true -> %% 分组 Groups = chunk_rules(RulesBin, 1200), - logger:debug("[sdlan_network] policy_response, groups: ~p", [Groups]), TotalNum = length(Groups), Fragments = lists:zip(lists:seq(0, TotalNum - 1), Groups), - lists:foreach(fun({Idx, ChunkRulesBin}) -> - FragmentPolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response { - network_id = NetworkId, - src_identity_id = SrcIdentityId, - dst_identity_id = DstIdentityId, - version = Version, - total_num = TotalNum, - index = Idx, - rules = ChunkRulesBin - }), - FragmentPolicyResponsePkt = <>, - logger:debug("[sdlan_network] will send policy response: ~p", [FragmentPolicyResponsePkt]), - gen_udp:send(Sock, ClientIp, ClientPort, FragmentPolicyResponsePkt) - end, Fragments); + [begin + FragmentPolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response { + network_id = NetworkId, + src_identity_id = SrcIdentityId, + dst_identity_id = DstIdentityId, + version = Version, + total_num = TotalNum, + index = Idx, + rules = ChunkRulesBin + }), + FragmentPolicyResponsePkt = <>, + gen_udp:send(Sock, ClientIp, ClientPort, FragmentPolicyResponsePkt) + end || {Idx, ChunkRulesBin} <- Fragments]; false -> %% 小于1200字节不分组 PolicyResponse = sdlan_pb:encode_msg(#sdl_policy_response {