face: Configurable IP subnets for "local" TCP faces
Change-Id: Idaddfe4b2c304b552d2e132235f4c3d3e6c2ebcb
Refs: #4546
diff --git a/tests/daemon/face/tcp-channel-fixture.hpp b/tests/daemon/face/tcp-channel-fixture.hpp
index 732ad22..fa90735 100644
--- a/tests/daemon/face/tcp-channel-fixture.hpp
+++ b/tests/daemon/face/tcp-channel-fixture.hpp
@@ -27,6 +27,7 @@
#define NFD_TESTS_DAEMON_FACE_TCP_CHANNEL_FIXTURE_HPP
#include "face/tcp-channel.hpp"
+#include "core/network-predicate.hpp"
#include "channel-fixture.hpp"
@@ -37,13 +38,19 @@
class TcpChannelFixture : public ChannelFixture<TcpChannel, tcp::Endpoint>
{
protected:
+ TcpChannelFixture()
+ {
+ local.assign({{"subnet", "127.0.0.0/8"}, {"subnet", "::1/128"}}, {});
+ }
+
unique_ptr<TcpChannel>
makeChannel(const boost::asio::ip::address& addr, uint16_t port = 0) final
{
if (port == 0)
port = getNextPort();
- return make_unique<TcpChannel>(tcp::Endpoint(addr, port), false);
+ return make_unique<TcpChannel>(tcp::Endpoint(addr, port), false,
+ std::bind(&TcpChannelFixture::determineFaceScope, this, _1, _2));
}
void
@@ -61,8 +68,21 @@
});
}
+ ndn::nfd::FaceScope
+ determineFaceScope(const boost::asio::ip::address& localAddress,
+ const boost::asio::ip::address& remoteAddress)
+ {
+ if (local(localAddress) && local(remoteAddress)) {
+ return ndn::nfd::FACE_SCOPE_LOCAL;
+ }
+ else {
+ return ndn::nfd::FACE_SCOPE_NON_LOCAL;
+ }
+ }
+
protected:
std::vector<shared_ptr<Face>> clientFaces;
+ IpAddressPredicate local;
};
} // namespace tests