This commit is contained in:
anlicheng 2026-04-16 15:40:08 +08:00
parent 7a5cb71bd4
commit 83e226aaf6

View File

@ -84,13 +84,13 @@ handle_info({udp, Sock, Ip, Port, Body}, State = #state{socket = Sock}) ->
#'SDLV6AssistProbe'{assist_token = Token} ->
case sdlan_token_store:lookup(Token) of
true ->
Reply = sdlan_pb:encode_msg(#'SDLV6AssistProbeReply'{
v6_info = #'SDLV6Info' {
v6 = Ip,
port = Port
}
}),
ok = gen_udp:send(Sock, Ip, Port, Reply);
case ipv6_assist_probe_reply(Ip, Port) of
Reply = #'SDLV6AssistProbeReply'{} ->
ReplyBin = sdlan_pb:encode_msg(Reply),
ok = gen_udp:send(Sock, Ip, Port, ReplyBin);
undefined ->
ok
end;
false ->
ok
end;
@ -111,3 +111,20 @@ terminate(_Reason, _State = #state{}) ->
{ok, NewState :: #state{}} | {error, Reason :: term()}.
code_change(_OldVsn, State = #state{}, _Extra) ->
{ok, State}.
-spec ipv6_assist_probe_reply(Ip :: inet:ip_address(), Port :: integer()) ->
undefined | #'SDLV6AssistProbeReply'{}.
ipv6_assist_probe_reply(Ip, Port) when is_integer(Port), Port > 0, Port =< 65535 ->
case sdlan_util:ipv6_to_bytes(Ip) of
<<_:128>> = V6Bytes ->
#'SDLV6AssistProbeReply'{
v6_info = #'SDLV6Info'{
v6 = V6Bytes,
port = Port
}
};
_ ->
undefined
end;
ipv6_assist_probe_reply(_, _) ->
undefined.