All pastes #39507 Raw Edit

Unnamed

public text v1 · immutable
#39507 ·published 2006-02-01 19:37 UTC
rendered paste body
void YateSIPConnection::reInvite(SIPTransaction* t)
{
    if (!checkUser(t))
        return;
    DDebug(this,DebugAll,"YateSIPConnection::reInvite(%p) [%p]",t,this);
    // hack: use a while instead of if so we can return or break out of it
    while (t->initialMessage()->body && t->initialMessage()->body->isSDP()) {
        // accept re-INVITE only for local RTP, not for pass-trough
        //if (m_rtpForward || (m_mediaStatus == MediaMissing))
        //    break;

        String addr;
        ObjList* lst = parseSDP(static_cast<SDPBody*>(t->initialMessage()->body),addr);
        if (!lst)
            break;
        // guess if the call comes from behind a NAT
	        if (s_auto_nat && isPrivateAddr(addr) && !isPrivateAddr(m_host)) {
            Debug(this,DebugInfo,"RTP NAT detected: private '%s' public '%s'",
                addr.c_str(),m_host.c_str());
            addr = m_host;
        }
        m_rtpAddr = addr;
        setMedia(lst);
        Debug(this,DebugAll,">>>>>>>>>>>>>>>>>>>>>>>New RTP addr '%s'<<<<<<<<<<<<<<<<<<<<<<<",m_rtpAddr.c_str());

        if (m_rtpForward) {
                SIPMessage* m = new SIPMessage(t->initialMessage());

                // modify sip headers for outgoing?

                SDPBody* sdp = createPassTroughSDP(t->initialMessage());
                m->setBody(sdp);

                // gen new transaction and send message on it's way?

                m->deref();
        } else {

                m_mediaStatus = MediaMissing;
                // let RTP guess again the local interface
                m_rtpLocalAddr.clear();
                // clear all data endpoints - createRtpSDP will build new ones
                clearEndpoint();
        }

        SIPMessage* m = new SIPMessage(t->initialMessage(), 200);
        if (m_rtpForward)
                SDPBody* sdp = createPassTroughSDP(t->initialMessage());
        else
                SDPBody* sdp = createRtpSDP(true);
        m->setBody(sdp);
        t->setResponse(m);
        m->deref();
        return;
    }
    t->setResponse(488);
}