~ubuntu-branches/ubuntu/saucy/resiprocate/saucy-proposed

« back to all changes in this revision

Viewing changes to resip/stack/test/RFC4475TortureTests.cxx

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2012-05-17 19:29:59 UTC
  • Revision ID: package-import@ubuntu.com-20120517192959-vv00m77isztdy64q
Tags: upstream-1.8.2
ImportĀ upstreamĀ versionĀ 1.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <iostream>
 
2
#include <memory>
 
3
 
 
4
#include "resip/stack/Contents.hxx"
 
5
#include "resip/stack/SdpContents.hxx"
 
6
#include "resip/stack/SipMessage.hxx"
 
7
#include "resip/stack/ExtensionHeader.hxx"
 
8
#include "resip/stack/ExtensionParameter.hxx"
 
9
#include "resip/stack/ParserCategories.hxx"
 
10
#include "resip/stack/ParameterTypes.hxx"
 
11
#include "resip/stack/Uri.hxx"
 
12
#include "rutil/Logger.hxx"
 
13
#include "tassert.h"
 
14
 
 
15
#define RESIPROCATE_SUBSYSTEM resip::Subsystem::TEST
 
16
 
 
17
void
 
18
wsinv()
 
19
{
 
20
/*
 
21
   This short, relatively human-readable message contains:
 
22
 
 
23
   o  line folding all over.
 
24
 
 
25
   o  escaped characters within quotes.
 
26
 
 
27
   o  an empty subject.
 
28
 
 
29
   o  LWS between colons, semicolons, header field values, and other
 
30
      fields.
 
31
 
 
32
   o  both comma separated and separately listed header field values.
 
33
 
 
34
   o  a mix of short and long form for the same header field name.
 
35
 
 
36
   o  unknown Request-URI parameter.
 
37
 
 
38
   o  unknown header fields.
 
39
 
 
40
   o  an unknown header field with a value that would be syntactically
 
41
      invalid if it were defined in terms of generic-param.
 
42
 
 
43
   o  unusual header field ordering.
 
44
 
 
45
   o  unusual header field name character case.
 
46
 
 
47
   o  unknown parameters of a known header field.
 
48
 
 
49
   o  a uri parameter with no value.
 
50
 
 
51
   o  a header parameter with no value.
 
52
 
 
53
   o  integer fields (Max-Forwards and CSeq) with leading zeros.
 
54
 
 
55
   All elements should treat this as a well-formed request.
 
56
 
 
57
   The UnknownHeaderWithUnusualValue header field deserves special
 
58
   attention.  If this header field were defined in terms of comma-
 
59
   separated values with semicolon-separated parameters (as would many
 
60
   of the existing defined header fields), this would be invalid.
 
61
   However, since the receiving element does not know the definition of
 
62
   the syntax for this field, it must parse it as a header value.
 
63
   Proxies would forward this header field unchanged.  Endpoints would
 
64
   ignore the header field.
 
65
 
 
66
INVITE sip:vivekg@chair-dnrc.example.com;unknownparam SIP/2.0
 
67
TO :
 
68
 sip:vivekg@chair-dnrc.example.com ;   tag    = 1918181833n
 
69
from   : "J Rosenberg \\\""       <sip:jdrosen@example.com>
 
70
  ;
 
71
  tag = 98asjd8
 
72
MaX-fOrWaRdS: 0068
 
73
Call-ID: wsinv.ndaksdj@192.0.2.1
 
74
Content-Length   : 150
 
75
cseq: 0009
 
76
  INVITE
 
77
Via  : SIP  /   2.0
 
78
 /UDP
 
79
    192.0.2.2;branch=390skdjuw
 
80
s :
 
81
NewFangledHeader:   newfangled value
 
82
 continued newfangled value
 
83
UnknownHeaderWithUnusualValue: ;;,,;;,;
 
84
Content-Type: application/sdp
 
85
Route:
 
86
 <sip:services.example.com;lr;unknownwith=value;unknown-no-value>
 
87
v:  SIP  / 2.0  / TCP     spindle.example.com   ;
 
88
  branch  =   z9hG4bK9ikj8  ,
 
89
 SIP  /    2.0   / UDP  192.168.255.111   ; branch=
 
90
 z9hG4bK30239
 
91
m:"Quoted string \"\"" <sip:jdrosen@example.com> ; newparam =
 
92
      newvalue ;
 
93
  secondparam ; q = 0.33
 
94
 
 
95
v=0
 
96
o=mhandley 29739 7272939 IN IP4 192.0.2.3
 
97
s=-
 
98
c=IN IP4 192.0.2.4
 
99
t=0 0
 
100
m=audio 49217 RTP/AVP 0 12
 
101
m=video 3227 RTP/AVP 31
 
102
a=rtpmap:31 LPC
 
103
 
 
104
*/
 
105
   FILE* fid= fopen("wsinv.dat","r");
 
106
   tassert(fid);
 
107
   resip::Data txt;
 
108
   char mBuf[1024];
 
109
   int result;
 
110
   while(!feof(fid))
 
111
   {
 
112
      result = fread(&mBuf,1,1024,fid);
 
113
      txt += resip::Data(mBuf,result);
 
114
   }
 
115
   fclose(fid);
 
116
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
117
   tassert_reset();
 
118
   tassert(msg);
 
119
   tassert_reset();
 
120
   if(!msg)
 
121
   {
 
122
      return;
 
123
   }
 
124
 
 
125
   std::auto_ptr<resip::SipMessage> message(msg);
 
126
   msg->parseAllHeaders();
 
127
 
 
128
   resip::SipMessage copy(*msg);
 
129
 
 
130
   resip::Data encoded;
 
131
   {
 
132
      resip::oDataStream str(encoded);
 
133
      msg->encode(str);
 
134
   }
 
135
   resip::Data copyEncoded;
 
136
   {
 
137
      resip::oDataStream str(copyEncoded);
 
138
      copy.encode(str);
 
139
   }
 
140
   
 
141
   // Request Line
 
142
   tassert(msg->header(resip::h_RequestLine).method()==resip::INVITE);
 
143
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="INVITE");
 
144
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
145
   tassert(msg->header(resip::h_RequestLine).uri().user()=="vivekg");
 
146
   tassert(msg->header(resip::h_RequestLine).uri().host()=="chair-dnrc.example.com");
 
147
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
148
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
149
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
150
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
151
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==1);
 
152
   resip::ExtensionParameter p_unknownparam("unknownparam");
 
153
   tassert(msg->header(resip::h_RequestLine).uri().exists(p_unknownparam));
 
154
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
155
   
 
156
   //To
 
157
   tassert(msg->exists(resip::h_To));
 
158
   tassert(msg->header(resip::h_To).displayName().empty());
 
159
   tassert(msg->header(resip::h_To).numKnownParams()==1);
 
160
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
161
   tassert(msg->header(resip::h_To).exists(resip::p_tag));
 
162
   tassert(msg->header(resip::h_To).param(resip::p_tag)=="1918181833n");
 
163
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
164
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
165
   tassert(msg->header(resip::h_To).uri().user()=="vivekg");
 
166
   tassert(msg->header(resip::h_To).uri().host()=="chair-dnrc.example.com");
 
167
   tassert(msg->header(resip::h_To).uri().port()==0);
 
168
   tassert(msg->header(resip::h_To).uri().password().empty());
 
169
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
170
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
171
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
172
 
 
173
   //From
 
174
   tassert(msg->exists(resip::h_From));
 
175
   tassert(msg->header(resip::h_From).displayName()=="J Rosenberg \\\\\\\"");
 
176
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
177
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
178
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
179
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="98asjd8");
 
180
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
181
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
182
   tassert(msg->header(resip::h_From).uri().user()=="jdrosen");
 
183
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
184
   tassert(msg->header(resip::h_From).uri().port()==0);
 
185
   tassert(msg->header(resip::h_From).uri().password().empty());
 
186
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
187
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
188
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
189
   
 
190
   //Max-Forwards
 
191
   tassert(msg->exists(resip::h_MaxForwards));
 
192
   tassert(msg->header(resip::h_MaxForwards).value()==68);
 
193
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
194
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
195
   
 
196
   
 
197
   //Call-ID
 
198
   tassert(msg->exists(resip::h_CallID));
 
199
   tassert(msg->header(resip::h_CallID).value()=="wsinv.ndaksdj@192.0.2.1");
 
200
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
201
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
202
   
 
203
   //Content-Length
 
204
   tassert(msg->exists(resip::h_ContentLength));
 
205
   tassert(msg->header(resip::h_ContentLength).value()==150);
 
206
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
207
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
208
   
 
209
   //CSeq
 
210
   tassert(msg->exists(resip::h_CSeq));
 
211
   tassert(msg->header(resip::h_CSeq).method()==resip::INVITE);
 
212
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="INVITE");
 
213
   tassert(msg->header(resip::h_CSeq).sequence()==9);
 
214
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
215
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
216
   
 
217
   //Vias
 
218
   tassert(msg->exists(resip::h_Vias));
 
219
   tassert(msg->header(resip::h_Vias).size()==3);
 
220
   resip::ParserContainer<resip::Via>::iterator i=msg->header(resip::h_Vias).begin();
 
221
   
 
222
   tassert(i->numKnownParams()==1);
 
223
   tassert(i->numUnknownParams()==0);
 
224
   tassert(i->protocolName()=="SIP");
 
225
   tassert(i->protocolVersion()=="2.0");
 
226
   tassert(i->transport()=="UDP");
 
227
   tassert(i->sentHost()=="192.0.2.2");
 
228
   tassert(i->sentPort()==0);
 
229
   
 
230
   tassert(i->exists(resip::p_branch));
 
231
   tassert(!(i->param(resip::p_branch).hasMagicCookie()));
 
232
   tassert(i->param(resip::p_branch).getTransactionId()=="390skdjuw");
 
233
   tassert(i->param(resip::p_branch).clientData().empty());
 
234
   
 
235
   i++;
 
236
   
 
237
   tassert(i->numKnownParams()==1);
 
238
   tassert(i->numUnknownParams()==0);
 
239
   tassert(i->protocolName()=="SIP");
 
240
   tassert(i->protocolVersion()=="2.0");
 
241
   tassert(i->transport()=="TCP");
 
242
   tassert(i->sentHost()=="spindle.example.com");
 
243
   tassert(i->sentPort()==0);
 
244
   
 
245
   tassert(i->exists(resip::p_branch));
 
246
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
247
   tassert(i->param(resip::p_branch).getTransactionId()=="9ikj8");
 
248
   tassert(i->param(resip::p_branch).clientData().empty());
 
249
      
 
250
   i++;
 
251
   
 
252
   tassert(i->numKnownParams()==1);
 
253
   tassert(i->numUnknownParams()==0);
 
254
   tassert(i->protocolName()=="SIP");
 
255
   tassert(i->protocolVersion()=="2.0");
 
256
   tassert(i->transport()=="UDP");
 
257
   tassert(i->sentHost()=="192.168.255.111");
 
258
   tassert(i->sentPort()==0);
 
259
   
 
260
   tassert(i->exists(resip::p_branch));
 
261
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
262
   tassert(i->param(resip::p_branch).getTransactionId()=="30239");
 
263
   tassert(i->param(resip::p_branch).clientData().empty());
 
264
   
 
265
   
 
266
   //Subject
 
267
   tassert(msg->exists(resip::h_Subject));
 
268
   tassert(msg->header(resip::h_Subject).value()=="");
 
269
   tassert(msg->header(resip::h_Subject).numKnownParams()==0);
 
270
   tassert(msg->header(resip::h_Subject).numUnknownParams()==0);
 
271
   
 
272
 
 
273
   // Unknown headers
 
274
   resip::ExtensionHeader h_NewFangledHeader("NewFangledHeader");
 
275
   
 
276
   tassert(msg->exists(h_NewFangledHeader));
 
277
   tassert(msg->header(h_NewFangledHeader).size()==1);
 
278
   tassert(msg->header(h_NewFangledHeader).begin()->value()=="newfangled value\r\n continued newfangled value");
 
279
   tassert(msg->header(h_NewFangledHeader).begin()->numKnownParams()==0);
 
280
   tassert(msg->header(h_NewFangledHeader).begin()->numUnknownParams()==0);
 
281
   
 
282
   resip::ExtensionHeader h_UnknownHeaderWithUnusualValue("UnknownHeaderWithUnusualValue");
 
283
   
 
284
   tassert(msg->exists(h_UnknownHeaderWithUnusualValue));
 
285
   tassert(msg->header(h_UnknownHeaderWithUnusualValue).size()==1);
 
286
   tassert(msg->header(h_UnknownHeaderWithUnusualValue).begin()->value()==";;,,;;,;");
 
287
   tassert(msg->header(h_UnknownHeaderWithUnusualValue).begin()->numKnownParams()==0);
 
288
   tassert(msg->header(h_UnknownHeaderWithUnusualValue).begin()->numUnknownParams()==0);
 
289
   
 
290
   //Content-Type
 
291
   tassert(msg->exists(resip::h_ContentType));
 
292
   tassert(msg->header(resip::h_ContentType).type()=="application");
 
293
   tassert(msg->header(resip::h_ContentType).subType()=="sdp");
 
294
   tassert(msg->header(resip::h_ContentType).numKnownParams()==0);
 
295
   tassert(msg->header(resip::h_ContentType).numUnknownParams()==0);
 
296
   
 
297
   //Contact
 
298
   tassert(msg->exists(resip::h_Contacts));
 
299
   tassert(msg->header(resip::h_Contacts).size()==1);
 
300
   tassert(msg->header(resip::h_Contacts).begin()->displayName()=="Quoted string \\\"\\\"");
 
301
   tassert(msg->header(resip::h_Contacts).begin()->numKnownParams()==1);
 
302
   tassert(msg->header(resip::h_Contacts).begin()->numUnknownParams()==2);
 
303
   tassert(!(msg->header(resip::h_Contacts).begin()->isAllContacts()));
 
304
   tassert(msg->header(resip::h_Contacts).begin()->uri().numKnownParams()==0);
 
305
   tassert(msg->header(resip::h_Contacts).begin()->uri().numUnknownParams()==0);
 
306
   tassert(msg->header(resip::h_Contacts).begin()->uri().scheme()=="sip");
 
307
   tassert(msg->header(resip::h_Contacts).begin()->uri().user()=="jdrosen");
 
308
   tassert(msg->header(resip::h_Contacts).begin()->uri().host()=="example.com");
 
309
   tassert(msg->header(resip::h_Contacts).begin()->uri().port()==0);
 
310
   tassert(msg->header(resip::h_Contacts).begin()->uri().password().empty());
 
311
   tassert(!(msg->header(resip::h_Contacts).begin()->uri().hasEmbedded()));
 
312
 
 
313
   resip::ExtensionParameter p_newparam("newparam");
 
314
   tassert(msg->header(resip::h_Contacts).begin()->exists(p_newparam));
 
315
   tassert(msg->header(resip::h_Contacts).begin()->param(p_newparam)=="newvalue");
 
316
   
 
317
   resip::ExtensionParameter p_secondparam("secondparam");
 
318
   tassert(msg->header(resip::h_Contacts).begin()->exists(p_secondparam));
 
319
   tassert(msg->header(resip::h_Contacts).begin()->param(p_secondparam)=="");
 
320
   
 
321
   tassert(msg->header(resip::h_Contacts).begin()->exists(resip::p_q));
 
322
   tassert(msg->header(resip::h_Contacts).begin()->param(resip::p_q)==330);
 
323
   
 
324
   
 
325
   
 
326
   
 
327
 
 
328
   InfoLog(<< "In case wsinv:" );
 
329
   InfoLog(<< "Original text:" << std::endl << txt );
 
330
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
331
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
332
 
 
333
 
 
334
 
 
335
 
 
336
}
 
337
 
 
338
 
 
339
void
 
340
intmeth()
 
341
{
 
342
#if 0
 
343
/*
 
344
   This message exercises a wider range of characters in several key
 
345
   syntactic elements than implementations usually see.  In particular,
 
346
   note the following:
 
347
 
 
348
   o  The Method contains non-alpha characters from token.  Note that %
 
349
      is not an escape character for this field.  A method of IN%56ITE
 
350
      is an unknown method.  It is not the same as a method of INVITE.
 
351
 
 
352
   o  The Request-URI contains unusual, but legal, characters.
 
353
 
 
354
   o  A branch parameter contains all non-alphanum characters from
 
355
      token.
 
356
 
 
357
   o  The To header field value's quoted string contains quoted-pair
 
358
      expansions, including a quoted NULL character.
 
359
 
 
360
   o  The name part of name-addr in the From header field value contains
 
361
      multiple tokens (instead of a quoted string) with all non-alphanum
 
362
      characters from the token production rule.  That value also has an
 
363
      unknown header parameter whose name contains the non-alphanum
 
364
      token characters and whose value is a non-ascii range UTF-8
 
365
      encoded string.  The tag parameter on this value contains the
 
366
      non-alphanum token characters.
 
367
 
 
368
   o  The Call-ID header field value contains the non-alphanum
 
369
      characters from word.  Notice that in this production:
 
370
 
 
371
      *  % is not an escape character.  It is only an escape character
 
372
         in productions matching the rule "escaped".
 
373
 
 
374
      *  " does not start a quoted string.  None of ',` or " imply that
 
375
         there will be a matching symbol later in the string.
 
376
 
 
377
      *  The characters []{}()<> do not have any grouping semantics.
 
378
         They are not required to appear in balanced pairs.
 
379
 
 
380
   o  There is an unknown header field (matching extension-header) with
 
381
      non-alphanum token characters in its name and a UTF8-NONASCII
 
382
      value.
 
383
 
 
384
   If this unusual URI has been defined at a proxy, the proxy will
 
385
   forward this request normally.  Otherwise, a proxy will generate a
 
386
   404.  Endpoints will generate a 501 listing the methods they
 
387
   understand in an Allow header field.
 
388
 
 
389
 
 
390
!interesting-Method0123456789_*+`.%indeed'~ sip:1_unusual.URI~(to-be!sure)&isn't+it$/crazy?,/;;*:&it+has=1,weird!*pas$wo~d_too.(doesn't-it)@example.com SIP/2.0
 
391
Via: SIP/2.0/TCP host1.example.com;branch=z9hG4bK-.!%66*_+`'~
 
392
To: "BEL:\ NUL:\ DEL:\" <sip:1_unusual.URI~(to-be!sure)&isn't+it$/crazy?,/;;*@example.com>
 
393
From: token1~` token2'+_ token3*%!.- <sip:mundane@example.com>;fromParam''~+*_!.-%="рŠ°Š±Š¾Ń‚Š°ŃŽŃ‰ŠøŠ¹";tag=_token~1'+`*%!-.
 
394
Call-ID: intmeth.word%ZK-!.*_+'@word`~)(><:\/"][?}{
 
395
CSeq: 139122385 !interesting-Method0123456789_*+`.%indeed'~
 
396
Max-Forwards: 255
 
397
extensionHeader-!.%*+_`'~:ļ»æ大停電
 
398
Content-Length: 0
 
399
 
 
400
 
 
401
*/
 
402
#endif
 
403
 
 
404
   FILE* fid= fopen("intmeth.dat","r");
 
405
   tassert(fid);
 
406
   resip::Data txt;
 
407
   char mBuf[1024];
 
408
   int result;
 
409
   while(!feof(fid))
 
410
   {
 
411
      result = fread(&mBuf,1,1024,fid);
 
412
      txt += resip::Data(mBuf,result);
 
413
   }
 
414
   fclose(fid);
 
415
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
416
   tassert_reset();
 
417
   tassert(msg);
 
418
   tassert_reset();
 
419
   if(!msg)
 
420
   {
 
421
      return;
 
422
   }
 
423
 
 
424
   std::auto_ptr<resip::SipMessage> message(msg);
 
425
   msg->parseAllHeaders();
 
426
 
 
427
   resip::SipMessage copy(*msg);
 
428
 
 
429
   resip::Data encoded;
 
430
   {
 
431
      resip::oDataStream str(encoded);
 
432
      msg->encode(str);
 
433
   }
 
434
   resip::Data copyEncoded;
 
435
   {
 
436
      resip::oDataStream str(copyEncoded);
 
437
      copy.encode(str);
 
438
   }
 
439
 
 
440
   // Request Line
 
441
   tassert(msg->header(resip::h_RequestLine).method()==resip::UNKNOWN);
 
442
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="!interesting-Method0123456789_*+`.%indeed'~");
 
443
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
444
   tassert(msg->header(resip::h_RequestLine).uri().user()=="1_unusual.URI~(to-be!sure)&isn't+it$/crazy?,/;;*");
 
445
   tassert(msg->header(resip::h_RequestLine).uri().password()=="&it+has=1,weird!*pas$wo~d_too.(doesn't-it)");
 
446
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.com");
 
447
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
448
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
449
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
450
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
451
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
452
   
 
453
   //To
 
454
   tassert(msg->exists(resip::h_To));
 
455
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
456
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
457
   resip::Data dispName;
 
458
   dispName+="BEL:\\";
 
459
   dispName+=(char)0x07;
 
460
   dispName+=" NUL:\\";
 
461
   dispName+=(char)0x00;
 
462
   dispName+=" DEL:\\";
 
463
   dispName+=(char)0x7F;   
 
464
   tassert(msg->header(resip::h_To).displayName()==dispName);
 
465
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
466
 
 
467
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
468
   tassert(msg->header(resip::h_To).uri().user()=="1_unusual.URI~(to-be!sure)&isn't+it$/crazy?,/;;*");
 
469
   tassert(msg->header(resip::h_To).uri().password().empty());
 
470
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
471
   tassert(msg->header(resip::h_To).uri().port()==0);
 
472
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
473
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
474
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
475
 
 
476
   //From
 
477
   tassert(msg->exists(resip::h_From));
 
478
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
479
   tassert(msg->header(resip::h_From).numUnknownParams()==1);
 
480
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
481
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="_token~1'+`*%!-.");
 
482
   
 
483
   resip::ExtensionParameter p_oddball("fromParam''~+*_!.-%");
 
484
   tassert(msg->header(resip::h_From).exists(p_oddball));
 
485
   resip::Data binaryParamVal;
 
486
   binaryParamVal+=(char)0xD1;
 
487
   binaryParamVal+=(char)0x80;
 
488
   binaryParamVal+=(char)0xD0;
 
489
   binaryParamVal+=(char)0xB0;
 
490
   binaryParamVal+=(char)0xD0;
 
491
   binaryParamVal+=(char)0xB1;
 
492
   binaryParamVal+=(char)0xD0;
 
493
   binaryParamVal+=(char)0xBE;
 
494
   binaryParamVal+=(char)0xD1;
 
495
   binaryParamVal+=(char)0x82;
 
496
   binaryParamVal+=(char)0xD0;
 
497
   binaryParamVal+=(char)0xB0;
 
498
   binaryParamVal+=(char)0xD1;
 
499
   binaryParamVal+=(char)0x8E;
 
500
   binaryParamVal+=(char)0xD1;
 
501
   binaryParamVal+=(char)0x89;
 
502
   binaryParamVal+=(char)0xD0;
 
503
   binaryParamVal+=(char)0xB8;
 
504
   binaryParamVal+=(char)0xD0;
 
505
   binaryParamVal+=(char)0xB9;
 
506
   tassert(msg->header(resip::h_From).param(p_oddball)==binaryParamVal);
 
507
   tassert(msg->header(resip::h_From).displayName()=="token1~` token2'+_ token3*%!.-");
 
508
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
509
 
 
510
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
511
   tassert(msg->header(resip::h_From).uri().user()=="mundane");
 
512
   tassert(msg->header(resip::h_From).uri().password().empty());
 
513
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
514
   tassert(msg->header(resip::h_From).uri().port()==0);
 
515
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
516
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
517
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
518
   
 
519
   
 
520
   //Max-Forwards
 
521
   tassert(msg->exists(resip::h_MaxForwards));
 
522
   tassert(msg->header(resip::h_MaxForwards).value()==255);
 
523
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
524
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
525
   
 
526
   //Call-ID
 
527
   tassert(msg->exists(resip::h_CallID));
 
528
   tassert(msg->header(resip::h_CallID).value()=="intmeth.word%ZK-!.*_+'@word`~)(><:\\/\"][?}{");
 
529
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
530
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
531
   
 
532
   //Content-Length
 
533
   tassert(msg->exists(resip::h_ContentLength));
 
534
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
535
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
536
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
537
   
 
538
   //CSeq
 
539
   tassert(msg->exists(resip::h_CSeq));
 
540
   tassert(msg->header(resip::h_CSeq).method()==resip::UNKNOWN);
 
541
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="!interesting-Method0123456789_*+`.%indeed'~");
 
542
   tassert(msg->header(resip::h_CSeq).sequence()==139122385);
 
543
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
544
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
545
   
 
546
   //Vias
 
547
   tassert(msg->exists(resip::h_Vias));
 
548
   tassert(msg->header(resip::h_Vias).size()==1);
 
549
   resip::ParserContainer<resip::Via>::iterator i=msg->header(resip::h_Vias).begin();
 
550
   
 
551
   tassert(i->protocolName()=="SIP");
 
552
   tassert(i->protocolVersion()=="2.0");
 
553
   tassert(i->transport()=="TCP");
 
554
   tassert(i->sentHost()=="host1.example.com");
 
555
   tassert(i->sentPort()==0);
 
556
   
 
557
   tassert(i->numKnownParams()==1);
 
558
   tassert(i->numUnknownParams()==0);
 
559
   tassert(i->exists(resip::p_branch));
 
560
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
561
   tassert(i->param(resip::p_branch).getTransactionId()=="-.!%66*_+`'~");
 
562
   tassert(i->param(resip::p_branch).clientData().empty());
 
563
   
 
564
 
 
565
   
 
566
   // Unknown headers
 
567
   resip::ExtensionHeader h_extensionHeader("extensionHeader-!.%*+_`'~");
 
568
   
 
569
   tassert(msg->exists(h_extensionHeader));
 
570
   tassert(msg->header(h_extensionHeader).size()==1);
 
571
   resip::Data binaryHfv;
 
572
   binaryHfv+=(char)0xEF;
 
573
   binaryHfv+=(char)0xBB;
 
574
   binaryHfv+=(char)0xBF;
 
575
   binaryHfv+=(char)0xE5;
 
576
   binaryHfv+=(char)0xA4;
 
577
   binaryHfv+=(char)0xA7;
 
578
   binaryHfv+=(char)0xE5;
 
579
   binaryHfv+=(char)0x81;
 
580
   binaryHfv+=(char)0x9C;
 
581
   binaryHfv+=(char)0xE9;
 
582
   binaryHfv+=(char)0x9B;
 
583
   binaryHfv+=(char)0xBB;
 
584
   tassert(msg->header(h_extensionHeader).begin()->value()==binaryHfv);
 
585
   tassert(msg->header(h_extensionHeader).begin()->numKnownParams()==0);
 
586
   tassert(msg->header(h_extensionHeader).begin()->numUnknownParams()==0);
 
587
   
 
588
   
 
589
   InfoLog(<< "In case intmeth:" );
 
590
   InfoLog(<< "Original text:" << std::endl << txt );
 
591
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
592
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
593
 
 
594
 
 
595
 
 
596
 
 
597
}
 
598
 
 
599
 
 
600
void
 
601
esc01()
 
602
{
 
603
/*
 
604
   This INVITE exercises the % HEX HEX escaping mechanism in several
 
605
   places.  The request is syntactically valid.  Interesting features
 
606
   include the following:
 
607
 
 
608
   o  The request-URI has sips:user@example.com embedded in its
 
609
      userpart.  What that might mean to example.net is beyond the scope
 
610
      of this document.
 
611
 
 
612
   o  The From and To URIs have escaped characters in their userparts.
 
613
 
 
614
   o  The Contact URI has escaped characters in the URI parameters.
 
615
      Note that the "name" uri-parameter has a value of "value%41",
 
616
      which is NOT equivalent to "valueA".  Per [RFC3986], unescaping
 
617
      URI components is never performed recursively.
 
618
 
 
619
   A parser must accept this as a well-formed message.  The application
 
620
   using the message must treat the % HEX HEX expansions as equivalent
 
621
   to the character being encoded.  The application must not try to
 
622
   interpret % as an escape character in those places where % HEX HEX
 
623
   ("escaped" in the grammar) is not a valid part of the construction.
 
624
   In [RFC3261], "escaped" only occurs in the expansions of SIP-URI,
 
625
   SIPS-URI, and Reason-Phrase.
 
626
   
 
627
   
 
628
INVITE sip:sips%3Auser%40example.com@example.net SIP/2.0
 
629
To: sip:%75se%72@example.com
 
630
From: <sip:I%20have%20spaces@example.net>;tag=938
 
631
Max-Forwards: 87
 
632
i: esc01.239409asdfakjkn23onasd0-3234
 
633
CSeq: 234234 INVITE
 
634
Via: SIP/2.0/UDP host5.example.net;branch=z9hG4bKkdjuw
 
635
C: application/sdp
 
636
Contact:
 
637
  <sip:cal%6Cer@host5.example.net;%6C%72;n%61me=v%61lue%25%34%31>
 
638
Content-Length: 150
 
639
 
 
640
v=0
 
641
o=mhandley 29739 7272939 IN IP4 192.0.2.1
 
642
s=-
 
643
c=IN IP4 192.0.2.1
 
644
t=0 0
 
645
m=audio 49217 RTP/AVP 0 12
 
646
m=video 3227 RTP/AVP 31
 
647
a=rtpmap:31 LPC
 
648
 
 
649
*/
 
650
   FILE* fid= fopen("esc01.dat","r");
 
651
   tassert(fid);
 
652
   resip::Data txt;
 
653
   char mBuf[1024];
 
654
   int result;
 
655
   while(!feof(fid))
 
656
   {
 
657
      result = fread(&mBuf,1,1024,fid);
 
658
      txt += resip::Data(mBuf,result);
 
659
   }
 
660
   fclose(fid);
 
661
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
662
   tassert_reset();
 
663
   tassert(msg);
 
664
   tassert_reset();
 
665
   if(!msg)
 
666
   {
 
667
      return;
 
668
   }
 
669
 
 
670
   std::auto_ptr<resip::SipMessage> message(msg);
 
671
   msg->parseAllHeaders();
 
672
 
 
673
   resip::SipMessage copy(*msg);
 
674
 
 
675
   resip::Data encoded;
 
676
   {
 
677
      resip::oDataStream str(encoded);
 
678
      msg->encode(str);
 
679
   }
 
680
   resip::Data copyEncoded;
 
681
   {
 
682
      resip::oDataStream str(copyEncoded);
 
683
      copy.encode(str);
 
684
   }
 
685
 
 
686
   // Request Line
 
687
   tassert(msg->header(resip::h_RequestLine).method()==resip::INVITE);
 
688
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="INVITE");
 
689
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
690
   // ?bwc? Is it appropriate to use a one-size-fits-all approach to unescaping
 
691
   // parsed components? ('@' is not legal in a userpart, but the internal
 
692
   // representation contains it)
 
693
   // What is the best approach: all (unescape everything that is printable),
 
694
   // none (leave escaping exactly as found), or context sensitive (escape
 
695
   // everything that is legal for a given field)?
 
696
   tassert(msg->header(resip::h_RequestLine).uri().user()=="sips%3Auser%40example.com");
 
697
   tassert_reset();
 
698
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
699
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.net");
 
700
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
701
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
702
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
703
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
704
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
705
   
 
706
   //To
 
707
   tassert(msg->exists(resip::h_To));
 
708
   tassert(msg->header(resip::h_To).displayName().empty());
 
709
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
710
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
711
   tassert(msg->header(resip::h_To).uri().user()=="user");
 
712
   tassert(msg->header(resip::h_To).uri().password().empty());
 
713
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
714
   tassert(msg->header(resip::h_To).uri().port()==0);
 
715
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
716
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
717
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
718
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
719
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
720
 
 
721
   //From
 
722
   tassert(msg->exists(resip::h_From));
 
723
   tassert(msg->header(resip::h_From).displayName().empty());
 
724
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
725
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
726
   // ?bwc? ' ' is not legal in a userpart, but the internal
 
727
   // representation contains it. Is this appropriate?
 
728
   tassert(msg->header(resip::h_From).uri().user()=="I%20have%20spaces");
 
729
   tassert_reset();
 
730
   tassert(msg->header(resip::h_From).uri().password().empty());
 
731
   tassert(msg->header(resip::h_From).uri().host()=="example.net");
 
732
   tassert(msg->header(resip::h_From).uri().port()==0);
 
733
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
734
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
735
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
736
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
737
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
738
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
739
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="938");
 
