~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/pjsip/src/test/uri_test.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: uri_test.c 3553 2011-05-05 06:14:19Z nanang $ */
2
 
/*
3
 
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
 
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 
 */
20
 
#include "test.h"
21
 
#include <pjsip.h>
22
 
#include <pjlib.h>
23
 
 
24
 
#define THIS_FILE   "uri_test.c"
25
 
 
26
 
 
27
 
#define ALPHANUM    "abcdefghijklmnopqrstuvwxyz" \
28
 
                    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
29
 
                    "0123456789"
30
 
#define MARK        "-_.!~*'()"
31
 
#define USER_CHAR   ALPHANUM MARK "&=+$,;?/"
32
 
#define PASS_CHAR   ALPHANUM MARK "&=+$,"
33
 
#define PARAM_CHAR  ALPHANUM MARK "[]/:&+$"
34
 
 
35
 
#define POOL_SIZE       8000
36
 
#if defined(PJ_DEBUG) && PJ_DEBUG!=0
37
 
#   define LOOP_COUNT   10000
38
 
#else
39
 
#   define LOOP_COUNT   40000
40
 
#endif
41
 
#define AVERAGE_URL_LEN 80
42
 
#define THREAD_COUNT    4
43
 
 
44
 
static struct
45
 
{
46
 
    pj_highprec_t parse_len, print_len, cmp_len;
47
 
    pj_timestamp  parse_time, print_time, cmp_time;
48
 
} var;
49
 
 
50
 
 
51
 
/* URI creator functions. */
52
 
static pjsip_uri *create_uri0( pj_pool_t *pool );
53
 
static pjsip_uri *create_uri1( pj_pool_t *pool );
54
 
static pjsip_uri *create_uri2( pj_pool_t *pool );
55
 
static pjsip_uri *create_uri3( pj_pool_t *pool );
56
 
static pjsip_uri *create_uri4( pj_pool_t *pool );
57
 
static pjsip_uri *create_uri5( pj_pool_t *pool );
58
 
static pjsip_uri *create_uri6( pj_pool_t *pool );
59
 
static pjsip_uri *create_uri7( pj_pool_t *pool );
60
 
static pjsip_uri *create_uri8( pj_pool_t *pool );
61
 
static pjsip_uri *create_uri9( pj_pool_t *pool );
62
 
static pjsip_uri *create_uri10( pj_pool_t *pool );
63
 
static pjsip_uri *create_uri11( pj_pool_t *pool );
64
 
static pjsip_uri *create_uri12( pj_pool_t *pool );
65
 
static pjsip_uri *create_uri13( pj_pool_t *pool );
66
 
static pjsip_uri *create_uri14( pj_pool_t *pool );
67
 
static pjsip_uri *create_uri15( pj_pool_t *pool );
68
 
static pjsip_uri *create_uri16( pj_pool_t *pool );
69
 
static pjsip_uri *create_uri17( pj_pool_t *pool );
70
 
static pjsip_uri *create_uri25( pj_pool_t *pool );
71
 
static pjsip_uri *create_uri26( pj_pool_t *pool );
72
 
static pjsip_uri *create_uri27( pj_pool_t *pool );
73
 
static pjsip_uri *create_uri28( pj_pool_t *pool );
74
 
static pjsip_uri *create_uri29( pj_pool_t *pool );
75
 
static pjsip_uri *create_uri30( pj_pool_t *pool );
76
 
static pjsip_uri *create_uri31( pj_pool_t *pool );
77
 
static pjsip_uri *create_uri32( pj_pool_t *pool );
78
 
static pjsip_uri *create_uri33( pj_pool_t *pool );
79
 
static pjsip_uri *create_uri34( pj_pool_t *pool );
80
 
static pjsip_uri *create_uri35( pj_pool_t *pool );
81
 
static pjsip_uri *create_uri36( pj_pool_t *pool );
82
 
static pjsip_uri *create_uri37( pj_pool_t *pool );
83
 
static pjsip_uri *create_uri38( pj_pool_t *pool );
84
 
static pjsip_uri *create_dummy( pj_pool_t *pool );
85
 
 
86
 
#define ERR_NOT_EQUAL   -1001
87
 
#define ERR_SYNTAX_ERR  -1002
88
 
 
89
 
struct uri_test
90
 
{
91
 
    pj_status_t      status;
92
 
    char             str[PJSIP_MAX_URL_SIZE];
93
 
    pjsip_uri       *(*creator)(pj_pool_t *pool);
94
 
    const char      *printed;
95
 
    pj_size_t        len;
96
 
} uri_test_array[] =
97
 
