<p>Maximilian Fridrich has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18838">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Add 100rel option "use_if_supported"<br><br>This patch adds a new option to the 100rel parameter for pjsip<br>endpoints called "use_if_supported". When an endpoint with this option<br>receives an incoming request and the request indicated support for the<br>100rel extension, then Asterisk will send 1xx responses reliably. If<br>the request did not indicate 100rel support, Asterisk sends 1xx<br>responses normally.<br><br>ASTERISK-30158<br><br>Change-Id: Id6d95ffa8f00dab118e0b386146e99f254f287ad<br>---<br>M include/asterisk/res_pjsip.h<br>M res/res_pjsip/pjsip_config.xml<br>M res/res_pjsip/pjsip_configuration.c<br>M res/res_pjsip_session.c<br>4 files changed, 39 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/38/18838/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h</span><br><span>index 1714cff..0325dfd 100644</span><br><span>--- a/include/asterisk/res_pjsip.h</span><br><span>+++ b/include/asterisk/res_pjsip.h</span><br><span>@@ -413,6 +413,20 @@</span><br><span> };</span><br><span> </span><br><span> /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief 100rel modes for SIP endpoints</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+enum ast_sip_100rel_mode {</span><br><span style="color: hsl(120, 100%, 40%);">+       /*! Do not support 100rel */</span><br><span style="color: hsl(120, 100%, 40%);">+  AST_SIP_100REL_UNSUPPORTED = 0,</span><br><span style="color: hsl(120, 100%, 40%);">+       /*! Indicate 100rel support in Supported header */</span><br><span style="color: hsl(120, 100%, 40%);">+    AST_SIP_100REL_SUPPORTED,</span><br><span style="color: hsl(120, 100%, 40%);">+     /*! As UAS, send 1xx responses reliable, if the UAC indicated its support. Otherwise same as AST_SIP_100REL_SUPPORTED. */</span><br><span style="color: hsl(120, 100%, 40%);">+     AST_SIP_100REL_USE_IF_SUPPORTED,</span><br><span style="color: hsl(120, 100%, 40%);">+      /*! Require the use 100rel */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_SIP_100REL_REQUIRED,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span>  * \brief DTMF modes for SIP endpoints</span><br><span>  */</span><br><span> enum ast_sip_dtmf_mode {</span><br><span>@@ -878,6 +892,8 @@</span><br><span>       unsigned int trust_connected_line;</span><br><span>   /*! Do we send connected line updates to this endpoint? */</span><br><span>   unsigned int send_connected_line;</span><br><span style="color: hsl(120, 100%, 40%);">+     /*! 100rel mode to use with this endpoint */</span><br><span style="color: hsl(120, 100%, 40%);">+  enum ast_sip_100rel_mode rel100;</span><br><span>     /*! Ignore 183 if no SDP is present */</span><br><span>       unsigned int ignore_183_without_sdp;</span><br><span>         /*! Set which STIR/SHAKEN behaviors we want on this endpoint */</span><br><span>diff --git a/res/res_pjsip/pjsip_config.xml b/res/res_pjsip/pjsip_config.xml</span><br><span>index e9abc86..b8f33c8 100644</span><br><span>--- a/res/res_pjsip/pjsip_config.xml</span><br><span>+++ b/res/res_pjsip/pjsip_config.xml</span><br><span>@@ -34,6 +34,7 @@</span><br><span>                                             <enumlist></span><br><span>                                                     <enum name="no" /></span><br><span>                                                   <enum name="required" /></span><br><span style="color: hsl(120, 100%, 40%);">+                                                      <enum name="use_if_supported" /></span><br><span>                                                     <enum name="yes" /></span><br><span>                                          </enumlist></span><br><span>                                    </description></span><br><span>diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c</span><br><span>index b514cea..cab4b87 100644</span><br><span>--- a/res/res_pjsip/pjsip_configuration.c</span><br><span>+++ b/res/res_pjsip/pjsip_configuration.c</span><br><span>@@ -182,9 +182,16 @@</span><br><span> </span><br><span>     if (ast_true(var->value)) {</span><br><span>               endpoint->extensions.flags |= PJSIP_INV_SUPPORT_100REL;</span><br><span style="color: hsl(120, 100%, 40%);">+            endpoint->rel100 = AST_SIP_100REL_SUPPORTED;</span><br><span style="color: hsl(120, 100%, 40%);">+       } else if (!strcasecmp(var->value, "use_if_supported")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                endpoint->extensions.flags |= PJSIP_INV_SUPPORT_100REL;</span><br><span style="color: hsl(120, 100%, 40%);">+            endpoint->rel100 = AST_SIP_100REL_USE_IF_SUPPORTED;</span><br><span>       } else if (!strcasecmp(var->value, "required")) {</span><br><span>               endpoint->extensions.flags |= PJSIP_INV_REQUIRE_100REL;</span><br><span style="color: hsl(0, 100%, 40%);">-      } else if (!ast_false(var->value)){</span><br><span style="color: hsl(120, 100%, 40%);">+                endpoint->rel100 = AST_SIP_100REL_REQUIRED;</span><br><span style="color: hsl(120, 100%, 40%);">+        } else if (ast_false(var->value)){</span><br><span style="color: hsl(120, 100%, 40%);">+         endpoint->rel100 = AST_SIP_100REL_UNSUPPORTED;</span><br><span style="color: hsl(120, 100%, 40%);">+     } else {</span><br><span>             return -1;</span><br><span>   }</span><br><span> </span><br><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index 3c55af7..3ff3000 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -3797,8 +3797,22 @@</span><br><span>      pjsip_dialog *dlg;</span><br><span>   pjsip_inv_session *inv_session;</span><br><span>      unsigned int options = endpoint->extensions.flags;</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_str_t STR_100REL = { "100rel", 6};</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int peer_100rel = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int i;</span><br><span>      pj_status_t dlg_status = PJ_EUNKNOWN;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+     for (i = 0; i < rdata->msg_info.supported->count; ++i) {</span><br><span style="color: hsl(120, 100%, 40%);">+         if (pj_stricmp(&rdata->msg_info.supported->values[i], &STR_100REL) == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+          peer_100rel = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+              break;</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (peer_100rel && endpoint->rel100 == AST_SIP_100REL_USE_IF_SUPPORTED) {</span><br><span style="color: hsl(120, 100%, 40%);">+          options |= PJSIP_INV_REQUIRE_100REL;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  if (pjsip_inv_verify_request(rdata, &options, NULL, NULL, ast_sip_get_pjsip_endpoint(), &tdata) != PJ_SUCCESS) {</span><br><span>             if (tdata) {</span><br><span>                         if (pjsip_endpt_send_response2(ast_sip_get_pjsip_endpoint(), rdata, tdata, NULL, NULL) != PJ_SUCCESS) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18838">change 18838</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/18838"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Id6d95ffa8f00dab118e0b386146e99f254f287ad </div>
<div style="display:none"> Gerrit-Change-Number: 18838 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Maximilian Fridrich <m.fridrich@commend.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>