No subject


Sun Dec 21 10:55:10 CET 2008


I really can't understand it, Kamailio shouldn't check the From URI of
the CANCEL, just the branch parameter.

Please, do the following test:

In your SIPp scenario change the From header to:
  From: "sipp"<a class="moz-txt-link-rfc2396E" href="sip:1-16122-192.168.160.141 at 192.168.160.141:5064">&lt;sip:1-16122-192.168.160.141 at 192.168.160.141:5064&gt;</a>;tag=XXXXXXXXX

In this way, the UAS will no modify it. Let's check if Kamailio still
fails when matching the transaction. If it works now, then there is an
important issue in Kamailio CANCEL/INVITE matching.
  </pre>
</blockquote>
This one work, I checked it.<br>
the t_lookupOriginalT functions which is used for CANCEL matching uses
the full header string for a match ...<br>
Headers are not parsed. This cannot work ...<br>
<br>
<blockquote type="cite">#define EQ_LEN(_hf)
(t_msg-&gt;_hf-&gt;body.len==p_msg-&gt;_hf-&gt;body.len)<br>
  <br>
#define EQ_STR(_hf) (memcmp(t_msg-&gt;_hf-&gt;body.s,\<br>
    p_msg-&gt;_hf-&gt;body.s, \<br>
    p_msg-&gt;_hf-&gt;body.len)==0)<br>
</blockquote>
<br>
<blockquote type="cite">/* function lookups transaction being canceled
by CANCEL in p_msg;<br>
 * it returns:<br>
 *       0 - transaction wasn't found<br>
 *       T - transaction found<br>
 */<br>
