|
reSIProcate/stack
9694
|
00001 #include "resip/stack/SipMessage.hxx" 00002 #include "resip/stack/Uri.hxx" 00003 #include "resip/stack/test/TestSupport.hxx" 00004 00005 #include <iostream> 00006 #include <memory> 00007 00008 using namespace resip; 00009 using namespace std; 00010 00011 int 00012 main() 00013 { 00014 { 00015 const char *txt1 = "REGISTER sip:registrar.biloxi.com SIP/2.0\r\nVia: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\nMax-Forwards: 70\r\nTo: Bob <sip:bob@biloxi.com>\r\nFrom: Bob <sip:bob@biloxi.com>;tag=456248\r\nCall-ID: 843817637684230@998sdasdh09\r\nCSeq: 1826 REGISTER\r\nContact: <sip:bob@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n"; 00016 00017 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1))); 00018 auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt1))); 00019 00020 NameAddr local; 00021 00022 local = message1->header(h_From); 00023 local = message2->header(h_From); 00024 } 00025 00026 { 00027 resipCerr << "Testing raw header transfer" << endl; 00028 00029 const char *txt1 = "REGISTER sip:registrar.biloxi.com SIP/2.0\r\nVia: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\nMax-Forwards: 70\r\nTo: Bob <sip:bob@biloxi.com>\r\nFrom: Bob <sip:bob@biloxi.com>;tag=456248\r\nCall-ID: 843817637684230@998sdasdh09\r\nCSeq: 1826 REGISTER\r\nContact: <sip:bob@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n"; 00030 00031 const char *txt2 = "REGISTER sip:registrar.ixolib.com SIP/2.0\r\nVia: SIP/2.0/UDP qoqspc.ixolib.com:5060;branch=2222222222\r\nMax-Forwards: 70\r\nTo: Qoq <sip:qoq@ixolib.com>\r\nFrom: Qoq <sip:qoq@ixolib.com>;tag=456248\r\nCall-ID: 111111111111111\r\nCSeq: 6281 REGISTER\r\nContact: <sip:qoq@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n"; 00032 00033 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1))); 00034 auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt2))); 00035 00036 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer() == 0); 00037 assert(message2->getRawHeader(Headers::CSeq)->getParserContainer() == 0); 00038 00039 message1->setRawHeader(message2->getRawHeader(Headers::CSeq), Headers::CSeq); 00040 message1->encode(resipCerr) << endl; 00041 assert(message1->header(h_CSeq).sequence() == 6281); 00042 } 00043 00044 { 00045 resipCerr << "Testing raw header transfer post parse" << endl; 00046 00047 const char *txt1 = "REGISTER sip:registrar.biloxi.com SIP/2.0\r\nVia: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\nMax-Forwards: 70\r\nTo: Bob <sip:bob@biloxi.com>\r\nFrom: Bob <sip:bob@biloxi.com>;tag=456248\r\nCall-ID: 843817637684230@998sdasdh09\r\nCSeq: 1826 REGISTER\r\nContact: <sip:bob@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n"; 00048 00049 const char *txt2 = "REGISTER sip:registrar.ixolib.com SIP/2.0\r\nVia: SIP/2.0/UDP qoqspc.ixolib.com:5060;branch=2222222222\r\nMax-Forwards: 70\r\nTo: Qoq <sip:qoq@ixolib.com>\r\nFrom: Qoq <sip:qoq@ixolib.com>;tag=456248\r\nCall-ID: 111111111111111\r\nCSeq: 6281 REGISTER\r\nContact: <sip:qoq@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n"; 00050 00051 00052 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1))); 00053 auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt2))); 00054 00055 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer() == 0); 00056 assert(message2->getRawHeader(Headers::CSeq)->getParserContainer() == 0); 00057 00058 // causes parse 00059 assert(message2->header(h_CSeq).sequence() == 6281); 00060 // should have a parsed header 00061 assert(message2->getRawHeader(Headers::CSeq)->getParserContainer()); 00062 00063 // should still work, but copies 00064 message1->setRawHeader(message2->getRawHeader(Headers::CSeq), Headers::CSeq); 00065 message1->encode(resipCerr) << endl; 00066 assert(message1->header(h_CSeq).sequence() == 6281); 00067 00068 // should have a parsed header 00069 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer()); 00070 } 00071 00072 resipCout << "All OK" << endl; 00073 return 0; 00074 } 00075 00076 00077 /* ==================================================================== 00078 * The Vovida Software License, Version 1.0 00079 * 00080 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00081 * 00082 * Redistribution and use in source and binary forms, with or without 00083 * modification, are permitted provided that the following conditions 00084 * are met: 00085 * 00086 * 1. Redistributions of source code must retain the above copyright 00087 * notice, this list of conditions and the following disclaimer. 00088 * 00089 * 2. Redistributions in binary form must reproduce the above copyright 00090 * notice, this list of conditions and the following disclaimer in 00091 * the documentation and/or other materials provided with the 00092 * distribution. 00093 * 00094 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00095 * and "Vovida Open Communication Application Library (VOCAL)" must 00096 * not be used to endorse or promote products derived from this 00097 * software without prior written permission. For written 00098 * permission, please contact vocal@vovida.org. 00099 * 00100 * 4. Products derived from this software may not be called "VOCAL", nor 00101 * may "VOCAL" appear in their name, without prior written 00102 * permission of Vovida Networks, Inc. 00103 * 00104 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00105 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00106 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00107 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00108 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00109 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00110 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00111 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00112 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00113 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00114 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00115 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00116 * DAMAGE. 00117 * 00118 * ==================================================================== 00119 * 00120 * This software consists of voluntary contributions made by Vovida 00121 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00122 * Inc. For more information on Vovida Networks, Inc., please see 00123 * <http://www.vovida.org/>. 00124 * 00125 */
1.7.5.1