Changeset 6004 for pjproject/trunk/pjnath/src/pjnath-test/turn_sock_test.c
- Timestamp:
- May 24, 2019 3:32:17 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath-test/turn_sock_test.c
r5350 r6004 91 91 } 92 92 93 93 pj_turn_tp_type get_turn_tp_type(pj_uint32_t flag) { 94 if (flag & TURN_TCP) { 95 return PJ_TURN_TP_TCP; 96 } else if (flag & TURN_TLS) { 97 return PJ_TURN_TP_TLS; 98 } 99 return PJ_TURN_TP_UDP; 100 } 94 101 95 102 static int create_test_session(pj_stun_config *stun_cfg, … … 104 111 pj_status_t status; 105 112 pj_bool_t use_ipv6 = cfg->srv.flags & SERVER_IPV6; 113 pj_turn_tp_type tp_type = get_turn_tp_type(cfg->srv.flags); 106 114 107 115 /* Create client */ … … 117 125 status = pj_turn_sock_create(sess->stun_cfg, 118 126 GET_AF(use_ipv6), 119 PJ_TURN_TP_UDP,127 tp_type, 120 128 &turn_sock_cb, 121 129 0, … … 258 266 259 267 static void set_server_flag(struct test_session_cfg *test_cfg, 260 pj_bool_t use_ipv6) 261 { 262 test_cfg->srv.flags &= ~(SERVER_IPV4+SERVER_IPV6); 263 test_cfg->srv.flags |= (use_ipv6)?SERVER_IPV6:SERVER_IPV4; 268 pj_bool_t use_ipv6, 269 pj_turn_tp_type tp_type) 270 { 271 pj_uint32_t flag = TURN_UDP; 272 test_cfg->srv.flags &= ~(SERVER_IPV4+SERVER_IPV6+ 273 TURN_UDP+TURN_TCP+TURN_TLS); 274 switch (tp_type) { 275 case PJ_TURN_TP_TCP: 276 flag = TURN_TCP; 277 break; 278 case PJ_TURN_TP_TLS: 279 flag = TURN_TLS; 280 } 281 test_cfg->srv.flags |= ((use_ipv6)?SERVER_IPV6:SERVER_IPV4)+flag; 264 282 } 265 283 266 284 static int state_progression_test(pj_stun_config *stun_cfg, 267 pj_bool_t use_ipv6) 285 pj_bool_t use_ipv6, 286 pj_turn_tp_type tp_type) 268 287 { 269 288 struct test_session_cfg test_cfg = … … 283 302 int rc = 0; 284 303 285 PJ_LOG(3,("", " state progression tests - (%s)",use_ipv6?"IPv6":"IPv4")); 304 PJ_LOG(3,("", " state progression tests - (%s) (%s)", 305 use_ipv6?"IPv6":"IPv4", 306 (tp_type==PJ_TURN_TP_UDP)?"UDP": 307 (tp_type==PJ_TURN_TP_TCP)?"TCP":"TLS")); 286 308 287 set_server_flag(&test_cfg, use_ipv6 );309 set_server_flag(&test_cfg, use_ipv6, tp_type); 288 310 for (i=0; i<=1; ++i) { 289 311 enum { TIMEOUT = 60 }; … … 312 334 313 335 poll_events(stun_cfg, 10, PJ_FALSE); 336 if (sess->turn_sock == NULL) { 337 break; 338 } 314 339 rc = pj_turn_sock_get_info(sess->turn_sock, &info); 315 340 if (rc!=PJ_SUCCESS) … … 389 414 390 415 if (use_ipv6) 391 rc = state_progression_test(stun_cfg, 0 );416 rc = state_progression_test(stun_cfg, 0, tp_type); 392 417 393 418 return rc; … … 400 425 pj_bool_t with_dns_srv, 401 426 pj_bool_t in_callback, 402 pj_bool_t use_ipv6) 427 pj_bool_t use_ipv6, 428 pj_turn_tp_type tp_type) 403 429 { 404 430 struct test_session_cfg test_cfg = … … 418 444 int rc; 419 445 420 PJ_LOG(3,("", " destroy test %s %s ",446 PJ_LOG(3,("", " destroy test %s %s (%s)", 421 447 (in_callback? "in callback" : ""), 422 (with_dns_srv? "with DNS srv" : "") 423 )); 448 (with_dns_srv? "with DNS srv" : ""), 449 (tp_type==PJ_TURN_TP_UDP)?"UDP": 450 (tp_type==PJ_TURN_TP_TCP)?"TCP":"TLS")); 424 451 425 452 test_cfg.client.enable_dns_srv = with_dns_srv; 426 set_server_flag(&test_cfg, use_ipv6 );453 set_server_flag(&test_cfg, use_ipv6, tp_type); 427 454 428 455 for (target_state=PJ_TURN_STATE_RESOLVING; target_state<=PJ_TURN_STATE_READY; ++target_state) { … … 507 534 pj_pool_t *pool; 508 535 pj_stun_config stun_cfg; 509 int i, rc = 0;536 int n, i, rc = 0; 510 537 511 538 pool = pj_pool_create(mem, "turntest", 512, 512, NULL); … … 516 543 } 517 544 518 rc = state_progression_test(&stun_cfg, USE_IPV6); 519 if (rc != 0) 520 goto on_return; 521 522 for (i=0; i<=1; ++i) { 523 int j; 524 for (j=0; j<=1; ++j) { 525 rc = destroy_test(&stun_cfg, i, j, USE_IPV6); 526 if (rc != 0) 527 goto on_return; 545 for (n = 0; n <= 2; ++n) { 546 pj_turn_tp_type tp_type = PJ_TURN_TP_UDP; 547 548 if ((n == 2) && !USE_TLS) 549 break; 550 551 switch (n) { 552 case 1: 553 tp_type = PJ_TURN_TP_TCP; 554 break; 555 case 2: 556 tp_type = PJ_TURN_TP_TLS; 557 } 558 559 rc = state_progression_test(&stun_cfg, USE_IPV6, tp_type); 560 if (rc != 0) 561 goto on_return; 562 563 for (i=0; i<=1; ++i) { 564 int j; 565 for (j=0; j<=1; ++j) { 566 rc = destroy_test(&stun_cfg, i, j, USE_IPV6, tp_type); 567 if (rc != 0) 568 goto on_return; 569 } 528 570 } 529 571 }
Note: See TracChangeset
for help on using the changeset viewer.