<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div><br></div><div>I'm trying to handle DTLS with other protocols on the same port but my UDP packets are ignored by the dtls_connection pid. I'm using OTP-22.0-rc1.<br></div><div><br></div><div>I'm creating a UDP socket and dtls_connection pid and pass incoming DTLS UDP packets to the pid:</div><div>
Pid ! {udp, Socket, IP, Port, Data}

</div><div><br></div><div>The UDP packets are ignored in dtls_connection:init/3 [2].<br></div><div>
<table class="gmail-highlight gmail-tab-size gmail-js-file-line-container"><tbody><tr><td id="gmail-LC463" class="gmail-blob-code gmail-blob-code-inner gmail-js-file-line"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-pl-en"></span>init(Type, Event, State) -><br>    gen_handshake(?FUNCTION_NAME, Type, Event, State).<br></blockquote><br>
I think the packets should arrive instead to [3].

</td></tr><tr></tr></tbody></table></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>init({call, _} = Type, Event, #state{static_env = #static_env{role = server},<br>    protocol_specific = PS} = State) -></div></blockquote><div><br></div><div>dtls_packet.demux:dispatch/3 just sends incoming UDP packets to the connection pid as normal messages [3] so I don't understand how it's different than what I'm doing. Does dtls_packet_demux changes the <span class="gmail-pl-en">gen_statem</span> state somehow before sending the first packet?<br></div><div><br></div><div>This is how I'm creating the dtls connection pid to bypass dtls_packet_demux:<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>-include_lib("ssl/src/ssl_internal.hrl").</div><div>listen(Socket, Options) -><br>    {ok, Config} = ssl:handle_options(Options, server),<br>    #config{ssl = DTLSOpts, emulated = EmOpts} = Config,<br>    {ok, {IP, Port}} = inet:peername(Socket),<br>    Client = {IP, Port},<br>    User = self(),<br>    ConnArgs = [server, "localhost", Port, {self(), {Client, Socket}},<br>        {DTLSOpts, EmOpts, dtls_listener}, User, dtls_socket:default_cb_info()],<br>    case dtls_connection_sup:start_child(ConnArgs) of<br>        {ok, Pid} -><br>            erlang:monitor(process, Pid),<br>            {ok, Pid};<br>        {error, Reason} -><br>            {error, Reason}<br>    end.</div><div><br></div><div>handle_info({udp, Socket, Addr, Port, Data}, #state{pid=Pid} = State)<br>    Pid ! {udp, Socket, Addr, Port, Data},<br>    {noreply, State};<br></div></blockquote><div><br></div><div>[1] <a href="https://github.com/erlang/otp/blob/master/lib/ssl/src/dtls_connection.erl#L463">https://github.com/erlang/otp/blob/master/lib/ssl/src/dtls_connection.erl#L463</a></div><div>[2] <a href="https://github.com/erlang/otp/blob/master/lib/ssl/src/dtls_connection.erl#L454">https://github.com/erlang/otp/blob/master/lib/ssl/src/dtls_connection.erl#L454</a></div><div>
[3] <a href="https://github.com/erlang/otp/blob/master/lib/ssl/src/dtls_packet_demux.erl#L203">https://github.com/erlang/otp/blob/master/lib/ssl/src/dtls_packet_demux.erl#L203</a> <br></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div>