740
   
 
741
   //Max-Forwards
 
742
   tassert(msg->exists(resip::h_MaxForwards));
 
743
   tassert(msg->header(resip::h_MaxForwards).value()==87);
 
744
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
745
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
746
   
 
747
   //Call-ID
 
748
   tassert(msg->exists(resip::h_CallID));
 
749
   tassert(msg->header(resip::h_CallID).value()=="esc01.239409asdfakjkn23onasd0-3234");
 
750
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
751
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
752
   
 
753
   //Content-Length
 
754
   tassert(msg->exists(resip::h_ContentLength));
 
755
   tassert(msg->header(resip::h_ContentLength).value()==150);
 
756
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
757
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
758
   
 
759
   //CSeq
 
760
   tassert(msg->exists(resip::h_CSeq));
 
761
   tassert(msg->header(resip::h_CSeq).method()==resip::INVITE);
 
762
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="INVITE");
 
763
   tassert(msg->header(resip::h_CSeq).sequence()==234234);
 
764
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
765
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
766
   
 
767
   //Vias
 
768
   tassert(msg->exists(resip::h_Vias));
 
769
   tassert(msg->header(resip::h_Vias).size()==1);
 
770
   resip::ParserContainer<resip::Via>::iterator i=msg->header(resip::h_Vias).begin();
 
771
   
 
772
   tassert(i->protocolName()=="SIP");
 
773
   tassert(i->protocolVersion()=="2.0");
 
774
   tassert(i->transport()=="UDP");
 
775
   tassert(i->sentHost()=="host5.example.net");
 
776
   tassert(i->sentPort()==0);
 
777
   
 
778
   tassert(i->numKnownParams()==1);
 
779
   tassert(i->numUnknownParams()==0);
 
780
 
 
781
   tassert(i->exists(resip::p_branch));
 
782
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
783
   tassert(i->param(resip::p_branch).getTransactionId()=="kdjuw");
 
784
   tassert(i->param(resip::p_branch).clientData().empty());
 
785
   
 
786
   
 
787
   
 
788
   //Content-Type
 
789
   tassert(msg->exists(resip::h_ContentType));
 
790
   tassert(msg->header(resip::h_ContentType).type()=="application");
 
791
   tassert(msg->header(resip::h_ContentType).subType()=="sdp");
 
792
   tassert(msg->header(resip::h_ContentType).numKnownParams()==0);
 
793
   tassert(msg->header(resip::h_ContentType).numUnknownParams()==0);
 
794
   
 
795
   //Contact
 
796
   tassert(msg->exists(resip::h_Contacts));
 
797
   tassert(msg->header(resip::h_Contacts).size()==1);
 
798
   tassert(msg->header(resip::h_Contacts).begin()->displayName().empty());
 
799
   tassert(!(msg->header(resip::h_Contacts).begin()->isAllContacts()));
 
800
   tassert(msg->header(resip::h_Contacts).begin()->uri().scheme()=="sip");
 
801
   tassert(msg->header(resip::h_Contacts).begin()->uri().user()=="caller");
 
802
   tassert(msg->header(resip::h_Contacts).begin()->uri().password().empty());
 
803
   tassert(msg->header(resip::h_Contacts).begin()->uri().host()=="host5.example.net");
 
804
   tassert(msg->header(resip::h_Contacts).begin()->uri().port()==0);
 
805
   tassert(!(msg->header(resip::h_Contacts).begin()->uri().hasEmbedded()));
 
806
 
 
807
   tassert(msg->header(resip::h_Contacts).begin()->uri().numKnownParams()==0);
 
808
   tassert(msg->header(resip::h_Contacts).begin()->uri().numUnknownParams()==2);
 
809
 
 
810
   // ?bwc? These params have escaped stuff in them; is it mandatory that we
 
811
   // treat escaped and unescaped versions of the same parameter as identical?
 
812
   
 
813
   resip::ExtensionParameter p_wonky1("%6C%72");
 
814
   resip::ExtensionParameter p_wonky2("n%61me");
 
815
   tassert(msg->header(resip::h_Contacts).begin()->uri().exists(p_wonky1));
 
816
   tassert(msg->header(resip::h_Contacts).begin()->uri().param(p_wonky1)=="");
 
817
   tassert(msg->header(resip::h_Contacts).begin()->uri().exists(p_wonky2));
 
818
   tassert(msg->header(resip::h_Contacts).begin()->uri().param(p_wonky2)=="v%61lue%25%34%31");
 
819
 
 
820
 
 
821
   tassert(msg->header(resip::h_Contacts).begin()->numKnownParams()==0);
 
822
   tassert(msg->header(resip::h_Contacts).begin()->numUnknownParams()==0);
 
823
 
 
824
   tassert_reset();
 
825
 
 
826
   InfoLog(<< "In case esc01:" );
 
827
   InfoLog(<< "Original text:" << std::endl << txt );
 
828
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
829
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
830
 
 
831
 
 
832
 
 
833
 
 
834
}
 
835
 
 
836
 
 
837
void
 
838
escnull()
 
839
{
 
840
/*
 
841
   This register request contains several URIs with nulls in the
 
842
   userpart.  The message is well formed - parsers must accept this
 
843
   message.  Implementations must take special care when unescaping the
 
844
   Address-of-Record (AOR) in this request so as to not prematurely
 
845
   shorten the username.  This request registers two distinct contact
 
846
   URIs.
 
847
 
 
848
REGISTER sip:example.com SIP/2.0
 
849
To: sip:null-%00-null@example.com
 
850
From: sip:null-%00-null@example.com;tag=839923423
 
851
Max-Forwards: 70
 
852
Call-ID: escnull.39203ndfvkjdasfkq3w4otrq0adsfdfnavd
 
853
CSeq: 14398234 REGISTER
 
854
Via: SIP/2.0/UDP host5.example.com;branch=z9hG4bKkdjuw
 
855
Contact: <sip:%00@host5.example.com>
 
856
Contact: <sip:%00%00@host5.example.com>
 
857
L:0
 
858
 
 
859
 
 
860
*/
 
861
   FILE* fid= fopen("escnull.dat","r");
 
862
   tassert(fid);
 
863
   resip::Data txt;
 
864
   char mBuf[1024];
 
865
   int result;
 
866
   while(!feof(fid))
 
867
   {
 
868
      result = fread(&mBuf,1,1024,fid);
 
869
      txt += resip::Data(mBuf,result);
 
870
   }
 
871
   fclose(fid);
 
872
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
873
   tassert_reset();
 
874
   tassert(msg);
 
875
   tassert_reset();
 
876
   if(!msg)
 
877
   {
 
878
      return;
 
879
   }
 
880
 
 
881
   std::auto_ptr<resip::SipMessage> message(msg);
 
882
   msg->parseAllHeaders();
 
883
 
 
884
   resip::SipMessage copy(*msg);
 
885
 
 
886
   resip::Data encoded;
 
887
   {
 
888
      resip::oDataStream str(encoded);
 
889
      msg->encode(str);
 
890
   }
 
891
   resip::Data copyEncoded;
 
892
   {
 
893
      resip::oDataStream str(copyEncoded);
 
894
      copy.encode(str);
 
895
   }
 
896
 
 
897
   // Request Line
 
898
   //REGISTER sip:example.com SIP/2.0
 
899
   tassert(msg->header(resip::h_RequestLine).method()==resip::REGISTER);
 
900
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="REGISTER");
 
901
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
902
   tassert(msg->header(resip::h_RequestLine).uri().user()=="");
 
903
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
904
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.com");
 
905
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
906
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
907
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
908
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
909
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
910
   
 
911
   //To: sip:null-%00-null@example.com
 
912
   tassert(msg->exists(resip::h_To));
 
913
   tassert(msg->header(resip::h_To).displayName().empty());
 
914
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
915
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
916
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
917
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
918
   tassert(msg->header(resip::h_To).uri().user()=="null-%00-null");
 
919
   tassert(msg->header(resip::h_To).uri().password().empty());
 
920
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
921
   tassert(msg->header(resip::h_To).uri().port()==0);
 
922
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
923
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
924
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
925
 
 
926
   //From: sip:null-%00-null@example.com;tag=839923423
 
927
   tassert(msg->exists(resip::h_From));
 
928
   tassert(msg->header(resip::h_From).displayName()=="");
 
929
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
930
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
931
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
932
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="839923423");
 
933
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
934
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
935
   tassert(msg->header(resip::h_From).uri().user()=="null-%00-null");
 
936
   tassert(msg->header(resip::h_From).uri().password().empty());
 
937
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
938
   tassert(msg->header(resip::h_From).uri().port()==0);
 
939
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
940
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
941
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
942
   
 
943
   //Max-Forwards: 70
 
944
   tassert(msg->exists(resip::h_MaxForwards));
 
945
   tassert(msg->header(resip::h_MaxForwards).value()==70);
 
946
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
947
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
948
   
 
949
   
 
950
   //Call-ID: escnull.39203ndfvkjdasfkq3w4otrq0adsfdfnavd
 
951
   tassert(msg->exists(resip::h_CallID));
 
952
   tassert(msg->header(resip::h_CallID).value()=="escnull.39203ndfvkjdasfkq3w4otrq0adsfdfnavd");
 
953
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
954
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
955
   
 
956
   //CSeq: 14398234 REGISTER
 
957
   tassert(msg->exists(resip::h_CSeq));
 
958
   tassert(msg->header(resip::h_CSeq).method()==resip::REGISTER);
 
959
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="REGISTER");
 
960
   tassert(msg->header(resip::h_CSeq).sequence()==14398234);
 
961
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
962
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
963
   
 
964
   //Via: SIP/2.0/UDP host5.example.com;branch=z9hG4bKkdjuw
 
965
   tassert(msg->exists(resip::h_Vias));
 
966
   tassert(msg->header(resip::h_Vias).size()==1);
 
967
   resip::ParserContainer<resip::Via>::iterator i=msg->header(resip::h_Vias).begin();
 
968
   
 
969
   tassert(i->numKnownParams()==1);
 
970
   tassert(i->numUnknownParams()==0);
 
971
   tassert(i->protocolName()=="SIP");
 
972
   tassert(i->protocolVersion()=="2.0");
 
973
   tassert(i->transport()=="UDP");
 
974
   tassert(i->sentHost()=="host5.example.com");
 
975
   tassert(i->sentPort()==0);
 
976
   
 
977
   tassert(i->exists(resip::p_branch));
 
978
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
979
   tassert(i->param(resip::p_branch).getTransactionId()=="kdjuw");
 
980
   tassert(i->param(resip::p_branch).clientData().empty());
 
981
      
 
982
   //Contact: <sip:%00@host5.example.com>
 
983
   //Contact: <sip:%00%00@host5.example.com>
 
984
   tassert(msg->exists(resip::h_Contacts));
 
985
   tassert(msg->header(resip::h_Contacts).size()==2);
 
986
   resip::ParserContainer<resip::NameAddr>::iterator j=msg->header(resip::h_Contacts).begin();
 
987
   
 
988
   tassert(j->displayName()=="");
 
989
   tassert(j->numKnownParams()==0);
 
990
   tassert(j->numUnknownParams()==0);
 
991
   tassert(!(j->isAllContacts()));
 
992
   tassert(j->uri().numKnownParams()==0);
 
993
   tassert(j->uri().numUnknownParams()==0);
 
994
   tassert(j->uri().scheme()=="sip");
 
995
   tassert(j->uri().user()=="%00");
 
996
   tassert(j->uri().password().empty());
 
997
   tassert(j->uri().host()=="host5.example.com");
 
998
   tassert(j->uri().port()==0);
 
999
   tassert(!(j->uri().hasEmbedded()));
 
1000
 
 
1001
   j++;
 
1002
   
 
1003
   tassert(j->displayName()=="");
 
1004
   tassert(j->numKnownParams()==0);
 
1005
   tassert(j->numUnknownParams()==0);
 
1006
   tassert(!(j->isAllContacts()));
 
1007
   tassert(j->uri().numKnownParams()==0);
 
1008
   tassert(j->uri().numUnknownParams()==0);
 
1009
   tassert(j->uri().scheme()=="sip");
 
1010
   tassert(j->uri().user()=="%00%00");
 
1011
   tassert(j->uri().password().empty());
 
1012
   tassert(j->uri().host()=="host5.example.com");
 
1013
   tassert(j->uri().port()==0);
 
1014
   tassert(!(j->uri().hasEmbedded()));
 
1015
 
 
1016
   //L:0
 
1017
   tassert(msg->exists(resip::h_ContentLength));
 
1018
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
1019
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
1020
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
1021
   
 
1022
   
 
1023
 
 
1024
 
 
1025
   InfoLog(<< "In case escnull:" );
 
1026
   InfoLog(<< "Original text:" << std::endl << txt );
 
1027
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
1028
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
1029
 
 
1030
 
 
1031
 
 
1032
 
 
1033
}
 
1034
 
 
1035
 
 
1036
void
 
1037
esc02()
 
1038
{
 
1039
/*
 
1040
   In most of the places % can appear in a SIP message, it is not an
 
1041
   escape character.  This can surprise the unwary implementor.  The
 
1042
   following well-formed request has these properties:
 
1043
 
 
1044
   o  The request method is unknown.  It is NOT equivalent to REGISTER.
 
1045
 
 
1046
   o  The display name portion of the To and From header fields is
 
1047
      "%Z%45".  Note that this is not the same as %ZE.
 
1048
 
 
1049
   o  This message has two Contact header field values, not three.
 
1050
      <sip:alias2@host2.example.com> is a C%6Fntact header field value.
 
1051
 
 
1052
   A parser should accept this message as well formed.  A proxy would
 
1053
   forward or reject the message depending on what the Request-URI meant
 
1054
   to it.  An endpoint would reject this message with a 501.
 
1055
 
 
1056
 
 
1057
RE%47IST%45R sip:registrar.example.com SIP/2.0
 
1058
To: "%Z%45" <sip:resource@example.com>
 
1059
From: "%Z%45" <sip:resource@example.com>;tag=f232jadfj23
 
1060
Call-ID: esc02.asdfnqwo34rq23i34jrjasdcnl23nrlknsdf
 
1061
Via: SIP/2.0/TCP host.example.com;branch=z9hG4bK209%fzsnel234
 
1062
CSeq: 29344 RE%47IST%45R
 
1063
Max-Forwards: 70
 
1064
Contact: <sip:alias1@host1.example.com>
 
1065
C%6Fntact: <sip:alias2@host2.example.com>
 
1066
Contact: <sip:alias3@host3.example.com>
 
1067
l: 0
 
1068
 
 
1069
 
 
1070
*/
 
1071
   FILE* fid= fopen("esc02.dat","r");
 
1072
   tassert(fid);
 
1073
   resip::Data txt;
 
1074
   char mBuf[1024];
 
1075
   int result;
 
1076
   while(!feof(fid))
 
1077
   {
 
1078
      result = fread(&mBuf,1,1024,fid);
 
1079
      txt += resip::Data(mBuf,result);
 
1080
   }
 
1081
   fclose(fid);
 
1082
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
1083
   tassert_reset();
 
1084
   tassert(msg);
 
1085
   tassert_reset();
 
1086
   if(!msg)
 
1087
   {
 
1088
      return;
 
1089
   }
 
1090
 
 
1091
   std::auto_ptr<resip::SipMessage> message(msg);
 
1092
   msg->parseAllHeaders();
 
1093
 
 
1094
   resip::SipMessage copy(*msg);
 
1095
 
 
1096
   resip::Data encoded;
 
1097
   {
 
1098
      resip::oDataStream str(encoded);
 
1099
      msg->encode(str);
 
1100
   }
 
1101
   resip::Data copyEncoded;
 
1102
   {
 
1103
      resip::oDataStream str(copyEncoded);
 
1104
      copy.encode(str);
 
1105
   }
 
1106
 
 
1107
   //RE%47IST%45R sip:registrar.example.com SIP/2.0
 
1108
   tassert(msg->header(resip::h_RequestLine).method()==resip::UNKNOWN);
 
1109
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="RE%47IST%45R");
 
1110
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
1111
   tassert(msg->header(resip::h_RequestLine).uri().user()=="");
 
1112
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
1113
   tassert(msg->header(resip::h_RequestLine).uri().host()=="registrar.example.com");
 
1114
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
1115
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
1116
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
1117
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
1118
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
1119
 
 
1120
   //To: "%Z%45" <sip:resource@example.com>
 
1121
   tassert(msg->exists(resip::h_To));
 
1122
   tassert(msg->header(resip::h_To).displayName()=="%Z%45");
 
1123
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
1124
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
1125
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
1126
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
1127
   tassert(msg->header(resip::h_To).uri().user()=="resource");
 
1128
   tassert(msg->header(resip::h_To).uri().password().empty());
 
1129
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
1130
   tassert(msg->header(resip::h_To).uri().port()==0);
 
1131
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
1132
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
1133
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
1134
 
 
1135
   //From: "%Z%45" <sip:resource@example.com>;tag=f232jadfj23
 
1136
   tassert(msg->exists(resip::h_From));
 
1137
   tassert(msg->header(resip::h_From).displayName()=="%Z%45");
 
1138
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
1139
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
1140
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
1141
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="f232jadfj23");
 
1142
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
1143
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
1144
   tassert(msg->header(resip::h_From).uri().user()=="resource");
 
1145
   tassert(msg->header(resip::h_From).uri().password().empty());
 
1146
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
1147
   tassert(msg->header(resip::h_From).uri().port()==0);
 
1148
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
1149
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
1150
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
1151
 
 
1152
   //Call-ID: esc02.asdfnqwo34rq23i34jrjasdcnl23nrlknsdf
 
1153
   tassert(msg->exists(resip::h_CallID));
 
1154
   tassert(msg->header(resip::h_CallID).value()=="esc02.asdfnqwo34rq23i34jrjasdcnl23nrlknsdf");
 
1155
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
1156
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
1157
 
 
1158
   //Via: SIP/2.0/TCP host.example.com;branch=z9hG4bK209%fzsnel234
 
1159
   tassert(msg->exists(resip::h_Vias));
 
1160
   tassert(msg->header(resip::h_Vias).size()==1);
 
1161
   resip::ParserContainer<resip::Via>::iterator i=msg->header(resip::h_Vias).begin();
 
1162
   
 
1163
   tassert(i->numKnownParams()==1);
 
1164
   tassert(i->numUnknownParams()==0);
 
1165
   tassert(i->protocolName()=="SIP");
 
1166
   tassert(i->protocolVersion()=="2.0");
 
1167
   tassert(i->transport()=="TCP");
 
1168
   tassert(i->sentHost()=="host.example.com");
 
1169
   tassert(i->sentPort()==0);
 
1170
   
 
1171
   tassert(i->exists(resip::p_branch));
 
1172
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
1173
   tassert(i->param(resip::p_branch).getTransactionId()=="209%fzsnel234");
 
1174
   tassert(i->param(resip::p_branch).clientData().empty());
 
1175
   
 
1176
   //CSeq: 29344 RE%47IST%45R
 
1177
   tassert(msg->exists(resip::h_CSeq));
 
1178
   tassert(msg->header(resip::h_CSeq).method()==resip::UNKNOWN);
 
1179
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="RE%47IST%45R");
 
1180
   tassert(msg->header(resip::h_CSeq).sequence()==29344);
 
1181
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
1182
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
1183
 
 
1184
   //Max-Forwards: 70
 
1185
   tassert(msg->exists(resip::h_MaxForwards));
 
1186
   tassert(msg->header(resip::h_MaxForwards).value()==70);
 
1187
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
1188
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
1189
 
 
1190
   //Contact: <sip:alias1@host1.example.com>
 
1191
   //Contact: <sip:alias3@host3.example.com>
 
1192
   tassert(msg->exists(resip::h_Contacts));
 
1193
   tassert(msg->header(resip::h_Contacts).size()==2);
 
1194
   resip::ParserContainer<resip::NameAddr>::iterator j=msg->header(resip::h_Contacts).begin();
 
1195
   
 
1196
   tassert(j->displayName()=="");
 
1197
   tassert(j->numKnownParams()==0);
 
1198
   tassert(j->numUnknownParams()==0);
 
1199
   tassert(!(j->isAllContacts()));
 
1200
   tassert(j->uri().numKnownParams()==0);
 
1201
   tassert(j->uri().numUnknownParams()==0);
 
1202
   tassert(j->uri().scheme()=="sip");
 
1203
   tassert(j->uri().user()=="alias1");
 
1204
   tassert(j->uri().password().empty());
 
1205
   tassert(j->uri().host()=="host1.example.com");
 
1206
   tassert(j->uri().port()==0);
 
1207
   tassert(!(j->uri().hasEmbedded()));
 
1208
 
 
1209
   j++;
 
1210
   
 
1211
   tassert(j->displayName()=="");
 
1212
   tassert(j->numKnownParams()==0);
 
1213
   tassert(j->numUnknownParams()==0);
 
1214
   tassert(!(j->isAllContacts()));
 
1215
   tassert(j->uri().numKnownParams()==0);
 
1216
   tassert(j->uri().numUnknownParams()==0);
 
1217
   tassert(j->uri().scheme()=="sip");
 
1218
   tassert(j->uri().user()=="alias3");
 
1219
   tassert(j->uri().password().empty());
 
1220
   tassert(j->uri().host()=="host3.example.com");
 
1221
   tassert(j->uri().port()==0);
 
1222
   tassert(!(j->uri().hasEmbedded()));
 
1223
 
 
1224
   //C%6Fntact: <sip:alias2@host2.example.com>
 
1225
   resip::ExtensionHeader p_fakeContact("C%6Fntact");
 
1226
   tassert(msg->exists(p_fakeContact));
 
1227
   tassert(msg->header(p_fakeContact).size()==1);
 
1228
   tassert(msg->header(p_fakeContact).begin()->value()=="<sip:alias2@host2.example.com>");
 
1229
   
 
1230
   //l: 0
 
1231
   tassert(msg->exists(resip::h_ContentLength));
 
1232
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
1233
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
1234
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
1235
 
 
1236
 
 
1237
   InfoLog(<< "In case esc02:" );
 
1238
   InfoLog(<< "Original text:" << std::endl << txt );
 
1239
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
1240
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
1241
 
 
1242
 
 
1243
 
 
1244
 
 
1245
}
 
1246
 
 
1247
 
 
1248
void
 
1249
lwsdisp()
 
1250
{
 
1251
/*
 
1252
   This OPTIONS request is not valid per the grammar in RFC 3261 since
 
1253
   there is no LWS between the token in the display name and < in the
 
1254
   From header field value.  This has been identified as a specification
 
1255
   bug that will be removed when RFC 3261 is revised.  Elements should
 
1256
   accept this request as well formed.
 
1257
 
 
1258
OPTIONS sip:user@example.com SIP/2.0
 
1259
To: sip:user@example.com
 
1260
From: caller<sip:caller@example.com>;tag=323
 
1261
Max-Forwards: 70
 
1262
Call-ID: lwsdisp.1234abcd@funky.example.com
 
1263
CSeq: 60 OPTIONS
 
1264
Via: SIP/2.0/UDP funky.example.com;branch=z9hG4bKkdjuw
 
1265
l: 0
 
1266
 
 
1267
 
 
1268
*/
 
1269
   FILE* fid= fopen("lwsdisp.dat","r");
 
1270
   tassert(fid);
 
1271
   resip::Data txt;
 
1272
   char mBuf[1024];
 
1273
   int result;
 
1274
   while(!feof(fid))
 
1275
   {
 
1276
      result = fread(&mBuf,1,1024,fid);
 
1277
      txt += resip::Data(mBuf,result);
 
1278
   }
 
1279
   fclose(fid);
 
1280
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
1281
   tassert_reset();
 
1282
   tassert(msg);
 
1283
   tassert_reset();
 
1284
   if(!msg)
 
1285
   {
 
1286
      return;
 
1287
   }
 
1288
 
 
1289
   std::auto_ptr<resip::SipMessage> message(msg);
 
1290
   msg->parseAllHeaders();
 
1291
 
 
1292
   resip::SipMessage copy(*msg);
 
1293
 
 
1294
   resip::Data encoded;
 
1295
   {
 
1296
      resip::oDataStream str(encoded);
 
1297
      msg->encode(str);
 
1298
   }
 
1299
   resip::Data copyEncoded;
 
1300
   {
 
1301
      resip::oDataStream str(copyEncoded);
 
1302
      copy.encode(str);
 
1303
   }
 
1304
 
 
1305
   //Request-Line
 
1306
   //OPTIONS sip:user@example.com SIP/2.0
 
1307
   tassert(msg->header(resip::h_RequestLine).method()==resip::OPTIONS);
 
1308
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="OPTIONS");
 
1309
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
1310
   tassert(msg->header(resip::h_RequestLine).uri().user()=="user");
 
1311
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
1312
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.com");
 
1313
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
1314
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
1315
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
1316
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
1317
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
1318
 
 
1319
   //To: sip:user@example.com
 
1320
   tassert(msg->exists(resip::h_To));
 
1321
   tassert(msg->header(resip::h_To).displayName()=="");
 
1322
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
1323
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
1324
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
1325
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
1326
   tassert(msg->header(resip::h_To).uri().user()=="user");
 
1327
   tassert(msg->header(resip::h_To).uri().password().empty());
 
1328
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
1329
   tassert(msg->header(resip::h_To).uri().port()==0);
 
1330
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
1331
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
1332
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
1333
 
 
1334
   //From: caller<sip:caller@example.com>;tag=323
 
1335
   tassert(msg->exists(resip::h_From));
 
1336
   tassert(msg->header(resip::h_From).displayName()=="caller");
 
1337
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
1338
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
1339
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
1340
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="323");
 
1341
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
1342
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
1343
   tassert(msg->header(resip::h_From).uri().user()=="caller");
 
1344
   tassert(msg->header(resip::h_From).uri().password().empty());
 
1345
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
1346
   tassert(msg->header(resip::h_From).uri().port()==0);
 
1347
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
1348
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
1349
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
1350
 
 
1351
   //Max-Forwards: 70
 
1352
   tassert(msg->exists(resip::h_MaxForwards));
 
1353
   tassert(msg->header(resip::h_MaxForwards).value()==70);
 
1354
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
1355
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
1356
 
 
1357
   //Call-ID: lwsdisp.1234abcd@funky.example.com
 
1358
   tassert(msg->exists(resip::h_CallID));
 
1359
   tassert(msg->header(resip::h_CallID).value()=="lwsdisp.1234abcd@funky.example.com");
 
1360
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
1361
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
1362
 
 
1363
   //CSeq: 60 OPTIONS
 
1364
   tassert(msg->exists(resip::h_CSeq));
 
1365
   tassert(msg->header(resip::h_CSeq).method()==resip::OPTIONS);
 
1366
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="OPTIONS");
 
1367
   tassert(msg->header(resip::h_CSeq).sequence()==60);
 
1368
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
1369
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
1370
 
 
1371
   //Via: SIP/2.0/UDP funky.example.com;branch=z9hG4bKkdjuw
 
1372
   tassert(msg->exists(resip::h_Vias));
 
1373
   tassert(msg->header(resip::h_Vias).size()==1);
 
1374
   resip::ParserContainer<resip::Via>::iterator i=msg->header(resip::h_Vias).begin();
 
1375
   
 
1376
   tassert(i->numKnownParams()==1);
 
1377
   tassert(i->numUnknownParams()==0);
 
1378
   tassert(i->protocolName()=="SIP");
 
1379
   tassert(i->protocolVersion()=="2.0");
 
1380
   tassert(i->transport()=="UDP");
 
1381
   tassert(i->sentHost()=="funky.example.com");
 
1382
   tassert(i->sentPort()==0);
 
1383
   
 
1384
   tassert(i->exists(resip::p_branch));
 
1385
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
1386
   tassert(i->param(resip::p_branch).getTransactionId()=="kdjuw");
 
1387
   tassert(i->param(resip::p_branch).clientData().empty());
 
1388
 
 
1389
   //l: 0
 
1390
   tassert(msg->exists(resip::h_ContentLength));
 
1391
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
1392
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
1393
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
1394
 
 
1395
   InfoLog(<< "In case lwsdisp:" );
 
1396
   InfoLog(<< "Original text:" << std::endl << txt );
 
1397
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
1398
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
1399
 
 
1400
 
 
1401
 
 
1402
 
 
1403
}
 
1404
 
 
1405
 
 
1406
void
 
1407
longreq()
 
1408
{
 
1409
/*
 
1410
   This well-formed request contains header fields with many values and
 
1411
   values that are very long.  Features include the following:
 
1412
 
 
1413
   o  The To header field has a long display name, and long uri
 
1414
      parameter names and values.
 
1415
 
 
1416
   o  The From header field has long header parameter names and values,
 
1417
      in particular, a very long tag.
 
1418
 
 
1419
   o  The Call-ID is one long token.
 
1420
 
 
1421
INVITE sip:user@example.com SIP/2.0
 
1422
To: "I have a user name of extremeextremeextremeextremeextremeextremeextremeextremeextremeextreme proportion"<sip:user@example.com:6000;unknownparam1=verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongvalue;longparamnamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamename=shortvalue;verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongParameterNameWithNoValue>
 
1423
F: sip:amazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallername@example.net;tag=12982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982424;unknownheaderparamnamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamename=unknowheaderparamvaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevalue;unknownValuelessparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamname
 
1424
Call-ID: longreq.onereallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongcallid
 
1425
CSeq: 3882340 INVITE
 
1426
Unknown-LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong-Name: unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-value; unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-parameter-name = unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-parameter-value
 
1427
Via: SIP/2.0/TCP sip33.example.com
 
1428
v: SIP/2.0/TCP sip32.example.com
 
1429
V: SIP/2.0/TCP sip31.example.com
 
1430
Via: SIP/2.0/TCP sip30.example.com
 
1431
ViA: SIP/2.0/TCP sip29.example.com
 
1432
VIa: SIP/2.0/TCP sip28.example.com
 
1433
VIA: SIP/2.0/TCP sip27.example.com
 
1434
via: SIP/2.0/TCP sip26.example.com
 
1435
viA: SIP/2.0/TCP sip25.example.com
 
1436
vIa: SIP/2.0/TCP sip24.example.com
 
1437
vIA: SIP/2.0/TCP sip23.example.com
 
1438
V :  SIP/2.0/TCP sip22.example.com
 
1439
v :  SIP/2.0/TCP sip21.example.com
 
1440
V  : SIP/2.0/TCP sip20.example.com
 
1441
v  : SIP/2.0/TCP sip19.example.com
 
1442
Via : SIP/2.0/TCP sip18.example.com
 
1443
Via  : SIP/2.0/TCP sip17.example.com
 
1444
Via: SIP/2.0/TCP sip16.example.com
 
1445
Via: SIP/2.0/TCP sip15.example.com
 
1446
Via: SIP/2.0/TCP sip14.example.com
 
1447
Via: SIP/2.0/TCP sip13.example.com
 
1448
Via: SIP/2.0/TCP sip12.example.com
 
1449
Via: SIP/2.0/TCP sip11.example.com
 
1450
Via: SIP/2.0/TCP sip10.example.com
 
1451
Via: SIP/2.0/TCP sip9.example.com
 
1452
Via: SIP/2.0/TCP sip8.example.com
 
1453
Via: SIP/2.0/TCP sip7.example.com
 
1454
Via: SIP/2.0/TCP sip6.example.com
 
1455
Via: SIP/2.0/TCP sip5.example.com
 
1456
Via: SIP/2.0/TCP sip4.example.com
 
1457
Via: SIP/2.0/TCP sip3.example.com
 
1458
Via: SIP/2.0/TCP sip2.example.com
 
1459
Via: SIP/2.0/TCP sip1.example.com
 
1460
Via: SIP/2.0/TCP host.example.com;received=192.0.2.5;branch=verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongbranchvalue
 
1461
Max-Forwards: 70
 
1462
Contact: <sip:amazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallername@host5.example.net>
 
1463
Content-Type: application/sdp
 
1464
l: 150
 
1465
 
 
1466
v=0
 
1467
o=mhandley 29739 7272939 IN IP4 192.0.2.1
 
1468
s=-
 
1469
c=IN IP4 192.0.2.1
 
1470
t=0 0
 
1471
m=audio 49217 RTP/AVP 0 12
 
1472
m=video 3227 RTP/AVP 31
 
1473
a=rtpmap:31 LPC
 
1474
 
 
1475
*/
 
1476
   FILE* fid= fopen("longreq.dat","r");
 
1477
   tassert(fid);
 
1478
   resip::Data txt;
 
1479
   char mBuf[1024];
 
1480
   int result;
 
1481
   while(!feof(fid))
 
1482
   {
 
1483
      result = fread(&mBuf,1,1024,fid);
 
1484
      txt += resip::Data(mBuf,result);
 
1485
   }
 
1486
   fclose(fid);
 
1487
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
1488
   tassert_reset();
 
1489
   tassert(msg);
 
1490
   tassert_reset();
 
1491
   if(!msg)
 
1492
   {
 
1493
      return;
 
1494
   }
 
1495
 
 
1496
   std::auto_ptr<resip::SipMessage> message(msg);
 
1497
   msg->parseAllHeaders();
 
1498
 
 
1499
   resip::SipMessage copy(*msg);
 
1500
 
 
1501
   resip::Data encoded;
 
1502
   {
 
1503
      resip::oDataStream str(encoded);
 
1504
      msg->encode(str);
 
1505
   }
 
1506
   resip::Data copyEncoded;
 
1507
   {
 
1508
      resip::oDataStream str(copyEncoded);
 
1509
      copy.encode(str);
 
1510
   }
 
1511
 
 
1512
   //Request Line
 
1513
   //INVITE sip:user@example.com SIP/2.0
 
1514
   tassert(msg->header(resip::h_RequestLine).method()==resip::INVITE);
 
1515
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="INVITE");
 
