<p>Kevin Harwell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/5934">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_rtp_asterisk: add control frame for when dtls is established<br><br>Once DTLS has been established there needed to be a way to notify<br>processes upstream. This patch adds a new control frame subclass<br>AST_CONTROL_DTLS_ESTABLISHED that gets created  and set whenever<br>a dtls has been established.<br><br>ASTERISK-27096 #close<br><br>Change-Id: I27ff344f5a8c691a1890dfe3254a4b1a49e7f4a0<br>---<br>M channels/chan_iax2.c<br>M funcs/func_frame_trace.c<br>M include/asterisk/frame.h<br>M main/channel.c<br>M res/res_rtp_asterisk.c<br>5 files changed, 31 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/34/5934/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c<br>index d15b55d..0f2b914 100644<br>--- a/channels/chan_iax2.c<br>+++ b/channels/chan_iax2.c<br>@@ -1444,6 +1444,7 @@<br>  case AST_CONTROL_RECORD_STOP:<br>         case AST_CONTROL_RECORD_SUSPEND:<br>      case AST_CONTROL_RECORD_MUTE:<br>+        default:<br>              /* None of these media recording control frames should go across the link. */<br>                 break;<br>        }<br>diff --git a/funcs/func_frame_trace.c b/funcs/func_frame_trace.c<br>index 49abfdf..2e20b33 100644<br>--- a/funcs/func_frame_trace.c<br>+++ b/funcs/func_frame_trace.c<br>@@ -369,6 +369,9 @@<br>               case AST_CONTROL_RECORD_MUTE:<br>                         ast_verbose("SubClass: RECORD_MUTE\n");<br>                     break;<br>+               case AST_CONTROL_DTLS_ESTABLISHED:<br>+                   ast_verbose("SubClass: DTLS_ESTABLISHED\n");<br>+                       break;<br>                }<br> <br>          if (frame->subclass.integer == -1) {<br>diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h<br>index 2f6c365..f35e242 100644<br>--- a/include/asterisk/frame.h<br>+++ b/include/asterisk/frame.h<br>@@ -299,6 +299,7 @@<br>         AST_CONTROL_MASQUERADE_NOTIFY = 34,     /*!< A masquerade is about to begin/end. (Never sent as a frame but directly with ast_indicate_data().) */<br>         AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE = 35,    /*!< Channel indication that a stream topology change has been requested */<br>    AST_CONTROL_STREAM_TOPOLOGY_CHANGED = 36,           /*!< Channel indication that a stream topology change has occurred */<br>+ AST_CONTROL_DTLS_ESTABLISHED = 37, /*!< Channel indication that a dtls has been established */<br> <br>  /*<br>     * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING<br>diff --git a/main/channel.c b/main/channel.c<br>index c7c2b9d..4d2f2e9 100644<br>--- a/main/channel.c<br>+++ b/main/channel.c<br>@@ -4240,6 +4240,8 @@<br>    case AST_CONTROL_UNHOLD:<br>              /* This is a special case.  You stop hearing this. */<br>                 break;<br>+       default:<br>+             break;<br>        }<br> <br>  return 0;<br>@@ -4526,6 +4528,7 @@<br>      case AST_CONTROL_RECORD_STOP:<br>         case AST_CONTROL_RECORD_SUSPEND:<br>      case AST_CONTROL_RECORD_MUTE:<br>+        case AST_CONTROL_DTLS_ESTABLISHED:<br>            /* Nothing left to do for these. */<br>           res = 0;<br>              break;<br>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c<br>index 600846c..b018125 100644<br>--- a/res/res_rtp_asterisk.c<br>+++ b/res/res_rtp_asterisk.c<br>@@ -109,6 +109,8 @@<br> #define SRTP_MASTER_SALT_LEN 14<br> #define SRTP_MASTER_LEN (SRTP_MASTER_KEY_LEN + SRTP_MASTER_SALT_LEN)<br> <br>+#define RTP_DTLS_ESTABLISHED -37<br>+<br> enum strict_rtp_state {<br>      STRICT_RTP_OPEN = 0, /*! No RTP packets should be dropped, all sources accepted */<br>    STRICT_RTP_LEARN,    /*! Accept next packet as source */<br>@@ -2477,7 +2479,11 @@<br>                      /* Any further connections will be existing since this is now established */<br>                  dtls->connection = AST_RTP_DTLS_CONNECTION_EXISTING;<br>                       /* Use the keying material to set up key/salt information */<br>-                 res = dtls_srtp_setup(rtp, srtp, instance, rtcp);<br>+                    if ((res = dtls_srtp_setup(rtp, srtp, instance, rtcp))) {<br>+                            return res;<br>+                  }<br>+                    /* Notify that dtls has been established */<br>+                  res = RTP_DTLS_ESTABLISHED;<br>           } else {<br>                      /* Since we've sent additional traffic start the timeout timer for retransmission */<br>                      dtls_srtp_start_timeout_timer(instance, rtp, rtcp);<br>@@ -4750,6 +4756,14 @@<br>   /* Read in RTCP data from the socket */<br>       if ((res = rtcp_recvfrom(instance, read_area, read_area_size,<br>                                 0, &addr)) < 0) {<br>+             if (res == RTP_DTLS_ESTABLISHED) {<br>+                   struct ast_frame dtls_established = {<br>+                                AST_FRAME_CONTROL,<br>+                           .subclass.integer = AST_CONTROL_DTLS_ESTABLISHED,<br>+                    };<br>+                   return ast_frisolate(&dtls_established);<br>+         }<br>+<br>          ast_assert(errno != EBADF);<br>           if (errno != EAGAIN) {<br>                        ast_log(LOG_WARNING, "RTCP Read error: %s.  Hanging up.\n",<br>@@ -4947,6 +4961,14 @@<br>         /* Actually read in the data from the socket */<br>       if ((res = rtp_recvfrom(instance, read_area, read_area_size, 0,<br>                               &addr)) < 0) {<br>+                if (res == RTP_DTLS_ESTABLISHED) {<br>+                   struct ast_frame dtls_established = {<br>+                                AST_FRAME_CONTROL,<br>+                           .subclass.integer = AST_CONTROL_DTLS_ESTABLISHED,<br>+                    };<br>+                   return ast_frisolate(&dtls_established);<br>+         }<br>+<br>          ast_assert(errno != EBADF);<br>           if (errno != EAGAIN) {<br>                        ast_log(LOG_WARNING, "RTP Read error: %s.  Hanging up.\n",<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/5934">change 5934</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/5934"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I27ff344f5a8c691a1890dfe3254a4b1a49e7f4a0 </div>
<div style="display:none"> Gerrit-Change-Number: 5934 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>