/[resiprocate]/main/resip/stack/test/testSipMessageMemory.cxx
ViewVC logotype

Annotation of /main/resip/stack/test/testSipMessageMemory.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 567 - (hide annotations) (download)
Fri Nov 8 17:46:03 2002 UTC (17 years, 1 month ago) by jason
Original Path: main/sip/resiprocate/test/testSipMessageMemory.cxx
File size: 6151 byte(s)
*** empty log message ***

1 jason 537 #include "sip2/sipstack/SipMessage.hxx"
2     #include "sip2/sipstack/Preparse.hxx"
3     #include "sip2/sipstack/Uri.hxx"
4 jason 567 #include "sip2/sipstack/Helper.hxx"
5 derekm 513
6     #include <iostream>
7    
8     using namespace Vocal2;
9     using namespace std;
10    
11     int
12     main()
13     {
14     {
15 jason 567 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";
16    
17     auto_ptr<SipMessage> message1(Helper::makeMessage(Data(txt1)));
18     auto_ptr<SipMessage> message2(Helper::makeMessage(Data(txt1)));
19    
20     NameAddr local;
21    
22     local = message1->header(h_From);
23     local = message2->header(h_From);
24     }
25    
26     {
27 derekm 513 cerr << "Testing raw header transfer" << endl;
28    
29     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";
30    
31     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";
32    
33 jason 567 auto_ptr<SipMessage> message1(Helper::makeMessage(Data(txt1)));
34     auto_ptr<SipMessage> message2(Helper::makeMessage(Data(txt2)));
35 derekm 513
36 jason 567 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
37     assert(message2->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
38 derekm 513
39 jason 567 message1->setRawHeader(message2->getRawHeader(Headers::CSeq), Headers::CSeq);
40     message1->encode(cerr) << endl;
41     assert(message1->header(h_CSeq).sequence() == 6281);
42 derekm 513 }
43    
44     {
45     cerr << "Testing raw header transfer post parse" << endl;
46    
47     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";
48    
49     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";
50    
51    
52 jason 567 auto_ptr<SipMessage> message1(Helper::makeMessage(Data(txt1)));
53     auto_ptr<SipMessage> message2(Helper::makeMessage(Data(txt2)));
54 derekm 513
55 jason 567 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
56     assert(message2->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
57 derekm 513
58     // causes parse
59 jason 567 assert(message2->header(h_CSeq).sequence() == 6281);
60 derekm 513 // should have a parsed header
61 jason 567 assert(message2->getRawHeader(Headers::CSeq)->getParserContainer());
62 derekm 513
63     // should still work, but copies
64 jason 567 message1->setRawHeader(message2->getRawHeader(Headers::CSeq), Headers::CSeq);
65     message1->encode(cerr) << endl;
66     assert(message1->header(h_CSeq).sequence() == 6281);
67 derekm 513
68     // should have a parsed header
69 jason 567 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer());
70 derekm 513 }
71     }
72    
73    
74     /* ====================================================================
75     * The Vovida Software License, Version 1.0
76     *
77     * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
78     *
79     * Redistribution and use in source and binary forms, with or without
80     * modification, are permitted provided that the following conditions
81     * are met:
82     *
83     * 1. Redistributions of source code must retain the above copyright
84     * notice, this list of conditions and the following disclaimer.
85     *
86     * 2. Redistributions in binary form must reproduce the above copyright
87     * notice, this list of conditions and the following disclaimer in
88     * the documentation and/or other materials provided with the
89     * distribution.
90     *
91     * 3. The names "VOCAL", "Vovida Open Communication Application Library",
92     * and "Vovida Open Communication Application Library (VOCAL)" must
93     * not be used to endorse or promote products derived from this
94     * software without prior written permission. For written
95     * permission, please contact vocal@vovida.org.
96     *
97     * 4. Products derived from this software may not be called "VOCAL", nor
98     * may "VOCAL" appear in their name, without prior written
99     * permission of Vovida Networks, Inc.
100     *
101     * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
102     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
103     * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
104     * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
105     * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
106     * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
107     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
108     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
109     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
110     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
112     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
113     * DAMAGE.
114     *
115     * ====================================================================
116     *
117     * This software consists of voluntary contributions made by Vovida
118     * Networks, Inc. and many individuals on behalf of Vovida Networks,
119     * Inc. For more information on Vovida Networks, Inc., please see
120     * <http://www.vovida.org/>.
121     *
122     */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27