1516
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
1517
   tassert(msg->header(resip::h_RequestLine).uri().user()=="user");
 
1518
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
1519
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.com");
 
1520
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
1521
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
1522
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
1523
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
1524
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
1525
 
 
1526
   //To: "I have a user name of extremeextremeextremeextremeextremeextremeextremeextremeextremeextreme proportion"<sip:user@example.com:6000;unknownparam1=verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongvalue;longparamnamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamename=shortvalue;verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongParameterNameWithNoValue>
 
1527
   tassert(msg->exists(resip::h_To));
 
1528
   tassert(msg->header(resip::h_To).displayName()=="I have a user name of extremeextremeextremeextremeextremeextremeextremeextremeextremeextreme proportion");
 
1529
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
1530
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
1531
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
1532
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
1533
   tassert(msg->header(resip::h_To).uri().user()=="user");
 
1534
   tassert(msg->header(resip::h_To).uri().password().empty());
 
1535
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
1536
   tassert(msg->header(resip::h_To).uri().port()==6000);
 
1537
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
1538
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
1539
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==3);
 
1540
 
 
1541
   resip::ExtensionParameter p_unknownparam1("unknownparam1");
 
1542
   tassert(msg->header(resip::h_To).uri().exists(p_unknownparam1));
 
1543
   tassert(msg->header(resip::h_To).uri().param(p_unknownparam1)=="verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongvalue");
 
1544
 
 
1545
   resip::ExtensionParameter p_long("longparamnamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamename");
 
1546
   tassert(msg->header(resip::h_To).uri().exists(p_long));
 
1547
   tassert(msg->header(resip::h_To).uri().param(p_long)=="shortvalue");
 
1548
 
 
1549
   resip::ExtensionParameter p_verylong("verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongParameterNameWithNoValue");
 
1550
   tassert(msg->header(resip::h_To).uri().exists(p_verylong));
 
1551
   tassert(msg->header(resip::h_To).uri().param(p_verylong)=="");
 
1552
 
 
1553
   //F: sip:amazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallername@example.net;tag=12982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982424;unknownheaderparamnamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamename=unknowheaderparamvaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevalue;unknownValuelessparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamname
 
1554
   tassert(msg->exists(resip::h_From));
 
1555
   tassert(msg->header(resip::h_From).displayName()=="");
 
1556
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
1557
   tassert(msg->header(resip::h_From).numUnknownParams()==2);
 
1558
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
1559
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="12982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982424");
 
1560
   
 
1561
   resip::ExtensionParameter p_unknownheaderparameternameXalot("unknownheaderparamnamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamename");
 
1562
   tassert(msg->header(resip::h_From).exists(p_unknownheaderparameternameXalot));
 
1563
   tassert(msg->header(resip::h_From).param(p_unknownheaderparameternameXalot)=="unknowheaderparamvaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevaluevalue");
 
1564
 
 
1565
   resip::ExtensionParameter p_unknownvalueless("unknownValuelessparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamnameparamname");
 
1566
   tassert(msg->header(resip::h_From).exists(p_unknownvalueless));
 
1567
   tassert(msg->header(resip::h_From).param(p_unknownvalueless)=="");
 
1568
 
 
1569
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
1570
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
1571
   tassert(msg->header(resip::h_From).uri().user()=="amazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallername");
 
1572
   tassert(msg->header(resip::h_From).uri().password().empty());
 
1573
   tassert(msg->header(resip::h_From).uri().host()=="example.net");
 
1574
   tassert(msg->header(resip::h_From).uri().port()==0);
 
1575
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
1576
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
1577
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
1578
 
 
1579
   //Call-ID: longreq.onereallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongcallid
 
1580
   tassert(msg->exists(resip::h_CallID));
 
1581
   tassert(msg->header(resip::h_CallID).value()=="longreq.onereallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongcallid");
 
1582
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
1583
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
1584
 
 
1585
   //CSeq: 3882340 INVITE
 
1586
   tassert(msg->exists(resip::h_CSeq));
 
1587
   tassert(msg->header(resip::h_CSeq).method()==resip::INVITE);
 
1588
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="INVITE");
 
1589
   tassert(msg->header(resip::h_CSeq).sequence()==3882340);
 
1590
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
1591
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
1592
 
 
1593
   //Unknown headers
 
1594
   //Unknown-LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong-Name: unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-value; unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-parameter-name = unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-parameter-value
 
1595
   resip::ExtensionHeader h_UnknownLong("Unknown-LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong-Name");
 
1596
   
 
1597
   tassert(msg->exists(h_UnknownLong));
 
1598
   tassert(msg->header(h_UnknownLong).size()==1);
 
1599
   tassert(msg->header(h_UnknownLong).begin()->value()=="unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-value; unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-parameter-name = unknown-longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong-parameter-value");
 
1600
   tassert(msg->header(h_UnknownLong).begin()->numKnownParams()==0);
 
1601
   tassert(msg->header(h_UnknownLong).begin()->numUnknownParams()==0);
 
1602
   
 
1603
   //Vias
 
1604
 
 
1605
   //Via: SIP/2.0/TCP sip33.example.com
 
1606
   //v: SIP/2.0/TCP sip32.example.com
 
1607
   //V: SIP/2.0/TCP sip31.example.com
 
1608
   //Via: SIP/2.0/TCP sip30.example.com
 
1609
   //ViA: SIP/2.0/TCP sip29.example.com
 
1610
   //VIa: SIP/2.0/TCP sip28.example.com
 
1611
   //VIA: SIP/2.0/TCP sip27.example.com
 
1612
   //via: SIP/2.0/TCP sip26.example.com
 
1613
   //viA: SIP/2.0/TCP sip25.example.com
 
1614
   //vIa: SIP/2.0/TCP sip24.example.com
 
1615
   //vIA: SIP/2.0/TCP sip23.example.com
 
1616
   //V :  SIP/2.0/TCP sip22.example.com
 
1617
   //v :  SIP/2.0/TCP sip21.example.com
 
1618
   //V  : SIP/2.0/TCP sip20.example.com
 
1619
   //v  : SIP/2.0/TCP sip19.example.com
 
1620
   //Via : SIP/2.0/TCP sip18.example.com
 
1621
   //Via  : SIP/2.0/TCP sip17.example.com
 
1622
   //Via: SIP/2.0/TCP sip16.example.com
 
1623
   //Via: SIP/2.0/TCP sip15.example.com
 
1624
   //Via: SIP/2.0/TCP sip14.example.com
 
1625
   //Via: SIP/2.0/TCP sip13.example.com
 
1626
   //Via: SIP/2.0/TCP sip12.example.com
 
1627
   //Via: SIP/2.0/TCP sip11.example.com
 
1628
   //Via: SIP/2.0/TCP sip10.example.com
 
1629
   //Via: SIP/2.0/TCP sip9.example.com
 
1630
   //Via: SIP/2.0/TCP sip8.example.com
 
1631
   //Via: SIP/2.0/TCP sip7.example.com
 
1632
   //Via: SIP/2.0/TCP sip6.example.com
 
1633
   //Via: SIP/2.0/TCP sip5.example.com
 
1634
   //Via: SIP/2.0/TCP sip4.example.com
 
1635
   //Via: SIP/2.0/TCP sip3.example.com
 
1636
   //Via: SIP/2.0/TCP sip2.example.com
 
1637
   //Via: SIP/2.0/TCP sip1.example.com
 
1638
   //Via: SIP/2.0/TCP host.example.com;received=192.0.2.5;branch=verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongbranchvalue
 
1639
 
 
1640
   tassert(msg->exists(resip::h_Vias));
 
1641
   tassert(msg->header(resip::h_Vias).size()==34);
 
1642
   
 
1643
   int i=33;
 
1644
   resip::Vias::iterator iter;
 
1645
   for(iter=msg->header(resip::h_Vias).begin();
 
1646
         iter!=msg->header(resip::h_Vias).end(); iter++)
 
1647
   {
 
1648
      if(i==0)
 
1649
      {
 
1650
         break;
 
1651
      }
 
1652
      tassert(iter->numKnownParams()==0);
 
1653
      tassert(iter->numUnknownParams()==0);
 
1654
      tassert(iter->protocolName()=="SIP");
 
1655
      tassert(iter->protocolVersion()=="2.0");
 
1656
      tassert(iter->transport()=="TCP");
 
1657
      tassert(iter->sentHost()==resip::Data("sip")+resip::Data(i)+resip::Data(".example.com"));
 
1658
      tassert(iter->sentPort()==0);
 
1659
      i--;
 
1660
   }
 
1661
   
 
1662
   tassert(iter->numKnownParams()==2);
 
1663
   tassert(iter->numUnknownParams()==0);
 
1664
   tassert(iter->protocolName()=="SIP");
 
1665
   tassert(iter->protocolVersion()=="2.0");
 
1666
   tassert(iter->transport()=="TCP");
 
1667
   tassert(iter->sentHost()=="host.example.com");
 
1668
   tassert(iter->sentPort()==0);
 
1669
   
 
1670
   tassert(iter->exists(resip::p_branch));
 
1671
   tassert(!(iter->param(resip::p_branch).hasMagicCookie()));
 
1672
   tassert(iter->param(resip::p_branch).getTransactionId()=="verylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongbranchvalue");
 
1673
   tassert(iter->param(resip::p_branch).clientData().empty());
 
1674
 
 
1675
   tassert(iter->exists(resip::p_received));
 
1676
   tassert(iter->param(resip::p_received)=="192.0.2.5");
 
1677
 
 
1678
   //Max-Forwards: 70
 
1679
   tassert(msg->exists(resip::h_MaxForwards));
 
1680
   tassert(msg->header(resip::h_MaxForwards).value()==70);
 
1681
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
1682
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
1683
 
 
1684
   //Contact: <sip:amazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallername@host5.example.net>
 
1685
   tassert(msg->exists(resip::h_Contacts));
 
1686
   tassert(msg->header(resip::h_Contacts).size()==1);
 
1687
   resip::ParserContainer<resip::NameAddr>::iterator j=msg->header(resip::h_Contacts).begin();
 
1688
   
 
1689
   tassert(j->displayName()=="");
 
1690
   tassert(j->numKnownParams()==0);
 
1691
   tassert(j->numUnknownParams()==0);
 
1692
   tassert(!(j->isAllContacts()));
 
1693
   tassert(j->uri().numKnownParams()==0);
 
1694
   tassert(j->uri().numUnknownParams()==0);
 
1695
   tassert(j->uri().scheme()=="sip");
 
1696
   tassert(j->uri().user()=="amazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallernameamazinglylongcallername");
 
1697
   tassert(j->uri().password().empty());
 
1698
   tassert(j->uri().host()=="host5.example.net");
 
1699
   tassert(j->uri().port()==0);
 
1700
   tassert(!(j->uri().hasEmbedded()));
 
1701
 
 
1702
   //Content-Type: application/sdp
 
1703
   tassert(msg->exists(resip::h_ContentType));
 
1704
   tassert(msg->header(resip::h_ContentType).type()=="application");
 
1705
   tassert(msg->header(resip::h_ContentType).subType()=="sdp");
 
1706
   tassert(msg->header(resip::h_ContentType).numKnownParams()==0);
 
1707
   tassert(msg->header(resip::h_ContentType).numUnknownParams()==0);
 
1708
   
 
1709
   //l: 150
 
1710
   tassert(msg->exists(resip::h_ContentLength));
 
1711
   tassert(msg->header(resip::h_ContentLength).value()==150);
 
1712
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
1713
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
1714
 
 
1715
   InfoLog(<< "In case longreq:" );
 
1716
   InfoLog(<< "Original text:" << std::endl << txt );
 
1717
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
1718
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
1719
 
 
1720
 
 
1721
 
 
1722
 
 
1723
}
 
1724
 
 
1725
 
 
1726
void
 
1727
dblreq()
 
1728
{
 
1729
/*
 
1730
   This message contains a single SIP REGISTER request, which ostensibly
 
1731
   arrived over UDP in a single datagram.  The packet contains extra
 
1732
   octets after the body (which in this case has zero length).  The
 
1733
   extra octets happen to look like a SIP INVITE request, but (per
 
1734
   section 18.3 of [RFC3261]) they are just spurious noise that must be
 
1735
   ignored.
 
1736
 
 
1737
   A SIP element receiving this datagram would handle the REGISTER
 
1738
   request normally and ignore the extra bits that look like an INVITE
 
1739
   request.  If the element is a proxy choosing to forward the REGISTER,
 
1740
   the INVITE octets would not appear in the forwarded request.
 
1741
 
 
1742
 
 
1743
 
 
1744
REGISTER sip:example.com SIP/2.0
 
1745
To: sip:j.user@example.com
 
1746
From: sip:j.user@example.com;tag=43251j3j324
 
1747
Max-Forwards: 8
 
1748
I: dblreq.0ha0isndaksdj99sdfafnl3lk233412
 
1749
Contact: sip:j.user@host.example.com
 
1750
CSeq: 8 REGISTER
 
1751
Via: SIP/2.0/UDP 192.0.2.125;branch=z9hG4bKkdjuw23492
 
1752
Content-Length: 0
 
1753
 
 
1754
 
 
1755
INVITE sip:joe@example.com SIP/2.0
 
1756
t: sip:joe@example.com
 
1757
From: sip:caller@example.net;tag=141334
 
1758
Max-Forwards: 8
 
1759
Call-ID: dblreq.0ha0isnda977644900765@192.0.2.15
 
1760
CSeq: 8 INVITE
 
1761
Via: SIP/2.0/UDP 192.0.2.15;branch=z9hG4bKkdjuw380234
 
1762
Content-Type: application/sdp
 
1763
Content-Length: 150
 
1764
 
 
1765
v=0
 
1766
o=mhandley 29739 7272939 IN IP4 192.0.2.15
 
1767
s=-
 
1768
c=IN IP4 192.0.2.15
 
1769
t=0 0
 
1770
m=audio 49217 RTP/AVP 0 12
 
1771
m =video 3227 RTP/AVP 31
 
1772
a=rtpmap:31 LPC
 
1773
 
 
1774
 
 
1775
*/
 
1776
   FILE* fid= fopen("dblreq.dat","r");
 
1777
   tassert(fid);
 
1778
   resip::Data txt;
 
1779
   char mBuf[1024];
 
1780
   int result;
 
1781
   while(!feof(fid))
 
1782
   {
 
1783
      result = fread(&mBuf,1,1024,fid);
 
1784
      txt += resip::Data(mBuf,result);
 
1785
   }
 
1786
   fclose(fid);
 
1787
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
1788
   tassert_reset();
 
1789
   tassert(msg);
 
1790
   tassert_reset();
 
1791
   if(!msg)
 
1792
   {
 
1793
      return;
 
1794
   }
 
1795
 
 
1796
   std::auto_ptr<resip::SipMessage> message(msg);
 
1797
   msg->parseAllHeaders();
 
1798
 
 
1799
   resip::SipMessage copy(*msg);
 
1800
 
 
1801
   resip::Data encoded;
 
1802
   {
 
1803
      resip::oDataStream str(encoded);
 
1804
      msg->encode(str);
 
1805
   }
 
1806
   resip::Data copyEncoded;
 
1807
   {
 
1808
      resip::oDataStream str(copyEncoded);
 
1809
      copy.encode(str);
 
1810
   }
 
1811
   
 
1812
   //Request Line
 
1813
   //REGISTER sip:example.com SIP/2.0
 
1814
   tassert(msg->header(resip::h_RequestLine).method()==resip::REGISTER);
 
1815
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="REGISTER");
 
1816
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
1817
   tassert(msg->header(resip::h_RequestLine).uri().user()=="");
 
1818
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
1819
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.com");
 
1820
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
1821
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
1822
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
1823
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
1824
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
1825
 
 
1826
   //To: sip:j.user@example.com
 
1827
   tassert(msg->exists(resip::h_To));
 
1828
   tassert(msg->header(resip::h_To).displayName()=="");
 
1829
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
1830
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
1831
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
1832
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
1833
   tassert(msg->header(resip::h_To).uri().user()=="j.user");
 
1834
   tassert(msg->header(resip::h_To).uri().password().empty());
 
1835
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
1836
   tassert(msg->header(resip::h_To).uri().port()==0);
 
1837
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
1838
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
1839
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
1840
 
 
1841
   //From: sip:j.user@example.com;tag=43251j3j324
 
1842
   tassert(msg->exists(resip::h_From));
 
1843
   tassert(msg->header(resip::h_From).displayName()=="");
 
1844
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
1845
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
1846
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
1847
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="43251j3j324");
 
1848
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
1849
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
1850
   tassert(msg->header(resip::h_From).uri().user()=="j.user");
 
1851
   tassert(msg->header(resip::h_From).uri().password().empty());
 
1852
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
1853
   tassert(msg->header(resip::h_From).uri().port()==0);
 
1854
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
1855
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
1856
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
1857
 
 
1858
   //Max-Forwards: 8
 
1859
   tassert(msg->exists(resip::h_MaxForwards));
 
1860
   tassert(msg->header(resip::h_MaxForwards).value()==8);
 
1861
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
1862
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
1863
 
 
1864
   //I: dblreq.0ha0isndaksdj99sdfafnl3lk233412
 
1865
   tassert(msg->exists(resip::h_CallID));
 
1866
   tassert(msg->header(resip::h_CallID).value()=="dblreq.0ha0isndaksdj99sdfafnl3lk233412");
 
1867
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
1868
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
1869
 
 
1870
   //Contact: sip:j.user@host.example.com
 
1871
   tassert(msg->exists(resip::h_Contacts));
 
1872
   tassert(msg->header(resip::h_Contacts).size()==1);
 
1873
   resip::ParserContainer<resip::NameAddr>::iterator j=msg->header(resip::h_Contacts).begin();
 
1874
   
 
1875
   tassert(j->displayName()=="");
 
1876
   tassert(j->numKnownParams()==0);
 
1877
   tassert(j->numUnknownParams()==0);
 
1878
   tassert(!(j->isAllContacts()));
 
1879
   tassert(j->uri().numKnownParams()==0);
 
1880
   tassert(j->uri().numUnknownParams()==0);
 
1881
   tassert(j->uri().scheme()=="sip");
 
1882
   tassert(j->uri().user()=="j.user");
 
1883
   tassert(j->uri().password().empty());
 
1884
   tassert(j->uri().host()=="host.example.com");
 
1885
   tassert(j->uri().port()==0);
 
1886
   tassert(!(j->uri().hasEmbedded()));
 
1887
 
 
1888
   //CSeq: 8 REGISTER
 
1889
   tassert(msg->exists(resip::h_CSeq));
 
1890
   tassert(msg->header(resip::h_CSeq).method()==resip::REGISTER);
 
1891
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="REGISTER");
 
1892
   tassert(msg->header(resip::h_CSeq).sequence()==8);
 
1893
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
1894
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
1895
 
 
1896
   //Via: SIP/2.0/UDP 192.0.2.125;branch=z9hG4bKkdjuw23492
 
1897
   tassert(msg->exists(resip::h_Vias));
 
1898
   tassert(msg->header(resip::h_Vias).size()==1);
 
1899
   resip::ParserContainer<resip::Via>::iterator i=msg->header(resip::h_Vias).begin();
 
1900
   
 
1901
   tassert(i->numKnownParams()==1);
 
1902
   tassert(i->numUnknownParams()==0);
 
1903
   tassert(i->protocolName()=="SIP");
 
1904
   tassert(i->protocolVersion()=="2.0");
 
1905
   tassert(i->transport()=="UDP");
 
1906
   tassert(i->sentHost()=="192.0.2.125");
 
1907
   tassert(i->sentPort()==0);
 
1908
   
 
1909
   tassert(i->exists(resip::p_branch));
 
1910
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
1911
   tassert(i->param(resip::p_branch).getTransactionId()=="kdjuw23492");
 
1912
   tassert(i->param(resip::p_branch).clientData().empty());
 
1913
 
 
1914
   //Content-Length: 0
 
1915
   tassert(msg->exists(resip::h_ContentLength));
 
1916
   // .bwc. We configured SipMessage to take the Content-Length seriously
 
1917
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
1918
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
1919
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
1920
 
 
1921
 
 
1922
 
 
1923
   InfoLog(<< "In case dblreq:" );
 
1924
   InfoLog(<< "Original text:" << std::endl << txt );
 
1925
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
1926
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
1927
 
 
1928
 
 
1929
 
 
1930
 
 
1931
}
 
1932
 
 
1933
 
 
1934
void
 
1935
semiuri()
 
1936
{
 
1937
/*
 
1938
   This request has a semicolon-separated parameter contained in the
 
1939
   "user" part of the Request-URI (whose value contains an escaped @
 
1940
   symbol).  Receiving elements will accept this as a well-formed
 
1941
   message.  The Request-URI will parse so that the user part is
 
1942
   "user;par=u@example.net".
 
1943
 
 
1944
OPTIONS sip:user;par=u%40example.net@example.com SIP/2.0
 
1945
To: sip:j_user@example.com
 
1946
From: sip:caller@example.org;tag=33242
 
1947
Max-Forwards: 3
 
1948
Call-ID: semiuri.0ha0isndaksdj
 
1949
CSeq: 8 OPTIONS
 
1950
Accept: application/sdp, application/pkcs7-mime,
 
1951
        multipart/mixed, multipart/signed,
 
1952
        message/sip, message/sipfrag
 
1953
Via: SIP/2.0/UDP 192.0.2.1;branch=z9hG4bKkdjuw
 
1954
l: 0
 
1955
 
 
1956
 
 
1957
*/
 
1958
   FILE* fid= fopen("semiuri.dat","r");
 
1959
   tassert(fid);
 
1960
   resip::Data txt;
 
1961
   char mBuf[1024];
 
1962
   int result;
 
1963
   while(!feof(fid))
 
1964
   {
 
1965
      result = fread(&mBuf,1,1024,fid);
 
1966
      txt += resip::Data(mBuf,result);
 
1967
   }
 
1968
   fclose(fid);
 
1969
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
1970
   tassert_reset();
 
1971
   tassert(msg);
 
1972
   tassert_reset();
 
1973
   if(!msg)
 
1974
   {
 
1975
      return;
 
1976
   }
 
1977
 
 
1978
   std::auto_ptr<resip::SipMessage> message(msg);
 
1979
   msg->parseAllHeaders();
 
1980
 
 
1981
   resip::SipMessage copy(*msg);
 
1982
 
 
1983
   resip::Data encoded;
 
1984
   {
 
1985
      resip::oDataStream str(encoded);
 
1986
      msg->encode(str);
 
1987
   }
 
1988
   resip::Data copyEncoded;
 
1989
   {
 
1990
      resip::oDataStream str(copyEncoded);
 
1991
      copy.encode(str);
 
1992
   }
 
1993
 
 
1994
   //Request Line
 
1995
   //OPTIONS sip:user;par=u%40example.net@example.com SIP/2.0
 
1996
   tassert(msg->header(resip::h_RequestLine).method()==resip::OPTIONS);
 
1997
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="OPTIONS");
 
1998
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
1999
   // ?bwc? Need to determine how escaped stuff should be represented internally
 
2000
   tassert(msg->header(resip::h_RequestLine).uri().user()=="user;par=u%40example.net");
 
2001
   tassert_reset();
 
2002
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
2003
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.com");
 
2004
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
2005
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
2006
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
2007
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
2008
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
2009
 
 
2010
   //To: sip:j_user@example.com
 
2011
   tassert(msg->exists(resip::h_To));
 
2012
   tassert(msg->header(resip::h_To).displayName()=="");
 
2013
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
2014
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
2015
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
2016
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
2017
   tassert(msg->header(resip::h_To).uri().user()=="j_user");
 
2018
   tassert(msg->header(resip::h_To).uri().password().empty());
 
2019
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
2020
   tassert(msg->header(resip::h_To).uri().port()==0);
 
2021
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
2022
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
2023
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
2024
 
 
2025
   //From: sip:caller@example.org;tag=33242
 
2026
   tassert(msg->exists(resip::h_From));
 
2027
   tassert(msg->header(resip::h_From).displayName()=="");
 
2028
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
2029
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
2030
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
2031
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="33242");
 
2032
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
2033
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
2034
   tassert(msg->header(resip::h_From).uri().user()=="caller");
 
2035
   tassert(msg->header(resip::h_From).uri().password().empty());
 
2036
   tassert(msg->header(resip::h_From).uri().host()=="example.org");
 
2037
   tassert(msg->header(resip::h_From).uri().port()==0);
 
2038
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
2039
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
2040
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
2041
 
 
2042
   //Max-Forwards: 3
 
2043
   tassert(msg->exists(resip::h_MaxForwards));
 
2044
   tassert(msg->header(resip::h_MaxForwards).value()==3);
 
2045
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
2046
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
2047
 
 
2048
   //Call-ID: semiuri.0ha0isndaksdj
 
2049
   tassert(msg->exists(resip::h_CallID));
 
2050
   tassert(msg->header(resip::h_CallID).value()=="semiuri.0ha0isndaksdj");
 
2051
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
2052
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
2053
 
 
2054
   //CSeq: 8 OPTIONS
 
2055
   tassert(msg->exists(resip::h_CSeq));
 
2056
   tassert(msg->header(resip::h_CSeq).method()==resip::OPTIONS);
 
2057
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="OPTIONS");
 
2058
   tassert(msg->header(resip::h_CSeq).sequence()==8);
 
2059
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
2060
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
2061
 
 
2062
   //Accept: application/sdp, application/pkcs7-mime,
 
2063
   //        multipart/mixed, multipart/signed,
 
2064
   //        message/sip, message/sipfrag
 
2065
   tassert(msg->exists(resip::h_Accepts));
 
2066
   tassert(msg->header(resip::h_Accepts).size()==6);
 
2067
   
 
2068
   resip::Mimes::iterator a=msg->header(resip::h_Accepts).begin();
 
2069
   
 
2070
   tassert(a->type()=="application");
 
2071
   tassert(a->subType()=="sdp");
 
2072
   tassert(a->numKnownParams()==0);
 
2073
   tassert(a->numUnknownParams()==0);
 
2074
   a++;
 
2075
 
 
2076
   tassert(a->type()=="application");
 
2077
   tassert(a->subType()=="pkcs7-mime");
 
2078
   tassert(a->numKnownParams()==0);
 
2079
   tassert(a->numUnknownParams()==0);
 
2080
   a++;
 
2081
 
 
2082
   tassert(a->type()=="multipart");
 
2083
   tassert(a->subType()=="mixed");
 
2084
   tassert(a->numKnownParams()==0);
 
2085
   tassert(a->numUnknownParams()==0);
 
2086
   a++;
 
2087
 
 
2088
   tassert(a->type()=="multipart");
 
2089
   tassert(a->subType()=="signed");
 
2090
   tassert(a->numKnownParams()==0);
 
2091
   tassert(a->numUnknownParams()==0);
 
2092
   a++;
 
2093
 
 
2094
   tassert(a->type()=="message");
 
2095
   tassert(a->subType()=="sip");
 
2096
   tassert(a->numKnownParams()==0);
 
2097
   tassert(a->numUnknownParams()==0);
 
2098
   a++;
 
2099
 
 
2100
   tassert(a->type()=="message");
 
2101
   tassert(a->subType()=="sipfrag");
 
2102
   tassert(a->numKnownParams()==0);
 
2103
   tassert(a->numUnknownParams()==0);
 
2104
 
 
2105
   //Via: SIP/2.0/UDP 192.0.2.1;branch=z9hG4bKkdjuw
 
2106
   tassert(msg->exists(resip::h_Vias));
 
2107
   tassert(msg->header(resip::h_Vias).size()==1);
 
2108
   resip::ParserContainer<resip::Via>::iterator i=msg->header(resip::h_Vias).begin();
 
2109
   
 
2110
   tassert(i->numKnownParams()==1);
 
2111
   tassert(i->numUnknownParams()==0);
 
2112
   tassert(i->protocolName()=="SIP");
 
2113
   tassert(i->protocolVersion()=="2.0");
 
2114
   tassert(i->transport()=="UDP");
 
2115
   tassert(i->sentHost()=="192.0.2.1");
 
2116
   tassert(i->sentPort()==0);
 
2117
   
 
2118
   tassert(i->exists(resip::p_branch));
 
2119
   tassert(i->param(resip::p_branch).hasMagicCookie());
 
2120
   tassert(i->param(resip::p_branch).getTransactionId()=="kdjuw");
 
2121
   tassert(i->param(resip::p_branch).clientData().empty());
 
2122
 
 
2123
   //l: 0
 
2124
   tassert(msg->exists(resip::h_ContentLength));
 
2125
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
2126
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
2127
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
2128
 
 
2129
 
 
2130
 
 
2131
   InfoLog(<< "In case semiuri:" );
 
2132
   InfoLog(<< "Original text:" << std::endl << txt );
 
2133
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
2134
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
2135
 
 
2136
 
 
2137
 
 
2138
 
 
2139
}
 
2140
 
 
2141
 
 
2142
void
 
2143
transports()
 
2144
{
 
2145
/*
 
2146
   This request contains Via header field values with all known
 
2147
   transport types and exercises the transport extension mechanism.
 
2148
   Parsers must accept this message as well formed.  Elements receiving
 
2149
   this message would process it exactly as if the 2nd and subsequent
 
2150
   header field values specified UDP (or other transport).
 
2151
 
 
2152
OPTIONS sip:user@example.com SIP/2.0
 
2153
To: sip:user@example.com
 
2154
From: <sip:caller@example.com>;tag=323
 
2155
Max-Forwards: 70
 
2156
Call-ID:  transports.kijh4akdnaqjkwendsasfdj
 
2157
Accept: application/sdp
 
2158
CSeq: 60 OPTIONS
 
2159
Via: SIP/2.0/UDP t1.example.com;branch=z9hG4bKkdjuw
 
2160
Via: SIP/2.0/SCTP t2.example.com;branch=z9hG4bKklasjdhf
 
2161
Via: SIP/2.0/TLS t3.example.com;branch=z9hG4bK2980unddj
 
2162
Via: SIP/2.0/UNKNOWN t4.example.com;branch=z9hG4bKasd0f3en
 
2163
Via: SIP/2.0/TCP t5.example.com;branch=z9hG4bK0a9idfnee
 
2164
l: 0
 
2165
 
 
2166
 
 
2167
*/
 
2168
   FILE* fid= fopen("transports.dat","r");
 
2169
   tassert(fid);
 
2170
   resip::Data txt;
 
2171
   char mBuf[1024];
 
2172
   int result;
 
2173
   while(!feof(fid))
 
2174
   {
 
2175
      result = fread(&mBuf,1,1024,fid);
 
2176
      txt += resip::Data(mBuf,result);
 
2177
   }
 
2178
   fclose(fid);
 
2179
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
2180
   tassert_reset();
 
2181
   tassert(msg);
 
2182
   tassert_reset();
 
2183
   if(!msg)
 
2184
   {
 
2185
      return;
 
2186
   }
 
2187
 
 
2188
   std::auto_ptr<resip::SipMessage> message(msg);
 
2189
   msg->parseAllHeaders();
 
2190
 
 
2191
   resip::SipMessage copy(*msg);
 
2192
 
 
2193
   resip::Data encoded;
 
2194
   {
 
2195
      resip::oDataStream str(encoded);
 
2196
      msg->encode(str);
 
2197
   }
 
2198
   resip::Data copyEncoded;
 
2199
   {
 
2200
      resip::oDataStream str(copyEncoded);
 
2201
      copy.encode(str);
 
2202
   }
 
2203
 
 
2204
   //Request Line
 
2205
   //OPTIONS sip:user@example.com SIP/2.0
 
2206
   tassert(msg->header(resip::h_RequestLine).method()==resip::OPTIONS);
 
2207
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="OPTIONS");
 
