|
reSIProcate/stack
9694
|
00001 #include <iostream> 00002 #include <memory> 00003 00004 #include "rutil/DataStream.hxx" 00005 #include "resip/stack/SipMessage.hxx" 00006 #include "resip/stack/Helper.hxx" 00007 #include "resip/stack/Uri.hxx" 00008 #include "resip/stack/Helper.hxx" 00009 #include "resip/stack/SdpContents.hxx" 00010 #include "resip/stack/test/TestSupport.hxx" 00011 #include "resip/stack/PlainContents.hxx" 00012 #include "resip/stack/UnknownHeaderType.hxx" 00013 #include "resip/stack/UnknownParameterType.hxx" 00014 #include "rutil/Logger.hxx" 00015 #include "rutil/ParseBuffer.hxx" 00016 #include "rutil/Inserter.hxx" 00017 00018 using namespace resip; 00019 using namespace std; 00020 00021 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST 00022 #define CRLF "\r\n" 00023 #define RESIP_COOKIE "-524287-" 00024 00025 //vis -o to make binary bodies text 00026 00027 int 00028 main(int argc, char** argv) 00029 { 00030 Log::initialize(Log::Cout, Log::Debug, argv[0]); 00031 static ExtensionParameter p_tag_ext("tag"); 00032 # 00033 Data txt( 00034 "SIP/2.0 401 Unauthorized\r\n" 00035 "To: <sip:6309790007@ahenc1.ascc.lucent.com>;tag=43822895-1132606320408559\r\n" 00036 "From: \"Kit LDAP\"<sip:6309790007@ahenc1.ascc.lucent.com>;tag=64505823\r\n" 00037 "Call-ID: 7574556ad424b15c@aW5zcDc1MDAudW5pY29uLWludGwuY29t\r\n" 00038 "CSeq: 1 PUBLISH\r\n" 00039 "Via: SIP/2.0/UDP 67.184.22.204:33001;received=67.184.22.204;branch=z9hG4bK" RESIP_COOKIE "1---861ee62db418b378\r\n" 00040 "Server: Lucent SIPTRANS 1.2\r\n" 00041 "WWW-Authenticate: Digest realm=\"aP3nFt10ziWg41Su4s8\", \r\n" 00042 " nonce=\"d6cb083cced5583c140c5f99eb81feda\", algorithm=MD5, qop=\"auth\", \r\n" 00043 " opaque=\"f2a62109ee6526c8760e4e7497861aac\"\r\n" 00044 "Content-Length: 0\r\n" 00045 "\r\n" 00046 ); 00047 initNetwork(); 00048 00049 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt)); 00050 assert(msg.get()); 00051 resipCerr << Inserter(msg->header(h_WWWAuthenticates)) << endl; 00052 00053 resipCerr << "[" << msg->header(h_WWWAuthenticates).back().param(p_opaque) << "]" << endl; 00054 00055 assert(msg->header(h_WWWAuthenticates).back().param(p_opaque) == "f2a62109ee6526c8760e4e7497861aac"); 00056 00057 { 00058 Data txt( 00059 "To: sip:fluffy@h1.cs.sipit.net\r\n" 00060 "From: tofu <sip:tofu@ua.ntt.sipit.net>;tag=5494179792598219348\r\n" 00061 "CSeq: 1 SUBSCRIBE\r\n" 00062 "Call-ID: 1129541551360711705\r\n" 00063 "Contact: sip:tofu@ua.ntt.sipit.net:5060\r\n" 00064 "Event: presence\r\n" 00065 "Content-Length: 0\r\n" 00066 "Expires: 3600\r\n" 00067 "User-Agent: NTT SecureSession User-Agent\r\n" 00068 "\r\n" 00069 "--Dfk2rISgfWIirrOJ\r\n" 00070 "Content-Type: application/pkcs7-signature; name=\"smime.p7s\"\r\n" 00071 "Content-Transfer-Encoding: binary\r\n" 00072 "Content-Disposition: attachment; filename=\"smime.p7s\"; handling=required\r\n" 00073 "0\202\004\201\327\006 *\206H\206\367\001\007\002\201\240\202\004\201\3100\202\004\201\304\002\001\0011\0130 \006\005+\003\002\032\005\000\201\260\013\006 \201\252\206\201\310\206\367\001\007\001\201\240\202\003\201\376\201\260\202\003\201\372\201\260\202\002\201\343\201\240\003\002\001\002\002\007\201\322\000\002\000\201\327\003\201\313\201\260\006 \201\252\206\201\310\206\367\001\001\005\005\000\201\260\201\360\201\261\013\201\260 \006\003\201\325\004\006\023\002\201\325\201\323\201\261\023\201\260\021\006\003\201\325\004\010\023r\201\303\201\341\201\354\201\351\201\346\201\357\201\362\201\356\201\351\201\341\201\261\021\201\260\006\003U\004\007\023\010San Jose1\201\260\014\006\003\201\325\004\023\005\201\363\201\351\201\360\201\351\201\364\201\261\201\251\201\260\201\247\006\003\201\325\004\013\023\201\240\201\323\201\351\201\360\201\351\201\364\201\240\201\324\201\345\201\363\201\364\201\240\201\303\201\345\201\362\201\364\201\351\201\346\201\351\201\343\201\341\201\364\201\345\201\240\201\301\201\365\201\364\201\350\201\357\201\362\201\351\201\364\201\371\201\260\036\027\201\260\201\264\201\260\201\270\201\262\201\265\201\260\201\262\201\261\201\270\201\264\201\270\201\332\027\201\260\201\267\201\260\201\270\201\262\201\265\201\260\201\262\201\261\201\270\201\264\201\270\201\332\201\260\201\345\201\261\013\201\260 \006\003\201\325\004\006\023\002\201\325\201\323\201\261\023\201\260\021\006\003\201\325\004\010\023\201\303\201\341\201\354\201\351\201\346\201\357\201\362\201\356\201\351\201\341\201\261\021\201\260\006\003U\004\007\023\010San Jose1\201\260\014\006\003\201\325\004\005\201\363\201\351\201\360\201\351\201\364\201\261\036\201\260\034\006\003\201\325\004\003\024\025\201\364\201\357\201\346\201\365\201\300\201\365\201\341\201\256\201\356\201\364\201\364\201\256\201\363\201\351\201\360\201\351\201\364\201\256\201\356\201\345\201\364\201\260\201\237\201\260\006 \201\252\206\201\310\206\367\001\001\001\005\000\003\201\215\000\201\260\201\211\002\201\201\000\201\331\201\322\201\267\201\345\201\263\201\337\201\201\365\201\246\201\317\201\337\201\314\201\343\201\350\201\370\201\332\201\372\201\366\201\356\227\201\260\010\201\304\201\326\005\201\253\014\201\316\201\335\201\362\201\253\201\336\036\201\326\201\247\201\365\201\321\201\342\201\312\201\336\201\310\030\201\310\034\201\325\201\274\201\255\201\336\201\372\201\306\201\277\201\303\201\364\201\343\201\355\201\240\201\323\201\374\201\347\201\240\004\201\363\205\316\230\205\320\205\261\205\255\211\205\205\261\205\276\205\333\205\277\205\350\205\274\205\361\021\201\260\201\255\201\265\201\276\201\373\203\201\267\201\356\201\355\201\256\201\337\201\262\201\244\201\305\033\023\000\201\266\206\021\201\303\201\252\201\265\201\364\001\201\246\201\251\030\201\372\235\201\325\201\273\037\201\251\201\332\201\354\201\331\201\371\201\263\201\261\201\347\236\201\322\201\376\201\274\201\332\201\377\002\003\001\000\001\201\243\202\001\201\247\201\260\202\001\201\243\201\260\201\332\006\003\201\325\035\021\004\201\323\201\260\201\321\206\031\201\363\201\351\201\360\201\272\201\364\201\357\201\346\201\365\201\300\201\365\201\341\201\256\201\356\201\364\201\364\201\256\201\363\201\351\201\360\201\351\201\364\201\256\201\356\201\345\201\364\206\030\201\351\201\355\201\272\201\364\201\357\201\346\201\365\201\300\201\365\201\341\201\256\201\356\201\364\201\364\201\256\201\363\201\351\201\360\201\351\201\364\201\256\201\356\201\345\201\364\206\032\201\360\201\362\201\345\201\363\201\272\201\364\201\357\201\346\201\365\201\300\201\365\201\341\201\256\201\356\201\364\201\364\201\256\201\363\201\351\201\360\201\351\201\364\201\256\201\356\201\345\201\364\201\260 \006\003\201\325\035\023\004\002\201\260\000\201\260\035\006\003\201\325\035\004\026\004\024 \026\201\307\201\306l\201\242\234\013\201\261\034\237\201\247\201\262\035\201\254B\201\357\201\324\201\2660\201\232\006\003U\035#\004\201\2220\201\217\200\024kF\027\024\201\352\224v%\200Tn\023T\201\332\201\241\201\343T\024\201\241\201\266\201\241t\201\244r0p1\0130 \006\003U\004\006\023\002US1\0230\021\006\003U\004\010\023California1\0210\006\003U\004\007\023\010San Jose1\201\260\014\006\003\201\325\004\023\005\201\363\201\351\201\360\201\351\201\364\201\261\201\251\201\260\201\247\006\003\201\325\004\013\023\201\240\201\323\201\351\201\360\201\351\201\364\201\240\201\324\201\345\201\363\201\364\201\240\201\303\201\345\201\362\201\364\201\351\201\346\201\351\201\343\201\341\201\364\201\345\201\240\201\301\201\365\201\364\201\350\201\357\201\362\201\351\201\364\201\371\202\001\000\201\260\006 \201\252\206\201\310\206\367\001\001\005\005\000\003\201\201\000\201\241\201\311\201\336\226\201\321\201\365\201\256\201\256\005\201\245\215\310\215\320\215\260\024\201\351\201\301\201\377\201\270\201\337\201\260\201\306\203\201\241\201\307\203\355\032\201\246\003\201\334\201\264\010\201\321\000\201\261\201\255\201\261\201\366\201\304\201\346\201\270\201\313\226\210\201\363\014\201\256\201\277\201\302\201\240\201\361\201\366\201\352\201\344\201\255\201\327\201\263\236\201\355\201\272\010\236\201\277\201\245\201\267\201\316\201\300\201\311\201\357\201\336\201\277\201\360\201\366\201\302\201\262\201\373\201\261\201\351\201\345\201\243\201\330\201\325\201\271\201\277\201\264\234\201\363\007\021\201\247\201\314\201\265\201\243\201\242\201\253\201\353\201\266\201\313\201\341\201\341\201\340\201\316\232\205\244\205\324\205\267\205\363\205\351\205\257\205\373\205\267\010\201\362\201\240\201\273\201\324\201\265\211\264\030\201\372\201\356\201\326\201\323\201\261\202\001\201\241\201\260\202\001\035\002\001\001\201\260\201\373\201\260\201\360\201\261\013\201\260 \006\003\201\325\004\006\023\002\201\325\201\323\201\261\023\201\260\021\006\003\201\325\004\010\023\201\303\201\341\201\354\201\351\201\346\201\357\201\362\201\356\201\351\201\341\201\261\021\201\260\006\003U\004\007\023\010San Jose1\201\260\014\006\003\201\325\004\023\005\201\363\201\351\201\360\201\351\201\364\201\261\201\251\201\260\201\247\006\003\201\325\004\013\023\201\240\201\323\201\351\201\360\201\351\201\364\201\240\201\324\201\345\201\363\201\364\201\240\201\303\201\345\201\362\201\364\201\351\201\346\201\351\201\343\201\341\201\364\201\345\201\240\201\301\201\365\201\364\201\350\201\357\201\362\201\351\201\364\201\371\002\007\201\322\000\002\000\201\327\003\201\313\201\260 \006\005\201\253\003\002\032\005\000\201\260\006 \201\252\206\201\310\206\367\001\001\001\005\000\004\201\200\201\246\201\255\202\350\202\242\202\261\207\227\033\027\201\375 \201\332\201\267\201\246\201\375\031\201\326\201\255\001\201\271\201\333\201\306\201\351\201\367\201\344\031\201\356\233\201\353\031\003\201\336 \003\201\353\201\260\201\323\201\267\026\022\201\307\233\201\316\201\362\201\304\201\256\201\247\201\243\201\256\201\261\211\202\243\202\324\202\314\027\222\027\222\034\230\201\240\201\323\037\201\345\034\220\201\372\201\261\201\377\201\333\201\310\201\343\201\300\201\335\201\310 \236\201\274\201\315\201\301\201\352\202\201\261\201\324\201\347\222\203\333\203\316\203\336\203\360<\211\236\203\276[\203\301\003\010\201\373rR\236\201\322\027\201\242\201\374b\027d:\225(\030\225\217\032\202\025\201\373\226\201\255\201\255\201\304\201\346\201\353\201\262\201\362\201\311\201\323\201\347\201\346\201\327\201\311\201\351\201\362\201\362\201\317\201\312\201\255\201\255" ); 00074 00075 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt)); 00076 // !ah! deleted resipCerr output that was messing up terminals 00077 } 00078 00079 { 00080 SipMessage empty; 00081 00082 try 00083 { 00084 resipCerr << empty.brief() << endl; 00085 empty.header(h_CSeq); 00086 resipCerr << empty.brief() << endl; 00087 empty.header(h_Vias).push_back(Via()); 00088 resipCerr << empty.brief() << endl; 00089 } 00090 catch (SipMessage::Exception& e) 00091 {} 00092 } 00093 00094 { 00095 Data txt("INVITE sip:192.168.2.92:5100;q=1 SIP/2.0\r\n" 00096 "To: <sip:yiwen_AT_meet2talk.com@whistler.gloo.net>\r\n" 00097 "From: Jason Fischl<sip:jason_AT_meet2talk.com@whistler.gloo.net>;tag=ba1aee2d\r\n" 00098 "Via: SIP/2.0/UDP 192.168.2.220:5060;branch=z9hG4bK-c87542-da4d3e6a.0-1--c87542-;rport=5060;received=192.168.2.220;stid=579667358\r\n" 00099 "Via: SIP/2.0/UDP 192.168.2.15:5100;branch=z9hG4bK-c87542-579667358-1--c87542-;rport=5100;received=192.168.2.15\r\n" 00100 "Call-ID: 6c64b42fce01b007\r\n" 00101 "CSeq: 2 INVITE\r\n" 00102 "Route: <sip:proxy@192.168.2.220:5060;lr>\r\n" 00103 "Contact: <sip:192.168.2.15:5100>\r\n" 00104 "Content-Length: 0\r\n" 00105 "\r\n"); 00106 00107 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt)); 00108 msg->header(h_Routes).pop_back(); 00109 resipCerr << *msg << endl; 00110 } 00111 00112 { 00113 Data txt("INVITE sip:192.168.2.92:5100;q=1 SIP/2.0\r\n" 00114 "To: <sip:yiwen_AT_meet2talk.com@whistler.gloo.net>\r\n" 00115 "From: Jason Fischl<sip:jason_AT_meet2talk.com@whistler.gloo.net>;tag=ba1aee2d\r\n" 00116 "Via: SIP/2.0/UDP 192.168.2.220:5060;branch=z9hG4bK-c87542-da4d3e6a.0-1--c87542-;rport=5060;received=192.168.2.220;stid=579667358\r\n" 00117 "Via: SIP/2.0/UDP 192.168.2.15:5100;branch=z9hG4bK-c87542-579667358-1--c87542-;rport=5100;received=192.168.2.15\r\n" 00118 "Call-ID: 6c64b42fce01b007\r\n" 00119 "CSeq: 2 INVITE\r\n" 00120 "Record-Route: <sip:proxy@192.168.2.220:5060;lr>\r\n" 00121 "Contact: <sip:192.168.2.15:5100>\r\n" 00122 "Max-Forwards: 69\r\n" 00123 "Content-Type: application/sdp\r\n" 00124 "Content-Length: 307\r\n" 00125 "\r\n" 00126 "v=0\r\n" 00127 "o=M2TUA 1589993278 1032390928 IN IP4 192.168.2.15\r\n" 00128 "s=-\r\n" 00129 "c=IN IP4 192.168.2.15\r\n" 00130 "t=0 0\r\n" 00131 "m=audio 9000 RTP/AVP 103 97 100 101 0 8 102\r\n" 00132 "a=rtpmap:103 ISAC/16000\r\n" 00133 "a=rtpmap:97 IPCMWB/16000\r\n" 00134 "a=rtpmap:100 EG711U/8000\r\n" 00135 "a=rtpmap:101 EG711A/8000\r\n" 00136 "a=rtpmap:0 PCMU/8000\r\n" 00137 "a=rtpmap:8 PCMA/8000\r\n" 00138 "a=rtpmap:102 iLBC/8000\r\n"); 00139 00140 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt)); 00141 SdpContents* sdp = dynamic_cast<SdpContents*>(msg->getContents()); 00142 00143 sdp->session().media().front(); 00144 00145 SdpContents osdp; 00146 osdp.session().version() = 0; 00147 osdp.session().name() = "-"; 00148 osdp.session().origin() = SdpContents::Session::Origin(Data("M2TUA"), 00149 77, 00150 99, 00151 SdpContents::IP4, 00152 "localhost"); 00153 osdp.session().addTime(SdpContents::Session::Time(0,0)); 00154 osdp.session().connection() = 00155 SdpContents::Session::Connection(SdpContents::IP4, "localhost", 0); 00156 SdpContents::Session::Medium medium(Symbols::audio, 0, 1, Symbols::RTP_AVP); 00157 00158 SdpContents::Session::Codec codec1("iLBC", 102, 8000); 00159 medium.addCodec(codec1); 00160 00161 SdpContents::Session::Codec codec2("PCMA", 8, 8000); 00162 medium.addCodec(codec2); 00163 00164 SdpContents::Session::Codec codec3("PCMU", 0, 8000); 00165 medium.addCodec(codec3); 00166 00167 SdpContents::Session::Codec codec4("EG711A", 101, 8000); 00168 medium.addCodec(codec4); 00169 00170 SdpContents::Session::Codec codec5("EG711U", 100, 8000); 00171 medium.addCodec(codec5); 00172 00173 SdpContents::Session::Codec codec6("IPCMWB", 97, 16000); 00174 medium.addCodec(codec6); 00175 00176 SdpContents::Session::Codec codec7("ISAC", 103, 16000); 00177 medium.addCodec(codec7); 00178 00179 osdp.session().addMedium(medium); 00180 SdpContents::Session::Medium& myMedium = osdp.session().media().front(); 00181 00182 SdpContents csdp; 00183 csdp = *sdp; 00184 SdpContents::Session::Medium& my1Medium = csdp.session().media().front(); 00185 resipCerr << myMedium.protocol() << " : " << my1Medium.protocol() << endl; 00186 00187 SdpContents c2sdp; 00188 c2sdp = *sdp; 00189 00190 00191 SdpContents::Session::Medium& myMedium2 = c2sdp.session().media().front(); 00192 resipCerr << myMedium2.protocol() << endl; 00193 } 00194 00195 { 00196 Data txt1 = "SIP/2.0 407 Proxy Authentication Required\r\n" 00197 "To: <sip:jason_AT_meet2talk.com@beta.meet2talk.com>\r\n" 00198 "From: <sip:jason_AT_meet2talk.com@beta.meet2talk.com>;tag=113cba09\r\n" 00199 "Via: SIP/2.0/64.124.66.32:9091;branch=z9hG4bK-c87542-5b42cb698e8c6827790212ac5bdade1a-1-PA32768-c87542-;rport;received=64.124.66.32\r\n" 00200 "Via: SIP/2.0/UDP 192.168.1.102:5100;branch=z9hG4bK-c87542-175255966-1--c87542-;rport\r\n" 00201 "Call-ID: d8023c1dc2559a21\r\n" 00202 "CSeq: 1 REGISTER\r\n" 00203 "Contact: <sip:64.124.66.32:5060>\r\n" 00204 "Content-Length: 0\r\n\r\n"; 00205 00206 auto_ptr<SipMessage> message1(TestSupport::makeMessage(txt1)); 00207 00208 try 00209 { 00210 resipCerr << "transport=" << message1->header(h_Vias).front().transport() << endl; 00211 assert(false); 00212 } 00213 catch (ParseException& e) 00214 { 00215 } 00216 } 00217 00218 { 00219 resipCerr << "test CRLFs before the start line" << endl; 00220 Data txt1 = "\r\n\r\n\r\nSIP/2.0 407 Proxy Authentication Required\r\n" 00221 "To: <sip:jason_AT_meet2talk.com@beta.meet2talk.com>\r\n" 00222 "From: <sip:jason_AT_meet2talk.com@beta.meet2talk.com>;tag=113cba09\r\n" 00223 "Via: SIP/2.0/UDP 64.124.66.32:9091;branch=z9hG4bK-c87542-5b42cb698e8c6827790212ac5bdade1a-1-PA32768-c87542-;rport;received=64.124.66.32\r\n" 00224 "Via: SIP/2.0/UDP 192.168.1.102:5100;branch=z9hG4bK-c87542-175255966-1--c87542-;rport\r\n" 00225 "Call-ID: d8023c1dc2559a21\r\n" 00226 "CSeq: 1 REGISTER\r\n" 00227 "Contact: <sip:64.124.66.32:5060>\r\n" 00228 "Content-Length: 0\r\n\r\n"; 00229 00230 try 00231 { 00232 auto_ptr<SipMessage> message1(TestSupport::makeMessage(txt1)); 00233 if (message1->header(h_StatusLine).statusCode() == 407){;} 00234 } 00235 catch (BaseException& e) 00236 { 00237 assert(false); 00238 } 00239 } 00240 00241 { 00242 resipCerr << "test complex content copy" << endl; 00243 00244 Data txt = ("MESSAGE sip:fluffy@212.157.205.40 SIP/2.0\r\n" 00245 "Via: SIP/2.0/TCP 212.157.205.198:5060;branch=z9hG4bK2367411811584019109\r\n" 00246 "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK-c87542-107338443-1--c87542-;stid=489573115\r\n" 00247 "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK-c87542-489573115-1--c87542-;received=192.168.2.220\r\n" 00248 "To: sip:fluffy@212.157.205.40\r\n" 00249 "From: sip:ntt2@h1.ntt2.sipit.net;tag=727823805122397238\r\n" 00250 "Max-Forwards: 70\r\n" 00251 "CSeq: 1 NOTIFY\r\n" 00252 "Call-ID: 28067261571992032320\r\n" 00253 "Contact: sip:ntt2@212.157.205.198:5060\r\n" 00254 "Expires: 47\r\n" 00255 "Content-Length: 1929\r\n" 00256 "Content-Type: multipart/signed;\r\n" 00257 " protocol=\"application/pkcs7-signature\";\r\n" 00258 " micalg=sha1; boundary=\"----YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\"\r\n" 00259 "\r\n" 00260 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\r\n" 00261 "Content-Type: multipart/mixed;boundary=\"----lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\"\r\n" 00262 "Content-Length: 870\r\n" 00263 "Content-Disposition: attachment;handling=required\r\n" 00264 "\r\n" 00265 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\r\n" 00266 "Content-Type: application/sipfrag\r\n" 00267 "Content-Length: 320\r\n" 00268 "\r\n" 00269 "To: sip:fluffy@212.157.205.40\r\n" 00270 "From: sip:ntt2@h1.ntt2.sipit.net;tag=727823805122397238\r\n" 00271 "CSeq: 1 NOTIFY\r\n" 00272 "Call-ID: 28067261571992032320\r\n" 00273 "Contact: sip:ntt2@212.157.205.198:5060\r\n" 00274 "Event: presence\r\n" 00275 "Content-Length: 210\r\n" 00276 "Content-Type: application/xpidf+xml\r\n" 00277 "Subscription-State: active\r\n" 00278 "User-Agent: XXX SecureSession User-Agent\r\n" 00279 "\r\n" 00280 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\r\n" 00281 "Content-Type: application/xpidf+xml\r\n" 00282 "Content-Length: 210\r\n" 00283 "\r\n" 00284 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" 00285 "<presence xmlns:impp=\"urn:ietf:params:xml:ns:pidf\" entity=\"pres:someone@example.com\">\r\n" 00286 "<tuple id=\"765\">\r\n" 00287 "<status>\r\n" 00288 "<basic>open</basic>\r\n" 00289 "</status>\r\n" 00290 "</tuple>\r\n" 00291 "</presence>\r\n" 00292 "\r\n" 00293 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY--\r\n" 00294 "\r\n" 00295 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\r\n" 00296 "Content-Type: application/pkcs7-signature; name=\"smime.p7s\"\r\n" 00297 "Content-Transfer-Encoding: base64\r\n" 00298 "Content-Disposition: attachment; filename=\"smime.p7s\"; handling=required\r\n" 00299 "\r\n" 00300 "MIIBVgYJKoZIhvcNAQcCoIIBRzCCAUMCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3\r\n" 00301 "DQEHATGCASIwggEeAgEBMHwwcDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlm\r\n" 00302 "b3JuaWExETAPBgNVBAcTCFNhbiBKb3NlMQ4wDAYDVQQKEwVzaXBpdDEpMCcGA1UE\r\n" 00303 "CxMgU2lwaXQgVGVzdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkCCAIWABUCBgIVMAkG\r\n" 00304 "BSsOAwIaBQAwDQYJKoZIhvcNAQEBBQAEgYAer8TPSMtA3ZqweGnXLUYKR51bp52N\r\n" 00305 "oGBEqHZz7xR0Nhs6DsAOXiSFv19vTR//33u6Se3zpNNHP/zj7NRr+olimI2PeBNB\r\n" 00306 "tczNdqexoN0pjRW7l7mHZ0e39pqZmI5bhFl+z9CJJu5xW0aSarw84CZxbh5RQaYr\r\n" 00307 "zhSvTYdki20aiQ==\r\n" 00308 "\r\n" 00309 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC--\r\n" 00310 ); 00311 00312 std::auto_ptr<SipMessage> msg(SipMessage::make(txt)); 00313 00314 SipMessage msg1; 00315 msg1.setContents(msg->getContents()); 00316 00317 CerrLog(<< Data::from(*msg1.getContents())); 00318 CerrLog(<< Data::from(*msg->getContents())); 00319 } 00320 00321 { 00322 InfoLog(<< "Testing assignment"); 00323 00324 Data txt1 = ("SIP/2.0 401 Unauthorized\r\n" 00325 "To: <sip:foobie@example.com>;tag=12345678\r\n" 00326 "From: <sip:bar@example.com>;tag=83ec8345\r\n" 00327 "Via: SIP/2.0/TLS 192.168.2.205:5061;branch=z9hG4bK-c87542-488593999-1--c87542-;rport\r\n" 00328 "Call-ID: 3f0b546f89f28456\r\n" 00329 "CSeq: 1 REGISTER\r\n" 00330 "Expires: 3600\r\n" 00331 "Max-Forwards: 70\r\n" 00332 "Www-Authenticate: Basic realm=test\r\n" 00333 "Allow-Events: presence\r\n" 00334 "Content-Length: 0\r\n" 00335 "\r\n"); 00336 00337 auto_ptr<SipMessage> message1(TestSupport::makeMessage(txt1)); 00338 00339 00340 Data txt2 = ("NOTIFY sip:fluffy@212.157.205.40 SIP/2.0\r\n" 00341 "Via: SIP/2.0/TCP 212.157.205.198:5060;branch=z9hG4bK2367411811584019109\r\n" 00342 "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK-c87542-107338443-1--c87542-;stid=489573115\r\n" 00343 "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK-c87542-489573115-1--c87542-;received=192.168.2.220\r\n" 00344 "To: sip:fluffy@212.157.205.40\r\n" 00345 "From: sip:ntt2@h1.ntt2.sipit.net;tag=727823805122397238\r\n" 00346 "Max-Forwards: 70\r\n" 00347 "CSeq: 1 NOTIFY\r\n" 00348 "Call-ID: 28067261571992032320\r\n" 00349 "Contact: sip:ntt2@212.157.205.198:5060\r\n" 00350 "Content-Length: 1929\r\n" 00351 "Content-Type: multipart/signed;\r\n" 00352 " protocol=\"application/pkcs7-signature\";\r\n" 00353 " micalg=sha1; boundary=\"----YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\"\r\n" 00354 "\r\n" 00355 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\r\n" 00356 "Content-Type: multipart/mixed;boundary=\"----lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\"\r\n" 00357 "Content-Length: 870\r\n" 00358 "Content-Disposition: attachment;handling=required\r\n" 00359 "\r\n" 00360 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\r\n" 00361 "Content-Type: application/sipfrag\r\n" 00362 "Content-Length: 320\r\n" 00363 "\r\n" 00364 "To: sip:fluffy@212.157.205.40\r\n" 00365 "From: sip:ntt2@h1.ntt2.sipit.net;tag=727823805122397238\r\n" 00366 "CSeq: 1 NOTIFY\r\n" 00367 "Call-ID: 28067261571992032320\r\n" 00368 "Contact: sip:ntt2@212.157.205.198:5060\r\n" 00369 "Event: presence\r\n" 00370 "Content-Length: 210\r\n" 00371 "Content-Type: application/xpidf+xml\r\n" 00372 "Subscription-State: active\r\n" 00373 "User-Agent: XXX SecureSession User-Agent\r\n" 00374 "\r\n" 00375 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\r\n" 00376 "Content-Type: application/xpidf+xml\r\n" 00377 "Content-Length: 210\r\n" 00378 "\r\n" 00379 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" 00380 "<presence xmlns:impp=\"urn:ietf:params:xml:ns:pidf\" entity=\"pres:someone@example.com\">\r\n" 00381 "<tuple id=\"765\">\r\n" 00382 "<status>\r\n" 00383 "<basic>open</basic>\r\n" 00384 "</status>\r\n" 00385 "</tuple>\r\n" 00386 "</presence>\r\n" 00387 "\r\n" 00388 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY--\r\n" 00389 "\r\n" 00390 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\r\n" 00391 "Content-Type: application/pkcs7-signature; name=\"smime.p7s\"\r\n" 00392 "Content-Transfer-Encoding: base64\r\n" 00393 "Content-Disposition: attachment; filename=\"smime.p7s\"; handling=required\r\n" 00394 "\r\n" 00395 "MIIBVgYJKoZIhvcNAQcCoIIBRzCCAUMCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3\r\n" 00396 "DQEHATGCASIwggEeAgEBMHwwcDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlm\r\n" 00397 "b3JuaWExETAPBgNVBAcTCFNhbiBKb3NlMQ4wDAYDVQQKEwVzaXBpdDEpMCcGA1UE\r\n" 00398 "CxMgU2lwaXQgVGVzdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkCCAIWABUCBgIVMAkG\r\n" 00399 "BSsOAwIaBQAwDQYJKoZIhvcNAQEBBQAEgYAer8TPSMtA3ZqweGnXLUYKR51bp52N\r\n" 00400 "oGBEqHZz7xR0Nhs6DsAOXiSFv19vTR//33u6Se3zpNNHP/zj7NRr+olimI2PeBNB\r\n" 00401 "tczNdqexoN0pjRW7l7mHZ0e39pqZmI5bhFl+z9CJJu5xW0aSarw84CZxbh5RQaYr\r\n" 00402 "zhSvTYdki20aiQ==\r\n" 00403 "\r\n" 00404 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC--\r\n" 00405 ); 00406 00407 auto_ptr<SipMessage> message2(TestSupport::makeMessage(txt2)); 00408 00409 SipMessage message3; 00410 UnknownHeaderType h_Foo("foo"); 00411 UnknownHeaderType h_Bar("bar"); 00412 00413 message3.header(h_Foo); 00414 message3.header(h_Bar).push_back(StringCategory("bar1")); 00415 message3.header(h_Bar).push_back(StringCategory("bar2")); 00416 00417 //message3.header(h_Vias); 00418 message3.header(h_To); 00419 00420 message3.header(h_RequestLine) = RequestLine(INVITE); 00421 message3.header(h_RequestLine).uri() = Uri("sip:bob@biloxi.com"); 00422 message3.header(h_To) = NameAddr("sip:bob@biloxi.com"); 00423 message3.header(h_From) = NameAddr("Alice <sip:alice@atlanta.com>;tag=1928301774"); 00424 message3.header(h_CallId).value() = "314159"; 00425 message3.header(h_CSeq).sequence() = 14; 00426 message3.header(h_CSeq).method() = INVITE; 00427 00428 PlainContents pc("here is some plain ol' contents"); 00429 message3.setContents(&pc); 00430 00431 message3 = *message2; 00432 00433 // cause some parsing 00434 assert(!message2->header(h_To).exists(p_tag)); 00435 message2->getContents(); 00436 00437 // cause some parsing 00438 assert(message1->header(h_Vias).front().param(p_branch).clientData().empty()); 00439 00440 assert(message1.get()); 00441 *message2 = *message1; 00442 00443 // cause some parsing 00444 message3.getContents(); 00445 message3 = *message2; 00446 00447 CerrLog(<< Data::from(message3)); 00448 CerrLog(<< Data::from(*message1)); 00449 00450 assert(message1.get()); 00451 assert(message3.isRequest() == message1->isRequest()); 00452 assert(message3.isResponse() == message1->isResponse()); 00453 00454 assert(Data::from(message3) == Data::from(*message1)); 00455 } 00456 00457 // !dlb! we seem to have relaxed the quoting requirement in general 00458 // we accept unquoted when the grammar says quoted, but always emit quoted 00459 #if 0 00460 { 00461 char* txt = ("SIP/2.0 401 Unauthorized\r\n" 00462 "To: <sip:foobie@example.com>;tag=12345678\r\n" 00463 "From: <sip:bar@example.com>;tag=83ec8345\r\n" 00464 "Via: SIP/2.0/TLS 192.168.2.205:5061;branch=z9hG4bK-c87542-488593999-1--c87542-;rport\r\n" 00465 "Call-ID: 3f0b546f89f28456\r\n" 00466 "CSeq: 1 REGISTER\r\n" 00467 "Expires: 3600\r\n" 00468 "Max-Forwards: 70\r\n" 00469 "Www-Authenticate: Basic realm=test\r\n" 00470 "Allow-Events: presence\r\n" 00471 "Content-Length: 0\r\n" 00472 "\r\n"); 00473 try 00474 { 00475 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00476 assert(message->exists(h_WWWAuthenticates)); 00477 assert(message->header(h_WWWAuthenticates).size() == 1); 00478 assert(message->header(h_WWWAuthenticates).front().scheme() == "Basic"); 00479 assert(0); 00480 } 00481 catch (ParseException& e) 00482 { 00483 InfoLog (<< "Rejected unquoted realm"); 00484 } 00485 } 00486 #endif 00487 00488 { 00489 Data txt( 00490 "NOTIFY sip:fluffy@212.157.205.40 SIP/2.0\r\n" 00491 "Via: SIP/2.0/TCP 212.157.205.198:5060;branch=z9hG4bK2367411811584019109\r\n" 00492 "To: sip:fluffy@212.157.205.40\r\n" 00493 "From: sip:ntt2@h1.ntt2.sipit.net;tag=727823805122397238\r\n" 00494 "Max-Forwards: 70\r\n" 00495 "CSeq: 1 NOTIFY\r\n" 00496 "Call-ID: 28067261571992032320\r\n" 00497 "Contact: sip:ntt2@212.157.205.198:5060\r\n" 00498 "Content-Length: 1929\r\n" 00499 "Content-Type: multipart/signed;\r\n" 00500 " protocol=\"application/pkcs7-signature\";\r\n" 00501 " micalg=sha1; boundary=\"----YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\"\r\n" 00502 "\r\n" 00503 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\r\n" 00504 "Content-Type: multipart/mixed;boundary=\"----lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\"\r\n" 00505 "Content-Length: 870\r\n" 00506 "Content-Disposition: attachment;handling=required\r\n" 00507 "\r\n" 00508 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\r\n" 00509 "Content-Type: application/sipfrag\r\n" 00510 "Content-Length: 320\r\n" 00511 "\r\n" 00512 "To: sip:fluffy@212.157.205.40\r\n" 00513 "From: sip:ntt2@h1.ntt2.sipit.net;tag=727823805122397238\r\n" 00514 "CSeq: 1 NOTIFY\r\n" 00515 "Call-ID: 28067261571992032320\r\n" 00516 "Contact: sip:ntt2@212.157.205.198:5060\r\n" 00517 "Event: presence\r\n" 00518 "Content-Length: 210\r\n" 00519 "Content-Type: application/xpidf+xml\r\n" 00520 "Subscription-State: active\r\n" 00521 "User-Agent: XXX SecureSession User-Agent\r\n" 00522 "\r\n" 00523 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY\r\n" 00524 "Content-Type: application/xpidf+xml\r\n" 00525 "Content-Length: 210\r\n" 00526 "\r\n" 00527 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" 00528 "<presence xmlns:impp=\"urn:ietf:params:xml:ns:pidf\" entity=\"pres:someone@example.com\">\r\n" 00529 "<tuple id=\"765\">\r\n" 00530 "<status>\r\n" 00531 "<basic>open</basic>\r\n" 00532 "</status>\r\n" 00533 "</tuple>\r\n" 00534 "</presence>\r\n" 00535 "\r\n" 00536 "------lRIGMC8E2Px6I2IODfk2rISgfWIirrOJwS3tY52HuxDP3pdTiFjsghJJWhvyRCEY--\r\n" 00537 "\r\n" 00538 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC\r\n" 00539 "Content-Type: application/pkcs7-signature; name=\"smime.p7s\"\r\n" 00540 "Content-Transfer-Encoding: base64\r\n" 00541 "Content-Disposition: attachment; filename=\"smime.p7s\"; handling=required\r\n" 00542 "\r\n" 00543 "MIIBVgYJKoZIhvcNAQcCoIIBRzCCAUMCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3\r\n" 00544 "DQEHATGCASIwggEeAgEBMHwwcDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlm\r\n" 00545 "b3JuaWExETAPBgNVBAcTCFNhbiBKb3NlMQ4wDAYDVQQKEwVzaXBpdDEpMCcGA1UE\r\n" 00546 "CxMgU2lwaXQgVGVzdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkCCAIWABUCBgIVMAkG\r\n" 00547 "BSsOAwIaBQAwDQYJKoZIhvcNAQEBBQAEgYAer8TPSMtA3ZqweGnXLUYKR51bp52N\r\n" 00548 "oGBEqHZz7xR0Nhs6DsAOXiSFv19vTR//33u6Se3zpNNHP/zj7NRr+olimI2PeBNB\r\n" 00549 "tczNdqexoN0pjRW7l7mHZ0e39pqZmI5bhFl+z9CJJu5xW0aSarw84CZxbh5RQaYr\r\n" 00550 "zhSvTYdki20aiQ==\r\n" 00551 "\r\n" 00552 "------YvhIjyjTU8lfNqGe8Fyvxcmb4mleF6quxsMFpT2hOhrDfS3LLs1MyYBdLNgBLsSC--\r\n" 00553 ); 00554 00555 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 00556 InfoLog (<< "msg->header(h_ContentLength).value() == " << msg->header(h_ContentLength).value()); 00557 assert( msg->header(h_ContentLength).value() == 1929 ); 00558 } 00559 { 00560 Data txt( 00561 "MESSAGE sip:fluffy@h1.cisco1.sipit.net:5060;transport=UDP SIP/2.0\r\n" 00562 "To: <sip:fluffy@h1.cisco1.sipit.net:5060>\r\n" 00563 "From: <sip:user@localhost:5080>;tag=20f94fd6\r\n" 00564 "Via: SIP/2.0/UDP 212.157.205.40:5080;branch=z9hG4bK-c87542-1005764096-2--c87542-;rport=5080;received=212.157.205.40\r\n" 00565 "Call-ID: 16f7f8fd368d8bcd\r\n" 00566 "CSeq: 1 MESSAGE\r\n" 00567 "Contact: <sip:user@212.157.205.40:5080>\r\n" 00568 "Max-Forwards: 70\r\n" 00569 "Content-Disposition: attachment;handling=required;filename=smime.p7\r\n" 00570 "Content-Type: application/pkcs7-mime;smime-type=enveloped-data;name=smime.p7m\r\n" 00571 "User-Agent: SIPimp.org/0.2.3 (curses)\r\n" 00572 "Content-Length: 4\r\n" 00573 "\r\n" 00574 "1234" ); 00575 00576 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 00577 00578 assert( msg->exists(h_ContentDisposition) ); 00579 msg->header(h_ContentDisposition); 00580 assert( msg->header(h_ContentLength).value() == 4 ); 00581 } 00582 { 00583 // exercise header remove 00584 const char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n" 00585 "Allow-Events: foo\r\n" 00586 "Allow-Events: bar\r\n" 00587 "Allow-Events: baz\r\n" 00588 "Allow-Events: quux\r\n" 00589 "Unsupported: \r\n" 00590 "To: <sip:ext101@whistler.gloo.net:5061>\r\n" 00591 "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n" 00592 "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK-c87542-107338443-1--c87542-;stid=489573115\r\n" 00593 "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK-c87542-489573115-1--c87542-;received=192.168.2.220\r\n" 00594 "Call-ID: 643f2f06\r\n" 00595 "CSeq: 1 INVITE\r\n" 00596 "Proxy-Authorization: Digest username=\"Alice\", realm = \"atlanta.com\", nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n" 00597 "Proxy-Authorization: Digest username=\"Betty\", realm = \"fresno.com\", nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n" 00598 "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n" 00599 "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n" 00600 "Max-Forwards: 69\r\n" 00601 "Content-Length: 0\r\n" 00602 "Unknown: foobie\r\n" 00603 "Unknown: biefoo\r\n" 00604 "\r\n"); 00605 00606 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00607 // note message has not been parsed 00608 00609 message->remove(h_AllowEvents); 00610 message->remove(h_Unsupporteds); 00611 message->remove(h_To); 00612 message->remove(h_From); 00613 message->remove(h_Vias); 00614 message->remove(h_CallId); 00615 message->remove(h_CSeq); 00616 message->remove(h_ProxyAuthorizations); 00617 message->remove(h_RecordRoutes); 00618 message->remove(h_Contacts); 00619 message->remove(h_MaxForwards); 00620 message->remove(h_ContentLength); 00621 message->remove(UnknownHeaderType("Unknown")); 00622 00623 Data enc; 00624 { 00625 DataStream str(enc); 00626 str << *message; 00627 } 00628 00629 InfoLog (<< enc); 00630 assert(enc == ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n" 00631 "Content-Length: 0\r\n" 00632 "\r\n")); 00633 } 00634 00635 { 00636 // exercise header remove 00637 const char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n" 00638 "Allow-Events: foo\r\n" 00639 "Allow-Events: bar\r\n" 00640 "Allow-Events: baz\r\n" 00641 "Allow-Events: quux\r\n" 00642 "Unsupported: \r\n" 00643 "To: <sip:ext101@whistler.gloo.net:5061>\r\n" 00644 "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n" 00645 "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK-c87542-107338443-1--c87542-;stid=489573115\r\n" 00646 "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK-c87542-489573115-1--c87542-;received=192.168.2.220\r\n" 00647 "Call-ID: 643f2f06\r\n" 00648 "CSeq: 1 INVITE\r\n" 00649 "Proxy-Authorization: Digest username=\"Alice\", realm = \"atlanta.com\", nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n" 00650 "Proxy-Authorization: Digest username=\"Betty\", realm = \"fresno.com\", nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n" 00651 "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n" 00652 "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n" 00653 "Max-Forwards: 69\r\n" 00654 "Content-Length: 0\r\n" 00655 "Unknown: foobie\r\n" 00656 "Unknown: biefoo\r\n" 00657 "\r\n"); 00658 00659 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00660 00661 message->header(h_AllowEvents).front().value(); 00662 message->header(h_Unsupporteds).empty(); 00663 message->header(h_To).uri().user(); 00664 message->header(h_From); 00665 message->header(h_Vias).front(); 00666 message->header(h_CallId).value(); 00667 message->header(h_CSeq).sequence(); 00668 message->header(h_ProxyAuthorizations).size(); 00669 message->header(h_RecordRoutes).front().uri().host(); 00670 message->header(h_Contacts).size(); 00671 message->header(h_MaxForwards).value(); 00672 message->header(h_ContentLength).value(); 00673 message->header(UnknownHeaderType("Unknown")).size(); 00674 00675 // note message has been parsed 00676 message->remove(h_AllowEvents); 00677 message->remove(h_Unsupporteds); 00678 message->remove(h_To); 00679 message->remove(h_From); 00680 message->remove(h_Vias); 00681 message->remove(h_CallId); 00682 message->remove(h_CSeq); 00683 message->remove(h_ProxyAuthorizations); 00684 message->remove(h_RecordRoutes); 00685 message->remove(h_Contacts); 00686 message->remove(h_MaxForwards); 00687 message->remove(h_ContentLength); 00688 message->remove(UnknownHeaderType("Unknown")); 00689 00690 // not present 00691 message->remove(h_Routes); 00692 00693 Data enc; 00694 { 00695 DataStream str(enc); 00696 str << *message; 00697 } 00698 00699 assert(enc == ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n" 00700 "Content-Length: 0\r\n" 00701 "\r\n")); 00702 } 00703 00704 { 00705 // demonstrate comma encoding 00706 const char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n" 00707 "Allow-Events: foo\r\n" 00708 "Allow-Events: bar\r\n" 00709 "Allow-Events: baz\r\n" 00710 "Allow-Events: quux\r\n" 00711 "Unsupported: \r\n" 00712 "To: <sip:ext101@whistler.gloo.net:5061>\r\n" 00713 "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n" 00714 "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK-c87542-107338443-1--c87542-;stid=489573115\r\n" 00715 "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK-c87542-489573115-1--c87542-;received=192.168.2.220\r\n" 00716 "Call-ID: 643f2f06\r\n" 00717 "CSeq: 1 INVITE\r\n" 00718 "Proxy-Authorization: Digest username=\"Alice\", realm = \"atlanta.com\", nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n" 00719 "Proxy-Authorization: Digest username=\"Betty\", realm = \"fresno.com\", nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n" 00720 "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n" 00721 "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n" 00722 "Max-Forwards: 69\r\n" 00723 "Content-Length: 0\r\n" 00724 "\r\n"); 00725 00726 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00727 assert(message->exists(h_Unsupporteds)); 00728 resipCerr << message->header(h_AllowEvents).size() << endl; 00729 resipCerr << message->header(h_Vias).size() << endl; 00730 resipCerr << message->header(h_ProxyAuthorizations).size() << endl; 00731 resipCerr << *message << endl; 00732 } 00733 00734 { 00735 SipMessage msg; 00736 msg.header(h_CallId).value() = "8d057730fba2cd5e"; 00737 00738 resipCerr << msg.header(h_CallId) << endl; 00739 00740 const SipMessage msg1(msg); 00741 resipCerr << msg1.header(h_CallId) << endl; 00742 } 00743 00744 { 00745 const char * txt = ("SIP/2.0 489 Bad Event" CRLF 00746 "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK-c87542-899769382-1--c87542-" CRLF 00747 "CSeq: " CRLF 00748 "Call-ID: f354ce714fb8a95c" CRLF 00749 "From: <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF 00750 "To: <sip:RjS@127.0.0.1:5060>" CRLF 00751 CRLF); 00752 TestSupport::prettyPrint(txt,strlen(txt)); 00753 00754 auto_ptr<SipMessage> response(TestSupport::makeMessage(txt,true)); 00755 try 00756 { 00757 response->header(h_CSeq).method(); 00758 assert(false); 00759 } 00760 catch (ParseException& e) 00761 { 00762 resipCerr << e << endl; 00763 } 00764 } 00765 00766 { 00767 const char * txt = ("SIP/2.0 489 Bad Event" CRLF 00768 "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK-c87542-899769382-1--c87542-" CRLF 00769 "CSeq: " CRLF 00770 "Call-ID: f354ce714fb8a95c" CRLF 00771 "From: <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF 00772 "To: <sip:RjS@127.0.0.1:5060>" CRLF 00773 CRLF); 00774 TestSupport::prettyPrint(txt,strlen(txt)); 00775 00776 auto_ptr<SipMessage> response(TestSupport::makeMessage(txt,true)); 00777 try 00778 { 00779 const SipMessage& constSip(*response); 00780 assert(!constSip.header(h_CSeq).isWellFormed()); 00781 } 00782 catch (...) 00783 { 00784 assert(false); 00785 } 00786 } 00787 00788 { 00789 const char * txt = ("SIP/2.0 489 Bad Event" CRLF 00790 "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "1---899769382" CRLF 00791 "CSeq: 1 SUBSCRIBE" CRLF 00792 "Allow-Events: " CRLF 00793 "Call-ID: f354ce714fb8a95c" CRLF 00794 "From: <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF 00795 "To: <sip:RjS@127.0.0.1:5060>" CRLF 00796 CRLF); 00797 TestSupport::prettyPrint(txt,strlen(txt)); 00798 00799 auto_ptr<SipMessage> response(TestSupport::makeMessage(txt,true)); 00800 assert(response->exists(h_AllowEvents)); 00801 assert(response->header(h_AllowEvents).size() == 0); 00802 00803 resipCerr << response->brief() << endl; 00804 assert(Data::from(response->brief()) == "SipResp: 489 tid=899769382 cseq=1 SUBSCRIBE / 1 from(wire)"); 00805 00806 const char * txt2 = ("SIP/2.0 489 Bad Event" CRLF 00807 "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "1---899769382" CRLF 00808 "CSeq: 1 SUBSCRIBE" CRLF 00809 "Call-ID: f354ce714fb8a95c" CRLF 00810 "From: <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF 00811 "To: <sip:RjS@127.0.0.1:5060>" CRLF 00812 "Allow-Events:" CRLF 00813 CRLF); 00814 TestSupport::prettyPrint(txt2,strlen(txt2)); 00815 00816 auto_ptr<SipMessage> r2(TestSupport::makeMessage(txt2,true)); 00817 assert(r2->exists(h_AllowEvents)); 00818 assert(r2->header(h_AllowEvents).size() == 0); 00819 00820 const char * txt3 =("SIP/2.0 489 Bad Event" CRLF 00821 "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "1---899769382" CRLF 00822 "CSeq: 1 SUBSCRIBE" CRLF 00823 "Call-ID: f354ce714fb8a95c" CRLF 00824 "From: <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF 00825 "To: <sip:RjS@127.0.0.1:5060>" CRLF 00826 "Allow-Events: foo" CRLF 00827 "Allow-Events: bar" CRLF 00828 "Allow-Events: " CRLF 00829 CRLF); 00830 00831 auto_ptr<SipMessage> r3(TestSupport::makeMessage(txt3,false)); 00832 assert(r3->exists(h_AllowEvents)); 00833 assert(r3->header(h_AllowEvents).size() == 2); 00834 assert(r3->header(h_AllowEvents).front().value() == "foo"); 00835 resipCerr << r3->brief() << endl; 00836 assert(Data::from(r3->brief()) == "SipResp: 489 tid=899769382 cseq=1 SUBSCRIBE / 1 from(tu)"); 00837 00838 const char * txt4 = ("SIP/2.0 489 Bad Event" CRLF 00839 "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "1---899769382" CRLF 00840 "CSeq: 1 SUBSCRIBE" CRLF 00841 "Call-ID: f354ce714fb8a95c" CRLF 00842 "From: <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF 00843 "To: <sip:RjS@127.0.0.1:5060>" CRLF 00844 "Allow-Events: foo,foobar" CRLF 00845 "Allow-Events: bar,gak" CRLF 00846 "Allow-Events: " CRLF 00847 CRLF); 00848 00849 auto_ptr<SipMessage> r4(TestSupport::makeMessage(txt4,true)); 00850 assert(r4->exists(h_AllowEvents) ); 00851 00852 resipCerr << r4->header(h_AllowEvents).size() << endl; 00853 resipCerr << r4->header(h_AllowEvents).front().value() << endl; 00854 00855 assert(r4->header(h_AllowEvents).size() == 4); 00856 assert(r4->header(h_AllowEvents).front().value() == "foo"); 00857 00858 00859 const char * txt5 = ("SIP/2.0 489 Bad Event" CRLF 00860 "Via: SIP/2.0/UDP RjS.localdomain:5070;branch=z9hG4bK" RESIP_COOKIE "1---899769382" CRLF 00861 "CSeq: 1 SUBSCRIBE" CRLF 00862 "Call-ID: f354ce714fb8a95c" CRLF 00863 "From: <sip:RjS@127.0.0.1:5070>;tag=59e7dd57" CRLF 00864 "To: <sip:RjS@127.0.0.1:5060>" CRLF 00865 "Allow-Events: " CRLF 00866 "Allow-Events: " CRLF 00867 "Allow-Events: " CRLF 00868 CRLF); 00869 00870 auto_ptr<SipMessage> r5(TestSupport::makeMessage(txt5,true)); 00871 assert(r5->exists(h_AllowEvents) ); 00872 assert(r5->header(h_AllowEvents).size() == 0); 00873 } 00874 00875 { 00876 // Test just in time parsing with comparison: NameAddr; 00877 const char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n" 00878 "To: <sip:ext101@whistler.gloo.net:5061>\r\n" 00879 "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n" 00880 "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK" RESIP_COOKIE "1-client_data--11111;stid=489573115\r\n" 00881 "Call-ID: 643f2f06\r\n" 00882 "CSeq: 1 INVITE\r\n" 00883 "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n" 00884 "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n" 00885 "Max-Forwards: 69\r\n" 00886 "Accept: foo/bar\r\n" 00887 "Content-Type: bar/foo\r\n" 00888 "Content-Encoding: foo\r\n" 00889 "Content-Disposition: bar\r\n" 00890 "Content-Length: 0\r\n" 00891 "\r\n"); 00892 00893 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00894 00895 assert(message->header(h_ContentDisposition) < message->header(h_ContentEncoding)); 00896 assert(message->header(h_ContentType) < message->header(h_Accepts).front()); 00897 assert(message->header(h_To) < message->header(h_From)); 00898 00899 resipCerr << message->brief() << endl; 00900 assert(Data::from(message->brief()) == "SipReq: INVITE ext101@192.168.2.220:5064 tid=11111 cseq=1 INVITE contact=ext103@192.168.2.220:5068 / 1 from(tu)"); 00901 } 00902 00903 { 00904 resipCerr << "!Proxy-Authorization params" << endl; 00905 const char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n" 00906 "To: <sip:ext101@whistler.gloo.net:5061>\r\n" 00907 "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n" 00908 "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK" RESIP_COOKIE "1---563465;stid=489573115\r\n" 00909 "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK" RESIP_COOKIE "1---489573115;received=192.168.2.220\r\n" 00910 "Call-ID: 643f2f06\r\n" 00911 "CSeq: 1 INVITE\r\n" 00912 "Proxy-Authorization: Digest username=\"Alice\",realm=\"atlanta.com\",nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n" 00913 "Proxy-Authorization: Digest username=\"Alice\", realm = \"atlanta.com\", nonce=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", response=\"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY\"\r\n" 00914 "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n" 00915 "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n" 00916 "Max-Forwards: 69\r\n" 00917 "Content-Length: 0\r\n" 00918 "\r\n"); 00919 00920 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00921 00922 assert(message->header(h_ProxyAuthorizations).size() == 2); 00923 assert(message->header(h_ProxyAuthorizations).front().param(p_realm) == "atlanta.com"); 00924 assert(message->header(h_ProxyAuthorizations).front().param(p_response) == "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"); 00925 00926 resipCerr << *message << endl; 00927 } 00928 00929 { 00930 const char* txt = ("INVITE sip:ext101@192.168.2.220:5064;transport=UDP SIP/2.0\r\n" 00931 "To: <sip:ext101@whistler.gloo.net:5061>\r\n" 00932 "From: <sip:ext103@whistler.gloo.net:5061>;tag=a731\r\n" 00933 "Via: SIP/2.0/UDP whistler.gloo.net:5061;branch=z9hG4bK" RESIP_COOKIE "1---21312;stid=489573115\r\n" 00934 "Via: SIP/2.0/UDP whistler.gloo.net:5068;branch=z9hG4bK" RESIP_COOKIE "1---489573115;received=192.168.2.220\r\n" 00935 "Call-ID: 643f2f06\r\n" 00936 "CSeq: 1 INVITE\r\n" 00937 "Record-Route: <sip:proxy@whistler.gloo.net:5061;lr>\r\n" 00938 "Contact: <sip:ext103@192.168.2.220:5068;transport=UDP>\r\n" 00939 "Max-Forwards: 69\r\n" 00940 "Content-Length: 0\r\n" 00941 "\r\n"); 00942 00943 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00944 resipCerr << *message << endl; 00945 00946 assert(message->header(h_Vias).front().param(UnknownParameterType("stid")) == "489573115"); 00947 message->header(h_Vias).front().param(p_received) = "received"; 00948 assert(message->header(h_Vias).front().param(UnknownParameterType("stid")) == "489573115"); 00949 } 00950 00951 { 00952 const char* txt = ("SIP/2.0 200 OK""\r\n" 00953 "From: 1245<sip:4000@193.12.63.124:5060>;tag=7c3f0cc1-13c4-3e5a380c-1ac5646-257e""\r\n" 00954 "To: prolab<sip:5000@host2.sipdragon.sipit.net>;tag=7c3f0cc1-13c5-3e5a380d-1ac5827-618f""\r\n" 00955 "Call-ID: 9e9017c-7c3f0cc1-13c4-3e5a380c-1ac5646-3700@193.12.63.124""\r\n" 00956 "CSeq: 1 INVITE""\r\n" 00957 "Via: SIP/2.0/UDP host2.sipdragon.sipit.net;received=193.12.62.209;branch=z9hG4bK-3e5a380c-1ac5646-adf1-1""\r\n" 00958 "Via: SIP/2.0/UDP 193.12.63.124:5060;received=193.12.63.124;branch=z9hG4bK-3e5a380c-1ac5646-adf""\r\n" 00959 "Contact: <sip:5000@193.12.63.124:5061>""\r\n" 00960 "Record-Route: <sip:proxy@host2.sipdragon.sipit.net:5060;lr>""\r\n" 00961 "Content-Length:0\r\n\r\n"); 00962 00963 00964 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00965 resipCerr << *message << endl; 00966 message->header(h_Vias).front(); 00967 message->header(h_From); 00968 message->header(h_To); 00969 resipCerr << message->header(h_Vias).front().param(p_branch).getTransactionId() << endl; 00970 resipCerr << message->header(h_Vias).back().param(p_branch).getTransactionId() << endl; 00971 } 00972 00973 { 00974 const char *txt = ("SIP/2.0 200 OK\r\n" 00975 "From: 1245<sip:4000@193.12.63.124:5060>;tag=7c3f0cc1-13c4-3e5a380c-1ac5646-257e\r\n" 00976 "To: prolab<sip:5000@host2.sipdragon.sipit.net>;tag=7c3f0cc1-13c5-3e5a380d-1ac5827-618f\r\n" 00977 "Call-ID: 9e9017c-7c3f0cc1-13c4-3e5a380c-1ac5646-3700@193.12.63.124\r\n" 00978 "CSeq: 1 INVITE\r\n" 00979 "Via: SIP/2.0/UDP host2.sipdragon.sipit.net;received=193.12.62.209;branch=z9hG4bK-3e5a380c-1ac5646-adf1-1\r\n" 00980 "Via: SIP/2.0/UDP 193.12.63.124:5060;received=193.12.63.124;branch=z9hG4bK-3e5a380c-1ac5646-adf\r\n" 00981 "Contact: <sip:5000@193.12.63.124:5061>\r\n" 00982 "Record-Route: <sip:proxy@host2.sipdragon.sipit.net:5060;lr>\r\n" 00983 "Content-Length:0\r\n\r\n"); 00984 00985 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 00986 assert(message.get()); 00987 for (Vias::iterator i = message->header(h_Vias).begin(); 00988 i != message->header(h_Vias).end(); i++) 00989 { 00990 i->param(p_branch).encode(resipCerr); 00991 resipCerr << endl; 00992 } 00993 } 00994 00995 { 00996 const char* txt = ("SIP/2.0 200 OK""\r\n" 00997 "From: 1245<sip:4000@193.12.63.124:5060>;tag=7c3f0cc1-13c4-3e5a380c-1ac5646-257e""\r\n" 00998 "To: prolab<sip:5000@host2.sipdragon.sipit.net>;tag=7c3f0cc1-13c5-3e5a380d-1ac5827-618f""\r\n" 00999 "Call-ID: 9e9017c-7c3f0cc1-13c4-3e5a380c-1ac5646-3700@193.12.63.124""\r\n" 01000 "CSeq: 1 INVITE""\r\n" 01001 "Via: SIP/2.0/UDP host2.sipdragon.sipit.net;received=193.12.62.209;branch=z9hG4bK-3e5a380c-1ac5646-adf1-1""\r\n" 01002 "Via: SIP/2.0/UDP 193.12.63.124:5060;received=193.12.63.124;branch=z9hG4bK-3e5a380c-1ac5646-adf""\r\n" 01003 "Contact: <sip:5000@193.12.63.124:5061>""\r\n" 01004 "Record-Route: <sip:proxy@host2.sipdragon.sipit.net:5060;lr>""\r\n" 01005 "Content-Length:0\r\n\r\n"); 01006 01007 01008 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01009 resipCerr << *message << endl; 01010 message->header(h_Vias).front(); 01011 message->header(h_From); 01012 message->header(h_To); 01013 resipCerr << message->header(h_Vias).front() << endl; 01014 resipCerr << message->header(h_Vias).back() << endl; 01015 resipCerr << message->header(h_Vias).front().param(p_branch).getTransactionId() << endl; 01016 resipCerr << message->header(h_Vias).back().param(p_branch).getTransactionId() << endl; 01017 } 01018 01019 { 01020 const char *txt = ("To: <sip:106@kelowna.gloo.net>" 01021 "From: <sip:106@kelowna.gloo.net>;tag=18c7b33a-430c-429c-9f46-e5b509264519\r\n" 01022 "Via: SIP/2.0/UDP 192.168.2.15:10276;received=192.168.2.15\r\n" 01023 "Call-ID: cb15283c-6efb-452e-aef2-5e44e02e2440@192.168.2.15\r\n" 01024 "CSeq: 2 REGISTER\r\n" 01025 "Contact: <sip:192.168.2.15:10276>;xmethods=\"INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK\"\r\n" 01026 "Expires: 0\r\n" 01027 "User-Agent: Windows RTC/1.0\r\n" 01028 "Content-Length: 0\r\n" 01029 "\r\n"); 01030 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01031 resipCerr << message->header(h_Contacts).front().param(UnknownParameterType("xmethods")) << endl; 01032 resipCerr << *message << endl; 01033 } 01034 01035 { 01036 Data txt1("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 01037 "Via: SIP/2.0/UDP pc33.atlanta.com\r\n" 01038 "To: Bob <sip:bob@biloxi.com>\r\n" 01039 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01040 "Call-ID: a84b4c76e66710\r\n" 01041 "CSeq: 314159 INVITE\r\n" 01042 "Max-Forwards: 70\r\n" 01043 "Foobie-Blech: it is not a glass paperweight\r\n" 01044 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01045 "Content-Length: 0\r\n" 01046 "\r\n"); 01047 01048 Data txt2("INVITE sip:joe@biloxi.com SIP/2.0\r\n" 01049 "Via: SIP/2.0/UDP pc33.atlanta.com\r\n" 01050 "To: Bob <sip:bob@biloxi.com>\r\n" 01051 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01052 "Call-ID: a84b4c76e66710\r\n" 01053 "CSeq: 314159 INVITE\r\n" 01054 "Max-Forwards: 70\r\n" 01055 "Foobie-Blech: it is not a glass paperweight\r\n" 01056 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01057 "Content-Length: 0\r\n" 01058 "\r\n"); 01059 01060 Data txt3("INVITE sip:bob@biloxi.com;user=phone SIP/2.0\r\n" 01061 "Via: SIP/2.0/UDP pc33.atlanta.com\r\n" 01062 "To: Bob <sip:bob@biloxi.com>\r\n" 01063 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01064 "Call-ID: a84b4c76e66710\r\n" 01065 "CSeq: 314159 INVITE\r\n" 01066 "Max-Forwards: 70\r\n" 01067 "Foobie-Blech: it is not a glass paperweight\r\n" 01068 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01069 "Content-Length: 0\r\n" 01070 "\r\n"); 01071 01072 Data txt4("INVITE sip:bob@biloxi.com;user=phone;lr SIP/2.0\r\n" 01073 "Via: SIP/2.0/UDP pc33.atlanta.com\r\n" 01074 "To: Bob <sip:bob@biloxi.com>\r\n" 01075 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01076 "Call-ID: a84b4c76e66710\r\n" 01077 "CSeq: 314159 INVITE\r\n" 01078 "Max-Forwards: 70\r\n" 01079 "Foobie-Blech: it is not a glass paperweight\r\n" 01080 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01081 "Content-Length: 0\r\n" 01082 "\r\n"); 01083 01084 Data txt5("INVITE sip:bob@biloxi.com;user=phone;lr;maddr=192.168.1.1 SIP/2.0\r\n" 01085 "Via: SIP/2.0/UDP pc33.atlanta.com\r\n" 01086 "To: Bob <sip:bob@biloxi.com>\r\n" 01087 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01088 "Call-ID: a84b4c76e66710\r\n" 01089 "CSeq: 314159 INVITE\r\n" 01090 "Max-Forwards: 70\r\n" 01091 "Foobie-Blech: it is not a glass paperweight\r\n" 01092 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01093 "Content-Length: 0\r\n" 01094 "\r\n"); 01095 01096 Data txt6("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;user=phone SIP/2.0\r\n" 01097 "Via: SIP/2.0/UDP pc33.atlanta.com\r\n" 01098 "To: Bob <sip:bob@biloxi.com>\r\n" 01099 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01100 "Call-ID: a84b4c76e66710\r\n" 01101 "CSeq: 314159 INVITE\r\n" 01102 "Max-Forwards: 70\r\n" 01103 "Foobie-Blech: it is not a glass paperweight\r\n" 01104 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01105 "Content-Length: 0\r\n" 01106 "\r\n"); 01107 01108 Data txt7("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;user=phone;jason=foo SIP/2.0\r\n" 01109 "Via: SIP/2.0/UDP pc33.atlanta.com\r\n" 01110 "To: Bob <sip:bob@biloxi.com>\r\n" 01111 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01112 "Call-ID: a84b4c76e66710\r\n" 01113 "CSeq: 314159 INVITE\r\n" 01114 "Max-Forwards: 70\r\n" 01115 "Foobie-Blech: it is not a glass paperweight\r\n" 01116 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01117 "Content-Length: 0\r\n" 01118 "\r\n"); 01119 01120 Data txt8("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;lr;jason=foo;user=phone SIP/2.0\r\n" 01121 "Via: SIP/2.0/UDP pc33.atlanta.com\r\n" 01122 "To: Bob <sip:bob@biloxi.com>\r\n" 01123 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01124 "Call-ID: a84b4c76e66710\r\n" 01125 "CSeq: 314159 INVITE\r\n" 01126 "Max-Forwards: 70\r\n" 01127 "Foobie-Blech: it is not a glass paperweight\r\n" 01128 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01129 "Content-Length: 0\r\n" 01130 "\r\n"); 01131 01132 Data txt9("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;lr;jason=foo;user=phone SIP/2.0\r\n" 01133 "Via: SIP/2.0/UDP pc33.atlanta.com; branch=foobar\r\n" 01134 "To: Bob <sip:bob@biloxi.com>\r\n" 01135 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01136 "Call-ID: a84b4c76e66710\r\n" 01137 "CSeq: 314159 INVITE\r\n" 01138 "Max-Forwards: 70\r\n" 01139 "Foobie-Blech: it is not a glass paperweight\r\n" 01140 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01141 "Content-Length: 0\r\n" 01142 "\r\n"); 01143 01144 Data txt10("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;lr;jason=foo;user=phone SIP/2.0\r\n" 01145 "Via: SIP/2.0/UDP pc33.atlanta.com; branch=foobar\r\n" 01146 "To: Bob <sip:bob@biloxi.com>\r\n" 01147 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01148 "Call-ID: a84b4c76e66710\r\n" 01149 "CSeq: 314158 INVITE\r\n" 01150 "Max-Forwards: 70\r\n" 01151 "Foobie-Blech: it is not a glass paperweight\r\n" 01152 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01153 "Content-Length: 0\r\n" 01154 "\r\n"); 01155 01156 Data txt11("INVITE sip:bob@biloxi.com;maddr=192.168.1.1;lr;jason=foo;user=phone SIP/2.0\r\n" 01157 "Via: SIP/2.0/UDP pc33.atlanta.com; branch=foobar\r\n" 01158 "To: Bob <sip:bob@biloxi.com>\r\n" 01159 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01160 "Call-ID: a84b4c76e66710\r\n" 01161 "CSeq: 314158 INVITE\r\n" 01162 "Max-Forwards: 73\r\n" 01163 "Foobie-Blech: it is not a glass paperweight\r\n" 01164 "Contact: <sip:alice@pc.atlanta.com>\r\n" 01165 "Content-Length: 0\r\n" 01166 "\r\n"); 01167 01168 01169 auto_ptr<SipMessage> msg1(TestSupport::makeMessage(txt1)); 01170 auto_ptr<SipMessage> msg2(TestSupport::makeMessage(txt2)); 01171 auto_ptr<SipMessage> msg3(TestSupport::makeMessage(txt3)); 01172 auto_ptr<SipMessage> msg4(TestSupport::makeMessage(txt4)); 01173 auto_ptr<SipMessage> msg5(TestSupport::makeMessage(txt5)); 01174 auto_ptr<SipMessage> msg6(TestSupport::makeMessage(txt6)); 01175 auto_ptr<SipMessage> msg7(TestSupport::makeMessage(txt7)); 01176 auto_ptr<SipMessage> msg8(TestSupport::makeMessage(txt8)); 01177 auto_ptr<SipMessage> msg9(TestSupport::makeMessage(txt9)); 01178 auto_ptr<SipMessage> msg10(TestSupport::makeMessage(txt10)); 01179 auto_ptr<SipMessage> msg11(TestSupport::makeMessage(txt11)); 01180 01181 assert(msg1->getTransactionId() == msg1->getTransactionId()); 01182 resipCerr << "msg2=" << msg2->getTransactionId() << endl; 01183 resipCerr << "msg3=" << msg3->getTransactionId() << endl; 01184 assert(msg2->getTransactionId() != msg3->getTransactionId()); 01185 assert(msg3->getTransactionId() == msg4->getTransactionId()); 01186 assert(msg4->getTransactionId() != msg5->getTransactionId()); 01187 assert(msg4->getTransactionId() != msg6->getTransactionId()); 01188 01189 resipCerr << "msg5=" << msg5->getTransactionId() << endl; 01190 resipCerr << "msg6=" << msg6->getTransactionId() << endl; 01191 assert(msg5->header(h_RequestLine).uri() == msg6->header(h_RequestLine).uri()); 01192 assert(msg5->header(h_RequestLine).uri().commutativeParameterHash() == msg6->header(h_RequestLine).uri().commutativeParameterHash()); 01193 01194 assert(msg5->getTransactionId() == msg6->getTransactionId()); 01195 assert(msg7->getTransactionId() == msg8->getTransactionId()); 01196 assert(msg6->getTransactionId() != msg8->getTransactionId()); 01197 assert(msg8->getTransactionId() != msg9->getTransactionId()); 01198 assert(msg9->getTransactionId() != msg10->getTransactionId()); 01199 assert(msg10->getTransactionId() == msg11->getTransactionId()); 01200 } 01201 01202 { 01203 SipMessage inv; 01204 01205 UnknownHeaderType h_Foo("foo"); 01206 UnknownHeaderType h_Bar("bar"); 01207 01208 inv.header(h_Foo); 01209 inv.header(h_Bar).push_back(StringCategory("bar1")); 01210 inv.header(h_Bar).push_back(StringCategory("bar2")); 01211 01212 inv.header(h_To); 01213 01214 inv.header(h_RequestLine) = RequestLine(INVITE); 01215 inv.header(h_RequestLine).uri() = Uri("sip:bob@biloxi.com"); 01216 inv.header(h_To) = NameAddr("sip:bob@biloxi.com"); 01217 inv.header(h_From) = NameAddr("Alice <sip:alice@atlanta.com>;tag=1928301774"); 01218 inv.header(h_CallId).value() = "314159"; 01219 inv.header(h_CSeq).sequence() = 14; 01220 inv.header(h_CSeq).method() = INVITE; 01221 01222 PlainContents pc("here is some plain ol' contents"); 01223 inv.setContents(&pc); 01224 01225 resipCerr << inv.header(h_ContentType).type() << endl; 01226 assert(inv.header(h_ContentType).type() == "text"); 01227 assert(inv.header(h_ContentType).subType() == "plain"); 01228 01229 assert(!inv.exists(h_ContentLength)); 01230 01231 assert(inv.getContents()); 01232 assert(dynamic_cast<PlainContents*>(inv.getContents())); 01233 assert(dynamic_cast<PlainContents*>(inv.getContents())->text() == "here is some plain ol' contents"); 01234 01235 const Data d(Data::from(inv)); 01236 01237 resipCerr << "!! " << d; 01238 assert(d == ("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 01239 "To: <sip:bob@biloxi.com>\r\n" 01240 "From: \"Alice\"<sip:alice@atlanta.com>;tag=1928301774\r\n" 01241 "Call-ID: 314159\r\n" 01242 "CSeq: 14 INVITE\r\n" 01243 "Content-Type: text/plain\r\n" 01244 "bar: bar1\r\n" 01245 "bar: bar2\r\n" 01246 "Content-Length: 31\r\n" 01247 "\r\n" 01248 "here is some plain ol' contents")); 01249 } 01250 01251 { 01252 SipMessage inv; 01253 01254 UnknownHeaderType h_Foo("foo"); 01255 UnknownHeaderType h_Bar("bar"); 01256 01257 inv.header(h_Foo); 01258 inv.header(h_Bar).push_back(StringCategory("bar1")); 01259 inv.header(h_Bar).push_back(StringCategory("bar2")); 01260 01261 //inv.header(h_Vias); 01262 inv.header(h_To); 01263 01264 inv.header(h_RequestLine) = RequestLine(INVITE); 01265 inv.header(h_RequestLine).uri() = Uri("sip:bob@biloxi.com"); 01266 inv.header(h_To) = NameAddr("sip:bob@biloxi.com"); 01267 inv.header(h_From) = NameAddr("Alice <sip:alice@atlanta.com>;tag=1928301774"); 01268 inv.header(h_CallId).value() = "314159"; 01269 inv.header(h_CSeq).sequence() = 14; 01270 inv.header(h_CSeq).method() = INVITE; 01271 01272 auto_ptr<Contents> pc(new PlainContents("here is some plain ol' contents")); 01273 inv.setContents(pc); 01274 01275 resipCerr << inv.header(h_ContentType).type() << endl; 01276 assert(inv.header(h_ContentType).type() == "text"); 01277 assert(inv.header(h_ContentType).subType() == "plain"); 01278 01279 assert(!inv.exists(h_ContentLength)); 01280 01281 assert(inv.getContents()); 01282 assert(dynamic_cast<PlainContents*>(inv.getContents())); 01283 assert(dynamic_cast<PlainContents*>(inv.getContents())->text() == "here is some plain ol' contents"); 01284 01285 Data d; 01286 { 01287 DataStream s(d); 01288 inv.encode(s); 01289 } 01290 01291 resipCerr << "!! " << d; 01292 assert(d == ("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 01293 "To: <sip:bob@biloxi.com>\r\n" 01294 "From: \"Alice\"<sip:alice@atlanta.com>;tag=1928301774\r\n" 01295 "Call-ID: 314159\r\n" 01296 "CSeq: 14 INVITE\r\n" 01297 "Content-Type: text/plain\r\n" 01298 // "foo: \r\n" 01299 "bar: bar1\r\n" 01300 "bar: bar2\r\n" 01301 "Content-Length: 31\r\n" 01302 "\r\n" 01303 "here is some plain ol' contents")); 01304 } 01305 01306 { 01307 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 01308 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 01309 "To: \"Bob\"<sip:bob@biloxi.com>\r\n" 01310 "From: \"Alice\"<sip:alice@atlanta.com>;tag=1928301774\r\n" 01311 "Call-ID: a84b4c76e66710\r\n" 01312 "CSeq: 314159 INVITE\r\n" 01313 "Max-Forwards: 70\r\n" 01314 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01315 "Content-Type: application/sdp\r\n" 01316 "Content-Length: 150\r\n" 01317 "\r\n" 01318 "v=0\r\n" 01319 "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" 01320 "s=-\r\n" 01321 "c=IN IP4 pc33.atlanta.com\r\n" 01322 "t=0 0\r\n" 01323 "m=audio 3456 RTP/AVP 0 1 3 99\r\n" 01324 "a=rtpmap:0 PCMU/8000\r\n"); 01325 01326 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 01327 01328 assert(msg->exists(h_ContentType)); 01329 assert(msg->exists(h_ContentLength)); 01330 assert(msg->header(h_ContentLength).value() == 150); 01331 01332 Contents* body = msg->getContents(); 01333 01334 assert(body != 0); 01335 SdpContents* sdp = dynamic_cast<SdpContents*>(body); 01336 assert(sdp != 0); 01337 01338 assert(sdp->session().version() == 0); 01339 assert(sdp->session().origin().user() == "alice"); 01340 assert(!sdp->session().media().empty()); 01341 assert(sdp->session().media().front().getValues("rtpmap").front() == "0 PCMU/8000"); 01342 01343 msg->encode(resipCerr); 01344 } 01345 01346 { 01347 InfoLog(<< "Test SipMessage::releaseContents; no contents"); 01348 01349 SipMessage msg; 01350 assert(msg.getContents() == 0); 01351 auto_ptr<Contents> old = msg.releaseContents(); 01352 assert(old.get() == 0); 01353 assert(msg.getContents() == 0); 01354 } 01355 01356 { 01357 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 01358 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 01359 "To: Bob <sip:bob@biloxi.com>\r\n" 01360 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01361 "Call-ID: a84b4c76e66710\r\n" 01362 "CSeq: 314159 INVITE\r\n" 01363 "Max-Forwards: 70\r\n" 01364 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01365 "Content-Type: application/sdp\r\n" 01366 "Content-Length: 150\r\n" 01367 "\r\n" 01368 "v=0\r\n" 01369 "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" 01370 "s=-\r\n" 01371 "c=IN IP4 pc33.atlanta.com\r\n" 01372 "t=0 0\r\n" 01373 "m=audio 3456 RTP/AVP 0 1 3 99\r\n" 01374 "a=rtpmap:0 PCMU/8000\r\n"); 01375 01376 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 01377 01378 assert(msg->exists(h_ContentType)); 01379 auto_ptr<Contents> abody = msg->releaseContents(); 01380 Contents* body = abody.release(); 01381 01382 assert(body != 0); 01383 SdpContents* sdp = dynamic_cast<SdpContents*>(body); 01384 assert(sdp != 0); 01385 01386 assert(sdp->session().version() == 0); 01387 assert(sdp->session().origin().user() == "alice"); 01388 assert(!sdp->session().media().empty()); 01389 assert(sdp->session().media().front().getValues("rtpmap").front() == "0 PCMU/8000"); 01390 01391 delete sdp; 01392 01393 assert(msg->getContents() == 0); 01394 } 01395 01396 { 01397 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 01398 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 01399 "To: Bob <sip:bob@biloxi.com>\r\n" 01400 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01401 "Call-ID: a84b4c76e66710\r\n" 01402 "CSeq: 314159 INVITE\r\n" 01403 "Max-Forwards: 70\r\n" 01404 "Foobie-Blech: it is not a glass paperweight\r\n" 01405 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01406 "Content-Type: application/sdp\r\n" 01407 "Content-Length: 150\r\n" 01408 "\r\n" 01409 "v=0\r\n" 01410 "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" 01411 "s=-\r\n" 01412 "c=IN IP4 pc33.atlanta.com\r\n" 01413 "t=0 0\r\n" 01414 "m=audio 3456 RTP/AVP 0 1 3 99\r\n" 01415 "a=rtpmap:0 PCMU/8000\r\n"); 01416 01417 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 01418 01419 assert(!msg->header(UnknownHeaderType("Foobie-Blech")).empty()); 01420 assert(msg->header(UnknownHeaderType("Foobie-Blech")).front().value() == "it is not a glass paperweight"); 01421 01422 Contents* body = msg->getContents(); 01423 01424 assert(body != 0); 01425 SdpContents* sdp = dynamic_cast<SdpContents*>(body); 01426 assert(sdp != 0); 01427 01428 assert(sdp->session().version() == 0); 01429 assert(sdp->session().origin().user() == "alice"); 01430 assert(!sdp->session().media().empty()); 01431 assert(sdp->session().media().front().getValues("rtpmap").front() == "0 PCMU/8000"); 01432 01433 msg->encode(resipCerr); 01434 } 01435 01436 { 01437 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 01438 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 01439 "To: Bob <sip:bob@biloxi.com>\r\n" 01440 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 01441 "Call-ID: a84b4c76e66710\r\n" 01442 "CSeq: 314159 INVITE\r\n" 01443 "Max-Forwards: 70\r\n" 01444 "Foobie-Blech: \r\n" 01445 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 01446 "Content-Type: application/sdp\r\n" 01447 "Content-Length: 150\r\n" 01448 "\r\n" 01449 "v=0\r\n" 01450 "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" 01451 "s=-\r\n" 01452 "c=IN IP4 pc33.atlanta.com\r\n" 01453 "t=0 0\r\n" 01454 "m=audio 3456 RTP/AVP 0 1 3 99\r\n" 01455 "a=rtpmap:0 PCMU/8000\r\n"); 01456 01457 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 01458 01459 msg->header(UnknownHeaderType("Foobie-Blech")).empty(); 01460 //assert(!msg->header(UnknownHeaderType("Foobie-Blech")).empty()); 01461 //assert(msg->header(UnknownHeaderType("Foobie-Blech")).front().value() == ""); 01462 msg->encode(resipCerr); 01463 } 01464 01465 { 01466 const char* b = "shared buffer"; 01467 HeaderFieldValue h1(b, strlen(b)); 01468 HeaderFieldValue h2(h1); 01469 } 01470 01471 { 01472 const char *txt = 01473 ("SIP/2.0 200\r\n" 01474 "To: <sip:ext102@squamish.gloo.net:5060>;tag=8be36d98\r\n" 01475 "From: <sip:ext102@squamish.gloo.net:5060>;tag=38810b6d\r\n" 01476 "Call-ID: a6aea86d75a6bb45\r\n" 01477 "CSeq: 2 REGISTER\r\n" 01478 "Contact: <sip:ext102@whistler.gloo.net:6064>;expires=63\r\n" 01479 "Via: SIP/2.0/UDP whistler.gloo.net:6064;rport=6064;received=192.168.2.220;branch=z9hG4bK-kcD23-4-1\r\n" 01480 "Content-Length: 0\r\n" 01481 "\r\n"); 01482 01483 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt)); 01484 resipCerr << msg->header(h_Contacts).front().param(p_expires) << endl; 01485 assert(msg->header(h_Contacts).front().param(p_expires) == 63); 01486 } 01487 01488 { 01489 resipCerr << "test backward compatible expires parameter" << endl; 01490 const char *txt1 = ("REGISTER sip:registrar.biloxi.com SIP/2.0\r\n" 01491 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=first\r\n" 01492 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=second\r\n" 01493 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=third\r\n" 01494 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fourth\r\n" 01495 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fifth\r\n" 01496 "Max-Forwards: 70\r\n" 01497 "To: Bob <sip:bob@biloxi.com>\r\n" 01498 "From: Bob <sip:bob@biloxi.com>;tag=456248\r\n" 01499 "Call-ID: 843817637684230@998sdasdh09\r\n" 01500 "CSeq: 1826 REGISTER\r\n" 01501 "Contact: <sip:bob@192.0.2.4>;expires=\"Sat, 01 Dec 2040 16:00:00 GMT\";foo=bar\r\n" 01502 "Contact: <sip:qoq@192.0.2.4>\r\n" 01503 "Content-Length: 0\r\n\r\n"); 01504 auto_ptr<SipMessage> message1(TestSupport::makeMessage(txt1)); 01505 resipCerr << message1->header(h_Contacts).front().param(p_expires) << endl; 01506 assert(message1->header(h_Contacts).front().param(p_expires) == 3600); 01507 assert(message1->header(h_Contacts).front().param(UnknownParameterType("foo")) == "bar"); 01508 } 01509 01510 { 01511 resipCerr << "test header copying between unparsed messages" << endl; 01512 const char *txt1 = ("REGISTER sip:registrar.biloxi.com SIP/2.0\r\n" 01513 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=first\r\n" 01514 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=second\r\n" 01515 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=third\r\n" 01516 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fourth\r\n" 01517 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fifth\r\n" 01518 "Max-Forwards: 70\r\n" 01519 "To: Bob <sip:bob@biloxi.com>\r\n" 01520 "From: Bob <sip:bob@biloxi.com>;tag=456248\r\n" 01521 "Call-ID: 843817637684230@998sdasdh09\r\n" 01522 "CSeq: 1826 REGISTER\r\n" 01523 "Contact: <sip:bob@192.0.2.4>\r\n" 01524 "Contact: <sip:qoq@192.0.2.4>\r\n" 01525 "Expires: 7200\r\n" 01526 "Content-Length: 0\r\n\r\n"); 01527 auto_ptr<SipMessage> message1(TestSupport::makeMessage(txt1)); 01528 auto_ptr<SipMessage> r(Helper::makeResponse(*message1, 100)); 01529 r->encode(resipCerr); 01530 01531 const char *txt2 = ("REGISTER sip:registrar.ixolib.com SIP/2.0\r\n" 01532 "Via: SIP/2.0/UDP speedyspc.biloxi.com:5060;branch=sfirst\r\n" 01533 "Via: SIP/2.0/UDP speedyspc.biloxi.com:5060;branch=ssecond\r\n" 01534 "Via: SIP/2.0/UDP speedyspc.biloxi.com:5060;branch=sthird\r\n" 01535 "Via: SIP/2.0/UDP speedyspc.biloxi.com:5060;branch=sfourth\r\n" 01536 "Max-Forwards: 7\r\n" 01537 "To: Speedy <sip:speedy@biloxi.com>\r\n" 01538 "From: Speedy <sip:speedy@biloxi.com>;tag=88888\r\n" 01539 "Call-ID: 88888@8888\r\n" 01540 "CSeq: 6281 REGISTER\r\n" 01541 "Contact: <sip:speedy@192.0.2.4>\r\n" 01542 "Contact: <sip:qoq@192.0.2.4>\r\n" 01543 "Expires: 2700\r\n" 01544 "Content-Length: 0\r\n\r\n"); 01545 auto_ptr<SipMessage> message2(TestSupport::makeMessage(txt2)); 01546 01547 // copy over everything 01548 message1->header(h_RequestLine) = message2->header(h_RequestLine); 01549 message1->header(h_Vias) = message2->header(h_Vias); 01550 message1->header(h_MaxForwards) = message2->header(h_MaxForwards); 01551 message1->header(h_To) = message2->header(h_To); 01552 message1->header(h_From) = message2->header(h_From); 01553 message1->header(h_CallId) = message2->header(h_CallId); 01554 message1->header(h_CSeq) = message2->header(h_CSeq); 01555 message1->header(h_Contacts) = message2->header(h_Contacts); 01556 message1->header(h_Expires) = message2->header(h_Expires); 01557 message1->header(h_ContentLength) = message2->header(h_ContentLength); 01558 01559 assert(message1->header(h_To).uri().user() == "speedy"); 01560 assert(message1->header(h_From).uri().user() == "speedy"); 01561 assert(message1->header(h_MaxForwards).value() == 7); 01562 assert(message1->header(h_Contacts).empty() == false); 01563 assert(message1->header(h_CallId).value() == "88888@8888"); 01564 assert(message1->header(h_CSeq).sequence() == 6281); 01565 assert(message1->header(h_CSeq).method() == REGISTER); 01566 assert(message1->header(h_Vias).empty() == false); 01567 assert(message1->header(h_Vias).size() == 4); 01568 assert(message1->header(h_Expires).value() == 2700); 01569 assert(message1->header(h_ContentLength).value() == 0); 01570 resipCerr << "Port: " << message1->header(h_RequestLine).uri().port() << endl; 01571 resipCerr << "AOR: " << message1->header(h_RequestLine).uri().getAor() << endl; 01572 assert(message1->header(h_RequestLine).uri().getAor() == "registrar.ixolib.com"); 01573 } 01574 01575 { 01576 resipCerr << "test header copying between parsed messages" << endl; 01577 resipCerr << " should NOT COPY any HeaderFieldValues" << endl; 01578 const char *txt1 = ("REGISTER sip:registrar.biloxi.com SIP/2.0\r\n" 01579 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=first\r\n" 01580 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=second\r\n" 01581 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=third\r\n" 01582 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fourth\r\n" 01583 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fifth\r\n" 01584 "Max-Forwards: 70\r\n" 01585 "To: Bob <sip:bob@biloxi.com>\r\n" 01586 "From: Bob <sip:bob@biloxi.com>;tag=456248\r\n" 01587 "Call-ID: 843817637684230@998sdasdh09\r\n" 01588 "CSeq: 1826 REGISTER\r\n" 01589 "Contact: <sip:bob@192.0.2.4>\r\n" 01590 "Contact: <sip:qoq@192.0.2.4>\r\n" 01591 "Expires: 7200\r\n" 01592 "Content-Length: 0\r\n\r\n"); 01593 auto_ptr<SipMessage> message1(TestSupport::makeMessage(txt1)); 01594 01595 // parse it 01596 message1->header(h_RequestLine).getMethod(); 01597 for (NameAddrs::iterator i = message1->header(h_Contacts).begin(); 01598 i != message1->header(h_Contacts).end(); i++) 01599 { 01600 i->uri(); 01601 } 01602 01603 for (Vias::iterator i = message1->header(h_Vias).begin(); 01604 i != message1->header(h_Vias).end(); i++) 01605 { 01606 i->sentPort(); 01607 } 01608 01609 message1->header(h_To).uri().user(); 01610 message1->header(h_From).uri().user(); 01611 message1->header(h_MaxForwards).value(); 01612 message1->header(h_Contacts).empty(); 01613 message1->header(h_CallId).value(); 01614 message1->header(h_CSeq).sequence(); 01615 message1->header(h_CSeq).method(); 01616 message1->header(h_Vias).empty(); 01617 message1->header(h_Vias).size(); 01618 message1->header(h_Expires).value(); 01619 message1->header(h_ContentLength).value(); 01620 01621 const char *txt2 = ("REGISTER sip:registrar.ixolib.com SIP/2.0\r\n" 01622 "Via: SIP/2.0/UDP speedyspc.biloxi.com:5061;branch=sfirst\r\n" 01623 "Via: SIP/2.0/UDP speedyspc.biloxi.com:5061;branch=ssecond\r\n" 01624 "Via: SIP/2.0/UDP speedyspc.biloxi.com:5061;branch=sthird\r\n" 01625 "Via: SIP/2.0/UDP speedyspc.biloxi.com:5061;branch=sfourth\r\n" 01626 "Max-Forwards: 7\r\n" 01627 "To: Speedy <sip:speedy@biloxi.com>\r\n" 01628 "From: Belle <sip:belle@biloxi.com>;tag=88888\r\n" 01629 "Call-ID: 88888@8888\r\n" 01630 "CSeq: 6281 REGISTER\r\n" 01631 "Contact: <sip:belle@192.0.2.4>\r\n" 01632 "Contact: <sip:qoq@192.0.2.4>\r\n" 01633 "Expires: 2700\r\n" 01634 "Content-Length: 0\r\n\r\n"); 01635 auto_ptr<SipMessage> message2(TestSupport::makeMessage(txt2)); 01636 01637 assert(message2->header(h_RequestLine).getMethod() == REGISTER); 01638 assert(message2->header(h_To).uri().user() == "speedy"); 01639 assert(message2->header(h_From).uri().user() == "belle"); 01640 assert(message2->header(h_MaxForwards).value() == 7); 01641 for (NameAddrs::iterator i = message2->header(h_Contacts).begin(); 01642 i != message2->header(h_Contacts).end(); i++) 01643 { 01644 i->uri(); 01645 } 01646 01647 for (Vias::iterator i = message2->header(h_Vias).begin(); 01648 i != message2->header(h_Vias).end(); i++) 01649 { 01650 assert(i->sentPort() == 5061); 01651 } 01652 assert(message2->header(h_CallId).value() == "88888@8888"); 01653 assert(message2->header(h_CSeq).sequence() == 6281); 01654 assert(message2->header(h_CSeq).method() == REGISTER); 01655 assert(message2->header(h_Vias).empty() == false); 01656 assert(message2->header(h_Vias).size() == 4); 01657 assert(message2->header(h_Expires).value() == 2700); 01658 assert(message2->header(h_ContentLength).value() == 0); 01659 01660 // copy over everything 01661 message1->header(h_RequestLine) = message2->header(h_RequestLine); 01662 message1->header(h_Vias) = message2->header(h_Vias); 01663 message1->header(h_MaxForwards) = message2->header(h_MaxForwards); 01664 message1->header(h_To) = message2->header(h_To); 01665 message1->header(h_From) = message2->header(h_From); 01666 message1->header(h_CallId) = message2->header(h_CallId); 01667 message1->header(h_CSeq) = message2->header(h_CSeq); 01668 message1->header(h_Contacts) = message2->header(h_Contacts); 01669 message1->header(h_Expires) = message2->header(h_Expires); 01670 message1->header(h_ContentLength) = message2->header(h_ContentLength); 01671 01672 assert(message1->header(h_To).uri().user() == "speedy"); 01673 assert(message1->header(h_From).uri().user() == "belle"); 01674 assert(message1->header(h_MaxForwards).value() == 7); 01675 assert(message1->header(h_Contacts).empty() == false); 01676 assert(message1->header(h_CallId).value() == "88888@8888"); 01677 assert(message1->header(h_CSeq).sequence() == 6281); 01678 assert(message1->header(h_CSeq).method() == REGISTER); 01679 assert(message1->header(h_Vias).empty() == false); 01680 assert(message1->header(h_Vias).size() == 4); 01681 assert(message1->header(h_Expires).value() == 2700); 01682 assert(message1->header(h_ContentLength).value() == 0); 01683 assert(message1->header(h_RequestLine).uri().getAor() == "registrar.ixolib.com"); 01684 } 01685 01686 { 01687 resipCerr << "test unparsed message copy" << endl; 01688 const char *txt = ("REGISTER sip:registrar.biloxi.com SIP/2.0\r\n" 01689 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=first\r\n" 01690 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=second\r\n" 01691 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=third\r\n" 01692 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fourth\r\n" 01693 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fifth\r\n" 01694 "Max-Forwards: 70\r\n" 01695 "To: Bob <sip:bob@biloxi.com>\r\n" 01696 "From: Bob <sip:bob@biloxi.com>;tag=456248\r\n" 01697 "Call-ID: 843817637684230@998sdasdh09\r\n" 01698 "CSeq: 1826 REGISTER\r\n" 01699 "Contact: <sip:bob@192.0.2.4>\r\n" 01700 "Contact: <sip:qoq@192.0.2.4>\r\n" 01701 "Expires: 7200\r\n" 01702 "Content-Length: 0\r\n\r\n"); 01703 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01704 01705 SipMessage copy(*message); 01706 copy.encode(resipCerr); 01707 resipCerr << endl; 01708 } 01709 01710 { 01711 resipCerr << "test header creation" << endl; 01712 SipMessage message; 01713 01714 message.header(h_CSeq).sequence() = 123456; 01715 assert(message.header(h_CSeq).sequence() == 123456); 01716 01717 message.header(h_To).uri().user() = "speedy"; 01718 assert(message.header(h_To).uri().user() == "speedy"); 01719 01720 message.encode(resipCerr); 01721 01722 } 01723 01724 { 01725 resipCerr << "test multiheaders access" << endl; 01726 01727 const char *txt = ("REGISTER sip:registrar.biloxi.com SIP/2.0\r\n" 01728 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=first\r\n" 01729 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=second\r\n" 01730 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=third\r\n" 01731 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fourth\r\n" 01732 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=fifth\r\n" 01733 "Max-Forwards: 70\r\n" 01734 "To: Bob <sip:bob@biloxi.com>\r\n" 01735 "From: Bob <sip:bob@biloxi.com>;tag=456248\r\n" 01736 "Call-ID: 843817637684230@998sdasdh09\r\n" 01737 "CSeq: 1826 REGISTER\r\n" 01738 "Contact: <sip:bob@192.0.2.4>\r\n" 01739 "Contact: <sip:qoq@192.0.2.4>\r\n" 01740 "Expires: 7200\r\n" 01741 "Content-Length: 0\r\n\r\n"); 01742 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01743 01744 resipCerr << "Encode from unparsed: " << endl; 01745 message->encode(resipCerr); 01746 01747 assert(message->header(h_To).uri().user() == "bob"); 01748 assert(message->header(h_From).uri().user() == "bob"); 01749 assert(message->header(h_MaxForwards).value() == 70); 01750 assert(message->header(h_Contacts).empty() == false); 01751 assert(message->header(h_CallId).value() == "843817637684230@998sdasdh09"); 01752 assert(message->header(h_CSeq).sequence() == 1826); 01753 assert(message->header(h_CSeq).method() == REGISTER); 01754 assert(message->header(h_Vias).empty() == false); 01755 assert(message->header(h_Vias).size() == 5); 01756 assert(message->header(h_Expires).value() == 7200); 01757 assert(message->header(h_ContentLength).value() == 0); 01758 assert(message->header(h_RequestLine).uri().getAor() == "registrar.biloxi.com"); 01759 01760 resipCerr << "Encode from parsed: " << endl; 01761 message->encode(resipCerr); 01762 01763 message->header(h_Contacts).front().uri().user() = "jason"; 01764 01765 resipCerr << "Encode after messing: " << endl; 01766 message->encode(resipCerr); 01767 01768 SipMessage copy(*message); 01769 assert(copy.header(h_To).uri().user() == "bob"); 01770 assert(copy.header(h_From).uri().user() == "bob"); 01771 assert(copy.header(h_MaxForwards).value() == 70); 01772 assert(copy.header(h_Contacts).empty() == false); 01773 assert(copy.header(h_CallId).value() == "843817637684230@998sdasdh09"); 01774 assert(copy.header(h_CSeq).sequence() == 1826); 01775 assert(copy.header(h_CSeq).method() == REGISTER); 01776 assert(copy.header(h_Vias).empty() == false); 01777 assert(copy.header(h_Vias).size() == 5); 01778 assert(copy.header(h_Expires).value() == 7200); 01779 assert(copy.header(h_ContentLength).value() == 0); 01780 resipCerr << "RequestLine Uri AOR = " << copy.header(h_RequestLine).uri().getAor() << endl; 01781 assert(copy.header(h_RequestLine).uri().getAor() == "registrar.biloxi.com"); 01782 01783 01784 resipCerr << "Encode after copying: " << endl; 01785 copy.encode(resipCerr); 01786 } 01787 01788 { 01789 resipCerr << "test callId access" << endl; 01790 01791 const char *txt = ("REGISTER sip:registrar.biloxi.com SIP/2.0\r\n" 01792 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\n" 01793 "Max-Forwards: 70\r\n" 01794 "To: Bob <sip:bob@biloxi.com>\r\n" 01795 "From: Bob <sip:bob@biloxi.com>;tag=456248\r\n" 01796 "Call-ID: 843817637684230@998sdasdh09\r\n" 01797 "CSeq: 1826 REGISTER\r\n" 01798 "Contact: <sip:bob@192.0.2.4>\r\n" 01799 "Expires: 7200\r\n" 01800 "Content-Length: 0\r\n\r\n"); 01801 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01802 01803 message->encode(resipCerr); 01804 01805 //Data v = message->header(h_CallId).value(); 01806 assert(message->header(h_CallId).value() == "843817637684230@998sdasdh09"); 01807 //StatusLine& foo = message->header(h_StatusLine); 01808 //RequestLine& bar = message->header(h_RequestLine); 01809 //resipCerr << bar.getMethod() << endl; 01810 } 01811 01812 { 01813 const char *txt = ("REGISTER sip:registrar.biloxi.com SIP/2.0\r\n" 01814 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\n" 01815 "Max-Forwards: 70\r\n" 01816 "To: Bob <sip:bob@biloxi.com>\r\n" 01817 "From: Bob <sip:bob@biloxi.com>;tag=456248;xmobility=hobble\r\n" 01818 "Call-ID: 843817637684230@998sdasdh09\r\n" 01819 "CSeq: 1826 REGISTER\r\n" 01820 "Contact: <sip:bob@192.0.2.4>\r\n" 01821 "Expires: 7200\r\n" 01822 "Content-Length: 0\r\n\r\n"); 01823 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01824 01825 Data v = message->header(h_CallId).value(); 01826 resipCerr << "Call-ID is " << v << endl; 01827 01828 message->encode(resipCerr); 01829 01830 //StatusLine& foo = message->header(h_StatusLine); 01831 //RequestLine& bar = message->header(h_RequestLine); 01832 //resipCerr << bar.getMethod() << endl; 01833 } 01834 01835 { 01836 01837 const char *txt = ("REGISTER sip:registrar.biloxi.com SIP/2.0\r\n" 01838 "Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\n" 01839 "Max-Forwards: 70\r\n" 01840 "To: Bob <sip:bob@biloxi.com>\r\n" 01841 "From: Bob <sip:bob@biloxi.com>;tag=456248;mobility=\"hobble\"\r\n" 01842 "Call-ID: 843817637684230@998sdasdh09\r\n" 01843 "CSeq: 1826 REGISTER\r\n" 01844 "Contact: <sip:bob@192.0.2.4>\r\n" 01845 "Expires: 7200\r\n" 01846 "Content-Length: 0\r\n\r\n"); 01847 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01848 01849 assert(message->getRawHeader(Headers::From)); 01850 assert(&message->header(h_From)); 01851 assert(message->header(h_From).exists(p_tag) == true); 01852 assert(message->header(h_From).exists(p_mobility) == true); 01853 assert(message->header(h_From).param(p_tag) == "456248"); 01854 assert(message->header(h_From).param(p_mobility) == "hobble"); 01855 01856 message->encode(resipCerr); 01857 01858 //StatusLine& foo = message->header(h_StatusLine); 01859 //RequestLine& bar = message->header(h_RequestLine); 01860 //resipCerr << bar.getMethod() << endl; 01861 } 01862 01863 { 01864 resipCerr << "first REGISTER in torture test" << endl; 01865 01866 const char *txt = ("REGISTER sip:company.com SIP/2.0\r\n" 01867 "To: sip:user@company.com\r\n" 01868 "From: sip:user@company.com;tag=3411345\r\n" 01869 "Max-Forwards: 8\r\n" 01870 "Contact: sip:user@host.company.com\r\n" 01871 "Call-ID: 0ha0isndaksdj@10.0.0.1\r\n" 01872 "CSeq: 8 REGISTER\r\n" 01873 "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n" 01874 "Expires: 353245\r\n\r\n"); 01875 01876 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01877 01878 assert(message->isRequest()); 01879 assert(message->isResponse() == false); 01880 01881 assert(message->exists(h_To)); 01882 assert(message->header(h_To).uri().user() == "user"); 01883 assert(message->header(h_To).uri().host() == "company.com"); 01884 assert(message->header(h_To).uri().exists(p_tag_ext) == false); 01885 01886 assert(message->exists(h_From)); 01887 assert(message->header(h_From).uri().user() == "user"); 01888 assert(message->header(h_From).uri().host() == "company.com"); 01889 assert(message->header(h_From).param(p_tag) == "3411345"); 01890 01891 assert(message->exists(h_MaxForwards)); 01892 assert(message->header(h_MaxForwards).value() == 8); 01893 assert(message->header(h_MaxForwards).exists(p_tag_ext) == false); 01894 01895 assert(message->exists(h_Contacts)); 01896 assert(message->header(h_Contacts).empty() == false); 01897 assert(message->header(h_Contacts).front().uri().user() == "user"); 01898 assert(message->header(h_Contacts).front().uri().host() == "host.company.com"); 01899 assert(message->header(h_Contacts).front().uri().port() == 0); 01900 01901 assert(message->exists(h_CallId)); 01902 assert(message->header(h_CallId).value() == "0ha0isndaksdj@10.0.0.1"); 01903 01904 assert(message->exists(h_CSeq)); 01905 assert(message->header(h_CSeq).sequence() == 8); 01906 assert(message->header(h_CSeq).method() == REGISTER); 01907 01908 assert(message->exists(h_Vias)); 01909 assert(message->header(h_Vias).empty() == false); 01910 assert(message->header(h_Vias).front().protocolName() == "SIP"); 01911 assert(message->header(h_Vias).front().protocolVersion() == "2.0"); 01912 assert(message->header(h_Vias).front().transport() == "UDP"); 01913 assert(message->header(h_Vias).front().sentHost() == "135.180.130.133"); 01914 assert(message->header(h_Vias).front().sentPort() == 0); 01915 01916 assert(message->exists(h_Expires)); 01917 assert(message->header(h_Expires).value() == 353245); 01918 01919 resipCerr << "Headers::Expires enum = " << h_Expires.getTypeNum() << endl; 01920 01921 message->encode(resipCerr); 01922 } 01923 01924 { 01925 resipCerr << "first REGISTER in torture test" << endl; 01926 01927 const char *txt = ("REGISTER sip:company.com SIP/2.0\r\n" 01928 "To: sip:user@company.com\r\n" 01929 "From: sip:user@company.com;tag=3411345\r\n" 01930 "Max-Forwards: 8\r\n" 01931 "Contact: sip:user@host.company.com\r\n" 01932 "Call-ID: 0ha0isndaksdj@10.0.0.1\r\n" 01933 "CSeq: 8 REGISTER\r\n" 01934 "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n" 01935 "Expires: 353245\r\n\r\n"); 01936 01937 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01938 01939 assert(message->header(h_MaxForwards).value() == 8); 01940 message->getRawHeader(Headers::MaxForwards)->getParserContainer()->encode(Headers::getHeaderName(Headers::MaxForwards), resipCerr) << endl; 01941 } 01942 01943 { 01944 resipCerr << "response to REGISTER" << endl; 01945 01946 const char *txt = ("SIP/2.0 100 Trying\r\n" 01947 "To: sip:localhost:5070\r\n" 01948 "From: sip:localhost:5070;tag=73483366\r\n" 01949 "Call-ID: 51dcb07418a21008e0ba100800000000\r\n" 01950 "CSeq: 1 REGISTER\r\n" 01951 "Via: SIP/2.0/UDP squamish.gloo.net:5060;branch=z9hG4bKff5c491951e40f08\r\n" 01952 "Content-Length: 0\r\n\r\n"); 01953 01954 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01955 01956 assert(message->header(h_To).uri().host() == "localhost"); 01957 } 01958 { 01959 NameAddr me; 01960 me.uri().host() = "localhost"; 01961 me.uri().port() = 5070; 01962 //auto_ptr<SipMessage> msg(Helper::makeRegister(me, me)); 01963 auto_ptr<SipMessage> msg(Helper::makeRegister(me, me, me)); 01964 resipCerr << "encoded=" << *msg << endl; 01965 } 01966 { 01967 const char *txt = ("REGISTER sip:company.com SIP/2.0\r\n" 01968 "To: sip:user@company.com\r\n" 01969 "From: sip:user@company.com;tag=3411345\r\n" 01970 "Max-Forwards: 8\r\n" 01971 "Contact: sip:user@host.company.com\r\n" 01972 "Call-ID: 0ha0isndaksdj@10.0.0.1\r\n" 01973 "CSeq: 8 REGISTER\r\n" 01974 "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n" 01975 "Expires: 353245\r\n\r\n"); 01976 01977 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01978 message->header(h_RequestLine).uri(); 01979 auto_ptr<SipMessage> copy(new SipMessage(*message)); 01980 assert(message->header(h_RequestLine).getMethod() == copy->header(h_RequestLine).getMethod()); 01981 } 01982 { 01983 const char *txt = ("REGISTER sip:company.com SIP/2.0\r\n" 01984 "To: sip:user@company.com\r\n" 01985 "From: sip:user@company.com;tag=3411345\r\n" 01986 "Max-Forwards: 8\r\n" 01987 "Contact: sip:user@host.company.com\r\n" 01988 "Call-ID: 0ha0isndaksdj@10.0.0.1\r\n" 01989 "Security-Client: ipsec-ike;d-alg=md5;q=0.1\r\n" 01990 "Security-Server: tls;q=0.2;d-qop=verify\r\n" 01991 "Security-Verify: tls;q=0.2;d-ver=\"0000000000000000000000000000abcd\"\r\n" 01992 "CSeq: 8 REGISTER\r\n" 01993 "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n" 01994 "Expires: 353245\r\n\r\n"); 01995 01996 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 01997 assert(message->header(h_SecurityClients).front().value() == "ipsec-ike"); 01998 assert(message->header(h_SecurityClients).front().param(p_dAlg) == "md5"); 01999 assert(message->header(h_SecurityClients).front().param(p_q) == 100); 02000 #ifndef RESIP_FIXED_POINT 02001 assert(message->header(h_SecurityClients).front().param(p_q) == double(0.1)); 02002 assert(message->header(h_SecurityClients).front().param(p_q) == 0.1); 02003 assert(message->header(h_SecurityClients).front().param(p_q) == float(0.1)); 02004 #endif 02005 02006 assert(message->header(h_SecurityServers).front().value() == "tls"); 02007 assert(message->header(h_SecurityServers).front().param(p_dQop) == "verify"); 02008 #ifndef RESIP_FIXED_POINT 02009 assert(message->header(h_SecurityServers).front().param(p_q) == double(0.2)); 02010 assert(message->header(h_SecurityServers).front().param(p_q) == 0.2f); 02011 #endif 02012 assert(message->header(h_SecurityServers).front().param(p_q) == 200); 02013 02014 assert(message->header(h_SecurityVerifies).front().value() == "tls"); 02015 assert(message->header(h_SecurityVerifies).front().param(p_dVer) == "0000000000000000000000000000abcd"); 02016 #ifndef RESIP_FIXED_POINT 02017 assert(message->header(h_SecurityVerifies).front().param(p_q) == double(0.2)); 02018 assert(message->header(h_SecurityVerifies).front().param(p_q) == 0.2f); 02019 #endif 02020 assert(message->header(h_SecurityVerifies).front().param(p_q) == 200); 02021 02022 assert(message->exists(h_AllowEvents) == false); 02023 } 02024 02025 { 02026 const char *txt = ("REGISTER sip:company.com SIP/2.0\r\n" 02027 "To: sip:user@company.com\r\n" 02028 "From: sip:user@company.com;tag=3411345\r\n" 02029 "Max-Forwards: 8\r\n" 02030 "Contact: sip:user@host.company.com\r\n" 02031 "Call-ID: 0ha0isndaksdj@10.0.0.1\r\n" 02032 "CSeq: 8 REGISTER\r\n" 02033 "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n" 02034 "Expires: 353245\r\n\r\n"); 02035 02036 const char *txt2 = ("REGISTER sip:company.com SIP/2.0\r\n" 02037 "To: sip:user@company.com\r\n" 02038 "From: sip:user@company.com;tag=3411345\r\n" 02039 "Max-Forwards: 8\r\n" 02040 "Contact: sip:user@host.company.com\r\n" 02041 "Call-ID: 0ha0isndaksdj@10.0.0.1\r\n" 02042 "Security-Client: ipsec-ike;d-alg=md5;q=0.1\r\n" 02043 "Security-Server: tls;q=0.2;d-qop=verify\r\n" 02044 "Security-Verify: tls;q=0.2;d-ver=\"0000000000000000000000000000abcd\"\r\n" 02045 "CSeq: 8 REGISTER\r\n" 02046 "Via: SIP/2.0/UDP 135.180.130.133;branch=z9hG4bKkdjuw\r\n" 02047 "Expires: 353245\r\n\r\n"); 02048 02049 auto_ptr<SipMessage> message(TestSupport::makeMessage(txt)); 02050 02051 { 02052 Token sec; 02053 sec.value() = "ipsec-ike"; 02054 sec.param(p_dAlg) = "md5"; 02055 sec.param(p_q) = 100; 02056 message->header(h_SecurityClients).push_back(sec); 02057 } 02058 { 02059 Token sec; 02060 sec.value() = "tls"; 02061 sec.param(p_q) = 200; 02062 sec.param(p_dQop) = "verify"; 02063 message->header(h_SecurityServers).push_back(sec); 02064 } 02065 { 02066 Token sec; 02067 sec.value() = "tls"; 02068 sec.param(p_q) = 200; 02069 sec.param(p_dVer) = "0000000000000000000000000000abcd"; 02070 message->header(h_SecurityVerifies).push_back(sec); 02071 } 02072 02073 auto_ptr<SipMessage> message2(TestSupport::makeMessage(txt2)); 02074 02075 Data msgEncoded; 02076 { 02077 DataStream s(msgEncoded); 02078 s << *message; 02079 } 02080 02081 Data msg2Encoded; 02082 { 02083 DataStream s(msg2Encoded); 02084 s << *message2; 02085 } 02086 02087 assert(msgEncoded == msg2Encoded); 02088 } 02089 02090 { 02091 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 02092 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 02093 "To: Bob <sip:bob@biloxi.com>\r\n" 02094 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 02095 "Call-ID: a84b4c76e66710\r\n" 02096 "CSeq: 314159 INVITE\r\n" 02097 "Max-Forwards: 70\r\n" 02098 "Accept: \r\n" 02099 "Foobie-Blech: \r\n" 02100 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 02101 "Content-Type: application/sdp\r\n" 02102 "Content-Length: 150\r\n" 02103 "\r\n" 02104 "v=0\r\n" 02105 "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" 02106 "s=-\r\n" 02107 "c=IN IP4 pc33.atlanta.com\r\n" 02108 "t=0 0\r\n" 02109 "m=audio 3456 RTP/AVP 0 1 3 99\r\n" 02110 "a=rtpmap:0 PCMU/8000\r\n"); 02111 02112 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 02113 02114 assert(msg->exists(h_Accepts)); 02115 assert(msg->header(h_Accepts).empty()); 02116 02117 assert(msg->exists(UnknownHeaderType("Foobie-Blech"))); 02118 assert(msg->header(UnknownHeaderType("Foobie-Blech")).empty()); 02119 } 02120 02121 { 02122 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 02123 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 02124 "To: Bob <sip:bob@biloxi.com>\r\n" 02125 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 02126 "Call-ID: a84b4c76e66710\r\n" 02127 "CSeq: 314159 INVITE\r\n" 02128 "Max-Forwards: 70\r\n" 02129 "Accept: \r\n" 02130 "Foobie-Blech: \r\n" 02131 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 02132 "Content-Type: application/sdp\r\n" 02133 "Content-Length: 150\r\n" 02134 "FooBarBaz: yetmorestuff\r\n" 02135 "FooBar: morestuff\r\n" 02136 "Foo: stuff\r\n" 02137 "\r\n" 02138 "v=0\r\n" 02139 "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" 02140 "s=-\r\n" 02141 "c=IN IP4 pc33.atlanta.com\r\n" 02142 "t=0 0\r\n" 02143 "m=audio 3456 RTP/AVP 0 1 3 99\r\n" 02144 "a=rtpmap:0 PCMU/8000\r\n"); 02145 02146 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 02147 02148 assert(msg->exists(h_Accepts)); 02149 assert(msg->header(h_Accepts).empty()); 02150 02151 assert(msg->exists(UnknownHeaderType("Foobie-Blech"))); 02152 assert(msg->header(UnknownHeaderType("Foobie-Blech")).empty()); 02153 02154 assert(msg->exists(UnknownHeaderType("Foo"))); 02155 assert(msg->header(UnknownHeaderType("Foo")).size()==1); 02156 02157 assert(msg->exists(UnknownHeaderType("FooBar"))); 02158 assert(msg->header(UnknownHeaderType("FooBar")).size()==1); 02159 02160 assert(msg->exists(UnknownHeaderType("FooBarBaz"))); 02161 assert(msg->header(UnknownHeaderType("FooBarBaz")).size()==1); 02162 } 02163 02164 { 02165 resip::Data invBuf; 02166 { 02167 resip::DataStream ds(invBuf); 02168 02169 ds << "INVITE sip:7003@192.122.24.94:20060?REQUIRE=replaces SIP/2.0\r\n"; 02170 ds << "Via: SIP/2.0/UDP 192.122.24.109;branch=z9hG4bKfc4a20db5EC58FB8\r\n"; 02171 ds << "From: \"7006 601\" <sip:7006@scsuk.europe.nortel.com>;tag=29C49D21-D9FDBDBC\r\n"; 02172 ds << "To: <sip:7003@192.122.24.94:20060?REQUIRE=replaces>\r\n"; 02173 ds << "CSeq: 1 INVITE\r\n"; 02174 ds << "Call-ID: a9ad18fd-5fd391bf-309febea@192.122.24.109\r\n"; 02175 ds << "Contact: <sip:7006@192.122.24.109>\r\n"; 02176 ds << "Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER\r\n"; 02177 ds << "User-Agent: PolycomSoundPointIP-SPIP_601-UA/2.1.1.0052\r\n"; 02178 ds << "Supported: 100rel,replaces\r\n"; 02179 ds << "Allow-Events: talk,hold,conference\r\n"; 02180 ds << "Replaces: MDQ5MDJmZGEyYTkyNTBhZjBhNDg0NjUyMzE1MTc2Mjk.;to-tag=cf71d002;from-tag=1394930945\r\n"; 02181 ds << "Referred-By: <sip:7776@scsuk.europe.nortel.com>\r\n"; 02182 ds << "Max-Forwards: 70\r\n"; 02183 ds << "Content-Type: application/sdp\r\n"; 02184 ds << "Content-Length: 253\r\n"; 02185 ds << "\r\n"; 02186 ds << "v=0\r\n"; 02187 ds << "o=- 1210601497 1210601497 IN IP4 192.122.24.109\r\n"; 02188 ds << "s=Polycom IP Phone\r\n"; 02189 ds << "c=IN IP4 192.122.24.109\r\n"; 02190 ds << "t=0 0\r\n"; 02191 ds << "m=audio 2224 RTP/AVP 0 8 18 101\r\n"; 02192 ds << "a=sendrecv\r\n"; 02193 ds << "a=rtpmap:0 PCMU/8000\r\n"; 02194 ds << "a=rtpmap:8 PCMA/8000\r\n"; 02195 ds << "a=rtpmap:18 G729/8000\r\n"; 02196 ds << "a=rtpmap:101 telephone-event/8000\r\n"; 02197 } 02198 02199 auto_ptr<SipMessage> testMsg(TestSupport::makeMessage(invBuf)); 02200 assert(testMsg->header(h_RequestLine).isWellFormed()); 02201 assert(testMsg->header(h_RequestLine).method() == INVITE); 02202 assert(testMsg->header(h_RequestLine).getSipVersion() == "SIP/2.0"); 02203 assert(testMsg->header(h_RequestLine).uri().hasEmbedded()); 02204 SipMessage& embeddedMsg = testMsg->header(h_RequestLine).uri().embedded(); 02205 assert(embeddedMsg.exists(h_Requires)); 02206 assert(embeddedMsg.header(h_Requires).find(Token(Symbols::Replaces))); 02207 assert(testMsg->header(h_To).uri().hasEmbedded()); 02208 SipMessage& embeddedMsg2 = testMsg->header(h_To).uri().embedded(); 02209 assert(embeddedMsg2.exists(h_Requires)); 02210 assert(embeddedMsg2.header(h_Requires).find(Token(Symbols::Replaces))); 02211 } 02212 02213 resipCerr << "\nTEST OK" << endl; 02214 return 0; 02215 } 02216 02217 /* ==================================================================== 02218 * The Vovida Software License, Version 1.0 02219 * 02220 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 02221 * 02222 * Redistribution and use in source and binary forms, with or without 02223 * modification, are permitted provided that the following conditions 02224 * are met: 02225 * 02226 * 1. Redistributions of source code must retain the above copyright 02227 * notice, this list of conditions and the following disclaimer. 02228 * 02229 * 2. Redistributions in binary form must reproduce the above copyright 02230 * notice, this list of conditions and the following disclaimer in 02231 * the documentation and/or other materials provided with the 02232 * distribution. 02233 * 02234 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 02235 * and "Vovida Open Communication Application Library (VOCAL)" must 02236 * not be used to endorse or promote products derived from this 02237 * software without prior written permission. For written 02238 * permission, please contact vocal@vovida.org. 02239 * 02240 * 4. Products derived from this software may not be called "VOCAL", nor 02241 * may "VOCAL" appear in their name, without prior written 02242 * permission of Vovida Networks, Inc. 02243 * 02244 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 02245 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 02246 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 02247 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 02248 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 02249 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 02250 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 02251 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 02252 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 02253 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 02254 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 02255 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 02256 * DAMAGE. 02257 * 02258 * ==================================================================== 02259 * 02260 * This software consists of voluntary contributions made by Vovida 02261 * Networks, Inc. and many individuals on behalf of Vovida Networks, 02262 * Inc. For more information on Vovida Networks, Inc., please see 02263 * <http://www.vovida.org/>. 02264 * 02265 */
1.7.5.1