diff options
Diffstat (limited to 'qpid/cpp')
| -rw-r--r-- | qpid/cpp/include/qpid/Url.h | 7 | ||||
| -rw-r--r-- | qpid/cpp/include/qpid/sys/SystemInfo.h | 6 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/Url.cpp | 13 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/broker/Broker.cpp | 25 | ||||
| -rwxr-xr-x | qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp | 45 | ||||
| -rwxr-xr-x | qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp | 25 | ||||
| -rwxr-xr-x | qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp | 29 |
7 files changed, 10 insertions, 140 deletions
diff --git a/qpid/cpp/include/qpid/Url.h b/qpid/cpp/include/qpid/Url.h index b3ff9576e2..f9ed87c24b 100644 --- a/qpid/cpp/include/qpid/Url.h +++ b/qpid/cpp/include/qpid/Url.h @@ -32,13 +32,6 @@ namespace qpid { /** An AMQP URL contains a list of addresses */ struct Url : public std::vector<Address> { - /** Url with the hostname as returned by gethostname(2) */ - QPID_COMMON_EXTERN static Url getHostNameUrl(uint16_t port); - - /** Url with local IP address(es), may be more than one address - * on a multi-homed host. */ - QPID_COMMON_EXTERN static Url getIpAddressesUrl(uint16_t port); - struct Invalid : public Exception { QPID_COMMON_EXTERN Invalid(const std::string& s); }; /** Convert to string form. */ diff --git a/qpid/cpp/include/qpid/sys/SystemInfo.h b/qpid/cpp/include/qpid/sys/SystemInfo.h index ec0e653881..1b5720a5f0 100644 --- a/qpid/cpp/include/qpid/sys/SystemInfo.h +++ b/qpid/cpp/include/qpid/sys/SystemInfo.h @@ -47,12 +47,6 @@ QPID_COMMON_EXTERN long concurrency(); QPID_COMMON_EXTERN bool getLocalHostname (Address &address); /** - * Get the (possibly multiple) local IP addresses of this host - * using the specified port. - */ -QPID_COMMON_EXTERN void getLocalIpAddresses (uint16_t port, std::vector<Address> &addrList); - -/** * Get the names of all the network interfaces connected to * this host. * @param names Receives the list of interface names diff --git a/qpid/cpp/src/qpid/Url.cpp b/qpid/cpp/src/qpid/Url.cpp index 840f46e928..21de32aaa3 100644 --- a/qpid/cpp/src/qpid/Url.cpp +++ b/qpid/cpp/src/qpid/Url.cpp @@ -64,19 +64,6 @@ class ProtocolTags { Url::Invalid::Invalid(const string& s) : Exception(s) {} -Url Url::getHostNameUrl(uint16_t port) { - Address address("tcp", std::string(), port); - if (!sys::SystemInfo::getLocalHostname(address)) - throw Url::Invalid(QPID_MSG("Cannot get host name: " << qpid::sys::strError(errno))); - return Url(address); -} - -Url Url::getIpAddressesUrl(uint16_t port) { - Url url; - sys::SystemInfo::getLocalIpAddresses(port, url); - return url; -} - string Url::str() const { if (cache.empty() && !this->empty()) { ostringstream os; diff --git a/qpid/cpp/src/qpid/broker/Broker.cpp b/qpid/cpp/src/qpid/broker/Broker.cpp index 8ec98e4fbe..a1169e073a 100644 --- a/qpid/cpp/src/qpid/broker/Broker.cpp +++ b/qpid/cpp/src/qpid/broker/Broker.cpp @@ -107,6 +107,14 @@ namespace _qmf = qmf::org::apache::qpid::broker; namespace qpid { namespace broker { +const std::string empty; +const std::string amq_direct("amq.direct"); +const std::string amq_topic("amq.topic"); +const std::string amq_fanout("amq.fanout"); +const std::string amq_match("amq.match"); +const std::string qpid_management("qpid.management"); +const std::string knownHostsNone("none"); + Broker::Options::Options(const std::string& name) : qpid::Options(name), noDataDir(0), @@ -124,6 +132,7 @@ Broker::Options::Options(const std::string& name) : queueLimit(100*1048576/*100M default limit*/), tcpNoDelay(false), requireEncrypted(false), + knownHosts(knownHostsNone), qmf2Support(true), qmf1Support(true), queueFlowStopRatio(80), @@ -182,14 +191,6 @@ Broker::Options::Options(const std::string& name) : ; } -const std::string empty; -const std::string amq_direct("amq.direct"); -const std::string amq_topic("amq.topic"); -const std::string amq_fanout("amq.fanout"); -const std::string amq_match("amq.match"); -const std::string qpid_management("qpid.management"); -const std::string knownHostsNone("none"); - namespace { // Arguments to declare a non-replicated exchange. framing::FieldTable noReplicateArgs() { @@ -355,13 +356,7 @@ Broker::Broker(const Broker::Options& conf) : queueCleaner.start(conf.queueCleanInterval * qpid::sys::TIME_SEC); } - //initialize known broker urls (TODO: add support for urls for other transports (SSL, RDMA)): - if (conf.knownHosts.empty()) { - boost::shared_ptr<ProtocolFactory> factory = getProtocolFactory(TCP_TRANSPORT); - if (factory) { - knownBrokers.push_back ( qpid::Url::getIpAddressesUrl ( factory->getPort() ) ); - } - } else if (conf.knownHosts != knownHostsNone) { + if (!conf.knownHosts.empty() && conf.knownHosts != knownHostsNone) { knownBrokers.push_back(Url(conf.knownHosts)); } diff --git a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp index cbff1effac..ea7f521f2b 100755 --- a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp +++ b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp @@ -77,51 +77,6 @@ inline bool isLoopback(const ::sockaddr* addr) { } } -void SystemInfo::getLocalIpAddresses (uint16_t port, - std::vector<Address> &addrList) { - ::ifaddrs* ifaddr = 0; - QPID_POSIX_CHECK(::getifaddrs(&ifaddr)); - for (::ifaddrs* ifap = ifaddr; ifap != 0; ifap = ifap->ifa_next) { - if (ifap->ifa_addr == 0) continue; - if (isLoopback(ifap->ifa_addr)) continue; - int family = ifap->ifa_addr->sa_family; - switch (family) { - case AF_INET6: { - // Ignore link local addresses as: - // * The scope id is illegal in URL syntax - // * Clients won't be able to use a link local address - // without adding their own (potentially different) scope id - sockaddr_in6* sa6 = (sockaddr_in6*)((void*)ifap->ifa_addr); - if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) break; - // Fallthrough - } - case AF_INET: { - char dispName[NI_MAXHOST]; - int rc = ::getnameinfo( - ifap->ifa_addr, - (family == AF_INET) - ? sizeof(struct sockaddr_in) - : sizeof(struct sockaddr_in6), - dispName, sizeof(dispName), - 0, 0, NI_NUMERICHOST); - if (rc != 0) { - throw QPID_POSIX_ERROR(rc); - } - string addr(dispName); - addrList.push_back(Address(TCP, addr, port)); - break; - } - default: - continue; - } - } - ::freeifaddrs(ifaddr); - - if (addrList.empty()) { - addrList.push_back(Address(TCP, LOOPBACK, port)); - } -} - namespace { inline socklen_t sa_len(::sockaddr* sa) { diff --git a/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp b/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp index d4b18e66c8..0e754e048b 100755 --- a/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp +++ b/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp @@ -60,31 +60,6 @@ bool SystemInfo::getLocalHostname(Address &address) { static const string LOCALHOST("127.0.0.1"); static const string TCP("tcp"); -void SystemInfo::getLocalIpAddresses(uint16_t port, - std::vector<Address> &addrList) { - int s = socket(PF_INET, SOCK_STREAM, 0); - for (int i=1;;i++) { - struct lifreq ifr; - ifr.lifr_index = i; - if (::ioctl(s, SIOCGIFADDR, &ifr) < 0) { - break; - } - struct sockaddr *sa = static_cast<struct sockaddr *>((void *) &ifr.lifr_addr); - if (sa->sa_family != AF_INET) { - // TODO: Url parsing currently can't cope with IPv6 addresses, defer for now - break; - } - struct sockaddr_in *sin = static_cast<struct sockaddr_in *>((void *)sa); - std::string addr(inet_ntoa(sin->sin_addr)); - if (addr != LOCALHOST) - addrList.push_back(Address(TCP, addr, port)); - } - if (addrList.empty()) { - addrList.push_back(Address(TCP, LOCALHOST, port)); - } - close (s); -} - void SystemInfo::getSystemId(std::string &osName, std::string &nodeName, std::string &release, diff --git a/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp b/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp index b3de8d947e..fb58d53b81 100755 --- a/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp +++ b/qpid/cpp/src/qpid/sys/windows/SystemInfo.cpp @@ -67,35 +67,6 @@ bool SystemInfo::getLocalHostname (Address &address) { static const std::string LOCALHOST("127.0.0.1"); static const std::string TCP("tcp"); -void SystemInfo::getLocalIpAddresses (uint16_t port, - std::vector<Address> &addrList) { - enum { MAX_URL_INTERFACES = 100 }; - - SOCKET s = socket (PF_INET, SOCK_STREAM, 0); - if (s != INVALID_SOCKET) { - INTERFACE_INFO interfaces[MAX_URL_INTERFACES]; - DWORD filledBytes = 0; - WSAIoctl (s, - SIO_GET_INTERFACE_LIST, - 0, - 0, - interfaces, - sizeof (interfaces), - &filledBytes, - 0, - 0); - unsigned int interfaceCount = filledBytes / sizeof (INTERFACE_INFO); - for (unsigned int i = 0; i < interfaceCount; ++i) { - if (interfaces[i].iiFlags & IFF_UP) { - std::string addr(inet_ntoa(interfaces[i].iiAddress.AddressIn.sin_addr)); - if (addr != LOCALHOST) - addrList.push_back(Address(TCP, addr, port)); - } - } - closesocket (s); - } -} - // Null function which always fails to find an network interface name bool SystemInfo::getInterfaceAddresses(const std::string&, std::vector<std::string>&) { |