2208
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
2209
   tassert(msg->header(resip::h_RequestLine).uri().user()=="user");
 
2210
   tassert_reset();
 
2211
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
2212
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.com");
 
2213
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
2214
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
2215
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
2216
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
2217
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
2218
 
 
2219
   //To: sip:user@example.com
 
2220
   tassert(msg->exists(resip::h_To));
 
2221
   tassert(msg->header(resip::h_To).displayName()=="");
 
2222
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
2223
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
2224
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
2225
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
2226
   tassert(msg->header(resip::h_To).uri().user()=="user");
 
2227
   tassert(msg->header(resip::h_To).uri().password().empty());
 
2228
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
2229
   tassert(msg->header(resip::h_To).uri().port()==0);
 
2230
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
2231
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
2232
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
2233
 
 
2234
   //From: <sip:caller@example.com>;tag=323
 
2235
   tassert(msg->exists(resip::h_From));
 
2236
   tassert(msg->header(resip::h_From).displayName()=="");
 
2237
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
2238
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
2239
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
2240
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="323");
 
2241
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
2242
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
2243
   tassert(msg->header(resip::h_From).uri().user()=="caller");
 
2244
   tassert(msg->header(resip::h_From).uri().password().empty());
 
2245
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
2246
   tassert(msg->header(resip::h_From).uri().port()==0);
 
2247
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
2248
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
2249
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
2250
 
 
2251
   //Max-Forwards: 70
 
2252
   tassert(msg->exists(resip::h_MaxForwards));
 
2253
   tassert(msg->header(resip::h_MaxForwards).value()==70);
 
2254
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
2255
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
2256
 
 
2257
   //Call-ID:  transports.kijh4akdnaqjkwendsasfdj
 
2258
   tassert(msg->exists(resip::h_CallID));
 
2259
   tassert(msg->header(resip::h_CallID).value()=="transports.kijh4akdnaqjkwendsasfdj");
 
2260
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
2261
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
2262
 
 
2263
   //Accept: application/sdp
 
2264
   tassert(msg->exists(resip::h_Accepts));
 
2265
   tassert(msg->header(resip::h_Accepts).size()==1);
 
2266
   
 
2267
   resip::Mimes::iterator a=msg->header(resip::h_Accepts).begin();
 
2268
   
 
2269
   tassert(a->type()=="application");
 
2270
   tassert(a->subType()=="sdp");
 
2271
   tassert(a->numKnownParams()==0);
 
2272
   tassert(a->numUnknownParams()==0);
 
2273
 
 
2274
   //CSeq: 60 OPTIONS
 
2275
   tassert(msg->exists(resip::h_CSeq));
 
2276
   tassert(msg->header(resip::h_CSeq).method()==resip::OPTIONS);
 
2277
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="OPTIONS");
 
2278
   tassert(msg->header(resip::h_CSeq).sequence()==60);
 
2279
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
2280
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
2281
 
 
2282
   //Vias
 
2283
   tassert(msg->exists(resip::h_Vias));
 
2284
   tassert(msg->header(resip::h_Vias).size()==5);
 
2285
   resip::ParserContainer<resip::Via>::iterator v=msg->header(resip::h_Vias).begin();
 
2286
 
 
2287
   //Via: SIP/2.0/UDP t1.example.com;branch=z9hG4bKkdjuw
 
2288
   tassert(v->numKnownParams()==1);
 
2289
   tassert(v->numUnknownParams()==0);
 
2290
   tassert(v->protocolName()=="SIP");
 
2291
   tassert(v->protocolVersion()=="2.0");
 
2292
   tassert(v->transport()=="UDP");
 
2293
   tassert(v->sentHost()=="t1.example.com");
 
2294
   tassert(v->sentPort()==0);
 
2295
   
 
2296
   tassert(v->exists(resip::p_branch));
 
2297
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
2298
   tassert(v->param(resip::p_branch).getTransactionId()=="kdjuw");
 
2299
   tassert(v->param(resip::p_branch).clientData().empty());
 
2300
   
 
2301
   v++;
 
2302
   //Via: SIP/2.0/SCTP t2.example.com;branch=z9hG4bKklasjdhf
 
2303
   tassert(v->numKnownParams()==1);
 
2304
   tassert(v->numUnknownParams()==0);
 
2305
   tassert(v->protocolName()=="SIP");
 
2306
   tassert(v->protocolVersion()=="2.0");
 
2307
   tassert(v->transport()=="SCTP");
 
2308
   tassert(v->sentHost()=="t2.example.com");
 
2309
   tassert(v->sentPort()==0);
 
2310
   
 
2311
   tassert(v->exists(resip::p_branch));
 
2312
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
2313
   tassert(v->param(resip::p_branch).getTransactionId()=="klasjdhf");
 
2314
   tassert(v->param(resip::p_branch).clientData().empty());
 
2315
   
 
2316
   v++;
 
2317
   //Via: SIP/2.0/TLS t3.example.com;branch=z9hG4bK2980unddj
 
2318
   tassert(v->numKnownParams()==1);
 
2319
   tassert(v->numUnknownParams()==0);
 
2320
   tassert(v->protocolName()=="SIP");
 
2321
   tassert(v->protocolVersion()=="2.0");
 
2322
   tassert(v->transport()=="TLS");
 
2323
   tassert(v->sentHost()=="t3.example.com");
 
2324
   tassert(v->sentPort()==0);
 
2325
   
 
2326
   tassert(v->exists(resip::p_branch));
 
2327
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
2328
   tassert(v->param(resip::p_branch).getTransactionId()=="2980unddj");
 
2329
   tassert(v->param(resip::p_branch).clientData().empty());
 
2330
   
 
2331
   v++;
 
2332
   //Via: SIP/2.0/UNKNOWN t4.example.com;branch=z9hG4bKasd0f3en
 
2333
   tassert(v->numKnownParams()==1);
 
2334
   tassert(v->numUnknownParams()==0);
 
2335
   tassert(v->protocolName()=="SIP");
 
2336
   tassert(v->protocolVersion()=="2.0");
 
2337
   tassert(v->transport()=="UNKNOWN");
 
2338
   tassert(v->sentHost()=="t4.example.com");
 
2339
   tassert(v->sentPort()==0);
 
2340
   
 
2341
   tassert(v->exists(resip::p_branch));
 
2342
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
2343
   tassert(v->param(resip::p_branch).getTransactionId()=="asd0f3en");
 
2344
   tassert(v->param(resip::p_branch).clientData().empty());
 
2345
   
 
2346
   v++;
 
2347
   //Via: SIP/2.0/TCP t5.example.com;branch=z9hG4bK0a9idfnee
 
2348
   tassert(v->numKnownParams()==1);
 
2349
   tassert(v->numUnknownParams()==0);
 
2350
   tassert(v->protocolName()=="SIP");
 
2351
   tassert(v->protocolVersion()=="2.0");
 
2352
   tassert(v->transport()=="TCP");
 
2353
   tassert(v->sentHost()=="t5.example.com");
 
2354
   tassert(v->sentPort()==0);
 
2355
   
 
2356
   tassert(v->exists(resip::p_branch));
 
2357
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
2358
   tassert(v->param(resip::p_branch).getTransactionId()=="0a9idfnee");
 
2359
   tassert(v->param(resip::p_branch).clientData().empty());
 
2360
   
 
2361
   //l: 0
 
2362
   tassert(msg->exists(resip::h_ContentLength));
 
2363
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
2364
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
2365
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
2366
 
 
2367
   InfoLog(<< "In case transports:" );
 
2368
   InfoLog(<< "Original text:" << std::endl << txt );
 
2369
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
2370
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
2371
 
 
2372
 
 
2373
 
 
2374
 
 
2375
}
 
2376
 
 
2377
 
 
2378
void
 
2379
mpart01()
 
2380
{
 
2381
#if 0
 
2382
/*
 
2383
   This MESSAGE request contains two body parts.  The second part is
 
2384
   binary encoded and contains null (0x00) characters.  Receivers must
 
2385
   take care to frame the received message properly.
 
2386
 
 
2387
   Parsers must accept this message as well formed, even if the
 
2388
   application above the parser does not support multipart/signed.
 
2389
 
 
2390
   Additional examples of multipart/mime messages, in particular S/MIME
 
2391
   messages, are available in the security call flow examples document
 
2392
   [SIP-SEC].
 
2393
 
 
2394
MESSAGE sip:kumiko@example.org SIP/2.0
 
2395
Via: SIP/2.0/UDP 127.0.0.1:5070;branch=z9hG4bK-d87543-4dade06d0bdb11ee-1--d87543-;rport
 
2396
Max-Forwards: 70
 
2397
Route: <sip:127.0.0.1:5080>
 
2398
Identity: r5mwreLuyDRYBi/0TiPwEsY3rEVsk/G2WxhgTV1PF7hHuLIK0YWVKZhKv9Mj8UeXqkMVbnVq37CD+813gvYjcBUaZngQmXc9WNZSDNGCzA+fWl9MEUHWIZo1CeJebdY/XlgKeTa0Olvq0rt70Q5jiSfbqMJmQFteeivUhkMWYUA=
 
2399
Contact: <sip:fluffy@127.0.0.1:5070>
 
2400
To: <sip:kumiko@example.org>
 
2401
From: <sip:fluffy@example.com>;tag=2fb0dcc9
 
2402
Call-ID: 3d9485ad0c49859b@Zmx1ZmZ5LW1hYy0xNi5sb2NhbA..
 
2403
CSeq: 1 MESSAGE
 
2404
Content-Transfer-Encoding: binary
 
2405
Content-Type: multipart/mixed;boundary=7a9cbec02ceef655
 
2406
Date: Sat, 15 Oct 2005 04:44:56 GMT
 
2407
User-Agent: SIPimp.org/0.2.5 (curses)
 
2408
Content-Length: 553
 
2409
 
 
2410
--7a9cbec02ceef655
 
2411
Content-Type: text/plain
 
2412
Content-Transfer-Encoding: binary
 
2413
 
 
2414
Hello
 
2415
--7a9cbec02ceef655
 
2416
Content-Type: application/octet-stream
 
2417
Content-Transfer-Encoding: binary
 
2418
 
 
2419
0ļæ½R   *ļæ½Hļæ½ļæ½
 
2420
ļæ½ļæ½C0ļæ½?1 0+0     *ļæ½Hļæ½ļæ½
 
2421
1ļæ½ 0ļæ½0|0p1 0   UUS10U
 
2422
California10USan Jose10 U
 
2423
sipit1)0'U  Sipit Test Certificate Authorityļæ½q30+0
 
2424
       *ļæ½Hļæ½ļæ½
 
2425
ļæ½ļæ½ļæ½ļæ½fļæ½Hļæ½R-ļæ½å—Žļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½fYqbļæ½ļæ½ļæ½*ļæ½ļæ½5
 
2426
hļæ½ļæ½ļæ½<ļæ½+ļæ½uļæ½ļæ½dļæ½Y=ļæ½G(ļæ½b ļæ½ļæ½Atļæ½3
 
2427
ļæ½ļæ½ļæ½Ū“ļæ½ B.{rļæ½Ņœļæ½É®.ļæ½ļæ½ļæ½ļæ½ļæ½/;~Oļæ½'ļæ½Tmä¶Ŗ:ļæ½>fļæ½ļæ½]ļæ½ļæ½Kļæ½ļæ½ļæ½ļæ½ļæ½ļæ½-ļæ½Oļæ½{eļæ½ļæ½ļæ½
 
2428
--7a9cbec02ceef655--
 
2429
 
 
2430
*/
 
2431
#endif
 
2432
 
 
2433
   FILE* fid= fopen("mpart01.dat","r");
 
2434
   tassert(fid);
 
2435
   resip::Data txt;
 
2436
   char mBuf[1024];
 
2437
   int result;
 
2438
   while(!feof(fid))
 
2439
   {
 
2440
      result = fread(&mBuf,1,1024,fid);
 
2441
      txt += resip::Data(mBuf,result);
 
2442
   }
 
2443
   fclose(fid);
 
2444
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
2445
   tassert_reset();
 
2446
   tassert(msg);
 
2447
   tassert_reset();
 
2448
   if(!msg)
 
2449
   {
 
2450
      return;
 
2451
   }
 
2452
 
 
2453
   std::auto_ptr<resip::SipMessage> message(msg);
 
2454
   msg->parseAllHeaders();
 
2455
 
 
2456
   resip::SipMessage copy(*msg);
 
2457
 
 
2458
   resip::Data encoded;
 
2459
   {
 
2460
      resip::oDataStream str(encoded);
 
2461
      msg->encode(str);
 
2462
   }
 
2463
   resip::Data copyEncoded;
 
2464
   {
 
2465
      resip::oDataStream str(copyEncoded);
 
2466
      copy.encode(str);
 
2467
   }
 
2468
 
 
2469
   //Request Line
 
2470
   //MESSAGE sip:kumiko@example.org SIP/2.0
 
2471
   tassert(msg->header(resip::h_RequestLine).method()==resip::MESSAGE);
 
2472
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="MESSAGE");
 
2473
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
2474
   tassert(msg->header(resip::h_RequestLine).uri().user()=="kumiko");
 
2475
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
2476
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.org");
 
2477
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
2478
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
2479
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
2480
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
2481
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
2482
 
 
2483
   //Vias
 
2484
   tassert(msg->exists(resip::h_Vias));
 
2485
   tassert(msg->header(resip::h_Vias).size()==1);
 
2486
   resip::ParserContainer<resip::Via>::iterator v=msg->header(resip::h_Vias).begin();
 
2487
 
 
2488
   //Via: SIP/2.0/UDP 127.0.0.1:5070;branch=z9hG4bK-d87543-4dade06d0bdb11ee-1--d87543-;rport
 
2489
   tassert(v->numKnownParams()==2);
 
2490
   tassert(v->numUnknownParams()==0);
 
2491
   tassert(v->protocolName()=="SIP");
 
2492
   tassert(v->protocolVersion()=="2.0");
 
2493
   tassert(v->transport()=="UDP");
 
2494
   tassert(v->sentHost()=="127.0.0.1");
 
2495
   tassert(v->sentPort()==5070);
 
2496
   
 
2497
   tassert(v->exists(resip::p_branch));
 
2498
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
2499
   // .bwc. This branch parameter has old resip-specific tokens in it. The 
 
2500
   // "d87543" used to be the resip cookie, but the resip cookie has since 
 
2501
   // changed. So, the whole branch param is taken as the transaction id.
 
2502
   tassert(v->param(resip::p_branch).getTransactionId()==
 
2503
                                 "-d87543-4dade06d0bdb11ee-1--d87543-");
 
2504
   tassert(v->param(resip::p_branch).clientData().empty());
 
2505
   
 
2506
   tassert(v->exists(resip::p_rport));
 
2507
   tassert(!(v->param(resip::p_rport).hasValue()));
 
2508
   tassert(v->param(resip::p_rport).port()==0);
 
2509
 
 
2510
   //Max-Forwards: 70
 
2511
   tassert(msg->exists(resip::h_MaxForwards));
 
2512
   tassert(msg->header(resip::h_MaxForwards).value()==70);
 
2513
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
2514
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
2515
 
 
2516
   //Route: <sip:127.0.0.1:5080>
 
2517
   tassert(msg->exists(resip::h_Routes));
 
2518
   tassert(msg->header(resip::h_Routes).size()==1);
 
2519
   resip::ParserContainer<resip::NameAddr>::iterator r=msg->header(resip::h_Routes).begin();
 
2520
   
 
2521
   tassert(r->numKnownParams()==0);
 
2522
   tassert(r->numUnknownParams()==0);
 
2523
   tassert(r->displayName()=="");
 
2524
   tassert(r->uri().scheme()=="sip");
 
2525
   tassert(r->uri().user()=="");
 
2526
   tassert(r->uri().password()=="");
 
2527
   tassert(r->uri().host()=="127.0.0.1");
 
2528
   tassert(r->uri().port()==5080);
 
2529
   tassert(!(r->uri().hasEmbedded()));
 
2530
   tassert(r->uri().numKnownParams()==0);
 
2531
   tassert(r->uri().numUnknownParams()==0);
 
2532
   
 
2533
 
 
2534
   //Identity: r5mwreLuyDRYBi/0TiPwEsY3rEVsk/G2WxhgTV1PF7hHuLIK0YWVKZhKv9Mj8UeXqkMVbnVq37CD+813gvYjcBUaZngQmXc9WNZSDNGCzA+fWl9MEUHWIZo1CeJebdY/XlgKeTa0Olvq0rt70Q5jiSfbqMJmQFteeivUhkMWYUA=
 
2535
   tassert(msg->exists(resip::h_Identity));
 
2536
   tassert(msg->header(resip::h_Identity).value()=="r5mwreLuyDRYBi/0TiPwEsY3rEVsk/G2WxhgTV1PF7hHuLIK0YWVKZhKv9Mj8UeXqkMVbnVq37CD+813gvYjcBUaZngQmXc9WNZSDNGCzA+fWl9MEUHWIZo1CeJebdY/XlgKeTa0Olvq0rt70Q5jiSfbqMJmQFteeivUhkMWYUA=");
 
2537
   tassert(msg->header(resip::h_Identity).numKnownParams()==0);
 
2538
   tassert(msg->header(resip::h_Identity).numUnknownParams()==0);
 
2539
   
 
2540
   //Contact: <sip:fluffy@127.0.0.1:5070>
 
2541
   tassert(msg->exists(resip::h_Contacts));
 
2542
   tassert(msg->header(resip::h_Contacts).size()==1);
 
2543
   resip::ParserContainer<resip::NameAddr>::iterator m=msg->header(resip::h_Contacts).begin();
 
2544
   
 
2545
   tassert(m->displayName()=="");
 
2546
   tassert(m->numKnownParams()==0);
 
2547
   tassert(m->numUnknownParams()==0);
 
2548
   tassert(!(m->isAllContacts()));
 
2549
   tassert(m->uri().numKnownParams()==0);
 
2550
   tassert(m->uri().numUnknownParams()==0);
 
2551
   tassert(m->uri().scheme()=="sip");
 
2552
   tassert(m->uri().user()=="fluffy");
 
2553
   tassert(m->uri().password().empty());
 
2554
   tassert(m->uri().host()=="127.0.0.1");
 
2555
   tassert(m->uri().port()==5070);
 
2556
   tassert(!(m->uri().hasEmbedded()));
 
2557
 
 
2558
   //To: <sip:kumiko@example.org>
 
2559
   tassert(msg->exists(resip::h_To));
 
2560
   tassert(msg->header(resip::h_To).displayName()=="");
 
2561
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
2562
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
2563
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
2564
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
2565
   tassert(msg->header(resip::h_To).uri().user()=="kumiko");
 
2566
   tassert(msg->header(resip::h_To).uri().password().empty());
 
2567
   tassert(msg->header(resip::h_To).uri().host()=="example.org");
 
2568
   tassert(msg->header(resip::h_To).uri().port()==0);
 
2569
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
2570
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
2571
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
2572
 
 
2573
   //From: <sip:fluffy@example.com>;tag=2fb0dcc9
 
2574
   tassert(msg->exists(resip::h_From));
 
2575
   tassert(msg->header(resip::h_From).displayName()=="");
 
2576
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
2577
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
2578
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
2579
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="2fb0dcc9");
 
2580
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
2581
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
2582
   tassert(msg->header(resip::h_From).uri().user()=="fluffy");
 
2583
   tassert(msg->header(resip::h_From).uri().password().empty());
 
2584
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
2585
   tassert(msg->header(resip::h_From).uri().port()==0);
 
2586
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
2587
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
2588
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
2589
 
 
2590
   //Call-ID: 3d9485ad0c49859b@Zmx1ZmZ5LW1hYy0xNi5sb2NhbA..
 
2591
   tassert(msg->exists(resip::h_CallID));
 
2592
   tassert(msg->header(resip::h_CallID).value()=="3d9485ad0c49859b@Zmx1ZmZ5LW1hYy0xNi5sb2NhbA..");
 
2593
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
2594
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
2595
 
 
2596
   //CSeq: 1 MESSAGE
 
2597
   tassert(msg->exists(resip::h_CSeq));
 
2598
   tassert(msg->header(resip::h_CSeq).method()==resip::MESSAGE);
 
2599
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="MESSAGE");
 
2600
   tassert(msg->header(resip::h_CSeq).sequence()==1);
 
2601
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
2602
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
2603
 
 
2604
   // .bwc. There appears to be some controversy over how this particular
 
2605
   // header should be implemented...
 
2606
   //Content-Transfer-Encoding: binary
 
2607
   tassert(msg->exists(resip::h_ContentTransferEncoding));
 
2608
   tassert(msg->header(resip::h_ContentTransferEncoding).value()=="binary");
 
2609
   tassert(msg->header(resip::h_ContentTransferEncoding).numKnownParams()==0);
 
2610
   tassert(msg->header(resip::h_ContentTransferEncoding).numUnknownParams()==0);
 
2611
   
 
2612
   //Content-Type: multipart/mixed;boundary=7a9cbec02ceef655
 
2613
   tassert(msg->exists(resip::h_ContentType));
 
2614
   tassert(msg->header(resip::h_ContentType).type()=="multipart");
 
2615
   tassert(msg->header(resip::h_ContentType).subType()=="mixed");
 
2616
   tassert(msg->header(resip::h_ContentType).numKnownParams()==1);
 
2617
   tassert(msg->header(resip::h_ContentType).numUnknownParams()==0);
 
2618
   
 
2619
   tassert(msg->header(resip::h_ContentType).exists(resip::p_boundary));
 
2620
   tassert(msg->header(resip::h_ContentType).param(resip::p_boundary)=="7a9cbec02ceef655");
 
2621
 
 
2622
   //Date: Sat, 15 Oct 2005 04:44:56 GMT
 
2623
   tassert(msg->exists(resip::h_Date));
 
2624
   tassert(msg->header(resip::h_Date).dayOfWeek()==resip::Sat);
 
2625
   tassert(msg->header(resip::h_Date).dayOfMonth()==15);
 
2626
   tassert(msg->header(resip::h_Date).month()==resip::Oct);
 
2627
   tassert(msg->header(resip::h_Date).year()==2005);
 
2628
   tassert(msg->header(resip::h_Date).hour()==4);
 
2629
   tassert(msg->header(resip::h_Date).minute()==44);
 
2630
   tassert(msg->header(resip::h_Date).second()==56);
 
2631
   tassert(msg->header(resip::h_Date).numKnownParams()==0);
 
2632
   tassert(msg->header(resip::h_Date).numUnknownParams()==0);
 
2633
   
 
2634
   //User-Agent: SIPimp.org/0.2.5 (curses)
 
2635
   tassert(msg->exists(resip::h_UserAgent));
 
2636
   tassert(msg->header(resip::h_UserAgent).value()=="SIPimp.org/0.2.5 (curses)");
 
2637
   tassert(msg->header(resip::h_UserAgent).numKnownParams()==0);
 
2638
   tassert(msg->header(resip::h_UserAgent).numUnknownParams()==0);
 
2639
   
 
2640
   //Content-Length: 553
 
2641
   tassert(msg->exists(resip::h_ContentLength));
 
2642
   tassert(msg->header(resip::h_ContentLength).value()==553);
 
2643
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
2644
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
2645
 
 
2646
 
 
2647
   InfoLog(<< "In case mpart01:" );
 
2648
   InfoLog(<< "Original text:" << std::endl << txt );
 
2649
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
2650
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
2651
 
 
2652
 
 
2653
 
 
2654
 
 
2655
}
 
2656
 
 
2657
 
 
2658
void
 
2659
unreason()
 
2660
{
 
2661
/*
 
2662
   This 200 response contains a reason phrase other than "OK".  The
 
2663
   reason phrase is intended for human consumption and may contain any
 
2664
   string produced by
 
2665
 
 
2666
       Reason-Phrase   =  *(reserved / unreserved / escaped
 
2667
                          / UTF8-NONASCII / UTF8-CONT / SP / HTAB)
 
2668
 
 
2669
   This particular response contains unreserved and non-ascii UTF-8
 
2670
   characters.  This response is well formed.  A parser must accept this
 
2671
   message.
 
2672
 
 
2673
 
 
2674
SIP/2.0 200 = 2**3 * 5**2 Š½Š¾ ŃŃ‚Š¾ Š“ŠµŠ²ŃŠ½Š¾ŃŃ‚Š¾ Š“ŠµŠ²ŃŃ‚ŃŒ - ŠæрŠ¾ŃŃ‚Š¾Šµ
 
2675
Via: SIP/2.0/UDP 192.0.2.198;branch=z9hG4bK1324923
 
2676
Call-ID: unreason.1234ksdfak3j2erwedfsASdf
 
2677
CSeq: 35 INVITE
 
2678
From: sip:user@example.com;tag=11141343
 
2679
To: sip:user@example.edu;tag=2229
 
2680
Content-Length: 154
 
2681
Content-Type: application/sdp
 
2682
Contact: <sip:user@host198.example.com>
 
2683
 
 
2684
v=0
 
2685
o=mhandley 29739 7272939 IN IP4 192.0.2.198
 
2686
s=-
 
2687
c=IN IP4 192.0.2.198
 
2688
t=0 0
 
2689
m=audio 49217 RTP/AVP 0 12
 
2690
m=video 3227 RTP/AVP 31
 
2691
a=rtpmap:31 LPC
 
2692
 
 
2693
*/
 
2694
   FILE* fid= fopen("unreason.dat","r");
 
2695
   tassert(fid);
 
2696
   resip::Data txt;
 
2697
   char mBuf[1024];
 
2698
   int result;
 
2699
   while(!feof(fid))
 
2700
   {
 
2701
      result = fread(&mBuf,1,1024,fid);
 
2702
      txt += resip::Data(mBuf,result);
 
2703
   }
 
2704
   fclose(fid);
 
2705
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
2706
   tassert_reset();
 
2707
   tassert(msg);
 
2708
   tassert_reset();
 
2709
   if(!msg)
 
2710
   {
 
2711
      return;
 
2712
   }
 
2713
 
 
2714
   std::auto_ptr<resip::SipMessage> message(msg);
 
2715
   msg->parseAllHeaders();
 
2716
 
 
2717
   resip::SipMessage copy(*msg);
 
2718
 
 
2719
   resip::Data encoded;
 
2720
   {
 
2721
      resip::oDataStream str(encoded);
 
2722
      msg->encode(str);
 
2723
   }
 
2724
   resip::Data copyEncoded;
 
2725
   {
 
2726
      resip::oDataStream str(copyEncoded);
 
2727
      copy.encode(str);
 
2728
   }
 
2729
   
 
2730
   //Status Line
 
2731
   //SIP/2.0 200 = 2**3 * 5**2 Š½Š¾ ŃŃ‚Š¾ Š“ŠµŠ²ŃŠ½Š¾ŃŃ‚Š¾ Š“ŠµŠ²ŃŃ‚ŃŒ - ŠæрŠ¾ŃŃ‚Š¾Šµ
 
2732
   tassert(msg->header(resip::h_StatusLine).responseCode()==200);
 
2733
   tassert(msg->header(resip::h_StatusLine).getSipVersion()=="SIP/2.0");
 
2734
   
 
2735
   resip::Data binaryReason("= 2**3 * 5**2 ");
 
2736
   binaryReason+=(char)0xD0;
 
2737
   binaryReason+=(char)0xBD;
 
2738
   binaryReason+=(char)0xD0;
 
2739
   binaryReason+=(char)0xBE;
 
2740
   binaryReason+=(char)0x20;
 
2741
   binaryReason+=(char)0xD1;
 
2742
   binaryReason+=(char)0x81;
 
2743
   binaryReason+=(char)0xD1;
 
2744
   binaryReason+=(char)0x82;
 
2745
   binaryReason+=(char)0xD0;
 
2746
   binaryReason+=(char)0xBE;
 
2747
   binaryReason+=(char)0x20;
 
2748
   binaryReason+=(char)0xD0;
 
2749
   binaryReason+=(char)0xB4;
 
2750
   binaryReason+=(char)0xD0;
 
2751
   binaryReason+=(char)0xB5;
 
2752
   binaryReason+=(char)0xD0;
 
2753
   binaryReason+=(char)0xB2;
 
2754
   binaryReason+=(char)0xD1;
 
2755
   binaryReason+=(char)0x8F;
 
2756
   binaryReason+=(char)0xD0;
 
2757
   binaryReason+=(char)0xBD;
 
2758
   binaryReason+=(char)0xD0;
 
2759
   binaryReason+=(char)0xBE;
 
2760
   binaryReason+=(char)0xD1;
 
2761
   binaryReason+=(char)0x81;
 
2762
   binaryReason+=(char)0xD1;
 
2763
   binaryReason+=(char)0x82;
 
2764
   binaryReason+=(char)0xD0;
 
2765
   binaryReason+=(char)0xBE;
 
2766
   binaryReason+=(char)0x20;
 
2767
   binaryReason+=(char)0xD0;
 
2768
   binaryReason+=(char)0xB4;
 
2769
   binaryReason+=(char)0xD0;
 
2770
   binaryReason+=(char)0xB5;
 
2771
   binaryReason+=(char)0xD0;
 
2772
   binaryReason+=(char)0xB2;
 
2773
   binaryReason+=(char)0xD1;
 
2774
   binaryReason+=(char)0x8F;
 
2775
   binaryReason+=(char)0xD1;
 
2776
   binaryReason+=(char)0x82;
 
2777
   binaryReason+=(char)0xD1;
 
2778
   binaryReason+=(char)0x8C;
 
2779
   binaryReason+=(char)0x20;
 
2780
   binaryReason+=(char)0x2D;
 
2781
   binaryReason+=(char)0x20;
 
2782
   binaryReason+=(char)0xD0;
 
2783
   binaryReason+=(char)0xBF;
 
2784
   binaryReason+=(char)0xD1;
 
2785
   binaryReason+=(char)0x80;
 
2786
   binaryReason+=(char)0xD0;
 
2787
   binaryReason+=(char)0xBE;
 
2788
   binaryReason+=(char)0xD1;
 
2789
   binaryReason+=(char)0x81;
 
2790
   binaryReason+=(char)0xD1;
 
2791
   binaryReason+=(char)0x82;
 
2792
   binaryReason+=(char)0xD0;
 
2793
   binaryReason+=(char)0xBE;
 
2794
   binaryReason+=(char)0xD0;
 
2795
   binaryReason+=(char)0xB5;   
 
2796
   tassert(msg->header(resip::h_StatusLine).reason()==binaryReason);
 
2797
   
 
2798
   //Vias
 
2799
   tassert(msg->exists(resip::h_Vias));
 
2800
   tassert(msg->header(resip::h_Vias).size()==1);
 
2801
   resip::ParserContainer<resip::Via>::iterator v=msg->header(resip::h_Vias).begin();
 
2802
 
 
2803
   //Via: SIP/2.0/UDP 192.0.2.198;branch=z9hG4bK1324923
 
2804
   tassert(v->numKnownParams()==1);
 
2805
   tassert(v->numUnknownParams()==0);
 
2806
   tassert(v->protocolName()=="SIP");
 
2807
   tassert(v->protocolVersion()=="2.0");
 
2808
   tassert(v->transport()=="UDP");
 
2809
   tassert(v->sentHost()=="192.0.2.198");
 
2810
   tassert(v->sentPort()==0);
 
2811
   
 
2812
   tassert(v->exists(resip::p_branch));
 
2813
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
2814
   tassert(v->param(resip::p_branch).getTransactionId()=="1324923");
 
2815
   tassert(v->param(resip::p_branch).clientData().empty());
 
2816
   
 
2817
   //Call-ID: unreason.1234ksdfak3j2erwedfsASdf
 
2818
   tassert(msg->exists(resip::h_CallID));
 
2819
   tassert(msg->header(resip::h_CallID).value()=="unreason.1234ksdfak3j2erwedfsASdf");
 
2820
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
2821
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
2822
 
 
2823
   //CSeq: 35 INVITE
 
2824
   tassert(msg->exists(resip::h_CSeq));
 
2825
   tassert(msg->header(resip::h_CSeq).method()==resip::INVITE);
 
2826
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="INVITE");
 
