Changeset 19848

Show
Ignore:
Timestamp:
03/03/07 10:44:13 (2 years ago)
Author:
patrick
Message:

Allow callers of vpr::InetAddr::getAllLocalAddrs() to choose whether the
address for interfaces in the down state should be returned. This patch
was started by Daniel Shipton and then expanded by Doug McCorkle?. I made
the final changes to it that extended the signature of
vpr::InetAddr::getAllLocalAddrs().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/branches/2.0/modules/vapor/ChangeLog

    r19815 r19848  
    11DATE       AUTHOR   CHANGE 
    22---------- -------- ----------------------------------------------------------- 
     32007-03-03 patrick  Allow callers of vpr::InetAddr::getAllLocalAddrs() to 
     4                    indicate whether interfaces in the down state should be 
     5                    considered. 
     6 
    37[1.0.3 released - 2.14.2007]=================================================== 
    48 
  • juggler/branches/2.0/modules/vapor/vpr/md/NSPR/IO/Socket/InetAddrNSPR.cpp

    r18288 r19848  
    5353 
    5454vpr::ReturnStatus getIfAddrs(std::vector<vpr::InetAddrNSPR>& hostAddrs, 
    55                              const bool withLoopback); 
     55                             const bool withLoopback, 
     56                             const bool withDisabledNICs); 
    5657 
    5758const InetAddrNSPR InetAddrNSPR::AnyAddr;      // Default constructor defaults to ANY addr 
     
    7475vpr::ReturnStatus 
    7576InetAddrNSPR::getAllLocalAddrs(std::vector<vpr::InetAddrNSPR>& hostAddrs, 
    76                                const bool withLoopback
    77 { 
    78    return vpr::getIfAddrs(hostAddrs, withLoopback); 
     77                               const bool withLoopback, const bool withDown
     78{ 
     79   return vpr::getIfAddrs(hostAddrs, withLoopback, withDown); 
    7980} 
    8081 
  • juggler/branches/2.0/modules/vapor/vpr/md/NSPR/IO/Socket/InetAddrNSPR.h

    r19215 r19848  
    122122    *                     address (127.0.0.1) in \p hostAddrs. This parameter 
    123123    *                     is optional and defaults to false. 
     124    * @param withDown     A flag indicating whether the address for interfaces 
     125    *                     in the down state should be included. This parameter 
     126    *                     is optional and defaults to false. 
    124127    * 
    125128    * @note This method currently supports only IPv4. 
     
    133136   static vpr::ReturnStatus 
    134137      getAllLocalAddrs(std::vector<vpr::InetAddrNSPR>& hostAddrs, 
    135                        const bool withLoopback = false); 
     138                       const bool withLoopback = false, 
     139                       const bool withDown = false); 
    136140 
    137141   /** 
  • juggler/branches/2.0/modules/vapor/vpr/md/POSIX/IO/Socket/InetAddrBSD.cpp

    r19670 r19848  
    7373 
    7474vpr::ReturnStatus getIfAddrs(std::vector<vpr::InetAddrBSD>& hostAddrs, 
    75                              const bool withLoopback); 
     75                             const bool withLoopback, const bool withDown); 
    7676 
    7777const InetAddrBSD InetAddrBSD::AnyAddr;      // Default constructor defaults to ANY addr 
     
    106106vpr::ReturnStatus 
    107107InetAddrBSD::getAllLocalAddrs(std::vector<vpr::InetAddrBSD>& hostAddrs, 
    108                               const bool withLoopback
    109 { 
    110    return vpr::getIfAddrs(hostAddrs, withLoopback); 
     108                              const bool withLoopback, const bool withDown
     109{ 
     110   return vpr::getIfAddrs(hostAddrs, withLoopback, withDown); 
    111111} 
    112112 
  • juggler/branches/2.0/modules/vapor/vpr/md/POSIX/IO/Socket/InetAddrBSD.h

    r18288 r19848  
    121121    *                     address (127.0.0.1) in \p hostAddrs. This parameter 
    122122    *                     is optional and defaults to false. 
     123    * @param withDown     A flag indicating whether the address for interfaces 
     124    *                     in the down state should be included. This parameter 
     125    *                     is optional and defaults to false. 
    123126    * 
    124127    * @note This method currently supports only IPv4. 
     
    132135   static vpr::ReturnStatus 
    133136      getAllLocalAddrs(std::vector<vpr::InetAddrBSD>& hostAddrs, 
    134                        const bool withLoopback = false); 
     137                       const bool withLoopback = false, 
     138                       const bool withDown = false); 
    135139 
    136140   /** 
  • juggler/branches/2.0/modules/vapor/vpr/md/common/InetAddrHelpers.cpp

    r18957 r19848  
    5757#  else 
    5858#     include <sys/ioctl.h> 
    59 #     include <net/if.h> 
    6059#  endif 
    6160 
     61#  include <net/if.h> 
    6262#  include <netinet/in.h> 
    6363#  include <arpa/inet.h> 
     
    9393 * @param withLoopback A flag indicating whether to include the loopback 
    9494 *                     address (127.0.0.1) in \p hostAddrs. 
     95 * @param withDown     A flag indicating whether the address for interfaces in 
     96 *                     the down state should be included. 
    9597 * 
    9698 * @note This method currently supports only IPv4. 
     
    101103 */ 
    102104vpr::ReturnStatus getIfAddrs(std::vector<vpr::InetAddr>& hostAddrs, 
    103                              const bool withLoopback
     105                             const bool withLoopback, const bool withDown
    104106{ 
    105107#if defined(VPR_OS_Windows) 
     
    133135         // We only handle IPv4 addresses. 
    134136         if ( addr_in->sin_family != AF_INET ) 
     137         { 
     138            continue; 
     139         } 
     140 
     141         // If the inerface is down and the caller asked to exclude down 
     142         // interfaces, skip this one. 
     143         if ( a->ifa_flags & IFF_UP == 0 && ! withDown ) 
    135144         { 
    136145            continue; 
     
    334343      } 
    335344 
     345#if defined(VPR_OS_Windows) 
     346      const bool down = if_list[i].iiFlags & IFF_UP == 0; 
     347#else 
     348      // XXX: This call may cause problems. It may not work on Linux. 
     349      const bool down ifc.ifc_req[i].ifr_flags & IFF_UP == 0; 
     350#endif 
     351 
     352      // If the inerface is down and the caller asked to exclude down 
     353      // interfaces, skip this one. 
     354      if ( down && ! withDown ) 
     355      { 
     356         continue; 
     357      } 
     358 
    336359      // If we have the loopback address and withLoopback is false, then we 
    337360      // skip this address.