struct cell* t_lookupOriginalT(  struct sip_msg* p_msg )<br>
{<br>
    struct cell     *p_cell;<br>
    unsigned int     hash_index;<br>
    struct sip_msg  *t_msg;<br>
    struct via_param *branch;<br>
    int ret;<br>
  <br>
    /* already looked for it? */<br>
    if (cancelled_T!=T_UNDEFINED)<br>
        return cancelled_T;<br>
  <br>
    /* start searching in the table */<br>
    hash_index = p_msg-&gt;hash_index;<br>
    LM_DBG("searching on hash entry %d\n",hash_index );<br>
  <br>
  <br>
    /* first of all, look if there is RFC3261 magic cookie in branch; if<br>
     * so, we can do very quick matching and skip the old-RFC bizzar<br>
     * comparison of many header fields<br>
     */<br>
    if (!p_msg-&gt;via1) {<br>
        LM_ERR("no via\n");<br>
        cancelled_T = NULL;<br>
        return 0;<br>
    }<br>
    branch=p_msg-&gt;via1-&gt;branch;<br>
    if (branch &amp;&amp; branch-&gt;value.s &amp;&amp;
branch-&gt;value.len&gt;MCOOKIE_LEN<br>
            &amp;&amp;
memcmp(branch-&gt;value.s,MCOOKIE,MCOOKIE_LEN)==0) {<br>
        /* huhuhu! the cookie is there -- let's proceed fast */<br>
        LOCK_HASH(hash_index);<br>
        ret=matching_3261(p_msg, &amp;p_cell,<br>
                /* we are seeking the original transaction --<br>
                 * skip CANCEL transactions during search<br>
                 */<br>
                METHOD_CANCEL);<br>
        if (ret==1) goto found; else goto notfound;<br>
    }<br>
  <br>
    /* no cookies --proceed to old-fashioned pre-3261 t-matching */<br>
  <br>
    LOCK_HASH(hash_index);<br>
  <br>
    /* all the transactions from the entry are compared */<br>
    for (p_cell=get_tm_table()-&gt;entrys[hash_index].first_cell;<br>
        p_cell; p_cell = p_cell-&gt;next_cell )<br>
    {<br>
        t_msg = p_cell-&gt;uas.request;<br>
  <br>
        if (!t_msg) continue; /* skip UAC transactions */<br>
  <br>
        /* we don't cancel CANCELs ;-) */<br>
        if (t_msg-&gt;REQ_METHOD==METHOD_CANCEL)<br>
            continue;<br>
  <br>
        LM_DBG("Trying transaction ...\n") ;<br>
  <br>
#define DBG_HDR(_hf) LM_DBG("Trying transaction : "#_hf"=%.*s &lt;&gt;
%.*s\n", \<br>
                t_msg-&gt;_hf-&gt;body.len, t_msg-&gt;_hf-&gt;body.s, \<br>
                p_msg-&gt;_hf-&gt;body.len, p_msg-&gt;_hf-&gt;body.s \<br>
                ) ;<br>
  <br>
        /* check lengths now */    <br>
        if (!EQ_LEN(callid))<br>
          {<br>
            DBG_HDR(callid) ;<br>
            continue;<br>
          }<br>
        if
(get_cseq(t_msg)-&gt;number.len!=get_cseq(p_msg)-&gt;number.len)<br>
            continue;<br>
        if (!EQ_LEN(from))<br>
          {<br>
            DBG_HDR(from) ;<br>
            continue;<br>
          }<br>
#ifdef CANCEL_TAG<br>
        if (!EQ_LEN(to))<br>
            continue;<br>
#else<br>
        /* relaxed matching -- we don't care about to-tags anymore,<br>
         * many broken UACs screw them up and ignoring them does not<br>
         * actually hurt<br>
         */<br>
        if (get_to(t_msg)-&gt;uri.len!=get_to(p_msg)-&gt;uri.len)<br>
            continue;<br>
#endif<br>
        if (ruri_matching &amp;&amp; !EQ_REQ_URI_LEN)<br>
          {<br>
            LM_DBG("RURI not matching\n") ;<br>
            continue;<br>
          }<br>
        if (via1_matching &amp;&amp; !EQ_VIA_LEN(via1))<br>
          {<br>
            LM_DBG("Via1 not matching\n") ;<br>
            continue;<br>
          }<br>
  <br>
        /* check the content now */<br>
        if (!EQ_STR(callid))<br>
          {<br>
            LM_DBG("callid not matching\n") ;<br>
            continue;<br>
          }<br>
        if (memcmp(get_cseq(t_msg)-&gt;number.s,<br>
          
 get_cseq(p_msg)-&gt;number.s,get_cseq(p_msg)-&gt;number.len)!=0)<br>
            continue;<br>
        if (!EQ_STR(from))<br>
          {<br>
            LM_DBG("from not matching\n") ;<br>
            continue;<br>
          }<br>
#ifdef CANCEL_TAG<br>
        if (!EQ_STR(to))<br>
            continue;<br>
#else<br>
        if (memcmp(get_to(t_msg)-&gt;uri.s, get_to(p_msg)-&gt;uri.s,<br>
                    get_to(t_msg)-&gt;uri.len)!=0)<br>
            continue;<br>
#endif<br>
        if (ruri_matching &amp;&amp; !EQ_REQ_URI_STR)<br>
          {<br>
            LM_DBG("ruri not matching\n") ;<br>
            continue;<br>
          }<br>
        if (via1_matching &amp;&amp; !EQ_VIA_STR(via1))<br>
          {<br>
            LM_DBG("via1 not matching\n") ;<br>
            continue;<br>
          }<br>
  <br>
        /* found */<br>
        goto found;<br>
    }<br>
  <br>
notfound:<br>
    /* no transaction found */<br>
    LM_DBG("no CANCEL matching found! \n" );<br>
    UNLOCK_HASH(hash_index);<br>
    cancelled_T = NULL;<br>
    LM_DBG("t_lookupOriginalT completed\n");<br>
    return 0;<br>
  <br>
found:<br>
    LM_DBG("canceled transaction found (%p)! \n",p_cell );<br>
    cancelled_T = p_cell;<br>
    REF_UNSAFE( p_cell );<br>
    UNLOCK_HASH(hash_index);<br>
    LM_DBG("t_lookupOriginalT completed\n");<br>
    return p_cell;<br>
}<br>
  <br>
</blockquote>
<br>
<br>
</body>
</html>

--------------080903090009050404030103--




More information about the Devel mailing list