2827
   tassert(msg->header(resip::h_CSeq).sequence()==35);
 
2828
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
2829
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
2830
 
 
2831
   //From: sip:user@example.com;tag=11141343
 
2832
   tassert(msg->exists(resip::h_From));
 
2833
   tassert(msg->header(resip::h_From).displayName()=="");
 
2834
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
2835
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
2836
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
2837
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="11141343");
 
2838
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
2839
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
2840
   tassert(msg->header(resip::h_From).uri().user()=="user");
 
2841
   tassert(msg->header(resip::h_From).uri().password().empty());
 
2842
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
2843
   tassert(msg->header(resip::h_From).uri().port()==0);
 
2844
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
2845
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
2846
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
2847
 
 
2848
   //To: sip:user@example.edu;tag=2229
 
2849
   tassert(msg->exists(resip::h_To));
 
2850
   tassert(msg->header(resip::h_To).displayName()=="");
 
2851
   tassert(msg->header(resip::h_To).numKnownParams()==1);
 
2852
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
2853
   tassert(msg->header(resip::h_To).exists(resip::p_tag));
 
2854
   tassert(msg->header(resip::h_To).param(resip::p_tag)=="2229");
 
2855
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
2856
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
2857
   tassert(msg->header(resip::h_To).uri().user()=="user");
 
2858
   tassert(msg->header(resip::h_To).uri().password().empty());
 
2859
   tassert(msg->header(resip::h_To).uri().host()=="example.edu");
 
2860
   tassert(msg->header(resip::h_To).uri().port()==0);
 
2861
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
2862
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
2863
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
2864
 
 
2865
   //Content-Length: 154
 
2866
   tassert(msg->exists(resip::h_ContentLength));
 
2867
   tassert(msg->header(resip::h_ContentLength).value()==154);
 
2868
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
2869
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
2870
 
 
2871
   //Content-Type: application/sdp
 
2872
   tassert(msg->exists(resip::h_ContentType));
 
2873
   tassert(msg->header(resip::h_ContentType).type()=="application");
 
2874
   tassert(msg->header(resip::h_ContentType).subType()=="sdp");
 
2875
   tassert(msg->header(resip::h_ContentType).numKnownParams()==0);
 
2876
   tassert(msg->header(resip::h_ContentType).numUnknownParams()==0);
 
2877
 
 
2878
   //Contact: <sip:user@host198.example.com>
 
2879
   tassert(msg->exists(resip::h_Contacts));
 
2880
   tassert(msg->header(resip::h_Contacts).size()==1);
 
2881
   resip::ParserContainer<resip::NameAddr>::iterator m=msg->header(resip::h_Contacts).begin();
 
2882
   
 
2883
   tassert(m->displayName()=="");
 
2884
   tassert(m->numKnownParams()==0);
 
2885
   tassert(m->numUnknownParams()==0);
 
2886
   tassert(!(m->isAllContacts()));
 
2887
   tassert(m->uri().numKnownParams()==0);
 
2888
   tassert(m->uri().numUnknownParams()==0);
 
2889
   tassert(m->uri().scheme()=="sip");
 
2890
   tassert(m->uri().user()=="user");
 
2891
   tassert(m->uri().password().empty());
 
2892
   tassert(m->uri().host()=="host198.example.com");
 
2893
   tassert(m->uri().port()==0);
 
2894
   tassert(!(m->uri().hasEmbedded()));
 
2895
 
 
2896
 
 
2897
   InfoLog(<< "In case unreason:" );
 
2898
   InfoLog(<< "Original text:" << std::endl << txt );
 
2899
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
2900
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
2901
 
 
2902
 
 
2903
 
 
2904
 
 
2905
}
 
2906
 
 
2907
 
 
2908
void
 
2909
noreason()
 
2910
{
 
2911
/*
 
2912
 
 
2913
   This well-formed response contains no reason phrase.  A parser must
 
2914
   accept this message.  The space character after the reason code is
 
2915
   required.  If it were not present, this message could be rejected as
 
2916
   invalid (a liberal receiver would accept it anyway).
 
2917
 
 
2918
SIP/2.0 100 
 
2919
Via: SIP/2.0/UDP 192.0.2.105;branch=z9hG4bK2398ndaoe
 
2920
Call-ID: noreason.asndj203insdf99223ndf
 
2921
CSeq: 35 INVITE
 
2922
From: <sip:user@example.com>;tag=39ansfi3
 
2923
To: <sip:user@example.edu>;tag=902jndnke3
 
2924
Content-Length: 0
 
2925
Contact: <sip:user@host105.example.com>
 
2926
 
 
2927
 
 
2928
*/
 
2929
   FILE* fid= fopen("noreason.dat","r");
 
2930
   tassert(fid);
 
2931
   resip::Data txt;
 
2932
   char mBuf[1024];
 
2933
   int result;
 
2934
   while(!feof(fid))
 
2935
   {
 
2936
      result = fread(&mBuf,1,1024,fid);
 
2937
      txt += resip::Data(mBuf,result);
 
2938
   }
 
2939
   fclose(fid);
 
2940
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
2941
   tassert_reset();
 
2942
   tassert(msg);
 
2943
   tassert_reset();
 
2944
   if(!msg)
 
2945
   {
 
2946
      return;
 
2947
   }
 
2948
 
 
2949
   std::auto_ptr<resip::SipMessage> message(msg);
 
2950
   msg->parseAllHeaders();
 
2951
 
 
2952
   resip::SipMessage copy(*msg);
 
2953
 
 
2954
   resip::Data encoded;
 
2955
   {
 
2956
      resip::oDataStream str(encoded);
 
2957
      msg->encode(str);
 
2958
   }
 
2959
   resip::Data copyEncoded;
 
2960
   {
 
2961
      resip::oDataStream str(copyEncoded);
 
2962
      copy.encode(str);
 
2963
   }
 
2964
 
 
2965
   //Status Line
 
2966
   //SIP/2.0 100 
 
2967
   tassert(msg->header(resip::h_StatusLine).responseCode()==100);
 
2968
   tassert(msg->header(resip::h_StatusLine).getSipVersion()=="SIP/2.0");
 
2969
   tassert(msg->header(resip::h_StatusLine).reason()=="");
 
2970
 
 
2971
   //Vias
 
2972
   tassert(msg->exists(resip::h_Vias));
 
2973
   tassert(msg->header(resip::h_Vias).size()==1);
 
2974
   resip::ParserContainer<resip::Via>::iterator v=msg->header(resip::h_Vias).begin();
 
2975
 
 
2976
   //Via: SIP/2.0/UDP 192.0.2.105;branch=z9hG4bK2398ndaoe
 
2977
   tassert(v->numKnownParams()==1);
 
2978
   tassert(v->numUnknownParams()==0);
 
2979
   tassert(v->protocolName()=="SIP");
 
2980
   tassert(v->protocolVersion()=="2.0");
 
2981
   tassert(v->transport()=="UDP");
 
2982
   tassert(v->sentHost()=="192.0.2.105");
 
2983
   tassert(v->sentPort()==0);
 
2984
   
 
2985
   tassert(v->exists(resip::p_branch));
 
2986
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
2987
   tassert(v->param(resip::p_branch).getTransactionId()=="2398ndaoe");
 
2988
   tassert(v->param(resip::p_branch).clientData().empty());
 
2989
 
 
2990
   //Call-ID: noreason.asndj203insdf99223ndf
 
2991
   tassert(msg->exists(resip::h_CallID));
 
2992
   tassert(msg->header(resip::h_CallID).value()=="noreason.asndj203insdf99223ndf");
 
2993
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
2994
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
2995
 
 
2996
   //CSeq: 35 INVITE
 
2997
   tassert(msg->exists(resip::h_CSeq));
 
2998
   tassert(msg->header(resip::h_CSeq).method()==resip::INVITE);
 
2999
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="INVITE");
 
3000
   tassert(msg->header(resip::h_CSeq).sequence()==35);
 
3001
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
3002
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
3003
 
 
3004
   //From: <sip:user@example.com>;tag=39ansfi3
 
3005
   tassert(msg->exists(resip::h_From));
 
3006
   tassert(msg->header(resip::h_From).displayName()=="");
 
3007
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
3008
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
3009
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
3010
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="39ansfi3");
 
3011
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
3012
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
3013
   tassert(msg->header(resip::h_From).uri().user()=="user");
 
3014
   tassert(msg->header(resip::h_From).uri().password().empty());
 
3015
   tassert(msg->header(resip::h_From).uri().host()=="example.com");
 
3016
   tassert(msg->header(resip::h_From).uri().port()==0);
 
3017
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
3018
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
3019
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
3020
 
 
3021
   //To: <sip:user@example.edu>;tag=902jndnke3
 
3022
   tassert(msg->exists(resip::h_To));
 
3023
   tassert(msg->header(resip::h_To).displayName()=="");
 
3024
   tassert(msg->header(resip::h_To).numKnownParams()==1);
 
3025
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
3026
   tassert(msg->header(resip::h_To).exists(resip::p_tag));
 
3027
   tassert(msg->header(resip::h_To).param(resip::p_tag)=="902jndnke3");
 
3028
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
3029
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
3030
   tassert(msg->header(resip::h_To).uri().user()=="user");
 
3031
   tassert(msg->header(resip::h_To).uri().password().empty());
 
3032
   tassert(msg->header(resip::h_To).uri().host()=="example.edu");
 
3033
   tassert(msg->header(resip::h_To).uri().port()==0);
 
3034
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
3035
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
3036
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
3037
 
 
3038
   //Content-Length: 0
 
3039
   tassert(msg->exists(resip::h_ContentLength));
 
3040
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
3041
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
3042
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
3043
 
 
3044
   //Contact: <sip:user@host105.example.com>
 
3045
   tassert(msg->exists(resip::h_Contacts));
 
3046
   tassert(msg->header(resip::h_Contacts).size()==1);
 
3047
   resip::ParserContainer<resip::NameAddr>::iterator m=msg->header(resip::h_Contacts).begin();
 
3048
   
 
3049
   tassert(m->displayName()=="");
 
3050
   tassert(m->numKnownParams()==0);
 
3051
   tassert(m->numUnknownParams()==0);
 
3052
   tassert(!(m->isAllContacts()));
 
3053
   tassert(m->uri().numKnownParams()==0);
 
3054
   tassert(m->uri().numUnknownParams()==0);
 
3055
   tassert(m->uri().scheme()=="sip");
 
3056
   tassert(m->uri().user()=="user");
 
3057
   tassert(m->uri().password().empty());
 
3058
   tassert(m->uri().host()=="host105.example.com");
 
3059
   tassert(m->uri().port()==0);
 
3060
   tassert(!(m->uri().hasEmbedded()));
 
3061
 
 
3062
 
 
3063
   InfoLog(<< "In case noreason:" );
 
3064
   InfoLog(<< "Original text:" << std::endl << txt );
 
3065
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3066
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3067
 
 
3068
 
 
3069
 
 
3070
 
 
3071
}
 
3072
 
 
3073
 
 
3074
void
 
3075
badinv01()
 
3076
{
 
3077
/*
 
3078
 
 
3079
   The Via header field of this request contains additional semicolons
 
3080
   and commas without parameters or values.  The Contact header field
 
3081
   contains additional semicolons without parameters.  This message is
 
3082
   syntactically invalid.
 
3083
 
 
3084
   An element receiving this request should respond with a 400 Bad
 
3085
   Request error.
 
3086
 
 
3087
INVITE sip:user@example.com SIP/2.0
 
3088
To: sip:j.user@example.com
 
3089
From: sip:caller@example.net;tag=134161461246
 
3090
Max-Forwards: 7
 
3091
Call-ID: badinv01.0ha0isndaksdjasdf3234nas
 
3092
CSeq: 8 INVITE
 
3093
Via: SIP/2.0/UDP 192.0.2.15;;,;,,
 
3094
Contact: "Joe" <sip:joe@example.org>;;;;
 
3095
Content-Length: 152
 
3096
Content-Type: application/sdp
 
3097
 
 
3098
v=0
 
3099
o=mhandley 29739 7272939 IN IP4 192.0.2.15
 
3100
s=-
 
3101
c=IN IP4 192.0.2.15
 
3102
t=0 0
 
3103
m=audio 49217 RTP/AVP 0 12
 
3104
m=video 3227 RTP/AVP 31
 
3105
a=rtpmap:31 LPC
 
3106
 
 
3107
*/
 
3108
   FILE* fid= fopen("badinv01.dat","r");
 
3109
   tassert(fid);
 
3110
   resip::Data txt;
 
3111
   char mBuf[1024];
 
3112
   int result;
 
3113
   while(!feof(fid))
 
3114
   {
 
3115
      result = fread(&mBuf,1,1024,fid);
 
3116
      txt += resip::Data(mBuf,result);
 
3117
   }
 
3118
   fclose(fid);
 
3119
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3120
   tassert_reset();
 
3121
   if(!msg)
 
3122
   {
 
3123
      return;
 
3124
   }
 
3125
 
 
3126
   std::auto_ptr<resip::SipMessage> message(msg);
 
3127
   msg->parseAllHeaders();
 
3128
 
 
3129
   resip::SipMessage copy(*msg);
 
3130
 
 
3131
   resip::Data encoded;
 
3132
   {
 
3133
      resip::oDataStream str(encoded);
 
3134
      msg->encode(str);
 
3135
   }
 
3136
   resip::Data copyEncoded;
 
3137
   {
 
3138
      resip::oDataStream str(copyEncoded);
 
3139
      copy.encode(str);
 
3140
   }
 
3141
 
 
3142
   InfoLog(<< "In case badinv01:" );
 
3143
   InfoLog(<< "Original text:" << std::endl << txt );
 
3144
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3145
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3146
 
 
3147
 
 
3148
 
 
3149
 
 
3150
}
 
3151
 
 
3152
 
 
3153
void
 
3154
clerr()
 
3155
{
 
3156
/*
 
3157
 
 
3158
   This is a request message with a Content Length that is larger than
 
3159
   the actual length of the body.
 
3160
 
 
3161
   When sent over UDP (as this message ostensibly was), the receiving
 
3162
   element should respond with a 400 Bad Request error.  If this message
 
3163
   arrived over a stream-based transport, such as TCP, there's not much
 
3164
   the receiving party could do but wait for more data on the stream and
 
3165
   close the connection if none is forthcoming within a reasonable
 
3166
   period of time.
 
3167
 
 
3168
INVITE sip:user@example.com SIP/2.0
 
3169
Max-Forwards: 80
 
3170
To: sip:j.user@example.com
 
3171
From: sip:caller@example.net;tag=93942939o2
 
3172
Contact: <sip:caller@hungry.example.net>
 
3173
Call-ID: clerr.0ha0isndaksdjweiafasdk3
 
3174
CSeq: 8 INVITE
 
3175
Via: SIP/2.0/UDP host5.example.com;branch=z9hG4bK-39234-23523
 
3176
Content-Type: application/sdp
 
3177
Content-Length: 9999
 
3178
 
 
3179
v=0
 
3180
o=mhandley 29739 7272939 IN IP4 192.0.2.155
 
3181
s=-
 
3182
c=IN IP4 192.0.2.155
 
3183
t=0 0
 
3184
m=audio 49217 RTP/AVP 0 12
 
3185
m=video 3227 RTP/AVP 31
 
3186
a=rtpmap:31 LPC
 
3187
 
 
3188
*/
 
3189
   FILE* fid= fopen("clerr.dat","r");
 
3190
   tassert(fid);
 
3191
   resip::Data txt;
 
3192
   char mBuf[1024];
 
3193
   int result;
 
3194
   while(!feof(fid))
 
3195
   {
 
3196
      result = fread(&mBuf,1,1024,fid);
 
3197
      txt += resip::Data(mBuf,result);
 
3198
   }
 
3199
   fclose(fid);
 
3200
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3201
   tassert_reset();
 
3202
 
 
3203
   if(!msg)
 
3204
   {
 
3205
      return;
 
3206
   }
 
3207
 
 
3208
   std::auto_ptr<resip::SipMessage> message(msg);
 
3209
   msg->parseAllHeaders();
 
3210
 
 
3211
   resip::SipMessage copy(*msg);
 
3212
 
 
3213
   resip::Data encoded;
 
3214
   {
 
3215
      resip::oDataStream str(encoded);
 
3216
      msg->encode(str);
 
3217
   }
 
3218
   resip::Data copyEncoded;
 
3219
   {
 
3220
      resip::oDataStream str(copyEncoded);
 
3221
      copy.encode(str);
 
3222
   }
 
3223
 
 
3224
   InfoLog(<< "In case clerr:" );
 
3225
   InfoLog(<< "Original text:" << std::endl << txt );
 
3226
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3227
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3228
 
 
3229
 
 
3230
 
 
3231
 
 
3232
}
 
3233
 
 
3234
 
 
3235
void
 
3236
ncl()
 
3237
{
 
3238
/*
 
3239
 
 
3240
   This request has a negative value for Content-Length.
 
3241
 
 
3242
   An element receiving this message should respond with an error.  This
 
3243
   request appeared over UDP, so the remainder of the datagram can
 
3244
   simply be discarded.  If a request like this arrives over TCP, the
 
3245
   framing error is not recoverable, and the connection should be
 
3246
   closed.  The same behavior is appropriate for messages that arrive
 
3247
   without a numeric value in the Content-Length header field, such as
 
3248
   the following:
 
3249
 
 
3250
      Content-Length: five
 
3251
 
 
3252
   Implementors should take extra precautions if the technique they
 
3253
   choose for converting this ascii field into an integral form can
 
3254
   return a negative value.  In particular, the result must not be used
 
3255
   as a counter or array index.
 
3256
 
 
3257
 
 
3258
INVITE sip:user@example.com SIP/2.0
 
3259
Max-Forwards: 254
 
3260
To: sip:j.user@example.com
 
3261
From: sip:caller@example.net;tag=32394234
 
3262
Call-ID: ncl.0ha0isndaksdj2193423r542w35
 
3263
CSeq: 0 INVITE
 
3264
Via: SIP/2.0/UDP 192.0.2.53;branch=z9hG4bKkdjuw
 
3265
Contact: <sip:caller@example53.example.net>
 
3266
Content-Type: application/sdp
 
3267
Content-Length: -999
 
3268
 
 
3269
v=0
 
3270
o=mhandley 29739 7272939 IN IP4 192.0.2.53
 
3271
s=-
 
3272
c=IN IP4 192.0.2.53
 
3273
t=0 0
 
3274
m=audio 49217 RTP/AVP 0 12
 
3275
m=video 3227 RTP/AVP 31
 
3276
a=rtpmap:31 LPC
 
3277
 
 
3278
*/
 
3279
   FILE* fid= fopen("ncl.dat","r");
 
3280
   tassert(fid);
 
3281
   resip::Data txt;
 
3282
   char mBuf[1024];
 
3283
   int result;
 
3284
   while(!feof(fid))
 
3285
   {
 
3286
      result = fread(&mBuf,1,1024,fid);
 
3287
      txt += resip::Data(mBuf,result);
 
3288
   }
 
3289
   fclose(fid);
 
3290
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3291
   tassert_reset();
 
3292
   if(!msg)
 
3293
   {
 
3294
      return;
 
3295
   }
 
3296
 
 
3297
   std::auto_ptr<resip::SipMessage> message(msg);
 
3298
   msg->parseAllHeaders();
 
3299
 
 
3300
   resip::SipMessage copy(*msg);
 
3301
 
 
3302
   resip::Data encoded;
 
3303
   {
 
3304
      resip::oDataStream str(encoded);
 
3305
      msg->encode(str);
 
3306
   }
 
3307
   resip::Data copyEncoded;
 
3308
   {
 
3309
      resip::oDataStream str(copyEncoded);
 
3310
      copy.encode(str);
 
3311
   }
 
3312
 
 
3313
   InfoLog(<< "In case ncl:" );
 
3314
   InfoLog(<< "Original text:" << std::endl << txt );
 
3315
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3316
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3317
 
 
3318
 
 
3319
 
 
3320
 
 
3321
}
 
3322
 
 
3323
 
 
3324
void
 
3325
scalar02()
 
3326
{
 
3327
/*
 
3328
 
 
3329
   This request contains several scalar header field values outside
 
3330
   their legal range.
 
3331
 
 
3332
      o  The CSeq sequence number is >2**32-1.
 
3333
 
 
3334
      o  The Max-Forwards value is >255.
 
3335
 
 
3336
      o  The Expires value is >2**32-1.
 
3337
 
 
3338
      o  The Contact expires parameter value is >2**32-1.
 
3339
 
 
3340
   An element receiving this request should respond with a 400 Bad
 
3341
   Request due to the CSeq error.  If only the Max-Forwards field were
 
3342
   in error, the element could choose to process the request as if the
 
3343
   field were absent.  If only the expiry values were in error, the
 
3344
   element could treat them as if they contained the default values for
 
3345
   expiration (3600 in this case).
 
3346
 
 
3347
   Other scalar request fields that may contain aberrant values include,
 
3348
   but are not limited to, the Contact q value, the Timestamp value, and
 
3349
   the Via ttl parameter.
 
3350
 
 
3351
 
 
3352
REGISTER sip:example.com SIP/2.0
 
3353
Via: SIP/2.0/TCP host129.example.com;branch=z9hG4bK342sdfoi3
 
3354
To: <sip:user@example.com>
 
3355
From: <sip:user@example.com>;tag=239232jh3
 
3356
CSeq: 36893488147419103232 REGISTER
 
3357
Call-ID: scalar02.23o0pd9vanlq3wnrlnewofjas9ui32
 
3358
Max-Forwards: 300
 
3359
Expires: 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 
3360
Contact: <sip:user@host129.example.com>
 
3361
  ;expires=280297596632815
 
3362
Content-Length: 0
 
3363
 
 
3364
 
 
3365
*/
 
3366
   FILE* fid= fopen("scalar02.dat","r");
 
3367
   tassert(fid);
 
3368
   resip::Data txt;
 
3369
   char mBuf[1024];
 
3370
   int result;
 
3371
   while(!feof(fid))
 
3372
   {
 
3373
      result = fread(&mBuf,1,1024,fid);
 
3374
      txt += resip::Data(mBuf,result);
 
3375
   }
 
3376
   fclose(fid);
 
3377
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3378
   tassert_reset();
 
3379
   if(!msg)
 
3380
   {
 
3381
      return;
 
3382
   }
 
3383
 
 
3384
   std::auto_ptr<resip::SipMessage> message(msg);
 
3385
   msg->parseAllHeaders();
 
3386
 
 
3387
   resip::SipMessage copy(*msg);
 
3388
 
 
3389
   resip::Data encoded;
 
3390
   {
 
3391
      resip::oDataStream str(encoded);
 
3392
      msg->encode(str);
 
3393
   }
 
3394
   resip::Data copyEncoded;
 
3395
   {
 
3396
      resip::oDataStream str(copyEncoded);
 
3397
      copy.encode(str);
 
3398
   }
 
3399
 
 
3400
   InfoLog(<< "In case scalar02:" );
 
3401
   InfoLog(<< "Original text:" << std::endl << txt );
 
3402
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3403
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3404
 
 
3405
 
 
3406
 
 
3407
 
 
3408
}
 
3409
 
 
3410
 
 
3411
void
 
3412
scalarlg()
 
3413
{
 
3414
/*
 
3415
 
 
3416
   This response contains several scalar header field values outside
 
3417
   their legal range.
 
3418
 
 
3419
   o  The CSeq sequence number is >2**32-1.
 
3420
 
 
3421
   o  The Retry-After field is unreasonably large (note that RFC 3261
 
3422
      does not define a legal range for this field).
 
3423
 
 
3424
   o  The Warning field has a warning-value with more than 3 digits.
 
3425
 
 
3426
   An element receiving this response will simply discard it.
 
3427
 
 
3428
SIP/2.0 503 Service Unavailable
 
3429
Via: SIP/2.0/TCP host129.example.com;branch=z9hG4bKzzxdiwo34sw;received=192.0.2.129
 
3430
To: <sip:user@example.com>
 
3431
From: <sip:other@example.net>;tag=2easdjfejw
 
3432
CSeq: 9292394834772304023312 OPTIONS
 
3433
Call-ID: scalarlg.noase0of0234hn2qofoaf0232aewf2394r
 
3434
Retry-After: 949302838503028349304023988
 
3435
Warning: 1812 overture "In Progress"
 
3436
Content-Length: 0
 
3437
 
 
3438
 
 
3439
*/
 
3440
   FILE* fid= fopen("scalarlg.dat","r");
 
3441
   tassert(fid);
 
3442
   resip::Data txt;
 
3443
   char mBuf[1024];
 
3444
   int result;
 
3445
   while(!feof(fid))
 
3446
   {
 
3447
      result = fread(&mBuf,1,1024,fid);
 
3448
      txt += resip::Data(mBuf,result);
 
3449
   }
 
3450
   fclose(fid);
 
3451
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3452
   tassert_reset();
 
3453
   if(!msg)
 
3454
   {
 
3455
      return;
 
3456
   }
 
3457
 
 
3458
   std::auto_ptr<resip::SipMessage> message(msg);
 
3459
   msg->parseAllHeaders();
 
3460
 
 
3461
   resip::SipMessage copy(*msg);
 
3462
 
 
3463
   resip::Data encoded;
 
3464
   {
 
3465
      resip::oDataStream str(encoded);
 
3466
      msg->encode(str);
 
3467
   }
 
3468
   resip::Data copyEncoded;
 
3469
   {
 
3470
      resip::oDataStream str(copyEncoded);
 
3471
      copy.encode(str);
 
3472
   }
 
3473
 
 
3474
   InfoLog(<< "In case scalarlg:" );
 
3475
   InfoLog(<< "Original text:" << std::endl << txt );
 
3476
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3477
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3478
 
 
3479
 
 
3480
 
 
3481
 
 
3482
}
 
3483
 
 
3484
 
 
3485
void
 
3486
quotbal()
 
3487
{
 
3488
/*
 
3489
 
 
3490
   This is a request with an unterminated quote in the display name of
 
3491
   the To field.  An element receiving this request should return a 400
 
3492
   Bad Request error.
 
3493
 
 
3494
   An element could attempt to infer a terminating quote and accept the
 
3495
   message.  Such an element needs to take care that it makes a
 
3496
   reasonable inference when it encounters
 
3497
 
 
3498
      To: "Mr J. User <sip:j.user@example.com> <sip:realj@example.net>
 
3499
 
 
3500
INVITE sip:user@example.com SIP/2.0
 
3501
To: "Mr. J. User <sip:j.user@example.com>
 
3502
From: sip:caller@example.net;tag=93334
 
3503
Max-Forwards: 10
 
3504
Call-ID: quotbal.aksdj
 
3505
Contact: <sip:caller@host59.example.net>
 
3506
CSeq: 8 INVITE
 
3507
Via: SIP/2.0/UDP 192.0.2.59:5050;branch=z9hG4bKkdjuw39234
 
3508
Content-Type: application/sdp
 
3509
Content-Length: 152
 
3510
 
 
3511
v=0
 
3512
o=mhandley 29739 7272939 IN IP4 192.0.2.15
 
3513
s=-
 
3514
c=IN IP4 192.0.2.15
 
3515
t=0 0
 
3516
m=audio 49217 RTP/AVP 0 12
 
3517
m=video 3227 RTP/AVP 31
 
3518
a=rtpmap:31 LPC
 
3519
 
 
3520
*/
 
3521
   FILE* fid= fopen("quotbal.dat","r");
 
3522
   tassert(fid);
 
3523
   resip::Data txt;
 
3524
   char mBuf[1024];
 
3525
   int result;
 
3526
   while(!feof(fid))
 
3527
   {
 
3528
      result = fread(&mBuf,1,1024,fid);
 
3529
      txt += resip::Data(mBuf,result);
 
3530
   }
 
3531
   fclose(fid);
 
3532
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3533
   tassert_reset();
 
3534
   if(!msg)
 
3535
   {
 
3536
      return;
 
3537
   }
 
3538
 
 
3539
   std::auto_ptr<resip::SipMessage> message(msg);
 
3540
   msg->parseAllHeaders();
 
3541
 
 
3542
   resip::SipMessage copy(*msg);
 
3543
 
 
3544
   resip::Data encoded;
 
3545
   {
 
3546
      resip::oDataStream str(encoded);
 
3547
      msg->encode(str);
 
3548
   }
 
3549
   resip::Data copyEncoded;
 
3550
   {
 
3551
      resip::oDataStream str(copyEncoded);
 
3552
      copy.encode(str);
 
3553
   }
 
3554
 
 
3555
   InfoLog(<< "In case quotbal:" );
 
3556
   InfoLog(<< "Original text:" << std::endl << txt );
 
3557
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3558
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3559
 
 
3560
 
 
3561
 
 
3562
 
 
3563
}
 
3564
 
 
3565
 
 
3566
void
 
3567
ltgtruri()
 
3568
{
 
3569
/*
 
3570
 
 
3571
   This INVITE request is invalid because the Request-URI has been
 
3572
   enclosed within in "<>".
 
3573
 
 
3574
   It is reasonable always to reject a request with this error with a
 
3575
   400 Bad Request.  Elements attempting to be liberal with what they
 
3576
   accept may choose to ignore the brackets.  If the element forwards
 
3577
   the request, it must not include the brackets in the messages it
 
3578
   sends.
 
3579
 
 
3580
INVITE <sip:user@example.com> SIP/2.0
 
3581
To: sip:user@example.com
 
3582
From: sip:caller@example.net;tag=39291
 
3583
Max-Forwards: 23
 
3584
Call-ID: ltgtruri.1@192.0.2.5
 
3585
CSeq: 1 INVITE
 
3586
Via: SIP/2.0/UDP 192.0.2.5
 
3587
Contact: <sip:caller@host5.example.net>
 
3588
Content-Type: application/sdp
 
3589
Content-Length: 159
 
3590
 
 
3591
v=0
 
3592
o=mhandley 29739 7272939 IN IP4 192.0.2.5
 
3593
s=-
 
3594
c=IN IP4 192.0.2.5
 
3595
t=3149328700 0
 
3596
m=audio 49217 RTP/AVP 0 12
 
3597
m=video 3227 RTP/AVP 31
 
3598
a=rtpmap:31 LPC
 
3599
 
 
3600
*/
 
3601
   FILE* fid= fopen("ltgtruri.dat","r");
 
3602
   tassert(fid);
 
3603
   resip::Data txt;
 
3604
   char mBuf[1024];
 
3605
   int result;
 
3606
   while(!feof(fid))
 
3607
   {
 
3608
      result = fread(&mBuf,1,1024,fid);
 
3609
      txt += resip::Data(mBuf,result);
 
3610
   }
 
3611
   fclose(fid);
 
3612
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3613
   tassert_reset();
 
3614
   if(!msg)
 
3615
   {
 
3616
      return;
 
3617
   }
 
3618
 
 
3619
   std::auto_ptr<resip::SipMessage> message(msg);
 
3620
   msg->parseAllHeaders();
 
3621
 
 
3622
   resip::SipMessage copy(*msg);
 
3623
 
 
3624
   resip::Data encoded;
 
3625
   {
 
3626
      resip::oDataStream str(encoded);
 
3627
      msg->encode(str);
 
3628
   }
 
3629
   resip::Data copyEncoded;
 
3630
   {
 
3631
      resip::oDataStream str(copyEncoded);
 
3632
      copy.encode(str);
 
3633
   }
 
3634
 
 
3635
   InfoLog(<< "In case ltgtruri:" );
 
3636
   InfoLog(<< "Original text:" << std::endl << txt );
 
3637
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3638
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3639
 
 
3640
 
 
3641
 
 
3642
 
 
3643
}
 
3644
 
 
3645
 
 
3646
void
 
3647
lwsruri()
 
