Ignore:
Timestamp:
Nov 14, 2016 6:13:01 AM (4 years ago)
Author:
nanang
Message:

Re #1971: Request IPv4 relay address to an IPv6 TURN server for IPv6-IPv4 connectivity.

File:
1 edited

Legend:

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

    r5469 r5481  
    725725                     PJ_EINVALIDOP); 
    726726 
     727    /* Verify address family in allocation param */ 
     728    if (param && param->af) { 
     729        PJ_ASSERT_RETURN(param->af==pj_AF_INET() || param->af==pj_AF_INET6(), 
     730                         PJ_EINVAL); 
     731    } 
     732 
    727733    pj_grp_lock_acquire(sess->grp_lock); 
    728734 
     
    771777    } 
    772778 
    773     /* Include ADDRESS-FAMILY for IPv6 request */ 
    774     if (sess->af == pj_AF_INET6()) { 
    775         enum { IPV6_AF_TYPE = 0x02 << 24 }; 
    776         pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg, 
    777                                   PJ_STUN_ATTR_REQ_ADDR_TYPE, IPV6_AF_TYPE); 
     779    /* Include ADDRESS-FAMILY if requested */ 
     780    if (sess->alloc_param.af || sess->af == pj_AF_INET6()) { 
     781        enum  { IPV4_AF_TYPE = 0x01 << 24, 
     782                IPV6_AF_TYPE = 0x02 << 24 }; 
     783 
     784        if (sess->alloc_param.af == pj_AF_INET6() || 
     785            (sess->alloc_param.af == 0 && sess->af == pj_AF_INET6())) 
     786        { 
     787            pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg, 
     788                                      PJ_STUN_ATTR_REQ_ADDR_TYPE, IPV6_AF_TYPE); 
     789        } else if (sess->alloc_param.af == pj_AF_INET()) { 
     790            /* For IPv4, only add the attribute when explicitly requested */ 
     791            pj_stun_msg_add_uint_attr(tdata->pool, tdata->msg, 
     792                                      PJ_STUN_ATTR_REQ_ADDR_TYPE, IPV4_AF_TYPE); 
     793        } 
    778794    } 
    779795 
     
    13591375        return; 
    13601376    } 
    1361     if (raddr_attr && raddr_attr->sockaddr.addr.sa_family != sess->af) { 
     1377    if (raddr_attr && 
     1378        ((sess->alloc_param.af != 0 && 
     1379          raddr_attr->sockaddr.addr.sa_family != sess->alloc_param.af) || 
     1380         (sess->alloc_param.af == 0 && 
     1381          raddr_attr->sockaddr.addr.sa_family != sess->af))) 
     1382    { 
    13621383        on_session_fail(sess, method, PJNATH_EINSTUNMSG, 
    13631384                        pj_cstr(&s, "Error: Mismatched RELAY-ADDRESS " 
Note: See TracChangeset for help on using the changeset viewer.