{
98
 
    {
99
 
        PJ_SUCCESS,
100
 
        "sip:localhost",
101
 
        &create_uri0
102
 
    },
103
 
    {
104
 
        PJ_SUCCESS,
105
 
        "sip:user@localhost",
106
 
        &create_uri1
107
 
    },
108
 
    {
109
 
        PJ_SUCCESS,
110
 
        "sip:user:password@localhost:5060",
111
 
        &create_uri2,    },
112
 
    {
113
 
        /* Port is specified should not match unspecified port. */
114
 
        ERR_NOT_EQUAL,
115
 
        "sip:localhost:5060",
116
 
        &create_uri3
117
 
    },
118
 
    {
119
 
        /* All recognized parameters. */
120
 
        PJ_SUCCESS,
121
 
        "sip:localhost;transport=tcp;user=ip;ttl=255;lr;maddr=127.0.0.1;method=ACK",
122
 
        &create_uri4
123
 
    },
124
 
    {
125
 
        /* Params mixed with other params and header params. */
126
 
        PJ_SUCCESS,
127
 
        "sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
128
 
        "?Subject=Hello%20There&Server=SIP%20Server",
129
 
        &create_uri5
130
 
    },
131
 
    {
132
 
        /* SIPS. */
133
 
        PJ_SUCCESS,
134
 
        "sips:localhost",
135
 
        &create_uri6,
136
 
    },
137
 
    {
138
 
        /* Name address */
139
 
        PJ_SUCCESS,
140
 
        "<sip:localhost>",
141
 
        &create_uri7
142
 
    },
143
 
    {
144
 
        /* Name address with display name and SIPS scheme with some redundant
145
 
         * whitespaced.
146
 
         */
147
 
        PJ_SUCCESS,
148
 
        "  Power Administrator  <sips:localhost>",
149
 
        &create_uri8
150
 
    },
151
 
    {
152
 
        /* Name address. */
153
 
        PJ_SUCCESS,
154
 
        " \"User\" <sip:user@localhost:5071>",
155
 
        &create_uri9
156
 
    },
157
 
    {
158
 
        /* Escaped sequence in display name (display=Strange User\"\\\"). */
159
 
        PJ_SUCCESS,
160
 
        " \"Strange User\\\"\\\\\\\"\" <sip:localhost>",
161
 
        &create_uri10,
162
 
    },
163
 
    {
164
 
        /* Errorneous escaping in display name. */
165
 
        ERR_SYNTAX_ERR,
166
 
        " \"Rogue User\\\" <sip:localhost>",
167
 
        &create_uri11,
168
 
    },
169
 
    {
170
 
        /* Dangling quote in display name, but that should be OK. */
171
 
        PJ_SUCCESS,
172
 
        "Strange User\" <sip:localhost>",
173
 
        &create_uri12,
174
 
    },
175
 
    {
176
 
        /* Special characters in parameter value must be quoted. */
177
 
        PJ_SUCCESS,
178
 
        "sip:localhost;pvalue=\"hello world\"",
179
 
        &create_uri13,
180
 
    },
181
 
    {
182
 
        /* Excercise strange character sets allowed in display, user, password,
183
 
         * host, and port.
184
 
         */
185
 
        PJ_SUCCESS,
186
 
        "This is -. !% *_+`'~ me <sip:a19A&=+$,;?/%2c:%40a&Zz=+$,@"
187
 
        "my_proxy09.MY-domain.com:9801>",
188
 
        &create_uri14,
189
 
    },
190
 
    {
191
 
        /* Another excercise to the allowed character sets to the hostname. */
192
 
        PJ_SUCCESS,
193
 
        "sip:" ALPHANUM "-_.com",
194
 
        &create_uri15,
195
 
    },
196
 
    {
197
 
        /* Another excercise to the allowed character sets to the username
198
 
         * and password.
199
 
         */
200
 
        PJ_SUCCESS,
201
 
        "sip:" USER_CHAR ":" PASS_CHAR "@host",
202
 
        &create_uri16,
203
 
    },
204
 
    {
205
 
        /* Excercise to the pname and pvalue, and mixup of other-param
206
 
         * between 'recognized' params.
207
 
         */
208
 
        PJ_SUCCESS,
209
 
        "sip:host;user=ip;" PARAM_CHAR "%21=" PARAM_CHAR "%21"
210
 
        ";lr;other=1;transport=sctp;other2",
211
 
        &create_uri17,
212
 
    },
213
 
    {
214
 
        /* 18: This should trigger syntax error. */
215
 
        ERR_SYNTAX_ERR,
216
 
        "sip:",
217
 
        &create_dummy,
218
 
    },
219
 
    {
220
 
        /* 19: Syntax error: whitespace after scheme. */
221
 
        ERR_SYNTAX_ERR,
222
 
        "sip :host",
223
 
        &create_dummy,
224
 
    },
225
 
    {
226
 
        /* 20: Syntax error: whitespace before hostname. */
227
 
        ERR_SYNTAX_ERR,
228
 
        "sip: host",
229
 
        &create_dummy,
230
 
    },
231
 
    {
232
 
        /* 21: Syntax error: invalid port. */
233
 
        ERR_SYNTAX_ERR,
234
 
        "sip:user:password",
235
 
        &create_dummy,
236
 
    },
237
 
    {
238
 
        /* 22: Syntax error: no host. */
239
 
        ERR_SYNTAX_ERR,
240
 
        "sip:user@",
241
 
        &create_dummy,
242
 
    },
243
 
    {
244
 
        /* 23: Syntax error: no user/host. */
245
 
        ERR_SYNTAX_ERR,
246
 
        "sip:@",
247
 
        &create_dummy,
248
 
    },
249
 
    {
250
 
        /* 24: Syntax error: empty string. */
251
 
        ERR_SYNTAX_ERR,
252
 
        "",
253
 
        &create_dummy,
254
 
    },
255
 
    {
256
 
        /* 25: Simple tel: URI with global context */
257
 
        PJ_SUCCESS,
258
 
        "tel:+1-201-555-0123",
259
 
        &create_uri25,
260
 
        "tel:+1-201-555-0123"
261
 
    },
262
 
    {
263
 
        /* 26: Simple tel: URI with local context */
264
 
        PJ_SUCCESS,
265
 
        "tel:7042;phone-context=example.com",
266
 
        &create_uri26,
267
 
        "tel:7042;phone-context=example.com"
268
 
    },
269
 
    {
270
 
        /* 27: Simple tel: URI with local context */
271
 
        PJ_SUCCESS,
272
 
        "tel:863-1234;phone-context=+1-914-555",
273
 
        &create_uri27,
274
 
        "tel:863-1234;phone-context=+1-914-555"
275
 
    },
276
 
    {
277
 
        /* 28: Comparison between local and global number */
278
 
        ERR_NOT_EQUAL,
279
 
        "tel:+1",
280
 
        &create_uri28,
281
 
        "tel:+1"
282
 
    },
283
 
    {
284
 
        /* 29: tel: with some visual chars and spaces */
285
 
        PJ_SUCCESS,
286
 
        "tel:(44).1234-*#+Deaf",
287
 
        &create_uri29,
288
 
        "tel:(44).1234-*#+Deaf"
289
 
    },
290
 
    {
291
 
        /* 30: isub parameters */
292
 
        PJ_SUCCESS,
293
 
        "tel:+1;isub=/:@&$,-_.!~*'()[]/:&$aA1%21+=",
294
 
        &create_uri30,
295
 
        "tel:+1;isub=/:@&$,-_.!~*'()[]/:&$aA1!+%3d"
296
 
    },
297
 
    {
298
 
        /* 31: extension number parsing and encoding */
299
 
        PJ_SUCCESS,
300
 
        "tel:+1;ext=+123",
301
 
        &create_uri31,
302
 
        "tel:+1;ext=%2b123"
303
 
    },
304
 
    {
305
 
        /* 32: context parameter parsing and encoding */
306
 
        PJ_SUCCESS,
307
 
        "tel:911;phone-context=+1-911",
308
 
        &create_uri32,
309
 
        "tel:911;phone-context=+1-911"
310
 
    },
311
 
    {
312
 
        /* 33: case-insensitive comparison */
313
 
        PJ_SUCCESS,
314
 
        "tel:911;phone-context=emergency.example.com",
315
 
        &create_uri33,
316
 
        "tel:911;phone-context=emergency.example.com"
317
 
    },
318
 
    {
319
 
        /* 34: parameter only appears in one URL */
320
 
        ERR_NOT_EQUAL,
321
 
        "tel:911;p1=p1;p2=p2",
322
 
        &create_uri34,
323
 
        "tel:911;p1=p1;p2=p2"
324
 
    },
325
 
    {
326
 
        /* 35: IPv6 in host and maddr parameter */
327
 
        PJ_SUCCESS,
328
 
        "sip:user@[::1];maddr=[::01]",
329
 
        &create_uri35,
330
 
        "sip:user@[::1];maddr=[::01]"
331
 
    },
332
 
    {
333
 
        /* 36: IPv6 in host and maddr, without username */
334
 
        PJ_SUCCESS,
335
 
        "sip:[::1];maddr=[::01]",
336
 
        &create_uri36,
337
 
        "sip:[::1];maddr=[::01]"
338
 
    },
339
 
    {
340
 
        /* 37: Non-ASCII UTF-8 in display name, with quote */
341
 
        PJ_SUCCESS,
342
 
        "\"\xC0\x81\" <sip:localhost>",
343
 
        &create_uri37,
344
 
        "\"\xC0\x81\" <sip:localhost>"
345
 
    },
346
 
    {
347
 
        /* 38: Non-ASCII UTF-8 in display name, without quote */
348
 
        PJ_SUCCESS,
349
 
        "\xC0\x81 <sip:localhost>",
350
 
        &create_uri38,
351
 
        "\"\xC0\x81\" <sip:localhost>"
352
 
    }
353
 
 
354
 
};
355
 
 
356
 
