face: refactor handling of LinkType face trait
This commit also includes some cleanups, fixes EthernetFace to report
the correct LinkType, and makes (get|set)Description non-virtual.
Change-Id: I53909d7bfa02a92641b523a766359413c966aae6
Refs: #2563
diff --git a/tests/daemon/face/ethernet.t.cpp b/tests/daemon/face/ethernet.t.cpp
index 6f8218a..6b7a0bb 100644
--- a/tests/daemon/face/ethernet.t.cpp
+++ b/tests/daemon/face/ethernet.t.cpp
@@ -114,6 +114,7 @@
BOOST_REQUIRE(static_cast<bool>(face));
BOOST_CHECK_EQUAL(face->isLocal(), false);
BOOST_CHECK_EQUAL(face->isOnDemand(), false);
+ BOOST_CHECK_EQUAL(face->isMultiAccess(), true);
BOOST_CHECK_EQUAL(face->getRemoteUri().toString(),
"ether://[" + ethernet::getDefaultMulticastAddress().toString() + "]");
BOOST_CHECK_EQUAL(face->getLocalUri().toString(),
diff --git a/tests/daemon/face/tcp.t.cpp b/tests/daemon/face/tcp.t.cpp
index 70da6d1..ee2eb41 100644
--- a/tests/daemon/face/tcp.t.cpp
+++ b/tests/daemon/face/tcp.t.cpp
@@ -273,8 +273,10 @@
BOOST_REQUIRE(static_cast<bool>(face1));
BOOST_REQUIRE(static_cast<bool>(face2));
- BOOST_CHECK(face1->isOnDemand());
- BOOST_CHECK(!face2->isOnDemand());
+ BOOST_CHECK_EQUAL(face1->isOnDemand(), true);
+ BOOST_CHECK_EQUAL(face2->isOnDemand(), false);
+ BOOST_CHECK_EQUAL(face1->isMultiAccess(), false);
+ BOOST_CHECK_EQUAL(face2->isMultiAccess(), false);
BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "tcp4://127.0.0.1:20070");
BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "tcp4://127.0.0.1:20070");
diff --git a/tests/daemon/face/udp.t.cpp b/tests/daemon/face/udp.t.cpp
index 4d29e7d..44772ec 100644
--- a/tests/daemon/face/udp.t.cpp
+++ b/tests/daemon/face/udp.t.cpp
@@ -117,39 +117,26 @@
BOOST_CHECK_EQUAL(channel4->getUri().toString(), "udp6://[::1]:20071");
//same endpoint of a unicast channel
- BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp,
- "224.0.0.1",
- "20070"),
- UdpFactory::Error,
- isTheSameUnicastEndpoint);
+ BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp, "224.0.0.1", "20070"),
+ UdpFactory::Error, isTheSameUnicastEndpoint);
-
- shared_ptr<MulticastUdpFace> multicastFace1 = factory.createMulticastFace(interfaceIp,
- "224.0.0.1",
- "20072");
- shared_ptr<MulticastUdpFace> multicastFace1a = factory.createMulticastFace(interfaceIp,
- "224.0.0.1",
- "20072");
+ auto multicastFace1 = factory.createMulticastFace(interfaceIp, "224.0.0.1", "20072");
+ auto multicastFace1a = factory.createMulticastFace(interfaceIp, "224.0.0.1", "20072");
BOOST_CHECK_EQUAL(multicastFace1, multicastFace1a);
-
+ BOOST_CHECK_EQUAL(multicastFace1->isLocal(), false);
+ BOOST_CHECK_EQUAL(multicastFace1->isOnDemand(), false);
+ BOOST_CHECK_EQUAL(multicastFace1->isMultiAccess(), true);
//same endpoint of a multicast face
BOOST_CHECK_EXCEPTION(factory.createChannel(interfaceIp, "20072"),
- UdpFactory::Error,
- isTheSameMulticastEndpoint);
+ UdpFactory::Error, isTheSameMulticastEndpoint);
//same multicast endpoint, different group
- BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp,
- "224.0.0.42",
- "20072"),
- UdpFactory::Error,
- isLocalEndpointOnDifferentGroup);
+ BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp, "224.0.0.42", "20072"),
+ UdpFactory::Error, isLocalEndpointOnDifferentGroup);
- BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp,
- "192.168.10.15",
- "20025"),
- UdpFactory::Error,
- isNotMulticastAddress);
+ BOOST_CHECK_EXCEPTION(factory.createMulticastFace(interfaceIp, "192.168.10.15", "20025"),
+ UdpFactory::Error, isNotMulticastAddress);
// //Test commented because it required to be run in a machine that can resolve ipv6 query
@@ -581,6 +568,7 @@
limitedIo.run(1, time::milliseconds(100)); // 1 create (on channel2)
BOOST_REQUIRE(face2 != nullptr);
BOOST_CHECK_EQUAL(face2->isOnDemand(), false);
+ BOOST_CHECK_EQUAL(face2->isMultiAccess(), false);
// face2 sends to channel1, creates face1
shared_ptr<Interest> interest2 = makeInterest("/I2");
@@ -590,6 +578,7 @@
BOOST_CHECK_EQUAL(channel1->size(), 1);
BOOST_REQUIRE(face1 != nullptr);
BOOST_CHECK_EQUAL(face1->isOnDemand(), true);
+ BOOST_CHECK_EQUAL(face1->isMultiAccess(), false);
limitedIo.defer(time::seconds(1));
BOOST_CHECK_EQUAL(history1->failures.size(), 0); // face1 is not idle
diff --git a/tests/daemon/face/unix-stream.t.cpp b/tests/daemon/face/unix-stream.t.cpp
index a8390fb..a3a5488 100644
--- a/tests/daemon/face/unix-stream.t.cpp
+++ b/tests/daemon/face/unix-stream.t.cpp
@@ -188,7 +188,9 @@
"UnixStreamChannel error: cannot connect or cannot accept connection");
BOOST_REQUIRE(static_cast<bool>(face1));
-
+ BOOST_CHECK_EQUAL(face1->isLocal(), true);
+ BOOST_CHECK_EQUAL(face1->isOnDemand(), true);
+ BOOST_CHECK_EQUAL(face1->isMultiAccess(), false);
BOOST_CHECK_EQUAL(face1->getRemoteUri().getScheme(), "fd");
BOOST_CHECK_NO_THROW(boost::lexical_cast<int>(face1->getRemoteUri().getHost()));
std::string face1localUri = face1->getLocalUri().toString();
diff --git a/tests/daemon/face/websocket.t.cpp b/tests/daemon/face/websocket.t.cpp
index b83604e..75d552e 100644
--- a/tests/daemon/face/websocket.t.cpp
+++ b/tests/daemon/face/websocket.t.cpp
@@ -231,12 +231,11 @@
BOOST_CHECK_EQUAL(channel1->size(), 1);
- BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "ws://127.0.0.1:20070");
+ BOOST_REQUIRE(static_cast<bool>(face1));
+ BOOST_CHECK_EQUAL(face1->isLocal(), false);
BOOST_CHECK_EQUAL(face1->isOnDemand(), true);
-
- //BOOST_CHECK_EQUAL(face1->isLocal(), true);
-
- //BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face1)), false);
+ BOOST_CHECK_EQUAL(face1->isMultiAccess(), false);
+ BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "ws://127.0.0.1:20070");
shared_ptr<Interest> interest1 = makeInterest("ndn:/TpnzGvW9R");
shared_ptr<Data> data1 = makeData("ndn:/KfczhUqVix");