Changeset 5636 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
- Timestamp:
- Aug 2, 2017 2:51:59 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r5449 r5636 1298 1298 stun_resolve_add_ref(sess); 1299 1299 1300 ++sess->idx; 1301 if (sess->idx >= sess->count) 1302 sess->status = status; 1300 if (pjsua_var.ua_cfg.stun_try_ipv6 && sess->af == pj_AF_INET()) { 1301 sess->af = pj_AF_INET6(); 1302 } else { 1303 ++sess->idx; 1304 sess->af = pj_AF_INET(); 1305 if (sess->idx >= sess->count) 1306 sess->status = status; 1307 } 1303 1308 1304 1309 resolve_stun_entry(sess); … … 1340 1345 1341 1346 /* Loop while we have entry to try */ 1342 for (; sess->idx < sess->count; ++sess->idx) { 1347 for (; sess->idx < sess->count; 1348 (pjsua_var.ua_cfg.stun_try_ipv6 && sess->af == pj_AF_INET())? 1349 sess->af = pj_AF_INET6(): (++sess->idx, sess->af = pj_AF_INET())) 1350 { 1343 1351 int af; 1344 1352 char target[64]; … … 1359 1367 PJ_LOG(2,(THIS_FILE, "Invalid STUN server entry %s", target)); 1360 1368 continue; 1361 } else if (af != pj_AF_INET()) {1362 /* Ignore IPv6 STUN server for now */1363 status = PJ_EAFNOTSUP;1364 PJ_LOG(3,(THIS_FILE, "Ignored STUN server entry %s, currently "1365 "only IPv4 STUN server is supported (does "1366 "IPv6 still need a mapped address?)",1367 target));1368 continue;1369 1369 } 1370 1370 … … 1375 1375 pj_assert(sess->stun_sock == NULL); 1376 1376 1377 PJ_LOG(4,(THIS_FILE, "Trying STUN server %s (%d of %d)..", 1378 target, sess->idx+1, sess->count)); 1377 PJ_LOG(4,(THIS_FILE, "Trying STUN server %s %s (%d of %d)..", 1378 target, (sess->af == pj_AF_INET()? "IPv4": "IPv6"), 1379 sess->idx+1, sess->count)); 1379 1380 1380 1381 /* Use STUN_sock to test this entry */ … … 1383 1384 sess->async_wait = PJ_FALSE; 1384 1385 status = pj_stun_sock_create(&pjsua_var.stun_cfg, "stunresolve", 1385 pj_AF_INET(), &stun_sock_cb,1386 sess->af, &stun_sock_cb, 1386 1387 NULL, sess, &sess->stun_sock); 1387 1388 if (status != PJ_SUCCESS) { … … 1489 1490 sess->waiter = pj_thread_this(); 1490 1491 sess->status = PJ_EPENDING; 1492 sess->af = pj_AF_INET(); 1491 1493 sess->srv = (pj_str_t*) pj_pool_calloc(pool, count, sizeof(pj_str_t)); 1492 1494 for (i=0; i<count; ++i) { … … 2158 2160 pj_sockaddr_set_port(p_pub_addr, (pj_uint16_t)port); 2159 2161 2160 } else if (stun_srv.slen && af == pj_AF_INET()) { 2162 } else if (stun_srv.slen && 2163 (af == pj_AF_INET() || pjsua_var.ua_cfg.stun_try_ipv6)) 2164 { 2161 2165 pjstun_setting stun_opt; 2162 2166 2163 2167 /* 2164 2168 * STUN is specified, resolve the address with STUN. 2165 * Currently, this is available for IPv4 address only. 2169 * Currently, this is only to get IPv4 mapped address 2170 * (does IPv6 still need a mapped address?). 2166 2171 */ 2167 2172 pj_bzero(&stun_opt, sizeof(stun_opt)); 2168 2173 stun_opt.use_stun2 = pjsua_var.ua_cfg.stun_map_use_stun2; 2174 stun_opt.af = pjsua_var.stun_srv.addr.sa_family; 2169 2175 stun_opt.srv1 = stun_opt.srv2 = stun_srv; 2170 2176 stun_opt.port1 = stun_opt.port2 = 2171 pj_ ntohs(pjsua_var.stun_srv.ipv4.sin_port);2177 pj_sockaddr_get_port(&pjsua_var.stun_srv); 2172 2178 status = pjstun_get_mapped_addr2(&pjsua_var.cp.factory, &stun_opt, 2173 2179 1, &sock, &p_pub_addr->ipv4); … … 2895 2901 2896 2902 /* Make sure we have STUN */ 2897 if (pjsua_var.stun_srv. ipv4.sin_family == 0) {2903 if (pjsua_var.stun_srv.addr.sa_family == 0) { 2898 2904 pjsua_var.nat_status = PJNATH_ESTUNINSERVER; 2899 2905 return PJNATH_ESTUNINSERVER; 2900 2906 } 2901 2907 2902 status = pj_stun_detect_nat_type (&pjsua_var.stun_srv.ipv4,2903 &pjsua_var.stun_cfg,2904 NULL, &nat_detect_cb);2908 status = pj_stun_detect_nat_type2(&pjsua_var.stun_srv, 2909 &pjsua_var.stun_cfg, 2910 NULL, &nat_detect_cb); 2905 2911 2906 2912 if (status != PJ_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.