static pjsip_uri *create_uri0(pj_pool_t *pool)
357
 
{
358
 
    /* "sip:localhost" */
359
 
    pjsip_sip_uri *url = pjsip_sip_uri_create(pool, 0);
360
 
 
361
 
    pj_strdup2(pool, &url->host, "localhost");
362
 
    return (pjsip_uri*)url;
363
 
}
364
 
 
365
 
static pjsip_uri *create_uri1(pj_pool_t *pool)
366
 
{
367
 
    /* "sip:user@localhost" */
368
 
    pjsip_sip_uri *url = pjsip_sip_uri_create(pool, 0);
369
 
 
370
 
    pj_strdup2( pool, &url->user, "user");
371
 
    pj_strdup2( pool, &url->host, "localhost");
372
 
 
373
 
    return (pjsip_uri*) url;
374
 
}
375
 
 
376
 
static pjsip_uri *create_uri2(pj_pool_t *pool)
377
 
{
378
 
    /* "sip:user:password@localhost:5060" */
379
 
    pjsip_sip_uri *url = pjsip_sip_uri_create(pool, 0);
380
 
 
381
 
    pj_strdup2( pool, &url->user, "user");
382
 
    pj_strdup2( pool, &url->passwd, "password");
383
 
    pj_strdup2( pool, &url->host, "localhost");
384
 
    url->port = 5060;
385
 
 
386
 
    return (pjsip_uri*) url;
387
 
}
388
 
 
389
 
static pjsip_uri *create_uri3(pj_pool_t *pool)
390
 
{
391
 
    /* Like: "sip:localhost:5060", but without the port. */
392
 
    pjsip_sip_uri *url = pjsip_sip_uri_create(pool, 0);
393
 
 
394
 
    pj_strdup2(pool, &url->host, "localhost");
395
 
    return (pjsip_uri*)url;
396
 
}
397
 
 
398
 
static pjsip_uri *create_uri4(pj_pool_t *pool)
399
 
{
400
 
    /* "sip:localhost;transport=tcp;user=ip;ttl=255;lr;maddr=127.0.0.1;method=ACK" */
401
 
    pjsip_sip_uri *url = pjsip_sip_uri_create(pool, 0);
402
 
 
403
 
    pj_strdup2(pool, &url->host, "localhost");
404
 
    pj_strdup2(pool, &url->transport_param, "tcp");
405
 
    pj_strdup2(pool, &url->user_param, "ip");
406
 
    url->ttl_param = 255;
407
 
    url->lr_param = 1;
408
 
    pj_strdup2(pool, &url->maddr_param, "127.0.0.1");
409
 
    pj_strdup2(pool, &url->method_param, "ACK");
410
 
 
411
 
    return (pjsip_uri*)url;
412
 
}
413
 
 
414
 
#define param_add(list,pname,pvalue)  \
415
 
        do { \
416
 
            pjsip_param *param; \
417
 
            param=PJ_POOL_ALLOC_T(pool, pjsip_param); \
418
 
            param->name = pj_str(pname); \
419
 
            param->value = pj_str(pvalue); \
420
 
            pj_list_insert_before(&list, param); \
421
 
        } while (0)
422
 
 
423
 
static pjsip_uri *create_uri5(pj_pool_t *pool)
424
 
{
425
 
    /* "sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
426
 
       "?Subject=Hello%20There&Server=SIP%20Server"
427
 
     */
428
 
    pjsip_sip_uri *url = pjsip_sip_uri_create(pool, 0);
429
 
 
430
 
    pj_strdup2(pool, &url->host, "localhost");
431
 
    pj_strdup2(pool, &url->user_param, "phone");
432
 
 
433
 
    //pj_strdup2(pool, &url->other_param, ";pickup=hurry;message=I%20am%20sorry");
434
 
    param_add(url->other_param, "pickup", "hurry");
435
 
    param_add(url->other_param, "message", "I am sorry");
436
 
 
437
 
    //pj_strdup2(pool, &url->header_param, "?Subject=Hello%20There&Server=SIP%20Server");
438
 
    param_add(url->header_param, "Subject", "Hello There");
439
 
    param_add(url->header_param, "Server", "SIP Server");
440
 
    return (pjsip_uri*)url;
441
 
 
442
 
}
443
 
 
444
 
