- Timestamp:
- Dec 28, 2016 3:40:07 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk (added) merged: 5209,5212-5234,5237-5253,5255,5257-5292,5294-5297,5299-5332,5334-5394,5396-5438,5440-5469,5471-5496,5498-5510
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjsip/src/pjsua-lib/pjsua_acc.c
r5188 r5513 88 88 pj_strdup_with_null(pool, &dst->reg_uri, &src->reg_uri); 89 89 pj_strdup_with_null(pool, &dst->force_contact, &src->force_contact); 90 pj_strdup_with_null(pool, &dst->reg_contact_params, 91 &src->reg_contact_params); 90 92 pj_strdup_with_null(pool, &dst->contact_params, &src->contact_params); 91 93 pj_strdup_with_null(pool, &dst->contact_uri_params, … … 381 383 pj_array_insert(pjsua_var.acc_ids, sizeof(pjsua_var.acc_ids[0]), 382 384 pjsua_var.acc_cnt, i, &acc_id); 385 386 if (acc_cfg->transport_id != PJSUA_INVALID_ID) 387 acc->tp_type = pjsua_var.tpdata[acc_cfg->transport_id].type; 383 388 384 389 return PJ_SUCCESS; … … 513 518 char transport_param[32]; 514 519 char uri[PJSIP_MAX_URL_SIZE]; 520 pjsua_acc_id acc_id; 521 pj_status_t status; 515 522 516 523 /* ID must be valid */ … … 555 562 cfg.id = pj_str(uri); 556 563 557 return pjsua_acc_add(&cfg, is_default, p_acc_id); 564 status = pjsua_acc_add(&cfg, is_default, &acc_id); 565 if (status == PJ_SUCCESS) { 566 pjsua_var.acc[acc_id].tp_type = t->type; 567 if (p_acc_id) 568 *p_acc_id = acc_id; 569 } 570 571 return status; 558 572 } 559 573 … … 981 995 update_reg = PJ_TRUE; 982 996 unreg_first = PJ_TRUE; 997 } 998 999 /* Register contact params */ 1000 if (pj_strcmp(&acc->cfg.reg_contact_params, &cfg->reg_contact_params)) { 1001 pj_strdup_with_null(acc->pool, &acc->cfg.reg_contact_params, 1002 &cfg->reg_contact_params); 1003 update_reg = PJ_TRUE; 983 1004 } 984 1005 … … 1466 1487 1467 1488 done: 1468 if (!need_outbound) { 1469 /* Outbound is not needed/wanted for the account. acc->reg_contact 1470 * is set to the same as acc->contact. 1471 */ 1472 acc->reg_contact = acc->contact; 1473 acc->rfc5626_status = OUTBOUND_NA; 1474 } else { 1475 /* Need to use outbound, append the contact with +sip.instance and 1476 * reg-id parameters. 1477 */ 1489 { 1478 1490 pj_ssize_t len; 1479 1491 pj_str_t reg_contact; 1480 1492 1481 1493 acc->rfc5626_status = OUTBOUND_WANTED; 1482 len = acc->contact.slen + acc->rfc5626_instprm.slen + 1483 acc->rfc5626_regprm.slen; 1484 reg_contact.ptr = (char*) pj_pool_alloc(acc->pool, len); 1485 1486 pj_strcpy(®_contact, &acc->contact); 1487 pj_strcat(®_contact, &acc->rfc5626_regprm); 1488 pj_strcat(®_contact, &acc->rfc5626_instprm); 1489 1490 acc->reg_contact = reg_contact; 1491 1492 PJ_LOG(4,(THIS_FILE, 1493 "Contact for acc %d updated for SIP outbound: %.*s", 1494 acc->index, 1495 (int)acc->reg_contact.slen, 1496 acc->reg_contact.ptr)); 1494 len = acc->contact.slen + acc->cfg.reg_contact_params.slen + 1495 (need_outbound? 1496 (acc->rfc5626_instprm.slen + acc->rfc5626_regprm.slen): 0); 1497 if (len > acc->contact.slen) { 1498 reg_contact.ptr = (char*) pj_pool_alloc(acc->pool, len); 1499 1500 pj_strcpy(®_contact, &acc->contact); 1501 1502 if (need_outbound) { 1503 acc->rfc5626_status = OUTBOUND_WANTED; 1504 1505 /* Need to use outbound, append the contact with 1506 * +sip.instance and reg-id parameters. 1507 */ 1508 pj_strcat(®_contact, &acc->rfc5626_regprm); 1509 pj_strcat(®_contact, &acc->rfc5626_instprm); 1510 } else { 1511 acc->rfc5626_status = OUTBOUND_NA; 1512 } 1513 1514 pj_strcat(®_contact, &acc->cfg.reg_contact_params); 1515 1516 acc->reg_contact = reg_contact; 1517 1518 PJ_LOG(4,(THIS_FILE, 1519 "Contact for acc %d updated: %.*s", 1520 acc->index, 1521 (int)acc->reg_contact.slen, 1522 acc->reg_contact.ptr)); 1523 1524 } else { 1525 /* Outbound is not needed/wanted for the account and there's 1526 * no custom registration Contact params. acc->reg_contact 1527 * is set to the same as acc->contact. 1528 */ 1529 acc->reg_contact = acc->contact; 1530 acc->rfc5626_status = OUTBOUND_NA; 1531 } 1497 1532 } 1498 1533 } … … 1533 1568 pjsip_via_hdr *via; 1534 1569 pj_sockaddr contact_addr; 1535 pj_sockaddr recv_addr ;1570 pj_sockaddr recv_addr = {{0}}; 1536 1571 pj_status_t status; 1537 1572 pj_bool_t matched; … … 1646 1681 &recv_addr); 1647 1682 if (status == PJ_SUCCESS) { 1648 /* Compare the addresses as sockaddr according to the ticket above */ 1649 matched = (uri->port == rport && 1683 /* Compare the addresses as sockaddr according to the ticket above, 1684 * but only if they have the same family (ipv4 vs ipv4, or 1685 * ipv6 vs ipv6) 1686 */ 1687 matched = (contact_addr.addr.sa_family != recv_addr.addr.sa_family) || 1688 (uri->port == rport && 1650 1689 pj_sockaddr_cmp(&contact_addr, &recv_addr)==0); 1651 1690 } else { … … 1941 1980 /* Send raw packet */ 1942 1981 status = pjsip_tpmgr_send_raw(pjsip_endpt_get_tpmgr(pjsua_var.endpt), 1943 PJSIP_TRANSPORT_UDP, &tp_sel,1982 acc->ka_transport->key.type, &tp_sel, 1944 1983 NULL, acc->cfg.ka_data.ptr, 1945 1984 acc->cfg.ka_data.slen, … … 2008 2047 if (/*pjsua_var.stun_srv.ipv4.sin_family == 0 ||*/ 2009 2048 acc->cfg.ka_interval == 0 || 2010 param->rdata->tp_info.transport->key.type != PJSIP_TRANSPORT_UDP) 2049 (param->rdata->tp_info.transport->key.type & 2050 ~PJSIP_TRANSPORT_IPV6)!= PJSIP_TRANSPORT_UDP) 2011 2051 { 2012 2052 /* Keep alive is not necessary */ … … 2288 2328 reg_info.cbparam = param; 2289 2329 reg_info.regc = param->regc; 2290 reg_info.renew = (rinfo.interval != 0);2330 reg_info.renew = !param->is_unreg; 2291 2331 (*pjsua_var.ua_cfg.cb.on_reg_state2)(acc->index, ®_info); 2292 2332 } … … 2476 2516 } 2477 2517 2518 pj_bool_t pjsua_sip_acc_is_using_ipv6(pjsua_acc_id acc_id) 2519 { 2520 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 2521 2522 return (acc->tp_type & PJSIP_TRANSPORT_IPV6) == PJSIP_TRANSPORT_IPV6; 2523 } 2524 2478 2525 pj_bool_t pjsua_sip_acc_is_using_stun(pjsua_acc_id acc_id) 2479 2526 { … … 2481 2528 2482 2529 return acc->cfg.sip_stun_use != PJSUA_STUN_USE_DISABLED && 2483 pjsua_var.ua_cfg.stun_srv_cnt != 0; 2530 pjsua_var.ua_cfg.stun_srv_cnt != 0; 2531 } 2532 2533 pj_bool_t pjsua_media_acc_is_using_stun(pjsua_acc_id acc_id) 2534 { 2535 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 2536 2537 return acc->cfg.media_stun_use != PJSUA_STUN_USE_DISABLED && 2538 pjsua_var.ua_cfg.stun_srv_cnt != 0; 2484 2539 } 2485 2540 … … 2907 2962 2908 2963 if (acc->valid && pj_stricmp(&acc->user_part, &sip_uri->user)==0) { 2909 2910 if (acc->cfg.transport_id != PJSUA_INVALID_ID) { 2911 pjsip_transport_type_e type; 2912 type = pjsip_transport_get_type_from_name(&sip_uri->transport_param); 2913 if (type == PJSIP_TRANSPORT_UNSPECIFIED) 2914 type = PJSIP_TRANSPORT_UDP; 2915 2916 if (pjsua_var.tpdata[acc->cfg.transport_id].type != type) 2917 continue; 2964 if (acc->tp_type != PJSIP_TRANSPORT_UNSPECIFIED && 2965 acc->tp_type != rdata->tp_info.transport->key.type) 2966 { 2967 continue; 2918 2968 } 2919 2969 … … 3019 3069 pj_in6_addr dummy6; 3020 3070 3021 /* First check with inet_aton()*/3022 if (pj_inet_ aton(host, &dummy) > 0)3071 /* First check if this is an IPv4 address */ 3072 if (pj_inet_pton(pj_AF_INET(), host, &dummy) == PJ_SUCCESS) 3023 3073 return 4; 3024 3074 … … 3088 3138 return PJSIP_EUNSUPTRANSPORT; 3089 3139 3090 /* If destination URI specifies IPv6 , then set transport type3091 * t o use IPv6 as well.3140 /* If destination URI specifies IPv6 or account is configured to use IPv6, 3141 * then set transport type to use IPv6 as well. 3092 3142 */ 3093 if (pj_strchr(&sip_uri->host, ':')) 3094 tp_type = (pjsip_transport_type_e)(((int)tp_type) + PJSIP_TRANSPORT_IPV6); 3143 if (pj_strchr(&sip_uri->host, ':') || pjsua_sip_acc_is_using_ipv6(acc_id)) 3144 tp_type = (pjsip_transport_type_e)(((int)tp_type) | 3145 PJSIP_TRANSPORT_IPV6); 3095 3146 3096 3147 flag = pjsip_transport_get_flag_from_type(tp_type); … … 3153 3204 if (status == PJ_SUCCESS) { 3154 3205 unsigned cnt=1; 3155 int af; 3156 3157 af = (dinfo.type & PJSIP_TRANSPORT_IPV6)? PJ_AF_INET6 : PJ_AF_INET; 3206 int af = pj_AF_UNSPEC(); 3207 3208 if (pjsua_sip_acc_is_using_ipv6(acc_id) || 3209 (dinfo.type & PJSIP_TRANSPORT_IPV6)) 3210 { 3211 af = pj_AF_INET6(); 3212 } 3158 3213 status = pj_getaddrinfo(af, &dinfo.addr.host, &cnt, &ai); 3214 if (cnt == 0) { 3215 status = PJ_ENOTSUP; 3216 } else if ((dinfo.type & PJSIP_TRANSPORT_IPV6)==0 && 3217 ai.ai_addr.addr.sa_family == pj_AF_INET6()) 3218 { 3219 /* Destination is a hostname and account is not bound to IPv6, 3220 * but hostname resolution reveals that it has IPv6 address, 3221 * so let's use IPv6 transport type. 3222 */ 3223 dinfo.type |= PJSIP_TRANSPORT_IPV6; 3224 tp_type |= PJSIP_TRANSPORT_IPV6; 3225 } 3159 3226 } 3160 3227 … … 3402 3469 return PJSIP_EUNSUPTRANSPORT; 3403 3470 3404 /* If destination URI specifies IPv6, then set transport type 3405 * to use IPv6 as well. 3471 /* If destination URI specifies IPv6 or account is configured to use IPv6 3472 * or the transport being used to receive data is an IPv6 transport, 3473 * then set transport type to use IPv6 as well. 3406 3474 */ 3407 if (pj_strchr(&sip_uri->host, ':')) 3408 tp_type = (pjsip_transport_type_e)(((int)tp_type) + PJSIP_TRANSPORT_IPV6); 3475 if (pj_strchr(&sip_uri->host, ':') || 3476 pjsua_sip_acc_is_using_ipv6(acc_id) || 3477 (rdata->tp_info.transport->key.type & PJSIP_TRANSPORT_IPV6)) 3478 { 3479 tp_type = (pjsip_transport_type_e) 3480 (((int)tp_type) | PJSIP_TRANSPORT_IPV6); 3481 } 3409 3482 3410 3483 flag = pjsip_transport_get_flag_from_type(tp_type); … … 3490 3563 3491 3564 acc->cfg.transport_id = tp_id; 3565 acc->tp_type = pjsua_var.tpdata[tp_id].type; 3492 3566 3493 3567 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.