< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] transaction matching/via checking


How much of the transaction matching/via checking is managed under the
covers of the SipStack in reciprocate?

If I wanted to implement a simple load balancer which forwards requests
off to another SIP proxy, would I have to manage the transactions and
proper via headers like repro does?

I am asking because I initially implemented a very trivial sip proxy
with resip that simply forwards requests to the destination and then
forwards the responses back to the top via (removing the top via).  The
problem occurred when the dumb client I was using, used the same magic
cookie for the second request as it did the first in the via.
Resiprocate matched this against the existing transaction and forward
the response to itself in the transaction manager, seemingly
indefinitely.

Ideally I would like to be able to just perform the code below; however,
I believe it may be too trivial of an implementation.  Please comment.

while (!isShutdown())
{
        resip::Message* msg = 0;

        try
        {
                if ((msg = mFifo.getNext(100)) != 0)
                {
                        resip::SipMessage* sip =
dynamic_cast<resip::SipMessage*>(msg);

                        if (sip)
                        {
                                if ( sip->isRequest() )
                                {
                                        addLocalVia( *sip ); /* adds top
via */
                                        resip::Uri destinationUri =
codethatcreatesdestination();
                                        mStack.sendTo(*sip,
destinationUri);
                                }
                                else if ( sip->isResponse() )
                                {
                        popTopVia(*sip); /* remove topmost via */
                                        mStack.send(*sip);
                                }
                                else
                                {
                                        WARN("Not a SIP request or
response.  I don't know how to process.  Dropping Message");
                                }
                        }
                        else
                        {
                                WARN("Not a SIP Message.  I don't know
how to process.  Dropping Message");
                        }
                }
        // Done with the message, get rid of it.
        delete msg;
        }
        catch (resip::BaseException& e)
      {
                WARN("Caught: %s", e.getMessage().c_str());
        }
        catch (...)
      {
        WARN("Caught unknown exception");
        }
}