static pjsip_uri *create_uri6(pj_pool_t *pool)
445
 
{
446
 
    /* "sips:localhost" */
447
 
    pjsip_sip_uri *url = pjsip_sip_uri_create(pool, 1);
448
 
 
449
 
    pj_strdup2(pool, &url->host, "localhost");
450
 
    return (pjsip_uri*)url;
451
 
}
452
 
 
453
 
static pjsip_uri *create_uri7(pj_pool_t *pool)
454
 
{
455
 
    /* "<sip:localhost>" */
456
 
    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
457
 
    pjsip_sip_uri *url;
458
 
 
459
 
    url = pjsip_sip_uri_create(pool, 0);
460
 
    name_addr->uri = (pjsip_uri*) url;
461
 
 
462
 
    pj_strdup2(pool, &url->host, "localhost");
463
 
    return (pjsip_uri*)name_addr;
464
 
}
465
 
 
466
 
static pjsip_uri *create_uri8(pj_pool_t *pool)
467
 
{
468
 
    /* "  Power Administrator <sips:localhost>" */
469
 
    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
470
 
    pjsip_sip_uri *url;
471
 
 
472
 
    url = pjsip_sip_uri_create(pool, 1);
473
 
    name_addr->uri = (pjsip_uri*) url;
474
 
 
475
 
    pj_strdup2(pool, &name_addr->display, "Power Administrator");
476
 
    pj_strdup2(pool, &url->host, "localhost");
477
 
    return (pjsip_uri*)name_addr;
478
 
}
479
 
 
480
 
static pjsip_uri *create_uri9(pj_pool_t *pool)
481
 
{
482
 
    /* " \"User\" <sip:user@localhost:5071>" */
483
 
    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
484
 
    pjsip_sip_uri *url;
485
 
 
486
 
    url = pjsip_sip_uri_create(pool, 0);
487
 
    name_addr->uri = (pjsip_uri*) url;
488
 
 
489
 
    pj_strdup2(pool, &name_addr->display, "User");
490
 
    pj_strdup2(pool, &url->user, "user");
491
 
    pj_strdup2(pool, &url->host, "localhost");
492
 
    url->port = 5071;
493
 
    return (pjsip_uri*)name_addr;
494
 
}
495
 
 
496
 
static pjsip_uri *create_uri10(pj_pool_t *pool)
497
 
{
498
 
    /* " \"Strange User\\\"\\\\\\\"\" <sip:localhost>" */
499
 
    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
500
 
    pjsip_sip_uri *url;
501
 
 
502
 
    url = pjsip_sip_uri_create(pool, 0);
503
 
    name_addr->uri = (pjsip_uri*) url;
504
 
 
505
 
    pj_strdup2(pool, &name_addr->display, "Strange User\\\"\\\\\\\"");
506
 
    pj_strdup2(pool, &url->host, "localhost");
507
 
    return (pjsip_uri*)name_addr;
508
 
}
509
 
 
510
 
static pjsip_uri *create_uri11(pj_pool_t *pool)
511
 
{
512
 
    /* " \"Rogue User\\\" <sip:localhost>" */
513
 
    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
514
 
    pjsip_sip_uri *url;
515
 
 
516
 
    url = pjsip_sip_uri_create(pool, 0);
517
 
    name_addr->uri = (pjsip_uri*) url;
518
 
 
519
 
    pj_strdup2(pool, &name_addr->display, "Rogue User\\");
520
 
    pj_strdup2(pool, &url->host, "localhost");
521
 
    return (pjsip_uri*)name_addr;
522
 
}
523
 
 
524
 
static pjsip_uri *create_uri12(pj_pool_t *pool)
525
 
{
526
 
    /* "Strange User\" <sip:localhost>" */
527
 
    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
528
 
    pjsip_sip_uri *url;
529
 
 
530
 
    url = pjsip_sip_uri_create(pool, 0);
531
 
    name_addr->uri = (pjsip_uri*) url;
532
 
 
533
 
    pj_strdup2(pool, &name_addr->display, "Strange User\"");
534
 
    pj_strdup2(pool, &url->host, "localhost");
535
 
    return (pjsip_uri*)name_addr;
536
 
}
537
 
 
538
 
static pjsip_uri *create_uri13(pj_pool_t *pool)
539
 
{
540
 
    /* "sip:localhost;pvalue=\"hello world\"" */
541
 
    pjsip_sip_uri *url;
542
 
    url = pjsip_sip_uri_create(pool, 0);
543
 
    pj_strdup2(pool, &url->host, "localhost");
544
 
    //pj_strdup2(pool, &url->other_param, ";pvalue=\"hello world\"");
545
 
    param_add(url->other_param, "pvalue", "\"hello world\"");
546
 
    return (pjsip_uri*)url;
547
 
}
548
 
 
549
 
static pjsip_uri *create_uri14(pj_pool_t *pool)
550
 
{
551
 
    /* "This is -. !% *_+`'~ me <sip:a19A&=+$,;?/%2c:%40a&Zz=+$,@my_proxy09.my-domain.com:9801>" */
552
 
    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
553
 
    pjsip_sip_uri *url;
554
 
 
555
 
    url = pjsip_sip_uri_create(pool, 0);
556
 
    name_addr->uri = (pjsip_uri*) url;
557
 
 
558
 
    pj_strdup2(pool, &name_addr->display, "This is -. !% *_+`'~ me");
559
 
    pj_strdup2(pool, &url->user, "a19A&=+$,;?/,");
560
 
    pj_strdup2(pool, &url->passwd, "@a&Zz=+$,");
561
 
    pj_strdup2(pool, &url->host, "my_proxy09.MY-domain.com");
562
 
    url->port = 9801;
563
 
    return (pjsip_uri*)name_addr;
564
 
}
565
 
 
566
 
