Changeset 5342


Ignore:
Timestamp:
Jun 13, 2016 7:11:41 AM (8 years ago)
Author:
nanang
Message:

Re #422: Enable IPv6 in ICE transport in pjsua-lib:

  • currently only IPv6 host candidate will be generated, still not sure whether IPv6 NAT is really used in real world
  • if the account enables IPv6 media and the host has IPv4 address, ICE will generate IPv4+IPv6 candidates, it should be very useful in NAT64 environment, and should not add delay in ICE nego in IPv6 only environment (note: candidate check pair must have same IP address family).
Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath/ice_strans.c

    r5340 r5342  
    675675    for (i=0; i<ice_st->cfg.stun_tp_cnt; ++i) { 
    676676        status = add_stun_and_host(ice_st, comp, i); 
    677         if (status != PJ_SUCCESS) 
    678             return status; 
     677        if (status != PJ_SUCCESS) { 
     678            PJ_PERROR(3,(ice_st->obj_name, status, 
     679                         "Failed creating STUN transport #%d for comp %d", 
     680                         i, comp->comp_id)); 
     681            //return status; 
     682        } 
    679683    } 
    680684 
     
    682686    for (i=0; i<ice_st->cfg.turn_tp_cnt; ++i) { 
    683687        status = add_update_turn(ice_st, comp, i); 
    684         if (status != PJ_SUCCESS) 
    685             return status; 
     688        if (status != PJ_SUCCESS) { 
     689            PJ_PERROR(3,(ice_st->obj_name, status, 
     690                         "Failed creating TURN transport #%d for comp %d", 
     691                         i, comp->comp_id)); 
     692            //return status; 
     693        } 
    686694    } 
    687695 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r5339 r5342  
    824824    unsigned comp_cnt; 
    825825    pj_status_t status; 
     826    pj_bool_t use_ipv6; 
    826827 
    827828    acc_cfg = &pjsua_var.acc[call_med->call->acc_id].cfg; 
     829    use_ipv6 = (acc_cfg->ipv6_media_use != PJSUA_IPV6_DISABLED); 
    828830 
    829831    /* Make sure STUN server resolution has completed */ 
     
    856858        ice_cfg.stun_tp_cnt = 1; 
    857859        pj_ice_strans_stun_cfg_default(&ice_cfg.stun_tp[0]); 
     860        if (use_ipv6 && PJ_ICE_MAX_STUN >= 2) { 
     861            ice_cfg.stun_tp_cnt = 2; 
     862            pj_ice_strans_stun_cfg_default(&ice_cfg.stun_tp[1]); 
     863            ice_cfg.stun_tp[1].af = pj_AF_INET6(); 
     864        } 
    858865    } 
    859866 
     
    866873        ice_cfg.stun_tp[0].port = pj_sockaddr_get_port(&pjsua_var.stun_srv); 
    867874    } 
    868     if (acc_cfg->ice_cfg.ice_max_host_cands >= 0) 
    869         ice_cfg.stun_tp[0].max_host_cands = acc_cfg->ice_cfg.ice_max_host_cands; 
     875    if (acc_cfg->ice_cfg.ice_max_host_cands >= 0) { 
     876        ice_cfg.stun_tp[0].max_host_cands = 
     877                                    acc_cfg->ice_cfg.ice_max_host_cands; 
     878        if (use_ipv6) 
     879            ice_cfg.stun_tp[1].max_host_cands = 
     880                                    acc_cfg->ice_cfg.ice_max_host_cands; 
     881    } 
    870882 
    871883    /* Copy binding port setting to STUN setting */ 
     
    873885                     &cfg->bound_addr, (pj_uint16_t)cfg->port); 
    874886    ice_cfg.stun_tp[0].cfg.port_range = (pj_uint16_t)cfg->port_range; 
    875     if (cfg->port != 0 && ice_cfg.stun_tp[0].cfg.port_range == 0) 
     887    if (cfg->port != 0 && ice_cfg.stun_tp[0].cfg.port_range == 0) { 
    876888        ice_cfg.stun_tp[0].cfg.port_range =  
    877889                                 (pj_uint16_t)(pjsua_var.ua_cfg.max_calls * 10); 
     890    } 
     891    if (use_ipv6) { 
     892        pj_str_t IN6_ADDR_ANY = {"0", 1}; 
     893        pj_sockaddr_init(pj_AF_INET6(), &ice_cfg.stun_tp[1].cfg.bound_addr, 
     894                         &IN6_ADDR_ANY, (pj_uint16_t)cfg->port); 
     895        ice_cfg.stun_tp[1].cfg.port_range = ice_cfg.stun_tp[0].cfg.port_range; 
     896    } 
    878897 
    879898    /* Copy QoS setting to STUN setting */ 
     
    881900    pj_memcpy(&ice_cfg.stun_tp[0].cfg.qos_params, &cfg->qos_params, 
    882901              sizeof(cfg->qos_params)); 
     902    if (use_ipv6) { 
     903        ice_cfg.stun_tp[1].cfg.qos_type = cfg->qos_type; 
     904        pj_memcpy(&ice_cfg.stun_tp[1].cfg.qos_params, &cfg->qos_params, 
     905                  sizeof(cfg->qos_params)); 
     906    } 
    883907 
    884908    /* Configure TURN settings */ 
     
    917941    ice_cfg.stun_tp[0].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 
    918942    ice_cfg.turn_tp[0].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 
     943 
     944    if (use_ipv6) { 
     945        ice_cfg.stun_tp[1].cfg.max_pkt_size = PJMEDIA_MAX_MRU; 
     946    } 
    919947 
    920948    pj_bzero(&ice_cb, sizeof(pjmedia_ice_cb)); 
Note: See TracChangeset for help on using the changeset viewer.