Changeset 5350 for pjproject/trunk/pjnath/src/pjnath-test/turn_sock_test.c
- Timestamp:
- Jun 21, 2016 6:55:10 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath-test/turn_sock_test.c
r3553 r5350 103 103 pj_stun_auth_cred cred; 104 104 pj_status_t status; 105 pj_bool_t use_ipv6 = cfg->srv.flags & SERVER_IPV6; 105 106 106 107 /* Create client */ … … 114 115 turn_sock_cb.on_rx_data = &turn_on_rx_data; 115 116 turn_sock_cb.on_state = &turn_on_state; 116 status = pj_turn_sock_create(sess->stun_cfg, pj_AF_INET(), PJ_TURN_TP_UDP, 117 &turn_sock_cb, 0, sess, &sess->turn_sock); 117 status = pj_turn_sock_create(sess->stun_cfg, 118 GET_AF(use_ipv6), 119 PJ_TURN_TP_UDP, 120 &turn_sock_cb, 121 0, 122 sess, 123 &sess->turn_sock); 118 124 if (status != PJ_SUCCESS) { 119 125 destroy_session(sess); … … 122 128 123 129 /* Create test server */ 124 status = create_test_server(sess->stun_cfg, cfg->srv.flags, 125 SRV_DOMAIN,&sess->test_srv);130 status = create_test_server(sess->stun_cfg, cfg->srv.flags, SRV_DOMAIN, 131 &sess->test_srv); 126 132 if (status != PJ_SUCCESS) { 127 133 destroy_session(sess); … … 140 146 141 147 } else { 142 pj_str_t dns_srv = pj_str("127.0.0.1");148 pj_str_t dns_srv = use_ipv6?pj_str("::1") : pj_str("127.0.0.1"); 143 149 pj_uint16_t dns_srv_port = (pj_uint16_t) DNS_SERVER_PORT; 144 150 status = pj_dns_resolver_set_ns(sess->resolver, 1, &dns_srv, &dns_srv_port); … … 171 177 } else { 172 178 /* Explicitly specify server address */ 173 pj_str_t host = pj_str("127.0.0.1");179 pj_str_t host = use_ipv6?pj_str("::1") : pj_str("127.0.0.1"); 174 180 status = pj_turn_sock_alloc(sess->turn_sock, &host, TURN_SERVER_PORT, 175 181 NULL, &cred, &alloc_param); … … 251 257 ///////////////////////////////////////////////////////////////////// 252 258 253 static int state_progression_test(pj_stun_config *stun_cfg) 259 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; 264 } 265 266 static int state_progression_test(pj_stun_config *stun_cfg, 267 pj_bool_t use_ipv6) 254 268 { 255 269 struct test_session_cfg test_cfg = 256 270 { 257 { /* Client cfg */ 258 /* DNS SRV */ /* Destroy on state */259 PJ_TRUE, 0xFFFF271 { /* Client cfg */ 272 PJ_TRUE, /* DNS SRV */ 273 0xFFFF /* Destroy on state */ 260 274 }, 261 275 { /* Server cfg */ … … 267 281 struct test_session *sess; 268 282 unsigned i; 269 int rc; 270 271 PJ_LOG(3,("", " state progression tests")); 272 283 int rc = 0; 284 285 PJ_LOG(3,("", " state progression tests - (%s)",use_ipv6?"IPv6":"IPv4")); 286 287 set_server_flag(&test_cfg, use_ipv6); 273 288 for (i=0; i<=1; ++i) { 274 289 enum { TIMEOUT = 60 }; … … 373 388 } 374 389 375 return 0; 390 if (use_ipv6) 391 rc = state_progression_test(stun_cfg, 0); 392 393 return rc; 376 394 } 377 395 … … 381 399 static int destroy_test(pj_stun_config *stun_cfg, 382 400 pj_bool_t with_dns_srv, 383 pj_bool_t in_callback) 401 pj_bool_t in_callback, 402 pj_bool_t use_ipv6) 384 403 { 385 404 struct test_session_cfg test_cfg = 386 405 { 387 { /* Client cfg */ 388 /* DNS SRV */ /* Destroy on state */389 PJ_TRUE, 0xFFFF406 { /* Client cfg */ 407 PJ_TRUE, /* DNS SRV */ 408 0xFFFF /* Destroy on state */ 390 409 }, 391 410 { /* Server cfg */ … … 405 424 406 425 test_cfg.client.enable_dns_srv = with_dns_srv; 426 set_server_flag(&test_cfg, use_ipv6); 407 427 408 428 for (target_state=PJ_TURN_STATE_RESOLVING; target_state<=PJ_TURN_STATE_READY; ++target_state) { … … 496 516 } 497 517 498 rc = state_progression_test(&stun_cfg );518 rc = state_progression_test(&stun_cfg, USE_IPV6); 499 519 if (rc != 0) 500 520 goto on_return; … … 503 523 int j; 504 524 for (j=0; j<=1; ++j) { 505 rc = destroy_test(&stun_cfg, i, j );525 rc = destroy_test(&stun_cfg, i, j, USE_IPV6); 506 526 if (rc != 0) 507 527 goto on_return;
Note: See TracChangeset
for help on using the changeset viewer.