static pjsip_uri *create_uri15(pj_pool_t *pool)
567
 
{
568
 
    /* "sip:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.com" */
569
 
    pjsip_sip_uri *url;
570
 
    url = pjsip_sip_uri_create(pool, 0);
571
 
    pj_strdup2(pool, &url->host, ALPHANUM "-_.com");
572
 
    return (pjsip_uri*)url;
573
 
}
574
 
 
575
 
static pjsip_uri *create_uri16(pj_pool_t *pool)
576
 
{
577
 
    /* "sip:" USER_CHAR ":" PASS_CHAR "@host" */
578
 
    pjsip_sip_uri *url;
579
 
    url = pjsip_sip_uri_create(pool, 0);
580
 
    pj_strdup2(pool, &url->user, USER_CHAR);
581
 
    pj_strdup2(pool, &url->passwd, PASS_CHAR);
582
 
    pj_strdup2(pool, &url->host, "host");
583
 
    return (pjsip_uri*)url;
584
 
}
585
 
 
586
 
static pjsip_uri *create_uri17(pj_pool_t *pool)
587
 
{
588
 
    /* "sip:host;user=ip;" PARAM_CHAR "%21=" PARAM_CHAR "%21;lr;other=1;transport=sctp;other2" */
589
 
    pjsip_sip_uri *url;
590
 
    url = pjsip_sip_uri_create(pool, 0);
591
 
    pj_strdup2(pool, &url->host, "host");
592
 
    pj_strdup2(pool, &url->user_param, "ip");
593
 
    pj_strdup2(pool, &url->transport_param, "sctp");
594
 
    param_add(url->other_param, PARAM_CHAR "!", PARAM_CHAR "!");
595
 
    param_add(url->other_param, "other", "1");
596
 
    param_add(url->other_param, "other2", "");
597
 
    url->lr_param = 1;
598
 
    return (pjsip_uri*)url;
599
 
}
600
 
 
601
 
 
602
 
static pjsip_uri *create_uri25(pj_pool_t *pool)
603
 
{
604
 
    /* "tel:+1-201-555-0123" */
605
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
606
 
 
607
 
    uri->number = pj_str("+1-201-555-0123");
608
 
    return (pjsip_uri*)uri;
609
 
}
610
 
 
611
 
static pjsip_uri *create_uri26(pj_pool_t *pool)
612
 
{
613
 
    /* tel:7042;phone-context=example.com */
614
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
615
 
 
616
 
    uri->number = pj_str("7042");
617
 
    uri->context = pj_str("example.com");
618
 
    return (pjsip_uri*)uri;
619
 
}
620
 
 
621
 
static pjsip_uri *create_uri27(pj_pool_t *pool)
622
 
{
623
 
    /* "tel:863-1234;phone-context=+1-914-555" */
624
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
625
 
 
626
 
    uri->number = pj_str("863-1234");
627
 
    uri->context = pj_str("+1-914-555");
628
 
    return (pjsip_uri*)uri;
629
 
}
630
 
 
631
 
/* "tel:1" */
632
 
static pjsip_uri *create_uri28(pj_pool_t *pool)
633
 
{
634
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
635
 
 
636
 
    uri->number = pj_str("1");
637
 
    return (pjsip_uri*)uri;
638
 
}
639
 
 
640
 
/* "tel:(44).1234-*#+Deaf" */
641
 
static pjsip_uri *create_uri29(pj_pool_t *pool)
642
 
{
643
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
644
 
 
645
 
    uri->number = pj_str("(44).1234-*#+Deaf");
646
 
    return (pjsip_uri*)uri;
647
 
}
648
 
 
649
 
/* "tel:+1;isub=/:@&$,-_.!~*'()[]/:&$aA1%21+=" */
650
 
static pjsip_uri *create_uri30(pj_pool_t *pool)
651
 
{
652
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
653
 
 
654
 
    uri->number = pj_str("+1");
655
 
    uri->isub_param = pj_str("/:@&$,-_.!~*'()[]/:&$aA1!+=");
656
 
    return (pjsip_uri*)uri;
657
 
}
658
 
 
659
 
/* "tel:+1;ext=+123" */
660
 
static pjsip_uri *create_uri31(pj_pool_t *pool)
661
 
{
662
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
663
 
 
664
 
    uri->number = pj_str("+1");
665
 
    uri->ext_param = pj_str("+123");
666
 
    return (pjsip_uri*)uri;
667
 
}
668
 
 
669
 
/* "tel:911;phone-context=+1-911" */
670
 
static pjsip_uri *create_uri32(pj_pool_t *pool)
671
 
{
672
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
673
 
 
674
 
    uri->number = pj_str("911");
675
 
    uri->context = pj_str("+1-911");
676
 
    return (pjsip_uri*)uri;
677
 
}
678
 
 
679
 
/* "tel:911;phone-context=emergency.example.com" */
680
 
static pjsip_uri *create_uri33(pj_pool_t *pool)
681
 
{
682
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
683
 
 
684
 
    uri->number = pj_str("911");
685
 
    uri->context = pj_str("EMERGENCY.EXAMPLE.COM");
686
 
    return (pjsip_uri*)uri;
687
 
}
688
 
 
689
 
/* "tel:911;p1=p1;p2=p2" */
690
 
static pjsip_uri *create_uri34(pj_pool_t *pool)
691
 
{
692
 
    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
693
 
    pjsip_param *p;
694
 
 
695
 
    uri->number = pj_str("911");
696
 
 
697
 
    p = PJ_POOL_ALLOC_T(pool, pjsip_param);
698
 
    p->name = p->value = pj_str("p1");
699
 
    pj_list_insert_before(&uri->other_param, p);
700
 
 
701
 
    return (pjsip_uri*)uri;
702
 
}
703
 
 
704
 
/* "sip:user@[::1];maddr=[::01]" */
705
 
static pjsip_uri *create_uri35( pj_pool_t *pool )
706
 
{
707
 
    pjsip_sip_uri *url;
708
 
    url = pjsip_sip_uri_create(pool, 0);
709
 
    url->user = pj_str("user");
710
 
    url->host = pj_str("::1");
711
 
    url->maddr_param = pj_str("::01");
712
 
    return (pjsip_uri*)url;
713
 
}
714
 
 
715
 