3648
{
 
3649
/*
 
3650
   This INVITE has illegal LWS within the Request-URI.
 
3651
 
 
3652
   An element receiving this request should respond with a 400 Bad
 
3653
   Request.
 
3654
 
 
3655
   An element could attempt to ignore the embedded LWS for those schemes
 
3656
   (like SIP) where doing so would not introduce ambiguity.
 
3657
 
 
3658
INVITE sip:user@example.com; lr SIP/2.0
 
3659
To: sip:user@example.com;tag=3xfe-9921883-z9f
 
3660
From: sip:caller@example.net;tag=231413434
 
3661
Max-Forwards: 5
 
3662
Call-ID: lwsruri.asdfasdoeoi2323-asdfwrn23-asd834rk423
 
3663
CSeq: 2130706432 INVITE
 
3664
Via: SIP/2.0/UDP 192.0.2.1:5060;branch=z9hG4bKkdjuw2395
 
3665
Contact: <sip:caller@host1.example.net>
 
3666
Content-Type: application/sdp
 
3667
Content-Length: 159
 
3668
 
 
3669
v=0
 
3670
o=mhandley 29739 7272939 IN IP4 192.0.2.1
 
3671
s=-
 
3672
c=IN IP4 192.0.2.1
 
3673
t=3149328700 0
 
3674
m=audio 49217 RTP/AVP 0 12
 
3675
m=video 3227 RTP/AVP 31
 
3676
a=rtpmap:31 LPC
 
3677
 
 
3678
*/
 
3679
   FILE* fid= fopen("lwsruri.dat","r");
 
3680
   tassert(fid);
 
3681
   resip::Data txt;
 
3682
   char mBuf[1024];
 
3683
   int result;
 
3684
   while(!feof(fid))
 
3685
   {
 
3686
      result = fread(&mBuf,1,1024,fid);
 
3687
      txt += resip::Data(mBuf,result);
 
3688
   }
 
3689
   fclose(fid);
 
3690
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3691
   tassert_reset();
 
3692
   if(!msg)
 
3693
   {
 
3694
      return;
 
3695
   }
 
3696
 
 
3697
   std::auto_ptr<resip::SipMessage> message(msg);
 
3698
   msg->parseAllHeaders();
 
3699
 
 
3700
   resip::SipMessage copy(*msg);
 
3701
 
 
3702
   resip::Data encoded;
 
3703
   {
 
3704
      resip::oDataStream str(encoded);
 
3705
      msg->encode(str);
 
3706
   }
 
3707
   resip::Data copyEncoded;
 
3708
   {
 
3709
      resip::oDataStream str(copyEncoded);
 
3710
      copy.encode(str);
 
3711
   }
 
3712
 
 
3713
   InfoLog(<< "In case lwsruri:" );
 
3714
   InfoLog(<< "Original text:" << std::endl << txt );
 
3715
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3716
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3717
 
 
3718
 
 
3719
 
 
3720
 
 
3721
}
 
3722
 
 
3723
 
 
3724
void
 
3725
lwsstart()
 
3726
{
 
3727
/*
 
3728
 
 
3729
   This INVITE has illegal multiple SP characters between elements of
 
3730
   the start line.
 
3731
 
 
3732
   It is acceptable to reject this request as malformed.  An element
 
3733
   that is liberal in what it accepts may ignore these extra SP
 
3734
   characters when processing the request.  If the element forwards the
 
3735
   request, it must not include these extra SP characters in the
 
3736
   messages it sends.
 
3737
 
 
3738
INVITE  sip:user@example.com  SIP/2.0
 
3739
Max-Forwards: 8
 
3740
To: sip:user@example.com
 
3741
From: sip:caller@example.net;tag=8814
 
3742
Call-ID: lwsstart.dfknq234oi243099adsdfnawe3@example.com
 
3743
CSeq: 1893884 INVITE
 
3744
Via: SIP/2.0/UDP host1.example.com;branch=z9hG4bKkdjuw3923
 
3745
Contact: <sip:caller@host1.example.net>
 
3746
Content-Type: application/sdp
 
3747
Content-Length: 150
 
3748
 
 
3749
v=0
 
3750
o=mhandley 29739 7272939 IN IP4 192.0.2.1
 
3751
s=-
 
3752
c=IN IP4 192.0.2.1
 
3753
t=0 0
 
3754
m=audio 49217 RTP/AVP 0 12
 
3755
m=video 3227 RTP/AVP 31
 
3756
a=rtpmap:31 LPC
 
3757
 
 
3758
*/
 
3759
   FILE* fid= fopen("lwsstart.dat","r");
 
3760
   tassert(fid);
 
3761
   resip::Data txt;
 
3762
   char mBuf[1024];
 
3763
   int result;
 
3764
   while(!feof(fid))
 
3765
   {
 
3766
      result = fread(&mBuf,1,1024,fid);
 
3767
      txt += resip::Data(mBuf,result);
 
3768
   }
 
3769
   fclose(fid);
 
3770
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3771
   tassert_reset();
 
3772
   if(!msg)
 
3773
   {
 
3774
      return;
 
3775
   }
 
3776
 
 
3777
   std::auto_ptr<resip::SipMessage> message(msg);
 
3778
   msg->parseAllHeaders();
 
3779
 
 
3780
   resip::SipMessage copy(*msg);
 
3781
 
 
3782
   resip::Data encoded;
 
3783
   {
 
3784
      resip::oDataStream str(encoded);
 
3785
      msg->encode(str);
 
3786
   }
 
3787
   resip::Data copyEncoded;
 
3788
   {
 
3789
      resip::oDataStream str(copyEncoded);
 
3790
      copy.encode(str);
 
3791
   }
 
3792
 
 
3793
   InfoLog(<< "In case lwsstart:" );
 
3794
   InfoLog(<< "Original text:" << std::endl << txt );
 
3795
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3796
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3797
 
 
3798
 
 
3799
 
 
3800
 
 
3801
}
 
3802
 
 
3803
 
 
3804
void
 
3805
trws()
 
3806
{
 
3807
/*
 
3808
 
 
3809
   This OPTIONS request contains SP characters between the SIP-Version
 
3810
   field and the CRLF terminating the Request-Line.
 
3811
 
 
3812
   It is acceptable to reject this request as malformed.  An element
 
3813
   that is liberal in what it accepts may ignore these extra SP
 
3814
   characters when processing the request.  If the element forwards the
 
3815
   request, it must not include these extra SP characters in the
 
3816
   messages it sends.
 
3817
 
 
3818
OPTIONS sip:remote-target@example.com SIP/2.0  
 
3819
Via: SIP/2.0/TCP host1.examle.com;branch=z9hG4bK299342093
 
3820
To: <sip:remote-target@example.com>
 
3821
From: <sip:local-resource@example.com>;tag=329429089
 
3822
Call-ID: trws.oicu34958239neffasdhr2345r
 
3823
Accept: application/sdp
 
3824
CSeq: 238923 OPTIONS
 
3825
Max-Forwards: 70
 
3826
Content-Length: 0
 
3827
 
 
3828
 
 
3829
*/
 
3830
   FILE* fid= fopen("trws.dat","r");
 
3831
   tassert(fid);
 
3832
   resip::Data txt;
 
3833
   char mBuf[1024];
 
3834
   int result;
 
3835
   while(!feof(fid))
 
3836
   {
 
3837
      result = fread(&mBuf,1,1024,fid);
 
3838
      txt += resip::Data(mBuf,result);
 
3839
   }
 
3840
   fclose(fid);
 
3841
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3842
   tassert_reset();
 
3843
   if(!msg)
 
3844
   {
 
3845
      return;
 
3846
   }
 
3847
 
 
3848
   std::auto_ptr<resip::SipMessage> message(msg);
 
3849
   msg->parseAllHeaders();
 
3850
 
 
3851
   resip::SipMessage copy(*msg);
 
3852
 
 
3853
   resip::Data encoded;
 
3854
   {
 
3855
      resip::oDataStream str(encoded);
 
3856
      msg->encode(str);
 
3857
   }
 
3858
   resip::Data copyEncoded;
 
3859
   {
 
3860
      resip::oDataStream str(copyEncoded);
 
3861
      copy.encode(str);
 
3862
   }
 
3863
 
 
3864
   InfoLog(<< "In case trws:" );
 
3865
   InfoLog(<< "Original text:" << std::endl << txt );
 
3866
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3867
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3868
 
 
3869
 
 
3870
 
 
3871
 
 
3872
}
 
3873
 
 
3874
 
 
3875
void
 
3876
escruri()
 
3877
{
 
3878
/*
 
3879
 
 
3880
   This INVITE is malformed, as the SIP Request-URI contains escaped
 
3881
   headers.
 
3882
 
 
3883
   It is acceptable for an element to reject this request with a 400 Bad
 
3884
   Request.  An element could choose to be liberal in what it accepts
 
3885
   and ignore the escaped headers.  If the element is a proxy, the
 
3886
   escaped headers must not appear in the Request-URI of the forwarded
 
3887
   request (and most certainly must not be translated into the actual
 
3888
   header of the forwarded request).
 
3889
 
 
3890
INVITE sip:user@example.com?Route=%3Csip:example.com%3E SIP/2.0
 
3891
To: sip:user@example.com
 
3892
From: sip:caller@example.net;tag=341518
 
3893
Max-Forwards: 7
 
3894
Contact: <sip:caller@host39923.example.net>
 
3895
Call-ID: escruri.23940-asdfhj-aje3br-234q098w-fawerh2q-h4n5
 
3896
CSeq: 149209342 INVITE
 
3897
Via: SIP/2.0/UDP host-of-the-hour.example.com;branch=z9hG4bKkdjuw
 
3898
Content-Type: application/sdp
 
3899
Content-Length: 150
 
3900
 
 
3901
v=0
 
3902
o=mhandley 29739 7272939 IN IP4 192.0.2.1
 
3903
s=-
 
3904
c=IN IP4 192.0.2.1
 
3905
t=0 0
 
3906
m=audio 49217 RTP/AVP 0 12
 
3907
m=video 3227 RTP/AVP 31
 
3908
a=rtpmap:31 LPC
 
3909
 
 
3910
*/
 
3911
   FILE* fid= fopen("escruri.dat","r");
 
3912
   tassert(fid);
 
3913
   resip::Data txt;
 
3914
   char mBuf[1024];
 
3915
   int result;
 
3916
   while(!feof(fid))
 
3917
   {
 
3918
      result = fread(&mBuf,1,1024,fid);
 
3919
      txt += resip::Data(mBuf,result);
 
3920
   }
 
3921
   fclose(fid);
 
3922
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
3923
   tassert_reset();
 
3924
   if(!msg)
 
3925
   {
 
3926
      return;
 
3927
   }
 
3928
 
 
3929
   std::auto_ptr<resip::SipMessage> message(msg);
 
3930
   msg->parseAllHeaders();
 
3931
 
 
3932
   resip::SipMessage copy(*msg);
 
3933
 
 
3934
   resip::Data encoded;
 
3935
   {
 
3936
      resip::oDataStream str(encoded);
 
3937
      msg->encode(str);
 
3938
   }
 
3939
   resip::Data copyEncoded;
 
3940
   {
 
3941
      resip::oDataStream str(copyEncoded);
 
3942
      copy.encode(str);
 
3943
   }
 
3944
 
 
3945
   InfoLog(<< "In case escruri:" );
 
3946
   InfoLog(<< "Original text:" << std::endl << txt );
 
3947
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
3948
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
3949
 
 
3950
 
 
3951
 
 
3952
 
 
3953
}
 
3954
 
 
3955
 
 
3956
void
 
3957
baddate()
 
3958
{
 
3959
/*
 
3960
 
 
3961
   This INVITE is invalid, as it contains a non-GMT time zone in the SIP
 
3962
   Date header field.
 
3963
 
 
3964
   It is acceptable to reject this request as malformed (though an
 
3965
   element shouldn't do that unless the contents of the Date header
 
3966
   field were actually important to its processing).  An element wishing
 
3967
   to be liberal in what it accepts could ignore this value altogether
 
3968
   if it wasn't going to use the Date header field anyway.  Otherwise,
 
3969
   it could attempt to interpret this date and adjust it to GMT.
 
3970
 
 
3971
   RFC 3261 explicitly defines the only acceptable time zone designation
 
3972
   as "GMT".  "UT", while synonymous with GMT per [RFC2822], is not
 
3973
   valid.  "UTC" and "UCT" are also invalid.
 
3974
 
 
3975
INVITE sip:user@example.com SIP/2.0
 
3976
To: sip:user@example.com
 
3977
From: sip:caller@example.net;tag=2234923
 
3978
Max-Forwards: 70
 
3979
Call-ID: baddate.239423mnsadf3j23lj42--sedfnm234
 
3980
CSeq: 1392934 INVITE
 
3981
Via: SIP/2.0/UDP host.example.com;branch=z9hG4bKkdjuw
 
3982
Date: Fri, 01 Jan 2010 16:00:00 EST
 
3983
Contact: <sip:caller@host5.example.net>
 
3984
Content-Type: application/sdp
 
3985
Content-Length: 150
 
3986
 
 
3987
v=0
 
3988
o=mhandley 29739 7272939 IN IP4 192.0.2.5
 
3989
s=-
 
3990
c=IN IP4 192.0.2.5
 
3991
t=0 0
 
3992
m=audio 49217 RTP/AVP 0 12
 
3993
m=video 3227 RTP/AVP 31
 
3994
a=rtpmap:31 LPC
 
3995
 
 
3996
*/
 
3997
   FILE* fid= fopen("baddate.dat","r");
 
3998
   tassert(fid);
 
3999
   resip::Data txt;
 
4000
   char mBuf[1024];
 
4001
   int result;
 
4002
   while(!feof(fid))
 
4003
   {
 
4004
      result = fread(&mBuf,1,1024,fid);
 
4005
      txt += resip::Data(mBuf,result);
 
4006
   }
 
4007
   fclose(fid);
 
4008
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4009
   tassert_reset();
 
4010
   if(!msg)
 
4011
   {
 
4012
      return;
 
4013
   }
 
4014
 
 
4015
   std::auto_ptr<resip::SipMessage> message(msg);
 
4016
   msg->parseAllHeaders();
 
4017
 
 
4018
   resip::SipMessage copy(*msg);
 
4019
 
 
4020
   resip::Data encoded;
 
4021
   {
 
4022
      resip::oDataStream str(encoded);
 
4023
      msg->encode(str);
 
4024
   }
 
4025
   resip::Data copyEncoded;
 
4026
   {
 
4027
      resip::oDataStream str(copyEncoded);
 
4028
      copy.encode(str);
 
4029
   }
 
4030
 
 
4031
   InfoLog(<< "In case baddate:" );
 
4032
   InfoLog(<< "Original text:" << std::endl << txt );
 
4033
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4034
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4035
 
 
4036
 
 
4037
 
 
4038
 
 
4039
}
 
4040
 
 
4041
 
 
4042
void
 
4043
regbadct()
 
4044
{
 
4045
/*
 
4046
 
 
4047
   This REGISTER request is malformed.  The SIP URI contained in the
 
4048
   Contact Header field has an escaped header, so the field must be in
 
4049
   name-addr form (which implies that the URI must be enclosed in <>).
 
4050
 
 
4051
   It is reasonable for an element receiving this request to respond
 
4052
   with a 400 Bad Request.  An element choosing to be liberal in what it
 
4053
   accepts could infer the angle brackets since there is no ambiguity in
 
4054
   this example.  In general, that won't be possible.
 
4055
 
 
4056
REGISTER sip:example.com SIP/2.0
 
4057
To: sip:user@example.com
 
4058
From: sip:user@example.com;tag=998332
 
4059
Max-Forwards: 70
 
4060
Call-ID: regbadct.k345asrl3fdbv@10.0.0.1
 
4061
CSeq: 1 REGISTER
 
4062
Via: SIP/2.0/UDP 135.180.130.133:5060;branch=z9hG4bKkdjuw
 
4063
Contact: sip:user@example.com?Route=%3Csip:sip.example.com%3E
 
4064
l: 0
 
4065
 
 
4066
 
 
4067
*/
 
4068
   FILE* fid= fopen("regbadct.dat","r");
 
4069
   tassert(fid);
 
4070
   resip::Data txt;
 
4071
   char mBuf[1024];
 
4072
   int result;
 
4073
   while(!feof(fid))
 
4074
   {
 
4075
      result = fread(&mBuf,1,1024,fid);
 
4076
      txt += resip::Data(mBuf,result);
 
4077
   }
 
4078
   fclose(fid);
 
4079
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4080
   tassert_reset();
 
4081
   if(!msg)
 
4082
   {
 
4083
      return;
 
4084
   }
 
4085
 
 
4086
   std::auto_ptr<resip::SipMessage> message(msg);
 
4087
   msg->parseAllHeaders();
 
4088
 
 
4089
   resip::SipMessage copy(*msg);
 
4090
 
 
4091
   resip::Data encoded;
 
4092
   {
 
4093
      resip::oDataStream str(encoded);
 
4094
      msg->encode(str);
 
4095
   }
 
4096
   resip::Data copyEncoded;
 
4097
   {
 
4098
      resip::oDataStream str(copyEncoded);
 
4099
      copy.encode(str);
 
4100
   }
 
4101
 
 
4102
   InfoLog(<< "In case regbadct:" );
 
4103
   InfoLog(<< "Original text:" << std::endl << txt );
 
4104
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4105
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4106
 
 
4107
 
 
4108
 
 
4109
 
 
4110
}
 
4111
 
 
4112
 
 
4113
void
 
4114
badaspec()
 
4115
{
 
4116
/*
 
4117
 
 
4118
   This request is malformed, since the addr-spec in the To header field
 
4119
   contains spaces.  Parsers receiving this request must not break.  It
 
4120
   is reasonable to reject this request with a 400 Bad Request response.
 
4121
   Elements attempting to be liberal may ignore the spaces.
 
4122
 
 
4123
OPTIONS sip:user@example.org SIP/2.0
 
4124
Via: SIP/2.0/UDP host4.example.com:5060;branch=z9hG4bKkdju43234
 
4125
Max-Forwards: 70
 
4126
From: "Bell, Alexander" <sip:a.g.bell@example.com>;tag=433423
 
4127
To: "Watson, Thomas" < sip:t.watson@example.org >
 
4128
Call-ID: badaspec.sdf0234n2nds0a099u23h3hnnw009cdkne3
 
4129
Accept: application/sdp
 
4130
CSeq: 3923239 OPTIONS
 
4131
l: 0
 
4132
 
 
4133
 
 
4134
*/
 
4135
   FILE* fid= fopen("badaspec.dat","r");
 
4136
   tassert(fid);
 
4137
   resip::Data txt;
 
4138
   char mBuf[1024];
 
4139
   int result;
 
4140
   while(!feof(fid))
 
4141
   {
 
4142
      result = fread(&mBuf,1,1024,fid);
 
4143
      txt += resip::Data(mBuf,result);
 
4144
   }
 
4145
   fclose(fid);
 
4146
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4147
   tassert_reset();
 
4148
   if(!msg)
 
4149
   {
 
4150
      return;
 
4151
   }
 
4152
 
 
4153
   std::auto_ptr<resip::SipMessage> message(msg);
 
4154
   msg->parseAllHeaders();
 
4155
 
 
4156
   resip::SipMessage copy(*msg);
 
4157
 
 
4158
   resip::Data encoded;
 
4159
   {
 
4160
      resip::oDataStream str(encoded);
 
4161
      msg->encode(str);
 
4162
   }
 
4163
   resip::Data copyEncoded;
 
4164
   {
 
4165
      resip::oDataStream str(copyEncoded);
 
4166
      copy.encode(str);
 
4167
   }
 
4168
   
 
4169
   
 
4170
 
 
4171
   InfoLog(<< "In case badaspec:" );
 
4172
   InfoLog(<< "Original text:" << std::endl << txt );
 
4173
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4174
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4175
 
 
4176
 
 
4177
 
 
4178
 
 
4179
}
 
4180
 
 
4181
 
 
4182
void
 
4183
baddn()
 
4184
{
 
4185
/*
 
4186
 
 
4187
   This OPTIONS request is malformed, since the display names in the To
 
4188
   and From header fields contain non-token characters but are unquoted.
 
4189
 
 
4190
   It is reasonable always to reject this kind of error with a 400 Bad
 
4191
   Request response.
 
4192
 
 
4193
   An element may attempt to be liberal in what it receives and infer
 
4194
   the missing quotes.  If this element were a proxy, it must not
 
4195
   propagate the error into the request it forwards.  As a consequence,
 
4196
   if the fields are covered by a signature, there's not much point in
 
4197
   trying to be liberal - the message should simply be rejected.
 
4198
 
 
4199
OPTIONS sip:t.watson@example.org SIP/2.0
 
4200
Via:     SIP/2.0/UDP c.example.com:5060;branch=z9hG4bKkdjuw
 
4201
Max-Forwards:      70
 
4202
From:    Bell, Alexander <sip:a.g.bell@example.com>;tag=43
 
4203
To:      Watson, Thomas <sip:t.watson@example.org>
 
4204
Call-ID: baddn.31415@c.example.com
 
4205
Accept: application/sdp
 
4206
CSeq:    3923239 OPTIONS
 
4207
l: 0
 
4208
 
 
4209
*/
 
4210
   FILE* fid= fopen("baddn.dat","r");
 
4211
   tassert(fid);
 
4212
   resip::Data txt;
 
4213
   char mBuf[1024];
 
4214
   int result;
 
4215
   while(!feof(fid))
 
4216
   {
 
4217
      result = fread(&mBuf,1,1024,fid);
 
4218
      txt += resip::Data(mBuf,result);
 
4219
   }
 
4220
   fclose(fid);
 
4221
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4222
   tassert_reset();
 
4223
   if(!msg)
 
4224
   {
 
4225
      return;
 
4226
   }
 
4227
 
 
4228
   std::auto_ptr<resip::SipMessage> message(msg);
 
4229
   msg->parseAllHeaders();
 
4230
 
 
4231
   resip::SipMessage copy(*msg);
 
4232
 
 
4233
   resip::Data encoded;
 
4234
   {
 
4235
      resip::oDataStream str(encoded);
 
4236
      msg->encode(str);
 
4237
   }
 
4238
   resip::Data copyEncoded;
 
4239
   {
 
4240
      resip::oDataStream str(copyEncoded);
 
4241
      copy.encode(str);
 
4242
   }
 
4243
 
 
4244
   InfoLog(<< "In case baddn:" );
 
4245
   InfoLog(<< "Original text:" << std::endl << txt );
 
4246
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4247
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4248
 
 
4249
 
 
4250
 
 
4251
 
 
4252
}
 
4253
 
 
4254
 
 
4255
void
 
4256
badvers()
 
4257
{
 
4258
/*
 
4259
 
 
4260
   To an element implementing [RFC3261], this request is malformed due
 
4261
   to its high version number.
 
4262
 
 
4263
   The element should respond to the request with a 505 Version Not
 
4264
   Supported error.
 
4265
 
 
4266
OPTIONS sip:t.watson@example.org SIP/7.0
 
4267
Via:     SIP/7.0/UDP c.example.com;branch=z9hG4bKkdjuw
 
4268
Max-Forwards:     70
 
4269
From:    A. Bell <sip:a.g.bell@example.com>;tag=qweoiqpe
 
4270
To:      T. Watson <sip:t.watson@example.org>
 
4271
Call-ID: badvers.31417@c.example.com
 
4272
CSeq:    1 OPTIONS
 
4273
l: 0
 
4274
 
 
4275
 
 
4276
*/
 
4277
   FILE* fid= fopen("badvers.dat","r");
 
4278
   tassert(fid);
 
4279
   resip::Data txt;
 
4280
   char mBuf[1024];
 
4281
   int result;
 
4282
   while(!feof(fid))
 
4283
   {
 
4284
      result = fread(&mBuf,1,1024,fid);
 
4285
      txt += resip::Data(mBuf,result);
 
4286
   }
 
4287
   fclose(fid);
 
4288
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4289
   tassert_reset();
 
4290
   if(!msg)
 
4291
   {
 
4292
      return;
 
4293
   }
 
4294
 
 
4295
   std::auto_ptr<resip::SipMessage> message(msg);
 
4296
   msg->parseAllHeaders();
 
4297
 
 
4298
   resip::SipMessage copy(*msg);
 
4299
 
 
4300
   resip::Data encoded;
 
4301
   {
 
4302
      resip::oDataStream str(encoded);
 
4303
      msg->encode(str);
 
4304
   }
 
4305
   resip::Data copyEncoded;
 
4306
   {
 
4307
      resip::oDataStream str(copyEncoded);
 
4308
      copy.encode(str);
 
4309
   }
 
4310
 
 
4311
   InfoLog(<< "In case badvers:" );
 
4312
   InfoLog(<< "Original text:" << std::endl << txt );
 
4313
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4314
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4315
 
 
4316
 
 
4317
 
 
4318
 
 
4319
}
 
4320
 
 
4321
 
 
4322
void
 
4323
mismatch01()
 
4324
{
 
4325
/*
 
4326
 
 
4327
   This request has mismatching values for the method in the start line
 
4328
   and the CSeq header field.  Any element receiving this request will
 
4329
   respond with a 400 Bad Request.
 
4330
 
 
4331
OPTIONS sip:user@example.com SIP/2.0
 
4332
To: sip:j.user@example.com
 
4333
From: sip:caller@example.net;tag=34525
 
4334
Max-Forwards: 6
 
4335
Call-ID: mismatch01.dj0234sxdfl3
 
4336
CSeq: 8 INVITE
 
4337
Via: SIP/2.0/UDP host.example.com;branch=z9hG4bKkdjuw
 
4338
l: 0
 
4339
 
 
4340
 
 
4341
*/
 
4342
   FILE* fid= fopen("mismatch01.dat","r");
 
4343
   tassert(fid);
 
4344
   resip::Data txt;
 
4345
   char mBuf[1024];
 
4346
   int result;
 
4347
   while(!feof(fid))
 
4348
   {
 
4349
      result = fread(&mBuf,1,1024,fid);
 
4350
      txt += resip::Data(mBuf,result);
 
4351
   }
 
4352
   fclose(fid);
 
4353
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4354
   tassert_reset();
 
4355
   if(!msg)
 
4356
   {
 
4357
      return;
 
4358
   }
 
4359
 
 
4360
   std::auto_ptr<resip::SipMessage> message(msg);
 
4361
   msg->parseAllHeaders();
 
4362
 
 
4363
   resip::SipMessage copy(*msg);
 
4364
 
 
4365
   resip::Data encoded;
 
4366
   {
 
4367
      resip::oDataStream str(encoded);
 
4368
      msg->encode(str);
 
4369
   }
 
4370
   resip::Data copyEncoded;
 
4371
   {
 
4372
      resip::oDataStream str(copyEncoded);
 
4373
      copy.encode(str);
 
4374
   }
 
4375
 
 
4376
   InfoLog(<< "In case mismatch01:" );
 
4377
   InfoLog(<< "Original text:" << std::endl << txt );
 
4378
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4379
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4380
 
 
4381
 
 
4382
 
 
4383
 
 
4384
}
 
4385
 
 
4386
 
 
4387
void
 
4388
mismatch02()
 
4389
{
 
4390
/*
 
4391
 
 
4392
   This message has an unknown method in the start line, and a CSeq
 
4393
   method tag that does not match.
 
4394
 
 
4395
   Any element receiving this response should respond with a 501 Not
 
4396
   Implemented.  A 400 Bad Request is also acceptable, but choosing a
 
4397
   501 (particularly at proxies) has better future-proof
 
4398
   characteristics.
 
4399
 
 
4400
NEWMETHOD sip:user@example.com SIP/2.0
 
4401
To: sip:j.user@example.com
 
4402
From: sip:caller@example.net;tag=34525
 
4403
Max-Forwards: 6
 
4404
Call-ID: mismatch02.dj0234sxdfl3
 
4405
CSeq: 8 INVITE
 
4406
Contact: <sip:caller@host.example.net>
 
4407
Via: SIP/2.0/UDP host.example.net;branch=z9hG4bKkdjuw
 
4408
Content-Type: application/sdp
 
4409
l: 138
 
4410
 
 
4411
v=0
 
4412
o=mhandley 29739 7272939 IN IP4 192.0.2.1
 
4413
c=IN IP4 192.0.2.1
 
4414
m=audio 49217 RTP/AVP 0 12
 
4415
m=video 3227 RTP/AVP 31
 
4416
a=rtpmap:31 LPC
 
4417
 
 
4418
*/
 
4419
   FILE* fid= fopen("mismatch02.dat","r");
 
4420
   tassert(fid);
 
4421
   resip::Data txt;
 
4422
   char mBuf[1024];
 
4423
   int result;
 
4424
   while(!feof(fid))
 
4425
   {
 
4426
      result = fread(&mBuf,1,1024,fid);
 
4427
      txt += resip::Data(mBuf,result);
 
4428
   }
 
4429
   fclose(fid);
 
4430
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4431
   tassert_reset();
 
4432
   if(!msg)
 
4433
   {
 
4434
      return;
 
4435
   }
 
4436
 
 
4437
   std::auto_ptr<resip::SipMessage> message(msg);
 
4438
   msg->parseAllHeaders();
 
4439
 
 
4440
   resip::SipMessage copy(*msg);
 
4441
 
 
4442
   resip::Data encoded;
 
4443
   {
 
4444
      resip::oDataStream str(encoded);
 
4445
      msg->encode(str);
 
4446
   }
 
4447
   resip::Data copyEncoded;
 
4448
   {
 
4449
      resip::oDataStream str(copyEncoded);
 
4450
      copy.encode(str);
 
4451
   }
 
4452
 
 
4453
   InfoLog(<< "In case mismatch02:" );
 
4454
   InfoLog(<< "Original text:" << std::endl << txt );
 
4455
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4456
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4457
 
 
4458
 
 
4459
 
 
4460
 
 
4461
}
 
4462
 
 
4463
 
 
4464
void
 
4465
bigcode()
 
4466
{
 
4467
/*
 
4468
 
 
4469
   This response has a response code larger than 699.  An element
 
4470
   receiving this response should simply drop it.
 
4471
 
 
4472
SIP/2.0 4294967301 better not break the receiver
 
4473
Via: SIP/2.0/UDP 192.0.2.105;branch=z9hG4bK2398ndaoe
 
4474
Call-ID: bigcode.asdof3uj203asdnf3429uasdhfas3ehjasdfas9i
 
4475
CSeq: 353494 INVITE
 
4476
From: <sip:user@example.com>;tag=39ansfi3
 
4477
To: <sip:user@example.edu>;tag=902jndnke3
 
4478
Content-Length: 0
 
4479
Contact: <sip:user@host105.example.com>
 
4480
 
 
4481
 
 
4482
*/
 
4483
   FILE* fid= fopen("bigcode.dat","r");
 
4484
   tassert(fid);
 
4485
   resip::Data txt;
 
4486
   char mBuf[1024];
 
4487
   int result;
 
4488
   while(!feof(fid))
 
4489
   {
 
4490
      result = fread(&mBuf,1,1024,fid);
 
4491
      txt += resip::Data(mBuf,result);
 
4492
   }
 
4493
   fclose(fid);
 
4494
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4495
   tassert_reset();
 
4496
   if(!msg)
 
4497
   {
 
4498
      return;
 
4499
   }
 
4500
 
 
4501
   std::auto_ptr<resip::SipMessage> message(msg);
 
4502
   msg->parseAllHeaders();
 
4503
 
 
4504
   resip::SipMessage copy(*msg);
 
4505
 
 
4506
   resip::Data encoded;
 
4507
   {
 
4508
      resip::oDataStream str(encoded);
 
4509
      msg->encode(str);
 
4510
   }
 
4511
   resip::Data copyEncoded;
 
4512
   {
 
4513
      resip::oDataStream str(copyEncoded);
 
4514
      copy.encode(str);
 
4515
   }
 
4516
 
 
4517
   InfoLog(<< "In case bigcode:" );
 
4518
   InfoLog(<< "Original text:" << std::endl << txt );
 
4519
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4520
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4521
 
 
4522
 
 
4523
 
 
4524
 
 
4525
}
 
4526
 
 
4527
 
 
4528
void
 
4529
badbranch()
 
