face: set EthernetTransport UP/DOWN based on netif state
refs #3352
Change-Id: I24476ee293d229cd9222996f91f31cfb15728c47
diff --git a/daemon/face/ethernet-transport.cpp b/daemon/face/ethernet-transport.cpp
index 7d1f7cb..412bcba 100644
--- a/daemon/face/ethernet-transport.cpp
+++ b/daemon/face/ethernet-transport.cpp
@@ -58,6 +58,11 @@
BOOST_THROW_EXCEPTION(Error(e.what()));
}
+ m_netifStateConn = localEndpoint.onStateChanged.connect(
+ [=] (ndn::net::InterfaceState, ndn::net::InterfaceState newState) {
+ handleNetifStateChange(newState);
+ });
+
asyncRead();
}
@@ -83,6 +88,20 @@
}
void
+EthernetTransport::handleNetifStateChange(ndn::net::InterfaceState netifState)
+{
+ NFD_LOG_FACE_TRACE("netif is " << netifState);
+ if (netifState == ndn::net::InterfaceState::RUNNING) {
+ if (getState() == TransportState::DOWN) {
+ this->setState(TransportState::UP);
+ }
+ }
+ else if (getState() == TransportState::UP) {
+ this->setState(TransportState::DOWN);
+ }
+}
+
+void
EthernetTransport::doSend(Transport::Packet&& packet)
{
NFD_LOG_FACE_TRACE(__func__);