/* "sip:[::1];maddr=[::01]" */
716
 
static pjsip_uri *create_uri36( pj_pool_t *pool )
717
 
{
718
 
    pjsip_sip_uri *url;
719
 
    url = pjsip_sip_uri_create(pool, 0);
720
 
    url->host = pj_str("::1");
721
 
    url->maddr_param = pj_str("::01");
722
 
    return (pjsip_uri*)url;
723
 
 
724
 
}
725
 
 
726
 
/* "\"\xC0\x81\" <sip:localhost>" */
727
 
static pjsip_uri *create_uri37( pj_pool_t *pool )
728
 
{
729
 
    pjsip_name_addr *name;
730
 
    pjsip_sip_uri *url;
731
 
 
732
 
    name = pjsip_name_addr_create(pool);
733
 
    name->display = pj_str("\xC0\x81");
734
 
 
735
 
    url = pjsip_sip_uri_create(pool, 0);
736
 
    url->host = pj_str("localhost");
737
 
 
738
 
    name->uri = (pjsip_uri*)url;
739
 
 
740
 
    return (pjsip_uri*)name;
741
 
 
742
 
}
743
 
 
744
 
/* "\xC0\x81 <sip:localhost>" */
745
 
static pjsip_uri *create_uri38( pj_pool_t *pool )
746
 
{
747
 
    pjsip_name_addr *name;
748
 
    pjsip_sip_uri *url;
749
 
 
750
 
    name = pjsip_name_addr_create(pool);
751
 
    name->display = pj_str("\xC0\x81");
752
 
 
753
 
    url = pjsip_sip_uri_create(pool, 0);
754
 
    url->host = pj_str("localhost");
755
 
 
756
 
    name->uri = (pjsip_uri*)url;
757
 
 
758
 
    return (pjsip_uri*)name;
759
 
 
760
 
}
761
 
 
762
 
static pjsip_uri *create_dummy(pj_pool_t *pool)
763
 
{
764
 
    PJ_UNUSED_ARG(pool);
765
 
    return NULL;
766
 
}
767
 
 
768
 
/*****************************************************************************/
769
 
 
770
 
/*
771
 
 * Test one test entry.
772
 
 */
773
 
static pj_status_t do_uri_test(pj_pool_t *pool, struct uri_test *entry)
774
 
{
775
 
    pj_status_t status;
776
 
    int len;
777
 
    char *input;
778
 
    pjsip_uri *parsed_uri, *ref_uri;
779
 
    pj_str_t s1 = {NULL, 0}, s2 = {NULL, 0};
780
 
    pj_timestamp t1, t2;
781
 
 
782
 
    if (entry->len == 0)
783
 
        entry->len = pj_ansi_strlen(entry->str);
784
 
 
785
 
#if defined(PJSIP_UNESCAPE_IN_PLACE) && PJSIP_UNESCAPE_IN_PLACE!=0
786
 
    input = pj_pool_alloc(pool, entry->len + 1);
787
 
    pj_memcpy(input, entry->str, entry->len);
788
 
    input[entry->len] = '\0';
789
 
#else
790
 
    input = entry->str;
791
 
#endif
792
 
 
793
 
    /* Parse URI text. */
794
 
    pj_get_timestamp(&t1);
795
 
    var.parse_len = var.parse_len + entry->len;
796
 
    parsed_uri = pjsip_parse_uri(pool, input, entry->len, 0);
797
 
    if (!parsed_uri) {
798
 
        /* Parsing failed. If the entry says that this is expected, then
799
 
         * return OK.
800
 
         */
801
 
        status = entry->status==ERR_SYNTAX_ERR ? PJ_SUCCESS : -10;
802
 
        if (status != 0) {
803
 
            PJ_LOG(3,(THIS_FILE, "   uri parse error!\n"
804
 
                                 "   uri='%s'\n",
805
 
                                 input));
806
 
        }
807
 
        goto on_return;
808
 
    }
809
 
    pj_get_timestamp(&t2);
810
 
    pj_sub_timestamp(&t2, &t1);
811
 
    pj_add_timestamp(&var.parse_time, &t2);
812
 
 
813
 
    /* Create the reference URI. */
814
 
    ref_uri = entry->creator(pool);
815
 
 
816
 
    /* Print both URI. */
817
 
    s1.ptr = (char*) pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
818
 
    s2.ptr = (char*) pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
819
 
 
820
 
    pj_get_timestamp(&t1);
821
 
    len = pjsip_uri_print( PJSIP_URI_IN_OTHER, parsed_uri, s1.ptr, PJSIP_MAX_URL_SIZE);
822
 
    if (len < 1) {
823
 
        status = -20;
824
 
        goto on_return;
825
 
    }
826
 
    s1.ptr[len] = '\0';
827
 
    s1.slen = len;
828
 
 
829
 
    var.print_len = var.print_len + len;
830
 
    pj_get_timestamp(&t2);
831
 
    pj_sub_timestamp(&t2, &t1);
832
 
    pj_add_timestamp(&var.print_time, &t2);
833
 
 
834
 
    len = pjsip_uri_print( PJSIP_URI_IN_OTHER, ref_uri, s2.ptr, PJSIP_MAX_URL_SIZE);
835
 
    if (len < 1) {
836
 
        status = -30;
837
 
        goto on_return;
838
 
    }
839
 
    s2.ptr[len] = '\0';
840
 
    s2.slen = len;
841
 
 
842
 
    /* Full comparison of parsed URI with reference URI. */
843
 
    pj_get_timestamp(&t1);
844
 
    status = pjsip_uri_cmp(PJSIP_URI_IN_OTHER, parsed_uri, ref_uri);
845
 
    if (status != 0) {
846
 
        /* Not equal. See if this is the expected status. */
847
 
        status = entry->status==ERR_NOT_EQUAL ? PJ_SUCCESS : -40;
848
 
        if (status != 0) {
849
 
            PJ_LOG(3,(THIS_FILE, "   uri comparison mismatch, status=%d:\n"
850
 
                                 "    uri1='%s'\n"
851
 
                                 "    uri2='%s'",
852
 
                                 status, s1.ptr, s2.ptr));
853
 
        }
854
 
        goto on_return;
855
 
 
856
 
    } else {
857
 
        /* Equal. See if this is the expected status. */
858
 
        status = entry->status==PJ_SUCCESS ? PJ_SUCCESS : -50;
859
 
        if (status != PJ_SUCCESS) {
860
 
            goto on_return;
861
 
        }
862
 
    }
863
 
 
864
 
    var.cmp_len = var.cmp_len + len;
865
 
    pj_get_timestamp(&t2);
866
 
    pj_sub_timestamp(&t2, &t1);
867
 
    pj_add_timestamp(&var.cmp_time, &t2);
868
 
 
869
 
    /* Compare text. */
870
 
    if (entry->printed) {
871
 
        if (pj_strcmp2(&s1, entry->printed) != 0) {
872
 
            /* Not equal. */
873
 
            PJ_LOG(3,(THIS_FILE, "   uri print mismatch:\n"
874
 
                                 "    printed='%s'\n"
875
 
                                 "    expectd='%s'",
876
 
                                 s1.ptr, entry->printed));
877
 
            status = -60;
878
 
        }
879
 
    } else {
880
 
        if (pj_strcmp(&s1, &s2) != 0) {
881
 
            /* Not equal. */
882
 
            PJ_LOG(3,(THIS_FILE, "   uri print mismatch:\n"
883
 
                                 "    uri1='%s'\n"
884
 
                                 "    uri2='%s'",
885
 
                                 s1.ptr, s2.ptr));
886
 
            status = -70;
887
 
        }
888
 
    }
889
 
 
890
 
on_return:
891
 
    return status;
892
 
}
893
 
 
894
 
 
895
 