4530
{
 
4531
/*
 
4532
 
 
4533
   This request indicates support for RFC 3261-style transaction
 
4534
   identifiers by providing the z9hG4bK prefix to the branch parameter,
 
4535
   but it provides no identifier.  A parser must not break when
 
4536
   receiving this message.  An element receiving this request could
 
4537
   reject the request with a 400 Response (preferably statelessly, as
 
4538
   other requests from the source are likely also to have a malformed
 
4539
   branch parameter), or it could fall back to the RFC 2543-style
 
4540
   transaction identifier.
 
4541
 
 
4542
OPTIONS sip:user@example.com SIP/2.0
 
4543
To: sip:user@example.com
 
4544
From: sip:caller@example.org;tag=33242
 
4545
Max-Forwards: 3
 
4546
Via: SIP/2.0/UDP 192.0.2.1;branch=z9hG4bK
 
4547
Accept: application/sdp
 
4548
Call-ID: badbranch.sadonfo23i420jv0as0derf3j3n
 
4549
CSeq: 8 OPTIONS
 
4550
l: 0
 
4551
 
 
4552
 
 
4553
*/
 
4554
   FILE* fid= fopen("badbranch.dat","r");
 
4555
   tassert(fid);
 
4556
   resip::Data txt;
 
4557
   char mBuf[1024];
 
4558
   int result;
 
4559
   while(!feof(fid))
 
4560
   {
 
4561
      result = fread(&mBuf,1,1024,fid);
 
4562
      txt += resip::Data(mBuf,result);
 
4563
   }
 
4564
   fclose(fid);
 
4565
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4566
   tassert_reset();
 
4567
   tassert(msg);
 
4568
   tassert_reset();
 
4569
   if(!msg)
 
4570
   {
 
4571
      return;
 
4572
   }
 
4573
 
 
4574
   std::auto_ptr<resip::SipMessage> message(msg);
 
4575
   msg->parseAllHeaders();
 
4576
 
 
4577
   resip::SipMessage copy(*msg);
 
4578
 
 
4579
   resip::Data encoded;
 
4580
   {
 
4581
      resip::oDataStream str(encoded);
 
4582
      msg->encode(str);
 
4583
   }
 
4584
   resip::Data copyEncoded;
 
4585
   {
 
4586
      resip::oDataStream str(copyEncoded);
 
4587
      copy.encode(str);
 
4588
   }
 
4589
 
 
4590
   //Request Line
 
4591
   //OPTIONS sip:user@example.com SIP/2.0
 
4592
   tassert(msg->header(resip::h_RequestLine).method()==resip::OPTIONS);
 
4593
   tassert(msg->header(resip::h_RequestLine).unknownMethodName()=="OPTIONS");
 
4594
   tassert(msg->header(resip::h_RequestLine).uri().scheme()=="sip");
 
4595
   tassert(msg->header(resip::h_RequestLine).uri().user()=="user");
 
4596
   tassert(msg->header(resip::h_RequestLine).uri().password().empty());
 
4597
   tassert(msg->header(resip::h_RequestLine).uri().host()=="example.com");
 
4598
   tassert(msg->header(resip::h_RequestLine).uri().port()==0);
 
4599
   tassert(!(msg->header(resip::h_RequestLine).uri().hasEmbedded()));
 
4600
   tassert(msg->header(resip::h_RequestLine).uri().numKnownParams()==0);
 
4601
   tassert(msg->header(resip::h_RequestLine).uri().numUnknownParams()==0);
 
4602
   tassert(msg->header(resip::h_RequestLine).getSipVersion()=="SIP/2.0");
 
4603
 
 
4604
   //To: sip:user@example.com
 
4605
   tassert(msg->exists(resip::h_To));
 
4606
   tassert(msg->header(resip::h_To).displayName()=="");
 
4607
   tassert(msg->header(resip::h_To).numKnownParams()==0);
 
4608
   tassert(msg->header(resip::h_To).numUnknownParams()==0);
 
4609
   tassert(!(msg->header(resip::h_To).isAllContacts()));
 
4610
   tassert(msg->header(resip::h_To).uri().scheme()=="sip");
 
4611
   tassert(msg->header(resip::h_To).uri().user()=="user");
 
4612
   tassert(msg->header(resip::h_To).uri().password().empty());
 
4613
   tassert(msg->header(resip::h_To).uri().host()=="example.com");
 
4614
   tassert(msg->header(resip::h_To).uri().port()==0);
 
4615
   tassert(!(msg->header(resip::h_To).uri().hasEmbedded()));
 
4616
   tassert(msg->header(resip::h_To).uri().numKnownParams()==0);
 
4617
   tassert(msg->header(resip::h_To).uri().numUnknownParams()==0);
 
4618
 
 
4619
   //From: sip:caller@example.org;tag=33242
 
4620
   tassert(msg->exists(resip::h_From));
 
4621
   tassert(msg->header(resip::h_From).displayName()=="");
 
4622
   tassert(msg->header(resip::h_From).numKnownParams()==1);
 
4623
   tassert(msg->header(resip::h_From).numUnknownParams()==0);
 
4624
   tassert(msg->header(resip::h_From).exists(resip::p_tag));
 
4625
   tassert(msg->header(resip::h_From).param(resip::p_tag)=="33242");
 
4626
   tassert(!(msg->header(resip::h_From).isAllContacts()));
 
4627
   tassert(msg->header(resip::h_From).uri().scheme()=="sip");
 
4628
   tassert(msg->header(resip::h_From).uri().user()=="caller");
 
4629
   tassert(msg->header(resip::h_From).uri().password().empty());
 
4630
   tassert(msg->header(resip::h_From).uri().host()=="example.org");
 
4631
   tassert(msg->header(resip::h_From).uri().port()==0);
 
4632
   tassert(!(msg->header(resip::h_From).uri().hasEmbedded()));
 
4633
   tassert(msg->header(resip::h_From).uri().numKnownParams()==0);
 
4634
   tassert(msg->header(resip::h_From).uri().numUnknownParams()==0);
 
4635
 
 
4636
   //Max-Forwards: 3
 
4637
   tassert(msg->exists(resip::h_MaxForwards));
 
4638
   tassert(msg->header(resip::h_MaxForwards).value()==3);
 
4639
   tassert(msg->header(resip::h_MaxForwards).numKnownParams()==0);
 
4640
   tassert(msg->header(resip::h_MaxForwards).numUnknownParams()==0);
 
4641
 
 
4642
   //Vias
 
4643
   tassert(msg->exists(resip::h_Vias));
 
4644
   tassert(msg->header(resip::h_Vias).size()==1);
 
4645
   resip::ParserContainer<resip::Via>::iterator v=msg->header(resip::h_Vias).begin();
 
4646
 
 
4647
   //Via: SIP/2.0/UDP 192.0.2.1;branch=z9hG4bK
 
4648
   tassert(v->numKnownParams()==1);
 
4649
   tassert(v->numUnknownParams()==0);
 
4650
   tassert(v->protocolName()=="SIP");
 
4651
   tassert(v->protocolVersion()=="2.0");
 
4652
   tassert(v->transport()=="UDP");
 
4653
   tassert(v->sentHost()=="192.0.2.1");
 
4654
   tassert(v->sentPort()==0);
 
4655
   
 
4656
   tassert(v->exists(resip::p_branch));
 
4657
   tassert(v->param(resip::p_branch).hasMagicCookie());
 
4658
   tassert(v->param(resip::p_branch).getTransactionId()=="");
 
4659
   tassert(v->param(resip::p_branch).clientData().empty());
 
4660
 
 
4661
   //Accept: application/sdp
 
4662
   tassert(msg->exists(resip::h_Accepts));
 
4663
   tassert(msg->header(resip::h_Accepts).size()==1);
 
4664
   
 
4665
   resip::Mimes::iterator a=msg->header(resip::h_Accepts).begin();
 
4666
   
 
4667
   tassert(a->type()=="application");
 
4668
   tassert(a->subType()=="sdp");
 
4669
   tassert(a->numKnownParams()==0);
 
4670
   tassert(a->numUnknownParams()==0);
 
4671
 
 
4672
   //Call-ID: badbranch.sadonfo23i420jv0as0derf3j3n
 
4673
   tassert(msg->exists(resip::h_CallID));
 
4674
   tassert(msg->header(resip::h_CallID).value()=="badbranch.sadonfo23i420jv0as0derf3j3n");
 
4675
   tassert(msg->header(resip::h_CallID).numKnownParams()==0);
 
4676
   tassert(msg->header(resip::h_CallID).numUnknownParams()==0);
 
4677
 
 
4678
   //CSeq: 8 OPTIONS
 
4679
   tassert(msg->exists(resip::h_CSeq));
 
4680
   tassert(msg->header(resip::h_CSeq).method()==resip::OPTIONS);
 
4681
   tassert(msg->header(resip::h_CSeq).unknownMethodName()=="OPTIONS");
 
4682
   tassert(msg->header(resip::h_CSeq).sequence()==8);
 
4683
   tassert(msg->header(resip::h_CSeq).numKnownParams()==0);
 
4684
   tassert(msg->header(resip::h_CSeq).numUnknownParams()==0);
 
4685
 
 
4686
   //l: 0
 
4687
   tassert(msg->exists(resip::h_ContentLength));
 
4688
   tassert(msg->header(resip::h_ContentLength).value()==0);
 
4689
   tassert(msg->header(resip::h_ContentLength).numKnownParams()==0);
 
4690
   tassert(msg->header(resip::h_ContentLength).numUnknownParams()==0);
 
4691
 
 
4692
 
 
4693
   InfoLog(<< "In case badbranch:" );
 
4694
   InfoLog(<< "Original text:" << std::endl << txt );
 
4695
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4696
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4697
 
 
4698
 
 
4699
 
 
4700
 
 
4701
}
 
4702
 
 
4703
 
 
4704
void
 
4705
bcast()
 
4706
{
 
4707
/*
 
4708
 
 
4709
SIP/2.0 200 OK
 
4710
Via: SIP/2.0/UDP 192.0.2.198;branch=z9hG4bK1324923
 
4711
Via: SIP/2.0/UDP 255.255.255.255;branch=z9hG4bK1saber23
 
4712
Call-ID: bcast.0384840201234ksdfak3j2erwedfsASdf
 
4713
CSeq: 35 INVITE
 
4714
From: sip:user@example.com;tag=11141343
 
4715
To: sip:user@example.edu;tag=2229
 
4716
Content-Length: 154
 
4717
Content-Type: application/sdp
 
4718
Contact: <sip:user@host28.example.com>
 
4719
 
 
4720
v=0
 
4721
o=mhandley 29739 7272939 IN IP4 192.0.2.198
 
4722
s=-
 
4723
c=IN IP4 192.0.2.198
 
4724
t=0 0
 
4725
m=audio 49217 RTP/AVP 0 12
 
4726
m=video 3227 RTP/AVP 31
 
4727
a=rtpmap:31 LPC
 
4728
 
 
4729
*/
 
4730
   FILE* fid= fopen("bcast.dat","r");
 
4731
   tassert(fid);
 
4732
   resip::Data txt;
 
4733
   char mBuf[1024];
 
4734
   int result;
 
4735
   while(!feof(fid))
 
4736
   {
 
4737
      result = fread(&mBuf,1,1024,fid);
 
4738
      txt += resip::Data(mBuf,result);
 
4739
   }
 
4740
   fclose(fid);
 
4741
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4742
   tassert_reset();
 
4743
   tassert(msg);
 
4744
   tassert_reset();
 
4745
   if(!msg)
 
4746
   {
 
4747
      return;
 
4748
   }
 
4749
 
 
4750
   std::auto_ptr<resip::SipMessage> message(msg);
 
4751
   msg->parseAllHeaders();
 
4752
 
 
4753
   resip::SipMessage copy(*msg);
 
4754
 
 
4755
   resip::Data encoded;
 
4756
   {
 
4757
      resip::oDataStream str(encoded);
 
4758
      msg->encode(str);
 
4759
   }
 
4760
   resip::Data copyEncoded;
 
4761
   {
 
4762
      resip::oDataStream str(copyEncoded);
 
4763
      copy.encode(str);
 
4764
   }
 
4765
 
 
4766
   InfoLog(<< "In case bcast:" );
 
4767
   InfoLog(<< "Original text:" << std::endl << txt );
 
4768
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4769
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4770
 
 
4771
 
 
4772
 
 
4773
 
 
4774
}
 
4775
 
 
4776
 
 
4777
void
 
4778
bext01()
 
4779
{
 
4780
/*
 
4781
 
 
4782
OPTIONS sip:user@example.com SIP/2.0
 
4783
To: sip:j_user@example.com
 
4784
From: sip:caller@example.net;tag=242etr
 
4785
Max-Forwards: 6
 
4786
Call-ID: bext01.0ha0isndaksdj
 
4787
Require: nothingSupportsThis, nothingSupportsThisEither
 
4788
Proxy-Require: noProxiesSupportThis, norDoAnyProxiesSupportThis
 
4789
CSeq: 8 OPTIONS
 
4790
Via: SIP/2.0/TLS fold-and-staple.example.com;branch=z9hG4bKkdjuw
 
4791
Content-Length: 0
 
4792
 
 
4793
 
 
4794
*/
 
4795
   FILE* fid= fopen("bext01.dat","r");
 
4796
   tassert(fid);
 
4797
   resip::Data txt;
 
4798
   char mBuf[1024];
 
4799
   int result;
 
4800
   while(!feof(fid))
 
4801
   {
 
4802
      result = fread(&mBuf,1,1024,fid);
 
4803
      txt += resip::Data(mBuf,result);
 
4804
   }
 
4805
   fclose(fid);
 
4806
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4807
   tassert_reset();
 
4808
   tassert(msg);
 
4809
   tassert_reset();
 
4810
   if(!msg)
 
4811
   {
 
4812
      return;
 
4813
   }
 
4814
 
 
4815
   std::auto_ptr<resip::SipMessage> message(msg);
 
4816
   msg->parseAllHeaders();
 
4817
 
 
4818
   resip::SipMessage copy(*msg);
 
4819
 
 
4820
   resip::Data encoded;
 
4821
   {
 
4822
      resip::oDataStream str(encoded);
 
4823
      msg->encode(str);
 
4824
   }
 
4825
   resip::Data copyEncoded;
 
4826
   {
 
4827
      resip::oDataStream str(copyEncoded);
 
4828
      copy.encode(str);
 
4829
   }
 
4830
 
 
4831
   InfoLog(<< "In case bext01:" );
 
4832
   InfoLog(<< "Original text:" << std::endl << txt );
 
4833
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4834
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4835
 
 
4836
 
 
4837
 
 
4838
 
 
4839
}
 
4840
 
 
4841
 
 
4842
void
 
4843
cparam01()
 
4844
{
 
4845
/*
 
4846
 
 
4847
REGISTER sip:example.com SIP/2.0
 
4848
Via: SIP/2.0/UDP saturn.example.com:5060;branch=z9hG4bKkdjuw
 
4849
Max-Forwards: 70
 
4850
From: sip:watson@example.com;tag=DkfVgjkrtMwaerKKpe
 
4851
To: sip:watson@example.com
 
4852
Call-ID: cparam01.70710@saturn.example.com
 
4853
CSeq: 2 REGISTER
 
4854
Contact: sip:+19725552222@gw1.example.net;unknownparam
 
4855
l: 0
 
4856
 
 
4857
 
 
4858
*/
 
4859
   FILE* fid= fopen("cparam01.dat","r");
 
4860
   tassert(fid);
 
4861
   resip::Data txt;
 
4862
   char mBuf[1024];
 
4863
   int result;
 
4864
   while(!feof(fid))
 
4865
   {
 
4866
      result = fread(&mBuf,1,1024,fid);
 
4867
      txt += resip::Data(mBuf,result);
 
4868
   }
 
4869
   fclose(fid);
 
4870
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4871
   tassert_reset();
 
4872
   tassert(msg);
 
4873
   tassert_reset();
 
4874
   if(!msg)
 
4875
   {
 
4876
      return;
 
4877
   }
 
4878
 
 
4879
   std::auto_ptr<resip::SipMessage> message(msg);
 
4880
   msg->parseAllHeaders();
 
4881
 
 
4882
   resip::SipMessage copy(*msg);
 
4883
 
 
4884
   resip::Data encoded;
 
4885
   {
 
4886
      resip::oDataStream str(encoded);
 
4887
      msg->encode(str);
 
4888
   }
 
4889
   resip::Data copyEncoded;
 
4890
   {
 
4891
      resip::oDataStream str(copyEncoded);
 
4892
      copy.encode(str);
 
4893
   }
 
4894
 
 
4895
   InfoLog(<< "In case cparam01:" );
 
4896
   InfoLog(<< "Original text:" << std::endl << txt );
 
4897
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4898
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4899
 
 
4900
 
 
4901
 
 
4902
 
 
4903
}
 
4904
 
 
4905
 
 
4906
void
 
4907
cparam02()
 
4908
{
 
4909
/*
 
4910
 
 
4911
REGISTER sip:example.com SIP/2.0
 
4912
Via: SIP/2.0/UDP saturn.example.com:5060;branch=z9hG4bKkdjuw
 
4913
Max-Forwards: 70
 
4914
From: sip:watson@example.com;tag=838293
 
4915
To: sip:watson@example.com
 
4916
Call-ID: cparam02.70710@saturn.example.com
 
4917
CSeq: 3 REGISTER
 
4918
Contact: <sip:+19725552222@gw1.example.net;unknownparam>
 
4919
l: 0
 
4920
 
 
4921
 
 
4922
*/
 
4923
   FILE* fid= fopen("cparam02.dat","r");
 
4924
   tassert(fid);
 
4925
   resip::Data txt;
 
4926
   char mBuf[1024];
 
4927
   int result;
 
4928
   while(!feof(fid))
 
4929
   {
 
4930
      result = fread(&mBuf,1,1024,fid);
 
4931
      txt += resip::Data(mBuf,result);
 
4932
   }
 
4933
   fclose(fid);
 
4934
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
4935
   tassert_reset();
 
4936
   tassert(msg);
 
4937
   tassert_reset();
 
4938
   if(!msg)
 
4939
   {
 
4940
      return;
 
4941
   }
 
4942
 
 
4943
   std::auto_ptr<resip::SipMessage> message(msg);
 
4944
   msg->parseAllHeaders();
 
4945
 
 
4946
   resip::SipMessage copy(*msg);
 
4947
 
 
4948
   resip::Data encoded;
 
4949
   {
 
4950
      resip::oDataStream str(encoded);
 
4951
      msg->encode(str);
 
4952
   }
 
4953
   resip::Data copyEncoded;
 
4954
   {
 
4955
      resip::oDataStream str(copyEncoded);
 
4956
      copy.encode(str);
 
4957
   }
 
4958
 
 
4959
   InfoLog(<< "In case cparam02:" );
 
4960
   InfoLog(<< "Original text:" << std::endl << txt );
 
4961
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
4962
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
4963
 
 
4964
 
 
4965
 
 
4966
 
 
4967
}
 
4968
 
 
4969
 
 
4970
void
 
4971
insuf()
 
4972
{
 
4973
/*
 
4974
 
 
4975
INVITE sip:user@example.com SIP/2.0
 
4976
CSeq: 193942 INVITE
 
4977
Via: SIP/2.0/UDP 192.0.2.95;branch=z9hG4bKkdj.insuf
 
4978
Content-Type: application/sdp
 
4979
l: 152
 
4980
 
 
4981
v=0
 
4982
o=mhandley 29739 7272939 IN IP4 192.0.2.95
 
4983
s=-
 
4984
c=IN IP4 192.0.2.95
 
4985
t=0 0
 
4986
m=audio 49217 RTP/AVP 0 12
 
4987
m=video 3227 RTP/AVP 31
 
4988
a=rtpmap:31 LPC
 
4989
 
 
4990
*/
 
4991
   FILE* fid= fopen("insuf.dat","r");
 
4992
   tassert(fid);
 
4993
   resip::Data txt;
 
4994
   char mBuf[1024];
 
4995
   int result;
 
4996
   while(!feof(fid))
 
4997
   {
 
4998
      result = fread(&mBuf,1,1024,fid);
 
4999
      txt += resip::Data(mBuf,result);
 
5000
   }
 
5001
   fclose(fid);
 
5002
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5003
   tassert_reset();
 
5004
   tassert(msg);
 
5005
   tassert_reset();
 
5006
   if(!msg)
 
5007
   {
 
5008
      return;
 
5009
   }
 
5010
 
 
5011
   std::auto_ptr<resip::SipMessage> message(msg);
 
5012
   msg->parseAllHeaders();
 
5013
 
 
5014
   resip::SipMessage copy(*msg);
 
5015
 
 
5016
   resip::Data encoded;
 
5017
   {
 
5018
      resip::oDataStream str(encoded);
 
5019
      msg->encode(str);
 
5020
   }
 
5021
   resip::Data copyEncoded;
 
5022
   {
 
5023
      resip::oDataStream str(copyEncoded);
 
5024
      copy.encode(str);
 
5025
   }
 
5026
 
 
5027
   InfoLog(<< "In case insuf:" );
 
5028
   InfoLog(<< "Original text:" << std::endl << txt );
 
5029
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5030
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5031
 
 
5032
 
 
5033
 
 
5034
 
 
5035
}
 
5036
 
 
5037
 
 
5038
void
 
5039
inv2543()
 
5040
{
 
5041
/*
 
5042
 
 
5043
INVITE sip:UserB@example.com SIP/2.0
 
5044
Via: SIP/2.0/UDP iftgw.example.com
 
5045
From: <sip:+13035551111@ift.client.example.net;user=phone>
 
5046
Record-Route: <sip:UserB@example.com;maddr=ss1.example.com>
 
5047
To: sip:+16505552222@ss1.example.net;user=phone
 
5048
Call-ID: inv2543.1717@ift.client.example.com
 
5049
CSeq: 56 INVITE
 
5050
Content-Type: application/sdp
 
5051
 
 
5052
v=0
 
5053
o=mhandley 29739 7272939 IN IP4 192.0.2.5
 
5054
s=-
 
5055
c=IN IP4 192.0.2.5
 
5056
t=0 0
 
5057
m=audio 49217 RTP/AVP 0
 
5058
 
 
5059
*/
 
5060
   FILE* fid= fopen("inv2543.dat","r");
 
5061
   tassert(fid);
 
5062
   resip::Data txt;
 
5063
   char mBuf[1024];
 
5064
   int result;
 
5065
   while(!feof(fid))
 
5066
   {
 
5067
      result = fread(&mBuf,1,1024,fid);
 
5068
      txt += resip::Data(mBuf,result);
 
5069
   }
 
5070
   fclose(fid);
 
5071
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5072
   tassert_reset();
 
5073
   tassert(msg);
 
5074
   tassert_reset();
 
5075
   if(!msg)
 
5076
   {
 
5077
      return;
 
5078
   }
 
5079
 
 
5080
   std::auto_ptr<resip::SipMessage> message(msg);
 
5081
   msg->parseAllHeaders();
 
5082
 
 
5083
   resip::SipMessage copy(*msg);
 
5084
 
 
5085
   resip::Data encoded;
 
5086
   {
 
5087
      resip::oDataStream str(encoded);
 
5088
      msg->encode(str);
 
5089
   }
 
5090
   resip::Data copyEncoded;
 
5091
   {
 
5092
      resip::oDataStream str(copyEncoded);
 
5093
      copy.encode(str);
 
5094
   }
 
5095
 
 
5096
   InfoLog(<< "In case inv2543:" );
 
5097
   InfoLog(<< "Original text:" << std::endl << txt );
 
5098
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5099
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5100
 
 
5101
 
 
5102
 
 
5103
 
 
5104
}
 
5105
 
 
5106
 
 
5107
void
 
5108
invut()
 
5109
{
 
5110
/*
 
5111
 
 
5112
INVITE sip:user@example.com SIP/2.0
 
5113
Contact: <sip:caller@host5.example.net>
 
5114
To: sip:j.user@example.com
 
5115
From: sip:caller@example.net;tag=8392034
 
5116
Max-Forwards: 70
 
5117
Call-ID: invut.0ha0isndaksdjadsfij34n23d
 
5118
CSeq: 235448 INVITE
 
5119
Via: SIP/2.0/UDP somehost.example.com;branch=z9hG4bKkdjuw
 
5120
Content-Type: application/unknownformat
 
5121
Content-Length: 40
 
5122
 
 
5123
<audio>
 
5124
 <pcmu port="443"/>
 
5125
</audio>
 
5126
 
 
5127
*/
 
5128
   FILE* fid= fopen("invut.dat","r");
 
5129
   tassert(fid);
 
5130
   resip::Data txt;
 
5131
   char mBuf[1024];
 
5132
   int result;
 
5133
   while(!feof(fid))
 
5134
   {
 
5135
      result = fread(&mBuf,1,1024,fid);
 
5136
      txt += resip::Data(mBuf,result);
 
5137
   }
 
5138
   fclose(fid);
 
5139
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5140
   tassert_reset();
 
5141
   tassert(msg);
 
5142
   tassert_reset();
 
5143
   if(!msg)
 
5144
   {
 
5145
      return;
 
5146
   }
 
5147
 
 
5148
   std::auto_ptr<resip::SipMessage> message(msg);
 
5149
   msg->parseAllHeaders();
 
5150
 
 
5151
   resip::SipMessage copy(*msg);
 
5152
 
 
5153
   resip::Data encoded;
 
5154
   {
 
5155
      resip::oDataStream str(encoded);
 
5156
      msg->encode(str);
 
5157
   }
 
5158
   resip::Data copyEncoded;
 
5159
   {
 
5160
      resip::oDataStream str(copyEncoded);
 
5161
      copy.encode(str);
 
5162
   }
 
5163
 
 
5164
   InfoLog(<< "In case invut:" );
 
5165
   InfoLog(<< "Original text:" << std::endl << txt );
 
5166
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5167
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5168
 
 
5169
 
 
5170
 
 
5171
 
 
5172
}
 
5173
 
 
5174
 
 
5175
void
 
5176
mcl01()
 
5177
{
 
5178
/*
 
5179
 
 
5180
OPTIONS sip:user@example.com SIP/2.0
 
5181
Via: SIP/2.0/UDP host5.example.net;branch=z9hG4bK293423
 
5182
To: sip:user@example.com
 
5183
From: sip:other@example.net;tag=3923942
 
5184
Call-ID: mcl01.fhn2323orihawfdoa3o4r52o3irsdf
 
5185
CSeq: 15932 OPTIONS
 
5186
Content-Length: 13
 
5187
Max-Forwards: 60
 
5188
Content-Length: 5
 
5189
Content-Type: text/plain
 
5190
 
 
5191
There's no way to know how many octets are supposed to be here.
 
5192
 
 
5193
 
 
5194
*/
 
5195
   FILE* fid= fopen("mcl01.dat","r");
 
5196
   tassert(fid);
 
5197
   resip::Data txt;
 
5198
   char mBuf[1024];
 
5199
   int result;
 
5200
   while(!feof(fid))
 
5201
   {
 
5202
      result = fread(&mBuf,1,1024,fid);
 
5203
      txt += resip::Data(mBuf,result);
 
5204
   }
 
5205
   fclose(fid);
 
5206
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5207
   tassert_reset();
 
5208
   tassert(msg);
 
5209
   tassert_reset();
 
5210
   if(!msg)
 
5211
   {
 
5212
      return;
 
5213
   }
 
5214
 
 
5215
   std::auto_ptr<resip::SipMessage> message(msg);
 
5216
   msg->parseAllHeaders();
 
5217
 
 
5218
   resip::SipMessage copy(*msg);
 
5219
 
 
5220
   resip::Data encoded;
 
5221
   {
 
5222
      resip::oDataStream str(encoded);
 
5223
      msg->encode(str);
 
5224
   }
 
5225
   resip::Data copyEncoded;
 
5226
   {
 
5227
      resip::oDataStream str(copyEncoded);
 
5228
      copy.encode(str);
 
5229
   }
 
5230
 
 
5231
   InfoLog(<< "In case mcl01:" );
 
5232
   InfoLog(<< "Original text:" << std::endl << txt );
 
5233
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5234
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5235
 
 
5236
 
 
5237
 
 
5238
 
 
5239
}
 
5240
 
 
5241
 
 
5242
void
 
5243
multi01()
 
5244
{
 
5245
/*
 
5246
 
 
5247
INVITE sip:user@company.com SIP/2.0
 
5248
Contact: <sip:caller@host25.example.net>
 
5249
Via: SIP/2.0/UDP 192.0.2.25;branch=z9hG4bKkdjuw
 
5250
Max-Forwards: 70
 
5251
CSeq: 5 INVITE
 
5252
Call-ID: multi01.98asdh@192.0.2.1
 
5253
CSeq: 59 INVITE
 
5254
Call-ID: multi01.98asdh@192.0.2.2
 
5255
From: sip:caller@example.com;tag=3413415
 
5256
To: sip:user@example.com
 
5257
To: sip:other@example.net
 
5258
From: sip:caller@example.net;tag=2923420123
 
5259
Content-Type: application/sdp
 
5260
l: 154
 
5261
Contact: <sip:caller@host36.example.net>
 
5262
Max-Forwards: 5
 
5263
 
 
5264
v=0
 
5265
o=mhandley 29739 7272939 IN IP4 192.0.2.25
 
5266
s=-
 
5267
c=IN IP4 192.0.2.25
 
5268
t=0 0
 
5269
m=audio 49217 RTP/AVP 0 12
 
5270
m=video 3227 RTP/AVP 31
 
5271
a=rtpmap:31 LPC
 
5272
 
 
5273
 
 
5274
*/
 
5275
   FILE* fid= fopen("multi01.dat","r");
 
5276
   tassert(fid);
 
5277
   resip::Data txt;
 
5278
   char mBuf[1024];
 
5279
   int result;
 
5280
   while(!feof(fid))
 
5281
   {
 
5282
      result = fread(&mBuf,1,1024,fid);
 
5283
      txt += resip::Data(mBuf,result);
 
5284
   }
 
5285
   fclose(fid);
 
5286
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5287
   tassert_reset();
 
5288
   tassert(msg);
 
5289
   tassert_reset();
 
5290
   if(!msg)
 
5291
   {
 
5292
      return;
 
5293
   }
 
5294
 
 
5295
   std::auto_ptr<resip::SipMessage> message(msg);
 
5296
   msg->parseAllHeaders();
 
5297
 
 
5298
   resip::SipMessage copy(*msg);
 
5299
 
 
5300
   resip::Data encoded;
 
5301
   {
 
5302
      resip::oDataStream str(encoded);
 
5303
      msg->encode(str);
 
5304
   }
 
5305
   resip::Data copyEncoded;
 
5306
   {
 
5307
      resip::oDataStream str(copyEncoded);
 
5308
      copy.encode(str);
 
5309
   }
 
5310
 
 
5311
   InfoLog(<< "In case multi01:" );
 
5312
   InfoLog(<< "Original text:" << std::endl << txt );
 
5313
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5314
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5315
 
 
5316
 
 
5317
 
 
5318
 
 
5319
}
 
5320
 
 
5321
 
 
5322
void
 
5323
novelsc()
 
5324
{
 
5325
/*
 
5326
 
 
5327
OPTIONS soap.beep://192.0.2.103:3002 SIP/2.0
 
5328
To: sip:user@example.com
 
5329
From: sip:caller@example.net;tag=384
 
5330
Max-Forwards: 3
 
5331
Call-ID: novelsc.asdfasser0q239nwsdfasdkl34
 
5332
CSeq: 3923423 OPTIONS
 
5333
Via: SIP/2.0/TCP host9.example.com;branch=z9hG4bKkdjuw39234
 
5334
Content-Length: 0
 
5335
 
 
5336
 
 
5337
*/
 
5338
   FILE* fid= fopen("novelsc.dat","r");
 
5339
   tassert(fid);
 
5340
   resip::Data txt;
 
5341
   char mBuf[1024];
 
5342
   int result;
 
5343
   while(!feof(fid))
 
5344
   {
 
5345
      result = fread(&mBuf,1,1024,fid);
 
5346
      txt += resip::Data(mBuf,result);
 
5347
   }
 
5348
   fclose(fid);
 
5349
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5350
   tassert_reset();
 
5351
   tassert(msg);
 
5352
   tassert_reset();
 
5353
   if(!msg)
 
5354
   {
 
5355
      return;
 
5356
   }
 
5357
 
 
5358
   std::auto_ptr<resip::SipMessage> message(msg);
 
5359
   msg->parseAllHeaders();
 
5360
 
 
5361
   resip::SipMessage copy(*msg);
 
5362
 
 
5363
   resip::Data encoded;
 
5364
   {
 
5365
      resip::oDataStream str(encoded);
 
5366
      msg->encode(str);
 
5367
   }
 
5368
   resip::Data copyEncoded;
 
5369
   {
 
5370
      resip::oDataStream str(copyEncoded);
 
5371
      copy.encode(str);
 
5372
   }
 
5373
 
 
5374
   InfoLog(<< "In case novelsc:" );
 
5375
   InfoLog(<< "Original text:" << std::endl << txt );
 
5376
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5377
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5378
 
 
5379
 
 
5380
 
 
5381
 
 
5382
}
 
5383
 
 
5384
 
 
5385
void
 
5386
regaut01()
 
