IfaceMgr::hasOpenSocket(const uint16_t family) const {
// Iterate over all interfaces and search for open sockets.
BOOST_FOREACH(IfacePtr iface, ifaces_) {
- const Iface::SocketCollection& sockets = iface->getSockets();
- for (Iface::SocketCollection::const_iterator sock = sockets.begin();
- sock != sockets.end(); ++sock) {
+ BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
// Check if the socket matches specified family.
- if (sock->family_ == family) {
+ if (sock.family_ == family) {
// There is at least one socket open, so return.
return (true);
}
IfaceMgr::hasOpenSocket(const IOAddress& addr) const {
// Iterate over all interfaces and search for open sockets.
BOOST_FOREACH(IfacePtr iface, ifaces_) {
- const Iface::SocketCollection& sockets = iface->getSockets();
- for (Iface::SocketCollection::const_iterator sock = sockets.begin();
- sock != sockets.end(); ++sock) {
+ BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
// Check if the socket address matches the specified address or
// if address is unspecified (in6addr_any).
- if (sock->addr_ == addr) {
+ if (sock.addr_ == addr) {
return (true);
- } else if (sock->addr_ == IOAddress("::")) {
+
+ } else if (sock.addr_ == IOAddress("::")) {
// Handle the case that the address is unspecified (any).
// In this case, we should check if the specified address
// belongs to any of the interfaces.
/// and then use its copy for select(). Please note that select() modifies
/// provided set to indicated which sockets have something to read.
BOOST_FOREACH(iface, ifaces_) {
- const Iface::SocketCollection& socket_collection = iface->getSockets();
- for (Iface::SocketCollection::const_iterator s = socket_collection.begin();
- s != socket_collection.end(); ++s) {
+ BOOST_FOREACH(SocketInfo s, iface->getSockets()) {
// Only deal with IPv4 addresses.
- if (s->addr_.isV4()) {
+ if (s.addr_.isV4()) {
// Add this socket to listening set
- FD_SET(s->sockfd_, &sockets);
- if (maxfd < s->sockfd_) {
- maxfd = s->sockfd_;
+ FD_SET(s.sockfd_, &sockets);
+ if (maxfd < s.sockfd_) {
+ maxfd = s.sockfd_;
}
}
}
// Let's find out which interface/socket has the data
BOOST_FOREACH(iface, ifaces_) {
- const Iface::SocketCollection& socket_collection = iface->getSockets();
- for (Iface::SocketCollection::const_iterator s = socket_collection.begin();
- s != socket_collection.end(); ++s) {
- if (FD_ISSET(s->sockfd_, &sockets)) {
- candidate = &(*s);
+ BOOST_FOREACH(SocketInfo s, iface->getSockets()) {
+ if (FD_ISSET(s.sockfd_, &sockets)) {
+ candidate = &(s);
break;
}
}
/// and then use its copy for select(). Please note that select() modifies
/// provided set to indicated which sockets have something to read.
BOOST_FOREACH(IfacePtr iface, ifaces_) {
- const Iface::SocketCollection& socket_collection = iface->getSockets();
- for (Iface::SocketCollection::const_iterator s = socket_collection.begin();
- s != socket_collection.end(); ++s) {
+ BOOST_FOREACH(SocketInfo s, iface->getSockets()) {
// Only deal with IPv6 addresses.
- if (s->addr_.isV6()) {
+ if (s.addr_.isV6()) {
// Add this socket to listening set
- FD_SET(s->sockfd_, &sockets);
- if (maxfd < s->sockfd_) {
- maxfd = s->sockfd_;
+ FD_SET(s.sockfd_, &sockets);
+ if (maxfd < s.sockfd_) {
+ maxfd = s.sockfd_;
}
}
}
// Let's find out which interface/socket has the data
BOOST_FOREACH(IfacePtr iface, ifaces_) {
- const Iface::SocketCollection& socket_collection = iface->getSockets();
- for (Iface::SocketCollection::const_iterator s = socket_collection.begin();
- s != socket_collection.end(); ++s) {
- if (FD_ISSET(s->sockfd_, &sockets)) {
- candidate = &(*s);
+ BOOST_FOREACH(SocketInfo s, iface->getSockets()) {
+ if (FD_ISSET(s.sockfd_, &sockets)) {
+ candidate = &(s);
break;
}
}
-// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
#include <dhcp/tests/pkt_filter_test_stub.h>
#include <dhcp/tests/pkt_filter6_test_stub.h>
+#include <boost/foreach.hpp>
+
using namespace isc::asiolink;
namespace isc {
isc_throw(Unexpected, "No such interface '" << iface_name << "'");
}
- const Iface::SocketCollection& sockets = iface->getSockets();
- for (Iface::SocketCollection::const_iterator sock = sockets.begin();
- sock != sockets.end(); ++sock) {
- if (sock->family_ == family) {
+ BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+ if (sock.family_ == family) {
return (true);
}
}
isc_throw(Unexpected, "No such interface '" << iface_name << "'");
}
- const Iface::SocketCollection& sockets = iface->getSockets();
- for (Iface::SocketCollection::const_iterator sock = sockets.begin();
- sock != sockets.end(); ++sock) {
- if ((sock->family_ == AF_INET) &&
- (sock->addr_ == IOAddress(address))) {
+ BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+ if ((sock.family_ == AF_INET) &&
+ (sock.addr_ == IOAddress(address))) {
return (true);
}
}
isc_throw(Unexpected, "No such interface '" << iface_name << "'");
}
- const Iface::SocketCollection& sockets = iface->getSockets();
- for (Iface::SocketCollection::const_iterator sock = sockets.begin();
- sock != sockets.end(); ++sock) {
- if ((!sock->addr_.isV6LinkLocal()) &&
- (!sock->addr_.isV6Multicast())) {
+ BOOST_FOREACH(SocketInfo sock, iface->getSockets()) {
+ if ((!sock.addr_.isV6LinkLocal()) &&
+ (!sock.addr_.isV6Multicast())) {
return (true);
}
}
-// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
#include <dhcp/pkt6.h>
#include <dhcp/tests/pkt_filter6_test_utils.h>
+#include <boost/foreach.hpp>
+
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
const uint16_t port, const bool) {
// Check if there is any other socket bound to the specified address
// and port on this interface.
- const Iface::SocketCollection& sockets = iface.getSockets();
- for (Iface::SocketCollection::const_iterator socket = sockets.begin();
- socket != sockets.end(); ++socket) {
- if ((socket->addr_ == addr) && (socket->port_ == port)) {
+ BOOST_FOREACH(SocketInfo socket, iface.getSockets()) {
+ if ((socket.addr_ == addr) && (socket.port_ == port)) {
isc_throw(SocketConfigError, "test socket bind error");
}
}