You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2012/11/16 15:27:09 UTC

svn commit: r1410360 - in /qpid/trunk/qpid/cpp: include/qpid/sys/SystemInfo.h src/qpid/sys/posix/SystemInfo.cpp src/tests/SystemInfo.cpp

Author: astitcher
Date: Fri Nov 16 14:27:08 2012
New Revision: 1410360

URL: http://svn.apache.org/viewvc?rev=1410360&view=rev
Log:
NO-JIRA: Removed unused isLocalHost() code

Modified:
    qpid/trunk/qpid/cpp/include/qpid/sys/SystemInfo.h
    qpid/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
    qpid/trunk/qpid/cpp/src/tests/SystemInfo.cpp

Modified: qpid/trunk/qpid/cpp/include/qpid/sys/SystemInfo.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/sys/SystemInfo.h?rev=1410360&r1=1410359&r2=1410360&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/sys/SystemInfo.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/sys/SystemInfo.h Fri Nov 16 14:27:08 2012
@@ -53,12 +53,6 @@ QPID_COMMON_EXTERN bool getLocalHostname
 QPID_COMMON_EXTERN void getLocalIpAddresses (uint16_t port, std::vector<Address> &addrList);
 
 /**
- * Return true if host names an address of the local host.
- *@param host host name or IP address.
- */
-QPID_COMMON_EXTERN bool isLocalHost(const std::string& host);
-
-/**
  * Retrieve system identifiers and versions. This is information that can
  * generally be retrieved via POSIX uname().
  *

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp?rev=1410360&r1=1410359&r2=1410360&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp Fri Nov 16 14:27:08 2012
@@ -21,7 +21,6 @@
 #include "qpid/log/Statement.h"
 #include "qpid/sys/SystemInfo.h"
 #include "qpid/sys/posix/check.h"
-#include <set>
 #include <arpa/inet.h>
 #include <sys/ioctl.h>
 #include <sys/utsname.h>
@@ -122,41 +121,6 @@ void SystemInfo::getLocalIpAddresses (ui
     }
 }
 
-namespace {
-struct AddrInfo {
-    struct addrinfo* ptr;
-    AddrInfo(const std::string& host) : ptr(0) {
-        ::addrinfo hints;
-        ::memset(&hints, 0, sizeof(hints));
-        hints.ai_family = AF_UNSPEC; // Allow both IPv4 and IPv6
-        if (::getaddrinfo(host.c_str(), NULL, &hints, &ptr) != 0)
-            ptr = 0;
-    }
-    ~AddrInfo() { if (ptr) ::freeaddrinfo(ptr); }
-};
-}
-
-bool SystemInfo::isLocalHost(const std::string& host) {
-    std::vector<Address> myAddrs;
-    getLocalIpAddresses(0, myAddrs);
-    std::set<string> localHosts;
-    for (std::vector<Address>::const_iterator i = myAddrs.begin(); i != myAddrs.end(); ++i)
-        localHosts.insert(i->host);
-    // Resolve host
-    AddrInfo ai(host);
-    if (!ai.ptr) return false;
-    for (struct addrinfo *res = ai.ptr; res != NULL; res = res->ai_next) {
-        if (isLoopback(res->ai_addr)) return true;
-        // Get string form of IP addr
-        char addr[NI_MAXHOST] = "";
-        int error = ::getnameinfo(res->ai_addr, res->ai_addrlen, addr, NI_MAXHOST, NULL, 0,
-                                  NI_NUMERICHOST | NI_NUMERICSERV);
-        if (error) return false;
-        if (localHosts.find(addr) != localHosts.end()) return true;
-    }
-    return false;
-}
-
 void SystemInfo::getSystemId (std::string &osName,
                               std::string &nodeName,
                               std::string &release,

Modified: qpid/trunk/qpid/cpp/src/tests/SystemInfo.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/SystemInfo.cpp?rev=1410360&r1=1410359&r2=1410360&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/SystemInfo.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/SystemInfo.cpp Fri Nov 16 14:27:08 2012
@@ -31,22 +31,6 @@ namespace tests {
 
 QPID_AUTO_TEST_SUITE(SystemInfoTestSuite)
 
-QPID_AUTO_TEST_CASE(TestIsLocalHost) {
-    // Test that local hostname and addresses are considered local
-    Address a;
-    BOOST_ASSERT(SystemInfo::getLocalHostname(a));
-    BOOST_ASSERT(SystemInfo::isLocalHost(a.host));
-    std::vector<Address> addrs;
-    SystemInfo::getLocalIpAddresses(0, addrs);
-    for (std::vector<Address>::iterator i = addrs.begin(); i != addrs.end(); ++i)
-        BOOST_ASSERT(SystemInfo::isLocalHost(i->host));
-    // Check some non-local addresses
-    BOOST_ASSERT(!SystemInfo::isLocalHost("123.4.5.6"));
-    BOOST_ASSERT(!SystemInfo::isLocalHost("nosuchhost"));
-    BOOST_ASSERT(SystemInfo::isLocalHost("127.0.0.1"));
-    BOOST_ASSERT(SystemInfo::isLocalHost("::1"));
-}
-
 QPID_AUTO_TEST_SUITE_END()
 
 }} // namespace qpid::tests



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org