Changeset 1996 for pjproject


Ignore:
Timestamp:
Jun 7, 2008 11:14:32 AM (16 years ago)
Author:
bennylp
Message:

Ignore 0.0.0.0/8 class IP address in interface enumeration function since this doesnt seem to have practical use for us (thanks Helmut Wolf)

Location:
pjproject/trunk/pjlib/src/pj
Files:
2 edited

Legend:

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

    r1668 r1996  
    9797        } 
    9898 
     99        /* Ignore 0.0.0.0/8 address. This is a special address 
     100         * which doesn't seem to have practical use. 
     101         */ 
     102        if (af==pj_AF_INET() && 
     103            (pj_ntohl(((pj_sockaddr_in*)ad)->sin_addr.s_addr) >> 24) == 0) 
     104        { 
     105            TRACE_((THIS_FILE, "  address %s ignored (0.0.0.0/8 class)",  
     106                    get_addr(ad), ad->sa_family)); 
     107            continue; 
     108        } 
     109 
    99110        TRACE_((THIS_FILE, "  address %s (af=%d) added at index %d",  
    100111                get_addr(ad), ad->sa_family, *p_cnt)); 
     
    178189        } 
    179190 
     191        /* Ignore 0.0.0.0/8 address. This is a special address 
     192         * which doesn't seem to have practical use. 
     193         */ 
     194        if (af==pj_AF_INET() && 
     195            (pj_ntohl(((pj_sockaddr_in*)ad)->sin_addr.s_addr) >> 24) == 0) 
     196        { 
     197            TRACE_((THIS_FILE, "  address %s ignored (0.0.0.0/8 class)",  
     198                    get_addr(ad), ad->sa_family)); 
     199            continue; 
     200        } 
     201 
    180202        TRACE_((THIS_FILE, "  address %s (af=%d) added at index %d",  
    181203                get_addr(ad), ad->sa_family, *p_cnt)); 
     
    215237    *p_cnt = 0; 
    216238    for (i=0; if_list[i].if_index && *p_cnt<max_count; ++i) { 
     239        struct sockaddr *ad; 
    217240        int rc; 
    218241 
     
    244267        } 
    245268 
    246         if (ifreq.ifr_addr.sa_family != af) { 
     269        ad = (struct sockaddr*) &ifreq.ifr_addr; 
     270 
     271        if (ad->sa_family != af) { 
    247272            TRACE_((THIS_FILE, "  address %s family %d ignored",  
    248273                               get_addr(&ifreq.ifr_addr), 
     
    251276        } 
    252277 
     278        /* Ignore 0.0.0.0/8 address. This is a special address 
     279         * which doesn't seem to have practical use. 
     280         */ 
     281        if (af==pj_AF_INET() && 
     282            (pj_ntohl(((pj_sockaddr_in*)ad)->sin_addr.s_addr) >> 24) == 0) 
     283        { 
     284            TRACE_((THIS_FILE, "  address %s ignored (0.0.0.0/8 class)",  
     285                    get_addr(ad), ad->sa_family)); 
     286            continue; 
     287        } 
     288 
    253289        /* Got an address ! */ 
    254290        TRACE_((THIS_FILE, "  address %s (af=%d) added at index %d",  
    255                 get_addr(&ifreq.ifr_addr), ifreq.ifr_addr.sa_family, *p_cnt)); 
     291                get_addr(ad), ad->sa_family, *p_cnt)); 
    256292 
    257293        pj_bzero(&ifs[*p_cnt], sizeof(ifs[0])); 
    258         pj_memcpy(&ifs[*p_cnt], &ifreq.ifr_addr,  
    259                   pj_sockaddr_get_len(&ifreq.ifr_addr)); 
     294        pj_memcpy(&ifs[*p_cnt], ad, pj_sockaddr_get_len(ad)); 
    260295        (*p_cnt)++; 
    261296    } 
  • pjproject/trunk/pjlib/src/pj/ip_helper_win32.c

    r1743 r1996  
    205205            continue; 
    206206 
     207        /* Ignore 0.0.0.0/8 address. This is a special address 
     208         * which doesn't seem to have practical use. 
     209         */ 
     210        if ((pj_ntohl(pTab->table[i].dwAddr) >> 24) == 0) 
     211            continue; 
     212 
    207213#if PJ_IP_HELPER_IGNORE_LOOPBACK_IF 
    208214        /* Investigate the type of this interface */ 
Note: See TracChangeset for help on using the changeset viewer.