This commit is contained in:
anlicheng 2026-04-02 15:46:01 +08:00
parent 32a7151f7d
commit 6ce69900f6
9 changed files with 589 additions and 298 deletions

View File

@ -33,6 +33,10 @@
%% , %% ,
-define(PACKET_EVENT, 16#10). -define(PACKET_EVENT, 16#10).
%% ,
-define(PACKET_COMMAND, 16#11).
-define(PACKET_COMMAND_ACK, 16#12).
%% %%
-define(PACKET_FLOW_TRACER, 16#15). -define(PACKET_FLOW_TRACER, 16#15).

View File

@ -8,13 +8,6 @@
-define(sdlan_pb_gpb_version, "4.21.7"). -define(sdlan_pb_gpb_version, "4.21.7").
-ifndef('HELLO_PB_H').
-define('HELLO_PB_H', true).
-record('Hello',
{
}).
-endif.
-ifndef('SDLV4INFO_PB_H'). -ifndef('SDLV4INFO_PB_H').
-define('SDLV4INFO_PB_H', true). -define('SDLV4INFO_PB_H', true).
-record('SDLV4Info', -record('SDLV4Info',
@ -154,9 +147,16 @@
}). }).
-endif. -endif.
-ifndef('SDLEVENT.EXITNODECONTROL_PB_H'). -ifndef('SDLEVENT_PB_H').
-define('SDLEVENT.EXITNODECONTROL_PB_H', true). -define('SDLEVENT_PB_H', true).
-record('SDLEvent.ExitNodeControl', -record('SDLEvent',
{event :: {nat_changed, sdlan_pb:'SDLEvent.NatChanged'()} | {send_register, sdlan_pb:'SDLEvent.SendRegister'()} | {shutdown, sdlan_pb:'SDLEvent.NetworkShutdown'()} | undefined % oneof
}).
-endif.
-ifndef('SDLCOMMAND.EXITNODECONTROL_PB_H').
-define('SDLCOMMAND.EXITNODECONTROL_PB_H', true).
-record('SDLCommand.ExitNodeControl',
{action = 0 :: integer() | undefined, % = 1, optional, 32 bits {action = 0 :: integer() | undefined, % = 1, optional, 32 bits
node_mac = <<>> :: iodata() | undefined, % = 2, optional node_mac = <<>> :: iodata() | undefined, % = 2, optional
node_ip = 0 :: non_neg_integer() | undefined, % = 3, optional, 32 bits node_ip = 0 :: non_neg_integer() | undefined, % = 3, optional, 32 bits
@ -164,10 +164,21 @@
}). }).
-endif. -endif.
-ifndef('SDLEVENT_PB_H'). -ifndef('SDLCOMMAND_PB_H').
-define('SDLEVENT_PB_H', true). -define('SDLCOMMAND_PB_H', true).
-record('SDLEvent', -record('SDLCommand',
{event :: {nat_changed, sdlan_pb:'SDLEvent.NatChanged'()} | {send_register, sdlan_pb:'SDLEvent.SendRegister'()} | {shutdown, sdlan_pb:'SDLEvent.NetworkShutdown'()} | {exit_node, sdlan_pb:'SDLEvent.ExitNodeControl'()} | undefined % oneof {pkt_id = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
command :: {exit_node, sdlan_pb:'SDLCommand.ExitNodeControl'()} | undefined % oneof
}).
-endif.
-ifndef('SDLCOMMANDACK_PB_H').
-define('SDLCOMMANDACK_PB_H', true).
-record('SDLCommandAck',
{pkt_id = 0 :: non_neg_integer() | undefined, % = 1, optional, 32 bits
code = 0 :: integer() | undefined, % = 2, optional, 32 bits
message = <<>> :: unicode:chardata() | undefined, % = 3, optional
data = <<>> :: iodata() | undefined % = 4, optional
}). }).
-endif. -endif.

View File

@ -1,13 +1,9 @@
syntax = "proto3"; syntax = "proto3";
package mypkg; package message;
// //
message Hello {
}
message SDLV4Info { message SDLV4Info {
uint32 port = 1; uint32 port = 1;
bytes v4 = 2; bytes v4 = 2;
@ -132,6 +128,16 @@ message SDLEvent {
string message = 1; string message = 1;
} }
oneof event {
NatChanged nat_changed = 1;
SendRegister send_register = 2;
NetworkShutdown shutdown = 3;
}
}
// Command指令
message SDLCommand {
uint32 pkt_id = 1;
// //
message ExitNodeControl { message ExitNodeControl {
int32 action = 1; // int32 action = 1; //
@ -140,14 +146,18 @@ message SDLEvent {
string remark = 4; // 便/ string remark = 4; // 便/
} }
oneof event { oneof command {
NatChanged nat_changed = 1; ExitNodeControl exit_node = 2;
SendRegister send_register = 2;
NetworkShutdown shutdown = 3;
ExitNodeControl exit_node = 4;
} }
} }
message SDLCommandAck {
uint32 pkt_id = 1;
int32 code = 2;
string message = 3;
bytes data = 4;
}
// UDP通讯消息 // UDP通讯消息
// client和stun之间的心跳包super的udp之间的存活逻辑 // client和stun之间的心跳包super的udp之间的存活逻辑

View File

@ -35,6 +35,20 @@ handle_request("POST", "/network/delete", _, #{<<"id">> := NetworkId}) when Netw
end end
end; end;
handle_request("POST", "/network/exit_node_control", _, #{<<"id">> := NetworkId}) when NetworkId > 0 ->
case sdlan_network:get_pid(NetworkId) of
undefined ->
{ok, 200, sdlan_util:json_data(<<"network not found">>)};
NetworkPid when is_pid(NetworkPid) ->
case sdlan_network_sup:delete_network(NetworkId) of
ok ->
{ok, 200, sdlan_util:json_data(<<"success">>)};
{error, Reason} ->
logger:debug("[network_handler] delete network: ~p, get error: ~p", [NetworkId, Reason]),
{ok, 200, sdlan_util:json_error(-1, <<"error">>)}
end
end;
handle_request(_, Path, _, _) -> handle_request(_, Path, _, _) ->
Path1 = list_to_binary(Path), Path1 = list_to_binary(Path),
{ok, 200, sdlan_util:json_error(-1, <<"url: ", Path1/binary, " not found">>)}. {ok, 200, sdlan_util:json_error(-1, <<"url: ", Path1/binary, " not found">>)}.

View File

@ -32,6 +32,7 @@ handle_request("GET", "/test/get_network", #{<<"id">> := Id0}, _) ->
<<"domain">> => <<"punchnet.cn">>, <<"domain">> => <<"punchnet.cn">>,
<<"ipaddr">> => <<"10.211.179.0/24">>, <<"ipaddr">> => <<"10.211.179.0/24">>,
<<"owner_id">> => 1234, <<"owner_id">> => 1234,
<<"algorithm">> => <<"chacha20">>,
<<"disabled_clients">> => [] <<"disabled_clients">> => []
} }
}, },

View File

@ -25,7 +25,7 @@
%% API %% API
-export([start_link/2]). -export([start_link/2]).
-export([send_event/3, stop/2]). -export([send_event/3, command/4, stop/2]).
-export([test_rules/2]). -export([test_rules/2]).
%% gen_statem callbacks %% gen_statem callbacks
@ -50,6 +50,11 @@
mac :: undefined | binary(), mac :: undefined | binary(),
ip = 0 :: integer(), ip = 0 :: integer(),
%%
pkt_id = 1,
%% #{pkt_id => {Ref, ReceiverPid}}
pending_commands = #{},
ping_counter = 0, ping_counter = 0,
%% 线 %% 线
@ -70,6 +75,10 @@ test_rules(SrcIdentityId, DstIdentityId) when is_integer(SrcIdentityId), is_inte
send_event(Pid, EventType, Event) when is_pid(Pid), is_integer(EventType), is_binary(Event) -> send_event(Pid, EventType, Event) when is_pid(Pid), is_integer(EventType), is_binary(Event) ->
gen_statem:cast(Pid, {send_event, EventType, Event}). gen_statem:cast(Pid, {send_event, EventType, Event}).
-spec command(Pid :: pid(), Ref :: reference(), ReceiverPid :: pid(), {Tag :: atom(), SubCommand :: any()}) -> no_return().
command(Pid, Ref, ReceiverPid, SubCommand) when is_pid(Pid), is_pid(ReceiverPid) ->
gen_statem:cast(Pid, {command, Ref, ReceiverPid, SubCommand}).
-spec stop(Pid :: pid(), Reason :: term()) -> ok. -spec stop(Pid :: pid(), Reason :: term()) -> ok.
stop(Pid, Reason) when is_pid(Pid) -> stop(Pid, Reason) when is_pid(Pid) ->
gen_statem:stop(Pid, Reason, 2000). gen_statem:stop(Pid, Reason, 2000).
@ -117,7 +126,7 @@ handle_event(info, {quic, dgram_state_changed, Conn, Opts = #{dgram_send_enabled
handle_event(info, {quic, new_stream, Stream, Opts}, waiting_stream, State=#state{max_packet_size = MaxPacketSize, heartbeat_sec = HeartbeatSec}) -> handle_event(info, {quic, new_stream, Stream, Opts}, waiting_stream, State=#state{max_packet_size = MaxPacketSize, heartbeat_sec = HeartbeatSec}) ->
logger:debug("[sdlan_quic_channel] call new_stream: ~p, opts: ~p", [Stream, Opts]), logger:debug("[sdlan_quic_channel] call new_stream: ~p, opts: ~p", [Stream, Opts]),
%% %%
WelcomePkt = sdlan_pb:encode_msg(#sdl_welcome{ WelcomePkt = sdlan_pb:encode_msg(#'SDLWelcome'{
version = 1, version = 1,
max_bidi_streams = 1, max_bidi_streams = 1,
max_packet_size = MaxPacketSize, max_packet_size = MaxPacketSize,
@ -150,9 +159,9 @@ handle_event(info, {quic, Data, Stream, _Props}, _StateName, State = #state{stre
%% %%
handle_event(internal, {frame, <<?PACKET_REGISTER_SUPER, Body/binary>>}, initialized, State=#state{stream = Stream}) -> handle_event(internal, {frame, <<?PACKET_REGISTER_SUPER, Body/binary>>}, initialized, State=#state{stream = Stream}) ->
#sdl_register_super{ #'SDLRegisterSuper'{
client_id = ClientId, network_id = NetworkId, mac = Mac, ip = Ip, mask_len = MaskLen, client_id = ClientId, network_id = NetworkId, mac = Mac, ip = Ip, mask_len = MaskLen,
hostname = HostName, pub_key = PubKey, access_token = AccessToken} = sdlan_pb:decode_msg(Body, sdl_register_super), hostname = HostName, pub_key = PubKey, access_token = AccessToken} = sdlan_pb:decode_msg(Body, 'SDLRegisterSuper'),
true = (Mac =/= <<>> andalso PubKey =/= <<>> andalso ClientId =/= <<>>), true = (Mac =/= <<>> andalso PubKey =/= <<>> andalso ClientId =/= <<>>),
%% Mac地址不能是广播地址 %% Mac地址不能是广播地址
@ -180,7 +189,7 @@ handle_event(internal, {frame, <<?PACKET_REGISTER_SUPER, Body/binary>>}, initial
NetworkPid when is_pid(NetworkPid) -> NetworkPid when is_pid(NetworkPid) ->
{ok, Algorithm, Key, RegionId, SessionToken} = sdlan_network:attach(NetworkPid, self(), ClientId, Mac, Ip, HostName), {ok, Algorithm, Key, RegionId, SessionToken} = sdlan_network:attach(NetworkPid, self(), ClientId, Mac, Ip, HostName),
RsaPubKey = sdlan_cipher:rsa_pem_decode(PubKey), RsaPubKey = sdlan_cipher:rsa_pem_decode(PubKey),
RegisterSuperAck = sdlan_pb:encode_msg(#sdl_register_super_ack { RegisterSuperAck = sdlan_pb:encode_msg(#'SDLRegisterSuperAck'{
algorithm = Algorithm, algorithm = Algorithm,
key = rsa_encode(Key, RsaPubKey), key = rsa_encode(Key, RsaPubKey),
region_id = RegionId, region_id = RegionId,
@ -223,13 +232,13 @@ handle_event(internal, {frame, <<?PACKET_REGISTER_SUPER, Body/binary>>}, initial
end; end;
handle_event(internal, {frame, <<?PACKET_QUERY_INFO, Body/binary>>}, registered, #state{stream = Stream, network_pid = NetworkPid, mac = SrcMac}) when is_pid(NetworkPid) -> handle_event(internal, {frame, <<?PACKET_QUERY_INFO, Body/binary>>}, registered, #state{stream = Stream, network_pid = NetworkPid, mac = SrcMac}) when is_pid(NetworkPid) ->
#sdl_query_info{dst_mac = DstMac} = sdlan_pb:decode_msg(Body, sdl_query_info), #'SDLQueryInfo'{dst_mac = DstMac} = sdlan_pb:decode_msg(Body, 'SDLQueryInfo'),
case sdlan_network:peer_info(NetworkPid, SrcMac, DstMac) of case sdlan_network:peer_info(NetworkPid, SrcMac, DstMac) of
error -> error ->
logger:debug("[sdlan_channel] query_info src_mac is: ~p, dst_mac: ~p, nat_peer not found", logger:debug("[sdlan_channel] query_info src_mac is: ~p, dst_mac: ~p, nat_peer not found",
[sdlan_util:format_mac(SrcMac), sdlan_util:format_mac(DstMac)]), [sdlan_util:format_mac(SrcMac), sdlan_util:format_mac(DstMac)]),
EmptyResponse = sdlan_pb:encode_msg(#sdl_peer_info{ EmptyResponse = sdlan_pb:encode_msg(#'SDLPeerInfo'{
dst_mac = DstMac, dst_mac = DstMac,
v4_info = undefined, v4_info = undefined,
v6_info = undefined v6_info = undefined
@ -240,9 +249,9 @@ handle_event(internal, {frame, <<?PACKET_QUERY_INFO, Body/binary>>}, registered,
logger:debug("[sdlan_channel] query_info src_mac is: ~p, dst_mac: ~p, nat_peer: ~p", logger:debug("[sdlan_channel] query_info src_mac is: ~p, dst_mac: ~p, nat_peer: ~p",
[sdlan_util:format_mac(SrcMac), sdlan_util:format_mac(DstMac), NatPeer]), [sdlan_util:format_mac(SrcMac), sdlan_util:format_mac(DstMac), NatPeer]),
PeerInfo = sdlan_pb:encode_msg(#sdl_peer_info{ PeerInfo = sdlan_pb:encode_msg(#'SDLPeerInfo'{
dst_mac = DstMac, dst_mac = DstMac,
v4_info = #sdl_v4_info { v4_info = #'SDLV4Info' {
port = NatPort, port = NatPort,
v4 = <<Ip0, Ip1, Ip2, Ip3>>, v4 = <<Ip0, Ip1, Ip2, Ip3>>,
nat_type = NatType nat_type = NatType
@ -255,11 +264,11 @@ handle_event(internal, {frame, <<?PACKET_QUERY_INFO, Body/binary>>}, registered,
%% arp查询 %% arp查询
handle_event(internal, {frame, <<?PACKET_ARP_REQUEST, Body/binary>>}, registered, #state{stream = Stream, network_id = NetworkId, network_pid = NetworkPid}) when is_pid(NetworkPid) -> handle_event(internal, {frame, <<?PACKET_ARP_REQUEST, Body/binary>>}, registered, #state{stream = Stream, network_id = NetworkId, network_pid = NetworkPid}) when is_pid(NetworkPid) ->
#sdl_arp_request{target_ip = TargetIp, origin_ip = OriginIp, context = Context} = sdlan_pb:decode_msg(Body, sdl_arp_request), #'SDLArpRequest'{target_ip = TargetIp, origin_ip = OriginIp, context = Context} = sdlan_pb:decode_msg(Body, 'SDLArpRequest'),
case sdlan_network:arp_request(NetworkPid, TargetIp) of case sdlan_network:arp_request(NetworkPid, TargetIp) of
error -> error ->
logger:debug("[sdlan_channel] network: ~p, arp_request target_ip: ~p, mac not found", [NetworkId, sdlan_util:int_to_ipv4(TargetIp)]), logger:debug("[sdlan_channel] network: ~p, arp_request target_ip: ~p, mac not found", [NetworkId, sdlan_util:int_to_ipv4(TargetIp)]),
EmptyArpResponsePkt = sdlan_pb:encode_msg(#sdl_arp_response{ EmptyArpResponsePkt = sdlan_pb:encode_msg(#'SDLArpResponse'{
target_ip = TargetIp, target_ip = TargetIp,
target_mac = <<>>, target_mac = <<>>,
origin_ip = OriginIp, origin_ip = OriginIp,
@ -269,7 +278,7 @@ handle_event(internal, {frame, <<?PACKET_ARP_REQUEST, Body/binary>>}, registered
keep_state_and_data; keep_state_and_data;
{ok, Mac} -> {ok, Mac} ->
logger:debug("[sdlan_channel] network: ~p, arp_request target_ip: ~p, mac: ~p", [NetworkId, sdlan_util:int_to_ipv4(TargetIp), sdlan_util:format_mac(Mac)]), logger:debug("[sdlan_channel] network: ~p, arp_request target_ip: ~p, mac: ~p", [NetworkId, sdlan_util:int_to_ipv4(TargetIp), sdlan_util:format_mac(Mac)]),
ArpResponsePkt = sdlan_pb:encode_msg(#sdl_arp_response{ ArpResponsePkt = sdlan_pb:encode_msg(#'SDLArpResponse'{
target_ip = TargetIp, target_ip = TargetIp,
target_mac = Mac, target_mac = Mac,
origin_ip = OriginIp, origin_ip = OriginIp,
@ -281,14 +290,13 @@ handle_event(internal, {frame, <<?PACKET_ARP_REQUEST, Body/binary>>}, registered
handle_event(internal, {frame, <<?PACKET_POLICY_REQUEST, Body/binary>>}, registered, #state{stream = Stream, network_pid = NetworkPid}) when is_pid(NetworkPid) -> handle_event(internal, {frame, <<?PACKET_POLICY_REQUEST, Body/binary>>}, registered, #state{stream = Stream, network_pid = NetworkPid}) when is_pid(NetworkPid) ->
maybe maybe
PolicyRequest = catch sdlan_pb:decode_msg(Body, sdl_policy_request), #'SDLPolicyRequest'{src_identity_id = SrcIdentityId, dst_identity_id = DstIdentityId, version = Version} ?= sdlan_pb:decode_msg(Body, 'SDLPolicyRequest'),
#sdl_policy_request{src_identity_id = SrcIdentityId, dst_identity_id = DstIdentityId, version = Version} ?= PolicyRequest,
{ok, Rules} = get_rules(SrcIdentityId, DstIdentityId), {ok, Rules} = get_rules(SrcIdentityId, DstIdentityId),
logger:debug("[sdlan_channel] policy_request src_identity_id: ~p, dst_identity_id: ~p, rules: ~p", [SrcIdentityId, DstIdentityId, Rules]), logger:debug("[sdlan_channel] policy_request src_identity_id: ~p, dst_identity_id: ~p, rules: ~p", [SrcIdentityId, DstIdentityId, Rules]),
RuleBin = iolist_to_binary(lists:map(fun({Proto, Port}) -> <<Proto:8, Port:16>> end, Rules)), RuleBin = iolist_to_binary(lists:map(fun({Proto, Port}) -> <<Proto:8, Port:16>> end, Rules)),
PolicyResponsePkt = sdlan_pb:encode_msg(#sdl_policy_response { PolicyResponsePkt = sdlan_pb:encode_msg(#'SDLPolicyResponse'{
src_identity_id = SrcIdentityId, src_identity_id = SrcIdentityId,
dst_identity_id = DstIdentityId, dst_identity_id = DstIdentityId,
version = Version, version = Version,
@ -298,6 +306,24 @@ handle_event(internal, {frame, <<?PACKET_POLICY_REQUEST, Body/binary>>}, registe
end, end,
keep_state_and_data; keep_state_and_data;
%%
handle_event(internal, {frame, <<?PACKET_COMMAND_ACK, Body/binary>>}, registered, State=#state{pending_commands = PendingCommands}) ->
maybe
CommandAck = sdlan_pb:decode_msg(Body, 'SDLCommandAck'),
#'SDLCommandAck'{pkt_id = PktId} ?= CommandAck,
{{Ref, ReceiverPid}, RestPendingCommands} ?= maps:take(PktId, PendingCommands),
case is_process_alive(ReceiverPid) of
true ->
ReceiverPid ! {quic_command_ack, Ref, CommandAck};
false ->
ok
end,
{keep_state, State#state{pending_commands = RestPendingCommands}}
else _ ->
keep_state_and_data
end;
handle_event(internal, {frame, <<?PACKET_PING>>}, _StateName, State = #state{stream = Stream, ping_counter = PingCounter}) -> handle_event(internal, {frame, <<?PACKET_PING>>}, _StateName, State = #state{stream = Stream, ping_counter = PingCounter}) ->
quic_send(Stream, <<?PACKET_PONG>>), quic_send(Stream, <<?PACKET_PONG>>),
{keep_state, State#state{ping_counter = PingCounter + 1}}; {keep_state, State#state{ping_counter = PingCounter + 1}};
@ -319,6 +345,17 @@ handle_event(cast, {send_event, EventType, Event}, registered, #state{stream = S
quic_send(Stream, <<?PACKET_EVENT, EventType, Event/binary>>), quic_send(Stream, <<?PACKET_EVENT, EventType, Event/binary>>),
keep_state_and_data; keep_state_and_data;
%%
handle_event(cast, {command, Ref, ReceiverPid, SubCommand}, registered, State=#state{stream = Stream, pkt_id = PktId, pending_commands = PendingCommands, client_id = ClientId}) ->
CommandPkt = sdlan_pb:encode_msg(#'SDLCommand'{
pkt_id = PktId,
command = SubCommand
}),
logger:debug("[sdlan_channel] client_id: ~p, will send Command: ~p", [ClientId, SubCommand]),
quic_send(Stream, <<?PACKET_COMMAND, CommandPkt/binary>>),
{keep_state, State#state{pkt_id = PktId + 1, pending_commands = maps:put(PktId, {Ref, ReceiverPid}, PendingCommands)}};
%% %%
handle_event(info, {frame, <<?PACKET_UNREGISTER>>}, registered, State=#state{client_id = ClientId, mac = Mac, network_pid = NetworkPid}) when is_pid(NetworkPid) -> handle_event(info, {frame, <<?PACKET_UNREGISTER>>}, registered, State=#state{client_id = ClientId, mac = Mac, network_pid = NetworkPid}) when is_pid(NetworkPid) ->
logger:warning("[sdlan_channel] unregister client_id: ~p", [ClientId]), logger:warning("[sdlan_channel] unregister client_id: ~p", [ClientId]),
@ -369,7 +406,7 @@ decode_frames0(Rest, _MaxPacketSize, Frames) ->
-spec register_nak_reply(ErrorCode :: integer(), ErrorMsg :: binary()) -> binary(). -spec register_nak_reply(ErrorCode :: integer(), ErrorMsg :: binary()) -> binary().
register_nak_reply(ErrorCode, ErrorMsg) when is_integer(ErrorCode), is_binary(ErrorMsg) -> register_nak_reply(ErrorCode, ErrorMsg) when is_integer(ErrorCode), is_binary(ErrorMsg) ->
RegisterNakReply = sdlan_pb:encode_msg(#sdl_register_super_nak { RegisterNakReply = sdlan_pb:encode_msg(#'SDLRegisterSuperNak'{
error_code = ErrorCode, error_code = ErrorCode,
error_message = ErrorMsg error_message = ErrorMsg
}), }),

View File

@ -43,7 +43,7 @@
hostname :: binary(), hostname :: binary(),
hole :: undefined | #hole{}, hole :: undefined | #hole{},
%% ip和ip_v6的映射关系, #{ip_addr :: integer() => {}} %% ip和ip_v6的映射关系, #{ip_addr :: integer() => {}}
v6_info :: undefined | #sdl_v6_info{}, v6_info :: undefined | #'SDLV6Info'{},
session_token :: binary(), session_token :: binary(),
last_seen :: integer() %% monotonic_time(second), last_seen :: integer() %% monotonic_time(second),
}). }).
@ -109,7 +109,7 @@ unregister(Pid, ClientId, Mac) when is_pid(Pid), is_binary(ClientId), is_binary(
gen_server:cast(Pid, {unregister, ClientId, Mac}). gen_server:cast(Pid, {unregister, ClientId, Mac}).
-spec peer_info(Pid :: pid(), SrcMac :: binary(), DstMac :: binary()) -> -spec peer_info(Pid :: pid(), SrcMac :: binary(), DstMac :: binary()) ->
error | {ok, {NatPeer :: {Ip :: inet:ip4_address(), Port :: integer()}, NatType :: integer()}, V6Info :: undefined | #sdl_v6_info{}}. error | {ok, {NatPeer :: {Ip :: inet:ip4_address(), Port :: integer()}, NatType :: integer()}, V6Info :: undefined | #'SDLV6Info'{}}.
peer_info(Pid, SrcMac, DstMac) when is_pid(Pid), is_binary(SrcMac), is_binary(DstMac) -> peer_info(Pid, SrcMac, DstMac) when is_pid(Pid), is_binary(SrcMac), is_binary(DstMac) ->
gen_server:call(Pid, {peer_info, SrcMac, DstMac}). gen_server:call(Pid, {peer_info, SrcMac, DstMac}).
@ -122,7 +122,7 @@ forward(Pid, Sock, SrcMac, DstMac, Packet) when is_pid(Pid), is_binary(SrcMac),
gen_server:cast(Pid, {forward, Sock, SrcMac, DstMac, Packet}). gen_server:cast(Pid, {forward, Sock, SrcMac, DstMac, Packet}).
%% ip地址对应的nat关系 %% ip地址对应的nat关系
-spec update_hole(Pid :: pid(), SessionToken :: binary(), ClientId :: binary(), Mac :: binary(), Peer :: tuple(), NatType :: integer(), V6Info :: undefined | #sdl_v6_info{}) -> no_return(). -spec update_hole(Pid :: pid(), SessionToken :: binary(), ClientId :: binary(), Mac :: binary(), Peer :: tuple(), NatType :: integer(), V6Info :: undefined | #'SDLV6Info'{}) -> no_return().
update_hole(Pid, SessionToken, ClientId, Mac, Peer, NatType, V6Info) when is_pid(Pid), is_binary(ClientId), is_binary(Mac), is_integer(NatType) -> update_hole(Pid, SessionToken, ClientId, Mac, Peer, NatType, V6Info) when is_pid(Pid), is_binary(ClientId), is_binary(Mac), is_integer(NatType) ->
gen_server:cast(Pid, {update_hole, SessionToken, ClientId, Mac, Peer, NatType, V6Info}). gen_server:cast(Pid, {update_hole, SessionToken, ClientId, Mac, Peer, NatType, V6Info}).
@ -207,22 +207,14 @@ handle_call({attach, ChannelPid, ClientId, Mac, Ip, Hostname}, _From,
{ok, #endpoint{ip = OldIp, channel_pid = OldChannelPid, channel_ref = OldChannelRef}} ?= maps:find(Mac, Endpoints), {ok, #endpoint{ip = OldIp, channel_pid = OldChannelPid, channel_ref = OldChannelRef}} ?= maps:find(Mac, Endpoints),
true ?= OldIp =/= Ip, true ?= OldIp =/= Ip,
#sdl_event { Event = sdlan_pb:encode_msg(#'SDLEvent'{
event = {nat_changed, #'sdl_event.nat_changed' { event = {nat_changed, #'SDLEvent.NatChanged' {
mac = Mac,
ip = Ip
}}
},
Event = sdlan_pb:encode_msg(#sdl_event {
event = {nat_changed, #'sdl_event.nat_changed' {
mac = Mac, mac = Mac,
ip = Ip ip = Ip
}} }}
}), }),
broadcast(fun(#endpoint{channel_pid = ChannelPid0}) -> broadcast(fun(#endpoint{channel_pid = ChannelPid0}) ->
sdlan_quic_channel:send_event(ChannelPid0, ?EVENT_NAT_CHANGED, NatChangedEvent) sdlan_quic_channel:send_event(ChannelPid0, ?EVENT_NAT_CHANGED, Event)
end, [Mac], Endpoints), end, [Mac], Endpoints),
%% %%
@ -272,13 +264,17 @@ handle_call({peer_info, SrcMac, DstMac}, _From, State = #state{endpoints = Endpo
%% sendRegister事件(2024-06-25 ) %% sendRegister事件(2024-06-25 )
maybe maybe
{ok, #endpoint{hole = #hole{peer = {SrcNatIp, SrcNatPort}, nat_type = SrcNatType}, v6_info = SrcV6Info}} ?= maps:find(SrcMac, Endpoints), {ok, #endpoint{hole = #hole{peer = {SrcNatIp, SrcNatPort}, nat_type = SrcNatType}, v6_info = SrcV6Info}} ?= maps:find(SrcMac, Endpoints),
RegisterEvent = sdlan_pb:encode_msg(#sdl_send_register_event {
dst_mac = SrcMac, RegisterEvent = sdlan_pb:encode_msg(#'SDLEvent' {
nat_ip = sdlan_util:ipv4_to_int(SrcNatIp), event = {send_register, #'SDLEvent.SendRegister'{
nat_type = SrcNatType, dst_mac = SrcMac,
nat_port = SrcNatPort, nat_ip = sdlan_util:ipv4_to_int(SrcNatIp),
v6_info = SrcV6Info nat_type = SrcNatType,
nat_port = SrcNatPort,
v6_info = SrcV6Info
}}
}), }),
sdlan_quic_channel:send_event(DstChannelPid, ?EVENT_SEND_REGISTER, RegisterEvent) sdlan_quic_channel:send_event(DstChannelPid, ?EVENT_SEND_REGISTER, RegisterEvent)
end, end,
{reply, {ok, {DstNatPeer, DstNatType}, DstV6Info}, State}; {reply, {ok, {DstNatPeer, DstNatType}, DstV6Info}, State};
@ -381,10 +377,14 @@ handle_cast({update_hole, SessionToken, ClientId, Mac, Peer, NatType, V6Info}, S
NHole = #hole{peer = Peer, nat_type = NatType}, NHole = #hole{peer = Peer, nat_type = NatType},
maybe maybe
true ?= not same_hole(OldHole, NHole), true ?= not same_hole(OldHole, NHole),
NatChangedEvent = sdlan_pb:encode_msg(#sdl_nat_changed_event{
mac = Mac, NatChangedEvent = sdlan_pb:encode_msg(#'SDLEvent' {
ip = Ip event = {nat_changed, #'SDLEvent.NatChanged'{
mac = Mac,
ip = Ip
}}
}), }),
logger:debug("[sdlan_network] client_id: ~p(~p), hole changed", [ClientId, Ip]), logger:debug("[sdlan_network] client_id: ~p(~p), hole changed", [ClientId, Ip]),
broadcast(fun(#endpoint{channel_pid = ChannelPid}) -> broadcast(fun(#endpoint{channel_pid = ChannelPid}) ->
sdlan_quic_channel:send_event(ChannelPid, ?EVENT_NAT_CHANGED, NatChangedEvent) sdlan_quic_channel:send_event(ChannelPid, ?EVENT_NAT_CHANGED, NatChangedEvent)
@ -426,8 +426,10 @@ terminate(Reason, #state{network_id = NetworkId, endpoints = Endpoints}) ->
broadcast(fun(#endpoint{channel_pid = ChannelPid}) -> broadcast(fun(#endpoint{channel_pid = ChannelPid}) ->
case is_process_alive(ChannelPid) of case is_process_alive(ChannelPid) of
true -> true ->
NetworkShutdownEvent = sdlan_pb:encode_msg(#sdl_network_shutdown_event{ NetworkShutdownEvent = sdlan_pb:encode_msg(#'SDLEvent'{
message = <<"Network shutdown">> event = {shutdown, #'SDLEvent.NetworkShutdown'{
message = <<"Network shutdown">>
}}
}), }),
sdlan_quic_channel:send_event(ChannelPid, ?EVENT_NETWORK_SHUTDOWN, NetworkShutdownEvent), sdlan_quic_channel:send_event(ChannelPid, ?EVENT_NETWORK_SHUTDOWN, NetworkShutdownEvent),
sdlan_quic_channel:stop(ChannelPid, normal); sdlan_quic_channel:stop(ChannelPid, normal);
@ -498,7 +500,7 @@ format_endpoint({Mac, #endpoint{client_id = ClientId, ip = Ip, hole = #hole{peer
V6InfoMap = case V6Info of V6InfoMap = case V6Info of
undefined -> undefined ->
#{}; #{};
#sdl_v6_info{v6 = V6, port = V6Port} -> #'SDLV6Info'{v6 = V6, port = V6Port} ->
#{v6 => V6, port => V6Port} #{v6 => V6, port => V6Port}
end, end,
#{ #{

View File

@ -54,8 +54,6 @@
-export_type([]). -export_type([]).
%% message types %% message types
-type 'Hello'() :: #'Hello'{}.
-type 'SDLV4Info'() :: #'SDLV4Info'{}. -type 'SDLV4Info'() :: #'SDLV4Info'{}.
-type 'SDLV6Info'() :: #'SDLV6Info'{}. -type 'SDLV6Info'() :: #'SDLV6Info'{}.
@ -86,10 +84,14 @@
-type 'SDLEvent.NetworkShutdown'() :: #'SDLEvent.NetworkShutdown'{}. -type 'SDLEvent.NetworkShutdown'() :: #'SDLEvent.NetworkShutdown'{}.
-type 'SDLEvent.ExitNodeControl'() :: #'SDLEvent.ExitNodeControl'{}.
-type 'SDLEvent'() :: #'SDLEvent'{}. -type 'SDLEvent'() :: #'SDLEvent'{}.
-type 'SDLCommand.ExitNodeControl'() :: #'SDLCommand.ExitNodeControl'{}.
-type 'SDLCommand'() :: #'SDLCommand'{}.
-type 'SDLCommandAck'() :: #'SDLCommandAck'{}.
-type 'SDLStunRequest'() :: #'SDLStunRequest'{}. -type 'SDLStunRequest'() :: #'SDLStunRequest'{}.
-type 'SDLStunReply'() :: #'SDLStunReply'{}. -type 'SDLStunReply'() :: #'SDLStunReply'{}.
@ -104,9 +106,9 @@
-type 'SDLRegisterAck'() :: #'SDLRegisterAck'{}. -type 'SDLRegisterAck'() :: #'SDLRegisterAck'{}.
-export_type(['Hello'/0, 'SDLV4Info'/0, 'SDLV6Info'/0, 'SDLWelcome'/0, 'SDLRegisterSuper'/0, 'SDLRegisterSuperAck'/0, 'SDLRegisterSuperNak'/0, 'SDLQueryInfo'/0, 'SDLPeerInfo'/0, 'SDLArpRequest'/0, 'SDLArpResponse'/0, 'SDLPolicyRequest'/0, 'SDLPolicyResponse'/0, 'SDLEvent.NatChanged'/0, 'SDLEvent.SendRegister'/0, 'SDLEvent.NetworkShutdown'/0, 'SDLEvent.ExitNodeControl'/0, 'SDLEvent'/0, 'SDLStunRequest'/0, 'SDLStunReply'/0, 'SDLData'/0, 'SDLStunProbe'/0, 'SDLStunProbeReply'/0, 'SDLRegister'/0, 'SDLRegisterAck'/0]). -export_type(['SDLV4Info'/0, 'SDLV6Info'/0, 'SDLWelcome'/0, 'SDLRegisterSuper'/0, 'SDLRegisterSuperAck'/0, 'SDLRegisterSuperNak'/0, 'SDLQueryInfo'/0, 'SDLPeerInfo'/0, 'SDLArpRequest'/0, 'SDLArpResponse'/0, 'SDLPolicyRequest'/0, 'SDLPolicyResponse'/0, 'SDLEvent.NatChanged'/0, 'SDLEvent.SendRegister'/0, 'SDLEvent.NetworkShutdown'/0, 'SDLEvent'/0, 'SDLCommand.ExitNodeControl'/0, 'SDLCommand'/0, 'SDLCommandAck'/0, 'SDLStunRequest'/0, 'SDLStunReply'/0, 'SDLData'/0, 'SDLStunProbe'/0, 'SDLStunProbeReply'/0, 'SDLRegister'/0, 'SDLRegisterAck'/0]).
-type '$msg_name'() :: 'Hello' | 'SDLV4Info' | 'SDLV6Info' | 'SDLWelcome' | 'SDLRegisterSuper' | 'SDLRegisterSuperAck' | 'SDLRegisterSuperNak' | 'SDLQueryInfo' | 'SDLPeerInfo' | 'SDLArpRequest' | 'SDLArpResponse' | 'SDLPolicyRequest' | 'SDLPolicyResponse' | 'SDLEvent.NatChanged' | 'SDLEvent.SendRegister' | 'SDLEvent.NetworkShutdown' | 'SDLEvent.ExitNodeControl' | 'SDLEvent' | 'SDLStunRequest' | 'SDLStunReply' | 'SDLData' | 'SDLStunProbe' | 'SDLStunProbeReply' | 'SDLRegister' | 'SDLRegisterAck'. -type '$msg_name'() :: 'SDLV4Info' | 'SDLV6Info' | 'SDLWelcome' | 'SDLRegisterSuper' | 'SDLRegisterSuperAck' | 'SDLRegisterSuperNak' | 'SDLQueryInfo' | 'SDLPeerInfo' | 'SDLArpRequest' | 'SDLArpResponse' | 'SDLPolicyRequest' | 'SDLPolicyResponse' | 'SDLEvent.NatChanged' | 'SDLEvent.SendRegister' | 'SDLEvent.NetworkShutdown' | 'SDLEvent' | 'SDLCommand.ExitNodeControl' | 'SDLCommand' | 'SDLCommandAck' | 'SDLStunRequest' | 'SDLStunReply' | 'SDLData' | 'SDLStunProbe' | 'SDLStunProbeReply' | 'SDLRegister' | 'SDLRegisterAck'.
-type '$msg'() :: 'Hello'() | 'SDLV4Info'() | 'SDLV6Info'() | 'SDLWelcome'() | 'SDLRegisterSuper'() | 'SDLRegisterSuperAck'() | 'SDLRegisterSuperNak'() | 'SDLQueryInfo'() | 'SDLPeerInfo'() | 'SDLArpRequest'() | 'SDLArpResponse'() | 'SDLPolicyRequest'() | 'SDLPolicyResponse'() | 'SDLEvent.NatChanged'() | 'SDLEvent.SendRegister'() | 'SDLEvent.NetworkShutdown'() | 'SDLEvent.ExitNodeControl'() | 'SDLEvent'() | 'SDLStunRequest'() | 'SDLStunReply'() | 'SDLData'() | 'SDLStunProbe'() | 'SDLStunProbeReply'() | 'SDLRegister'() | 'SDLRegisterAck'(). -type '$msg'() :: 'SDLV4Info'() | 'SDLV6Info'() | 'SDLWelcome'() | 'SDLRegisterSuper'() | 'SDLRegisterSuperAck'() | 'SDLRegisterSuperNak'() | 'SDLQueryInfo'() | 'SDLPeerInfo'() | 'SDLArpRequest'() | 'SDLArpResponse'() | 'SDLPolicyRequest'() | 'SDLPolicyResponse'() | 'SDLEvent.NatChanged'() | 'SDLEvent.SendRegister'() | 'SDLEvent.NetworkShutdown'() | 'SDLEvent'() | 'SDLCommand.ExitNodeControl'() | 'SDLCommand'() | 'SDLCommandAck'() | 'SDLStunRequest'() | 'SDLStunReply'() | 'SDLData'() | 'SDLStunProbe'() | 'SDLStunProbeReply'() | 'SDLRegister'() | 'SDLRegisterAck'().
-export_type(['$msg_name'/0, '$msg'/0]). -export_type(['$msg_name'/0, '$msg'/0]).
-if(?OTP_RELEASE >= 24). -if(?OTP_RELEASE >= 24).
@ -133,7 +135,6 @@ encode_msg(Msg, MsgName, Opts) ->
end, end,
TrUserData = proplists:get_value(user_data, Opts), TrUserData = proplists:get_value(user_data, Opts),
case MsgName of case MsgName of
'Hello' -> encode_msg_Hello(id(Msg, TrUserData), TrUserData);
'SDLV4Info' -> encode_msg_SDLV4Info(id(Msg, TrUserData), TrUserData); 'SDLV4Info' -> encode_msg_SDLV4Info(id(Msg, TrUserData), TrUserData);
'SDLV6Info' -> encode_msg_SDLV6Info(id(Msg, TrUserData), TrUserData); 'SDLV6Info' -> encode_msg_SDLV6Info(id(Msg, TrUserData), TrUserData);
'SDLWelcome' -> encode_msg_SDLWelcome(id(Msg, TrUserData), TrUserData); 'SDLWelcome' -> encode_msg_SDLWelcome(id(Msg, TrUserData), TrUserData);
@ -149,8 +150,10 @@ encode_msg(Msg, MsgName, Opts) ->
'SDLEvent.NatChanged' -> 'encode_msg_SDLEvent.NatChanged'(id(Msg, TrUserData), TrUserData); 'SDLEvent.NatChanged' -> 'encode_msg_SDLEvent.NatChanged'(id(Msg, TrUserData), TrUserData);
'SDLEvent.SendRegister' -> 'encode_msg_SDLEvent.SendRegister'(id(Msg, TrUserData), TrUserData); 'SDLEvent.SendRegister' -> 'encode_msg_SDLEvent.SendRegister'(id(Msg, TrUserData), TrUserData);
'SDLEvent.NetworkShutdown' -> 'encode_msg_SDLEvent.NetworkShutdown'(id(Msg, TrUserData), TrUserData); 'SDLEvent.NetworkShutdown' -> 'encode_msg_SDLEvent.NetworkShutdown'(id(Msg, TrUserData), TrUserData);
'SDLEvent.ExitNodeControl' -> 'encode_msg_SDLEvent.ExitNodeControl'(id(Msg, TrUserData), TrUserData);
'SDLEvent' -> encode_msg_SDLEvent(id(Msg, TrUserData), TrUserData); 'SDLEvent' -> encode_msg_SDLEvent(id(Msg, TrUserData), TrUserData);
'SDLCommand.ExitNodeControl' -> 'encode_msg_SDLCommand.ExitNodeControl'(id(Msg, TrUserData), TrUserData);
'SDLCommand' -> encode_msg_SDLCommand(id(Msg, TrUserData), TrUserData);
'SDLCommandAck' -> encode_msg_SDLCommandAck(id(Msg, TrUserData), TrUserData);
'SDLStunRequest' -> encode_msg_SDLStunRequest(id(Msg, TrUserData), TrUserData); 'SDLStunRequest' -> encode_msg_SDLStunRequest(id(Msg, TrUserData), TrUserData);
'SDLStunReply' -> encode_msg_SDLStunReply(id(Msg, TrUserData), TrUserData); 'SDLStunReply' -> encode_msg_SDLStunReply(id(Msg, TrUserData), TrUserData);
'SDLData' -> encode_msg_SDLData(id(Msg, TrUserData), TrUserData); 'SDLData' -> encode_msg_SDLData(id(Msg, TrUserData), TrUserData);
@ -161,8 +164,6 @@ encode_msg(Msg, MsgName, Opts) ->
end. end.
encode_msg_Hello(_Msg, _TrUserData) -> <<>>.
encode_msg_SDLV4Info(Msg, TrUserData) -> encode_msg_SDLV4Info(Msg, <<>>, TrUserData). encode_msg_SDLV4Info(Msg, TrUserData) -> encode_msg_SDLV4Info(Msg, <<>>, TrUserData).
@ -681,10 +682,23 @@ encode_msg_SDLPolicyResponse(#'SDLPolicyResponse'{src_identity_id = F1, dst_iden
end end
end. end.
'encode_msg_SDLEvent.ExitNodeControl'(Msg, TrUserData) -> 'encode_msg_SDLEvent.ExitNodeControl'(Msg, <<>>, TrUserData). encode_msg_SDLEvent(Msg, TrUserData) -> encode_msg_SDLEvent(Msg, <<>>, TrUserData).
'encode_msg_SDLEvent.ExitNodeControl'(#'SDLEvent.ExitNodeControl'{action = F1, node_mac = F2, node_ip = F3, remark = F4}, Bin, TrUserData) -> encode_msg_SDLEvent(#'SDLEvent'{event = F1}, Bin, TrUserData) ->
if F1 =:= undefined -> Bin;
true ->
case id(F1, TrUserData) of
{nat_changed, TF1} -> begin TrTF1 = id(TF1, TrUserData), e_mfield_SDLEvent_nat_changed(TrTF1, <<Bin/binary, 10>>, TrUserData) end;
{send_register, TF1} -> begin TrTF1 = id(TF1, TrUserData), e_mfield_SDLEvent_send_register(TrTF1, <<Bin/binary, 18>>, TrUserData) end;
{shutdown, TF1} -> begin TrTF1 = id(TF1, TrUserData), e_mfield_SDLEvent_shutdown(TrTF1, <<Bin/binary, 26>>, TrUserData) end
end
end.
'encode_msg_SDLCommand.ExitNodeControl'(Msg, TrUserData) -> 'encode_msg_SDLCommand.ExitNodeControl'(Msg, <<>>, TrUserData).
'encode_msg_SDLCommand.ExitNodeControl'(#'SDLCommand.ExitNodeControl'{action = F1, node_mac = F2, node_ip = F3, remark = F4}, Bin, TrUserData) ->
B1 = if F1 == undefined -> Bin; B1 = if F1 == undefined -> Bin;
true -> true ->
begin begin
@ -724,17 +738,63 @@ encode_msg_SDLPolicyResponse(#'SDLPolicyResponse'{src_identity_id = F1, dst_iden
end end
end. end.
encode_msg_SDLEvent(Msg, TrUserData) -> encode_msg_SDLEvent(Msg, <<>>, TrUserData). encode_msg_SDLCommand(Msg, TrUserData) -> encode_msg_SDLCommand(Msg, <<>>, TrUserData).
encode_msg_SDLEvent(#'SDLEvent'{event = F1}, Bin, TrUserData) -> encode_msg_SDLCommand(#'SDLCommand'{pkt_id = F1, command = F2}, Bin, TrUserData) ->
if F1 =:= undefined -> Bin; B1 = if F1 == undefined -> Bin;
true ->
begin
TrF1 = id(F1, TrUserData),
if TrF1 =:= 0 -> Bin;
true -> e_varint(TrF1, <<Bin/binary, 8>>, TrUserData)
end
end
end,
if F2 =:= undefined -> B1;
true -> case id(F2, TrUserData) of {exit_node, TF2} -> begin TrTF2 = id(TF2, TrUserData), e_mfield_SDLCommand_exit_node(TrTF2, <<B1/binary, 18>>, TrUserData) end end
end.
encode_msg_SDLCommandAck(Msg, TrUserData) -> encode_msg_SDLCommandAck(Msg, <<>>, TrUserData).
encode_msg_SDLCommandAck(#'SDLCommandAck'{pkt_id = F1, code = F2, message = F3, data = F4}, Bin, TrUserData) ->
B1 = if F1 == undefined -> Bin;
true ->
begin
TrF1 = id(F1, TrUserData),
if TrF1 =:= 0 -> Bin;
true -> e_varint(TrF1, <<Bin/binary, 8>>, TrUserData)
end
end
end,
B2 = if F2 == undefined -> B1;
true ->
begin
TrF2 = id(F2, TrUserData),
if TrF2 =:= 0 -> B1;
true -> e_type_int32(TrF2, <<B1/binary, 16>>, TrUserData)
end
end
end,
B3 = if F3 == undefined -> B2;
true ->
begin
TrF3 = id(F3, TrUserData),
case is_empty_string(TrF3) of
true -> B2;
false -> e_type_string(TrF3, <<B2/binary, 26>>, TrUserData)
end
end
end,
if F4 == undefined -> B3;
true -> true ->
case id(F1, TrUserData) of begin
{nat_changed, TF1} -> begin TrTF1 = id(TF1, TrUserData), e_mfield_SDLEvent_nat_changed(TrTF1, <<Bin/binary, 10>>, TrUserData) end; TrF4 = id(F4, TrUserData),
{send_register, TF1} -> begin TrTF1 = id(TF1, TrUserData), e_mfield_SDLEvent_send_register(TrTF1, <<Bin/binary, 18>>, TrUserData) end; case iolist_size(TrF4) of
{shutdown, TF1} -> begin TrTF1 = id(TF1, TrUserData), e_mfield_SDLEvent_shutdown(TrTF1, <<Bin/binary, 26>>, TrUserData) end; 0 -> B3;
{exit_node, TF1} -> begin TrTF1 = id(TF1, TrUserData), e_mfield_SDLEvent_exit_node(TrTF1, <<Bin/binary, 34>>, TrUserData) end _ -> e_type_bytes(TrF4, <<B3/binary, 34>>, TrUserData)
end
end end
end. end.
@ -1057,8 +1117,8 @@ e_mfield_SDLEvent_shutdown(Msg, Bin, TrUserData) ->
Bin2 = e_varint(byte_size(SubBin), Bin), Bin2 = e_varint(byte_size(SubBin), Bin),
<<Bin2/binary, SubBin/binary>>. <<Bin2/binary, SubBin/binary>>.
e_mfield_SDLEvent_exit_node(Msg, Bin, TrUserData) -> e_mfield_SDLCommand_exit_node(Msg, Bin, TrUserData) ->
SubBin = 'encode_msg_SDLEvent.ExitNodeControl'(Msg, <<>>, TrUserData), SubBin = 'encode_msg_SDLCommand.ExitNodeControl'(Msg, <<>>, TrUserData),
Bin2 = e_varint(byte_size(SubBin), Bin), Bin2 = e_varint(byte_size(SubBin), Bin),
<<Bin2/binary, SubBin/binary>>. <<Bin2/binary, SubBin/binary>>.
@ -1205,7 +1265,6 @@ decode_msg_1_catch(Bin, MsgName, TrUserData) ->
end. end.
-endif. -endif.
decode_msg_2_doit('Hello', Bin, TrUserData) -> id(decode_msg_Hello(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLV4Info', Bin, TrUserData) -> id(decode_msg_SDLV4Info(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLV4Info', Bin, TrUserData) -> id(decode_msg_SDLV4Info(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLV6Info', Bin, TrUserData) -> id(decode_msg_SDLV6Info(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLV6Info', Bin, TrUserData) -> id(decode_msg_SDLV6Info(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLWelcome', Bin, TrUserData) -> id(decode_msg_SDLWelcome(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLWelcome', Bin, TrUserData) -> id(decode_msg_SDLWelcome(Bin, TrUserData), TrUserData);
@ -1221,8 +1280,10 @@ decode_msg_2_doit('SDLPolicyResponse', Bin, TrUserData) -> id(decode_msg_SDLPoli
decode_msg_2_doit('SDLEvent.NatChanged', Bin, TrUserData) -> id('decode_msg_SDLEvent.NatChanged'(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLEvent.NatChanged', Bin, TrUserData) -> id('decode_msg_SDLEvent.NatChanged'(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLEvent.SendRegister', Bin, TrUserData) -> id('decode_msg_SDLEvent.SendRegister'(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLEvent.SendRegister', Bin, TrUserData) -> id('decode_msg_SDLEvent.SendRegister'(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLEvent.NetworkShutdown', Bin, TrUserData) -> id('decode_msg_SDLEvent.NetworkShutdown'(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLEvent.NetworkShutdown', Bin, TrUserData) -> id('decode_msg_SDLEvent.NetworkShutdown'(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLEvent.ExitNodeControl', Bin, TrUserData) -> id('decode_msg_SDLEvent.ExitNodeControl'(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLEvent', Bin, TrUserData) -> id(decode_msg_SDLEvent(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLEvent', Bin, TrUserData) -> id(decode_msg_SDLEvent(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLCommand.ExitNodeControl', Bin, TrUserData) -> id('decode_msg_SDLCommand.ExitNodeControl'(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLCommand', Bin, TrUserData) -> id(decode_msg_SDLCommand(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLCommandAck', Bin, TrUserData) -> id(decode_msg_SDLCommandAck(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLStunRequest', Bin, TrUserData) -> id(decode_msg_SDLStunRequest(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLStunRequest', Bin, TrUserData) -> id(decode_msg_SDLStunRequest(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLStunReply', Bin, TrUserData) -> id(decode_msg_SDLStunReply(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLStunReply', Bin, TrUserData) -> id(decode_msg_SDLStunReply(Bin, TrUserData), TrUserData);
decode_msg_2_doit('SDLData', Bin, TrUserData) -> id(decode_msg_SDLData(Bin, TrUserData), TrUserData); decode_msg_2_doit('SDLData', Bin, TrUserData) -> id(decode_msg_SDLData(Bin, TrUserData), TrUserData);
@ -1233,40 +1294,6 @@ decode_msg_2_doit('SDLRegisterAck', Bin, TrUserData) -> id(decode_msg_SDLRegiste
decode_msg_Hello(Bin, TrUserData) -> dfp_read_field_def_Hello(Bin, 0, 0, 0, TrUserData).
dfp_read_field_def_Hello(<<>>, 0, 0, _, _) -> #'Hello'{};
dfp_read_field_def_Hello(Other, Z1, Z2, F, TrUserData) -> dg_read_field_def_Hello(Other, Z1, Z2, F, TrUserData).
dg_read_field_def_Hello(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 32 - 7 -> dg_read_field_def_Hello(Rest, N + 7, X bsl N + Acc, F, TrUserData);
dg_read_field_def_Hello(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) ->
Key = X bsl N + Acc,
case Key band 7 of
0 -> skip_varint_Hello(Rest, 0, 0, Key bsr 3, TrUserData);
1 -> skip_64_Hello(Rest, 0, 0, Key bsr 3, TrUserData);
2 -> skip_length_delimited_Hello(Rest, 0, 0, Key bsr 3, TrUserData);
3 -> skip_group_Hello(Rest, 0, 0, Key bsr 3, TrUserData);
5 -> skip_32_Hello(Rest, 0, 0, Key bsr 3, TrUserData)
end;
dg_read_field_def_Hello(<<>>, 0, 0, _, _) -> #'Hello'{}.
skip_varint_Hello(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> skip_varint_Hello(Rest, Z1, Z2, F, TrUserData);
skip_varint_Hello(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_Hello(Rest, Z1, Z2, F, TrUserData).
skip_length_delimited_Hello(<<1:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) when N < 57 -> skip_length_delimited_Hello(Rest, N + 7, X bsl N + Acc, F, TrUserData);
skip_length_delimited_Hello(<<0:1, X:7, Rest/binary>>, N, Acc, F, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_Hello(Rest2, 0, 0, F, TrUserData).
skip_group_Hello(Bin, _, Z2, FNum, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_Hello(Rest, 0, Z2, FNum, TrUserData).
skip_32_Hello(<<_:32, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_Hello(Rest, Z1, Z2, F, TrUserData).
skip_64_Hello(<<_:64, Rest/binary>>, Z1, Z2, F, TrUserData) -> dfp_read_field_def_Hello(Rest, Z1, Z2, F, TrUserData).
decode_msg_SDLV4Info(Bin, TrUserData) -> dfp_read_field_def_SDLV4Info(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData). decode_msg_SDLV4Info(Bin, TrUserData) -> dfp_read_field_def_SDLV4Info(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), TrUserData).
dfp_read_field_def_SDLV4Info(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_SDLV4Info_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_SDLV4Info(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData) -> d_field_SDLV4Info_port(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, TrUserData);
@ -2209,78 +2236,11 @@ skip_64_SDLPolicyResponse(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@
'skip_64_SDLEvent.NetworkShutdown'(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> 'dfp_read_field_def_SDLEvent.NetworkShutdown'(Rest, Z1, Z2, F, F@_1, TrUserData). 'skip_64_SDLEvent.NetworkShutdown'(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> 'dfp_read_field_def_SDLEvent.NetworkShutdown'(Rest, Z1, Z2, F, F@_1, TrUserData).
'decode_msg_SDLEvent.ExitNodeControl'(Bin, TrUserData) -> 'dfp_read_field_def_SDLEvent.ExitNodeControl'(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), TrUserData).
'dfp_read_field_def_SDLEvent.ExitNodeControl'(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'd_field_SDLEvent.ExitNodeControl_action'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dfp_read_field_def_SDLEvent.ExitNodeControl'(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'd_field_SDLEvent.ExitNodeControl_node_mac'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dfp_read_field_def_SDLEvent.ExitNodeControl'(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'd_field_SDLEvent.ExitNodeControl_node_ip'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dfp_read_field_def_SDLEvent.ExitNodeControl'(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'd_field_SDLEvent.ExitNodeControl_remark'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dfp_read_field_def_SDLEvent.ExitNodeControl'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #'SDLEvent.ExitNodeControl'{action = F@_1, node_mac = F@_2, node_ip = F@_3, remark = F@_4};
'dfp_read_field_def_SDLEvent.ExitNodeControl'(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'dg_read_field_def_SDLEvent.ExitNodeControl'(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
'dg_read_field_def_SDLEvent.ExitNodeControl'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> 'dg_read_field_def_SDLEvent.ExitNodeControl'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dg_read_field_def_SDLEvent.ExitNodeControl'(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
Key = X bsl N + Acc,
case Key of
8 -> 'd_field_SDLEvent.ExitNodeControl_action'(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
18 -> 'd_field_SDLEvent.ExitNodeControl_node_mac'(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
24 -> 'd_field_SDLEvent.ExitNodeControl_node_ip'(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
34 -> 'd_field_SDLEvent.ExitNodeControl_remark'(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
_ ->
case Key band 7 of
0 -> 'skip_varint_SDLEvent.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
1 -> 'skip_64_SDLEvent.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
2 -> 'skip_length_delimited_SDLEvent.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
3 -> 'skip_group_SDLEvent.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
5 -> 'skip_32_SDLEvent.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData)
end
end;
'dg_read_field_def_SDLEvent.ExitNodeControl'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #'SDLEvent.ExitNodeControl'{action = F@_1, node_mac = F@_2, node_ip = F@_3, remark = F@_4}.
'd_field_SDLEvent.ExitNodeControl_action'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> 'd_field_SDLEvent.ExitNodeControl_action'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'd_field_SDLEvent.ExitNodeControl_action'(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) ->
{NewFValue, RestF} = {begin <<Res:32/signed-native>> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest},
'dfp_read_field_def_SDLEvent.ExitNodeControl'(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData).
'd_field_SDLEvent.ExitNodeControl_node_mac'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> 'd_field_SDLEvent.ExitNodeControl_node_mac'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'd_field_SDLEvent.ExitNodeControl_node_mac'(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
'dfp_read_field_def_SDLEvent.ExitNodeControl'(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData).
'd_field_SDLEvent.ExitNodeControl_node_ip'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> 'd_field_SDLEvent.ExitNodeControl_node_ip'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'd_field_SDLEvent.ExitNodeControl_node_ip'(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) ->
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
'dfp_read_field_def_SDLEvent.ExitNodeControl'(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData).
'd_field_SDLEvent.ExitNodeControl_remark'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> 'd_field_SDLEvent.ExitNodeControl_remark'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'd_field_SDLEvent.ExitNodeControl_remark'(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
'dfp_read_field_def_SDLEvent.ExitNodeControl'(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData).
'skip_varint_SDLEvent.ExitNodeControl'(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'skip_varint_SDLEvent.ExitNodeControl'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'skip_varint_SDLEvent.ExitNodeControl'(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'dfp_read_field_def_SDLEvent.ExitNodeControl'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
'skip_length_delimited_SDLEvent.ExitNodeControl'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 ->
'skip_length_delimited_SDLEvent.ExitNodeControl'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'skip_length_delimited_SDLEvent.ExitNodeControl'(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
'dfp_read_field_def_SDLEvent.ExitNodeControl'(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
'skip_group_SDLEvent.ExitNodeControl'(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
'dfp_read_field_def_SDLEvent.ExitNodeControl'(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData).
'skip_32_SDLEvent.ExitNodeControl'(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'dfp_read_field_def_SDLEvent.ExitNodeControl'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
'skip_64_SDLEvent.ExitNodeControl'(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'dfp_read_field_def_SDLEvent.ExitNodeControl'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
decode_msg_SDLEvent(Bin, TrUserData) -> dfp_read_field_def_SDLEvent(Bin, 0, 0, 0, id(undefined, TrUserData), TrUserData). decode_msg_SDLEvent(Bin, TrUserData) -> dfp_read_field_def_SDLEvent(Bin, 0, 0, 0, id(undefined, TrUserData), TrUserData).
dfp_read_field_def_SDLEvent(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_SDLEvent_nat_changed(Rest, Z1, Z2, F, F@_1, TrUserData); dfp_read_field_def_SDLEvent(<<10, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_SDLEvent_nat_changed(Rest, Z1, Z2, F, F@_1, TrUserData);
dfp_read_field_def_SDLEvent(<<18, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_SDLEvent_send_register(Rest, Z1, Z2, F, F@_1, TrUserData); dfp_read_field_def_SDLEvent(<<18, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_SDLEvent_send_register(Rest, Z1, Z2, F, F@_1, TrUserData);
dfp_read_field_def_SDLEvent(<<26, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_SDLEvent_shutdown(Rest, Z1, Z2, F, F@_1, TrUserData); dfp_read_field_def_SDLEvent(<<26, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_SDLEvent_shutdown(Rest, Z1, Z2, F, F@_1, TrUserData);
dfp_read_field_def_SDLEvent(<<34, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> d_field_SDLEvent_exit_node(Rest, Z1, Z2, F, F@_1, TrUserData);
dfp_read_field_def_SDLEvent(<<>>, 0, 0, _, F@_1, _) -> #'SDLEvent'{event = F@_1}; dfp_read_field_def_SDLEvent(<<>>, 0, 0, _, F@_1, _) -> #'SDLEvent'{event = F@_1};
dfp_read_field_def_SDLEvent(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_SDLEvent(Other, Z1, Z2, F, F@_1, TrUserData). dfp_read_field_def_SDLEvent(Other, Z1, Z2, F, F@_1, TrUserData) -> dg_read_field_def_SDLEvent(Other, Z1, Z2, F, F@_1, TrUserData).
@ -2291,7 +2251,6 @@ dg_read_field_def_SDLEvent(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, TrUserDat
10 -> d_field_SDLEvent_nat_changed(Rest, 0, 0, 0, F@_1, TrUserData); 10 -> d_field_SDLEvent_nat_changed(Rest, 0, 0, 0, F@_1, TrUserData);
18 -> d_field_SDLEvent_send_register(Rest, 0, 0, 0, F@_1, TrUserData); 18 -> d_field_SDLEvent_send_register(Rest, 0, 0, 0, F@_1, TrUserData);
26 -> d_field_SDLEvent_shutdown(Rest, 0, 0, 0, F@_1, TrUserData); 26 -> d_field_SDLEvent_shutdown(Rest, 0, 0, 0, F@_1, TrUserData);
34 -> d_field_SDLEvent_exit_node(Rest, 0, 0, 0, F@_1, TrUserData);
_ -> _ ->
case Key band 7 of case Key band 7 of
0 -> skip_varint_SDLEvent(Rest, 0, 0, Key bsr 3, F@_1, TrUserData); 0 -> skip_varint_SDLEvent(Rest, 0, 0, Key bsr 3, F@_1, TrUserData);
@ -2345,20 +2304,6 @@ d_field_SDLEvent_shutdown(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData
end, end,
TrUserData). TrUserData).
d_field_SDLEvent_exit_node(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, TrUserData) when N < 57 -> d_field_SDLEvent_exit_node(Rest, N + 7, X bsl N + Acc, F, F@_1, TrUserData);
d_field_SDLEvent_exit_node(<<0:1, X:7, Rest/binary>>, N, Acc, F, Prev, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bs:Len/binary, Rest2/binary>> = Rest, {id('decode_msg_SDLEvent.ExitNodeControl'(Bs, TrUserData), TrUserData), Rest2} end,
dfp_read_field_def_SDLEvent(RestF,
0,
0,
F,
case Prev of
undefined -> id({exit_node, NewFValue}, TrUserData);
{exit_node, MVPrev} -> id({exit_node, 'merge_msg_SDLEvent.ExitNodeControl'(MVPrev, NewFValue, TrUserData)}, TrUserData);
_ -> id({exit_node, NewFValue}, TrUserData)
end,
TrUserData).
skip_varint_SDLEvent(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_SDLEvent(Rest, Z1, Z2, F, F@_1, TrUserData); skip_varint_SDLEvent(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> skip_varint_SDLEvent(Rest, Z1, Z2, F, F@_1, TrUserData);
skip_varint_SDLEvent(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_SDLEvent(Rest, Z1, Z2, F, F@_1, TrUserData). skip_varint_SDLEvent(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_SDLEvent(Rest, Z1, Z2, F, F@_1, TrUserData).
@ -2376,6 +2321,199 @@ skip_32_SDLEvent(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read
skip_64_SDLEvent(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_SDLEvent(Rest, Z1, Z2, F, F@_1, TrUserData). skip_64_SDLEvent(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, TrUserData) -> dfp_read_field_def_SDLEvent(Rest, Z1, Z2, F, F@_1, TrUserData).
'decode_msg_SDLCommand.ExitNodeControl'(Bin, TrUserData) -> 'dfp_read_field_def_SDLCommand.ExitNodeControl'(Bin, 0, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), TrUserData).
'dfp_read_field_def_SDLCommand.ExitNodeControl'(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'd_field_SDLCommand.ExitNodeControl_action'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dfp_read_field_def_SDLCommand.ExitNodeControl'(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'd_field_SDLCommand.ExitNodeControl_node_mac'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dfp_read_field_def_SDLCommand.ExitNodeControl'(<<24, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'd_field_SDLCommand.ExitNodeControl_node_ip'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dfp_read_field_def_SDLCommand.ExitNodeControl'(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'd_field_SDLCommand.ExitNodeControl_remark'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dfp_read_field_def_SDLCommand.ExitNodeControl'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #'SDLCommand.ExitNodeControl'{action = F@_1, node_mac = F@_2, node_ip = F@_3, remark = F@_4};
'dfp_read_field_def_SDLCommand.ExitNodeControl'(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'dg_read_field_def_SDLCommand.ExitNodeControl'(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
'dg_read_field_def_SDLCommand.ExitNodeControl'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 ->
'dg_read_field_def_SDLCommand.ExitNodeControl'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'dg_read_field_def_SDLCommand.ExitNodeControl'(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
Key = X bsl N + Acc,
case Key of
8 -> 'd_field_SDLCommand.ExitNodeControl_action'(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
18 -> 'd_field_SDLCommand.ExitNodeControl_node_mac'(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
24 -> 'd_field_SDLCommand.ExitNodeControl_node_ip'(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
34 -> 'd_field_SDLCommand.ExitNodeControl_remark'(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
_ ->
case Key band 7 of
0 -> 'skip_varint_SDLCommand.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
1 -> 'skip_64_SDLCommand.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
2 -> 'skip_length_delimited_SDLCommand.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
3 -> 'skip_group_SDLCommand.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
5 -> 'skip_32_SDLCommand.ExitNodeControl'(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData)
end
end;
'dg_read_field_def_SDLCommand.ExitNodeControl'(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #'SDLCommand.ExitNodeControl'{action = F@_1, node_mac = F@_2, node_ip = F@_3, remark = F@_4}.
'd_field_SDLCommand.ExitNodeControl_action'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> 'd_field_SDLCommand.ExitNodeControl_action'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'd_field_SDLCommand.ExitNodeControl_action'(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) ->
{NewFValue, RestF} = {begin <<Res:32/signed-native>> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest},
'dfp_read_field_def_SDLCommand.ExitNodeControl'(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData).
'd_field_SDLCommand.ExitNodeControl_node_mac'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> 'd_field_SDLCommand.ExitNodeControl_node_mac'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'd_field_SDLCommand.ExitNodeControl_node_mac'(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
'dfp_read_field_def_SDLCommand.ExitNodeControl'(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData).
'd_field_SDLCommand.ExitNodeControl_node_ip'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> 'd_field_SDLCommand.ExitNodeControl_node_ip'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'd_field_SDLCommand.ExitNodeControl_node_ip'(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) ->
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
'dfp_read_field_def_SDLCommand.ExitNodeControl'(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData).
'd_field_SDLCommand.ExitNodeControl_remark'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> 'd_field_SDLCommand.ExitNodeControl_remark'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'd_field_SDLCommand.ExitNodeControl_remark'(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
'dfp_read_field_def_SDLCommand.ExitNodeControl'(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData).
'skip_varint_SDLCommand.ExitNodeControl'(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'skip_varint_SDLCommand.ExitNodeControl'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'skip_varint_SDLCommand.ExitNodeControl'(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'dfp_read_field_def_SDLCommand.ExitNodeControl'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
'skip_length_delimited_SDLCommand.ExitNodeControl'(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 ->
'skip_length_delimited_SDLCommand.ExitNodeControl'(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
'skip_length_delimited_SDLCommand.ExitNodeControl'(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
'dfp_read_field_def_SDLCommand.ExitNodeControl'(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
'skip_group_SDLCommand.ExitNodeControl'(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
'dfp_read_field_def_SDLCommand.ExitNodeControl'(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData).
'skip_32_SDLCommand.ExitNodeControl'(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'dfp_read_field_def_SDLCommand.ExitNodeControl'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
'skip_64_SDLCommand.ExitNodeControl'(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> 'dfp_read_field_def_SDLCommand.ExitNodeControl'(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
decode_msg_SDLCommand(Bin, TrUserData) -> dfp_read_field_def_SDLCommand(Bin, 0, 0, 0, id(0, TrUserData), id(undefined, TrUserData), TrUserData).
dfp_read_field_def_SDLCommand(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_SDLCommand_pkt_id(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
dfp_read_field_def_SDLCommand(<<18, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> d_field_SDLCommand_exit_node(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
dfp_read_field_def_SDLCommand(<<>>, 0, 0, _, F@_1, F@_2, _) -> #'SDLCommand'{pkt_id = F@_1, command = F@_2};
dfp_read_field_def_SDLCommand(Other, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dg_read_field_def_SDLCommand(Other, Z1, Z2, F, F@_1, F@_2, TrUserData).
dg_read_field_def_SDLCommand(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_SDLCommand(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
dg_read_field_def_SDLCommand(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, TrUserData) ->
Key = X bsl N + Acc,
case Key of
8 -> d_field_SDLCommand_pkt_id(Rest, 0, 0, 0, F@_1, F@_2, TrUserData);
18 -> d_field_SDLCommand_exit_node(Rest, 0, 0, 0, F@_1, F@_2, TrUserData);
_ ->
case Key band 7 of
0 -> skip_varint_SDLCommand(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
1 -> skip_64_SDLCommand(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
2 -> skip_length_delimited_SDLCommand(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
3 -> skip_group_SDLCommand(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData);
5 -> skip_32_SDLCommand(Rest, 0, 0, Key bsr 3, F@_1, F@_2, TrUserData)
end
end;
dg_read_field_def_SDLCommand(<<>>, 0, 0, _, F@_1, F@_2, _) -> #'SDLCommand'{pkt_id = F@_1, command = F@_2}.
d_field_SDLCommand_pkt_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_SDLCommand_pkt_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
d_field_SDLCommand_pkt_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, TrUserData) ->
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
dfp_read_field_def_SDLCommand(RestF, 0, 0, F, NewFValue, F@_2, TrUserData).
d_field_SDLCommand_exit_node(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> d_field_SDLCommand_exit_node(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
d_field_SDLCommand_exit_node(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, Prev, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bs:Len/binary, Rest2/binary>> = Rest, {id('decode_msg_SDLCommand.ExitNodeControl'(Bs, TrUserData), TrUserData), Rest2} end,
dfp_read_field_def_SDLCommand(RestF,
0,
0,
F,
F@_1,
case Prev of
undefined -> id({exit_node, NewFValue}, TrUserData);
{exit_node, MVPrev} -> id({exit_node, 'merge_msg_SDLCommand.ExitNodeControl'(MVPrev, NewFValue, TrUserData)}, TrUserData);
_ -> id({exit_node, NewFValue}, TrUserData)
end,
TrUserData).
skip_varint_SDLCommand(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> skip_varint_SDLCommand(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData);
skip_varint_SDLCommand(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_SDLCommand(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
skip_length_delimited_SDLCommand(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_SDLCommand(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, TrUserData);
skip_length_delimited_SDLCommand(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_SDLCommand(Rest2, 0, 0, F, F@_1, F@_2, TrUserData).
skip_group_SDLCommand(Bin, _, Z2, FNum, F@_1, F@_2, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_SDLCommand(Rest, 0, Z2, FNum, F@_1, F@_2, TrUserData).
skip_32_SDLCommand(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_SDLCommand(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
skip_64_SDLCommand(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, TrUserData) -> dfp_read_field_def_SDLCommand(Rest, Z1, Z2, F, F@_1, F@_2, TrUserData).
decode_msg_SDLCommandAck(Bin, TrUserData) -> dfp_read_field_def_SDLCommandAck(Bin, 0, 0, 0, id(0, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData).
dfp_read_field_def_SDLCommandAck(<<8, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_SDLCommandAck_pkt_id(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
dfp_read_field_def_SDLCommandAck(<<16, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_SDLCommandAck_code(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
dfp_read_field_def_SDLCommandAck(<<26, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_SDLCommandAck_message(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
dfp_read_field_def_SDLCommandAck(<<34, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_SDLCommandAck_data(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
dfp_read_field_def_SDLCommandAck(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #'SDLCommandAck'{pkt_id = F@_1, code = F@_2, message = F@_3, data = F@_4};
dfp_read_field_def_SDLCommandAck(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_SDLCommandAck(Other, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
dg_read_field_def_SDLCommandAck(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_SDLCommandAck(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
dg_read_field_def_SDLCommandAck(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
Key = X bsl N + Acc,
case Key of
8 -> d_field_SDLCommandAck_pkt_id(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
16 -> d_field_SDLCommandAck_code(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
26 -> d_field_SDLCommandAck_message(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
34 -> d_field_SDLCommandAck_data(Rest, 0, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData);
_ ->
case Key band 7 of
0 -> skip_varint_SDLCommandAck(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
1 -> skip_64_SDLCommandAck(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
2 -> skip_length_delimited_SDLCommandAck(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
3 -> skip_group_SDLCommandAck(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData);
5 -> skip_32_SDLCommandAck(Rest, 0, 0, Key bsr 3, F@_1, F@_2, F@_3, F@_4, TrUserData)
end
end;
dg_read_field_def_SDLCommandAck(<<>>, 0, 0, _, F@_1, F@_2, F@_3, F@_4, _) -> #'SDLCommandAck'{pkt_id = F@_1, code = F@_2, message = F@_3, data = F@_4}.
d_field_SDLCommandAck_pkt_id(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_SDLCommandAck_pkt_id(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
d_field_SDLCommandAck_pkt_id(<<0:1, X:7, Rest/binary>>, N, Acc, F, _, F@_2, F@_3, F@_4, TrUserData) ->
{NewFValue, RestF} = {id((X bsl N + Acc) band 4294967295, TrUserData), Rest},
dfp_read_field_def_SDLCommandAck(RestF, 0, 0, F, NewFValue, F@_2, F@_3, F@_4, TrUserData).
d_field_SDLCommandAck_code(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_SDLCommandAck_code(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
d_field_SDLCommandAck_code(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, _, F@_3, F@_4, TrUserData) ->
{NewFValue, RestF} = {begin <<Res:32/signed-native>> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest},
dfp_read_field_def_SDLCommandAck(RestF, 0, 0, F, F@_1, NewFValue, F@_3, F@_4, TrUserData).
d_field_SDLCommandAck_message(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_SDLCommandAck_message(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
d_field_SDLCommandAck_message(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, _, F@_4, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
dfp_read_field_def_SDLCommandAck(RestF, 0, 0, F, F@_1, F@_2, NewFValue, F@_4, TrUserData).
d_field_SDLCommandAck_data(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_SDLCommandAck_data(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
d_field_SDLCommandAck_data(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, _, TrUserData) ->
{NewFValue, RestF} = begin Len = X bsl N + Acc, <<Bytes:Len/binary, Rest2/binary>> = Rest, Bytes2 = binary:copy(Bytes), {id(Bytes2, TrUserData), Rest2} end,
dfp_read_field_def_SDLCommandAck(RestF, 0, 0, F, F@_1, F@_2, F@_3, NewFValue, TrUserData).
skip_varint_SDLCommandAck(<<1:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_SDLCommandAck(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
skip_varint_SDLCommandAck(<<0:1, _:7, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_SDLCommandAck(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
skip_length_delimited_SDLCommandAck(<<1:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_SDLCommandAck(Rest, N + 7, X bsl N + Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData);
skip_length_delimited_SDLCommandAck(<<0:1, X:7, Rest/binary>>, N, Acc, F, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
Length = X bsl N + Acc,
<<_:Length/binary, Rest2/binary>> = Rest,
dfp_read_field_def_SDLCommandAck(Rest2, 0, 0, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
skip_group_SDLCommandAck(Bin, _, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
{_, Rest} = read_group(Bin, FNum),
dfp_read_field_def_SDLCommandAck(Rest, 0, Z2, FNum, F@_1, F@_2, F@_3, F@_4, TrUserData).
skip_32_SDLCommandAck(<<_:32, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_SDLCommandAck(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
skip_64_SDLCommandAck(<<_:64, Rest/binary>>, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_SDLCommandAck(Rest, Z1, Z2, F, F@_1, F@_2, F@_3, F@_4, TrUserData).
decode_msg_SDLStunRequest(Bin, TrUserData) -> decode_msg_SDLStunRequest(Bin, TrUserData) ->
dfp_read_field_def_SDLStunRequest(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), id(0, TrUserData), id(undefined, TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_SDLStunRequest(Bin, 0, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), id(<<>>, TrUserData), id(0, TrUserData), id(0, TrUserData), id(undefined, TrUserData), id(<<>>, TrUserData), TrUserData).
@ -2923,7 +3061,6 @@ merge_msgs(Prev, New, Opts) when element(1, Prev) =:= element(1, New), is_list(O
merge_msgs(Prev, New, MsgName, Opts) -> merge_msgs(Prev, New, MsgName, Opts) ->
TrUserData = proplists:get_value(user_data, Opts), TrUserData = proplists:get_value(user_data, Opts),
case MsgName of case MsgName of
'Hello' -> merge_msg_Hello(Prev, New, TrUserData);
'SDLV4Info' -> merge_msg_SDLV4Info(Prev, New, TrUserData); 'SDLV4Info' -> merge_msg_SDLV4Info(Prev, New, TrUserData);
'SDLV6Info' -> merge_msg_SDLV6Info(Prev, New, TrUserData); 'SDLV6Info' -> merge_msg_SDLV6Info(Prev, New, TrUserData);
'SDLWelcome' -> merge_msg_SDLWelcome(Prev, New, TrUserData); 'SDLWelcome' -> merge_msg_SDLWelcome(Prev, New, TrUserData);
@ -2939,8 +3076,10 @@ merge_msgs(Prev, New, MsgName, Opts) ->
'SDLEvent.NatChanged' -> 'merge_msg_SDLEvent.NatChanged'(Prev, New, TrUserData); 'SDLEvent.NatChanged' -> 'merge_msg_SDLEvent.NatChanged'(Prev, New, TrUserData);
'SDLEvent.SendRegister' -> 'merge_msg_SDLEvent.SendRegister'(Prev, New, TrUserData); 'SDLEvent.SendRegister' -> 'merge_msg_SDLEvent.SendRegister'(Prev, New, TrUserData);
'SDLEvent.NetworkShutdown' -> 'merge_msg_SDLEvent.NetworkShutdown'(Prev, New, TrUserData); 'SDLEvent.NetworkShutdown' -> 'merge_msg_SDLEvent.NetworkShutdown'(Prev, New, TrUserData);
'SDLEvent.ExitNodeControl' -> 'merge_msg_SDLEvent.ExitNodeControl'(Prev, New, TrUserData);
'SDLEvent' -> merge_msg_SDLEvent(Prev, New, TrUserData); 'SDLEvent' -> merge_msg_SDLEvent(Prev, New, TrUserData);
'SDLCommand.ExitNodeControl' -> 'merge_msg_SDLCommand.ExitNodeControl'(Prev, New, TrUserData);
'SDLCommand' -> merge_msg_SDLCommand(Prev, New, TrUserData);
'SDLCommandAck' -> merge_msg_SDLCommandAck(Prev, New, TrUserData);
'SDLStunRequest' -> merge_msg_SDLStunRequest(Prev, New, TrUserData); 'SDLStunRequest' -> merge_msg_SDLStunRequest(Prev, New, TrUserData);
'SDLStunReply' -> merge_msg_SDLStunReply(Prev, New, TrUserData); 'SDLStunReply' -> merge_msg_SDLStunReply(Prev, New, TrUserData);
'SDLData' -> merge_msg_SDLData(Prev, New, TrUserData); 'SDLData' -> merge_msg_SDLData(Prev, New, TrUserData);
@ -2950,9 +3089,6 @@ merge_msgs(Prev, New, MsgName, Opts) ->
'SDLRegisterAck' -> merge_msg_SDLRegisterAck(Prev, New, TrUserData) 'SDLRegisterAck' -> merge_msg_SDLRegisterAck(Prev, New, TrUserData)
end. end.
-compile({nowarn_unused_function,merge_msg_Hello/3}).
merge_msg_Hello(_Prev, New, _TrUserData) -> New.
-compile({nowarn_unused_function,merge_msg_SDLV4Info/3}). -compile({nowarn_unused_function,merge_msg_SDLV4Info/3}).
merge_msg_SDLV4Info(#'SDLV4Info'{port = PFport, v4 = PFv4, nat_type = PFnat_type}, #'SDLV4Info'{port = NFport, v4 = NFv4, nat_type = NFnat_type}, _) -> merge_msg_SDLV4Info(#'SDLV4Info'{port = PFport, v4 = PFv4, nat_type = PFnat_type}, #'SDLV4Info'{port = NFport, v4 = NFv4, nat_type = NFnat_type}, _) ->
#'SDLV4Info'{port = #'SDLV4Info'{port =
@ -3204,26 +3340,6 @@ merge_msg_SDLPolicyResponse(#'SDLPolicyResponse'{src_identity_id = PFsrc_identit
true -> NFmessage true -> NFmessage
end}. end}.
-compile({nowarn_unused_function,'merge_msg_SDLEvent.ExitNodeControl'/3}).
'merge_msg_SDLEvent.ExitNodeControl'(#'SDLEvent.ExitNodeControl'{action = PFaction, node_mac = PFnode_mac, node_ip = PFnode_ip, remark = PFremark},
#'SDLEvent.ExitNodeControl'{action = NFaction, node_mac = NFnode_mac, node_ip = NFnode_ip, remark = NFremark}, _) ->
#'SDLEvent.ExitNodeControl'{action =
if NFaction =:= undefined -> PFaction;
true -> NFaction
end,
node_mac =
if NFnode_mac =:= undefined -> PFnode_mac;
true -> NFnode_mac
end,
node_ip =
if NFnode_ip =:= undefined -> PFnode_ip;
true -> NFnode_ip
end,
remark =
if NFremark =:= undefined -> PFremark;
true -> NFremark
end}.
-compile({nowarn_unused_function,merge_msg_SDLEvent/3}). -compile({nowarn_unused_function,merge_msg_SDLEvent/3}).
merge_msg_SDLEvent(#'SDLEvent'{event = PFevent}, #'SDLEvent'{event = NFevent}, TrUserData) -> merge_msg_SDLEvent(#'SDLEvent'{event = PFevent}, #'SDLEvent'{event = NFevent}, TrUserData) ->
#'SDLEvent'{event = #'SDLEvent'{event =
@ -3231,11 +3347,62 @@ merge_msg_SDLEvent(#'SDLEvent'{event = PFevent}, #'SDLEvent'{event = NFevent}, T
{{nat_changed, OPFevent}, {nat_changed, ONFevent}} -> {nat_changed, 'merge_msg_SDLEvent.NatChanged'(OPFevent, ONFevent, TrUserData)}; {{nat_changed, OPFevent}, {nat_changed, ONFevent}} -> {nat_changed, 'merge_msg_SDLEvent.NatChanged'(OPFevent, ONFevent, TrUserData)};
{{send_register, OPFevent}, {send_register, ONFevent}} -> {send_register, 'merge_msg_SDLEvent.SendRegister'(OPFevent, ONFevent, TrUserData)}; {{send_register, OPFevent}, {send_register, ONFevent}} -> {send_register, 'merge_msg_SDLEvent.SendRegister'(OPFevent, ONFevent, TrUserData)};
{{shutdown, OPFevent}, {shutdown, ONFevent}} -> {shutdown, 'merge_msg_SDLEvent.NetworkShutdown'(OPFevent, ONFevent, TrUserData)}; {{shutdown, OPFevent}, {shutdown, ONFevent}} -> {shutdown, 'merge_msg_SDLEvent.NetworkShutdown'(OPFevent, ONFevent, TrUserData)};
{{exit_node, OPFevent}, {exit_node, ONFevent}} -> {exit_node, 'merge_msg_SDLEvent.ExitNodeControl'(OPFevent, ONFevent, TrUserData)};
{_, undefined} -> PFevent; {_, undefined} -> PFevent;
_ -> NFevent _ -> NFevent
end}. end}.
-compile({nowarn_unused_function,'merge_msg_SDLCommand.ExitNodeControl'/3}).
'merge_msg_SDLCommand.ExitNodeControl'(#'SDLCommand.ExitNodeControl'{action = PFaction, node_mac = PFnode_mac, node_ip = PFnode_ip, remark = PFremark},
#'SDLCommand.ExitNodeControl'{action = NFaction, node_mac = NFnode_mac, node_ip = NFnode_ip, remark = NFremark}, _) ->
#'SDLCommand.ExitNodeControl'{action =
if NFaction =:= undefined -> PFaction;
true -> NFaction
end,
node_mac =
if NFnode_mac =:= undefined -> PFnode_mac;
true -> NFnode_mac
end,
node_ip =
if NFnode_ip =:= undefined -> PFnode_ip;
true -> NFnode_ip
end,
remark =
if NFremark =:= undefined -> PFremark;
true -> NFremark
end}.
-compile({nowarn_unused_function,merge_msg_SDLCommand/3}).
merge_msg_SDLCommand(#'SDLCommand'{pkt_id = PFpkt_id, command = PFcommand}, #'SDLCommand'{pkt_id = NFpkt_id, command = NFcommand}, TrUserData) ->
#'SDLCommand'{pkt_id =
if NFpkt_id =:= undefined -> PFpkt_id;
true -> NFpkt_id
end,
command =
case {PFcommand, NFcommand} of
{{exit_node, OPFcommand}, {exit_node, ONFcommand}} -> {exit_node, 'merge_msg_SDLCommand.ExitNodeControl'(OPFcommand, ONFcommand, TrUserData)};
{_, undefined} -> PFcommand;
_ -> NFcommand
end}.
-compile({nowarn_unused_function,merge_msg_SDLCommandAck/3}).
merge_msg_SDLCommandAck(#'SDLCommandAck'{pkt_id = PFpkt_id, code = PFcode, message = PFmessage, data = PFdata}, #'SDLCommandAck'{pkt_id = NFpkt_id, code = NFcode, message = NFmessage, data = NFdata}, _) ->
#'SDLCommandAck'{pkt_id =
if NFpkt_id =:= undefined -> PFpkt_id;
true -> NFpkt_id
end,
code =
if NFcode =:= undefined -> PFcode;
true -> NFcode
end,
message =
if NFmessage =:= undefined -> PFmessage;
true -> NFmessage
end,
data =
if NFdata =:= undefined -> PFdata;
true -> NFdata
end}.
-compile({nowarn_unused_function,merge_msg_SDLStunRequest/3}). -compile({nowarn_unused_function,merge_msg_SDLStunRequest/3}).
merge_msg_SDLStunRequest(#'SDLStunRequest'{client_id = PFclient_id, network_id = PFnetwork_id, mac = PFmac, ip = PFip, nat_type = PFnat_type, v6_info = PFv6_info, session_token = PFsession_token}, merge_msg_SDLStunRequest(#'SDLStunRequest'{client_id = PFclient_id, network_id = PFnetwork_id, mac = PFmac, ip = PFip, nat_type = PFnat_type, v6_info = PFv6_info, session_token = PFsession_token},
#'SDLStunRequest'{client_id = NFclient_id, network_id = NFnetwork_id, mac = NFmac, ip = NFip, nat_type = NFnat_type, v6_info = NFv6_info, session_token = NFsession_token}, TrUserData) -> #'SDLStunRequest'{client_id = NFclient_id, network_id = NFnetwork_id, mac = NFmac, ip = NFip, nat_type = NFnat_type, v6_info = NFv6_info, session_token = NFsession_token}, TrUserData) ->
@ -3383,7 +3550,6 @@ verify_msg(X, _Opts) -> mk_type_error(not_a_known_message, X, []).
verify_msg(Msg, MsgName, Opts) -> verify_msg(Msg, MsgName, Opts) ->
TrUserData = proplists:get_value(user_data, Opts), TrUserData = proplists:get_value(user_data, Opts),
case MsgName of case MsgName of
'Hello' -> v_msg_Hello(Msg, [MsgName], TrUserData);
'SDLV4Info' -> v_msg_SDLV4Info(Msg, [MsgName], TrUserData); 'SDLV4Info' -> v_msg_SDLV4Info(Msg, [MsgName], TrUserData);
'SDLV6Info' -> v_msg_SDLV6Info(Msg, [MsgName], TrUserData); 'SDLV6Info' -> v_msg_SDLV6Info(Msg, [MsgName], TrUserData);
'SDLWelcome' -> v_msg_SDLWelcome(Msg, [MsgName], TrUserData); 'SDLWelcome' -> v_msg_SDLWelcome(Msg, [MsgName], TrUserData);
@ -3399,8 +3565,10 @@ verify_msg(Msg, MsgName, Opts) ->
'SDLEvent.NatChanged' -> 'v_msg_SDLEvent.NatChanged'(Msg, [MsgName], TrUserData); 'SDLEvent.NatChanged' -> 'v_msg_SDLEvent.NatChanged'(Msg, [MsgName], TrUserData);
'SDLEvent.SendRegister' -> 'v_msg_SDLEvent.SendRegister'(Msg, [MsgName], TrUserData); 'SDLEvent.SendRegister' -> 'v_msg_SDLEvent.SendRegister'(Msg, [MsgName], TrUserData);
'SDLEvent.NetworkShutdown' -> 'v_msg_SDLEvent.NetworkShutdown'(Msg, [MsgName], TrUserData); 'SDLEvent.NetworkShutdown' -> 'v_msg_SDLEvent.NetworkShutdown'(Msg, [MsgName], TrUserData);
'SDLEvent.ExitNodeControl' -> 'v_msg_SDLEvent.ExitNodeControl'(Msg, [MsgName], TrUserData);
'SDLEvent' -> v_msg_SDLEvent(Msg, [MsgName], TrUserData); 'SDLEvent' -> v_msg_SDLEvent(Msg, [MsgName], TrUserData);
'SDLCommand.ExitNodeControl' -> 'v_msg_SDLCommand.ExitNodeControl'(Msg, [MsgName], TrUserData);
'SDLCommand' -> v_msg_SDLCommand(Msg, [MsgName], TrUserData);
'SDLCommandAck' -> v_msg_SDLCommandAck(Msg, [MsgName], TrUserData);
'SDLStunRequest' -> v_msg_SDLStunRequest(Msg, [MsgName], TrUserData); 'SDLStunRequest' -> v_msg_SDLStunRequest(Msg, [MsgName], TrUserData);
'SDLStunReply' -> v_msg_SDLStunReply(Msg, [MsgName], TrUserData); 'SDLStunReply' -> v_msg_SDLStunReply(Msg, [MsgName], TrUserData);
'SDLData' -> v_msg_SDLData(Msg, [MsgName], TrUserData); 'SDLData' -> v_msg_SDLData(Msg, [MsgName], TrUserData);
@ -3412,11 +3580,6 @@ verify_msg(Msg, MsgName, Opts) ->
end. end.
-compile({nowarn_unused_function,v_msg_Hello/3}).
-dialyzer({nowarn_function,v_msg_Hello/3}).
v_msg_Hello(#'Hello'{}, _Path, _) -> ok;
v_msg_Hello(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'Hello'}, X, Path).
-compile({nowarn_unused_function,v_submsg_SDLV4Info/3}). -compile({nowarn_unused_function,v_submsg_SDLV4Info/3}).
-dialyzer({nowarn_function,v_submsg_SDLV4Info/3}). -dialyzer({nowarn_function,v_submsg_SDLV4Info/3}).
v_submsg_SDLV4Info(Msg, Path, TrUserData) -> v_msg_SDLV4Info(Msg, Path, TrUserData). v_submsg_SDLV4Info(Msg, Path, TrUserData) -> v_msg_SDLV4Info(Msg, Path, TrUserData).
@ -3674,13 +3837,26 @@ v_msg_SDLPolicyResponse(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'S
ok; ok;
'v_msg_SDLEvent.NetworkShutdown'(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'SDLEvent.NetworkShutdown'}, X, Path). 'v_msg_SDLEvent.NetworkShutdown'(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'SDLEvent.NetworkShutdown'}, X, Path).
-compile({nowarn_unused_function,'v_submsg_SDLEvent.ExitNodeControl'/3}). -compile({nowarn_unused_function,v_msg_SDLEvent/3}).
-dialyzer({nowarn_function,'v_submsg_SDLEvent.ExitNodeControl'/3}). -dialyzer({nowarn_function,v_msg_SDLEvent/3}).
'v_submsg_SDLEvent.ExitNodeControl'(Msg, Path, TrUserData) -> 'v_msg_SDLEvent.ExitNodeControl'(Msg, Path, TrUserData). v_msg_SDLEvent(#'SDLEvent'{event = F1}, Path, TrUserData) ->
case F1 of
undefined -> ok;
{nat_changed, OF1} -> 'v_submsg_SDLEvent.NatChanged'(OF1, [nat_changed, event | Path], TrUserData);
{send_register, OF1} -> 'v_submsg_SDLEvent.SendRegister'(OF1, [send_register, event | Path], TrUserData);
{shutdown, OF1} -> 'v_submsg_SDLEvent.NetworkShutdown'(OF1, [shutdown, event | Path], TrUserData);
_ -> mk_type_error(invalid_oneof, F1, [event | Path])
end,
ok;
v_msg_SDLEvent(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'SDLEvent'}, X, Path).
-compile({nowarn_unused_function,'v_msg_SDLEvent.ExitNodeControl'/3}). -compile({nowarn_unused_function,'v_submsg_SDLCommand.ExitNodeControl'/3}).
-dialyzer({nowarn_function,'v_msg_SDLEvent.ExitNodeControl'/3}). -dialyzer({nowarn_function,'v_submsg_SDLCommand.ExitNodeControl'/3}).
'v_msg_SDLEvent.ExitNodeControl'(#'SDLEvent.ExitNodeControl'{action = F1, node_mac = F2, node_ip = F3, remark = F4}, Path, TrUserData) -> 'v_submsg_SDLCommand.ExitNodeControl'(Msg, Path, TrUserData) -> 'v_msg_SDLCommand.ExitNodeControl'(Msg, Path, TrUserData).
-compile({nowarn_unused_function,'v_msg_SDLCommand.ExitNodeControl'/3}).
-dialyzer({nowarn_function,'v_msg_SDLCommand.ExitNodeControl'/3}).
'v_msg_SDLCommand.ExitNodeControl'(#'SDLCommand.ExitNodeControl'{action = F1, node_mac = F2, node_ip = F3, remark = F4}, Path, TrUserData) ->
if F1 == undefined -> ok; if F1 == undefined -> ok;
true -> v_type_int32(F1, [action | Path], TrUserData) true -> v_type_int32(F1, [action | Path], TrUserData)
end, end,
@ -3694,21 +3870,39 @@ v_msg_SDLPolicyResponse(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'S
true -> v_type_string(F4, [remark | Path], TrUserData) true -> v_type_string(F4, [remark | Path], TrUserData)
end, end,
ok; ok;
'v_msg_SDLEvent.ExitNodeControl'(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'SDLEvent.ExitNodeControl'}, X, Path). 'v_msg_SDLCommand.ExitNodeControl'(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'SDLCommand.ExitNodeControl'}, X, Path).
-compile({nowarn_unused_function,v_msg_SDLEvent/3}). -compile({nowarn_unused_function,v_msg_SDLCommand/3}).
-dialyzer({nowarn_function,v_msg_SDLEvent/3}). -dialyzer({nowarn_function,v_msg_SDLCommand/3}).
v_msg_SDLEvent(#'SDLEvent'{event = F1}, Path, TrUserData) -> v_msg_SDLCommand(#'SDLCommand'{pkt_id = F1, command = F2}, Path, TrUserData) ->
case F1 of if F1 == undefined -> ok;
true -> v_type_uint32(F1, [pkt_id | Path], TrUserData)
end,
case F2 of
undefined -> ok; undefined -> ok;
{nat_changed, OF1} -> 'v_submsg_SDLEvent.NatChanged'(OF1, [nat_changed, event | Path], TrUserData); {exit_node, OF2} -> 'v_submsg_SDLCommand.ExitNodeControl'(OF2, [exit_node, command | Path], TrUserData);
{send_register, OF1} -> 'v_submsg_SDLEvent.SendRegister'(OF1, [send_register, event | Path], TrUserData); _ -> mk_type_error(invalid_oneof, F2, [command | Path])
{shutdown, OF1} -> 'v_submsg_SDLEvent.NetworkShutdown'(OF1, [shutdown, event | Path], TrUserData);
{exit_node, OF1} -> 'v_submsg_SDLEvent.ExitNodeControl'(OF1, [exit_node, event | Path], TrUserData);
_ -> mk_type_error(invalid_oneof, F1, [event | Path])
end, end,
ok; ok;
v_msg_SDLEvent(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'SDLEvent'}, X, Path). v_msg_SDLCommand(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'SDLCommand'}, X, Path).
-compile({nowarn_unused_function,v_msg_SDLCommandAck/3}).
-dialyzer({nowarn_function,v_msg_SDLCommandAck/3}).
v_msg_SDLCommandAck(#'SDLCommandAck'{pkt_id = F1, code = F2, message = F3, data = F4}, Path, TrUserData) ->
if F1 == undefined -> ok;
true -> v_type_uint32(F1, [pkt_id | Path], TrUserData)
end,
if F2 == undefined -> ok;
true -> v_type_int32(F2, [code | Path], TrUserData)
end,
if F3 == undefined -> ok;
true -> v_type_string(F3, [message | Path], TrUserData)
end,
if F4 == undefined -> ok;
true -> v_type_bytes(F4, [data | Path], TrUserData)
end,
ok;
v_msg_SDLCommandAck(X, Path, _TrUserData) -> mk_type_error({expected_msg, 'SDLCommandAck'}, X, Path).
-compile({nowarn_unused_function,v_msg_SDLStunRequest/3}). -compile({nowarn_unused_function,v_msg_SDLStunRequest/3}).
-dialyzer({nowarn_function,v_msg_SDLStunRequest/3}). -dialyzer({nowarn_function,v_msg_SDLStunRequest/3}).
@ -3910,8 +4104,7 @@ cons(Elem, Acc, _TrUserData) -> [Elem | Acc].
get_msg_defs() -> get_msg_defs() ->
[{{msg, 'Hello'}, []}, [{{msg, 'SDLV4Info'},
{{msg, 'SDLV4Info'},
[#field{name = port, fnum = 1, rnum = 2, type = uint32, occurrence = defaulty, opts = []}, [#field{name = port, fnum = 1, rnum = 2, type = uint32, occurrence = defaulty, opts = []},
#field{name = v4, fnum = 2, rnum = 3, type = bytes, occurrence = defaulty, opts = []}, #field{name = v4, fnum = 2, rnum = 3, type = bytes, occurrence = defaulty, opts = []},
#field{name = nat_type, fnum = 3, rnum = 4, type = uint32, occurrence = defaulty, opts = []}]}, #field{name = nat_type, fnum = 3, rnum = 4, type = uint32, occurrence = defaulty, opts = []}]},
@ -3967,19 +4160,26 @@ get_msg_defs() ->
#field{name = nat_type, fnum = 4, rnum = 5, type = uint32, occurrence = defaulty, opts = []}, #field{name = nat_type, fnum = 4, rnum = 5, type = uint32, occurrence = defaulty, opts = []},
#field{name = v6_info, fnum = 5, rnum = 6, type = {msg, 'SDLV6Info'}, occurrence = optional, opts = []}]}, #field{name = v6_info, fnum = 5, rnum = 6, type = {msg, 'SDLV6Info'}, occurrence = optional, opts = []}]},
{{msg, 'SDLEvent.NetworkShutdown'}, [#field{name = message, fnum = 1, rnum = 2, type = string, occurrence = defaulty, opts = []}]}, {{msg, 'SDLEvent.NetworkShutdown'}, [#field{name = message, fnum = 1, rnum = 2, type = string, occurrence = defaulty, opts = []}]},
{{msg, 'SDLEvent.ExitNodeControl'},
[#field{name = action, fnum = 1, rnum = 2, type = int32, occurrence = defaulty, opts = []},
#field{name = node_mac, fnum = 2, rnum = 3, type = bytes, occurrence = defaulty, opts = []},
#field{name = node_ip, fnum = 3, rnum = 4, type = uint32, occurrence = defaulty, opts = []},
#field{name = remark, fnum = 4, rnum = 5, type = string, occurrence = defaulty, opts = []}]},
{{msg, 'SDLEvent'}, {{msg, 'SDLEvent'},
[#gpb_oneof{name = event, rnum = 2, [#gpb_oneof{name = event, rnum = 2,
fields = fields =
[#field{name = nat_changed, fnum = 1, rnum = 2, type = {msg, 'SDLEvent.NatChanged'}, occurrence = optional, opts = []}, [#field{name = nat_changed, fnum = 1, rnum = 2, type = {msg, 'SDLEvent.NatChanged'}, occurrence = optional, opts = []},
#field{name = send_register, fnum = 2, rnum = 2, type = {msg, 'SDLEvent.SendRegister'}, occurrence = optional, opts = []}, #field{name = send_register, fnum = 2, rnum = 2, type = {msg, 'SDLEvent.SendRegister'}, occurrence = optional, opts = []},
#field{name = shutdown, fnum = 3, rnum = 2, type = {msg, 'SDLEvent.NetworkShutdown'}, occurrence = optional, opts = []}, #field{name = shutdown, fnum = 3, rnum = 2, type = {msg, 'SDLEvent.NetworkShutdown'}, occurrence = optional, opts = []}],
#field{name = exit_node, fnum = 4, rnum = 2, type = {msg, 'SDLEvent.ExitNodeControl'}, occurrence = optional, opts = []}],
opts = []}]}, opts = []}]},
{{msg, 'SDLCommand.ExitNodeControl'},
[#field{name = action, fnum = 1, rnum = 2, type = int32, occurrence = defaulty, opts = []},
#field{name = node_mac, fnum = 2, rnum = 3, type = bytes, occurrence = defaulty, opts = []},
#field{name = node_ip, fnum = 3, rnum = 4, type = uint32, occurrence = defaulty, opts = []},
#field{name = remark, fnum = 4, rnum = 5, type = string, occurrence = defaulty, opts = []}]},
{{msg, 'SDLCommand'},
[#field{name = pkt_id, fnum = 1, rnum = 2, type = uint32, occurrence = defaulty, opts = []},
#gpb_oneof{name = command, rnum = 3, fields = [#field{name = exit_node, fnum = 2, rnum = 3, type = {msg, 'SDLCommand.ExitNodeControl'}, occurrence = optional, opts = []}], opts = []}]},
{{msg, 'SDLCommandAck'},
[#field{name = pkt_id, fnum = 1, rnum = 2, type = uint32, occurrence = defaulty, opts = []},
#field{name = code, fnum = 2, rnum = 3, type = int32, occurrence = defaulty, opts = []},
#field{name = message, fnum = 3, rnum = 4, type = string, occurrence = defaulty, opts = []},
#field{name = data, fnum = 4, rnum = 5, type = bytes, occurrence = defaulty, opts = []}]},
{{msg, 'SDLStunRequest'}, {{msg, 'SDLStunRequest'},
[#field{name = client_id, fnum = 1, rnum = 2, type = string, occurrence = defaulty, opts = []}, [#field{name = client_id, fnum = 1, rnum = 2, type = string, occurrence = defaulty, opts = []},
#field{name = network_id, fnum = 2, rnum = 3, type = uint32, occurrence = defaulty, opts = []}, #field{name = network_id, fnum = 2, rnum = 3, type = uint32, occurrence = defaulty, opts = []},
@ -4018,8 +4218,7 @@ get_msg_defs() ->
get_msg_names() -> get_msg_names() ->
['Hello', ['SDLV4Info',
'SDLV4Info',
'SDLV6Info', 'SDLV6Info',
'SDLWelcome', 'SDLWelcome',
'SDLRegisterSuper', 'SDLRegisterSuper',
@ -4034,8 +4233,10 @@ get_msg_names() ->
'SDLEvent.NatChanged', 'SDLEvent.NatChanged',
'SDLEvent.SendRegister', 'SDLEvent.SendRegister',
'SDLEvent.NetworkShutdown', 'SDLEvent.NetworkShutdown',
'SDLEvent.ExitNodeControl',
'SDLEvent', 'SDLEvent',
'SDLCommand.ExitNodeControl',
'SDLCommand',
'SDLCommandAck',
'SDLStunRequest', 'SDLStunRequest',
'SDLStunReply', 'SDLStunReply',
'SDLData', 'SDLData',
@ -4049,8 +4250,7 @@ get_group_names() -> [].
get_msg_or_group_names() -> get_msg_or_group_names() ->
['Hello', ['SDLV4Info',
'SDLV4Info',
'SDLV6Info', 'SDLV6Info',
'SDLWelcome', 'SDLWelcome',
'SDLRegisterSuper', 'SDLRegisterSuper',
@ -4065,8 +4265,10 @@ get_msg_or_group_names() ->
'SDLEvent.NatChanged', 'SDLEvent.NatChanged',
'SDLEvent.SendRegister', 'SDLEvent.SendRegister',
'SDLEvent.NetworkShutdown', 'SDLEvent.NetworkShutdown',
'SDLEvent.ExitNodeControl',
'SDLEvent', 'SDLEvent',
'SDLCommand.ExitNodeControl',
'SDLCommand',
'SDLCommandAck',
'SDLStunRequest', 'SDLStunRequest',
'SDLStunReply', 'SDLStunReply',
'SDLData', 'SDLData',
@ -4090,7 +4292,6 @@ fetch_msg_def(MsgName) ->
fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}).
find_msg_def('Hello') -> [];
find_msg_def('SDLV4Info') -> find_msg_def('SDLV4Info') ->
[#field{name = port, fnum = 1, rnum = 2, type = uint32, occurrence = defaulty, opts = []}, [#field{name = port, fnum = 1, rnum = 2, type = uint32, occurrence = defaulty, opts = []},
#field{name = v4, fnum = 2, rnum = 3, type = bytes, occurrence = defaulty, opts = []}, #field{name = v4, fnum = 2, rnum = 3, type = bytes, occurrence = defaulty, opts = []},
@ -4147,19 +4348,26 @@ find_msg_def('SDLEvent.SendRegister') ->
#field{name = nat_type, fnum = 4, rnum = 5, type = uint32, occurrence = defaulty, opts = []}, #field{name = nat_type, fnum = 4, rnum = 5, type = uint32, occurrence = defaulty, opts = []},
#field{name = v6_info, fnum = 5, rnum = 6, type = {msg, 'SDLV6Info'}, occurrence = optional, opts = []}]; #field{name = v6_info, fnum = 5, rnum = 6, type = {msg, 'SDLV6Info'}, occurrence = optional, opts = []}];
find_msg_def('SDLEvent.NetworkShutdown') -> [#field{name = message, fnum = 1, rnum = 2, type = string, occurrence = defaulty, opts = []}]; find_msg_def('SDLEvent.NetworkShutdown') -> [#field{name = message, fnum = 1, rnum = 2, type = string, occurrence = defaulty, opts = []}];
find_msg_def('SDLEvent.ExitNodeControl') ->
[#field{name = action, fnum = 1, rnum = 2, type = int32, occurrence = defaulty, opts = []},
#field{name = node_mac, fnum = 2, rnum = 3, type = bytes, occurrence = defaulty, opts = []},
#field{name = node_ip, fnum = 3, rnum = 4, type = uint32, occurrence = defaulty, opts = []},
#field{name = remark, fnum = 4, rnum = 5, type = string, occurrence = defaulty, opts = []}];
find_msg_def('SDLEvent') -> find_msg_def('SDLEvent') ->
[#gpb_oneof{name = event, rnum = 2, [#gpb_oneof{name = event, rnum = 2,
fields = fields =
[#field{name = nat_changed, fnum = 1, rnum = 2, type = {msg, 'SDLEvent.NatChanged'}, occurrence = optional, opts = []}, [#field{name = nat_changed, fnum = 1, rnum = 2, type = {msg, 'SDLEvent.NatChanged'}, occurrence = optional, opts = []},
#field{name = send_register, fnum = 2, rnum = 2, type = {msg, 'SDLEvent.SendRegister'}, occurrence = optional, opts = []}, #field{name = send_register, fnum = 2, rnum = 2, type = {msg, 'SDLEvent.SendRegister'}, occurrence = optional, opts = []},
#field{name = shutdown, fnum = 3, rnum = 2, type = {msg, 'SDLEvent.NetworkShutdown'}, occurrence = optional, opts = []}, #field{name = shutdown, fnum = 3, rnum = 2, type = {msg, 'SDLEvent.NetworkShutdown'}, occurrence = optional, opts = []}],
#field{name = exit_node, fnum = 4, rnum = 2, type = {msg, 'SDLEvent.ExitNodeControl'}, occurrence = optional, opts = []}],
opts = []}]; opts = []}];
find_msg_def('SDLCommand.ExitNodeControl') ->
[#field{name = action, fnum = 1, rnum = 2, type = int32, occurrence = defaulty, opts = []},
#field{name = node_mac, fnum = 2, rnum = 3, type = bytes, occurrence = defaulty, opts = []},
#field{name = node_ip, fnum = 3, rnum = 4, type = uint32, occurrence = defaulty, opts = []},
#field{name = remark, fnum = 4, rnum = 5, type = string, occurrence = defaulty, opts = []}];
find_msg_def('SDLCommand') ->
[#field{name = pkt_id, fnum = 1, rnum = 2, type = uint32, occurrence = defaulty, opts = []},
#gpb_oneof{name = command, rnum = 3, fields = [#field{name = exit_node, fnum = 2, rnum = 3, type = {msg, 'SDLCommand.ExitNodeControl'}, occurrence = optional, opts = []}], opts = []}];
find_msg_def('SDLCommandAck') ->
[#field{name = pkt_id, fnum = 1, rnum = 2, type = uint32, occurrence = defaulty, opts = []},
#field{name = code, fnum = 2, rnum = 3, type = int32, occurrence = defaulty, opts = []},
#field{name = message, fnum = 3, rnum = 4, type = string, occurrence = defaulty, opts = []},
#field{name = data, fnum = 4, rnum = 5, type = bytes, occurrence = defaulty, opts = []}];
find_msg_def('SDLStunRequest') -> find_msg_def('SDLStunRequest') ->
[#field{name = client_id, fnum = 1, rnum = 2, type = string, occurrence = defaulty, opts = []}, [#field{name = client_id, fnum = 1, rnum = 2, type = string, occurrence = defaulty, opts = []},
#field{name = network_id, fnum = 2, rnum = 3, type = uint32, occurrence = defaulty, opts = []}, #field{name = network_id, fnum = 2, rnum = 3, type = uint32, occurrence = defaulty, opts = []},
@ -4253,7 +4461,6 @@ fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S
service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}).
fqbin_to_msg_name(<<"mypkg.Hello">>) -> 'Hello';
fqbin_to_msg_name(<<"mypkg.SDLV4Info">>) -> 'SDLV4Info'; fqbin_to_msg_name(<<"mypkg.SDLV4Info">>) -> 'SDLV4Info';
fqbin_to_msg_name(<<"mypkg.SDLV6Info">>) -> 'SDLV6Info'; fqbin_to_msg_name(<<"mypkg.SDLV6Info">>) -> 'SDLV6Info';
fqbin_to_msg_name(<<"mypkg.SDLWelcome">>) -> 'SDLWelcome'; fqbin_to_msg_name(<<"mypkg.SDLWelcome">>) -> 'SDLWelcome';
@ -4269,8 +4476,10 @@ fqbin_to_msg_name(<<"mypkg.SDLPolicyResponse">>) -> 'SDLPolicyResponse';
fqbin_to_msg_name(<<"mypkg.SDLEvent.NatChanged">>) -> 'SDLEvent.NatChanged'; fqbin_to_msg_name(<<"mypkg.SDLEvent.NatChanged">>) -> 'SDLEvent.NatChanged';
fqbin_to_msg_name(<<"mypkg.SDLEvent.SendRegister">>) -> 'SDLEvent.SendRegister'; fqbin_to_msg_name(<<"mypkg.SDLEvent.SendRegister">>) -> 'SDLEvent.SendRegister';
fqbin_to_msg_name(<<"mypkg.SDLEvent.NetworkShutdown">>) -> 'SDLEvent.NetworkShutdown'; fqbin_to_msg_name(<<"mypkg.SDLEvent.NetworkShutdown">>) -> 'SDLEvent.NetworkShutdown';
fqbin_to_msg_name(<<"mypkg.SDLEvent.ExitNodeControl">>) -> 'SDLEvent.ExitNodeControl';
fqbin_to_msg_name(<<"mypkg.SDLEvent">>) -> 'SDLEvent'; fqbin_to_msg_name(<<"mypkg.SDLEvent">>) -> 'SDLEvent';
fqbin_to_msg_name(<<"mypkg.SDLCommand.ExitNodeControl">>) -> 'SDLCommand.ExitNodeControl';
fqbin_to_msg_name(<<"mypkg.SDLCommand">>) -> 'SDLCommand';
fqbin_to_msg_name(<<"mypkg.SDLCommandAck">>) -> 'SDLCommandAck';
fqbin_to_msg_name(<<"mypkg.SDLStunRequest">>) -> 'SDLStunRequest'; fqbin_to_msg_name(<<"mypkg.SDLStunRequest">>) -> 'SDLStunRequest';
fqbin_to_msg_name(<<"mypkg.SDLStunReply">>) -> 'SDLStunReply'; fqbin_to_msg_name(<<"mypkg.SDLStunReply">>) -> 'SDLStunReply';
fqbin_to_msg_name(<<"mypkg.SDLData">>) -> 'SDLData'; fqbin_to_msg_name(<<"mypkg.SDLData">>) -> 'SDLData';
@ -4281,7 +4490,6 @@ fqbin_to_msg_name(<<"mypkg.SDLRegisterAck">>) -> 'SDLRegisterAck';
fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}).
msg_name_to_fqbin('Hello') -> <<"mypkg.Hello">>;
msg_name_to_fqbin('SDLV4Info') -> <<"mypkg.SDLV4Info">>; msg_name_to_fqbin('SDLV4Info') -> <<"mypkg.SDLV4Info">>;
msg_name_to_fqbin('SDLV6Info') -> <<"mypkg.SDLV6Info">>; msg_name_to_fqbin('SDLV6Info') -> <<"mypkg.SDLV6Info">>;
msg_name_to_fqbin('SDLWelcome') -> <<"mypkg.SDLWelcome">>; msg_name_to_fqbin('SDLWelcome') -> <<"mypkg.SDLWelcome">>;
@ -4297,8 +4505,10 @@ msg_name_to_fqbin('SDLPolicyResponse') -> <<"mypkg.SDLPolicyResponse">>;
msg_name_to_fqbin('SDLEvent.NatChanged') -> <<"mypkg.SDLEvent.NatChanged">>; msg_name_to_fqbin('SDLEvent.NatChanged') -> <<"mypkg.SDLEvent.NatChanged">>;
msg_name_to_fqbin('SDLEvent.SendRegister') -> <<"mypkg.SDLEvent.SendRegister">>; msg_name_to_fqbin('SDLEvent.SendRegister') -> <<"mypkg.SDLEvent.SendRegister">>;
msg_name_to_fqbin('SDLEvent.NetworkShutdown') -> <<"mypkg.SDLEvent.NetworkShutdown">>; msg_name_to_fqbin('SDLEvent.NetworkShutdown') -> <<"mypkg.SDLEvent.NetworkShutdown">>;
msg_name_to_fqbin('SDLEvent.ExitNodeControl') -> <<"mypkg.SDLEvent.ExitNodeControl">>;
msg_name_to_fqbin('SDLEvent') -> <<"mypkg.SDLEvent">>; msg_name_to_fqbin('SDLEvent') -> <<"mypkg.SDLEvent">>;
msg_name_to_fqbin('SDLCommand.ExitNodeControl') -> <<"mypkg.SDLCommand.ExitNodeControl">>;
msg_name_to_fqbin('SDLCommand') -> <<"mypkg.SDLCommand">>;
msg_name_to_fqbin('SDLCommandAck') -> <<"mypkg.SDLCommandAck">>;
msg_name_to_fqbin('SDLStunRequest') -> <<"mypkg.SDLStunRequest">>; msg_name_to_fqbin('SDLStunRequest') -> <<"mypkg.SDLStunRequest">>;
msg_name_to_fqbin('SDLStunReply') -> <<"mypkg.SDLStunReply">>; msg_name_to_fqbin('SDLStunReply') -> <<"mypkg.SDLStunReply">>;
msg_name_to_fqbin('SDLData') -> <<"mypkg.SDLData">>; msg_name_to_fqbin('SDLData') -> <<"mypkg.SDLData">>;
@ -4345,12 +4555,13 @@ get_all_proto_names() -> ["sdlan"].
get_msg_containment("sdlan") -> get_msg_containment("sdlan") ->
['Hello', ['SDLArpRequest',
'SDLArpRequest',
'SDLArpResponse', 'SDLArpResponse',
'SDLCommand',
'SDLCommand.ExitNodeControl',
'SDLCommandAck',
'SDLData', 'SDLData',
'SDLEvent', 'SDLEvent',
'SDLEvent.ExitNodeControl',
'SDLEvent.NatChanged', 'SDLEvent.NatChanged',
'SDLEvent.NetworkShutdown', 'SDLEvent.NetworkShutdown',
'SDLEvent.SendRegister', 'SDLEvent.SendRegister',
@ -4397,6 +4608,7 @@ get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLStunRequest">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLPolicyRequest">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLPolicyRequest">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLEvent.NatChanged">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLEvent.NatChanged">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLEvent">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLEvent">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLCommand">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLArpRequest">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLArpRequest">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLWelcome">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLWelcome">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLStunProbe">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLStunProbe">>) -> "sdlan";
@ -4407,13 +4619,13 @@ get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLStunProbeReply">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLRegisterSuperNak">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLRegisterSuperNak">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLRegisterSuperAck">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLRegisterSuperAck">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLRegisterAck">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLRegisterAck">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLEvent.ExitNodeControl">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLCommandAck">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLCommand.ExitNodeControl">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLEvent.NetworkShutdown">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLEvent.NetworkShutdown">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLV6Info">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLV6Info">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLV4Info">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLV4Info">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLQueryInfo">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLQueryInfo">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLPeerInfo">>) -> "sdlan"; get_proto_by_msg_name_as_fqbin(<<"mypkg.SDLPeerInfo">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(<<"mypkg.Hello">>) -> "sdlan";
get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}).

View File

@ -96,13 +96,13 @@ handle_cast(_Request, State) ->
{noreply, NewState :: #state{}, timeout() | hibernate} | {noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}). {stop, Reason :: term(), NewState :: #state{}}).
handle_info({udp, Sock, Ip, Port, <<?PACKET_STUN_REQUEST:8, Body/binary>>}, State = #state{socket = Sock}) -> handle_info({udp, Sock, Ip, Port, <<?PACKET_STUN_REQUEST:8, Body/binary>>}, State = #state{socket = Sock}) ->
StunRequest = catch sdlan_pb:decode_msg(Body, sdl_stun_request), StunRequest = catch sdlan_pb:decode_msg(Body, 'SDLStunRequest'),
%% ip对应的nat的映射关系 %% ip对应的nat的映射关系
maybe maybe
#sdl_stun_request{session_token = SessionToken, client_id = ClientId, network_id = NetworkId, mac = Mac, nat_type = NatType, v6_info = V6Info} ?= StunRequest, #'SDLStunRequest'{session_token = SessionToken, client_id = ClientId, network_id = NetworkId, mac = Mac, nat_type = NatType, v6_info = V6Info} ?= StunRequest,
{ok, NetworkPid} ?= sdlan_network:lookup_pid(NetworkId), {ok, NetworkPid} ?= sdlan_network:lookup_pid(NetworkId),
sdlan_network:update_hole(NetworkPid, SessionToken, ClientId, Mac, {Ip, Port}, NatType, V6Info), sdlan_network:update_hole(NetworkPid, SessionToken, ClientId, Mac, {Ip, Port}, NatType, V6Info),
StunReply = sdlan_pb:encode_msg(#sdl_stun_reply{}), StunReply = sdlan_pb:encode_msg(#'SDLStunReply'{}),
%logger:debug("[sdlan_stun] stun_request network_id: ~p, client_id: ~p, hole: ~p", [NetworkId, ClientId, {Ip, Port}]) %logger:debug("[sdlan_stun] stun_request network_id: ~p, client_id: ~p, hole: ~p", [NetworkId, ClientId, {Ip, Port}])
ok = gen_udp:send(Sock, Ip, Port, <<?PACKET_STUN_REPLY:8, StunReply/binary>>) ok = gen_udp:send(Sock, Ip, Port, <<?PACKET_STUN_REPLY:8, StunReply/binary>>)
end, end,
@ -111,11 +111,11 @@ handle_info({udp, Sock, Ip, Port, <<?PACKET_STUN_REQUEST:8, Body/binary>>}, Stat
%% nat类型的探测机制, %% nat类型的探测机制,
%% assist的配置attr = 2 %% assist的配置attr = 2
handle_info({udp, Sock, ClientIp, ClientPort, <<?PACKET_STUN_PROBE:8, Body/binary>>}, State = #state{socket = Sock}) -> handle_info({udp, Sock, ClientIp, ClientPort, <<?PACKET_STUN_PROBE:8, Body/binary>>}, State = #state{socket = Sock}) ->
StunProbe = catch sdlan_pb:decode_msg(Body, sdl_stun_probe), StunProbe = catch sdlan_pb:decode_msg(Body, 'SDLStunProbe'),
maybe maybe
#sdl_stun_probe{cookie = Cookie, attr = Attr} ?= StunProbe, #'SDLStunProbe'{cookie = Cookie, attr = Attr} ?= StunProbe,
logger:debug("[sdlan_stun] get stun_probe request, att: ~p", [Attr]), logger:debug("[sdlan_stun] get stun_probe request, att: ~p", [Attr]),
ProbeReplyPkt = sdlan_pb:encode_msg(#sdl_stun_probe_reply { ProbeReplyPkt = sdlan_pb:encode_msg(#'SDLStunProbeReply' {
cookie = Cookie, cookie = Cookie,
port = ClientPort, port = ClientPort,
ip = int_ip(ClientIp) ip = int_ip(ClientIp)
@ -134,13 +134,13 @@ handle_info({udp, Sock, ClientIp, ClientPort, <<?PACKET_STUN_PROBE:8, Body/binar
{noreply, State}; {noreply, State};
handle_info({udp, _, _Ip, _Port, <<?PACKET_STUN_DATA, Body/binary>>}, State = #state{socket = Sock}) -> handle_info({udp, _, _Ip, _Port, <<?PACKET_STUN_DATA, Body/binary>>}, State = #state{socket = Sock}) ->
Data = catch sdlan_pb:decode_msg(Body, sdl_data), Data = catch sdlan_pb:decode_msg(Body, 'SDLData'),
maybe maybe
#sdl_data{network_id = NetworkId, src_mac = SrcMac, dst_mac = DstMac, ttl = TTL} ?= Data, #'SDLData'{network_id = NetworkId, src_mac = SrcMac, dst_mac = DstMac, ttl = TTL} ?= Data,
logger:debug("[sdlan_stun] forward data, network_id: ~p", [NetworkId]), logger:debug("[sdlan_stun] forward data, network_id: ~p", [NetworkId]),
{ok, NetworkPid} ?= sdlan_network:lookup_pid(NetworkId), {ok, NetworkPid} ?= sdlan_network:lookup_pid(NetworkId),
%% ttl需要减1 %% ttl需要减1
NData = sdlan_pb:encode_msg(Data#sdl_data{ttl = TTL - 1, is_p2p = false}), NData = sdlan_pb:encode_msg(Data#'SDLData'{ttl = TTL - 1, is_p2p = false}),
sdlan_network:forward(NetworkPid, Sock, SrcMac, DstMac, <<?PACKET_STUN_DATA, NData/binary>>) sdlan_network:forward(NetworkPid, Sock, SrcMac, DstMac, <<?PACKET_STUN_DATA, NData/binary>>)
end, end,
{noreply, State}; {noreply, State};