blob: 0ee45628072bcd342e8129eea56c5f291b4a0052 [file] [log] [blame]
Junxiao Shicde37ad2015-12-24 01:02:05 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi84d62cb2017-07-12 16:15:18 +00002/*
Davide Pesaventod7083a52023-10-19 17:51:16 -04003 * Copyright (c) 2014-2023, Regents of the University of California,
Junxiao Shicde37ad2015-12-24 01:02:05 -07004 * 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.
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/>.
24 */
25
26#include "face/ethernet-factory.hpp"
27
Junxiao Shi7003c602017-01-10 13:35:28 +000028#include "ethernet-fixture.hpp"
29#include "face-system-fixture.hpp"
Junxiao Shi79a92082017-08-08 02:40:59 +000030#include "factory-test-common.hpp"
Davide Pesaventob15276f2017-07-15 16:27:13 -040031
Junxiao Shi7003c602017-01-10 13:35:28 +000032#include <boost/algorithm/string/replace.hpp>
Junxiao Shicde37ad2015-12-24 01:02:05 -070033
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040034namespace nfd::tests {
35
36using face::EthernetFactory;
Junxiao Shicde37ad2015-12-24 01:02:05 -070037
Junxiao Shi0ba6d642017-07-17 00:53:22 +000038class EthernetFactoryFixture : public EthernetFixture
39 , public FaceSystemFactoryFixture<EthernetFactory>
Junxiao Shi7003c602017-01-10 13:35:28 +000040{
Junxiao Shi0ba6d642017-07-17 00:53:22 +000041protected:
Junxiao Shi79a92082017-08-08 02:40:59 +000042 EthernetFactoryFixture()
43 {
44 this->copyRealNetifsToNetmon();
45 }
46
Davide Pesaventob15276f2017-07-15 16:27:13 -040047 std::set<std::string>
48 listUrisOfAvailableNetifs() const
49 {
50 std::set<std::string> uris;
51 std::transform(netifs.begin(), netifs.end(), std::inserter(uris, uris.end()),
Davide Pesaventod7083a52023-10-19 17:51:16 -040052 [] (const auto& netif) { return FaceUri::fromDev(netif->getName()).toString(); });
Davide Pesaventob15276f2017-07-15 16:27:13 -040053 return uris;
54 }
55
Junxiao Shi7003c602017-01-10 13:35:28 +000056 std::vector<const Face*>
Teng Liangbfea5752017-03-29 04:51:10 +000057 listEtherMcastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
Junxiao Shi7003c602017-01-10 13:35:28 +000058 {
Davide Pesaventod7083a52023-10-19 17:51:16 -040059 return listFacesByScheme("ether", linkType);
Junxiao Shi7003c602017-01-10 13:35:28 +000060 }
61
62 size_t
Teng Liangbfea5752017-03-29 04:51:10 +000063 countEtherMcastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
Junxiao Shi7003c602017-01-10 13:35:28 +000064 {
Davide Pesaventod7083a52023-10-19 17:51:16 -040065 return listEtherMcastFaces(linkType).size();
Junxiao Shi7003c602017-01-10 13:35:28 +000066 }
67};
68
Junxiao Shi0ba6d642017-07-17 00:53:22 +000069BOOST_AUTO_TEST_SUITE(Face)
70BOOST_FIXTURE_TEST_SUITE(TestEthernetFactory, EthernetFactoryFixture)
71
Junxiao Shi0ba6d642017-07-17 00:53:22 +000072BOOST_AUTO_TEST_SUITE(ProcessConfig)
Junxiao Shi7003c602017-01-10 13:35:28 +000073
Davide Pesavento494a9552018-02-04 22:16:05 -050074BOOST_AUTO_TEST_CASE(Defaults)
Junxiao Shi7003c602017-01-10 13:35:28 +000075{
76 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
77
78 const std::string CONFIG = R"CONFIG(
79 face_system
80 {
81 ether
82 {
Davide Pesaventob15276f2017-07-15 16:27:13 -040083 mcast no
84 }
85 }
86 )CONFIG";
87
88 parseConfig(CONFIG, true);
89 parseConfig(CONFIG, false);
90
Davide Pesaventob15276f2017-07-15 16:27:13 -040091 checkChannelListEqual(factory, this->listUrisOfAvailableNetifs());
Davide Pesavento494a9552018-02-04 22:16:05 -050092 auto channels = factory.getChannels();
93 BOOST_CHECK(std::all_of(channels.begin(), channels.end(),
Davide Pesaventod27841b2018-11-13 00:22:24 -050094 [] (const auto& ch) { return ch->isListening(); }));
Davide Pesaventob15276f2017-07-15 16:27:13 -040095 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
96}
97
Davide Pesavento494a9552018-02-04 22:16:05 -050098BOOST_AUTO_TEST_CASE(DisableListen)
Davide Pesaventob15276f2017-07-15 16:27:13 -040099{
100 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
101
102 const std::string CONFIG = R"CONFIG(
103 face_system
104 {
105 ether
106 {
107 listen no
108 idle_timeout 60
109 mcast no
110 }
111 }
112 )CONFIG";
113
114 parseConfig(CONFIG, true);
115 parseConfig(CONFIG, false);
116
Davide Pesaventob15276f2017-07-15 16:27:13 -0400117 checkChannelListEqual(factory, this->listUrisOfAvailableNetifs());
Davide Pesavento494a9552018-02-04 22:16:05 -0500118 auto channels = factory.getChannels();
119 BOOST_CHECK(std::none_of(channels.begin(), channels.end(),
Davide Pesaventod27841b2018-11-13 00:22:24 -0500120 [] (const auto& ch) { return ch->isListening(); }));
Davide Pesaventob15276f2017-07-15 16:27:13 -0400121 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
122}
123
Davide Pesaventob15276f2017-07-15 16:27:13 -0400124BOOST_AUTO_TEST_CASE(McastNormal)
125{
126 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
127
128 const std::string CONFIG = R"CONFIG(
129 face_system
130 {
131 ether
132 {
133 listen no
Junxiao Shi7003c602017-01-10 13:35:28 +0000134 mcast yes
135 mcast_group 01:00:5E:00:17:AA
Teng Liangbfea5752017-03-29 04:51:10 +0000136 mcast_ad_hoc no
Junxiao Shi7003c602017-01-10 13:35:28 +0000137 whitelist
138 {
139 *
140 }
141 blacklist
142 {
143 }
144 }
145 }
146 )CONFIG";
147
Junxiao Shi1b65ca12017-01-21 23:04:41 +0000148 parseConfig(CONFIG, true);
149 parseConfig(CONFIG, false);
Junxiao Shi7003c602017-01-10 13:35:28 +0000150
151 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), netifs.size());
Alexander Afanasyev3a2339a2020-05-27 23:05:06 -0400152 for (const auto& face : this->listEtherMcastFaces()) {
153 BOOST_REQUIRE(face->getChannel().lock());
154 // not universal, but for Ethernet, local URI of a mcast face matches URI of the associated channel
155 BOOST_CHECK_EQUAL(face->getLocalUri(), face->getChannel().lock()->getUri());
156 }
Junxiao Shi7003c602017-01-10 13:35:28 +0000157}
158
Teng Liangbfea5752017-03-29 04:51:10 +0000159BOOST_AUTO_TEST_CASE(EnableDisableMcast)
Junxiao Shi7003c602017-01-10 13:35:28 +0000160{
Teng Liangbfea5752017-03-29 04:51:10 +0000161 const std::string CONFIG_WITH_MCAST = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000162 face_system
163 {
Teng Liangbfea5752017-03-29 04:51:10 +0000164 ether
165 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400166 listen no
Teng Liangbfea5752017-03-29 04:51:10 +0000167 mcast yes
168 }
169 }
170 )CONFIG";
171 const std::string CONFIG_WITHOUT_MCAST = R"CONFIG(
172 face_system
173 {
174 ether
175 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400176 listen no
Teng Liangbfea5752017-03-29 04:51:10 +0000177 mcast no
178 }
Junxiao Shi7003c602017-01-10 13:35:28 +0000179 }
180 )CONFIG";
181
Teng Liangbfea5752017-03-29 04:51:10 +0000182 parseConfig(CONFIG_WITHOUT_MCAST, false);
Junxiao Shi7003c602017-01-10 13:35:28 +0000183 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
Teng Liangbfea5752017-03-29 04:51:10 +0000184
185 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
186
187 parseConfig(CONFIG_WITH_MCAST, false);
188 g_io.poll();
189 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), netifs.size());
190
191 parseConfig(CONFIG_WITHOUT_MCAST, false);
192 g_io.poll();
193 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
194}
195
196BOOST_AUTO_TEST_CASE(McastAdHoc)
197{
198 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
199
200 const std::string CONFIG = R"CONFIG(
201 face_system
202 {
203 ether
204 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400205 listen no
206 mcast yes
Teng Liangbfea5752017-03-29 04:51:10 +0000207 mcast_ad_hoc yes
208 }
209 }
210 )CONFIG";
211
212 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400213 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(ndn::nfd::LINK_TYPE_MULTI_ACCESS), 0);
Teng Liangbfea5752017-03-29 04:51:10 +0000214 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(ndn::nfd::LINK_TYPE_AD_HOC), netifs.size());
215}
216
217BOOST_AUTO_TEST_CASE(ChangeMcastGroup)
218{
219 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
220
221 const std::string CONFIG1 = R"CONFIG(
222 face_system
223 {
224 ether
225 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400226 mcast_group 01:00:5e:90:10:01
Teng Liangbfea5752017-03-29 04:51:10 +0000227 }
228 }
229 )CONFIG";
230 const std::string CONFIG2 = R"CONFIG(
231 face_system
232 {
233 ether
234 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400235 mcast_group 01:00:5e:90:10:02
Teng Liangbfea5752017-03-29 04:51:10 +0000236 }
237 }
238 )CONFIG";
239
240 parseConfig(CONFIG1, false);
241 auto etherMcastFaces = this->listEtherMcastFaces();
242 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), netifs.size());
243 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getRemoteUri(),
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400244 FaceUri(ethernet::Address{0x01, 0x00, 0x5e, 0x90, 0x10, 0x01}));
Teng Liangbfea5752017-03-29 04:51:10 +0000245
246 parseConfig(CONFIG2, false);
247 g_io.poll();
248 etherMcastFaces = this->listEtherMcastFaces();
249 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), netifs.size());
250 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getRemoteUri(),
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400251 FaceUri(ethernet::Address{0x01, 0x00, 0x5e, 0x90, 0x10, 0x02}));
Junxiao Shi7003c602017-01-10 13:35:28 +0000252}
253
254BOOST_AUTO_TEST_CASE(Whitelist)
255{
256 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
257
258 std::string CONFIG = R"CONFIG(
259 face_system
260 {
261 ether
262 {
263 whitelist
264 {
265 ifname %ifname
266 }
267 }
268 }
269 )CONFIG";
Davide Pesaventob15276f2017-07-15 16:27:13 -0400270 auto ifname = netifs.front()->getName();
271 boost::replace_first(CONFIG, "%ifname", ifname);
Junxiao Shi7003c602017-01-10 13:35:28 +0000272
Junxiao Shi1b65ca12017-01-21 23:04:41 +0000273 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400274
Junxiao Shi7003c602017-01-10 13:35:28 +0000275 auto etherMcastFaces = this->listEtherMcastFaces();
276 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), 1);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400277 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getLocalUri(), FaceUri::fromDev(ifname));
Junxiao Shi7003c602017-01-10 13:35:28 +0000278}
279
280BOOST_AUTO_TEST_CASE(Blacklist)
281{
282 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
283
284 std::string CONFIG = R"CONFIG(
285 face_system
286 {
287 ether
288 {
289 blacklist
290 {
291 ifname %ifname
292 }
293 }
294 }
295 )CONFIG";
Davide Pesaventob15276f2017-07-15 16:27:13 -0400296 auto ifname = netifs.front()->getName();
297 boost::replace_first(CONFIG, "%ifname", ifname);
Junxiao Shi7003c602017-01-10 13:35:28 +0000298
Junxiao Shi1b65ca12017-01-21 23:04:41 +0000299 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400300
Junxiao Shi7003c602017-01-10 13:35:28 +0000301 auto etherMcastFaces = this->listEtherMcastFaces();
302 BOOST_CHECK_EQUAL(etherMcastFaces.size(), netifs.size() - 1);
Davide Pesavento494a9552018-02-04 22:16:05 -0500303 BOOST_CHECK(std::none_of(etherMcastFaces.begin(), etherMcastFaces.end(),
Davide Pesaventod7083a52023-10-19 17:51:16 -0400304 [uri = FaceUri::fromDev(ifname)] (const auto* face) {
305 return face->getLocalUri() == uri;
306 }));
Junxiao Shi7003c602017-01-10 13:35:28 +0000307}
308
Teng Liangbfea5752017-03-29 04:51:10 +0000309BOOST_AUTO_TEST_CASE(Omitted)
Junxiao Shi7003c602017-01-10 13:35:28 +0000310{
Teng Liangbfea5752017-03-29 04:51:10 +0000311 const std::string CONFIG = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000312 face_system
313 {
Junxiao Shi7003c602017-01-10 13:35:28 +0000314 }
315 )CONFIG";
316
Teng Liangbfea5752017-03-29 04:51:10 +0000317 parseConfig(CONFIG, true);
318 parseConfig(CONFIG, false);
319
Junxiao Shi7003c602017-01-10 13:35:28 +0000320 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
Junxiao Shi7003c602017-01-10 13:35:28 +0000321}
322
Davide Pesavento494a9552018-02-04 22:16:05 -0500323BOOST_AUTO_TEST_CASE(BadListen)
324{
325 const std::string CONFIG = R"CONFIG(
326 face_system
327 {
328 ether
329 {
330 listen hello
331 }
332 }
333 )CONFIG";
334
335 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
336 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
337}
338
Davide Pesavento494a9552018-02-04 22:16:05 -0500339BOOST_AUTO_TEST_CASE(BadIdleTimeout)
340{
341 // not a number
342 const std::string CONFIG1 = R"CONFIG(
343 face_system
344 {
345 ether
346 {
347 idle_timeout hello
348 }
349 }
350 )CONFIG";
351
352 BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
353 BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
354
355 // negative number
356 const std::string CONFIG2 = R"CONFIG(
357 face_system
358 {
359 ether
360 {
361 idle_timeout -15
362 }
363 }
364 )CONFIG";
365
366 BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
367 BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
368}
369
Junxiao Shi7003c602017-01-10 13:35:28 +0000370BOOST_AUTO_TEST_CASE(BadMcast)
371{
372 const std::string CONFIG = R"CONFIG(
373 face_system
374 {
375 ether
376 {
377 mcast hello
378 }
379 }
380 )CONFIG";
381
382 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
383 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
384}
385
386BOOST_AUTO_TEST_CASE(BadMcastGroup)
387{
Davide Pesavento494a9552018-02-04 22:16:05 -0500388 // not an address
389 const std::string CONFIG1 = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000390 face_system
391 {
392 ether
393 {
Junxiao Shi7003c602017-01-10 13:35:28 +0000394 mcast_group hello
395 }
396 }
397 )CONFIG";
398
Davide Pesavento494a9552018-02-04 22:16:05 -0500399 BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
400 BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
Junxiao Shi7003c602017-01-10 13:35:28 +0000401
Davide Pesavento494a9552018-02-04 22:16:05 -0500402 // non-multicast address
403 const std::string CONFIG2 = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000404 face_system
405 {
406 ether
407 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400408 mcast_group 00:00:5e:00:53:5e
Junxiao Shi7003c602017-01-10 13:35:28 +0000409 }
410 }
411 )CONFIG";
412
Davide Pesavento494a9552018-02-04 22:16:05 -0500413 BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
414 BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
Junxiao Shi7003c602017-01-10 13:35:28 +0000415}
416
417BOOST_AUTO_TEST_CASE(UnknownOption)
418{
419 const std::string CONFIG = R"CONFIG(
420 face_system
421 {
422 ether
423 {
424 hello
425 }
426 }
427 )CONFIG";
428
429 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
430 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
431}
432
433BOOST_AUTO_TEST_SUITE_END() // ProcessConfig
Junxiao Shicde37ad2015-12-24 01:02:05 -0700434
435BOOST_AUTO_TEST_CASE(GetChannels)
436{
Davide Pesaventob15276f2017-07-15 16:27:13 -0400437 BOOST_CHECK_EQUAL(factory.getChannels().empty(), true);
Davide Pesaventod7083a52023-10-19 17:51:16 -0400438
Davide Pesaventob15276f2017-07-15 16:27:13 -0400439 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
440
Davide Pesavento14e71f02019-03-28 17:35:25 -0400441 factory.createChannel(netifs.front(), 1_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400442 checkChannelListEqual(factory, {FaceUri::fromDev(netifs.front()->getName()).toString()});
Junxiao Shicde37ad2015-12-24 01:02:05 -0700443}
444
Davide Pesaventob15276f2017-07-15 16:27:13 -0400445BOOST_AUTO_TEST_CASE(CreateChannel)
446{
447 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
448
Davide Pesavento14e71f02019-03-28 17:35:25 -0400449 auto channel1 = factory.createChannel(netifs.front(), 1_min);
450 auto channel1a = factory.createChannel(netifs.front(), 5_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400451 BOOST_CHECK_EQUAL(channel1, channel1a);
452 BOOST_CHECK_EQUAL(channel1->getUri().toString(), "dev://" + netifs.front()->getName());
453
454 SKIP_IF_ETHERNET_NETIF_COUNT_LT(2);
455
Davide Pesavento14e71f02019-03-28 17:35:25 -0400456 auto channel2 = factory.createChannel(netifs.back(), 1_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400457 BOOST_CHECK_NE(channel1, channel2);
458}
459
460BOOST_AUTO_TEST_CASE(CreateFace)
461{
462 createFace(factory,
463 FaceUri("ether://[00:00:5e:00:53:5e]"),
464 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700465 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400466 {CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
467
468 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
Davide Pesavento14e71f02019-03-28 17:35:25 -0400469 auto localUri = factory.createChannel(netifs.front(), 1_min)->getUri();
Davide Pesaventob15276f2017-07-15 16:27:13 -0400470
471 createFace(factory,
472 FaceUri("ether://[00:00:5e:00:53:5e]"),
473 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700474 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400475 {CreateFaceExpectedResult::SUCCESS, 0, ""});
476
477 createFace(factory,
478 FaceUri("ether://[00:00:5e:00:53:5e]"),
479 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700480 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400481 {CreateFaceExpectedResult::SUCCESS, 0, ""});
482
483 createFace(factory,
484 FaceUri("ether://[00:00:5e:00:53:53]"),
485 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700486 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, false},
Eric Newberry2642cd22017-07-13 21:34:53 -0400487 {CreateFaceExpectedResult::SUCCESS, 0, ""});
488
489 createFace(factory,
490 FaceUri("ether://[00:00:5e:00:53:57]"),
491 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700492 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, true, false},
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700493 {CreateFaceExpectedResult::SUCCESS, 0, ""});
494
495 createFace(factory,
496 FaceUri("ether://[00:00:5e:00:53:5b]"),
497 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700498 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, true},
499 {CreateFaceExpectedResult::SUCCESS, 0, ""});
500
501 createFace(factory,
502 FaceUri("ether://[00:00:5e:00:53:5c]"),
503 localUri,
504 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, 1000, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400505 {CreateFaceExpectedResult::SUCCESS, 0, ""});
506}
507
508BOOST_AUTO_TEST_CASE(UnsupportedCreateFace)
Junxiao Shicde37ad2015-12-24 01:02:05 -0700509{
Eric Newberry42602412016-08-27 09:33:18 -0700510 createFace(factory,
Davide Pesavento46afec42017-05-28 14:28:47 -0400511 FaceUri("ether://[00:00:5e:00:53:5e]"),
Eric Newberry78e32b02017-04-01 14:34:44 +0000512 {},
Eric Newberry812d6152018-06-06 15:06:01 -0700513 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400514 {CreateFaceExpectedResult::FAILURE, 406,
515 "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
516
517 createFace(factory,
518 FaceUri("ether://[00:00:5e:00:53:5e]"),
519 FaceUri("udp4://127.0.0.1:20071"),
Eric Newberry812d6152018-06-06 15:06:01 -0700520 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400521 {CreateFaceExpectedResult::FAILURE, 406,
522 "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
523
524 createFace(factory,
525 FaceUri("ether://[00:00:5e:00:53:5e]"),
526 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700527 {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400528 {CreateFaceExpectedResult::FAILURE, 406,
529 "Outgoing Ethernet faces do not support on-demand persistency"});
530
531 createFace(factory,
532 FaceUri("ether://[01:00:5e:90:10:5e]"),
533 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700534 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400535 {CreateFaceExpectedResult::FAILURE, 406,
536 "Cannot create multicast Ethernet faces"});
537
538 createFace(factory,
539 FaceUri("ether://[00:00:5e:00:53:5e]"),
540 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700541 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, true, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400542 {CreateFaceExpectedResult::FAILURE, 406,
543 "Local fields can only be enabled on faces with local scope"});
Junxiao Shicde37ad2015-12-24 01:02:05 -0700544}
545
546BOOST_AUTO_TEST_SUITE_END() // TestEthernetFactory
547BOOST_AUTO_TEST_SUITE_END() // Face
548
Davide Pesaventoe422f9e2022-06-03 01:30:23 -0400549} // namespace nfd::tests