Changeset 5337 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
- Timestamp:
- Jun 8, 2016 2:49:56 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.