Changeset 5636
- Timestamp:
- Aug 2, 2017 2:51:59 AM (7 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/include/pjlib-util/stun_simple.h
r4224 r5636 211 211 */ 212 212 pj_bool_t use_stun2; 213 214 /** 215 * Address family of the STUN servers. 216 */ 217 int af; 213 218 214 219 /** -
pjproject/trunk/pjlib-util/src/pjlib-util/stun_simple_client.c
r5311 r5636 64 64 const pj_str_t *srv1, *srv2; 65 65 int port1, port2; 66 pj_sockaddr _insrv_addr[2];66 pj_sockaddr srv_addr[2]; 67 67 int i, send_cnt = 0, nfds; 68 68 pj_pool_t *pool; … … 117 117 118 118 /* Resolve servers. */ 119 status = pj_sockaddr_in _init(&srv_addr[0], srv1, (pj_uint16_t)port1);119 status = pj_sockaddr_init(opt->af, &srv_addr[0], srv1, (pj_uint16_t)port1); 120 120 if (status != PJ_SUCCESS) 121 121 goto on_error; … … 124 124 125 125 if (srv2 && port2) { 126 status = pj_sockaddr_in_init(&srv_addr[1], srv2, (pj_uint16_t)port2); 126 status = pj_sockaddr_init(opt->af, &srv_addr[1], srv2, 127 (pj_uint16_t)port2); 127 128 if (status != PJ_SUCCESS) 128 129 goto on_error; 129 130 130 if (srv_addr[1].sin_addr.s_addr != srv_addr[0].sin_addr.s_addr && 131 srv_addr[1].sin_port != srv_addr[0].sin_port) 132 { 131 if (pj_sockaddr_cmp(&srv_addr[1], &srv_addr[0]) != 0) { 133 132 srv_cnt++; 134 133 } … … 182 181 status = pj_sock_sendto(sock[i], out_msg, &sent_len, 0, 183 182 (pj_sockaddr_t*)&srv_addr[j], 184 sizeof(pj_sockaddr_in));183 pj_sockaddr_get_len(&srv_addr[j])); 185 184 } 186 185 } … … 222 221 pj_ssize_t len; 223 222 pjstun_msg msg; 224 pj_sockaddr _inaddr;223 pj_sockaddr addr; 225 224 int addrlen = sizeof(addr); 226 225 pjstun_mapped_addr_attr *attr; -
pjproject/trunk/pjlib/include/pj/sock.h
r5444 r5636 934 934 PJ_DECL(void) pj_sockaddr_cp(pj_sockaddr_t *dst, const pj_sockaddr_t *src); 935 935 936 /* 937 * If the source's and desired address family matches, copy the address, 938 * otherwise synthesize a new address with the desired address family, 939 * from the source address. This can be useful to generate an IPv4-mapped 940 * IPv6 address. 941 * 942 * @param dst_af Desired address family. 943 * @param dst Destination socket address, invalid if synthesis is 944 * required and failed. 945 * @param src Source socket address. 946 * 947 * @return PJ_SUCCESS on success, or the error status 948 * if synthesis is required and failed. 949 */ 950 PJ_DECL(pj_status_t) pj_sockaddr_synthesize(int dst_af, 951 pj_sockaddr_t *dst, 952 const pj_sockaddr_t *src); 953 936 954 /** 937 955 * Get the IP address of an IPv4 socket address. -
pjproject/trunk/pjlib/src/pj/sock_common.c
r5627 r5636 414 414 { 415 415 pj_memcpy(dst, src, pj_sockaddr_get_len(src)); 416 } 417 418 /* 419 * Synthesize address. 420 */ 421 PJ_DEF(pj_status_t) pj_sockaddr_synthesize(int dst_af, 422 pj_sockaddr_t *dst, 423 const pj_sockaddr_t *src) 424 { 425 char ip_addr_buf[PJ_INET6_ADDRSTRLEN]; 426 unsigned int count = 1; 427 pj_addrinfo ai[1]; 428 pj_str_t ip_addr; 429 pj_status_t status; 430 431 /* Validate arguments */ 432 PJ_ASSERT_RETURN(src && dst, PJ_EINVAL); 433 434 if (dst_af == ((const pj_sockaddr *)src)->addr.sa_family) { 435 pj_sockaddr_cp(dst, src); 436 return PJ_SUCCESS; 437 } 438 439 pj_sockaddr_print(src, ip_addr_buf, sizeof(ip_addr_buf), 0); 440 ip_addr = pj_str(ip_addr_buf); 441 442 /* Try to synthesize address using pj_getaddrinfo(). */ 443 status = pj_getaddrinfo(dst_af, &ip_addr, &count, ai); 444 if (status == PJ_SUCCESS && count > 0) { 445 pj_sockaddr_cp(dst, &ai[0].ai_addr); 446 pj_sockaddr_set_port(dst, pj_sockaddr_get_port(src)); 447 } 448 449 return status; 416 450 } 417 451 -
pjproject/trunk/pjmedia/src/pjmedia/transport_udp.c
r5597 r5636 653 653 struct transport_udp *udp = (struct transport_udp*) tp; 654 654 const pj_sockaddr *rtcp_addr; 655 pj_sockaddr sock_addr, remote_addr, remote_rtcp; 656 int rem_addr_len; 657 pj_status_t status; 655 658 656 659 /* Validate arguments */ … … 668 671 /* "Attach" the application: */ 669 672 673 rem_addr_len = sizeof(pj_sockaddr); 674 pj_sock_getsockname(udp->rtp_sock, &sock_addr, &rem_addr_len); 675 676 /* Synthesize address, if necessary. */ 677 status = pj_sockaddr_synthesize(sock_addr.addr.sa_family, 678 &remote_addr, rem_addr); 679 if (status != PJ_SUCCESS) { 680 pj_perror(3, tp->name, status, "Failed to synthesize the correct" 681 "IP address for RTP"); 682 } 683 rem_addr_len = pj_sockaddr_get_len(&remote_addr); 684 670 685 /* Copy remote RTP address */ 671 pj_memcpy(&udp->rem_rtp_addr, rem_addr,addr_len);686 pj_memcpy(&udp->rem_rtp_addr, &remote_addr, rem_addr_len); 672 687 673 688 /* Copy remote RTP address, if one is specified. */ 674 689 rtcp_addr = (const pj_sockaddr*) rem_rtcp; 675 690 if (rtcp_addr && pj_sockaddr_has_addr(rtcp_addr)) { 676 pj_memcpy(&udp->rem_rtcp_addr, rem_rtcp, addr_len); 691 pj_status_t status; 692 693 status = pj_sockaddr_synthesize(sock_addr.addr.sa_family, 694 &remote_rtcp, rem_rtcp); 695 if (status != PJ_SUCCESS) { 696 pj_perror(3, tp->name, status, "Failed to synthesize the correct" 697 "IP address for RTCP"); 698 } 699 pj_memcpy(&udp->rem_rtcp_addr, &remote_rtcp, rem_addr_len); 677 700 678 701 } else { … … 680 703 681 704 /* Otherwise guess the RTCP address from the RTP address */ 682 pj_memcpy(&udp->rem_rtcp_addr, rem_addr,addr_len);705 pj_memcpy(&udp->rem_rtcp_addr, &udp->rem_rtp_addr, rem_addr_len); 683 706 rtcp_port = pj_sockaddr_get_port(&udp->rem_rtp_addr) + 1; 684 707 pj_sockaddr_set_port(&udp->rem_rtcp_addr, (pj_uint16_t)rtcp_port); … … 691 714 692 715 /* Save address length */ 693 udp->addr_len = addr_len;716 udp->addr_len = rem_addr_len; 694 717 695 718 /* Last, mark transport as attached */ -
pjproject/trunk/pjnath/src/pjnath/ice_session.c
r5534 r5636 2186 2186 pj_ice_sess_checklist *clist; 2187 2187 pj_stun_xor_mapped_addr_attr *xaddr; 2188 const pj_sockaddr_t *source_addr = src_addr; 2188 2189 unsigned i; 2189 2190 … … 2287 2288 * Request was sent from. 2288 2289 */ 2289 if (pj_sockaddr_cmp(&check->rcand->addr, (const pj_sockaddr*)src_addr)!=0) 2290 if (check->rcand->addr.addr.sa_family == pj_AF_INET() && 2291 ((pj_sockaddr *)src_addr)->addr.sa_family == pj_AF_INET6()) 2290 2292 { 2293 /* If the address family is different, we need to check 2294 * whether the two addresses are equivalent (i.e. the IPv6 2295 * is synthesized from IPv4). 2296 */ 2297 pj_sockaddr synth_addr; 2298 pj_status_t status; 2299 2300 status = pj_sockaddr_synthesize(pj_AF_INET6(), &synth_addr, 2301 &check->rcand->addr); 2302 if (status == PJ_SUCCESS && 2303 pj_sockaddr_cmp(&synth_addr, src_addr) == 0) 2304 { 2305 source_addr = &check->rcand->addr; 2306 } 2307 } 2308 2309 if (pj_sockaddr_cmp(&check->rcand->addr, source_addr) != 0) { 2291 2310 status = PJNATH_EICEINSRCADDR; 2292 2311 LOG4((ice->obj_name, … … 2475 2494 pj_stun_tx_data *tdata; 2476 2495 pj_ice_rx_check *rcheck, tmp_rcheck; 2496 const pj_sockaddr_t *source_addr = src_addr; 2497 unsigned source_addr_len = src_addr_len; 2477 2498 pj_status_t status; 2478 2499 … … 2588 2609 } 2589 2610 2611 if (((pj_sockaddr *)src_addr)->addr.sa_family == pj_AF_INET6()) { 2612 unsigned i; 2613 unsigned transport_id = ((pj_ice_msg_data*)token)->transport_id; 2614 pj_ice_sess_cand *lcand = NULL; 2615 2616 for (i = 0; i < ice->clist.count; ++i) { 2617 pj_ice_sess_check *c = &ice->clist.checks[i]; 2618 if (c->lcand->comp_id == sd->comp_id && 2619 c->lcand->transport_id == transport_id) 2620 { 2621 lcand = c->lcand; 2622 break; 2623 } 2624 } 2625 2626 if (lcand != NULL && lcand->addr.addr.sa_family == pj_AF_INET()) { 2627 /* We are behind NAT64, so src_addr is a synthesized IPv6 2628 * address. Instead of putting this synth IPv6 address as 2629 * the XOR-MAPPED-ADDRESS, we need to find its original 2630 * IPv4 address. 2631 */ 2632 for (i = 0; i < ice->rcand_cnt; ++i) { 2633 pj_status_t status; 2634 pj_sockaddr synth_addr; 2635 2636 if (ice->rcand[i].addr.addr.sa_family != pj_AF_INET()) 2637 continue; 2638 2639 status = pj_sockaddr_synthesize(pj_AF_INET6(), &synth_addr, 2640 &ice->rcand[i].addr); 2641 if (status == PJ_SUCCESS && 2642 pj_sockaddr_cmp(src_addr, &synth_addr) == 0) 2643 { 2644 /* We find the original IPv4 address. */ 2645 source_addr = &ice->rcand[i].addr; 2646 source_addr_len = pj_sockaddr_get_len(source_addr); 2647 break; 2648 } 2649 } 2650 } 2651 } 2652 2653 2590 2654 /* Add XOR-MAPPED-ADDRESS attribute */ 2591 2655 status = pj_stun_msg_add_sockaddr_attr(tdata->pool, tdata->msg, 2592 2656 PJ_STUN_ATTR_XOR_MAPPED_ADDR, 2593 PJ_TRUE, src_addr, src_addr_len); 2657 PJ_TRUE, source_addr, 2658 source_addr_len); 2594 2659 2595 2660 /* Create a msg_data to be associated with this response */ … … 2620 2685 rcheck->comp_id = sd->comp_id; 2621 2686 rcheck->transport_id = ((pj_ice_msg_data*)token)->transport_id; 2622 rcheck->src_addr_len = s rc_addr_len;2623 pj_sockaddr_cp(&rcheck->src_addr, s rc_addr);2687 rcheck->src_addr_len = source_addr_len; 2688 pj_sockaddr_cp(&rcheck->src_addr, source_addr); 2624 2689 rcheck->use_candidate = (uc_attr != NULL); 2625 2690 rcheck->priority = prio_attr->value; -
pjproject/trunk/pjnath/src/pjnath/ice_strans.c
r5604 r5636 168 168 unsigned cand_cnt; /**< # of candidates/aliaes. */ 169 169 pj_ice_sess_cand cand_list[PJ_ICE_ST_MAX_CAND]; /**< Cand array */ 170 171 pj_bool_t ipv4_mapped; /**< Is IPv6 addr mapped to IPv4?*/ 172 pj_sockaddr dst_addr; /**< Destination address */ 173 pj_sockaddr synth_addr; /**< Synthesized dest address */ 174 unsigned synth_addr_len;/**< Synthesized dest addr len */ 170 175 171 176 unsigned default_cand; /**< Default candidate. */ … … 655 660 */ 656 661 if (comp->ice_st->cfg.af != pj_AF_UNSPEC() && 657 comp->cand_list[comp->default_cand].addr.addr.sa_family != 662 addr->addr.sa_family == comp->ice_st->cfg.af && 663 comp->cand_list[comp->default_cand].base_addr.addr.sa_family != 658 664 ice_st->cfg.af) 659 665 { … … 1134 1140 /* Must have address */ 1135 1141 pj_assert(pj_sockaddr_has_addr(&cand->addr)); 1142 1143 /* Skip if we are mapped to IPv4 address and this candidate 1144 * is not IPv4. 1145 */ 1146 if (comp->ipv4_mapped && 1147 cand->addr.addr.sa_family != pj_AF_INET()) 1148 { 1149 continue; 1150 } 1136 1151 1137 1152 /* Add the candidate */ … … 1501 1516 PJ_SUCCESS : status; 1502 1517 } else { 1518 const pj_sockaddr_t *dest_addr; 1519 unsigned dest_addr_len; 1520 1521 if (comp->ipv4_mapped) { 1522 if (comp->synth_addr_len == 0 || 1523 pj_sockaddr_cmp(&comp->dst_addr, dst_addr) != 0) 1524 { 1525 status = pj_sockaddr_synthesize(pj_AF_INET6(), 1526 &comp->synth_addr, 1527 dst_addr); 1528 if (status != PJ_SUCCESS) 1529 return status; 1530 1531 pj_sockaddr_cp(&comp->dst_addr, dst_addr); 1532 comp->synth_addr_len = pj_sockaddr_get_len( 1533 &comp->synth_addr); 1534 } 1535 dest_addr = &comp->synth_addr; 1536 dest_addr_len = comp->synth_addr_len; 1537 } else { 1538 dest_addr = dst_addr; 1539 dest_addr_len = dst_addr_len; 1540 } 1541 1503 1542 status = pj_stun_sock_sendto(comp->stun[tp_idx].sock, NULL, data, 1504 (unsigned)data_len, 0, d st_addr,1505 d st_addr_len);1543 (unsigned)data_len, 0, dest_addr, 1544 dest_addr_len); 1506 1545 return (status==PJ_SUCCESS||status==PJ_EPENDING) ? 1507 1546 PJ_SUCCESS : status; … … 1650 1689 } 1651 1690 } else if (tp_typ == TP_STUN) { 1691 const pj_sockaddr_t *dest_addr; 1692 unsigned dest_addr_len; 1693 1694 if (comp->ipv4_mapped) { 1695 if (comp->synth_addr_len == 0 || 1696 pj_sockaddr_cmp(&comp->dst_addr, dst_addr) != 0) 1697 { 1698 status = pj_sockaddr_synthesize(pj_AF_INET6(), 1699 &comp->synth_addr, dst_addr); 1700 if (status != PJ_SUCCESS) 1701 return status; 1702 1703 pj_sockaddr_cp(&comp->dst_addr, dst_addr); 1704 comp->synth_addr_len = pj_sockaddr_get_len(&comp->synth_addr); 1705 } 1706 dest_addr = &comp->synth_addr; 1707 dest_addr_len = comp->synth_addr_len; 1708 } else { 1709 dest_addr = dst_addr; 1710 dest_addr_len = dst_addr_len; 1711 } 1712 1652 1713 status = pj_stun_sock_sendto(comp->stun[tp_idx].sock, NULL, 1653 1714 pkt, (unsigned)size, 0, 1654 d st_addr, dst_addr_len);1715 dest_addr, dest_addr_len); 1655 1716 } else { 1656 1717 pj_assert(!"Invalid transport ID"); … … 1820 1881 pj_bool_t dup = PJ_FALSE; 1821 1882 1883 if (info.mapped_addr.addr.sa_family == pj_AF_INET() && 1884 cand->base_addr.addr.sa_family == pj_AF_INET6()) 1885 { 1886 /* We get an IPv4 mapped address for our IPv6 1887 * host address. 1888 */ 1889 comp->ipv4_mapped = PJ_TRUE; 1890 1891 /* Find other host candidates with the same (IPv6) 1892 * address, and replace it with the new (IPv4) 1893 * mapped address. 1894 */ 1895 for (i = 0; i < comp->cand_cnt; ++i) { 1896 pj_sockaddr *a1, *a2; 1897 1898 if (comp->cand_list[i].type != PJ_ICE_CAND_TYPE_HOST) 1899 continue; 1900 1901 a1 = &comp->cand_list[i].addr; 1902 a2 = &cand->base_addr; 1903 if (pj_memcmp(pj_sockaddr_get_addr(a1), 1904 pj_sockaddr_get_addr(a2), 1905 pj_sockaddr_get_addr_len(a1)) == 0) 1906 { 1907 pj_uint16_t port = pj_sockaddr_get_port(a1); 1908 pj_sockaddr_cp(a1, &info.mapped_addr); 1909 if (port != pj_sockaddr_get_port(a2)) 1910 pj_sockaddr_set_port(a1, port); 1911 pj_sockaddr_cp(&comp->cand_list[i].base_addr, a1); 1912 } 1913 } 1914 pj_sockaddr_cp(&cand->base_addr, &info.mapped_addr); 1915 pj_sockaddr_cp(&cand->rel_addr, &info.mapped_addr); 1916 } 1917 1822 1918 /* Eliminate the srflx candidate if the address is 1823 1919 * equal to other (host) candidates. -
pjproject/trunk/pjnath/src/pjnath/nat_detect.c
r5523 r5636 89 89 pj_sockaddr server; 90 90 pj_sockaddr *cur_server; 91 pj_sockaddr cur_addr; 91 92 pj_stun_session *stun_sess; 92 93 … … 855 856 goto on_error; 856 857 857 /* Configure alternate address */ 858 if (alt_addr) 859 sess->cur_server = (pj_sockaddr*) alt_addr; 860 else 858 /* Configure alternate address, synthesize it if necessary */ 859 if (alt_addr) { 860 status = pj_sockaddr_synthesize(sess->server.addr.sa_family, 861 &sess->cur_addr, alt_addr); 862 if (status != PJ_SUCCESS) 863 goto on_error; 864 865 sess->cur_server = &sess->cur_addr; 866 } else { 861 867 sess->cur_server = &sess->server; 868 } 862 869 863 870 PJ_LOG(5,(sess->pool->obj_name, -
pjproject/trunk/pjnath/src/pjnath/turn_session.c
r5635 r5636 678 678 pj_memcpy(addr, &ai[i].ai_addr, sizeof(pj_sockaddr)); 679 679 addr->addr.sa_family = sess->af; 680 addr->ipv4.sin_port = pj_htons(sess->default_port);680 pj_sockaddr_set_port(addr, sess->default_port); 681 681 } 682 682 -
pjproject/trunk/pjsip-apps/src/swig/symbols.i
r5518 r5636 154 154 typedef enum pjsua_ipv6_use {PJSUA_IPV6_DISABLED, PJSUA_IPV6_ENABLED} pjsua_ipv6_use; 155 155 156 typedef enum pjsua_nat64_opt {PJSUA_NAT64_DISABLED, PJSUA_NAT64_ENABLED} pjsua_nat64_opt; 157 156 158 typedef enum pjsua_buddy_status {PJSUA_BUDDY_STATUS_UNKNOWN, PJSUA_BUDDY_STATUS_ONLINE, PJSUA_BUDDY_STATUS_OFFLINE} pjsua_buddy_status; 157 159 -
pjproject/trunk/pjsip-apps/src/swig/symbols.lst
r5518 r5636 34 34 pjsip-ua/sip_inv.h pjsip_inv_state 35 35 36 pjsua-lib/pjsua.h pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_ buddy_status pjsua_call_media_status pjsua_vid_win_id pjsua_call_id pjsua_med_tp_st pjsua_call_vid_strm_op pjsua_vid_req_keyframe_method pjsua_call_flag pjsua_create_media_transport_flag pjsua_snd_dev_mode36 pjsua-lib/pjsua.h pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_nat64_opt pjsua_buddy_status pjsua_call_media_status pjsua_vid_win_id pjsua_call_id pjsua_med_tp_st pjsua_call_vid_strm_op pjsua_vid_req_keyframe_method pjsua_call_flag pjsua_create_media_transport_flag pjsua_snd_dev_mode -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r5597 r5636 1596 1596 1597 1597 /** 1598 * This specifies if the library should try to do an IPv6 resolution of 1599 * the STUN servers if the IPv4 resolution fails. It can be useful 1600 * in an IPv6-only environment, including on NAT64. 1601 * 1602 * Default: PJ_FALSE 1603 */ 1604 pj_bool_t stun_try_ipv6; 1605 1606 /** 1598 1607 * This specifies if the library should ignore failure with the 1599 1608 * STUN servers. If this is set to PJ_FALSE, the library will refuse to … … 2911 2920 2912 2921 /** 2922 * Specify NAT64 options to be used in account config. 2923 */ 2924 typedef enum pjsua_nat64_opt 2925 { 2926 /** 2927 * NAT64 is not used. 2928 */ 2929 PJSUA_NAT64_DISABLED, 2930 2931 /** 2932 * NAT64 is enabled. 2933 */ 2934 PJSUA_NAT64_ENABLED 2935 2936 } pjsua_nat64_opt; 2937 2938 /** 2913 2939 * This structure describes account configuration to be specified when 2914 2940 * adding a new account with #pjsua_acc_add(). Application MUST initialize … … 3346 3372 */ 3347 3373 pjsua_transport_config rtp_cfg; 3374 3375 /** 3376 * Specify NAT64 options. 3377 * 3378 * Default: PJSUA_NAT64_DISABLED 3379 */ 3380 pjsua_nat64_opt nat64_opt; 3348 3381 3349 3382 /** -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r5442 r5636 375 375 pj_sockaddr addr; /**< Result */ 376 376 pj_stun_sock *stun_sock; /**< Testing STUN sock */ 377 int af; /**< Address family */ 377 378 pj_bool_t async_wait;/**< Async resolution 378 379 of STUN entry */ -
pjproject/trunk/pjsip/include/pjsua2/account.hpp
r5455 r5636 470 470 471 471 /** 472 * Specify NAT64 options. 473 * 474 * Default: PJSUA_NAT64_DISABLED 475 */ 476 pjsua_nat64_opt nat64Opt; 477 478 /** 472 479 * Enable ICE for the media transport. 473 480 * -
pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp
r5522 r5636 391 391 StringVector stunServer; 392 392 393 /** 394 * This specifies if the library should try to do an IPv6 resolution of 395 * the STUN servers if the IPv4 resolution fails. It can be useful 396 * in an IPv6-only environment, including on NAT64. 397 * 398 * Default: FALSE 399 */ 400 401 bool stunTryIpv6; 393 402 /** 394 403 * This specifies if the library startup should ignore failure with the -
pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
r5519 r5636 701 701 pj_pool_t *pool; 702 702 struct udp_transport *tp; 703 const char *format, *ipv6_quoteb , *ipv6_quotee;703 const char *format, *ipv6_quoteb = "", *ipv6_quotee = ""; 704 704 unsigned i; 705 705 pj_status_t status; … … 710 710 /* Object name. */ 711 711 if (type & PJSIP_TRANSPORT_IPV6) { 712 pj_in6_addr dummy6; 713 712 714 format = "udpv6%p"; 713 ipv6_quoteb = "["; 714 ipv6_quotee = "]"; 715 /* We don't need to add quote if the transport type is IPv6, but 716 * actually translated to IPv4. 717 */ 718 if (pj_inet_pton(pj_AF_INET6(), &a_name->host, &dummy6)==PJ_SUCCESS) { 719 ipv6_quoteb = "["; 720 ipv6_quotee = "]"; 721 } 715 722 } else { 716 723 format = "udp%p"; 717 ipv6_quoteb = ipv6_quotee = "";718 724 } 719 725 -
pjproject/trunk/pjsip/src/pjsip/sip_util.c
r5555 r5636 1220 1220 */ 1221 1221 if (tdata->via_addr.host.slen > 0 && 1222 (tdata->via_tp == (void *)stateless_data->cur_transport || 1222 (!tdata->via_tp || 1223 tdata->via_tp == (void *)stateless_data->cur_transport || 1223 1224 tdata->msg->line.req.method.id == PJSIP_CANCEL_METHOD)) 1224 1225 { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r5579 r5636 33 33 34 34 35 static int get_ip_addr_ver(const pj_str_t *host); 35 36 static void schedule_reregistration(pjsua_acc *acc); 36 37 static void keep_alive_timer_cb(pj_timer_heap_t *th, pj_timer_entry *te); … … 548 549 549 550 /* Enclose IPv6 address in square brackets */ 550 if ( t->type & PJSIP_TRANSPORT_IPV6) {551 if (get_ip_addr_ver(&t->local_name.host) == 6) { 551 552 beginquote = "["; 552 553 endquote = "]"; … … 1326 1327 } 1327 1328 1329 acc->cfg.nat64_opt = cfg->nat64_opt; 1328 1330 acc->cfg.ipv6_media_use = cfg->ipv6_media_use; 1329 1331 … … 1697 1699 /* Compare the addresses as sockaddr according to the ticket above, 1698 1700 * but only if they have the same family (ipv4 vs ipv4, or 1699 * ipv6 vs ipv6) 1701 * ipv6 vs ipv6). 1702 * Checking for the same address family is currently disabled, 1703 * since it can be useful in cases such as when on NAT64, 1704 * in order to get the IPv4-mapped address from IPv6. 1700 1705 */ 1701 matched = (contact_addr.addr.sa_family != recv_addr.addr.sa_family)||1706 matched = //(contact_addr.addr.sa_family != recv_addr.addr.sa_family)|| 1702 1707 (uri->port == rport && 1703 1708 pj_sockaddr_cmp(&contact_addr, &recv_addr)==0); … … 3115 3120 pjsip_tpmgr *tpmgr; 3116 3121 pjsip_tpmgr_fla2_param tfla2_prm; 3122 pj_bool_t update_addr = PJ_TRUE; 3117 3123 3118 3124 PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL); … … 3183 3189 addr->host = tfla2_prm.ret_addr; 3184 3190 addr->port = tfla2_prm.ret_port; 3191 3192 /* If we are behind NAT64, use the Contact and Via address from 3193 * the UDP6 transport, which should be obtained from STUN. 3194 */ 3195 if (acc->cfg.nat64_opt != PJSUA_NAT64_DISABLED) { 3196 pjsip_tpmgr_fla2_param tfla2_prm2 = tfla2_prm; 3197 3198 tfla2_prm2.tp_type = PJSIP_TRANSPORT_UDP6; 3199 tfla2_prm2.tp_sel = NULL; 3200 tfla2_prm2.local_if = (!pjsua_sip_acc_is_using_stun(acc_id)); 3201 status = pjsip_tpmgr_find_local_addr2(tpmgr, pool, &tfla2_prm2); 3202 if (status == PJ_SUCCESS) { 3203 update_addr = PJ_FALSE; 3204 addr->host = tfla2_prm2.ret_addr; 3205 pj_strdup(acc->pool, &acc->via_addr.host, &addr->host); 3206 acc->via_addr.port = addr->port; 3207 acc->via_tp = (pjsip_transport *)tfla2_prm.ret_tp; 3208 } 3209 } 3185 3210 3186 3211 /* For TCP/TLS, acc may request to specify source port */ … … 3277 3302 3278 3303 if (status == PJ_SUCCESS) { 3279 /* Got the local transport address */ 3280 pj_strdup(pool, &addr->host, &tp->local_name.host); 3304 /* Got the local transport address, don't update if 3305 * we are on NAT64 and already obtained the address 3306 * from STUN above. 3307 */ 3308 if (update_addr) 3309 pj_strdup(pool, &addr->host, &tp->local_name.host); 3281 3310 addr->port = tp->local_name.port; 3282 3311 } -
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) { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c
r5597 r5636 241 241 }; 242 242 int i; 243 pj_bool_t use_ipv6 ;243 pj_bool_t use_ipv6, use_nat64; 244 244 int af; 245 245 pj_sockaddr bound_addr; … … 251 251 252 252 use_ipv6 = (acc->cfg.ipv6_media_use != PJSUA_IPV6_DISABLED); 253 af = use_ipv6 ? pj_AF_INET6() : pj_AF_INET(); 253 use_nat64 = (acc->cfg.nat64_opt != PJSUA_NAT64_DISABLED); 254 af = (use_ipv6 || use_nat64) ? pj_AF_INET6() : pj_AF_INET(); 254 255 255 256 /* Make sure STUN server resolution has completed */ 256 if (!use_ipv6 && pjsua_media_acc_is_using_stun(call_med->call->acc_id)) { 257 if ((!use_ipv6 || use_nat64) && 258 pjsua_media_acc_is_using_stun(call_med->call->acc_id)) 259 { 257 260 pj_bool_t retry_stun = (acc->cfg.media_stun_use & 258 261 PJSUA_STUN_RETRY_ON_FAILURE) == … … 354 357 * and make sure that the mapped RTCP port is adjacent with the RTP. 355 358 */ 356 if ( !use_ipv6&&359 if ((!use_ipv6 || use_nat64) && 357 360 pjsua_media_acc_is_using_stun(call_med->call->acc_id) && 358 361 pjsua_var.stun_srv.addr.sa_family != 0) 359 362 { 360 char ip_addr[ 32];363 char ip_addr[PJ_INET6_ADDRSTRLEN]; 361 364 pj_str_t stun_srv; 362 365 pj_sockaddr_in resolved_addr[2]; … … 368 371 pj_bzero(&stun_opt, sizeof(stun_opt)); 369 372 stun_opt.use_stun2 = pjsua_var.ua_cfg.stun_map_use_stun2; 373 stun_opt.af = pjsua_var.stun_srv.addr.sa_family; 370 374 stun_opt.srv1 = stun_opt.srv2 = stun_srv; 371 375 stun_opt.port1 = stun_opt.port2 = 372 pj_ ntohs(pjsua_var.stun_srv.ipv4.sin_port);376 pj_sockaddr_get_port(&pjsua_var.stun_srv); 373 377 status=pjstun_get_mapped_addr2(&pjsua_var.cp.factory, &stun_opt, 374 378 2, sock, resolved_addr); … … 433 437 } 434 438 439 stun_opt.af = pjsua_var.stun_srv.addr.sa_family; 435 440 stun_opt.srv1 = stun_opt.srv2 = stun_srv; 436 441 stun_opt.port1 = stun_opt.port2 = 437 pj_ ntohs(pjsua_var.stun_srv.ipv4.sin_port);442 pj_sockaddr_get_port(&pjsua_var.stun_srv); 438 443 status = pjstun_get_mapped_addr2(&pjsua_var.cp.factory, 439 444 &stun_opt, 2, sock, … … 824 829 unsigned comp_cnt; 825 830 pj_status_t status; 826 pj_bool_t use_ipv6 ;831 pj_bool_t use_ipv6, use_nat64; 827 832 828 833 acc_cfg = &pjsua_var.acc[call_med->call->acc_id].cfg; 829 834 use_ipv6 = (acc_cfg->ipv6_media_use != PJSUA_IPV6_DISABLED); 835 use_nat64 = (acc_cfg->nat64_opt != PJSUA_NAT64_DISABLED); 830 836 831 837 /* Make sure STUN server resolution has completed */ … … 864 870 if (pj_stricmp(&c->addr_type, &ID_IP6) == 0) 865 871 ice_cfg.af = pj_AF_INET6(); 866 } else if (use_ipv6 ) {872 } else if (use_ipv6 || use_nat64) { 867 873 ice_cfg.af = pj_AF_INET6(); 868 874 } … … 875 881 ice_cfg.stun_tp_cnt = 1; 876 882 pj_ice_strans_stun_cfg_default(&ice_cfg.stun_tp[0]); 877 if (use_ipv6 && PJ_ICE_MAX_STUN >= 2) { 883 if (use_nat64) { 884 ice_cfg.stun_tp[0].af = pj_AF_INET6(); 885 } else if (use_ipv6 && PJ_ICE_MAX_STUN >= 2) { 878 886 ice_cfg.stun_tp_cnt = 2; 879 887 pj_ice_strans_stun_cfg_default(&ice_cfg.stun_tp[1]); … … 886 894 unsigned i; 887 895 888 /* Configure STUN server (currently only for IPv4) */ 889 if (pj_sockaddr_has_addr(&pjsua_var.stun_srv) && 890 pjsua_media_acc_is_using_stun(call_med->call->acc_id)) 891 { 892 pj_sockaddr_print(&pjsua_var.stun_srv, stunip, sizeof(stunip), 0); 893 ice_cfg.stun_tp[0].server = pj_str(stunip); 894 ice_cfg.stun_tp[0].port = 895 pj_sockaddr_get_port(&pjsua_var.stun_srv); 896 } 897 898 /* Configure max host candidates */ 899 if (acc_cfg->ice_cfg.ice_max_host_cands >= 0) { 900 for (i = 0; i < ice_cfg.stun_tp_cnt; ++i) 896 pj_sockaddr_print(&pjsua_var.stun_srv, stunip, sizeof(stunip), 0); 897 898 for (i = 0; i < ice_cfg.stun_tp_cnt; ++i) { 899 pj_str_t IN6_ADDR_ANY = {"0", 1}; 900 901 /* Configure STUN server */ 902 if (pj_sockaddr_has_addr(&pjsua_var.stun_srv) && 903 pjsua_media_acc_is_using_stun(call_med->call->acc_id)) 904 { 905 ice_cfg.stun_tp[i].server = pj_str(stunip); 906 ice_cfg.stun_tp[i].port = pj_sockaddr_get_port( 907 &pjsua_var.stun_srv); 908 } 909 910 /* Configure max host candidates */ 911 if (acc_cfg->ice_cfg.ice_max_host_cands >= 0) { 901 912 ice_cfg.stun_tp[i].max_host_cands = 902 913 acc_cfg->ice_cfg.ice_max_host_cands; 903 } 904 905 /* Configure binding address */ 906 pj_sockaddr_init(ice_cfg.stun_tp[0].af, 907 &ice_cfg.stun_tp[0].cfg.bound_addr, 908 &cfg->bound_addr, (pj_uint16_t)cfg->port); 909 ice_cfg.stun_tp[0].cfg.port_range = (pj_uint16_t)cfg->port_range; 910 if (cfg->port != 0 && ice_cfg.stun_tp[0].cfg.port_range == 0) { 911 ice_cfg.stun_tp[0].cfg.port_range = 914 } 915 916 /* Configure binding address */ 917 pj_sockaddr_init(ice_cfg.stun_tp[i].af, 918 &ice_cfg.stun_tp[i].cfg.bound_addr, 919 (ice_cfg.stun_tp[i].af == pj_AF_INET()? 920 &cfg->bound_addr: &IN6_ADDR_ANY), 921 (pj_uint16_t)cfg->port); 922 ice_cfg.stun_tp[i].cfg.port_range = (pj_uint16_t)cfg->port_range; 923 if (cfg->port != 0 && ice_cfg.stun_tp[i].cfg.port_range == 0) { 924 ice_cfg.stun_tp[i].cfg.port_range = 912 925 (pj_uint16_t)(pjsua_var.ua_cfg.max_calls * 10); 913 } 914 if (use_ipv6 && ice_cfg.stun_tp_cnt > 1) { 915 pj_str_t IN6_ADDR_ANY = {"0", 1}; 916 pj_sockaddr_init(pj_AF_INET6(), 917 &ice_cfg.stun_tp[1].cfg.bound_addr, 918 &IN6_ADDR_ANY, (pj_uint16_t)cfg->port); 919 ice_cfg.stun_tp[1].cfg.port_range = 920 ice_cfg.stun_tp[0].cfg.port_range; 921 } 922 923 /* Configure QoS setting */ 924 ice_cfg.stun_tp[0].cfg.qos_type = cfg->qos_type; 925 pj_memcpy(&ice_cfg.stun_tp[0].cfg.qos_params, &cfg->qos_params, 926 sizeof(cfg->qos_params)); 927 if (use_ipv6 && ice_cfg.stun_tp_cnt > 1) { 928 ice_cfg.stun_tp[1].cfg.qos_type = cfg->qos_type; 929 pj_memcpy(&ice_cfg.stun_tp[1].cfg.qos_params, &cfg->qos_params, 926 } 927 928 /* Configure QoS setting */ 929 ice_cfg.stun_tp[i].cfg.qos_type = cfg->qos_type; 930 pj_memcpy(&ice_cfg.stun_tp[i].cfg.qos_params, &cfg->qos_params, 930 931 sizeof(cfg->qos_params)); 931 } 932 933 /* Configure max packet size */ 934 ice_cfg.stun_tp[0].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 935 if (use_ipv6 && ice_cfg.stun_tp_cnt > 1) 936 ice_cfg.stun_tp[1].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 937 932 933 /* Configure max packet size */ 934 ice_cfg.stun_tp[i].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 935 } 938 936 } 939 937 940 938 /* Configure TURN settings */ 941 939 if (acc_cfg->turn_cfg.enable_turn) { 942 ice_cfg.turn_tp_cnt = 1; 943 pj_ice_strans_turn_cfg_default(&ice_cfg.turn_tp[0]); 944 if (use_ipv6 && PJ_ICE_MAX_TURN >= 3) { 945 ice_cfg.turn_tp_cnt = 3; 946 947 pj_ice_strans_turn_cfg_default(&ice_cfg.turn_tp[1]); 948 ice_cfg.turn_tp[1].af = pj_AF_INET6(); 940 unsigned i, idx = 0; 941 942 if (use_ipv6 && !use_nat64 && PJ_ICE_MAX_TURN >= 3) { 943 ice_cfg.turn_tp_cnt = 3; 944 idx = 1; 945 } else { 946 ice_cfg.turn_tp_cnt = 1; 947 } 948 949 for (i = 0; i < ice_cfg.turn_tp_cnt; i++) 950 pj_ice_strans_turn_cfg_default(&ice_cfg.turn_tp[i]); 951 952 if (use_ipv6 || use_nat64) { 953 if (!use_nat64) 954 ice_cfg.turn_tp[idx++].af = pj_AF_INET6(); 949 955 950 956 /* Additional candidate: IPv4 relay via IPv6 TURN server */ 951 pj_ice_strans_turn_cfg_default(&ice_cfg.turn_tp[2]); 952 ice_cfg.turn_tp[2].af = pj_AF_INET6(); 953 ice_cfg.turn_tp[2].alloc_param.af = pj_AF_INET(); 957 ice_cfg.turn_tp[idx].af = pj_AF_INET6(); 958 ice_cfg.turn_tp[idx].alloc_param.af = pj_AF_INET(); 954 959 } 955 960 … … 963 968 } 964 969 965 /* Configure TURN connection settings and credential */966 970 if (ice_cfg.turn_tp[0].port == 0) 967 971 ice_cfg.turn_tp[0].port = 3479; 968 ice_cfg.turn_tp[0].conn_type = acc_cfg->turn_cfg.turn_conn_type; 969 pj_memcpy(&ice_cfg.turn_tp[0].auth_cred, 970 &acc_cfg->turn_cfg.turn_auth_cred, 971 sizeof(ice_cfg.turn_tp[0].auth_cred)); 972 973 if (use_ipv6 && ice_cfg.turn_tp_cnt > 1) { 974 ice_cfg.turn_tp[1].server = ice_cfg.turn_tp[0].server; 975 ice_cfg.turn_tp[1].port = ice_cfg.turn_tp[0].port; 976 ice_cfg.turn_tp[1].conn_type = ice_cfg.turn_tp[0].conn_type; 977 pj_memcpy(&ice_cfg.turn_tp[1].auth_cred, 972 973 for (i = 0; i < ice_cfg.turn_tp_cnt; i++) { 974 pj_str_t IN6_ADDR_ANY = {"0", 1}; 975 976 /* Configure TURN connection settings and credential */ 977 ice_cfg.turn_tp[i].server = ice_cfg.turn_tp[0].server; 978 ice_cfg.turn_tp[i].port = ice_cfg.turn_tp[0].port; 979 ice_cfg.turn_tp[i].conn_type = acc_cfg->turn_cfg.turn_conn_type; 980 pj_memcpy(&ice_cfg.turn_tp[i].auth_cred, 978 981 &acc_cfg->turn_cfg.turn_auth_cred, 979 sizeof(ice_cfg.turn_tp[1].auth_cred)); 980 981 ice_cfg.turn_tp[2].server = ice_cfg.turn_tp[0].server; 982 ice_cfg.turn_tp[2].port = ice_cfg.turn_tp[0].port; 983 ice_cfg.turn_tp[2].conn_type = ice_cfg.turn_tp[0].conn_type; 984 pj_memcpy(&ice_cfg.turn_tp[2].auth_cred, 985 &acc_cfg->turn_cfg.turn_auth_cred, 986 sizeof(ice_cfg.turn_tp[2].auth_cred)); 987 } 988 989 /* Configure QoS setting */ 990 ice_cfg.turn_tp[0].cfg.qos_type = cfg->qos_type; 991 pj_memcpy(&ice_cfg.turn_tp[0].cfg.qos_params, &cfg->qos_params, 992 sizeof(cfg->qos_params)); 993 if (use_ipv6 && ice_cfg.turn_tp_cnt > 1) { 994 ice_cfg.turn_tp[1].cfg.qos_type = cfg->qos_type; 995 pj_memcpy(&ice_cfg.turn_tp[1].cfg.qos_params, &cfg->qos_params, 982 sizeof(ice_cfg.turn_tp[i].auth_cred)); 983 984 /* Configure QoS setting */ 985 ice_cfg.turn_tp[i].cfg.qos_type = cfg->qos_type; 986 pj_memcpy(&ice_cfg.turn_tp[i].cfg.qos_params, &cfg->qos_params, 996 987 sizeof(cfg->qos_params)); 997 988 998 ice_cfg.turn_tp[2].cfg.qos_type = cfg->qos_type; 999 pj_memcpy(&ice_cfg.turn_tp[2].cfg.qos_params, &cfg->qos_params, 1000 sizeof(cfg->qos_params)); 1001 } 1002 1003 /* Configure binding address */ 1004 pj_sockaddr_init(ice_cfg.turn_tp[0].af, &ice_cfg.turn_tp[0].cfg.bound_addr, 1005 &cfg->bound_addr, (pj_uint16_t)cfg->port); 1006 ice_cfg.turn_tp[0].cfg.port_range = (pj_uint16_t)cfg->port_range; 1007 if (cfg->port != 0 && ice_cfg.turn_tp[0].cfg.port_range == 0) 1008 ice_cfg.turn_tp[0].cfg.port_range = 989 /* Configure binding address */ 990 pj_sockaddr_init(ice_cfg.turn_tp[i].af, 991 &ice_cfg.turn_tp[i].cfg.bound_addr, 992 (ice_cfg.turn_tp[i].af == pj_AF_INET()? 993 &cfg->bound_addr: &IN6_ADDR_ANY), 994 (pj_uint16_t)cfg->port); 995 ice_cfg.turn_tp[i].cfg.port_range = (pj_uint16_t)cfg->port_range; 996 if (cfg->port != 0 && ice_cfg.turn_tp[i].cfg.port_range == 0) 997 ice_cfg.turn_tp[i].cfg.port_range = 1009 998 (pj_uint16_t)(pjsua_var.ua_cfg.max_calls * 10); 1010 999 1011 if (use_ipv6 && ice_cfg.turn_tp_cnt > 1) { 1012 pj_str_t IN6_ADDR_ANY = {"0", 1}; 1013 pj_sockaddr_init(pj_AF_INET6(), 1014 &ice_cfg.turn_tp[1].cfg.bound_addr, 1015 &IN6_ADDR_ANY, (pj_uint16_t)cfg->port); 1016 ice_cfg.turn_tp[1].cfg.port_range = 1017 ice_cfg.turn_tp[0].cfg.port_range; 1018 1019 pj_sockaddr_init(pj_AF_INET6(), 1020 &ice_cfg.turn_tp[2].cfg.bound_addr, 1021 &IN6_ADDR_ANY, (pj_uint16_t)cfg->port); 1022 ice_cfg.turn_tp[2].cfg.port_range = 1023 ice_cfg.turn_tp[0].cfg.port_range; 1024 } 1025 1026 /* Configure max packet size */ 1027 ice_cfg.turn_tp[0].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 1028 if (use_ipv6 && ice_cfg.turn_tp_cnt > 1) { 1029 ice_cfg.turn_tp[1].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 1030 ice_cfg.turn_tp[2].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 1000 /* Configure max packet size */ 1001 ice_cfg.turn_tp[i].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 1031 1002 } 1032 1003 } … … 2396 2367 if (m->conn == NULL && sdp->conn == NULL) { 2397 2368 pj_bool_t use_ipv6; 2369 pj_bool_t use_nat64; 2398 2370 2399 2371 use_ipv6 = (pjsua_var.acc[call->acc_id].cfg.ipv6_media_use != 2400 2372 PJSUA_IPV6_DISABLED); 2373 use_nat64 = (pjsua_var.acc[call->acc_id].cfg.nat64_opt != 2374 PJSUA_NAT64_DISABLED); 2401 2375 2402 2376 m->conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn); 2403 2377 m->conn->net_type = pj_str("IN"); 2404 if (use_ipv6 ) {2378 if (use_ipv6 && !use_nat64) { 2405 2379 m->conn->addr_type = pj_str("IP6"); 2406 2380 m->conn->addr = pj_str("::1"); -
pjproject/trunk/pjsip/src/pjsua2/account.cpp
r5466 r5636 185 185 NODE_READ_NUM_T ( this_node, pjsua_stun_use, sipStunUse); 186 186 NODE_READ_NUM_T ( this_node, pjsua_stun_use, mediaStunUse); 187 NODE_READ_NUM_T ( this_node, pjsua_nat64_opt, nat64Opt); 187 188 NODE_READ_BOOL ( this_node, iceEnabled); 188 189 NODE_READ_INT ( this_node, iceMaxHostCands); … … 216 217 NODE_WRITE_NUM_T ( this_node, pjsua_stun_use, sipStunUse); 217 218 NODE_WRITE_NUM_T ( this_node, pjsua_stun_use, mediaStunUse); 219 NODE_WRITE_NUM_T ( this_node, pjsua_nat64_opt, nat64Opt); 218 220 NODE_WRITE_BOOL ( this_node, iceEnabled); 219 221 NODE_WRITE_INT ( this_node, iceMaxHostCands); … … 392 394 ret.sip_stun_use = natConfig.sipStunUse; 393 395 ret.media_stun_use = natConfig.mediaStunUse; 396 ret.nat64_opt = natConfig.nat64Opt; 394 397 ret.ice_cfg_use = PJSUA_ICE_CONFIG_USE_CUSTOM; 395 398 ret.ice_cfg.enable_ice = natConfig.iceEnabled; … … 535 538 natConfig.sipStunUse = prm.sip_stun_use; 536 539 natConfig.mediaStunUse = prm.media_stun_use; 540 natConfig.nat64Opt = prm.nat64_opt; 537 541 if (prm.ice_cfg_use == PJSUA_ICE_CONFIG_USE_CUSTOM) { 538 542 natConfig.iceEnabled = PJ2BOOL(prm.ice_cfg.enable_ice); -
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5635 r5636 149 149 } 150 150 151 this->stunTryIpv6 = PJ2BOOL(ua_cfg.stun_try_ipv6); 151 152 this->stunIgnoreFailure = PJ2BOOL(ua_cfg.stun_ignore_failure); 152 153 this->natTypeInSdp = ua_cfg.nat_type_in_sdp; … … 195 196 NODE_READ_STRING ( this_node, userAgent); 196 197 NODE_READ_STRINGV ( this_node, stunServer); 198 NODE_READ_BOOL ( this_node, stunTryIpv6); 197 199 NODE_READ_BOOL ( this_node, stunIgnoreFailure); 198 200 NODE_READ_INT ( this_node, natTypeInSdp); … … 210 212 NODE_WRITE_STRING ( this_node, userAgent); 211 213 NODE_WRITE_STRINGV ( this_node, stunServer); 214 NODE_WRITE_BOOL ( this_node, stunTryIpv6); 212 215 NODE_WRITE_BOOL ( this_node, stunIgnoreFailure); 213 216 NODE_WRITE_INT ( this_node, natTypeInSdp);
Note: See TracChangeset
for help on using the changeset viewer.