static int simple_uri_test(void)
896
 
{
897
 
    unsigned i;
898
 
    pj_pool_t *pool;
899
 
    pj_status_t status;
900
 
 
901
 
    PJ_LOG(3,(THIS_FILE, "  simple test"));
902
 
    for (i=0; i<PJ_ARRAY_SIZE(uri_test_array); ++i) {
903
 
        pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE);
904
 
        status = do_uri_test(pool, &uri_test_array[i]);
905
 
        pjsip_endpt_release_pool(endpt, pool);
906
 
        if (status != PJ_SUCCESS) {
907
 
            PJ_LOG(3,(THIS_FILE, "  error %d when testing entry %d",
908
 
                      status, i));
909
 
            return status;
910
 
        }
911
 
    }
912
 
 
913
 
    return 0;
914
 
}
915
 
 
916
 
#if INCLUDE_BENCHMARKS
917
 
static int uri_benchmark(unsigned *p_parse, unsigned *p_print, unsigned *p_cmp)
918
 
{
919
 
    unsigned i, loop;
920
 
    pj_status_t status = PJ_SUCCESS;
921
 
    pj_timestamp zero;
922
 
    pj_time_val elapsed;
923
 
    pj_highprec_t avg_parse, avg_print, avg_cmp, kbytes;
924
 
 
925
 
    pj_bzero(&var, sizeof(var));
926
 
 
927
 
    zero.u32.hi = zero.u32.lo = 0;
928
 
 
929
 
    var.parse_len = var.print_len = var.cmp_len = 0;
930
 
    var.parse_time.u32.hi = var.parse_time.u32.lo = 0;
931
 
    var.print_time.u32.hi = var.print_time.u32.lo = 0;
932
 
    var.cmp_time.u32.hi = var.cmp_time.u32.lo = 0;
933
 
    for (loop=0; loop<LOOP_COUNT; ++loop) {
934
 
        for (i=0; i<PJ_ARRAY_SIZE(uri_test_array); ++i) {
935
 
            pj_pool_t *pool;
936
 
            pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE);
937
 
            status = do_uri_test(pool, &uri_test_array[i]);
938
 
            pjsip_endpt_release_pool(endpt, pool);
939
 
            if (status != PJ_SUCCESS) {
940
 
                PJ_LOG(3,(THIS_FILE, "  error %d when testing entry %d",
941
 
                          status, i));
942
 
                pjsip_endpt_release_pool(endpt, pool);
943
 
                goto on_return;
944
 
            }
945
 
        }
946
 
    }
947
 
 
948
 
    kbytes = var.parse_len;
949
 
    pj_highprec_mod(kbytes, 1000000);
950
 
    pj_highprec_div(kbytes, 100000);
951
 
    elapsed = pj_elapsed_time(&zero, &var.parse_time);
952
 
    avg_parse = pj_elapsed_usec(&zero, &var.parse_time);
953
 
    pj_highprec_mul(avg_parse, AVERAGE_URL_LEN);
954
 
    pj_highprec_div(avg_parse, var.parse_len);
955
 
    if (avg_parse == 0)
956
 
        avg_parse = 1;
957
 
    avg_parse = 1000000 / avg_parse;
958
 
 
959
 
    PJ_LOG(3,(THIS_FILE,
960
 
              "    %u.%u MB of urls parsed in %d.%03ds (avg=%d urls/sec)",
961
 
              (unsigned)(var.parse_len/1000000), (unsigned)kbytes,
962
 
              elapsed.sec, elapsed.msec,
963
 
              (unsigned)avg_parse));
964
 
 
965
 
    *p_parse = (unsigned)avg_parse;
966
 
 
967
 
    kbytes = var.print_len;
968
 
    pj_highprec_mod(kbytes, 1000000);
969
 
    pj_highprec_div(kbytes, 100000);
970
 
    elapsed = pj_elapsed_time(&zero, &var.print_time);
971
 
    avg_print = pj_elapsed_usec(&zero, &var.print_time);
972
 
    pj_highprec_mul(avg_print, AVERAGE_URL_LEN);
973
 
    pj_highprec_div(avg_print, var.parse_len);
974
 
    if (avg_print == 0)
975
 
        avg_print = 1;
976
 
    avg_print = 1000000 / avg_print;
