[ previous ] [ next ] [ threads ]
 To :  <Yate@v...>
 From :  "Andrew McDonald" <andrew.mcdonald@n...>
 Subject :  [yate] SIP 302 response handling
 Date :  Mon, 21 Aug 2006 13:46:14 +0800
Hi, 

We run YATE (1.0) as a H323/SIP gateway and directly exposed to our SIP redirect server. For certain calls we wish to route via the redirect server which means we receive a 302 reponse. The ysipchan currently does not support handling a 302 reponse, although it does generate 302's for call redirection. 
I originally added support 302 response handling to a copy of Yate 0.9.4 and recently finished merging a 1.0 release. 

I am not sure whether anyone would find this a useful, or appropriate, addition, but thought I should at least make the changes available.

I have included the diffs to the YateSIPConnection::process(SIPEvent* ev) function
in the tagged RELEASE_1_0_0 version of ysipchan.cpp.

There are probably a few things that may need cleaning up. 

Firstly it simply treats all 3xx responses identically, which is probably fine for 301, 302, 305 but not for 380 etc, so you may wish to tighten up the guard condition.

Secondly I reconstructed the state inYateSipConnection that needed updating, by reading the outgoing call constructor and cutting and pasting appropriate parts, so someone may like to check I have the necessary and sufficient changes and possibly even put the common code into a utility member function ?? Possibly also the hangup code that is reused for a 302 without a contact.

2249c2249
<     if (msg && !msg->isOutgoing() && msg->isAnswer() && (code >= 300)) {
---
>     if (msg && !msg->isOutgoing() && msg->isAnswer() && (code >= 400)) {
2254a2255,2311
>     if (msg && !msg->isOutgoing() && msg->isAnswer() && (code >= 300) && (code < 400)) {
>         Debug(this,DebugInfo,"SIP Redirect response received");
>         SIPHeaderLine* contact = const_cast(msg->getHeader("Contact"));
>         if (!contact && !contact->empty())
>         {
>             Debug(this,DebugWarn,"SIP Redirect response with no contact");
>             m_cancel = false;
>             m_byebye = false;
>             setReason(msg->reason,code);
>             hangup();
>         }
>         else
>         {
>             SIPMessage* m = new SIPMessage(*(m_tr->initialMessage()));
>             // check if contact is quoted 
>             if (contact->at(0) == '<')
>             {
>                 m_uri = contact->substr(1,contact->length()-2);
>             }
>             else
>             {
>                 m->uri = *contact;
>             }
>             m->uri = m_uri;
>             plugin.ep()->buildParty(m);
> 
>             if (!m->getParty()) 
>             {
> 	        Debug(this,DebugWarn,"Could not create redirected party for '%s' [%p]",m_uri.c_str(),this);
> 	        m->destruct();
>             }
>             else
>             {
> 
>                 clearTransaction();
>                 m->complete(plugin.ep()->engine());
> 
>                 m_host = m->getParty()->getPartyAddr();
>                 m_port = m->getParty()->getPartyPort();
>                 m_address << m_host << ":" << m_port;
>                 filterDebug(m_address);
>                 m_dialog = *m;
>                 //SIPHeaderLine* hl = const_cast(getHeader("Via"));
>                 m_tr = plugin.ep()->engine()->addMessage(m);
>                 if (m_tr) 
>                 {
> 	            m_tr->ref();
> 	            m_callid = m_tr->getCallID();
> 	            m_tr->setUserData(this);
>                 }
>                 m->deref();
>             }
>         }  //has contact
>     }
> 

regards, 

Andrew McDonald
System Architect

> Norwood Systems Australia Pty Ltd
71 Troy Terrace
PO Box 1281
Subiaco, WA 6904

> Tel	+61 8 9380 7766		
> Fax	+61 8 9380 7733  		
andrew.mcdonald@n...
>  
> The information in this email, and any attachments, may contain confidential information and is intended solely for the attention and use of the named addressee (s). It must not be disclosed to any person(s) without authorization. If you are not the intended recipient, or a person responsible for delivering it to the intended>  recipient, you are not authorized to, and must not, disclose, copy, distribute, or retain this message or any part of it. If you have received this communication in error, please notify the sender immediately.
> 
> 
> 
>