|
reSIProcate/stack
9694
|
00001 #include "rutil/DataStream.hxx" 00002 00003 #include "resip/stack/SipMessage.hxx" 00004 #include "resip/stack/Helper.hxx" 00005 #include "resip/stack/Uri.hxx" 00006 #include "resip/stack/ApplicationSip.hxx" 00007 #include "TestSupport.hxx" 00008 00009 #include <iostream> 00010 #include <memory> 00011 00012 using namespace resip; 00013 using namespace std; 00014 00015 int 00016 main() 00017 { 00018 { 00019 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 00020 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 00021 "To: Bob <sip:bob@biloxi.com>\r\n" 00022 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 00023 "Call-ID: a84b4c76e66710\r\n" 00024 "CSeq: 314159 INVITE\r\n" 00025 "Max-Forwards: 70\r\n" 00026 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 00027 "Content-Type: application/sip\r\n" 00028 "Content-Length: 35\r\n" 00029 "\r\n" 00030 "INVITE sip:bob@biloxi.com SIP/2.0\r\n"); 00031 00032 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 00033 00034 Contents* body = msg->getContents(); 00035 00036 assert(body != 0); 00037 ApplicationSip* frag = dynamic_cast<ApplicationSip*>(body); 00038 assert(frag != 0); 00039 00040 std::cerr << "!! "; 00041 frag->encode(resipCerr); 00042 00043 assert(frag->message().header(h_RequestLine).uri().user() == "bob"); 00044 msg->encode(resipCerr); 00045 } 00046 00047 { 00048 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 00049 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 00050 "To: Bob <sip:bob@biloxi.com>\r\n" 00051 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 00052 "Call-ID: a84b4c76e66710\r\n" 00053 "CSeq: 314159 INVITE\r\n" 00054 "Max-Forwards: 70\r\n" 00055 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 00056 "Content-Type: application/sip\r\n" 00057 "\r\n" 00058 "INVITE sip:bob@biloxi.com SIP/2.0\r\n" 00059 "From: Alice <sip:alice@atlanta.com>\r\n" 00060 "To: Bob <sip:bob@biloxi.com>\r\n" 00061 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 00062 "Date: Thu, 21 Feb 2002 13:02:03 GMT\r\n" 00063 "Call-ID: a84b4c76e66710\r\n" 00064 "Cseq: 314159 INVITE\r\n\r\n"); 00065 00066 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 00067 00068 Contents* body = msg->getContents(); 00069 00070 assert(body != 0); 00071 ApplicationSip* frag = dynamic_cast<ApplicationSip*>(body); 00072 assert(frag != 0); 00073 00074 std::cerr << "!! "; 00075 frag->encode(resipCerr); 00076 00077 assert(frag->message().exists(h_From)); 00078 assert(frag->message().header(h_From).uri().user() == "alice"); 00079 00080 assert(frag->message().exists(h_CSeq)); 00081 assert(frag->message().header(h_CSeq).sequence() == 314159); 00082 00083 msg->encode(resipCerr); 00084 } 00085 00086 // backward compatibiltiy with SipFrag 00087 { 00088 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 00089 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 00090 "To: Bob <sip:bob@biloxi.com>\r\n" 00091 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 00092 "Call-ID: a84b4c76e66710\r\n" 00093 "CSeq: 314159 INVITE\r\n" 00094 "Max-Forwards: 70\r\n" 00095 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 00096 "Content-Type: application/sip\r\n" 00097 "\r\n" 00098 "INVITE sip:bob@biloxi.com SIP/2.0\r\n" 00099 "From: Alice <sip:alice@atlanta.com>\r\n" 00100 "To: Bob <sip:bob@biloxi.com>\r\n" 00101 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 00102 "Date: Thu, 21 Feb 2002 13:02:03 GMT\r\n" 00103 "Call-ID: a84b4c76e66710\r\n" 00104 "Cseq: 314159 INVITE\r\n\r\n"); 00105 00106 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 00107 00108 Contents* body = msg->getContents(); 00109 00110 assert(body != 0); 00111 SipFrag* frag = dynamic_cast<SipFrag*>(body); 00112 assert(frag != 0); 00113 00114 std::cerr << "!! "; 00115 frag->encode(resipCerr); 00116 00117 assert(frag->message().exists(h_From)); 00118 assert(frag->message().header(h_From).uri().user() == "alice"); 00119 00120 assert(frag->message().exists(h_CSeq)); 00121 assert(frag->message().header(h_CSeq).sequence() == 314159); 00122 00123 msg->encode(resipCerr); 00124 } 00125 00126 cerr << "\nTEST OK" << endl; 00127 00128 return 0; 00129 } 00130 00131 /* ==================================================================== 00132 * The Vovida Software License, Version 1.0 00133 * 00134 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00135 * 00136 * Redistribution and use in source and binary forms, with or without 00137 * modification, are permitted provided that the following conditions 00138 * are met: 00139 * 00140 * 1. Redistributions of source code must retain the above copyright 00141 * notice, this list of conditions and the following disclaimer. 00142 * 00143 * 2. Redistributions in binary form must reproduce the above copyright 00144 * notice, this list of conditions and the following disclaimer in 00145 * the documentation and/or other materials provided with the 00146 * distribution. 00147 * 00148 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00149 * and "Vovida Open Communication Application Library (VOCAL)" must 00150 * not be used to endorse or promote products derived from this 00151 * software without prior written permission. For written 00152 * permission, please contact vocal@vovida.org. 00153 * 00154 * 4. Products derived from this software may not be called "VOCAL", nor 00155 * may "VOCAL" appear in their name, without prior written 00156 * permission of Vovida Networks, Inc. 00157 * 00158 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00159 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00160 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00161 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00162 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00163 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00164 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00165 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00166 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00167 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00168 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00169 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00170 * DAMAGE. 00171 * 00172 * ==================================================================== 00173 * 00174 * This software consists of voluntary contributions made by Vovida 00175 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00176 * Inc. For more information on Vovida Networks, Inc., please see 00177 * <http://www.vovida.org/>. 00178 * 00179 */
1.7.5.1