1
/* $Id: tsx_uas_test.c 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
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.
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.
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
25
#define THIS_FILE "tsx_uas_test.c"
28
/*****************************************************************************
32
** This file performs various tests for UAC transactions. Each test will have
33
** a different Via branch param so that message receiver module and
34
** transaction user module can identify which test is being carried out.
37
** Test that non-INVITE transaction returns 2xx response to the correct
38
** transport and correctly terminates the transaction.
39
** This also checks that transaction is destroyed immediately after
40
** it sends final response when reliable transport is used.
43
** As above, for non-2xx final response.
46
** Transaction correctly progressing to PROCEEDING state when provisional
50
** Transaction retransmits last response (if any) without notifying
51
** transaction user upon receiving request retransmissions on TRYING
55
** As above, in PROCEEDING state.
58
** As above, in COMPLETED state, with first sending provisional response.
59
** (Only applicable for non-reliable transports).
62
** INVITE transaction MUST retransmit non-2xx final response.
65
** As above, for INVITE's 2xx final response (this is PJSIP specific).
68
** INVITE transaction MUST cease retransmission of final response when
69
** ACK is received. (Note: PJSIP also retransmit 2xx final response
70
** until it's terminated by user).
71
** Transaction also MUST terminate in T4 seconds.
72
** (Only applicable for non-reliable transports).
75
** Test scenario where transport fails before response is sent (i.e.
79
** As above, after provisional response is sent but before final
80
** response is sent (i.e. in PROCEEDING state).
83
** As above, for INVITE, after final response has been sent but before
84
** ACK is received (i.e. in CONNECTED state).
87
** When UAS failed to deliver the response with the selected transport,
88
** it should try contacting the client with other transport or begin
89
** RFC 3263 server resolution procedure.
90
** This should be tested on:
91
** a. TRYING state (when delivering first response).
92
** b. PROCEEDING state (when failed to retransmit last response
93
** upon receiving request retransmission).
94
** c. COMPLETED state.
98
#define TEST1_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test1")
99
#define TEST2_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test2")
100
#define TEST3_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test3")
101
#define TEST4_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test4")
102
#define TEST5_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test5")
103
#define TEST6_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test6")
104
#define TEST7_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test7")
105
#define TEST8_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test8")
106
#define TEST9_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test9")
107
#define TEST10_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test10")
108
#define TEST11_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test11")
109
#define TEST12_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test12")
110
//#define TEST13_BRANCH_ID (PJSIP_RFC3261_BRANCH_ID "-UAS-Test13")
112
#define TEST1_STATUS_CODE 200
113
#define TEST2_STATUS_CODE 301
114
#define TEST3_PROVISIONAL_CODE PJSIP_SC_QUEUED
115
#define TEST3_STATUS_CODE 202
116
#define TEST4_STATUS_CODE 200
117
#define TEST4_REQUEST_COUNT 2
118
#define TEST5_PROVISIONAL_CODE 100
119
#define TEST5_STATUS_CODE 200
120
#define TEST5_REQUEST_COUNT 2
121
#define TEST5_RESPONSE_COUNT 2
122
#define TEST6_PROVISIONAL_CODE 100
123
#define TEST6_STATUS_CODE 200 /* Must be final */
124
#define TEST6_REQUEST_COUNT 2
125
#define TEST6_RESPONSE_COUNT 3
126
#define TEST7_STATUS_CODE 301
127
#define TEST8_STATUS_CODE 302
128
#define TEST9_STATUS_CODE 301
131
#define TEST4_TITLE "test4: absorbing request retransmission"
132
#define TEST5_TITLE "test5: retransmit last response in PROCEEDING state"
133
#define TEST6_TITLE "test6: retransmit last response in COMPLETED state"
136
static char TARGET_URI[128];
137
static char FROM_URI[128];
138
static struct tsx_test_param *test_param;
139
static unsigned tp_flag;
142
#define TEST_TIMEOUT_ERROR -30
143
#define MAX_ALLOWED_DIFF 150
145
static void tsx_user_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e);
146
static pj_bool_t on_rx_message(pjsip_rx_data *rdata);
148
/* UAC transaction user module. */
149
static pjsip_module tsx_user =
151
NULL, NULL, /* prev and next */
152
{ "Tsx-UAS-User", 12}, /* Name. */
154
PJSIP_MOD_PRIORITY_APPLICATION-1, /* Priority */
159
NULL, /* on_rx_request() */
160
NULL, /* on_rx_response() */
161
NULL, /* on_tx_request() */
162
NULL, /* on_tx_response() */
163
&tsx_user_on_tsx_state, /* on_tsx_state() */
166
/* Module to send request. */
167
static pjsip_module msg_sender =
169
NULL, NULL, /* prev and next */
170
{ "Msg-Sender", 10}, /* Name. */
172
PJSIP_MOD_PRIORITY_APPLICATION-1, /* Priority */
177
&on_rx_message, /* on_rx_request() */
178
&on_rx_message, /* on_rx_response() */
179
NULL, /* on_tx_request() */
180
NULL, /* on_tx_response() */
181
NULL, /* on_tsx_state() */
184
/* Static vars, which will be reset on each test. */
185
static int recv_count;
186
static pj_time_val recv_last;
187
static pj_bool_t test_complete;
189
/* Loop transport instance. */
190
static pjsip_transport *loop;
192
/* UAS transaction key. */
193
static char key_buf[64];
194
static pj_str_t tsx_key = { key_buf, 0 };
197
/* General timer entry to be used by tests. */
198
//static pj_timer_entry timer;
200
/* Timer to send response via transaction. */
204
pjsip_tx_data *tdata;
207
/* Timer callback to send response. */
208
static void send_response_timer( pj_timer_heap_t *timer_heap,
209
struct pj_timer_entry *entry)
211
pjsip_transaction *tsx;
212
struct response *r = (struct response*) entry->user_data;
215
PJ_UNUSED_ARG(timer_heap);
217
tsx = pjsip_tsx_layer_find_tsx(&r->tsx_key, PJ_TRUE);
219
PJ_LOG(3,(THIS_FILE," error: timer unable to find transaction"));
220
pjsip_tx_data_dec_ref(r->tdata);
224
status = pjsip_tsx_send_msg(tsx, r->tdata);
225
if (status != PJ_SUCCESS) {
226
// Some tests do expect failure!
227
//PJ_LOG(3,(THIS_FILE," error: timer unable to send response"));
228
pj_mutex_unlock(tsx->mutex);
229
pjsip_tx_data_dec_ref(r->tdata);
233
pj_mutex_unlock(tsx->mutex);
236
/* Utility to send response. */
237
static void send_response( pjsip_rx_data *rdata,
238
pjsip_transaction *tsx,
242
pjsip_tx_data *tdata;
244
status = pjsip_endpt_create_response( endpt, rdata, status_code, NULL,
246
if (status != PJ_SUCCESS) {
247
app_perror(" error: unable to create response", status);
248
test_complete = -196;
252
status = pjsip_tsx_send_msg(tsx, tdata);
253
if (status != PJ_SUCCESS) {
254
pjsip_tx_data_dec_ref(tdata);
255
// Some tests do expect failure!
256
//app_perror(" error: unable to send response", status);
257
//test_complete = -197;
262
/* Schedule timer to send response for the specified UAS transaction */
263
static void schedule_send_response( pjsip_rx_data *rdata,
264
const pj_str_t *tsx_key,
269
pjsip_tx_data *tdata;
274
status = pjsip_endpt_create_response( endpt, rdata, status_code, NULL,
276
if (status != PJ_SUCCESS) {
277
app_perror(" error: unable to create response", status);
278
test_complete = -198;
282
r = PJ_POOL_ALLOC_T(tdata->pool, struct response);
283
pj_strdup(tdata->pool, &r->tsx_key, tsx_key);
287
delay.msec = msec_delay;
288
pj_time_val_normalize(&delay);
290
t = PJ_POOL_ZALLOC_T(tdata->pool, pj_timer_entry);
292
t->cb = &send_response_timer;
294
status = pjsip_endpt_schedule_timer(endpt, t, &delay);
295
if (status != PJ_SUCCESS) {
296
pjsip_tx_data_dec_ref(tdata);
297
app_perror(" error: unable to schedule timer", status);
298
test_complete = -199;
304
/* Find and terminate tsx with the specified key. */
305
static void terminate_our_tsx(int status_code)
307
pjsip_transaction *tsx;
309
tsx = pjsip_tsx_layer_find_tsx(&tsx_key, PJ_TRUE);
311
PJ_LOG(3,(THIS_FILE," error: timer unable to find transaction"));
315
pjsip_tsx_terminate(tsx, status_code);
316
pj_mutex_unlock(tsx->mutex);
319
#if 0 /* Unused for now */
320
/* Timer callback to terminate transaction. */
321
static void terminate_tsx_timer( pj_timer_heap_t *timer_heap,
322
struct pj_timer_entry *entry)
324
terminate_our_tsx(entry->id);
328
/* Schedule timer to terminate transaction. */
329
static void schedule_terminate_tsx( pjsip_transaction *tsx,
336
delay.msec = msec_delay;
337
pj_time_val_normalize(&delay);
339
pj_assert(pj_strcmp(&tsx->transaction_key, &tsx_key)==0);
340
timer.user_data = NULL;
341
timer.id = status_code;
342
timer.cb = &terminate_tsx_timer;
343
pjsip_endpt_schedule_timer(endpt, &timer, &delay);
349
* This is the handler to receive state changed notification from the
350
* transaction. It is used to verify that the transaction behaves according
351
* to the test scenario.
353
static void tsx_user_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e)
355
if (pj_strcmp2(&tsx->branch, TEST1_BRANCH_ID)==0 ||
356
pj_strcmp2(&tsx->branch, TEST2_BRANCH_ID)==0)
359
* TEST1_BRANCH_ID tests that non-INVITE transaction transmits final
360
* response using correct transport and terminates transaction after
361
* T4 (PJSIP_T4_TIMEOUT, 5 seconds).
363
* TEST2_BRANCH_ID does similar test for non-2xx final response.
365
int status_code = (pj_strcmp2(&tsx->branch, TEST1_BRANCH_ID)==0) ?
366
TEST1_STATUS_CODE : TEST2_STATUS_CODE;
368
if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
372
/* Check that status code is status_code. */
373
if (tsx->status_code != status_code) {
374
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
375
test_complete = -100;
378
/* Previous state must be completed. */
379
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
380
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
381
test_complete = -101;
384
} else if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
386
/* Previous state must be TRYING. */
387
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
388
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
389
test_complete = -102;
395
if (pj_strcmp2(&tsx->branch, TEST3_BRANCH_ID)==0) {
397
* TEST3_BRANCH_ID tests sending provisional response.
399
if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
403
/* Check that status code is status_code. */
404
if (tsx->status_code != TEST3_STATUS_CODE) {
405
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
406
test_complete = -110;
409
/* Previous state must be completed. */
410
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
411
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
412
test_complete = -111;
415
} else if (tsx->state == PJSIP_TSX_STATE_PROCEEDING) {
417
/* Previous state must be TRYING. */
418
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
419
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
420
test_complete = -112;
423
/* Check that status code is status_code. */
424
if (tsx->status_code != TEST3_PROVISIONAL_CODE) {
425
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
426
test_complete = -113;
429
/* Check that event must be TX_MSG */
430
if (e->body.tsx_state.type != PJSIP_EVENT_TX_MSG) {
431
PJ_LOG(3,(THIS_FILE, " error: incorrect event"));
432
test_complete = -114;
435
} else if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
437
/* Previous state must be PROCEEDING. */
438
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_PROCEEDING) {
439
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
440
test_complete = -115;
443
/* Check that status code is status_code. */
444
if (tsx->status_code != TEST3_STATUS_CODE) {
445
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
446
test_complete = -116;
449
/* Check that event must be TX_MSG */
450
if (e->body.tsx_state.type != PJSIP_EVENT_TX_MSG) {
451
PJ_LOG(3,(THIS_FILE, " error: incorrect event"));
452
test_complete = -117;
458
if (pj_strcmp2(&tsx->branch, TEST4_BRANCH_ID)==0) {
460
* TEST4_BRANCH_ID tests receiving retransmissions in TRYING state.
462
if (tsx->state == PJSIP_TSX_STATE_TRYING) {
463
/* Request is received. */
464
} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
466
/* Check that status code is status_code. */
467
if (tsx->status_code != TEST4_STATUS_CODE) {
469
" error: incorrect status code %d "
470
"(expecting %d)", tsx->status_code,
472
test_complete = -120;
475
/* Previous state. */
476
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
477
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
478
test_complete = -121;
481
} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED)
483
PJ_LOG(3,(THIS_FILE, " error: unexpected state %s (122)",
484
pjsip_tsx_state_str(tsx->state)));
485
test_complete = -122;
491
if (pj_strcmp2(&tsx->branch, TEST5_BRANCH_ID)==0) {
493
* TEST5_BRANCH_ID tests receiving retransmissions in PROCEEDING state
495
if (tsx->state == PJSIP_TSX_STATE_TRYING) {
496
/* Request is received. */
498
} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
500
/* Check that status code is status_code. */
501
if (tsx->status_code != TEST5_STATUS_CODE) {
502
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
503
test_complete = -130;
506
/* Previous state. */
507
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_PROCEEDING) {
508
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
509
test_complete = -131;
512
} else if (tsx->state == PJSIP_TSX_STATE_PROCEEDING) {
514
/* Check status code. */
515
if (tsx->status_code != TEST5_PROVISIONAL_CODE) {
516
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
517
test_complete = -132;
520
} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) {
521
PJ_LOG(3,(THIS_FILE, " error: unexpected state %s (133)",
522
pjsip_tsx_state_str(tsx->state)));
523
test_complete = -133;
528
if (pj_strcmp2(&tsx->branch, TEST6_BRANCH_ID)==0) {
530
* TEST6_BRANCH_ID tests receiving retransmissions in COMPLETED state
532
if (tsx->state == PJSIP_TSX_STATE_TRYING) {
533
/* Request is received. */
535
} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
537
/* Check that status code is status_code. */
538
if (tsx->status_code != TEST6_STATUS_CODE) {
539
PJ_LOG(3,(THIS_FILE, " error: incorrect status code %d "
540
"(expecting %d)", tsx->status_code,
542
test_complete = -140;
545
/* Previous state. */
546
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
547
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
548
test_complete = -141;
551
} else if (tsx->state != PJSIP_TSX_STATE_PROCEEDING &&
552
tsx->state != PJSIP_TSX_STATE_COMPLETED &&
553
tsx->state != PJSIP_TSX_STATE_DESTROYED)
555
PJ_LOG(3,(THIS_FILE, " error: unexpected state %s (142)",
556
pjsip_tsx_state_str(tsx->state)));
557
test_complete = -142;
563
if (pj_strcmp2(&tsx->branch, TEST7_BRANCH_ID)==0 ||
564
pj_strcmp2(&tsx->branch, TEST8_BRANCH_ID)==0)
567
* TEST7_BRANCH_ID and TEST8_BRANCH_ID test retransmission of
568
* INVITE final response
572
if (pj_strcmp2(&tsx->branch, TEST7_BRANCH_ID) == 0)
573
code = TEST7_STATUS_CODE;
575
code = TEST8_STATUS_CODE;
577
if (tsx->state == PJSIP_TSX_STATE_TRYING) {
578
/* Request is received. */
580
} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
582
if (test_complete == 0)
585
/* Check status code. */
586
if (tsx->status_code != PJSIP_SC_TSX_TIMEOUT) {
587
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
588
test_complete = -150;
591
/* Previous state. */
592
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
593
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
594
test_complete = -151;
597
/* Check the number of retransmissions */
598
if (tp_flag & PJSIP_TRANSPORT_RELIABLE) {
600
if (tsx->retransmit_count != 0) {
601
PJ_LOG(3,(THIS_FILE, " error: should not retransmit"));
602
test_complete = -1510;
607
if (tsx->retransmit_count != 10) {
609
" error: incorrect retransmit count %d "
611
tsx->retransmit_count));
612
test_complete = -1510;
617
} else if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
619
/* Check that status code is status_code. */
620
if (tsx->status_code != code) {
621
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
622
test_complete = -152;
625
/* Previous state. */
626
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
627
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
628
test_complete = -153;
631
} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) {
633
PJ_LOG(3,(THIS_FILE, " error: unexpected state (154)"));
634
test_complete = -154;
640
if (pj_strcmp2(&tsx->branch, TEST9_BRANCH_ID)==0) {
642
* TEST9_BRANCH_ID tests that retransmission of INVITE final response
643
* must cease when ACK is received.
646
if (tsx->state == PJSIP_TSX_STATE_TRYING) {
647
/* Request is received. */
649
} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
651
if (test_complete == 0)
654
/* Check status code. */
655
if (tsx->status_code != TEST9_STATUS_CODE) {
656
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
657
test_complete = -160;
660
/* Previous state. */
661
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_CONFIRMED) {
662
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
663
test_complete = -161;
666
} else if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
668
/* Check that status code is status_code. */
669
if (tsx->status_code != TEST9_STATUS_CODE) {
670
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
671
test_complete = -162;
674
/* Previous state. */
675
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
676
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
677
test_complete = -163;
681
} else if (tsx->state == PJSIP_TSX_STATE_CONFIRMED) {
683
/* Check that status code is status_code. */
684
if (tsx->status_code != TEST9_STATUS_CODE) {
685
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
686
test_complete = -164;
689
/* Previous state. */
690
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
691
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
692
test_complete = -165;
695
} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) {
697
PJ_LOG(3,(THIS_FILE, " error: unexpected state (166)"));
698
test_complete = -166;
704
if (pj_strcmp2(&tsx->branch, TEST10_BRANCH_ID)==0 ||
705
pj_strcmp2(&tsx->branch, TEST11_BRANCH_ID)==0 ||
706
pj_strcmp2(&tsx->branch, TEST12_BRANCH_ID)==0)
708
if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
713
if (tsx->status_code != PJSIP_SC_TSX_TRANSPORT_ERROR) {
714
PJ_LOG(3,(THIS_FILE," error: incorrect status code"));
715
test_complete = -170;
722
/* Save transaction key to global variables. */
723
static void save_key(pjsip_transaction *tsx)
727
pj_strdup(tsx->pool, &key, &tsx->transaction_key);
728
pj_strcpy(&tsx_key, &key);
731
#define DIFF(a,b) ((a<b) ? (b-a) : (a-b))
734
* Message receiver handler.
736
static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
738
pjsip_msg *msg = rdata->msg_info.msg;
739
pj_str_t branch_param = rdata->msg_info.via->branch_param;
742
if (pj_strcmp2(&branch_param, TEST1_BRANCH_ID) == 0 ||
743
pj_strcmp2(&branch_param, TEST2_BRANCH_ID) == 0)
746
* TEST1_BRANCH_ID tests that non-INVITE transaction transmits 2xx
747
* final response using correct transport and terminates transaction
750
* TEST2_BRANCH_ID performs similar test for non-2xx final response.
752
int status_code = (pj_strcmp2(&branch_param, TEST1_BRANCH_ID) == 0) ?
753
TEST1_STATUS_CODE : TEST2_STATUS_CODE;
755
if (msg->type == PJSIP_REQUEST_MSG) {
756
/* On received request, create UAS and respond with final
759
pjsip_transaction *tsx;
761
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
762
if (status != PJ_SUCCESS) {
763
app_perror(" error: unable to create transaction", status);
764
test_complete = -110;
767
pjsip_tsx_recv_msg(tsx, rdata);
770
send_response(rdata, tsx, status_code);
773
/* Verify the response received. */
777
/* Verify status code. */
778
if (msg->line.status.code != status_code) {
779
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
780
test_complete = -113;
783
/* Verify that no retransmissions is received. */
784
if (recv_count > 1) {
785
PJ_LOG(3,(THIS_FILE, " error: retransmission received"));
786
test_complete = -114;
792
} else if (pj_strcmp2(&branch_param, TEST3_BRANCH_ID) == 0) {
794
/* TEST3_BRANCH_ID tests provisional response. */
796
if (msg->type == PJSIP_REQUEST_MSG) {
797
/* On received request, create UAS and respond with provisional
798
* response, then schedule timer to send final response.
800
pjsip_transaction *tsx;
802
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
803
if (status != PJ_SUCCESS) {
804
app_perror(" error: unable to create transaction", status);
805
test_complete = -116;
808
pjsip_tsx_recv_msg(tsx, rdata);
812
send_response(rdata, tsx, TEST3_PROVISIONAL_CODE);
813
schedule_send_response(rdata, &tsx->transaction_key,
814
TEST3_STATUS_CODE, 2000);
817
/* Verify the response received. */
821
if (recv_count == 1) {
822
/* Verify status code. */
823
if (msg->line.status.code != TEST3_PROVISIONAL_CODE) {
824
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
825
test_complete = -123;
827
} else if (recv_count == 2) {
828
/* Verify status code. */
829
if (msg->line.status.code != TEST3_STATUS_CODE) {
830
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
831
test_complete = -124;
834
PJ_LOG(3,(THIS_FILE, " error: retransmission received"));
835
test_complete = -125;
841
} else if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0 ||
842
pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0 ||
843
pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0)
846
/* TEST4_BRANCH_ID: absorbs retransmissions in TRYING state. */
847
/* TEST5_BRANCH_ID: retransmit last response in PROCEEDING state. */
848
/* TEST6_BRANCH_ID: retransmit last response in COMPLETED state. */
850
if (msg->type == PJSIP_REQUEST_MSG) {
851
/* On received request, create UAS. */
852
pjsip_transaction *tsx;
854
PJ_LOG(4,(THIS_FILE, " received request (probably retransmission)"));
856
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
857
if (status != PJ_SUCCESS) {
858
app_perror(" error: unable to create transaction", status);
859
test_complete = -130;
863
pjsip_tsx_recv_msg(tsx, rdata);
866
if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0) {
868
} else if (pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0) {
869
send_response(rdata, tsx, TEST5_PROVISIONAL_CODE);
871
} else if (pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0) {
872
PJ_LOG(4,(THIS_FILE, " sending provisional response"));
873
send_response(rdata, tsx, TEST6_PROVISIONAL_CODE);
874
PJ_LOG(4,(THIS_FILE, " sending final response"));
875
send_response(rdata, tsx, TEST6_STATUS_CODE);
879
/* Verify the response received. */
881
PJ_LOG(4,(THIS_FILE, " received response number %d", recv_count));
885
if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0) {
886
PJ_LOG(3,(THIS_FILE, " error: not expecting response!"));
887
test_complete = -132;
889
} else if (pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0) {
891
if (rdata->msg_info.msg->line.status.code!=TEST5_PROVISIONAL_CODE) {
892
PJ_LOG(3,(THIS_FILE, " error: incorrect status code!"));
893
test_complete = -133;
896
if (recv_count > TEST5_RESPONSE_COUNT) {
897
PJ_LOG(3,(THIS_FILE, " error: not expecting response!"));
898
test_complete = -134;
901
} else if (pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0) {
903
int code = rdata->msg_info.msg->line.status.code;
905
switch (recv_count) {
907
if (code != TEST6_PROVISIONAL_CODE) {
908
PJ_LOG(3,(THIS_FILE, " error: invalid code!"));
909
test_complete = -135;
914
if (code != TEST6_STATUS_CODE) {
915
PJ_LOG(3,(THIS_FILE, " error: invalid code %d "
916
"(expecting %d)", code, TEST6_STATUS_CODE));
917
test_complete = -136;
921
PJ_LOG(3,(THIS_FILE, " error: not expecting response"));
922
test_complete = -137;
930
} else if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0 ||
931
pj_strcmp2(&branch_param, TEST8_BRANCH_ID) == 0)
935
* TEST7_BRANCH_ID and TEST8_BRANCH_ID test the retransmission
936
* of INVITE final response
938
if (msg->type == PJSIP_REQUEST_MSG) {
940
/* On received request, create UAS. */
941
pjsip_transaction *tsx;
943
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
944
if (status != PJ_SUCCESS) {
945
app_perror(" error: unable to create transaction", status);
946
test_complete = -140;
950
pjsip_tsx_recv_msg(tsx, rdata);
953
if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0) {
955
send_response(rdata, tsx, TEST7_STATUS_CODE);
959
send_response(rdata, tsx, TEST8_STATUS_CODE);
968
if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0)
969
code = TEST7_STATUS_CODE;
971
code = TEST8_STATUS_CODE;
975
if (rdata->msg_info.msg->line.status.code != code) {
976
PJ_LOG(3,(THIS_FILE," error: invalid status code"));
977
test_complete = -141;
980
recv_last = rdata->pkt_info.timestamp;
985
unsigned msec, msec_expected;
987
now = rdata->pkt_info.timestamp;
989
PJ_TIME_VAL_SUB(now, recv_last);
991
msec = now.sec*1000 + now.msec;
992
msec_expected = (1 << (recv_count-2)) * pjsip_cfg()->tsx.t1;
993
if (msec_expected > pjsip_cfg()->tsx.t2)
994
msec_expected = pjsip_cfg()->tsx.t2;
996
if (DIFF(msec, msec_expected) > MAX_ALLOWED_DIFF) {
998
" error: incorrect retransmission "
999
"time (%d ms expected, %d ms received",
1000
msec_expected, msec));
1001
test_complete = -142;
1004
if (recv_count > 11) {
1005
PJ_LOG(3,(THIS_FILE," error: too many responses (%d)",
1007
test_complete = -143;
1010
recv_last = rdata->pkt_info.timestamp;
1016
} else if (pj_strcmp2(&branch_param, TEST9_BRANCH_ID) == 0) {
1019
* TEST9_BRANCH_ID tests that the retransmission of INVITE final
1020
* response should cease when ACK is received. Transaction also MUST
1021
* terminate in T4 seconds.
1023
if (msg->type == PJSIP_REQUEST_MSG) {
1025
/* On received request, create UAS. */
1026
pjsip_transaction *tsx;
1028
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
1029
if (status != PJ_SUCCESS) {
1030
app_perror(" error: unable to create transaction", status);
1031
test_complete = -150;
1035
pjsip_tsx_recv_msg(tsx, rdata);
1037
send_response(rdata, tsx, TEST9_STATUS_CODE);
1044
if (rdata->msg_info.msg->line.status.code != TEST9_STATUS_CODE) {
1045
PJ_LOG(3,(THIS_FILE," error: invalid status code"));
1046
test_complete = -151;
1049
if (recv_count==1) {
1051
recv_last = rdata->pkt_info.timestamp;
1053
} else if (recv_count < 5) {
1055
/* Let UAS retransmit some messages before we send ACK. */
1057
unsigned msec, msec_expected;
1059
now = rdata->pkt_info.timestamp;
1061
PJ_TIME_VAL_SUB(now, recv_last);
1063
msec = now.sec*1000 + now.msec;
1064
msec_expected = (1 << (recv_count-2)) * pjsip_cfg()->tsx.t1;
1065
if (msec_expected > pjsip_cfg()->tsx.t2)
1066
msec_expected = pjsip_cfg()->tsx.t2;
1068
if (DIFF(msec, msec_expected) > MAX_ALLOWED_DIFF) {
1069
PJ_LOG(3,(THIS_FILE,
1070
" error: incorrect retransmission "
1071
"time (%d ms expected, %d ms received",
1072
msec_expected, msec));
1073
test_complete = -152;
1076
recv_last = rdata->pkt_info.timestamp;
1078
} else if (recv_count == 5) {
1079
pjsip_tx_data *tdata;
1083
status = pjsip_endpt_create_request_from_hdr(
1084
endpt, &pjsip_ack_method,
1085
rdata->msg_info.to->uri,
1086
rdata->msg_info.from,
1089
rdata->msg_info.cid,
1090
rdata->msg_info.cseq->cseq,
1093
if (status != PJ_SUCCESS) {
1094
app_perror(" error: unable to create ACK", status);
1095
test_complete = -153;
1099
uri=(pjsip_sip_uri*)pjsip_uri_get_uri(tdata->msg->line.req.uri);
1100
uri->transport_param = pj_str("loop-dgram");
1102
via = (pjsip_via_hdr*) pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
1103
via->branch_param = pj_str(TEST9_BRANCH_ID);
1105
status = pjsip_endpt_send_request_stateless(endpt, tdata,
1107
if (status != PJ_SUCCESS) {
1108
app_perror(" error: unable to send ACK", status);
1109
test_complete = -154;
1113
PJ_LOG(3,(THIS_FILE," error: too many responses (%d)",
1115
test_complete = -155;
1121
} else if (pj_strcmp2(&branch_param, TEST10_BRANCH_ID) == 0 ||
1122
pj_strcmp2(&branch_param, TEST11_BRANCH_ID) == 0 ||
1123
pj_strcmp2(&branch_param, TEST12_BRANCH_ID) == 0)
1125
int test_num, code1, code2;
1127
if (pj_strcmp2(&branch_param, TEST10_BRANCH_ID) == 0)
1128
test_num=10, code1 = 100, code2 = 0;
1129
else if (pj_strcmp2(&branch_param, TEST11_BRANCH_ID) == 0)
1130
test_num=11, code1 = 100, code2 = 200;
1132
test_num=12, code1 = 200, code2 = 0;
1134
if (rdata->msg_info.msg->type == PJSIP_REQUEST_MSG) {
1136
/* On received response, create UAS. */
1137
pjsip_transaction *tsx;
1139
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
1140
if (status != PJ_SUCCESS) {
1141
app_perror(" error: unable to create transaction", status);
1142
test_complete = -150;
1146
pjsip_tsx_recv_msg(tsx, rdata);
1149
schedule_send_response(rdata, &tsx_key, code1, 1000);
1152
schedule_send_response(rdata, &tsx_key, code2, 2000);
1165
* The generic test framework, used by most of the tests.
1167
static int perform_test( char *target_uri, char *from_uri,
1168
char *branch_param, int test_time,
1169
const pjsip_method *method,
1170
int request_cnt, int request_interval_msec,
1171
int expecting_timeout)
1173
pjsip_tx_data *tdata;
1174
pj_str_t target, from;
1176
pj_time_val timeout, next_send;
1180
PJ_LOG(3,(THIS_FILE,
1181
" please standby, this will take at most %d seconds..",
1190
target = pj_str(target_uri);
1191
from = pj_str(from_uri);
1193
/* Create request. */
1194
status = pjsip_endpt_create_request( endpt, method, &target,
1195
&from, &target, NULL, NULL, -1,
1197
if (status != PJ_SUCCESS) {
1198
app_perror(" Error: unable to create request", status);
1202
/* Set the branch param for test 1. */
1203
via = (pjsip_via_hdr*) pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
1204
via->branch_param = pj_str(branch_param);
1206
/* Schedule first send. */
1208
pj_gettimeofday(&next_send);
1209
pj_time_val_normalize(&next_send);
1211
/* Set test completion time. */
1212
pj_gettimeofday(&timeout);
1213
timeout.sec += test_time;
1215
/* Wait until test complete. */
1216
while (!test_complete) {
1217
pj_time_val now, poll_delay = {0, 10};
1219
pjsip_endpt_handle_events(endpt, &poll_delay);
1221
pj_gettimeofday(&now);
1223
if (sent_cnt < request_cnt && PJ_TIME_VAL_GTE(now, next_send)) {
1224
/* Add additional reference to tdata to prevent transaction from
1227
pjsip_tx_data_add_ref(tdata);
1229
/* (Re)Send the request. */
1230
PJ_LOG(4,(THIS_FILE, " (re)sending request %d", sent_cnt));
1232
status = pjsip_endpt_send_request_stateless(endpt, tdata, 0, 0);
1233
if (status != PJ_SUCCESS) {
1234
app_perror(" Error: unable to send request", status);
1235
pjsip_tx_data_dec_ref(tdata);
1239
/* Schedule next send, if any. */
1241
if (sent_cnt < request_cnt) {
1242
pj_gettimeofday(&next_send);
1243
next_send.msec += request_interval_msec;
1244
pj_time_val_normalize(&next_send);
1248
if (now.sec > timeout.sec) {
1249
if (!expecting_timeout)
1250
PJ_LOG(3,(THIS_FILE, " Error: test has timed out"));
1251
pjsip_tx_data_dec_ref(tdata);
1252
return TEST_TIMEOUT_ERROR;
1256
if (test_complete < 0) {
1257
pjsip_transaction *tsx;
1259
tsx = pjsip_tsx_layer_find_tsx(&tsx_key, PJ_TRUE);
1261
pjsip_tsx_terminate(tsx, PJSIP_SC_REQUEST_TERMINATED);
1262
pj_mutex_unlock(tsx->mutex);
1265
pjsip_tx_data_dec_ref(tdata);
1266
return test_complete;
1269
/* Allow transaction to destroy itself */
1272
/* Make sure transaction has been destroyed. */
1273
if (pjsip_tsx_layer_find_tsx(&tsx_key, PJ_FALSE) != NULL) {
1274
PJ_LOG(3,(THIS_FILE, " Error: transaction has not been destroyed"));
1275
pjsip_tx_data_dec_ref(tdata);
1279
/* Check tdata reference counter. */
1280
if (pj_atomic_get(tdata->ref_cnt) != 1) {
1281
PJ_LOG(3,(THIS_FILE, " Error: tdata reference counter is %d",
1282
pj_atomic_get(tdata->ref_cnt)));
1283
pjsip_tx_data_dec_ref(tdata);
1287
/* Destroy txdata */
1288
pjsip_tx_data_dec_ref(tdata);
1295
/*****************************************************************************
1297
** TEST1_BRANCH_ID: Basic 2xx final response
1298
** TEST2_BRANCH_ID: Basic non-2xx final response
1300
*****************************************************************************
1302
static int tsx_basic_final_response_test(void)
1307
PJ_LOG(3,(THIS_FILE," test1: basic sending 2xx final response"));
1309
/* Test duration must be greater than 32 secs if unreliable transport
1312
duration = (tp_flag & PJSIP_TRANSPORT_RELIABLE) ? 1 : 33;
1314
status = perform_test(TARGET_URI, FROM_URI, TEST1_BRANCH_ID,
1315
duration, &pjsip_options_method, 1, 0, 0);
1319
PJ_LOG(3,(THIS_FILE," test2: basic sending non-2xx final response"));
1321
status = perform_test(TARGET_URI, FROM_URI, TEST2_BRANCH_ID,
1322
duration, &pjsip_options_method, 1, 0, 0);
1330
/*****************************************************************************
1332
** TEST3_BRANCH_ID: Sending provisional response
1334
*****************************************************************************
1336
static int tsx_basic_provisional_response_test(void)
1341
PJ_LOG(3,(THIS_FILE," test3: basic sending 2xx final response"));
1343
duration = (tp_flag & PJSIP_TRANSPORT_RELIABLE) ? 1 : 33;
1346
status = perform_test(TARGET_URI, FROM_URI, TEST3_BRANCH_ID, duration,
1347
&pjsip_options_method, 1, 0, 0);
1353
/*****************************************************************************
1355
** TEST4_BRANCH_ID: Absorbs retransmissions in TRYING state
1356
** TEST5_BRANCH_ID: Absorbs retransmissions in PROCEEDING state
1357
** TEST6_BRANCH_ID: Absorbs retransmissions in COMPLETED state
1359
*****************************************************************************
1361
static int tsx_retransmit_last_response_test(const char *title,
1368
PJ_LOG(3,(THIS_FILE," %s", title));
1370
status = perform_test(TARGET_URI, FROM_URI, branch_id, 5,
1371
&pjsip_options_method,
1372
request_cnt, 1000, 1);
1373
if (status && status != TEST_TIMEOUT_ERROR)
1376
PJ_LOG(3,(THIS_FILE, " error: expecting timeout"));
1380
terminate_our_tsx(status_code);
1383
if (test_complete != 1)
1384
return test_complete;
1390
/*****************************************************************************
1392
** TEST7_BRANCH_ID: INVITE non-2xx final response retransmission test
1393
** TEST8_BRANCH_ID: INVITE 2xx final response retransmission test
1395
*****************************************************************************
1397
static int tsx_final_response_retransmission_test(void)
1401
PJ_LOG(3,(THIS_FILE,
1402
" test7: INVITE non-2xx final response retransmission"));
1404
status = perform_test(TARGET_URI, FROM_URI, TEST7_BRANCH_ID,
1405
33, /* Test duration must be greater than 32 secs */
1406
&pjsip_invite_method, 1, 0, 0);
1410
PJ_LOG(3,(THIS_FILE,
1411
" test8: INVITE 2xx final response retransmission"));
1413
status = perform_test(TARGET_URI, FROM_URI, TEST8_BRANCH_ID,
1414
33, /* Test duration must be greater than 32 secs */
1415
&pjsip_invite_method, 1, 0, 0);
1423
/*****************************************************************************
1425
** TEST9_BRANCH_ID: retransmission of non-2xx INVITE final response must
1426
** cease when ACK is received
1428
*****************************************************************************
1430
static int tsx_ack_test(void)
1434
PJ_LOG(3,(THIS_FILE,
1435
" test9: receiving ACK for non-2xx final response"));
1437
status = perform_test(TARGET_URI, FROM_URI, TEST9_BRANCH_ID,
1438
20, /* allow 5 retransmissions */
1439
&pjsip_invite_method, 1, 0, 0);
1449
/*****************************************************************************
1451
** TEST10_BRANCH_ID: test transport failure in TRYING state.
1452
** TEST11_BRANCH_ID: test transport failure in PROCEEDING state.
1453
** TEST12_BRANCH_ID: test transport failure in CONNECTED state.
1454
** TEST13_BRANCH_ID: test transport failure in CONFIRMED state.
1456
*****************************************************************************
1458
static int tsx_transport_failure_test(void)
1462
int transport_delay;
1468
{ 0, 10, TEST10_BRANCH_ID, "test10: failed transport in TRYING state (no delay)" },
1469
{ 50, 10, TEST10_BRANCH_ID, "test10: failed transport in TRYING state (50 ms delay)" },
1470
{ 0, 1500, TEST11_BRANCH_ID, "test11: failed transport in PROCEEDING state (no delay)" },
1471
{ 50, 1500, TEST11_BRANCH_ID, "test11: failed transport in PROCEEDING state (50 ms delay)" },
1472
{ 0, 2500, TEST12_BRANCH_ID, "test12: failed transport in COMPLETED state (no delay)" },
1473
{ 50, 2500, TEST12_BRANCH_ID, "test12: failed transport in COMPLETED state (50 ms delay)" },
1477
for (i=0; i<(int)PJ_ARRAY_SIZE(tests); ++i) {
1478
pj_time_val fail_time, end_test, now;
1480
PJ_LOG(3,(THIS_FILE, " %s", tests[i].title));
1481
pjsip_loop_set_failure(loop, 0, NULL);
1482
pjsip_loop_set_delay(loop, tests[i].transport_delay);
1484
status = perform_test(TARGET_URI, FROM_URI, tests[i].branch_id,
1485
0, &pjsip_invite_method, 1, 0, 1);
1486
if (status && status != TEST_TIMEOUT_ERROR)
1489
PJ_LOG(3,(THIS_FILE, " error: expecting timeout"));
1493
pj_gettimeofday(&fail_time);
1494
fail_time.msec += tests[i].fail_delay;
1495
pj_time_val_normalize(&fail_time);
1498
pj_time_val interval = { 0, 1 };
1499
pj_gettimeofday(&now);
1500
pjsip_endpt_handle_events(endpt, &interval);
1501
} while (PJ_TIME_VAL_LT(now, fail_time));
1503
pjsip_loop_set_failure(loop, 1, NULL);
1509
pj_time_val interval = { 0, 1 };
1510
pj_gettimeofday(&now);
1511
pjsip_endpt_handle_events(endpt, &interval);
1512
} while (!test_complete && PJ_TIME_VAL_LT(now, end_test));
1514
if (test_complete == 0) {
1515
PJ_LOG(3,(THIS_FILE, " error: test has timed out"));
1519
if (test_complete != 1)
1520
return test_complete;
1526
/*****************************************************************************
1528
** UAS Transaction Test.
1530
*****************************************************************************
1532
int tsx_uas_test(struct tsx_test_param *param)
1534
pj_sockaddr_in addr;
1538
tp_flag = pjsip_transport_get_flag_from_type((pjsip_transport_type_e)param->type);
1540
pj_ansi_sprintf(TARGET_URI, "sip:bob@127.0.0.1:%d;transport=%s",
1541
param->port, param->tp_type);
1542
pj_ansi_sprintf(FROM_URI, "sip:alice@127.0.0.1:%d;transport=%s",
1543
param->port, param->tp_type);
1545
/* Check if loop transport is configured. */
1546
status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_LOOP_DGRAM,
1547
&addr, sizeof(addr), NULL, &loop);
1548
if (status != PJ_SUCCESS) {
1549
PJ_LOG(3,(THIS_FILE, " Error: loop transport is not configured!"));
1552
/* Register modules. */
1553
status = pjsip_endpt_register_module(endpt, &tsx_user);
1554
if (status != PJ_SUCCESS) {
1555
app_perror(" Error: unable to register module", status);
1558
status = pjsip_endpt_register_module(endpt, &msg_sender);
1559
if (status != PJ_SUCCESS) {
1560
app_perror(" Error: unable to register module", status);
1564
/* TEST1_BRANCH_ID: Basic 2xx final response.
1565
* TEST2_BRANCH_ID: Basic non-2xx final response.
1567
status = tsx_basic_final_response_test();
1571
/* TEST3_BRANCH_ID: with provisional response
1573
status = tsx_basic_provisional_response_test();
1577
/* TEST4_BRANCH_ID: absorbs retransmissions in TRYING state
1579
status = tsx_retransmit_last_response_test(TEST4_TITLE,
1581
TEST4_REQUEST_COUNT,
1586
/* TEST5_BRANCH_ID: retransmit last response in PROCEEDING state
1588
status = tsx_retransmit_last_response_test(TEST5_TITLE,
1590
TEST5_REQUEST_COUNT,
1595
/* TEST6_BRANCH_ID: retransmit last response in COMPLETED state
1596
* This only applies to non-reliable transports,
1597
* since UAS transaction is destroyed as soon
1598
* as final response is sent for reliable transports.
1600
if ((tp_flag & PJSIP_TRANSPORT_RELIABLE) == 0) {
1601
status = tsx_retransmit_last_response_test(TEST6_TITLE,
1603
TEST6_REQUEST_COUNT,
1609
/* TEST7_BRANCH_ID: INVITE non-2xx final response retransmission test
1610
* TEST8_BRANCH_ID: INVITE 2xx final response retransmission test
1612
status = tsx_final_response_retransmission_test();
1616
/* TEST9_BRANCH_ID: retransmission of non-2xx INVITE final response must
1617
* cease when ACK is received
1618
* Only applicable for non-reliable transports.
1620
if ((tp_flag & PJSIP_TRANSPORT_RELIABLE) == 0) {
1621
status = tsx_ack_test();
1627
/* TEST10_BRANCH_ID: test transport failure in TRYING state.
1628
* TEST11_BRANCH_ID: test transport failure in PROCEEDING state.
1629
* TEST12_BRANCH_ID: test transport failure in CONNECTED state.
1630
* TEST13_BRANCH_ID: test transport failure in CONFIRMED state.
1632
/* Only valid for loop-dgram */
1633
if (param->type == PJSIP_TRANSPORT_LOOP_DGRAM) {
1634
status = tsx_transport_failure_test();
1640
/* Register modules. */
1641
status = pjsip_endpt_unregister_module(endpt, &tsx_user);
1642
if (status != PJ_SUCCESS) {
1643
app_perror(" Error: unable to unregister module", status);
1646
status = pjsip_endpt_unregister_module(endpt, &msg_sender);
1647
if (status != PJ_SUCCESS) {
1648
app_perror(" Error: unable to unregister module", status);
1654
pjsip_transport_dec_ref(loop);