Ignore:
Timestamp:
Feb 27, 2013 2:43:38 PM (12 years ago)
Author:
riza
Message:

Re #1613: backported to 1.x

Location:
pjproject/branches/1.x
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x

  • pjproject/branches/1.x/pjlib/src/pj/ip_helper_generic.c

    r3553 r4403  
    166166    } 
    167167 
    168     /* Done with socket */ 
    169     pj_sock_close(sock); 
    170  
    171168    /* Interface interfaces */ 
    172169    ifr = (struct ifreq*) ifc.ifc_req; 
     
    178175    for (i=0; i<count; ++i) { 
    179176        struct ifreq *itf = &ifr[i]; 
     177        struct ifreq iff = *itf; 
    180178        struct sockaddr *ad = &itf->ifr_addr; 
    181179         
     
    189187        } 
    190188 
    191         if ((itf->ifr_flags & IFF_UP)==0) { 
     189        if (ioctl(sock, SIOCGIFFLAGS, &iff) != 0) { 
     190            TRACE_((THIS_FILE, "  ioctl(SIOCGIFFLAGS) failed: %s", 
     191                    get_os_errmsg())); 
     192            continue;   /* Failed to get flags, continue */ 
     193        } 
     194 
     195        if ((iff.ifr_flags & IFF_UP)==0) { 
    192196            TRACE_((THIS_FILE, "  interface is down")); 
    193197            continue; /* Skip when interface is down */ 
     
    195199 
    196200#if PJ_IP_HELPER_IGNORE_LOOPBACK_IF 
    197         if (itf->ifr_flags & IFF_LOOPBACK) { 
     201        if (iff.ifr_flags & IFF_LOOPBACK) { 
    198202            TRACE_((THIS_FILE, "  loopback interface")); 
    199203            continue; /* Skip loopback interface */ 
     
    221225    } 
    222226 
     227    /* Done with socket */ 
     228    pj_sock_close(sock); 
     229 
    223230    TRACE_((THIS_FILE, "done, found %d address(es)", *p_cnt)); 
    224231    return (*p_cnt != 0) ? PJ_SUCCESS : PJ_ENOTFOUND; 
    225232} 
     233 
    226234 
    227235#elif defined(PJ_HAS_NET_IF_H) && PJ_HAS_NET_IF_H != 0 
Note: See TracChangeset for help on using the changeset viewer.