Changeset 119 for pjproject/trunk/pjsip/src/test-pjsip/tsx_uas_test.c
- Timestamp:
- Jan 10, 2006 1:31:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/test-pjsip/tsx_uas_test.c
r117 r119 46 46 ** TEST4_BRANCH_ID 47 47 ** Transaction retransmits last response (if any) without notifying 48 ** transaction user upon receiving request retransmissions on: 49 ** a. TRYING state. 50 ** a. PROCEEDING state. 51 ** b. COMPLETED state. 48 ** transaction user upon receiving request retransmissions on TRYING 49 ** state 52 50 ** 53 51 ** TEST5_BRANCH_ID 54 ** INVITE transaction MUST retransmit final response. (Note: PJSIP also 55 ** retransmit 2xx final response until it's terminated by user). 52 ** As above, in PROCEEDING state. 56 53 ** 57 54 ** TEST6_BRANCH_ID 55 ** As above, in COMPLETED state, with first sending provisional response. 56 ** 57 ** TEST7_BRANCH_ID 58 ** INVITE transaction MUST retransmit non-2xx final response. 59 ** 60 ** TEST8_BRANCH_ID 61 ** As above, for INVITE's 2xx final response (this is PJSIP specific). 62 ** 63 ** TEST9_BRANCH_ID 58 64 ** INVITE transaction MUST cease retransmission of final response when 59 * ACK is received. (Note: PJSIP also retransmit 2xx final response 60 * until it's terminated by user). 61 ** 62 ** TEST7_BRANCH_ID 65 ** ACK is received. (Note: PJSIP also retransmit 2xx final response 66 ** until it's terminated by user). 67 ** Transaction also MUST terminate in T4 seconds. 68 ** 69 ** TEST10_BRANCH_ID 63 70 ** Test where INVITE UAS transaction never receives ACK 64 71 ** 65 ** TEST 8_BRANCH_ID72 ** TEST11_BRANCH_ID 66 73 ** When UAS failed to deliver the response with the selected transport, 67 74 ** it should try contacting the client with other transport or begin … … 73 80 ** c. COMPLETED state. 74 81 ** 75 ** TEST 9_BRANCH_ID82 ** TEST12_BRANCH_ID 76 83 ** Variant of previous test, where transaction fails to deliver the 77 84 ** response using any kind of transports. Transaction should report … … 87 94 static char *TEST6_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test6"; 88 95 static char *TEST7_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test7"; 96 static char *TEST8_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test8"; 97 static char *TEST9_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test9"; 98 static char *TEST10_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test10"; 99 static char *TEST11_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test11"; 100 static char *TEST12_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test12"; 89 101 90 102 #define TEST1_STATUS_CODE 200 … … 92 104 #define TEST3_PROVISIONAL_CODE PJSIP_SC_QUEUED 93 105 #define TEST3_STATUS_CODE 202 94 106 #define TEST4_STATUS_CODE 200 107 #define TEST4_REQUEST_COUNT 2 108 #define TEST5_PROVISIONAL_CODE 100 109 #define TEST5_STATUS_CODE 200 110 #define TEST5_REQUEST_COUNT 2 111 #define TEST5_RESPONSE_COUNT 2 112 #define TEST6_PROVISIONAL_CODE 100 113 #define TEST6_STATUS_CODE 200 /* Must be final */ 114 #define TEST6_REQUEST_COUNT 2 115 #define TEST6_RESPONSE_COUNT 3 116 #define TEST7_STATUS_CODE 301 117 #define TEST8_STATUS_CODE 302 118 119 120 #define TEST4_TITLE "test4: absorbing request retransmission" 121 #define TEST5_TITLE "test5: retransmit last response in PROCEEDING state" 122 #define TEST6_TITLE "test6: retransmit last response in COMPLETED state" 123 124 125 #define TEST_TIMEOUT_ERROR -30 126 #define MAX_ALLOWED_DIFF 150 95 127 96 128 static void tsx_user_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e); … … 162 194 }; 163 195 196 /* Timer callback to send response. */ 164 197 static void send_response_timer( pj_timer_heap_t *timer_heap, 165 198 struct pj_timer_entry *entry) … … 180 213 PJ_LOG(3,(THIS_FILE," error: timer unable to send response")); 181 214 pjsip_tx_data_dec_ref(r->tdata); 215 return; 216 } 217 } 218 219 /* Utility to send response. */ 220 static void send_response( pjsip_rx_data *rdata, 221 pjsip_transaction *tsx, 222 int status_code ) 223 { 224 pj_status_t status; 225 pjsip_tx_data *tdata; 226 227 status = pjsip_endpt_create_response( endpt, rdata, status_code, NULL, 228 &tdata); 229 if (status != PJ_SUCCESS) { 230 app_perror(" error: unable to create response", status); 231 test_complete = -196; 232 return; 233 } 234 235 status = pjsip_tsx_send_msg(tsx, tdata); 236 if (status != PJ_SUCCESS) { 237 app_perror(" error: unable to send response", status); 238 pjsip_tx_data_dec_ref(tdata); 239 test_complete = -197; 182 240 return; 183 241 } … … 222 280 } 223 281 } 282 283 284 /* Find and terminate tsx with the specified key. */ 285 static void terminate_our_tsx(int status_code) 286 { 287 pjsip_transaction *tsx; 288 289 tsx = pjsip_tsx_layer_find_tsx(&tsx_key, PJ_TRUE); 290 if (!tsx) { 291 PJ_LOG(3,(THIS_FILE," error: timer unable to find transaction")); 292 return; 293 } 294 295 pjsip_tsx_terminate(tsx, status_code); 296 pj_mutex_unlock(tsx->mutex); 297 } 298 299 /* Timer callback to terminate transaction. */ 300 static void terminate_tsx_timer( pj_timer_heap_t *timer_heap, 301 struct pj_timer_entry *entry) 302 { 303 terminate_our_tsx(entry->id); 304 } 305 306 307 /* Schedule timer to terminate transaction. */ 308 static void schedule_terminate_tsx( pjsip_transaction *tsx, 309 int status_code, 310 int msec_delay ) 311 { 312 pj_time_val delay; 313 314 delay.sec = 0; 315 delay.msec = msec_delay; 316 pj_time_val_normalize(&delay); 317 318 pj_assert(pj_strcmp(&tsx->transaction_key, &tsx_key)==0); 319 timer.user_data = NULL; 320 timer.id = status_code; 321 timer.cb = &terminate_tsx_timer; 322 pjsip_endpt_schedule_timer(endpt, &timer, &delay); 323 } 324 224 325 225 326 /* … … 332 433 } 333 434 435 } else 436 if (pj_strcmp2(&tsx->branch, TEST4_BRANCH_ID)==0) { 437 /* 438 * TEST4_BRANCH_ID tests receiving retransmissions in TRYING state. 439 */ 440 if (tsx->state == PJSIP_TSX_STATE_TERMINATED) { 441 442 /* Check that status code is status_code. */ 443 if (tsx->status_code != TEST4_STATUS_CODE) { 444 PJ_LOG(3,(THIS_FILE, " error: incorrect status code")); 445 test_complete = -120; 446 } 447 448 /* Previous state. */ 449 if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) { 450 PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state")); 451 test_complete = -121; 452 } 453 454 } else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) 455 { 456 PJ_LOG(3,(THIS_FILE, " error: unexpected state")); 457 test_complete = -122; 458 459 } 460 461 462 } else 463 if (pj_strcmp2(&tsx->branch, TEST5_BRANCH_ID)==0) { 464 /* 465 * TEST5_BRANCH_ID tests receiving retransmissions in PROCEEDING state 466 */ 467 if (tsx->state == PJSIP_TSX_STATE_TERMINATED) { 468 469 /* Check that status code is status_code. */ 470 if (tsx->status_code != TEST5_STATUS_CODE) { 471 PJ_LOG(3,(THIS_FILE, " error: incorrect status code")); 472 test_complete = -130; 473 } 474 475 /* Previous state. */ 476 if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_PROCEEDING) { 477 PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state")); 478 test_complete = -131; 479 } 480 481 } else if (tsx->state == PJSIP_TSX_STATE_PROCEEDING) { 482 483 /* Check status code. */ 484 if (tsx->status_code != TEST5_PROVISIONAL_CODE) { 485 PJ_LOG(3,(THIS_FILE, " error: incorrect status code")); 486 test_complete = -132; 487 } 488 489 } else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) { 490 PJ_LOG(3,(THIS_FILE, " error: unexpected state")); 491 test_complete = -133; 492 493 } 494 495 } else 496 if (pj_strcmp2(&tsx->branch, TEST6_BRANCH_ID)==0) { 497 /* 498 * TEST6_BRANCH_ID tests receiving retransmissions in COMPLETED state 499 */ 500 if (tsx->state == PJSIP_TSX_STATE_TERMINATED) { 501 502 /* Check that status code is status_code. */ 503 if (tsx->status_code != TEST6_STATUS_CODE) { 504 PJ_LOG(3,(THIS_FILE, " error: incorrect status code")); 505 test_complete = -140; 506 } 507 508 /* Previous state. */ 509 if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) { 510 PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state")); 511 test_complete = -141; 512 } 513 514 } else if (tsx->state != PJSIP_TSX_STATE_PROCEEDING && 515 tsx->state != PJSIP_TSX_STATE_COMPLETED && 516 tsx->state != PJSIP_TSX_STATE_DESTROYED) 517 { 518 PJ_LOG(3,(THIS_FILE, " error: unexpected state")); 519 test_complete = -142; 520 521 } 522 523 524 } else 525 if (pj_strcmp2(&tsx->branch, TEST7_BRANCH_ID)==0 || 526 pj_strcmp2(&tsx->branch, TEST8_BRANCH_ID)==0) 527 { 528 /* 529 * TEST7_BRANCH_ID and TEST8_BRANCH_ID test retransmission of 530 * INVITE final response 531 */ 532 int code; 533 534 if (pj_strcmp2(&tsx->branch, TEST7_BRANCH_ID) == 0) 535 code = TEST7_STATUS_CODE; 536 else 537 code = TEST8_STATUS_CODE; 538 539 if (tsx->state == PJSIP_TSX_STATE_TERMINATED) { 540 541 if (test_complete == 0) 542 test_complete = 1; 543 544 /* Check status code. */ 545 if (tsx->status_code != PJSIP_SC_TSX_TIMEOUT) { 546 PJ_LOG(3,(THIS_FILE, " error: incorrect status code")); 547 test_complete = -150; 548 } 549 550 /* Previous state. */ 551 if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) { 552 PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state")); 553 test_complete = -151; 554 } 555 556 } else if (tsx->state == PJSIP_TSX_STATE_COMPLETED) { 557 558 /* Check that status code is status_code. */ 559 if (tsx->status_code != code) { 560 PJ_LOG(3,(THIS_FILE, " error: incorrect status code")); 561 test_complete = -152; 562 } 563 564 /* Previous state. */ 565 if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) { 566 PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state")); 567 test_complete = -153; 568 } 569 570 } else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) { 571 572 PJ_LOG(3,(THIS_FILE, " error: unexpected state")); 573 test_complete = -154; 574 575 } 576 334 577 } 335 578 … … 344 587 pj_strcpy(&tsx_key, &key); 345 588 } 589 590 #define DIFF(a,b) ((a<b) ? (b-a) : (a-b)) 346 591 347 592 /* … … 372 617 */ 373 618 pjsip_transaction *tsx; 374 pjsip_tx_data *tdata;375 619 376 620 status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx); … … 382 626 383 627 save_key(tsx); 384 385 status = pjsip_endpt_create_response(endpt, rdata, 386 status_code, NULL, 387 &tdata); 388 if (status != PJ_SUCCESS) { 389 app_perror(" error: unable to create response", status); 390 test_complete = -111; 391 return PJ_TRUE; 392 } 393 394 status = pjsip_tsx_send_msg(tsx, tdata); 395 if (status != PJ_SUCCESS) { 396 app_perror(" error: unable to send response", status); 397 test_complete = -112; 398 return PJ_TRUE; 399 } 628 send_response(rdata, tsx, status_code); 400 629 401 630 } else { … … 428 657 */ 429 658 pjsip_transaction *tsx; 430 pjsip_tx_data *tdata;431 659 432 660 status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx); … … 439 667 save_key(tsx); 440 668 441 status = pjsip_endpt_create_response(endpt, rdata, 442 TEST3_PROVISIONAL_CODE, NULL, 443 &tdata); 444 if (status != PJ_SUCCESS) { 445 app_perror(" error: unable to create response", status); 446 test_complete = -121; 447 return PJ_TRUE; 448 } 449 450 status = pjsip_tsx_send_msg(tsx, tdata); 451 if (status != PJ_SUCCESS) { 452 app_perror(" error: unable to send response", status); 453 test_complete = -122; 454 return PJ_TRUE; 455 } 456 669 send_response(rdata, tsx, TEST3_PROVISIONAL_CODE); 457 670 schedule_send_response(rdata, &tsx->transaction_key, 458 671 TEST3_STATUS_CODE, 2000); … … 483 696 return PJ_TRUE; 484 697 698 } else if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0 || 699 pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0 || 700 pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0) 701 { 702 703 /* TEST4_BRANCH_ID: absorbs retransmissions in TRYING state. */ 704 /* TEST5_BRANCH_ID: retransmit last response in PROCEEDING state. */ 705 /* TEST6_BRANCH_ID: retransmit last response in COMPLETED state. */ 706 707 if (msg->type == PJSIP_REQUEST_MSG) { 708 /* On received response, create UAS. */ 709 pjsip_transaction *tsx; 710 711 status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx); 712 if (status != PJ_SUCCESS) { 713 app_perror(" error: unable to create transaction", status); 714 test_complete = -130; 715 return PJ_TRUE; 716 } 717 718 save_key(tsx); 719 720 if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0) { 721 722 } else if (pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0) { 723 send_response(rdata, tsx, TEST5_PROVISIONAL_CODE); 724 725 } else if (pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0) { 726 send_response(rdata, tsx, TEST6_PROVISIONAL_CODE); 727 send_response(rdata, tsx, TEST6_STATUS_CODE); 728 } 729 730 } else { 731 /* Verify the response received. */ 732 733 ++recv_count; 734 735 if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0) { 736 PJ_LOG(3,(THIS_FILE, " error: not expecting response!")); 737 test_complete = -132; 738 739 } else if (pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0) { 740 741 if (rdata->msg_info.msg->line.status.code!=TEST5_PROVISIONAL_CODE) { 742 PJ_LOG(3,(THIS_FILE, " error: incorrect status code!")); 743 test_complete = -133; 744 745 } 746 if (recv_count > TEST5_RESPONSE_COUNT) { 747 PJ_LOG(3,(THIS_FILE, " error: not expecting response!")); 748 test_complete = -134; 749 } 750 751 } else if (pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0) { 752 753 int code = rdata->msg_info.msg->line.status.code; 754 755 switch (recv_count) { 756 case 1: 757 if (code != TEST6_PROVISIONAL_CODE) { 758 PJ_LOG(3,(THIS_FILE, " error: invalid code!")); 759 test_complete = -135; 760 } 761 break; 762 case 2: 763 case 3: 764 if (code != TEST6_STATUS_CODE) { 765 PJ_LOG(3,(THIS_FILE, " error: invalid code!")); 766 test_complete = -136; 767 } 768 break; 769 default: 770 PJ_LOG(3,(THIS_FILE, " error: not expecting response")); 771 test_complete = -137; 772 break; 773 } 774 } 775 } 776 return PJ_TRUE; 777 778 779 } else if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0 || 780 pj_strcmp2(&branch_param, TEST8_BRANCH_ID) == 0) 781 { 782 783 /* 784 * TEST7_BRANCH_ID and TEST8_BRANCH_ID test the retransmission 785 * of INVITE final response 786 */ 787 if (msg->type == PJSIP_REQUEST_MSG) { 788 789 /* On received response, create UAS. */ 790 pjsip_transaction *tsx; 791 792 status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx); 793 if (status != PJ_SUCCESS) { 794 app_perror(" error: unable to create transaction", status); 795 test_complete = -140; 796 return PJ_TRUE; 797 } 798 799 save_key(tsx); 800 801 if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0) { 802 803 send_response(rdata, tsx, TEST7_STATUS_CODE); 804 805 } else { 806 807 send_response(rdata, tsx, TEST8_STATUS_CODE); 808 809 } 810 811 } else { 812 int code; 813 814 ++recv_count; 815 816 if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0) 817 code = TEST7_STATUS_CODE; 818 else 819 code = TEST8_STATUS_CODE; 820 821 if (recv_count==1) { 822 823 if (rdata->msg_info.msg->line.status.code != code) { 824 PJ_LOG(3,(THIS_FILE," error: invalid status code")); 825 test_complete = -141; 826 } 827 828 recv_last = rdata->pkt_info.timestamp; 829 830 } else { 831 832 pj_time_val now; 833 unsigned msec, msec_expected; 834 835 now = rdata->pkt_info.timestamp; 836 837 PJ_TIME_VAL_SUB(now, recv_last); 838 839 msec = now.sec*1000 + now.msec; 840 msec_expected = (1 << (recv_count-2)) * PJSIP_T1_TIMEOUT; 841 if (msec_expected > PJSIP_T2_TIMEOUT) 842 msec_expected = PJSIP_T2_TIMEOUT; 843 844 if (DIFF(msec, msec_expected) > MAX_ALLOWED_DIFF) { 845 PJ_LOG(3,(THIS_FILE, 846 " error: incorrect retransmission " 847 "time (%d ms expected, %d ms received", 848 msec_expected, msec)); 849 test_complete = -142; 850 } 851 852 if (recv_count > 11) { 853 PJ_LOG(3,(THIS_FILE," error: too many responses (%d)", 854 recv_count)); 855 test_complete = -143; 856 } 857 858 recv_last = rdata->pkt_info.timestamp; 859 } 860 861 } 862 return PJ_TRUE; 863 864 } else if (pj_strcmp2(&branch_param, TEST9_BRANCH_ID)) { 865 866 /* 867 * TEST9_BRANCH_ID tests that the retransmission of INVITE final 868 * response should cease when ACK is received. Transaction also MUST 869 * terminate in T4 seconds. 870 */ 871 if (msg->type == PJSIP_REQUEST_MSG) { 872 873 /* On received response, create UAS. */ 874 pjsip_transaction *tsx; 875 876 status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx); 877 if (status != PJ_SUCCESS) { 878 app_perror(" error: unable to create transaction", status); 879 test_complete = -140; 880 return PJ_TRUE; 881 } 882 883 save_key(tsx); 884 885 if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0) { 886 887 send_response(rdata, tsx, TEST7_STATUS_CODE); 888 889 } else { 890 891 send_response(rdata, tsx, TEST8_STATUS_CODE); 892 893 } 894 895 } else { 896 int code; 897 898 ++recv_count; 899 900 if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0) 901 code = TEST7_STATUS_CODE; 902 else 903 code = TEST8_STATUS_CODE; 904 905 if (recv_count==1) { 906 907 if (rdata->msg_info.msg->line.status.code != code) { 908 PJ_LOG(3,(THIS_FILE," error: invalid status code")); 909 test_complete = -141; 910 } 911 912 recv_last = rdata->pkt_info.timestamp; 913 914 } else { 915 916 pj_time_val now; 917 unsigned msec, msec_expected; 918 919 now = rdata->pkt_info.timestamp; 920 921 PJ_TIME_VAL_SUB(now, recv_last); 922 923 msec = now.sec*1000 + now.msec; 924 msec_expected = (1 << (recv_count-2)) * PJSIP_T1_TIMEOUT; 925 if (msec_expected > PJSIP_T2_TIMEOUT) 926 msec_expected = PJSIP_T2_TIMEOUT; 927 928 if (DIFF(msec, msec_expected) > MAX_ALLOWED_DIFF) { 929 PJ_LOG(3,(THIS_FILE, 930 " error: incorrect retransmission " 931 "time (%d ms expected, %d ms received", 932 msec_expected, msec)); 933 test_complete = -142; 934 } 935 936 if (recv_count > 11) { 937 PJ_LOG(3,(THIS_FILE," error: too many responses (%d)", 938 recv_count)); 939 test_complete = -143; 940 } 941 942 recv_last = rdata->pkt_info.timestamp; 943 } 944 945 } 946 return PJ_TRUE; 485 947 } 486 948 … … 493 955 static int perform_test( char *target_uri, char *from_uri, 494 956 char *branch_param, int test_time, 495 const pjsip_method *method ) 957 const pjsip_method *method, 958 int request_cnt, int request_interval_msec, 959 int expecting_timeout) 496 960 { 497 961 pjsip_tx_data *tdata; 498 962 pj_str_t target, from; 499 963 pjsip_via_hdr *via; 500 pj_time_val timeout; 964 pj_time_val timeout, next_send; 965 int sent_cnt; 501 966 pj_status_t status; 502 967 … … 527 992 via->branch_param = pj_str(branch_param); 528 993 529 /* Add additional reference to tdata to prevent transaction from 530 * deleting it. 531 */ 532 pjsip_tx_data_add_ref(tdata); 533 534 /* Send the first message. */ 535 status = pjsip_endpt_send_request_stateless(endpt, tdata, NULL, NULL); 536 if (status != PJ_SUCCESS) { 537 app_perror(" Error: unable to send request", status); 538 return -20; 539 } 994 /* Schedule first send. */ 995 sent_cnt = 0; 996 pj_gettimeofday(&next_send); 997 pj_time_val_normalize(&next_send); 540 998 541 999 /* Set test completion time. */ … … 550 1008 551 1009 pj_gettimeofday(&now); 1010 1011 if (sent_cnt < request_cnt && PJ_TIME_VAL_GTE(now, next_send)) { 1012 /* Add additional reference to tdata to prevent transaction from 1013 * deleting it. 1014 */ 1015 pjsip_tx_data_add_ref(tdata); 1016 1017 /* (Re)Send the request. */ 1018 status = pjsip_endpt_send_request_stateless(endpt, tdata, 0, 0); 1019 if (status != PJ_SUCCESS) { 1020 app_perror(" Error: unable to send request", status); 1021 pjsip_tx_data_dec_ref(tdata); 1022 return -20; 1023 } 1024 1025 /* Schedule next send, if any. */ 1026 sent_cnt++; 1027 if (sent_cnt < request_cnt) { 1028 pj_gettimeofday(&next_send); 1029 next_send.msec += request_interval_msec; 1030 pj_time_val_normalize(&next_send); 1031 } 1032 } 1033 552 1034 if (now.sec > timeout.sec) { 553 PJ_LOG(3,(THIS_FILE, " Error: test has timed out")); 1035 if (!expecting_timeout) 1036 PJ_LOG(3,(THIS_FILE, " Error: test has timed out")); 554 1037 pjsip_tx_data_dec_ref(tdata); 555 return -30;1038 return TEST_TIMEOUT_ERROR; 556 1039 } 557 1040 } … … 613 1096 TEST1_BRANCH_ID, 614 1097 33, /* Test duration must be greater than 32 secs */ 615 &pjsip_options_method );1098 &pjsip_options_method, 1, 0, 0); 616 1099 if (status != 0) 617 1100 return status; … … 623 1106 TEST2_BRANCH_ID, 624 1107 33, /* Test duration must be greater than 32 secs */ 625 &pjsip_options_method );1108 &pjsip_options_method, 1, 0, 0); 626 1109 if (status != 0) 627 1110 return status; … … 647 1130 TEST3_BRANCH_ID, 648 1131 35, 649 &pjsip_options_method); 1132 &pjsip_options_method, 1, 0, 0); 1133 650 1134 return status; 651 1135 } 1136 1137 1138 /***************************************************************************** 1139 ** 1140 ** TEST4_BRANCH_ID: Absorbs retransmissions in TRYING state 1141 ** TEST5_BRANCH_ID: Absorbs retransmissions in PROCEEDING state 1142 ** TEST6_BRANCH_ID: Absorbs retransmissions in COMPLETED state 1143 ** 1144 ***************************************************************************** 1145 */ 1146 static int tsx_retransmit_last_response_test(const char *title, 1147 char *branch_id, 1148 int request_cnt, 1149 int status_code) 1150 { 1151 int status; 1152 1153 PJ_LOG(3,(THIS_FILE," %s", title)); 1154 1155 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1156 "sip:129.0.0.1;transport=loop-dgram", 1157 branch_id, 1158 5, 1159 &pjsip_options_method, 1160 request_cnt, 1000, 1); 1161 if (status && status != TEST_TIMEOUT_ERROR) 1162 return status; 1163 if (!status) { 1164 PJ_LOG(3,(THIS_FILE, " error: expecting timeout")); 1165 return -31; 1166 } 1167 1168 terminate_our_tsx(status_code); 1169 flush_events(100); 1170 1171 if (test_complete != 1) 1172 return test_complete; 1173 1174 flush_events(100); 1175 return 0; 1176 } 1177 1178 /***************************************************************************** 1179 ** 1180 ** TEST7_BRANCH_ID: INVITE non-2xx final response retransmission test 1181 ** TEST8_BRANCH_ID: INVITE 2xx final response retransmission test 1182 ** 1183 ***************************************************************************** 1184 */ 1185 static int tsx_final_response_retransmission_test(void) 1186 { 1187 int status; 1188 1189 PJ_LOG(3,(THIS_FILE, 1190 " test7: INVITE non-2xx final response retransmission")); 1191 1192 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1193 "sip:129.0.0.1;transport=loop-dgram", 1194 TEST7_BRANCH_ID, 1195 33, /* Test duration must be greater than 32 secs */ 1196 &pjsip_invite_method, 1, 0, 0); 1197 if (status != 0) 1198 return status; 1199 1200 PJ_LOG(3,(THIS_FILE, 1201 " test8: INVITE 2xx final response retransmission")); 1202 1203 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1204 "sip:129.0.0.1;transport=loop-dgram", 1205 TEST8_BRANCH_ID, 1206 33, /* Test duration must be greater than 32 secs */ 1207 &pjsip_invite_method, 1, 0, 0); 1208 if (status != 0) 1209 return status; 1210 1211 return 0; 1212 } 1213 652 1214 653 1215 … … 690 1252 if (status != 0) 691 1253 return status; 692 #endif693 1254 694 1255 /* TEST3_BRANCH_ID: with provisional response … … 698 1259 return status; 699 1260 1261 /* TEST4_BRANCH_ID: absorbs retransmissions in TRYING state 1262 */ 1263 status = tsx_retransmit_last_response_test(TEST4_TITLE, 1264 TEST4_BRANCH_ID, 1265 TEST4_REQUEST_COUNT, 1266 TEST4_STATUS_CODE); 1267 if (status != 0) 1268 return status; 1269 1270 /* TEST5_BRANCH_ID: retransmit last response in PROCEEDING state 1271 */ 1272 status = tsx_retransmit_last_response_test(TEST5_TITLE, 1273 TEST5_BRANCH_ID, 1274 TEST5_REQUEST_COUNT, 1275 TEST5_STATUS_CODE); 1276 if (status != 0) 1277 return status; 1278 1279 /* TEST6_BRANCH_ID: retransmit last response in PROCEEDING state 1280 */ 1281 status = tsx_retransmit_last_response_test(TEST6_TITLE, 1282 TEST6_BRANCH_ID, 1283 TEST6_REQUEST_COUNT, 1284 TEST6_STATUS_CODE); 1285 if (status != 0) 1286 return status; 1287 1288 /* TEST7_BRANCH_ID: INVITE non-2xx final response retransmission test 1289 * TEST8_BRANCH_ID: INVITE 2xx final response retransmission test 1290 */ 1291 1292 status = tsx_final_response_retransmission_test(); 1293 if (status != 0) 1294 return status; 1295 1296 #endif 700 1297 701 1298 pjsip_transport_dec_ref(loop);
Note: See TracChangeset
for help on using the changeset viewer.