Changeset 5337
- Timestamp:
- Jun 8, 2016 2:49:56 AM (8 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r5326 r5337 284 284 285 285 pj_uint16_t next_rtp_port; /**< Next RTP port to be used. */ 286 pjsip_transport_type_e tp_type; /**< Transport type (for local acc or 287 transport binding) */ 286 288 } pjsua_acc; 287 289 … … 623 625 pj_bool_t pjsua_media_acc_is_using_stun(pjsua_acc_id acc_id); 624 626 627 /* acc use IPv6? */ 628 pj_bool_t pjsua_sip_acc_is_using_ipv6(pjsua_acc_id acc_id); 629 625 630 /* Get local transport address suitable to be used for Via or Contact address 626 631 * to send request to the specified destination URI. -
pjproject/trunk/pjsip/src/pjsip/sip_resolve.c
r5311 r5337 196 196 struct query *query; 197 197 pjsip_transport_type_e type = target->type; 198 int af = pj_AF_UNSPEC(); 198 199 199 200 /* If an external implementation has been provided use it instead */ … … 205 206 /* Is it IP address or hostname? And if it's an IP, which version? */ 206 207 ip_addr_ver = get_ip_addr_ver(&target->addr.host); 208 209 /* Initialize address family type */ 210 if ((ip_addr_ver == 6) || (type & PJSIP_TRANSPORT_IPV6)) 211 af = pj_AF_INET6(); 212 else if (ip_addr_ver == 4) 213 af = pj_AF_INET(); 207 214 208 215 /* Set the transport type if not explicitly specified. … … 242 249 } 243 250 } 244 245 /* Add IPv6 flag for IPv6 address */246 if (ip_addr_ver == 6)247 type = (pjsip_transport_type_e)((int)type + PJSIP_TRANSPORT_IPV6);248 251 } 249 252 … … 272 275 pj_addrinfo ai; 273 276 unsigned count; 274 int af;275 277 276 278 PJ_LOG(5,(THIS_FILE, … … 281 283 target->addr.port, 282 284 pjsip_transport_get_type_name(target->type))); 283 284 if (type & PJSIP_TRANSPORT_IPV6) {285 af = pj_AF_INET6();286 } else {287 af = pj_AF_INET();288 }289 285 290 286 /* Resolve */ … … 300 296 } 301 297 302 svr_addr.entry[0].addr.addr.sa_family = (pj_uint16_t)af;303 pj_memcpy(&svr_addr.entry[0].addr, &ai.ai_addr,304 sizeof(pj_sockaddr));298 pj_sockaddr_cp(&svr_addr.entry[0].addr, &ai.ai_addr); 299 if (af == pj_AF_UNSPEC()) 300 af = ai.ai_addr.addr.sa_family; 305 301 } 302 303 /* After address resolution, update IPv6 bitflag in transport type. */ 304 if (af == pj_AF_INET6()) 305 type |= PJSIP_TRANSPORT_IPV6; 306 306 307 307 /* Set the port number */ -
pjproject/trunk/pjsip/src/pjsip/sip_util.c
r4888 r5337 1016 1016 if (status != PJ_SUCCESS) 1017 1017 return status; 1018 1019 /* If transport selector is set, set destination type accordingly */ 1020 if (tdata->tp_sel.type != PJSIP_TPSELECTOR_NONE && tdata->tp_sel.u.ptr) { 1021 if (tdata->tp_sel.type == PJSIP_TPSELECTOR_TRANSPORT) 1022 dest_info->type = tdata->tp_sel.u.transport->key.type; 1023 else if (tdata->tp_sel.type == PJSIP_TPSELECTOR_LISTENER) 1024 dest_info->type = tdata->tp_sel.u.listener->type; 1025 } 1018 1026 1019 1027 /* If target URI is different than request URI, replace -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r5322 r5337 382 382 pjsua_var.acc_cnt, i, &acc_id); 383 383 384 if (acc_cfg->transport_id != PJSUA_INVALID_ID) 385 acc->tp_type = pjsua_var.tpdata[acc_cfg->transport_id].type; 386 384 387 return PJ_SUCCESS; 385 388 } … … 513 516 char transport_param[32]; 514 517 char uri[PJSIP_MAX_URL_SIZE]; 518 pjsua_acc_id acc_id; 519 pj_status_t status; 515 520 516 521 /* ID must be valid */ … … 555 560 cfg.id = pj_str(uri); 556 561 557 return pjsua_acc_add(&cfg, is_default, p_acc_id); 562 status = pjsua_acc_add(&cfg, is_default, &acc_id); 563 if (status == PJ_SUCCESS) { 564 pjsua_var.acc[acc_id].tp_type = t->type; 565 if (p_acc_id) 566 *p_acc_id = acc_id; 567 } 568 569 return status; 558 570 } 559 571 … … 2481 2493 } 2482 2494 2495 pj_bool_t pjsua_sip_acc_is_using_ipv6(pjsua_acc_id acc_id) 2496 { 2497 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 2498 2499 return (acc->tp_type & PJSIP_TRANSPORT_IPV6) == PJSIP_TRANSPORT_IPV6; 2500 } 2501 2483 2502 pj_bool_t pjsua_sip_acc_is_using_stun(pjsua_acc_id acc_id) 2484 2503 { … … 2920 2939 2921 2940 if (acc->valid && pj_stricmp(&acc->user_part, &sip_uri->user)==0) { 2922 2923 if (acc->cfg.transport_id != PJSUA_INVALID_ID) { 2924 pjsip_transport_type_e type; 2925 type = pjsip_transport_get_type_from_name(&sip_uri->transport_param); 2926 if (type == PJSIP_TRANSPORT_UNSPECIFIED) 2927 type = PJSIP_TRANSPORT_UDP; 2928 2929 if (pjsua_var.tpdata[acc->cfg.transport_id].type != type) 2930 continue; 2941 if (acc->tp_type != PJSIP_TRANSPORT_UNSPECIFIED && 2942 acc->tp_type != rdata->tp_info.transport->key.type) 2943 { 2944 continue; 2931 2945 } 2932 2946 … … 3101 3115 return PJSIP_EUNSUPTRANSPORT; 3102 3116 3103 /* If destination URI specifies IPv6 , then set transport type3104 * t o use IPv6 as well.3117 /* If destination URI specifies IPv6 or account is configured to use IPv6, 3118 * then set transport type to use IPv6 as well. 3105 3119 */ 3106 if (pj_strchr(&sip_uri->host, ':') )3120 if (pj_strchr(&sip_uri->host, ':') || pjsua_sip_acc_is_using_ipv6(acc_id)) 3107 3121 tp_type = (pjsip_transport_type_e)(((int)tp_type) | 3108 3122 PJSIP_TRANSPORT_IPV6); … … 3167 3181 if (status == PJ_SUCCESS) { 3168 3182 unsigned cnt=1; 3169 int af; 3170 3171 af = (dinfo.type & PJSIP_TRANSPORT_IPV6)? PJ_AF_INET6 : PJ_AF_INET; 3183 int af = pj_AF_UNSPEC(); 3184 3185 if (pjsua_sip_acc_is_using_ipv6(acc_id) || 3186 (dinfo.type & PJSIP_TRANSPORT_IPV6)) 3187 { 3188 af = pj_AF_INET6(); 3189 } 3172 3190 status = pj_getaddrinfo(af, &dinfo.addr.host, &cnt, &ai); 3173 if (cnt == 0) status = PJ_ENOTSUP; 3191 if (cnt == 0) { 3192 status = PJ_ENOTSUP; 3193 } else if ((dinfo.type & PJSIP_TRANSPORT_IPV6)==0 && 3194 ai.ai_addr.addr.sa_family == pj_AF_INET6()) 3195 { 3196 /* Destination is a hostname and account is not bound to IPv6, 3197 * but hostname resolution reveals that it has IPv6 address, 3198 * so let's use IPv6 transport type. 3199 */ 3200 dinfo.type |= PJSIP_TRANSPORT_IPV6; 3201 tp_type |= PJSIP_TRANSPORT_IPV6; 3202 } 3174 3203 } 3175 3204 … … 3417 3446 return PJSIP_EUNSUPTRANSPORT; 3418 3447 3419 /* If destination URI specifies IPv6, then set transport type 3420 * to use IPv6 as well. 3448 /* If destination URI specifies IPv6 or account is configured to use IPv6 3449 * or the transport being used to receive data is an IPv6 transport, 3450 * then set transport type to use IPv6 as well. 3421 3451 */ 3422 if (pj_strchr(&sip_uri->host, ':')) 3423 tp_type = (pjsip_transport_type_e)(((int)tp_type) + PJSIP_TRANSPORT_IPV6); 3452 if (pj_strchr(&sip_uri->host, ':') || 3453 pjsua_sip_acc_is_using_ipv6(acc_id) || 3454 (rdata->tp_info.transport->key.type & PJSIP_TRANSPORT_IPV6)) 3455 { 3456 tp_type = (pjsip_transport_type_e) 3457 (((int)tp_type) | PJSIP_TRANSPORT_IPV6); 3458 } 3424 3459 3425 3460 flag = pjsip_transport_get_flag_from_type(tp_type); … … 3505 3540 3506 3541 acc->cfg.transport_id = tp_id; 3542 acc->tp_type = pjsua_var.tpdata[tp_id].type; 3507 3543 3508 3544 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.