5387
{
 
5388
/*
 
5389
 
 
5390
REGISTER sip:example.com SIP/2.0
 
5391
To: sip:j.user@example.com
 
5392
From: sip:j.user@example.com;tag=87321hj23128
 
5393
Max-Forwards: 8
 
5394
Call-ID: regaut01.0ha0isndaksdj
 
5395
CSeq: 9338 REGISTER
 
5396
Via: SIP/2.0/TCP 192.0.2.253;branch=z9hG4bKkdjuw
 
5397
Authorization: NoOneKnowsThisScheme opaque-data=here
 
5398
Content-Length:0
 
5399
 
 
5400
 
 
5401
*/
 
5402
   FILE* fid= fopen("regaut01.dat","r");
 
5403
   tassert(fid);
 
5404
   resip::Data txt;
 
5405
   char mBuf[1024];
 
5406
   int result;
 
5407
   while(!feof(fid))
 
5408
   {
 
5409
      result = fread(&mBuf,1,1024,fid);
 
5410
      txt += resip::Data(mBuf,result);
 
5411
   }
 
5412
   fclose(fid);
 
5413
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5414
   tassert_reset();
 
5415
   tassert(msg);
 
5416
   tassert_reset();
 
5417
   if(!msg)
 
5418
   {
 
5419
      return;
 
5420
   }
 
5421
 
 
5422
   std::auto_ptr<resip::SipMessage> message(msg);
 
5423
   msg->parseAllHeaders();
 
5424
 
 
5425
   resip::SipMessage copy(*msg);
 
5426
 
 
5427
   resip::Data encoded;
 
5428
   {
 
5429
      resip::oDataStream str(encoded);
 
5430
      msg->encode(str);
 
5431
   }
 
5432
   resip::Data copyEncoded;
 
5433
   {
 
5434
      resip::oDataStream str(copyEncoded);
 
5435
      copy.encode(str);
 
5436
   }
 
5437
 
 
5438
   InfoLog(<< "In case regaut01:" );
 
5439
   InfoLog(<< "Original text:" << std::endl << txt );
 
5440
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5441
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5442
 
 
5443
 
 
5444
 
 
5445
 
 
5446
}
 
5447
 
 
5448
 
 
5449
void
 
5450
regescrt()
 
5451
{
 
5452
/*
 
5453
 
 
5454
REGISTER sip:example.com SIP/2.0
 
5455
To: sip:user@example.com
 
5456
From: sip:user@example.com;tag=8
 
5457
Max-Forwards: 70
 
5458
Call-ID: regescrt.k345asrl3fdbv@192.0.2.1
 
5459
CSeq: 14398234 REGISTER
 
5460
Via: SIP/2.0/UDP host5.example.com;branch=z9hG4bKkdjuw
 
5461
M: <sip:user@example.com?Route=%3Csip:sip.example.com%3E>
 
5462
L:0
 
5463
 
 
5464
 
 
5465
*/
 
5466
   FILE* fid= fopen("regescrt.dat","r");
 
5467
   tassert(fid);
 
5468
   resip::Data txt;
 
5469
   char mBuf[1024];
 
5470
   int result;
 
5471
   while(!feof(fid))
 
5472
   {
 
5473
      result = fread(&mBuf,1,1024,fid);
 
5474
      txt += resip::Data(mBuf,result);
 
5475
   }
 
5476
   fclose(fid);
 
5477
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5478
   tassert_reset();
 
5479
   tassert(msg);
 
5480
   tassert_reset();
 
5481
   if(!msg)
 
5482
   {
 
5483
      return;
 
5484
   }
 
5485
 
 
5486
   std::auto_ptr<resip::SipMessage> message(msg);
 
5487
   msg->parseAllHeaders();
 
5488
 
 
5489
   resip::SipMessage copy(*msg);
 
5490
 
 
5491
   resip::Data encoded;
 
5492
   {
 
5493
      resip::oDataStream str(encoded);
 
5494
      msg->encode(str);
 
5495
   }
 
5496
   resip::Data copyEncoded;
 
5497
   {
 
5498
      resip::oDataStream str(copyEncoded);
 
5499
      copy.encode(str);
 
5500
   }
 
5501
 
 
5502
   InfoLog(<< "In case regescrt:" );
 
5503
   InfoLog(<< "Original text:" << std::endl << txt );
 
5504
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5505
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5506
 
 
5507
 
 
5508
 
 
5509
 
 
5510
}
 
5511
 
 
5512
 
 
5513
void
 
5514
sdp01()
 
5515
{
 
5516
/*
 
5517
 
 
5518
INVITE sip:user@example.com SIP/2.0
 
5519
To: sip:j_user@example.com
 
5520
Contact: <sip:caller@host15.example.net>
 
5521
From: sip:caller@example.net;tag=234
 
5522
Max-Forwards: 5
 
5523
Call-ID: sdp01.ndaksdj9342dasdd
 
5524
Accept: text/nobodyKnowsThis
 
5525
CSeq: 8 INVITE
 
5526
Via: SIP/2.0/UDP 192.0.2.15;branch=z9hG4bKkdjuw
 
5527
Content-Length: 150
 
5528
Content-Type: application/sdp
 
5529
 
 
5530
v=0
 
5531
o=mhandley 29739 7272939 IN IP4 192.0.2.5
 
5532
s=-
 
5533
c=IN IP4 192.0.2.5
 
5534
t=0 0
 
5535
m=audio 49217 RTP/AVP 0 12
 
5536
m=video 3227 RTP/AVP 31
 
5537
a=rtpmap:31 LPC
 
5538
 
 
5539
*/
 
5540
   FILE* fid= fopen("sdp01.dat","r");
 
5541
   tassert(fid);
 
5542
   resip::Data txt;
 
5543
   char mBuf[1024];
 
5544
   int result;
 
5545
   while(!feof(fid))
 
5546
   {
 
5547
      result = fread(&mBuf,1,1024,fid);
 
5548
      txt += resip::Data(mBuf,result);
 
5549
   }
 
5550
   fclose(fid);
 
5551
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5552
   tassert_reset();
 
5553
   tassert(msg);
 
5554
   tassert_reset();
 
5555
   if(!msg)
 
5556
   {
 
5557
      return;
 
5558
   }
 
5559
 
 
5560
   std::auto_ptr<resip::SipMessage> message(msg);
 
5561
   msg->parseAllHeaders();
 
5562
 
 
5563
   resip::SipMessage copy(*msg);
 
5564
 
 
5565
   resip::Data encoded;
 
5566
   {
 
5567
      resip::oDataStream str(encoded);
 
5568
      msg->encode(str);
 
5569
   }
 
5570
   resip::Data copyEncoded;
 
5571
   {
 
5572
      resip::oDataStream str(copyEncoded);
 
5573
      copy.encode(str);
 
5574
   }
 
5575
 
 
5576
   InfoLog(<< "In case sdp01:" );
 
5577
   InfoLog(<< "Original text:" << std::endl << txt );
 
5578
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5579
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5580
 
 
5581
 
 
5582
 
 
5583
 
 
5584
}
 
5585
 
 
5586
 
 
5587
void
 
5588
unkscm()
 
5589
{
 
5590
/*
 
5591
 
 
5592
OPTIONS nobodyKnowsThisScheme:totallyopaquecontent SIP/2.0
 
5593
To: sip:user@example.com
 
5594
From: sip:caller@example.net;tag=384
 
5595
Max-Forwards: 3
 
5596
Call-ID: unkscm.nasdfasser0q239nwsdfasdkl34
 
5597
CSeq: 3923423 OPTIONS
 
5598
Via: SIP/2.0/TCP host9.example.com;branch=z9hG4bKkdjuw39234
 
5599
Content-Length: 0
 
5600
 
 
5601
 
 
5602
*/
 
5603
   FILE* fid= fopen("unkscm.dat","r");
 
5604
   tassert(fid);
 
5605
   resip::Data txt;
 
5606
   char mBuf[1024];
 
5607
   int result;
 
5608
   while(!feof(fid))
 
5609
   {
 
5610
      result = fread(&mBuf,1,1024,fid);
 
5611
      txt += resip::Data(mBuf,result);
 
5612
   }
 
5613
   fclose(fid);
 
5614
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5615
   tassert_reset();
 
5616
   tassert(msg);
 
5617
   tassert_reset();
 
5618
   if(!msg)
 
5619
   {
 
5620
      return;
 
5621
   }
 
5622
 
 
5623
   std::auto_ptr<resip::SipMessage> message(msg);
 
5624
   msg->parseAllHeaders();
 
5625
 
 
5626
   resip::SipMessage copy(*msg);
 
5627
 
 
5628
   resip::Data encoded;
 
5629
   {
 
5630
      resip::oDataStream str(encoded);
 
5631
      msg->encode(str);
 
5632
   }
 
5633
   resip::Data copyEncoded;
 
5634
   {
 
5635
      resip::oDataStream str(copyEncoded);
 
5636
      copy.encode(str);
 
5637
   }
 
5638
 
 
5639
   InfoLog(<< "In case unkscm:" );
 
5640
   InfoLog(<< "Original text:" << std::endl << txt );
 
5641
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5642
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5643
 
 
5644
 
 
5645
 
 
5646
 
 
5647
}
 
5648
 
 
5649
 
 
5650
void
 
5651
unksm2()
 
5652
{
 
5653
/*
 
5654
 
 
5655
REGISTER sip:example.com SIP/2.0
 
5656
To: isbn:2983792873
 
5657
From: <http://www.example.com>;tag=3234233
 
5658
Call-ID: unksm2.daksdj@hyphenated-host.example.com
 
5659
CSeq: 234902 REGISTER
 
5660
Max-Forwards: 70
 
5661
Via: SIP/2.0/UDP 192.0.2.21:5060;branch=z9hG4bKkdjuw
 
5662
Contact: <name:John_Smith>
 
5663
l: 0
 
5664
 
 
5665
 
 
5666
*/
 
5667
   FILE* fid= fopen("unksm2.dat","r");
 
5668
   tassert(fid);
 
5669
   resip::Data txt;
 
5670
   char mBuf[1024];
 
5671
   int result;
 
5672
   while(!feof(fid))
 
5673
   {
 
5674
      result = fread(&mBuf,1,1024,fid);
 
5675
      txt += resip::Data(mBuf,result);
 
5676
   }
 
5677
   fclose(fid);
 
5678
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5679
   tassert_reset();
 
5680
   tassert(msg);
 
5681
   tassert_reset();
 
5682
   if(!msg)
 
5683
   {
 
5684
      return;
 
5685
   }
 
5686
 
 
5687
   std::auto_ptr<resip::SipMessage> message(msg);
 
5688
   msg->parseAllHeaders();
 
5689
 
 
5690
   resip::SipMessage copy(*msg);
 
5691
 
 
5692
   resip::Data encoded;
 
5693
   {
 
5694
      resip::oDataStream str(encoded);
 
5695
      msg->encode(str);
 
5696
   }
 
5697
   resip::Data copyEncoded;
 
5698
   {
 
5699
      resip::oDataStream str(copyEncoded);
 
5700
      copy.encode(str);
 
5701
   }
 
5702
 
 
5703
   InfoLog(<< "In case unksm2:" );
 
5704
   InfoLog(<< "Original text:" << std::endl << txt );
 
5705
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5706
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5707
 
 
5708
 
 
5709
 
 
5710
 
 
5711
}
 
5712
 
 
5713
 
 
5714
void
 
5715
zeromf()
 
5716
{
 
5717
/*
 
5718
 
 
5719
OPTIONS sip:user@example.com SIP/2.0
 
5720
To: sip:user@example.com
 
5721
From: sip:caller@example.net;tag=3ghsd41
 
5722
Call-ID: zeromf.jfasdlfnm2o2l43r5u0asdfas
 
5723
CSeq: 39234321 OPTIONS
 
5724
Via: SIP/2.0/UDP host1.example.com;branch=z9hG4bKkdjuw2349i
 
5725
Max-Forwards: 0
 
5726
Content-Length: 0
 
5727
 
 
5728
 
 
5729
*/
 
5730
   FILE* fid= fopen("zeromf.dat","r");
 
5731
   tassert(fid);
 
5732
   resip::Data txt;
 
5733
   char mBuf[1024];
 
5734
   int result;
 
5735
   while(!feof(fid))
 
5736
   {
 
5737
      result = fread(&mBuf,1,1024,fid);
 
5738
      txt += resip::Data(mBuf,result);
 
5739
   }
 
5740
   fclose(fid);
 
5741
   resip::SipMessage* msg = resip::SipMessage::make(txt);
 
5742
   tassert_reset();
 
5743
   tassert(msg);
 
5744
   tassert_reset();
 
5745
   if(!msg)
 
5746
   {
 
5747
      return;
 
5748
   }
 
5749
 
 
5750
   std::auto_ptr<resip::SipMessage> message(msg);
 
5751
   msg->parseAllHeaders();
 
5752
 
 
5753
   resip::SipMessage copy(*msg);
 
5754
 
 
5755
   resip::Data encoded;
 
5756
   {
 
5757
      resip::oDataStream str(encoded);
 
5758
      msg->encode(str);
 
5759
   }
 
5760
   resip::Data copyEncoded;
 
5761
   {
 
5762
      resip::oDataStream str(copyEncoded);
 
5763
      copy.encode(str);
 
5764
   }
 
5765
 
 
5766
   InfoLog(<< "In case zeromf:" );
 
5767
   InfoLog(<< "Original text:" << std::endl << txt );
 
5768
   InfoLog(<< "Encoded form:" << std::endl << encoded );
 
5769
   InfoLog(<< "Encoded form of copy:" << std::endl << copyEncoded );
 
5770
 
 
5771
 
 
5772
 
 
5773
 
 
5774
}
 
5775
 
 
5776
 
 
5777
int main()
 
5778
{
 
5779
 
 
5780
resip::SipMessage::checkContentLength=true;
 
5781
 
 
5782
resip::Log::initialize("cout", "DEBUG", "RFC4475TortureTests");
 
5783
try
 
5784
{
 
5785
   wsinv();
 
5786
}
 
5787
catch(resip::BaseException& e)
 
5788
{
 
5789
   tassert(0);
 
5790
   tassert_reset();
 
5791
   InfoLog(<< "Exception caught in test case wsinv : " << e );
 
5792
   InfoLog(<< "This message was valid." );
 
5793
}
 
5794
 
 
5795
 
 
5796
try
 
5797
{
 
5798
   intmeth();
 
5799
}
 
5800
catch(resip::BaseException& e)
 
5801
{
 
5802
   tassert(0);
 
5803
   tassert_reset();
 
5804
   InfoLog(<< "Exception caught in test case intmeth : " << e );
 
5805
   InfoLog(<< "This message was valid." );
 
5806
}
 
5807
 
 
5808
 
 
5809
try
 
5810
{
 
5811
   esc01();
 
5812
}
 
5813
catch(resip::BaseException& e)
 
5814
{
 
5815
   tassert(0);
 
5816
   tassert_reset();
 
5817
   InfoLog(<< "Exception caught in test case esc01 : " << e );
 
5818
   InfoLog(<< "This message was valid." );
 
5819
}
 
5820
 
 
5821
 
 
5822
try
 
5823
{
 
5824
   escnull();
 
5825
}
 
5826
catch(resip::BaseException& e)
 
5827
{
 
5828
   tassert(0);
 
5829
   tassert_reset();
 
5830
   InfoLog(<< "Exception caught in test case escnull : " << e );
 
5831
   InfoLog(<< "This message was valid." );
 
5832
}
 
5833
 
 
5834
 
 
5835
try
 
5836
{
 
5837
   esc02();
 
5838
}
 
5839
catch(resip::BaseException& e)
 
5840
{
 
5841
   tassert(0);
 
5842
   tassert_reset();
 
5843
   InfoLog(<< "Exception caught in test case esc02 : " << e );
 
5844
   InfoLog(<< "This message was valid." );
 
5845
}
 
5846
 
 
5847
 
 
5848
try
 
5849
{
 
5850
   lwsdisp();
 
5851
}
 
5852
catch(resip::BaseException& e)
 
5853
{
 
5854
   tassert(0);
 
5855
   tassert_reset();
 
5856
   InfoLog(<< "Exception caught in test case lwsdisp : " << e );
 
5857
   InfoLog(<< "This message was valid." );
 
5858
}
 
5859
 
 
5860
 
 
5861
try
 
5862
{
 
5863
   longreq();
 
5864
}
 
5865
catch(resip::BaseException& e)
 
5866
{
 
5867
   tassert(0);
 
5868
   tassert_reset();
 
5869
   InfoLog(<< "Exception caught in test case longreq : " << e );
 
5870
   InfoLog(<< "This message was valid." );
 
5871
}
 
5872
 
 
5873
 
 
5874
try
 
5875
{
 
5876
   dblreq();
 
5877
}
 
5878
catch(resip::BaseException& e)
 
5879
{
 
5880
   tassert(0);
 
5881
   tassert_reset();
 
5882
   InfoLog(<< "Exception caught in test case dblreq : " << e );
 
5883
   InfoLog(<< "This message was valid." );
 
5884
}
 
5885
 
 
5886
 
 
5887
try
 
5888
{
 
5889
   semiuri();
 
5890
}
 
5891
catch(resip::BaseException& e)
 
5892
{
 
5893
   tassert(0);
 
5894
   tassert_reset();
 
5895
   InfoLog(<< "Exception caught in test case semiuri : " << e );
 
5896
   InfoLog(<< "This message was valid." );
 
5897
}
 
5898
 
 
5899
 
 
5900
try
 
5901
{
 
5902
   transports();
 
5903
}
 
5904
catch(resip::BaseException& e)
 
5905
{
 
5906
   tassert(0);
 
5907
   tassert_reset();
 
5908
   InfoLog(<< "Exception caught in test case transports : " << e );
 
5909
   InfoLog(<< "This message was valid." );
 
5910
}
 
5911
 
 
5912
 
 
5913
try
 
5914
{
 
5915
   mpart01();
 
5916
}
 
5917
catch(resip::BaseException& e)
 
5918
{
 
5919
   tassert(0);
 
5920
   tassert_reset();
 
5921
   InfoLog(<< "Exception caught in test case mpart01 : " << e );
 
5922
   InfoLog(<< "This message was valid." );
 
5923
}
 
5924
 
 
5925
 
 
5926
try
 
5927
{
 
5928
   unreason();
 
5929
}
 
5930
catch(resip::BaseException& e)
 
5931
{
 
5932
   tassert(0);
 
5933
   tassert_reset();
 
5934
   InfoLog(<< "Exception caught in test case unreason : " << e );
 
5935
   InfoLog(<< "This message was valid." );
 
5936
}
 
5937
 
 
5938
 
 
5939
try
 
5940
{
 
5941
   noreason();
 
5942
}
 
5943
catch(resip::BaseException& e)
 
5944
{
 
5945
   tassert(0);
 
5946
   tassert_reset();
 
5947
   InfoLog(<< "Exception caught in test case noreason : " << e );
 
5948
   InfoLog(<< "This message was valid." );
 
5949
}
 
5950
 
 
5951
 
 
5952
try
 
5953
{
 
5954
   badinv01();
 
5955
}
 
5956
catch(resip::BaseException& e)
 
5957
{
 
5958
   InfoLog(<< "Exception caught in test case badinv01 : " << e );
 
5959
   InfoLog(<< "This message wasn't valid." );
 
5960
}
 
5961
 
 
5962
 
 
5963
try
 
5964
{
 
5965
   clerr();
 
5966
}
 
5967
catch(resip::BaseException& e)
 
5968
{
 
5969
   InfoLog(<< "Exception caught in test case clerr : " << e );
 
5970
   InfoLog(<< "This message wasn't valid." );
 
5971
}
 
5972
 
 
5973
 
 
5974
try
 
5975
{
 
5976
   scalar02();
 
5977
}
 
5978
catch(resip::BaseException& e)
 
5979
{
 
5980
   InfoLog(<< "Exception caught in test case scalar02 : " << e );
 
5981
   InfoLog(<< "This message wasn't valid." );
 
5982
}
 
5983
 
 
5984
 
 
5985
try
 
5986
{
 
5987
   scalarlg();
 
5988
}
 
5989
catch(resip::BaseException& e)
 
5990
{
 
5991
   InfoLog(<< "Exception caught in test case scalarlg : " << e );
 
5992
   InfoLog(<< "This message wasn't valid." );
 
5993
}
 
5994
 
 
5995
 
 
5996
try
 
5997
{
 
5998
   quotbal();
 
5999
}
 
6000
catch(resip::BaseException& e)
 
6001
{
 
6002
   InfoLog(<< "Exception caught in test case quotbal : " << e );
 
6003
   InfoLog(<< "This message wasn't valid." );
 
6004
}
 
6005
 
 
6006
 
 
6007
try
 
6008
{
 
6009
   ltgtruri();
 
6010
}
 
6011
catch(resip::BaseException& e)
 
6012
{
 
6013
   InfoLog(<< "Exception caught in test case ltgtruri : " << e );
 
6014
   InfoLog(<< "This message wasn't valid." );
 
6015
}
 
6016
 
 
6017
 
 
6018
try
 
6019
{
 
6020
   lwsruri();
 
6021
}
 
6022
catch(resip::BaseException& e)
 
6023
{
 
6024
   InfoLog(<< "Exception caught in test case lwsruri : " << e );
 
6025
   InfoLog(<< "This message wasn't valid." );
 
6026
}
 
6027
 
 
6028
 
 
6029
try
 
6030
{
 
6031
   lwsstart();
 
6032
}
 
6033
catch(resip::BaseException& e)
 
6034
{
 
6035
   InfoLog(<< "Exception caught in test case lwsstart : " << e );
 
6036
   InfoLog(<< "This message wasn't valid." );
 
6037
}
 
6038
 
 
6039
 
 
6040
try
 
6041
{
 
6042
   trws();
 
6043
}
 
6044
catch(resip::BaseException& e)
 
6045
{
 
6046
   InfoLog(<< "Exception caught in test case trws : " << e );
 
6047
   InfoLog(<< "This message wasn't valid." );
 
6048
}
 
6049
 
 
6050
 
 
6051
try
 
6052
{
 
6053
   escruri();
 
6054
}
 
6055
catch(resip::BaseException& e)
 
6056
{
 
6057
   InfoLog(<< "Exception caught in test case escruri : " << e );
 
6058
   InfoLog(<< "This message wasn't valid." );
 
6059
}
 
6060
 
 
6061
 
 
6062
try
 
6063
{
 
6064
   baddate();
 
6065
}
 
6066
catch(resip::BaseException& e)
 
6067
{
 
6068
   InfoLog(<< "Exception caught in test case baddate : " << e );
 
6069
   InfoLog(<< "This message wasn't valid." );
 
6070
}
 
6071
 
 
6072
 
 
6073
try
 
6074
{
 
6075
   regbadct();
 
6076
}
 
6077
catch(resip::BaseException& e)
 
6078
{
 
6079
   InfoLog(<< "Exception caught in test case regbadct : " << e );
 
6080
   InfoLog(<< "This message wasn't valid." );
 
6081
}
 
6082
 
 
6083
 
 
6084
try
 
6085
{
 
6086
   badaspec();
 
6087
}
 
6088
catch(resip::BaseException& e)
 
6089
{
 
6090
   InfoLog(<< "Exception caught in test case badaspec : " << e );
 
6091
   InfoLog(<< "This message wasn't valid." );
 
6092
}
 
6093
 
 
6094
 
 
6095
try
 
6096
{
 
6097
   baddn();
 
6098
}
 
6099
catch(resip::BaseException& e)
 
6100
{
 
6101
   InfoLog(<< "Exception caught in test case baddn : " << e );
 
6102
   InfoLog(<< "This message wasn't valid." );
 
6103
}
 
6104
 
 
6105
 
 
6106
try
 
6107
{
 
6108
   badvers();
 
6109
}
 
6110
catch(resip::BaseException& e)
 
6111
{
 
6112
   InfoLog(<< "Exception caught in test case badvers : " << e );
 
6113
   InfoLog(<< "This message wasn't valid." );
 
6114
}
 
6115
 
 
6116
 
 
6117
try
 
6118
{
 
6119
   mismatch01();
 
6120
}
 
6121
catch(resip::BaseException& e)
 
6122
{
 
6123
   InfoLog(<< "Exception caught in test case mismatch01 : " << e );
 
6124
   InfoLog(<< "This message wasn't valid." );
 
6125
}
 
6126
 
 
6127
 
 
6128
try
 
6129
{
 
6130
   mismatch02();
 
6131
}
 
6132
catch(resip::BaseException& e)
 
6133
{
 
6134
   InfoLog(<< "Exception caught in test case mismatch02 : " << e );
 
6135
   InfoLog(<< "This message wasn't valid." );
 
6136
}
 
6137
 
 
6138
 
 
6139
try
 
6140
{
 
6141
   bigcode();
 
6142
}
 
6143
catch(resip::BaseException& e)
 
6144
{
 
6145
   InfoLog(<< "Exception caught in test case bigcode : " << e );
 
6146
   InfoLog(<< "This message wasn't valid." );
 
6147
}
 
6148
 
 
6149
 
 
6150
try
 
6151
{
 
6152
   badbranch();
 
6153
}
 
6154
catch(resip::BaseException& e)
 
6155
{
 
6156
   tassert(0);
 
6157
   tassert_reset();
 
6158
   InfoLog(<< "Exception caught in test case badbranch : " << e );
 
6159
   InfoLog(<< "This message was (syntactically) valid." );
 
6160
}
 
6161
 
 
6162
 
 
6163
try
 
6164
{
 
6165
   bcast();
 
6166
}
 
6167
catch(resip::BaseException& e)
 
6168
{
 
6169
   InfoLog(<< "Exception caught in test case bcast : " << e );
 
6170
   InfoLog(<< "This message was/wasn't valid." );
 
6171
}
 
6172
 
 
6173
 
 
6174
try
 
6175
{
 
6176
   bext01();
 
6177
}
 
6178
catch(resip::BaseException& e)
 
6179
{
 
6180
   InfoLog(<< "Exception caught in test case bext01 : " << e );
 
6181
   InfoLog(<< "This message was/wasn't valid." );
 
6182
}
 
6183
 
 
6184
 
 
6185
try
 
6186
{
 
6187
   cparam01();
 
6188
}
 
6189
catch(resip::BaseException& e)
 
6190
{
 
6191
   InfoLog(<< "Exception caught in test case cparam01 : " << e );
 
6192
   InfoLog(<< "This message was/wasn't valid." );
 
6193
}
 
6194
 
 
6195
 
 
6196
try
 
6197
{
 
6198
   cparam02();
 
6199
}
 
6200
catch(resip::BaseException& e)
 
6201
{
 
6202
   InfoLog(<< "Exception caught in test case cparam02 : " << e );
 
6203
   InfoLog(<< "This message was/wasn't valid." );
 
6204
}
 
6205
 
 
6206
 
 
6207
try
 
6208
{
 
6209
   insuf();
 
6210
}
 
6211
catch(resip::BaseException& e)
 
6212
{
 
6213
   InfoLog(<< "Exception caught in test case insuf : " << e );
 
6214
   InfoLog(<< "This message was/wasn't valid." );
 
6215
}
 
6216
 
 
6217
 
 
6218
try
 
6219
{
 
6220
   inv2543();
 
6221
}
 
6222
catch(resip::BaseException& e)
 
6223
{
 
6224
   InfoLog(<< "Exception caught in test case inv2543 : " << e );
 
6225
   InfoLog(<< "This message was/wasn't valid." );
 
6226
}
 
6227
 
 
6228
 
 
6229
try
 
6230
{
 
6231
   invut();
 
6232
}
 
6233
catch(resip::BaseException& e)
 
6234
{
 
6235
   InfoLog(<< "Exception caught in test case invut : " << e );
 
6236
   InfoLog(<< "This message was/wasn't valid." );
 
6237
}
 
6238
 
 
6239
 
 
6240
try
 
6241
{
 
6242
   mcl01();
 
6243
}
 
6244
catch(resip::BaseException& e)
 
6245
{
 
6246
   InfoLog(<< "Exception caught in test case mcl01 : " << e );
 
6247
   InfoLog(<< "This message was/wasn't valid." );
 
6248
}
 
6249
 
 
6250
 
 
6251
try
 
6252
{
 
6253
   multi01();
 
6254
}
 
6255
catch(resip::BaseException& e)
 
6256
{
 
6257
   InfoLog(<< "Exception caught in test case multi01 : " << e );
 
6258
   InfoLog(<< "This message was/wasn't valid." );
 
6259
}
 
6260
 
 
6261
 
 
6262
try
 
6263
{
 
6264
   ncl();
 
6265
}
 
6266
catch(resip::BaseException& e)
 
6267
{
 
6268
   InfoLog(<< "Exception caught in test case ncl : " << e );
 
6269
   InfoLog(<< "This message wasn't valid." );
 
6270
}
 
6271
 
 
6272
 
 
6273
try
 
6274
{
 
6275
   novelsc();
 
6276
}
 
6277
catch(resip::BaseException& e)
 
6278
{
 
6279
   InfoLog(<< "Exception caught in test case novelsc : " << e );
 
6280
   InfoLog(<< "This message was/wasn't valid." );
 
6281
}
 
6282
 
 
6283
 
 
6284
try
 
6285
{
 
6286
   regaut01();
 
6287
}
 
6288
catch(resip::BaseException& e)
 
6289
{
 
6290
   InfoLog(<< "Exception caught in test case regaut01 : " << e );
 
6291
   InfoLog(<< "This message was/wasn't valid." );
 
6292
}
 
6293
 
 
6294
 
 
6295
try
 
6296
{
 
6297
   regescrt();
 
6298
}
 
6299
catch(resip::BaseException& e)
 
6300
{
 
6301
   InfoLog(<< "Exception caught in test case regescrt : " << e );
 
6302
   InfoLog(<< "This message was/wasn't valid." );
 
6303
}
 
6304
 
 
6305
 
 
6306
try
 
6307
{
 
6308
   sdp01();
 
6309
}
 
6310
catch(resip::BaseException& e)
 
6311
{
 
6312
   InfoLog(<< "Exception caught in test case sdp01 : " << e );
 
6313
   InfoLog(<< "This message was/wasn't valid." );
 
6314
}
 
6315
 
 
6316
 
 
6317
try
 
6318
{
 
6319
   unkscm();
 
6320
}
 
6321
catch(resip::BaseException& e)
 
6322
{
 
6323
   InfoLog(<< "Exception caught in test case unkscm : " << e );
 
6324
   InfoLog(<< "This message was/wasn't valid." );
 
6325
}
 
6326
 
 
6327
 
 
6328
try
 
6329
{
 
6330
   unksm2();
 
6331
}
 
6332
catch(resip::BaseException& e)
 
6333
{
 
6334
   InfoLog(<< "Exception caught in test case unksm2 : " << e );
 
6335
   InfoLog(<< "This message was/wasn't valid." );
 
6336
}
 
6337
 
 
6338
 
 
6339
try
 
6340
{
 
6341
   zeromf();
 
6342
}
 
6343
catch(resip::BaseException& e)
 
6344
{
 
6345
   InfoLog(<< "Exception caught in test case zeromf : " << e );
 
6346
   InfoLog(<< "This message was/wasn't valid." );
 
6347
}
 
6348
 
 
6349
 
 
6350
}
 
6351
 
 
6352
/* ====================================================================
 
6353
 * The Vovida Software License, Version 1.0
 
6354
 *
 
6355
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
 
6356
 *
 
6357
 * Redistribution and use in source and binary forms, with or without
 
6358
 * modification, are permitted provided that the following conditions
 
6359
 * are met:
 
6360
 *
 
6361
 * 1. Redistributions of source code must retain the above copyright
 
6362
 *    notice, this list of conditions and the following disclaimer.
 
6363
 *
 
6364
 * 2. Redistributions in binary form must reproduce the above copyright
 
6365
 *    notice, this list of conditions and the following disclaimer in
 
6366
 *    the documentation and/or other materials provided with the
 
6367
 *    distribution.
 
6368
 *
 
6369
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
 
6370
 *    and "Vovida Open Communication Application Library (VOCAL)" must
 
6371
 *    not be used to endorse or promote products derived from this
 
6372
 *    software without prior written permission. For written
 
6373
 *    permission, please contact vocal@vovida.org.
 
6374
 *
 
6375
 * 4. Products derived from this software may not be called "VOCAL", nor
 
6376
 *    may "VOCAL" appear in their name, without prior written
 
6377
 *    permission of Vovida Networks, Inc.
 
6378
 *
 
6379
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
 
6380
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
6381
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
 
6382
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
 
6383
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
 
6384
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
 
6385
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
6386
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
6387
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 
6388
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
6389
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 
6390
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 
6391
 * DAMAGE.
 
6392
 *
 
6393
 * ====================================================================
 
6394
 *
 
6395
 * This software consists of voluntary contributions made by Vovida
 
6396
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
 
6397
 * Inc.  For more information on Vovida Networks, Inc., please see
 
6398
 * <http://www.vovida.org/>.
 
6399
 *
 
6400
 */