<div dir="ltr"><div>Hi!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Den tis 12 mars 2019 kl 13:17 skrev pablo platt <<a href="mailto:pablo.platt@gmail.com">pablo.platt@gmail.com</a>>:<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 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-m_-2980656391537222502gmail-highlight gmail-m_-2980656391537222502gmail-tab-size gmail-m_-2980656391537222502gmail-js-file-line-container"><tbody><tr><td id="gmail-m_-2980656391537222502gmail-LC463" class="gmail-m_-2980656391537222502gmail-blob-code gmail-m_-2980656391537222502gmail-blob-code-inner gmail-m_-2980656391537222502gmail-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-m_-2980656391537222502gmail-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-m_-2980656391537222502gmail-pl-en">gen_statem</span> state somehow before sending the first packet?<br></div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>It dispatches the packets in an active once manner to the DTLS connection process that will tell the multiplexer when it wants more data.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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></div><div>This is how I'm creating the dtls connection pid to bypass dtls_packet_demux:<br></div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>I think what we really want is callbacks to the multiplexor so that it should not need to be bypassed but extended. </div><div><br></div><div><br></div><div>Regards Ingela Erlang/OTP team - Ericsson AB</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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></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" target="_blank">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" target="_blank">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" target="_blank">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>_______________________________________________<br>erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div>