Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 2 | /* |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, Regents of the University of California, |
Alexander Afanasyev | 319f2c8 | 2015-01-07 14:56:53 -0800 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 24 | */ |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 25 | |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 26 | #include "ethernet-factory.hpp" |
Davide Pesavento | 35120ea | 2015-11-17 21:13:18 +0100 | [diff] [blame] | 27 | #include "generic-link-service.hpp" |
Davide Pesavento | 6bd6d0b | 2017-03-25 15:16:40 -0400 | [diff] [blame] | 28 | #include "multicast-ethernet-transport.hpp" |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 29 | #include <boost/range/adaptors.hpp> |
| 30 | #include <boost/range/algorithm/copy.hpp> |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 31 | |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 32 | namespace nfd { |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 33 | namespace face { |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 34 | |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 35 | NFD_LOG_INIT("EthernetFactory"); |
Junxiao Shi | b47247d | 2017-01-24 15:09:16 +0000 | [diff] [blame] | 36 | NFD_REGISTER_PROTOCOL_FACTORY(EthernetFactory); |
| 37 | |
| 38 | const std::string& |
| 39 | EthernetFactory::getId() |
| 40 | { |
| 41 | static std::string id("ether"); |
| 42 | return id; |
| 43 | } |
| 44 | |
Junxiao Shi | 0ba6d64 | 2017-07-17 00:53:22 +0000 | [diff] [blame] | 45 | EthernetFactory::EthernetFactory(const CtorParams& params) |
| 46 | : ProtocolFactory(params) |
| 47 | { |
| 48 | } |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 49 | |
| 50 | void |
| 51 | EthernetFactory::processConfig(OptionalConfigSection configSection, |
| 52 | FaceSystem::ConfigContext& context) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 53 | { |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 54 | // ether |
| 55 | // { |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 56 | // listen yes |
| 57 | // idle_timeout 600 |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 58 | // mcast yes |
| 59 | // mcast_group 01:00:5E:00:17:AA |
Teng Liang | bfea575 | 2017-03-29 04:51:10 +0000 | [diff] [blame] | 60 | // mcast_ad_hoc no |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 61 | // whitelist |
| 62 | // { |
| 63 | // * |
| 64 | // } |
| 65 | // blacklist |
| 66 | // { |
| 67 | // } |
| 68 | // } |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 69 | |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 70 | bool wantListen = true; |
| 71 | uint32_t idleTimeout = 600; |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 72 | MulticastConfig mcastConfig; |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 73 | |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 74 | if (configSection) { |
| 75 | // face_system.ether.mcast defaults to 'yes' but only if face_system.ether section is present |
| 76 | mcastConfig.isEnabled = true; |
Davide Pesavento | 35120ea | 2015-11-17 21:13:18 +0100 | [diff] [blame] | 77 | |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 78 | for (const auto& pair : *configSection) { |
| 79 | const std::string& key = pair.first; |
| 80 | const ConfigSection& value = pair.second; |
Davide Pesavento | 7726ae5 | 2014-11-23 21:01:05 +0100 | [diff] [blame] | 81 | |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 82 | if (key == "listen") { |
| 83 | wantListen = ConfigFile::parseYesNo(pair, "face_system.ether"); |
| 84 | } |
| 85 | else if (key == "idle_timeout") { |
| 86 | idleTimeout = ConfigFile::parseNumber<uint32_t>(pair, "face_system.ether"); |
| 87 | } |
| 88 | else if (key == "mcast") { |
| 89 | mcastConfig.isEnabled = ConfigFile::parseYesNo(pair, "face_system.ether"); |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 90 | } |
| 91 | else if (key == "mcast_group") { |
| 92 | const std::string& valueStr = value.get_value<std::string>(); |
| 93 | mcastConfig.group = ethernet::Address::fromString(valueStr); |
| 94 | if (mcastConfig.group.isNull()) { |
| 95 | BOOST_THROW_EXCEPTION(ConfigFile::Error("face_system.ether.mcast_group: '" + |
| 96 | valueStr + "' cannot be parsed as an Ethernet address")); |
| 97 | } |
| 98 | else if (!mcastConfig.group.isMulticast()) { |
| 99 | BOOST_THROW_EXCEPTION(ConfigFile::Error("face_system.ether.mcast_group: '" + |
| 100 | valueStr + "' is not a multicast address")); |
| 101 | } |
| 102 | } |
Teng Liang | bfea575 | 2017-03-29 04:51:10 +0000 | [diff] [blame] | 103 | else if (key == "mcast_ad_hoc") { |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 104 | bool wantAdHoc = ConfigFile::parseYesNo(pair, "face_system.ether"); |
Teng Liang | bfea575 | 2017-03-29 04:51:10 +0000 | [diff] [blame] | 105 | mcastConfig.linkType = wantAdHoc ? ndn::nfd::LINK_TYPE_AD_HOC : ndn::nfd::LINK_TYPE_MULTI_ACCESS; |
| 106 | } |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 107 | else if (key == "whitelist") { |
| 108 | mcastConfig.netifPredicate.parseWhitelist(value); |
| 109 | } |
| 110 | else if (key == "blacklist") { |
| 111 | mcastConfig.netifPredicate.parseBlacklist(value); |
| 112 | } |
| 113 | else { |
| 114 | BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.ether." + key)); |
| 115 | } |
| 116 | } |
| 117 | } |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 118 | |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 119 | if (!context.isDryRun) { |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 120 | if (configSection) { |
| 121 | providedSchemes.insert("ether"); |
| 122 | |
| 123 | // determine the interfaces on which channels should be created |
| 124 | auto netifs = context.listNetifs() | |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 125 | boost::adaptors::transformed([] (const NetworkInterfaceInfo& nii) { return nii.asNetworkInterface(); }) | |
| 126 | boost::adaptors::filtered([] (const shared_ptr<const ndn::net::NetworkInterface>& netif) { |
| 127 | return netif->isUp() && !netif->isLoopback(); |
| 128 | }); |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 129 | |
| 130 | // create channels |
| 131 | for (const auto& netif : netifs) { |
| 132 | auto channel = this->createChannel(netif, time::seconds(idleTimeout)); |
| 133 | if (wantListen && !channel->isListening()) { |
| 134 | try { |
Junxiao Shi | 2d49175 | 2017-07-14 21:32:05 +0000 | [diff] [blame] | 135 | channel->listen(this->addFace, nullptr); |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 136 | } |
| 137 | catch (const EthernetChannel::Error& e) { |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 138 | NFD_LOG_WARN("Cannot listen on " << netif->getName() << ": " << e.what()); |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 139 | } |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | else if (!m_channels.empty()) { |
| 144 | NFD_LOG_WARN("Cannot disable dev channels after initialization"); |
| 145 | } |
| 146 | |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 147 | if (m_mcastConfig.isEnabled != mcastConfig.isEnabled) { |
| 148 | if (mcastConfig.isEnabled) { |
| 149 | NFD_LOG_INFO("enabling multicast on " << mcastConfig.group); |
| 150 | } |
| 151 | else { |
| 152 | NFD_LOG_INFO("disabling multicast"); |
| 153 | } |
| 154 | } |
Teng Liang | bfea575 | 2017-03-29 04:51:10 +0000 | [diff] [blame] | 155 | else if (mcastConfig.isEnabled) { |
| 156 | if (m_mcastConfig.linkType != mcastConfig.linkType && !m_mcastFaces.empty()) { |
| 157 | NFD_LOG_WARN("Cannot change ad hoc setting on existing faces"); |
| 158 | } |
| 159 | if (m_mcastConfig.group != mcastConfig.group) { |
| 160 | NFD_LOG_INFO("changing multicast group from " << m_mcastConfig.group << |
| 161 | " to " << mcastConfig.group); |
| 162 | } |
| 163 | if (m_mcastConfig.netifPredicate != mcastConfig.netifPredicate) { |
| 164 | NFD_LOG_INFO("changing whitelist/blacklist"); |
| 165 | } |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Teng Liang | bfea575 | 2017-03-29 04:51:10 +0000 | [diff] [blame] | 168 | // Even if there's no configuration change, we still need to re-apply configuration because |
| 169 | // netifs may have changed. |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 170 | m_mcastConfig = mcastConfig; |
| 171 | this->applyConfig(context); |
| 172 | } |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 173 | } |
| 174 | |
Alexander Afanasyev | d665530 | 2014-02-28 08:41:28 -0800 | [diff] [blame] | 175 | void |
Eric Newberry | 944f38b | 2017-07-20 20:54:22 -0400 | [diff] [blame] | 176 | EthernetFactory::createFace(const CreateFaceParams& params, |
Alexander Afanasyev | d665530 | 2014-02-28 08:41:28 -0800 | [diff] [blame] | 177 | const FaceCreatedCallback& onCreated, |
Eric Newberry | 4260241 | 2016-08-27 09:33:18 -0700 | [diff] [blame] | 178 | const FaceCreationFailedCallback& onFailure) |
Alexander Afanasyev | d665530 | 2014-02-28 08:41:28 -0800 | [diff] [blame] | 179 | { |
Eric Newberry | 944f38b | 2017-07-20 20:54:22 -0400 | [diff] [blame] | 180 | BOOST_ASSERT(params.remoteUri.isCanonical()); |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 181 | |
Eric Newberry | 944f38b | 2017-07-20 20:54:22 -0400 | [diff] [blame] | 182 | if (!params.localUri || params.localUri->getScheme() != "dev") { |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 183 | NFD_LOG_TRACE("Cannot create unicast Ethernet face without dev:// LocalUri"); |
| 184 | onFailure(406, "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"); |
| 185 | return; |
| 186 | } |
Eric Newberry | 944f38b | 2017-07-20 20:54:22 -0400 | [diff] [blame] | 187 | BOOST_ASSERT(params.localUri->isCanonical()); |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 188 | |
Eric Newberry | 944f38b | 2017-07-20 20:54:22 -0400 | [diff] [blame] | 189 | if (params.persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) { |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 190 | NFD_LOG_TRACE("createFace does not support FACE_PERSISTENCY_ON_DEMAND"); |
| 191 | onFailure(406, "Outgoing Ethernet faces do not support on-demand persistency"); |
| 192 | return; |
| 193 | } |
| 194 | |
Eric Newberry | 944f38b | 2017-07-20 20:54:22 -0400 | [diff] [blame] | 195 | ethernet::Address remoteEndpoint(ethernet::Address::fromString(params.remoteUri.getHost())); |
| 196 | std::string localEndpoint(params.localUri->getHost()); |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 197 | |
| 198 | if (remoteEndpoint.isMulticast()) { |
| 199 | NFD_LOG_TRACE("createFace does not support multicast faces"); |
| 200 | onFailure(406, "Cannot create multicast Ethernet faces"); |
| 201 | return; |
| 202 | } |
| 203 | |
Eric Newberry | 944f38b | 2017-07-20 20:54:22 -0400 | [diff] [blame] | 204 | if (params.wantLocalFieldsEnabled) { |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 205 | // Ethernet faces are never local |
| 206 | NFD_LOG_TRACE("createFace cannot create non-local face with local fields enabled"); |
| 207 | onFailure(406, "Local fields can only be enabled on faces with local scope"); |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | for (const auto& i : m_channels) { |
| 212 | if (i.first == localEndpoint) { |
Eric Newberry | 944f38b | 2017-07-20 20:54:22 -0400 | [diff] [blame] | 213 | i.second->connect(remoteEndpoint, params.persistency, onCreated, onFailure); |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 214 | return; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | NFD_LOG_TRACE("No channels available to connect to " << remoteEndpoint); |
| 219 | onFailure(504, "No channels available to connect"); |
| 220 | } |
| 221 | |
| 222 | shared_ptr<EthernetChannel> |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 223 | EthernetFactory::createChannel(const shared_ptr<const ndn::net::NetworkInterface>& localEndpoint, |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 224 | time::nanoseconds idleTimeout) |
| 225 | { |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 226 | auto it = m_channels.find(localEndpoint->getName()); |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 227 | if (it != m_channels.end()) |
| 228 | return it->second; |
| 229 | |
| 230 | auto channel = std::make_shared<EthernetChannel>(localEndpoint, idleTimeout); |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 231 | m_channels[localEndpoint->getName()] = channel; |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 232 | |
| 233 | return channel; |
Alexander Afanasyev | d665530 | 2014-02-28 08:41:28 -0800 | [diff] [blame] | 234 | } |
| 235 | |
Davide Pesavento | 1d7e7af | 2015-10-10 23:54:08 +0200 | [diff] [blame] | 236 | std::vector<shared_ptr<const Channel>> |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 237 | EthernetFactory::getChannels() const |
| 238 | { |
Davide Pesavento | 46afec4 | 2017-05-28 14:28:47 -0400 | [diff] [blame] | 239 | return getChannelsFromMap(m_channels); |
Steve DiBenedetto | ef04f27 | 2014-06-04 14:28:31 -0600 | [diff] [blame] | 240 | } |
| 241 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 242 | shared_ptr<Face> |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 243 | EthernetFactory::createMulticastFace(const ndn::net::NetworkInterface& netif, |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 244 | const ethernet::Address& address) |
Davide Pesavento | 1d7e7af | 2015-10-10 23:54:08 +0200 | [diff] [blame] | 245 | { |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 246 | BOOST_ASSERT(address.isMulticast()); |
| 247 | |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 248 | auto key = std::make_pair(netif.getName(), address); |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 249 | auto found = m_mcastFaces.find(key); |
| 250 | if (found != m_mcastFaces.end()) { |
| 251 | return found->second; |
| 252 | } |
| 253 | |
Davide Pesavento | 8fd15e6 | 2017-04-06 19:58:54 -0400 | [diff] [blame] | 254 | GenericLinkService::Options opts; |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 255 | opts.allowFragmentation = true; |
| 256 | opts.allowReassembly = true; |
| 257 | |
Davide Pesavento | 8fd15e6 | 2017-04-06 19:58:54 -0400 | [diff] [blame] | 258 | auto linkService = make_unique<GenericLinkService>(opts); |
| 259 | auto transport = make_unique<MulticastEthernetTransport>(netif, address, m_mcastConfig.linkType); |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 260 | auto face = make_shared<Face>(std::move(linkService), std::move(transport)); |
| 261 | |
| 262 | m_mcastFaces[key] = face; |
| 263 | connectFaceClosedSignal(*face, [this, key] { m_mcastFaces.erase(key); }); |
| 264 | |
| 265 | return face; |
Davide Pesavento | 1d7e7af | 2015-10-10 23:54:08 +0200 | [diff] [blame] | 266 | } |
| 267 | |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 268 | void |
| 269 | EthernetFactory::applyConfig(const FaceSystem::ConfigContext& context) |
| 270 | { |
| 271 | // collect old faces |
| 272 | std::set<shared_ptr<Face>> oldFaces; |
| 273 | boost::copy(m_mcastFaces | boost::adaptors::map_values, |
| 274 | std::inserter(oldFaces, oldFaces.end())); |
| 275 | |
| 276 | if (m_mcastConfig.isEnabled) { |
| 277 | // determine interfaces on which faces should be created or retained |
| 278 | auto capableNetifs = context.listNetifs() | |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 279 | boost::adaptors::transformed([] (const NetworkInterfaceInfo& nii) { return nii.asNetworkInterface(); }) | |
| 280 | boost::adaptors::filtered([this] (const shared_ptr<const ndn::net::NetworkInterface>& netif) { |
| 281 | return netif->isUp() && netif->canMulticast() && m_mcastConfig.netifPredicate(*netif); |
| 282 | }); |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 283 | |
| 284 | // create faces |
| 285 | for (const auto& netif : capableNetifs) { |
| 286 | shared_ptr<Face> face; |
| 287 | try { |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 288 | face = this->createMulticastFace(*netif, m_mcastConfig.group); |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 289 | } |
| 290 | catch (const EthernetTransport::Error& e) { |
Junxiao Shi | 0d82d04 | 2017-07-07 06:15:27 +0000 | [diff] [blame] | 291 | NFD_LOG_WARN("Cannot create Ethernet multicast face on " << netif->getName() << ": " << e.what()); |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 292 | continue; |
| 293 | } |
| 294 | |
| 295 | if (face->getId() == face::INVALID_FACEID) { |
| 296 | // new face: register with forwarding |
Junxiao Shi | 2d49175 | 2017-07-14 21:32:05 +0000 | [diff] [blame] | 297 | this->addFace(face); |
Junxiao Shi | 7003c60 | 2017-01-10 13:35:28 +0000 | [diff] [blame] | 298 | } |
| 299 | else { |
| 300 | // existing face: don't destroy |
| 301 | oldFaces.erase(face); |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | // destroy old faces that are not needed in new configuration |
| 307 | for (const auto& face : oldFaces) { |
| 308 | face->close(); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | } // namespace face |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 313 | } // namespace nfd |