Changeset 76 for pjproject/trunk
- Timestamp:
- Nov 22, 2005 1:06:33 AM (19 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_parser.h
r74 r76 50 50 /** If this option is specified, function #pjsip_parse_uri and other 51 51 * internal functions that this function calls will parse URI according 52 * to convention for parsing From/To header. For example, when the URI53 * is not enclosed in brackets ("<" and ">"), all parameters will not54 * be stored to the URI (it will be stored to the header).52 * to convention for parsing From/To/Contact header. For example, when 53 * the URI is not enclosed in brackets ("<" and ">"), all parameters 54 * are treated as header parameters (not URI parameters). 55 55 */ 56 56 PJSIP_PARSE_URI_IN_FROM_TO_HDR = 2, -
pjproject/trunk/pjsip/src/pjsip/sip_parser.c
r74 r76 759 759 } 760 760 761 msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG);762 763 761 /* Parse request or status line */ 764 762 if (pj_scan_stricmp( scanner, PJSIP_VERSION, 7) == 0) { 765 msg ->type = PJSIP_RESPONSE_MSG;763 msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG); 766 764 int_parse_status_line( scanner, &msg->line.status ); 767 765 } else { 768 msg ->type = PJSIP_REQUEST_MSG;766 msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG); 769 767 int_parse_req_line(scanner, pool, &msg->line.req ); 770 768 } … … 859 857 860 858 /* If we have Content-Type header, treat the rest of the message as body.*/ 861 if (ctype_hdr ) {859 if (ctype_hdr && scanner->curptr!=scanner->end) { 862 860 pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body)); 863 861 pj_strdup(pool, &body->content_type.type, &ctype_hdr->media.type); … … 1380 1378 hdr->star = 0; 1381 1379 hdr->uri = int_parse_uri_or_name_addr(scanner, ctx->pool, 1382 PJSIP_PARSE_URI_AS_NAMEADDR); 1380 PJSIP_PARSE_URI_AS_NAMEADDR | 1381 PJSIP_PARSE_URI_IN_FROM_TO_HDR); 1383 1382 1384 1383 int_parse_contact_param(hdr, scanner, ctx->pool); -
pjproject/trunk/pjsip/src/test-pjsip/msg.c
r65 r76 21 21 #include <pjlib.h> 22 22 23 #define POOL_SIZE 8000 24 #define LOOP 10000 25 #define AVERAGE_MSG_LEN 800 26 23 27 static pjsip_msg *create_msg0(pj_pool_t *pool); 28 static pjsip_msg *create_msg1(pj_pool_t *pool); 29 30 #define STATUS_PARTIAL 1 31 #define STATUS_SYNTAX_ERROR 2 32 33 #define FLAG_DETECT_ONLY 1 34 #define FLAG_PARSE_ONLY 4 35 #define FLAG_PRINT_ONLY 8 36 37 static int flag = FLAG_PARSE_ONLY; 24 38 25 39 struct test_msg … … 28 42 pjsip_msg *(*creator)(pj_pool_t *pool); 29 43 pj_size_t len; 44 int expected_status; 30 45 } test_array[] = 31 46 { 32 { 33 /* 'Normal' message with all headers. */ 34 "INVITE sip:user@foo SIP/2.0\n" 35 "From: Hi I'm Joe <sip:joe.user@bar.otherdomain.com>;tag=1234578901234567890\r" 36 "To: Fellow User <sip:user@foo.bar.domain.com>\r\n" 37 "Call-ID: 12345678901234567890@bar\r\n" 38 "Content-Length: 0\r\n" 39 "CSeq: 123456 INVITE\n" 40 "Contact: <sip:joe@bar> ; q=0.5;expires=3600,sip:user@host;q=0.500\r" 41 " ,sip:user2@host2\n" 42 "Content-Type: text/html ; charset=ISO-8859-4\r" 43 "Route: <sip:bigbox3.site3.atlanta.com;lr>,\r\n" 44 " <sip:server10.biloxi.com;lr>\r" 45 "Record-Route: <sip:server10.biloxi.com>,\r\n" 46 " <sip:bigbox3.site3.atlanta.com;lr>\n" 47 "Via: SIP/2.0/SCTP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\n" 48 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\n" 49 " ;received=192.0.2.1\r\n" 50 "Via: SIP/2.0/UDP 10.2.1.1, SIP/2.0/TCP 192.168.1.1\n" 51 "Organization: \r" 52 "Max-Forwards: 70\n" 53 "X-Header: \r\n" 54 "\r", 55 &create_msg0 56 } 47 { 48 /* 'Normal' message with all headers. */ 49 "INVITE sip:user@foo SIP/2.0\n" 50 "From: Hi I'm Joe <sip:joe.user@bar.otherdomain.com>;tag=1234578901234567890\r" 51 "To: Fellow User <sip:user@foo.bar.domain.com>\r\n" 52 "Call-ID: 12345678901234567890@bar\r\n" 53 "Content-Length: 0\r\n" 54 "CSeq: 123456 INVITE\n" 55 "Contact: <sip:joe@bar> ; q=0.5;expires=3600,sip:user@host;q=0.500\r" 56 " ,sip:user2@host2\n" 57 "Content-Type: text/html ; charset=ISO-8859-4\r" 58 "Route: <sip:bigbox3.site3.atlanta.com;lr>,\r\n" 59 " <sip:server10.biloxi.com;lr>\r" 60 "Record-Route: <sip:server10.biloxi.com>,\r\n" 61 " <sip:bigbox3.site3.atlanta.com;lr>\n" 62 "Via: SIP/2.0/SCTP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\n" 63 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\n" 64 " ;received=192.0.2.1\r\n" 65 "Via: SIP/2.0/UDP 10.2.1.1, SIP/2.0/TCP 192.168.1.1\n" 66 "Organization: \r" 67 "Max-Forwards: 70\n" 68 "X-Header: \r\n" 69 "\r\n", 70 &create_msg0, 71 PJ_SUCCESS 72 }, 73 { 74 /* Typical response message. */ 75 "SIP/2.0 200 OK\r\n" 76 "Via: SIP/2.0/SCTP server10.biloxi.com;branch=z9hG4bKnashds8;rport;received=192.0.2.1\r\n" 77 "Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2\r\n" 78 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds ;received=192.0.2.3\r\n" 79 "Route: <sip:proxy.sipprovider.com>\r\n" 80 "Route: <sip:proxy.supersip.com:5060>\r\n" 81 "Max-Forwards: 70\r\n" 82 "To: Bob <sip:bob@biloxi.com>;tag=a6c85cf\r\n" 83 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 84 "Call-ID: a84b4c76e66710@pc33.atlanta.com\r\n" 85 "CSeq: 314159 INVITE\r\n" 86 "Contact: <sips:bob@192.0.2.4>\r\n" 87 "Content-Type: application/sdp\r\n" 88 "Content-Length: 150\r\n" 89 "\r\n" 90 "v=0\r\n" 91 "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" 92 "s=-\r\n" 93 "t=0 0\r\n" 94 "c=IN IP4 pc33.atlanta.com\r\n" 95 "m=audio 3456 RTP/AVP 0 1 3 99\r\n" 96 "a=rtpmap:0 PCMU/8000\r\n", 97 &create_msg1, 98 PJ_SUCCESS 99 } 57 100 }; 58 101 59 static pj_uint32_t parse_len, parse_time, print_time; 102 static pj_highprec_t detect_len, parse_len, print_len; 103 static pj_timestamp detect_time, parse_time, print_time; 60 104 61 105 static pj_status_t test_entry( pj_pool_t *pool, struct test_msg *entry ) … … 67 111 pjsip_hdr *hdr1, *hdr2; 68 112 pj_timestamp t1, t2; 69 char *msgbuf; 113 pjsip_parser_err_report err_list; 114 pj_size_t msg_size; 115 char msgbuf1[PJSIP_MAX_PKT_LEN]; 116 char msgbuf2[PJSIP_MAX_PKT_LEN]; 70 117 71 118 enum { BUFLEN = 512 }; 119 120 entry->len = pj_native_strlen(entry->msg); 121 122 if (flag & FLAG_PARSE_ONLY) 123 goto parse_msg; 124 if (flag & FLAG_PRINT_ONLY) 125 goto print_msg; 126 127 /* Detect message. */ 128 detect_len = detect_len + entry->len; 129 pj_get_timestamp(&t1); 130 status = pjsip_find_msg(entry->msg, entry->len, PJ_FALSE, &msg_size); 131 if (status != PJ_SUCCESS) { 132 if (status!=PJSIP_EPARTIALMSG || 133 entry->expected_status!=STATUS_PARTIAL) 134 { 135 app_perror(" error: unable to detect message", status); 136 return -5; 137 } 138 } 139 if (msg_size != entry->len) { 140 PJ_LOG(3,("", " error: size mismatch")); 141 return -6; 142 } 143 pj_get_timestamp(&t2); 144 pj_sub_timestamp(&t2, &t1); 145 pj_add_timestamp(&detect_time, &t2); 146 147 if (flag & FLAG_PARSE_ONLY) 148 return PJ_SUCCESS; 72 149 73 150 /* Parse message. */ 74 parse_len += entry->len; 151 parse_msg: 152 parse_len = parse_len + entry->len; 75 153 pj_get_timestamp(&t1); 76 parsed_msg = pjsip_parse_msg(pool, entry->msg, entry->len, NULL); 154 pj_list_init(&err_list); 155 parsed_msg = pjsip_parse_msg(pool, entry->msg, entry->len, &err_list); 77 156 if (parsed_msg == NULL) { 78 status = -10; 79 goto on_return; 157 if (entry->expected_status != STATUS_SYNTAX_ERROR) { 158 status = -10; 159 if (err_list.next != &err_list) { 160 PJ_LOG(3,("", " Syntax error in line %d col %d", 161 err_list.next->line, err_list.next->col)); 162 } 163 goto on_return; 164 } 80 165 } 81 166 pj_get_timestamp(&t2); 82 parse_time += t2.u32.lo - t1.u32.lo; 167 pj_sub_timestamp(&t2, &t1); 168 pj_add_timestamp(&parse_time, &t2); 169 170 if (flag & FLAG_PARSE_ONLY) 171 return PJ_SUCCESS; 83 172 84 173 /* Create reference message. */ … … 100 189 pjsip_method *m2 = &ref_msg->line.req.method; 101 190 102 if ( m1->id != m2->id || pj_strcmp(&m1->name, &m2->name)) {191 if (pjsip_method_cmp(m1, m2) != 0) { 103 192 status = -30; 104 193 goto on_return; 105 194 } 195 status = pjsip_uri_cmp(PJSIP_URI_IN_REQ_URI, 196 parsed_msg->line.req.uri, 197 ref_msg->line.req.uri); 198 if (status != PJ_SUCCESS) { 199 app_perror(" error: request URI mismatch", status); 200 status = -31; 201 goto on_return; 202 } 106 203 } else { 107 204 if (parsed_msg->line.status.code != ref_msg->line.status.code) { 205 PJ_LOG(3,("", " error: status code mismatch")); 206 status = -32; 207 goto on_return; 208 } 209 if (pj_strcmp(&parsed_msg->line.status.reason, 210 &ref_msg->line.status.reason) != 0) 211 { 212 PJ_LOG(3,("", " error: status text mismatch")); 213 status = -33; 214 goto on_return; 215 } 108 216 } 109 217 … … 118 226 goto on_return; 119 227 } 228 str1.ptr[len] = '\0'; 120 229 str1.slen = len; 121 230 … … 125 234 goto on_return; 126 235 } 236 str2.ptr[len] = '\0'; 127 237 str2.slen = len; 128 238 129 239 if (pj_strcmp(&str1, &str2) != 0) { 130 240 status = -60; 241 PJ_LOG(3,("", " error: header string mismatch:\n" 242 " h1='%s'\n" 243 " h2='%s'\n", 244 str1.ptr, str2.ptr)); 131 245 goto on_return; 132 246 } … … 141 255 } 142 256 257 /* Compare body? */ 258 if (parsed_msg->body==NULL && ref_msg->body==NULL) 259 goto print_msg; 260 261 /* Compare msg body length. */ 262 if (parsed_msg->body->len != ref_msg->body->len) { 263 status = -80; 264 goto on_return; 265 } 266 267 /* Compare msg body content type. */ 268 if (pj_strcmp(&parsed_msg->body->content_type.type, 269 &ref_msg->body->content_type.type) != 0) { 270 status = -90; 271 goto on_return; 272 } 273 if (pj_strcmp(&parsed_msg->body->content_type.subtype, 274 &ref_msg->body->content_type.subtype) != 0) { 275 status = -100; 276 goto on_return; 277 } 278 279 /* Compare body content. */ 280 str1.slen = parsed_msg->body->print_body(parsed_msg->body, 281 msgbuf1, sizeof(msgbuf1)); 282 if (str1.slen < 1) { 283 status = -110; 284 goto on_return; 285 } 286 str1.ptr = msgbuf1; 287 288 str2.slen = ref_msg->body->print_body(ref_msg->body, 289 msgbuf2, sizeof(msgbuf2)); 290 if (str2.slen < 1) { 291 status = -120; 292 goto on_return; 293 } 294 str2.ptr = msgbuf2; 295 296 if (pj_strcmp(&str1, &str2) != 0) { 297 status = -140; 298 goto on_return; 299 } 300 143 301 /* Print message. */ 144 msgbuf = pj_pool_alloc(pool, PJSIP_MAX_PKT_LEN); 145 if (msgbuf == NULL) { 146 status = -80; 147 goto on_return; 148 } 302 print_msg: 303 print_len = print_len + entry->len; 149 304 pj_get_timestamp(&t1); 150 len = pjsip_msg_print(parsed_msg, msgbuf , PJSIP_MAX_PKT_LEN);305 len = pjsip_msg_print(parsed_msg, msgbuf1, PJSIP_MAX_PKT_LEN); 151 306 if (len < 1) { 152 status = - 90;307 status = -150; 153 308 goto on_return; 154 309 } 155 310 pj_get_timestamp(&t2); 156 print_time += t2.u32.lo - t1.u32.lo; 311 pj_sub_timestamp(&t2, &t1); 312 pj_add_timestamp(&print_time, &t2); 313 314 157 315 status = PJ_SUCCESS; 158 316 … … 161 319 } 162 320 163 164 pj_status_t msg_test(void)165 {166 pj_status_t status;167 pj_pool_t *pool;168 169 pool = pjsip_endpt_create_pool(endpt, NULL, 4000, 4000);170 171 status = test_entry( pool, &test_array[0] );172 173 pjsip_endpt_destroy(endpt);174 return status;175 }176 177 /*****************************************************************************/178 321 179 322 static pjsip_msg *create_msg0(pj_pool_t *pool) … … 258 401 pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact); 259 402 contact->q1000 = 500; 260 url = pjsip_url_create(pool, 0); 261 contact->uri = (pjsip_uri*)url; 403 name_addr = pjsip_name_addr_create(pool); 404 contact->uri = (pjsip_uri*)name_addr; 405 url = pjsip_url_create(pool, 0); 406 name_addr->uri = (pjsip_uri*)url; 262 407 pj_strdup2(pool, &url->user, "user"); 263 408 pj_strdup2(pool, &url->host, "host"); … … 266 411 contact = pjsip_contact_hdr_create(pool); 267 412 pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact); 268 url = pjsip_url_create(pool, 0); 269 contact->uri = (pjsip_uri*)url; 413 name_addr = pjsip_name_addr_create(pool); 414 contact->uri = (pjsip_uri*)name_addr; 415 url = pjsip_url_create(pool, 0); 416 name_addr->uri = (pjsip_uri*)url; 270 417 pj_strdup2(pool, &url->user, "user2"); 271 418 pj_strdup2(pool, &url->host, "host2"); … … 368 515 return msg; 369 516 } 517 518 static pjsip_msg *create_msg1(pj_pool_t *pool) 519 { 520 pjsip_via_hdr *via; 521 pjsip_route_hdr *route; 522 pjsip_name_addr *name_addr; 523 pjsip_url *url; 524 pjsip_max_forwards_hdr *max_fwd; 525 pjsip_to_hdr *to; 526 pjsip_from_hdr *from; 527 pjsip_contact_hdr *contact; 528 pjsip_ctype_hdr *ctype; 529 pjsip_cid_hdr *cid; 530 pjsip_clen_hdr *clen; 531 pjsip_cseq_hdr *cseq; 532 pjsip_msg *msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG); 533 pjsip_msg_body *body; 534 535 //"SIP/2.0 200 OK\r\n" 536 msg->line.status.code = 200; 537 msg->line.status.reason = pj_str("OK"); 538 539 //"Via: SIP/2.0/SCTP server10.biloxi.com;branch=z9hG4bKnashds8;rport;received=192.0.2.1\r\n" 540 via = pjsip_via_hdr_create(pool); 541 pjsip_msg_add_hdr(msg, (pjsip_hdr*)via); 542 via->transport = pj_str("SCTP"); 543 via->sent_by.host = pj_str("server10.biloxi.com"); 544 via->branch_param = pj_str("z9hG4bKnashds8"); 545 via->rport_param = 0; 546 via->recvd_param = pj_str("192.0.2.1"); 547 548 //"Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2\r\n" 549 via = pjsip_via_hdr_create(pool); 550 pjsip_msg_add_hdr(msg, (pjsip_hdr*)via); 551 via->transport = pj_str("UDP"); 552 via->sent_by.host = pj_str("bigbox3.site3.atlanta.com"); 553 via->branch_param = pj_str("z9hG4bK77ef4c2312983.1"); 554 via->recvd_param = pj_str("192.0.2.2"); 555 556 //"Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds ;received=192.0.2.3\r\n" 557 via = pjsip_via_hdr_create(pool); 558 pjsip_msg_add_hdr(msg, (pjsip_hdr*)via); 559 via->transport = pj_str("UDP"); 560 via->sent_by.host = pj_str("pc33.atlanta.com"); 561 via->branch_param = pj_str("z9hG4bK776asdhds"); 562 via->recvd_param = pj_str("192.0.2.3"); 563 564 //"Route: <sip:proxy.sipprovider.com>\r\n" 565 route = pjsip_route_hdr_create(pool); 566 pjsip_msg_add_hdr(msg, (pjsip_hdr*)route); 567 url = pjsip_url_create(pool, PJ_FALSE); 568 route->name_addr.uri = (pjsip_uri*)url; 569 url->host = pj_str("proxy.sipprovider.com"); 570 571 //"Route: <sip:proxy.supersip.com:5060>\r\n" 572 route = pjsip_route_hdr_create(pool); 573 pjsip_msg_add_hdr(msg, (pjsip_hdr*)route); 574 url = pjsip_url_create(pool, PJ_FALSE); 575 route->name_addr.uri = (pjsip_uri*)url; 576 url->host = pj_str("proxy.supersip.com"); 577 url->port = 5060; 578 579 //"Max-Forwards: 70\r\n" 580 max_fwd = pjsip_max_forwards_hdr_create(pool); 581 pjsip_msg_add_hdr(msg, (pjsip_hdr*)max_fwd); 582 max_fwd->ivalue = 70; 583 584 //"To: Bob <sip:bob@biloxi.com>;tag=a6c85cf\r\n" 585 to = pjsip_to_hdr_create(pool); 586 pjsip_msg_add_hdr(msg, (pjsip_hdr*)to); 587 name_addr = pjsip_name_addr_create(pool); 588 name_addr->display = pj_str("Bob"); 589 to->uri = (pjsip_uri*)name_addr; 590 url = pjsip_url_create(pool, PJ_FALSE); 591 name_addr->uri = (pjsip_uri*)url; 592 url->user = pj_str("bob"); 593 url->host = pj_str("biloxi.com"); 594 to->tag = pj_str("a6c85cf"); 595 596 //"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 597 from = pjsip_from_hdr_create(pool); 598 pjsip_msg_add_hdr(msg, (pjsip_hdr*)from); 599 name_addr = pjsip_name_addr_create(pool); 600 name_addr->display = pj_str("Alice"); 601 from->uri = (pjsip_uri*)name_addr; 602 url = pjsip_url_create(pool, PJ_FALSE); 603 name_addr->uri = (pjsip_uri*)url; 604 url->user = pj_str("alice"); 605 url->host = pj_str("atlanta.com"); 606 from->tag = pj_str("1928301774"); 607 608 //"Call-ID: a84b4c76e66710@pc33.atlanta.com\r\n" 609 cid = pjsip_cid_hdr_create(pool); 610 pjsip_msg_add_hdr(msg, (pjsip_hdr*)cid); 611 cid->id = pj_str("a84b4c76e66710@pc33.atlanta.com"); 612 613 //"CSeq: 314159 INVITE\r\n" 614 cseq = pjsip_cseq_hdr_create(pool); 615 pjsip_msg_add_hdr(msg, (pjsip_hdr*)cseq); 616 cseq->cseq = 314159; 617 pjsip_method_set(&cseq->method, PJSIP_INVITE_METHOD); 618 619 //"Contact: <sips:bob@192.0.2.4>\r\n" 620 contact = pjsip_contact_hdr_create(pool); 621 pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact); 622 name_addr = pjsip_name_addr_create(pool); 623 contact->uri = (pjsip_uri*)name_addr; 624 url = pjsip_url_create(pool, PJ_TRUE); 625 name_addr->uri = (pjsip_uri*)url; 626 url->user = pj_str("bob"); 627 url->host = pj_str("192.0.2.4"); 628 629 //"Content-Type: application/sdp\r\n" 630 ctype = pjsip_ctype_hdr_create(pool); 631 pjsip_msg_add_hdr(msg, (pjsip_hdr*)ctype); 632 ctype->media.type = pj_str("application"); 633 ctype->media.subtype = pj_str("sdp"); 634 635 //"Content-Length: 150\r\n" 636 clen = pjsip_clen_hdr_create(pool); 637 pjsip_msg_add_hdr(msg, (pjsip_hdr*)clen); 638 clen->len = 150; 639 640 // Body 641 body = pj_pool_zalloc(pool, sizeof(*body)); 642 msg->body = body; 643 body->content_type.type = pj_str("application"); 644 body->content_type.subtype = pj_str("sdp"); 645 body->data = 646 "v=0\r\n" 647 "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n" 648 "s=-\r\n" 649 "t=0 0\r\n" 650 "c=IN IP4 pc33.atlanta.com\r\n" 651 "m=audio 3456 RTP/AVP 0 1 3 99\r\n" 652 "a=rtpmap:0 PCMU/8000\r\n"; 653 body->len = pj_native_strlen(body->data); 654 body->print_body = &pjsip_print_text_body; 655 656 return msg; 657 } 658 659 /*****************************************************************************/ 660 661 pj_status_t msg_test(void) 662 { 663 pj_status_t status; 664 pj_pool_t *pool; 665 int i, loop; 666 pj_timestamp zero; 667 pj_time_val elapsed; 668 pj_highprec_t avg_detect, avg_parse, avg_print, kbytes; 669 670 PJ_LOG(3,("", " simple test..")); 671 for (i=0; i<PJ_ARRAY_SIZE(test_array); ++i) { 672 pool = pjsip_endpt_create_pool(endpt, NULL, POOL_SIZE, POOL_SIZE); 673 status = test_entry( pool, &test_array[i] ); 674 pjsip_endpt_destroy_pool(endpt, pool); 675 676 if (status != PJ_SUCCESS) 677 return status; 678 } 679 680 PJ_LOG(3,("", " benchmarking..")); 681 detect_len = parse_len = print_len = 0; 682 zero.u64 = detect_time.u64 = parse_time.u64 = print_time.u64 = 0; 683 684 for (loop=0; loop<LOOP; ++loop) { 685 for (i=0; i<PJ_ARRAY_SIZE(test_array); ++i) { 686 pool = pjsip_endpt_create_pool(endpt, NULL, POOL_SIZE, POOL_SIZE); 687 status = test_entry( pool, &test_array[i] ); 688 pjsip_endpt_destroy_pool(endpt, pool); 689 690 if (status != PJ_SUCCESS) 691 return status; 692 } 693 } 694 695 kbytes = detect_len; 696 pj_highprec_mod(kbytes, 1000000); 697 pj_highprec_div(kbytes, 100000); 698 elapsed = pj_elapsed_time(&zero, &detect_time); 699 avg_detect = pj_elapsed_usec(&zero, &detect_time); 700 pj_highprec_mul(avg_detect, AVERAGE_MSG_LEN); 701 pj_highprec_div(avg_detect, detect_len); 702 avg_detect = 1000000 / avg_detect; 703 704 PJ_LOG(3,("", " %u.%u MB detected in %d.%03ds (avg=%d msg detection/sec)", 705 (unsigned)(detect_len/1000000), (unsigned)kbytes, 706 elapsed.sec, elapsed.msec, 707 (unsigned)avg_detect)); 708 709 kbytes = parse_len; 710 pj_highprec_mod(kbytes, 1000000); 711 pj_highprec_div(kbytes, 100000); 712 elapsed = pj_elapsed_time(&zero, &parse_time); 713 avg_parse = pj_elapsed_usec(&zero, &parse_time); 714 pj_highprec_mul(avg_parse, AVERAGE_MSG_LEN); 715 pj_highprec_div(avg_parse, parse_len); 716 avg_parse = 1000000 / avg_parse; 717 718 PJ_LOG(3,("", " %u.%u MB parsed in %d.%03ds (avg=%d msg parsing/sec)", 719 (unsigned)(parse_len/1000000), (unsigned)kbytes, 720 elapsed.sec, elapsed.msec, 721 (unsigned)avg_parse)); 722 723 kbytes = print_len; 724 pj_highprec_mod(kbytes, 1000000); 725 pj_highprec_div(kbytes, 100000); 726 elapsed = pj_elapsed_time(&zero, &print_time); 727 avg_print = pj_elapsed_usec(&zero, &print_time); 728 pj_highprec_mul(avg_print, AVERAGE_MSG_LEN); 729 pj_highprec_div(avg_print, print_len); 730 avg_print = 1000000 / avg_print; 731 732 PJ_LOG(3,("", " %u.%u MB printed in %d.%03ds (avg=%d msg print/sec)", 733 (unsigned)(print_len/1000000), (unsigned)kbytes, 734 elapsed.sec, elapsed.msec, 735 (unsigned)avg_print)); 736 737 return status; 738 } 739 740 /*****************************************************************************/ -
pjproject/trunk/pjsip/src/test-pjsip/test.c
r65 r76 43 43 44 44 pjsip_strerror(rc, errbuf, sizeof(errbuf)); 45 PJ_LOG( 1,("test", "%s: [pj_status_t=%d] %s", msg, rc, errbuf));45 PJ_LOG(3,("test", "%s: [pj_status_t=%d] %s", msg, rc, errbuf)); 46 46 47 47 } … … 82 82 PJ_LOG(3,("","")); 83 83 84 DO_TEST(uri_test()); 84 //DO_TEST(uri_test()); 85 DO_TEST(msg_test()); 85 86 86 87 on_return:
Note: See TracChangeset
for help on using the changeset viewer.