977
 
 
978
 
    PJ_LOG(3,(THIS_FILE,
979
 
              "    %u.%u MB of urls printed in %d.%03ds (avg=%d urls/sec)",
980
 
              (unsigned)(var.print_len/1000000), (unsigned)kbytes,
981
 
              elapsed.sec, elapsed.msec,
982
 
              (unsigned)avg_print));
983
 
 
984
 
    *p_print = (unsigned)avg_print;
985
 
 
986
 
    kbytes = var.cmp_len;
987
 
    pj_highprec_mod(kbytes, 1000000);
988
 
    pj_highprec_div(kbytes, 100000);
989
 
    elapsed = pj_elapsed_time(&zero, &var.cmp_time);
990
 
    avg_cmp = pj_elapsed_usec(&zero, &var.cmp_time);
991
 
    pj_highprec_mul(avg_cmp, AVERAGE_URL_LEN);
992
 
    pj_highprec_div(avg_cmp, var.cmp_len);
993
 
    if (avg_cmp == 0)
994
 
        avg_cmp = 1;
995
 
    avg_cmp = 1000000 / avg_cmp;
996
 
 
997
 
    PJ_LOG(3,(THIS_FILE,
998
 
              "    %u.%u MB of urls compared in %d.%03ds (avg=%d urls/sec)",
999
 
              (unsigned)(var.cmp_len/1000000), (unsigned)kbytes,
1000
 
              elapsed.sec, elapsed.msec,
1001
 
              (unsigned)avg_cmp));
1002
 
 
1003
 
    *p_cmp = (unsigned)avg_cmp;
1004
 
 
1005
 
on_return:
1006
 
    return status;
1007
 
}
1008
 
#endif  /* INCLUDE_BENCHMARKS */
1009
 
 
1010
 
/*****************************************************************************/
1011
 
 
1012
 
int uri_test(void)
1013
 
{
1014
 
    enum { COUNT = 1, DETECT=0, PARSE=1, PRINT=2 };
1015
 
    struct {
1016
 
        unsigned parse;
1017
 
        unsigned print;
1018
 
        unsigned cmp;
1019
 
    } run[COUNT];
1020
 
    unsigned i, max, avg_len;
1021
 
    char desc[200];
1022
 
    pj_status_t status;
1023
 
 
1024
 
    status = simple_uri_test();
1025
 
    if (status != PJ_SUCCESS)
1026
 
        return status;
1027
 
 
1028
 
#if INCLUDE_BENCHMARKS
1029
 
    for (i=0; i<COUNT; ++i) {
1030
 
        PJ_LOG(3,(THIS_FILE, "  benchmarking (%d of %d)...", i+1, COUNT));
1031
 
        status = uri_benchmark(&run[i].parse, &run[i].print, &run[i].cmp);
1032
 
        if (status != PJ_SUCCESS)
1033
 
            return status;
1034
 
    }
1035
 
 
1036
 
    /* Calculate average URI length */
1037
 
    for (i=0, avg_len=0; i<PJ_ARRAY_SIZE(uri_test_array); ++i) {
1038
 
        avg_len += uri_test_array[i].len;
1039
 
    }
1040
 
    avg_len /= PJ_ARRAY_SIZE(uri_test_array);
1041
 
 
1042
 
 
1043
 
    /*
1044
 
     * Print maximum parse/sec
1045
 
     */
1046
 
    for (i=0, max=0; i<COUNT; ++i)
1047
 
        if (run[i].parse > max) max = run[i].parse;
1048
 
 
1049
 
    PJ_LOG(3,("", "  Maximum URI parse/sec=%u", max));
1050
 
 
1051
 
    pj_ansi_sprintf(desc, "Number of SIP/TEL URIs that can be <B>parsed</B> with "
1052
 
                          "<tt>pjsip_parse_uri()</tt> per second "
1053
 
                          "(tested with %d URI set, with average length of "
1054
 
                          "%d chars)",
1055
 
                          (int)PJ_ARRAY_SIZE(uri_test_array), avg_len);
1056
 
 
1057
 
    report_ival("uri-parse-per-sec", max, "URI/sec", desc);
1058
 
 
1059
 
    /* URI parsing bandwidth */
1060
 
    report_ival("uri-parse-bandwidth-mb", avg_len*max/1000000, "MB/sec",
1061
 
                "URI parsing bandwidth in megabytes (number of megabytes "
1062
 
                "worth of URI that can be parsed per second)");
1063
 
 
1064
 
 
1065
 
    /* Print maximum print/sec */
1066
 
    for (i=0, max=0; i<COUNT; ++i)
1067
 
        if (run[i].print > max) max = run[i].print;
1068
 
 
1069
 
    PJ_LOG(3,("", "  Maximum URI print/sec=%u", max));
1070
 
 
1071
 
    pj_ansi_sprintf(desc, "Number of SIP/TEL URIs that can be <B>printed</B> with "
1072
 
                          "<tt>pjsip_uri_print()</tt> per second "
1073
 
                          "(tested with %d URI set, with average length of "
1074
 
                          "%d chars)",
1075
 
                          (int)PJ_ARRAY_SIZE(uri_test_array), avg_len);
1076
 
 
1077
 
    report_ival("uri-print-per-sec", max, "URI/sec", desc);
1078
 
 
1079
 
    /* Print maximum detect/sec */
1080
 
    for (i=0, max=0; i<COUNT; ++i)
1081
 
        if (run[i].cmp > max) max = run[i].cmp;
1082
 
 
1083
 
    PJ_LOG(3,("", "  Maximum URI comparison/sec=%u", max));
1084
 
 
1085
 
    pj_ansi_sprintf(desc, "Number of SIP/TEL URIs that can be <B>compared</B> with "
1086
 
                          "<tt>pjsip_uri_cmp()</tt> per second "
1087
 
                          "(tested with %d URI set, with average length of "
1088
 
                          "%d chars)",
1089
 
                          (int)PJ_ARRAY_SIZE(uri_test_array), avg_len);
1090
 
 
1091
 
    report_ival("uri-cmp-per-sec", max, "URI/sec", desc);
1092
 
 
1093
 
#endif  /* INCLUDE_BENCHMARKS */
1094
 
 
1095
 
    return PJ_SUCCESS;
1096
 
}