<div dir="ltr"><div class="gmail_default" style="font-family:monospace;font-size:large;color:#0b5394"><div class="gmail_default">Hi Bogdan-Andrei,</div><div class="gmail_default"><br></div><div class="gmail_default">  This indeed has solved my problem!<br><br></div><div class="gmail_default">Here is my new code:</div><div class="gmail_default">```</div><div class="gmail_default"><br></div><div class="gmail_default"><div style="color:rgb(255,255,255);background-color:rgb(25,53,73);font-family:"Droid Sans Mono","monospace",monospace;font-size:14px;line-height:19px"><br><div>    <span style="color:rgb(0,136,255);font-style:italic"># CANCEL processing</span></div><div>    <span style="color:rgb(255,157,0)">if</span> ( <span style="color:rgb(255,157,0)">is_method</span>(<span style="color:rgb(165,255,144)">"CANCEL"</span>) ) {</div><div>        <span style="color:rgb(255,157,0)">if</span> ( <span style="color:rgb(255,157,0)">t_check_trans</span>() ){</div><div>            t_add_cancel_reason(<span style="color:rgb(165,255,144)">"X-Reason: Q.850;cause=31</span><span style="color:rgb(255,98,140)">\r\n</span><span style="color:rgb(165,255,144)">"</span>)<span style="color:rgb(225,239,255)">;</span></div><div>           <span style="color:rgb(255,157,0)">t_relay</span>()<span style="color:rgb(225,239,255)">;</span></div><div>        }</div><div>        <span style="color:rgb(255,157,0)">exit</span><span style="color:rgb(225,239,255)">;</span></div><div>    }</div></div></div><div class="gmail_default"> ```</div><div class="gmail_default">  Thank you very much.</div><div class="gmail_default"><br></div><div class="gmail_default">Best regards,</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 14, 2024 at 3:58 PM Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org">bogdan@opensips.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
    
  
  <div>
    <font face="monospace">Hi,<br>
      <br>
      Take a look at this
      <a href="https://blog.opensips.org/2016/11/15/cancel-request-and-reason-header/" target="_blank">https://blog.opensips.org/2016/11/15/cancel-request-and-reason-header/</a><br>
      <br>
      Regards,<br>
    </font>
    <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank">https://www.opensips-solutions.com</a>
  <a href="https://www.siphub.com" target="_blank">https://www.siphub.com</a></pre>
    <div>On 14.08.2024 06:46, Mohamed OUALLA
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div class="gmail_default" style="font-size:large;color:rgb(11,83,148)">
          <p style="font-family:monospace">Hello everyone,</p>
          <p style="font-family:monospace">  I am currently working with
            OpenSIPs in stateful mode, and I am encountering an issue
            with relaying a CANCEL request to cancel a pending initial
            SIP INVITE.</p>
          <p style="font-family:monospace">  The CANCEL request is
            hop-by-hop, so OpenSIPs act on it first "<b><i>send 200
                canceling</i></b>" then it generates a CANCEL SIP
            Request and relay it to the next hop. My goal is to add a
            custom SIP header, specifically "<b>X-Reason</b>", to this
            relayed CANCEL request. Unfortunately, I am only able to add
            the standard "<b>Reason</b>" header.</p>
          <p style="font-family:monospace">  The challenge I am facing
            is that FreeSWITCH, which receives the relayed CANCEL
            request, removes the "Reason" header due to a parameter I
            have set to disable adding Q.850 reasons. This parameter was
            initially enabled to prevent FreeSWITCH from adding the
            "Reason" header to negative SIP responses, but it's now also
            affecting the CANCEL request, leading to the removal of the
            "Reason" header!</p>
          <p style="font-family:monospace">Here’s my current OpenSIPs
            configuration that successfully adds the "Reason" header to
            the CANCEL request:</p>
          <p style="font-family:monospace">```</p>
          <p><font face="verdana, sans-serif">if(!is_present_hf("Reason")){<br>
                  append_hf("Reason: Q.850;cause=32\r\n", "CSeq");</font> <font face="verdana, sans-serif">#the outgoing CANCEL request
              has the Reason header value now<br>
              }</font></p>
          <span style="font-family:monospace">```</span></div>
        <div class="gmail_default" style="font-size:large;color:rgb(11,83,148)">
          <p>  However, when I try to add headers like "<b>X-Reason</b>"
            or "<b>TestHeader</b>" for example, they don't seem to be
            included in the relayed CANCEL request:</p>
          <p><span style="font-family:monospace">```</span><br>
          </p>
          <p><font face="verdana, sans-serif">if(!is_present_hf("Reason")){<br>
                  append_hf("X-Reason: Q.850;cause=31\r\n", "CSeq");</font>
            <span style="font-family:verdana,sans-serif"># No changes
              are reflected in the relayed CANCEL request :-/</span><font face="verdana, sans-serif"><br>
                  # or<br>
                  append_hf("TestHeader: Q.850;cause=31\r\n", "CSeq");#
              No changes are reflected in the relayed CANCEL request :-/<br>
              }</font></p>
          <span style="font-family:monospace">```</span></div>
        <div class="gmail_default" style="font-size:large;color:rgb(11,83,148)">
          <p>  Has anyone faced a similar issue or have any suggestions
            on how I can successfully add a custom "<b>X-Reason</b>"
            header or any other custom "<b><i>X-Header</i></b>" to the
            relayed CANCEL request?</p>
          <p>Thanks in advance,</p>
          <p>Have a beautiful day</p>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="color:rgb(136,136,136)">==============================</span></div><div>Mohamed OUALLA</div><div><b><font color="#0b5394">VoIP Technical Solutions and Software Engineer</font></b></div></div><div dir="ltr">Mail: <a href="mailto:oualla.simohamed@gmail.com" target="_blank">oualla.simohamed@gmail.com</a></div><div dir="ltr"><a href="mailto:oualla.simohamed@gmail.com" target="_blank"><span style="color:rgb(32,33,36)">N.Phone: +212 6 29 19 3116</span><br></a><span style="color:rgb(136,136,136)"><img src="https://ci3.googleusercontent.com/mail-sig/AIorK4w8wo1XjkD9o9pEbHwWo6FMT1wF_bInLSJDV6d97ZxVT7gcrrywnIHV6FirIbCxhmM3g0UskTWbriW8"></span><span style="text-align:center;background-color:rgb(255,255,255)"><b><font size="4" face="monospace" color="#134f5c">SSC Certified Professional</font></b></span></div><div dir="ltr"><span style="color:rgb(136,136,136)">==============================</span></div></div></div></div></div></div>