diff options
author | Andrew Stitcher <astitcher@apache.org> | 2012-11-16 14:27:08 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2012-11-16 14:27:08 +0000 |
commit | 384aa602a1d54734f76d1d0fc59ef41d2415e03b (patch) | |
tree | b398c0b6a051b26adeceaf54e66b6c0ec7998874 /cpp/src/qpid/sys/posix/SystemInfo.cpp | |
parent | 74cf1e52ab5ef4f4c69a9b78f9664ea0558e5207 (diff) | |
download | qpid-python-384aa602a1d54734f76d1d0fc59ef41d2415e03b.tar.gz |
NO-JIRA: Removed unused isLocalHost() code
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1410360 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/posix/SystemInfo.cpp')
-rwxr-xr-x | cpp/src/qpid/sys/posix/SystemInfo.cpp | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/cpp/src/qpid/sys/posix/SystemInfo.cpp b/cpp/src/qpid/sys/posix/SystemInfo.cpp index dea74b4ab0..0f29f511b1 100755 --- a/cpp/src/qpid/sys/posix/SystemInfo.cpp +++ b/cpp/src/qpid/sys/posix/SystemInfo.cpp @@ -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 (uint16_t port, } } -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, |