Changeset 1629 for pjproject


Ignore:
Timestamp:
Dec 12, 2007 5:13:34 PM (17 years ago)
Author:
bennylp
Message:

Disable assertion in pj_sockaddr_has_addr()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/sock_common.c

    r1613 r1629  
    310310    const pj_sockaddr *a = (const pj_sockaddr*)addr; 
    311311 
    312     PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET || 
    313                      a->addr.sa_family == PJ_AF_INET6, PJ_EAFNOTSUP); 
    314  
    315     if (a->addr.sa_family == PJ_AF_INET6) { 
     312    /* It's probably not wise to raise assertion here if 
     313     * the address doesn't contain a valid address family, and 
     314     * just return PJ_FALSE instead. 
     315     *  
     316     * The reason is because application may need to distinguish  
     317     * these three conditions with sockaddr: 
     318     *  a) sockaddr is not initialized. This is by convention 
     319     *     indicated by sa_family==0. 
     320     *  b) sockaddr is initialized with zero address. This is 
     321     *     indicated with the address field having zero address. 
     322     *  c) sockaddr is initialized with valid address/port. 
     323     * 
     324     * If we enable this assertion, then application will loose 
     325     * the capability to specify condition a), since it will be 
     326     * forced to always initialize sockaddr (even with zero address). 
     327     * This may break some parts of upper layer libraries. 
     328     */ 
     329    //PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET || 
     330    //               a->addr.sa_family == PJ_AF_INET6, PJ_EAFNOTSUP); 
     331 
     332    if (a->addr.sa_family!=PJ_AF_INET && a->addr.sa_family!=PJ_AF_INET6) { 
     333        return PJ_FALSE; 
     334    } else if (a->addr.sa_family == PJ_AF_INET6) { 
    316335        pj_uint8_t zero[24]; 
    317336        pj_bzero(zero, sizeof(zero)); 
Note: See TracChangeset for help on using the changeset viewer.