[Kamailio-Devel] [Bulk] Re: [tm] t_lookupOriginalT : cannot find matching INVITE for CANCEL because of display name

Aurelien Grimaud gstelzz at yahoo.fr
Tue Jan 20 15:19:57 CET 2009


Iñaki Baz Castillo a écrit :
> 2009/1/20 Aurelien Grimaud <gstelzz at yahoo.fr>:
>   
>> Hi,
>> it seems that I have a problem with finding initial INVITE when request is
>> CANCELED.
>> sipp uac (192.168.160.141:5064) contact a uas (192.168.160.23:6075) through
>> kamailio 1.4.3 (192.168.160.141:5060)
>>
>> The request is CANCELED by uac.
>> But From field is taken from 180 reply and is trhough slightly different
>> from initial one.
>> The display name is quoted and whitespace is missing.
>>
>> This makes the t_lookupOriginalT fails .... attached log from kamailio
>> (check the end)
>>     
>
> This is annoying:
>
> The From in the reply has been changed but remains the same (same
> From_tag, URI and Display-Name, but the Display name is quoted).
>
> Then the UAC uses that modified From when generating the CANCEL and
> you say that Kamailio fails to match the INVITE transaction since the
> From URI doesn't match the From in the INVITE transaction.
> 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"<sip:1-16122-192.168.160.141 at 192.168.160.141:5064>;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.
>   
This one work, I checked it.
the t_lookupOriginalT functions which is used for CANCEL matching uses 
the full header string for a match ...
Headers are not parsed. This cannot work ...

> #define EQ_LEN(_hf) (t_msg->_hf->body.len==p_msg->_hf->body.len)
>
> #define EQ_STR(_hf) (memcmp(t_msg->_hf->body.s,\
>     p_msg->_hf->body.s, \
>     p_msg->_hf->body.len)==0)

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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/devel/attachments/20090120/4cab996f/attachment-0001.htm 


More information about the Devel mailing list