PreProcessRouteInfo() public method

This function performs processing on a request to handle any actions that need to be taken based on the Route header.
The main sections in the RFC3261 dealing with Route header processing are sections 12.2.1.1 for request processing and 16.4 for proxy processing. The steps to process requests for Route headers are: 1. If route set is empty no further action is required, forward to destination resolved from request URI, 2. If the request URI is identified as a value that was previously set as a Route by this SIP agent it means the previous hop was a strict router. Replace the reqest URI with the last Route header and go to next step, 3. If the top most route header was set by this SIP agent then remove it and go to next step, 4. If the top most route set does contain the lr parameter then forward to the destination resolved by it, 5. If the top most route header does NOT contain the lr parameter is must be popped and inserted as the request URI and the original request URI must be added to the end of the route set, forward to destination resolved from request URI,
public PreProcessRouteInfo ( SIPRequest sipRequest ) : void
sipRequest SIPRequest
return void
        public void StrictRoutePriorToProxyUnitTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            string sipMsg =
                "INVITE sip:82.195.148.216:5062;lr SIP/2.0" + m_CRLF +
                "Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001" + m_CRLF +
                "Route: <sip:89.100.92.186:45270;lr>,<sip:[email protected]>" + m_CRLF +
                "From: SER Test X <sip:[email protected]:5065>;tag=196468136" + m_CRLF +
                "To: <sip:[email protected]>" + m_CRLF +
                "Contact: <sip:[email protected]:5065>" + m_CRLF +
                "Call-ID: [email protected]" + m_CRLF +
                "CSeq: 49429 INVITE" + m_CRLF +
                "Max-Forwards: 70" + m_CRLF +
                "Content-Type: application/sdp" + m_CRLF +
                "User-Agent: X-PRO release 1103v" + m_CRLF +
                m_CRLF;

            SIPMessage sipMessage = SIPMessage.ParseSIPMessage(Encoding.UTF8.GetBytes(sipMsg), null, null);
            SIPRequest inviteReq = SIPRequest.ParseSIPRequest(sipMessage);

            SIPTransport mockSIPTransport = new SIPTransport(MockSIPDNSManager.Resolve, null, false);
            mockSIPTransport.AddSIPChannel(new MockSIPChannel(IPSocket.ParseSocketString("82.195.148.216:5062")));

            mockSIPTransport.PreProcessRouteInfo(inviteReq);

            Console.WriteLine(inviteReq.ToString());
            Console.WriteLine("Next Route=" + inviteReq.Header.Routes.TopRoute.ToString());
            Console.WriteLine("Request URI=" + inviteReq.URI.ToString());

            Assert.IsTrue(inviteReq.Header.Routes.TopRoute.ToString() == "<sip:89.100.92.186:45270;lr>", "Top route was not correct.");
            Assert.IsTrue(inviteReq.URI.ToString() == "sip:[email protected]", "The request URI was incorrectly adjusted.");
            Assert.IsTrue(inviteReq.Header.Routes.Length == 1, "The route set was not correct.");
        }
        public void AvayaInviteUnitTest()
        {
            Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            string sipMsg =
                "INVITE sip:194.213.29.100:5060 SIP/2.0" + m_CRLF +
                "Via: SIP/2.0/UDP 10.1.1.241;branch=z9hG4bK94fc63626" + m_CRLF +
                "To: UNKNOWN <sip:[email protected]>" + m_CRLF +
                "From: 'Joe Bloggs' <sip:[email protected]>;tag=cc16d34c122e5fe" + m_CRLF +
                "Call-ID: [email protected]" + m_CRLF +
                "CSeq: 2009546910 INVITE" + m_CRLF +
                "Contact: 'Val Gavin' <sip:[email protected]>" + m_CRLF +
                "Max-Forwards: 70" + m_CRLF +
                "Route: <sip:[email protected]>" + m_CRLF +    // Strict Route header (this header is actually a fault but it ends up being a strict route).
                "User-Agent: NeuralX MxSF/v3.2.6.26" + m_CRLF +
                "Content-Type: application/sdp" + m_CRLF +
                "Content-Length: 318" + m_CRLF +
                "P-Asserted-Identity: 'Joe Bloggs' <sip:[email protected]>" + m_CRLF +
                "Allow: INVITE" + m_CRLF +
                "Allow: CANCEL" + m_CRLF +
                "Allow: OPTIONS" + m_CRLF +
                "Allow: BYE" + m_CRLF +
                "Allow: REFER" + m_CRLF +
                "Allow: INFO" + m_CRLF +
                "Allow: UPDATE" + m_CRLF +
                "Supported: replaces" + m_CRLF +
                m_CRLF +
                "v=0" + m_CRLF +
                "o=xxxxx 1174909600 1174909601 IN IP4 10.1.1.241" + m_CRLF +
                "s=-" + m_CRLF +
                "c=IN IP4 10.1.1.241" + m_CRLF +
                "t=0 0" + m_CRLF +
                "a=sendrecv" + m_CRLF +
                "m=audio 20026 RTP/AVP 8 0 18 101" + m_CRLF +
                "a=rtpmap:8 PCMA/8000" + m_CRLF +
                "a=rtpmap:0 PCMU/8000" + m_CRLF +
                "a=rtpmap:18 G729/8000" + m_CRLF +
                "a=rtpmap:101 telephone-event/8000" + m_CRLF +
                "a=fmtp:18 annexb=no" + m_CRLF +
                "a=fmtp:101 0-15" + m_CRLF +
                "a=ptime:20" + m_CRLF +
                "a=rtcp:20027 IN IP4 10.1.1.241";

            SIPMessage sipMessage = SIPMessage.ParseSIPMessage(Encoding.UTF8.GetBytes(sipMsg), null, null);
            SIPRequest inviteReq = SIPRequest.ParseSIPRequest(sipMessage);

            SIPTransport mockSIPTransport = new SIPTransport(MockSIPDNSManager.Resolve, null, false);
            mockSIPTransport.AddSIPChannel(new MockSIPChannel(IPSocket.ParseSocketString("194.213.29.100:5060")));

            mockSIPTransport.PreProcessRouteInfo(inviteReq);

            Console.WriteLine(inviteReq.ToString());

            Assert.IsTrue(inviteReq.URI.ToString() == "sip:[email protected]", "The request URI was not updated to the strict route.");
            Assert.IsTrue(inviteReq.Header.Routes.TopRoute.URI.ToString() == "sip:194.213.29.100:5060", "The route set was not correctly updated.");

            Console.WriteLine("-----------------------------------------");
        }