blob: 269c79ffe3f06fb5a488bab8d5e0fe09099a74bc [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/*
Eric Newberrycb27d912020-04-08 19:38:18 -07003 * Copyright (c) 2014-2020, 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
34namespace nfd {
Junxiao Shi7003c602017-01-10 13:35:28 +000035namespace face {
Junxiao Shicde37ad2015-12-24 01:02:05 -070036namespace tests {
37
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 Pesaventod27841b2018-11-13 00:22:24 -050052 [] (const auto& netif) {
53 return FaceUri::fromDev(netif->getName()).toString();
Davide Pesaventob15276f2017-07-15 16:27:13 -040054 });
55 return uris;
56 }
57
Junxiao Shi7003c602017-01-10 13:35:28 +000058 std::vector<const Face*>
Teng Liangbfea5752017-03-29 04:51:10 +000059 listEtherMcastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
Junxiao Shi7003c602017-01-10 13:35:28 +000060 {
Teng Liangbfea5752017-03-29 04:51:10 +000061 return this->listFacesByScheme("ether", linkType);
Junxiao Shi7003c602017-01-10 13:35:28 +000062 }
63
64 size_t
Teng Liangbfea5752017-03-29 04:51:10 +000065 countEtherMcastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
Junxiao Shi7003c602017-01-10 13:35:28 +000066 {
Teng Liangbfea5752017-03-29 04:51:10 +000067 return this->listEtherMcastFaces(linkType).size();
Junxiao Shi7003c602017-01-10 13:35:28 +000068 }
69};
70
Junxiao Shi0ba6d642017-07-17 00:53:22 +000071BOOST_AUTO_TEST_SUITE(Face)
72BOOST_FIXTURE_TEST_SUITE(TestEthernetFactory, EthernetFactoryFixture)
73
Junxiao Shi0ba6d642017-07-17 00:53:22 +000074BOOST_AUTO_TEST_SUITE(ProcessConfig)
Junxiao Shi7003c602017-01-10 13:35:28 +000075
Davide Pesavento494a9552018-02-04 22:16:05 -050076BOOST_AUTO_TEST_CASE(Defaults)
Junxiao Shi7003c602017-01-10 13:35:28 +000077{
78 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
79
80 const std::string CONFIG = R"CONFIG(
81 face_system
82 {
83 ether
84 {
Davide Pesaventob15276f2017-07-15 16:27:13 -040085 mcast no
86 }
87 }
88 )CONFIG";
89
90 parseConfig(CONFIG, true);
91 parseConfig(CONFIG, false);
92
Davide Pesaventob15276f2017-07-15 16:27:13 -040093 checkChannelListEqual(factory, this->listUrisOfAvailableNetifs());
Davide Pesavento494a9552018-02-04 22:16:05 -050094 auto channels = factory.getChannels();
95 BOOST_CHECK(std::all_of(channels.begin(), channels.end(),
Davide Pesaventod27841b2018-11-13 00:22:24 -050096 [] (const auto& ch) { return ch->isListening(); }));
Davide Pesaventob15276f2017-07-15 16:27:13 -040097 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
98}
99
Davide Pesavento494a9552018-02-04 22:16:05 -0500100BOOST_AUTO_TEST_CASE(DisableListen)
Davide Pesaventob15276f2017-07-15 16:27:13 -0400101{
102 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
103
104 const std::string CONFIG = R"CONFIG(
105 face_system
106 {
107 ether
108 {
109 listen no
110 idle_timeout 60
111 mcast no
112 }
113 }
114 )CONFIG";
115
116 parseConfig(CONFIG, true);
117 parseConfig(CONFIG, false);
118
Davide Pesaventob15276f2017-07-15 16:27:13 -0400119 checkChannelListEqual(factory, this->listUrisOfAvailableNetifs());
Davide Pesavento494a9552018-02-04 22:16:05 -0500120 auto channels = factory.getChannels();
121 BOOST_CHECK(std::none_of(channels.begin(), channels.end(),
Davide Pesaventod27841b2018-11-13 00:22:24 -0500122 [] (const auto& ch) { return ch->isListening(); }));
Davide Pesaventob15276f2017-07-15 16:27:13 -0400123 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
124}
125
Davide Pesaventob15276f2017-07-15 16:27:13 -0400126BOOST_AUTO_TEST_CASE(McastNormal)
127{
128 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
129
130 const std::string CONFIG = R"CONFIG(
131 face_system
132 {
133 ether
134 {
135 listen no
Junxiao Shi7003c602017-01-10 13:35:28 +0000136 mcast yes
137 mcast_group 01:00:5E:00:17:AA
Teng Liangbfea5752017-03-29 04:51:10 +0000138 mcast_ad_hoc no
Junxiao Shi7003c602017-01-10 13:35:28 +0000139 whitelist
140 {
141 *
142 }
143 blacklist
144 {
145 }
146 }
147 }
148 )CONFIG";
149
Junxiao Shi1b65ca12017-01-21 23:04:41 +0000150 parseConfig(CONFIG, true);
151 parseConfig(CONFIG, false);
Junxiao Shi7003c602017-01-10 13:35:28 +0000152
153 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), netifs.size());
Alexander Afanasyev3a2339a2020-05-27 23:05:06 -0400154 for (const auto& face : this->listEtherMcastFaces()) {
155 BOOST_REQUIRE(face->getChannel().lock());
156 // not universal, but for Ethernet, local URI of a mcast face matches URI of the associated channel
157 BOOST_CHECK_EQUAL(face->getLocalUri(), face->getChannel().lock()->getUri());
158 }
Junxiao Shi7003c602017-01-10 13:35:28 +0000159}
160
Teng Liangbfea5752017-03-29 04:51:10 +0000161BOOST_AUTO_TEST_CASE(EnableDisableMcast)
Junxiao Shi7003c602017-01-10 13:35:28 +0000162{
Teng Liangbfea5752017-03-29 04:51:10 +0000163 const std::string CONFIG_WITH_MCAST = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000164 face_system
165 {
Teng Liangbfea5752017-03-29 04:51:10 +0000166 ether
167 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400168 listen no
Teng Liangbfea5752017-03-29 04:51:10 +0000169 mcast yes
170 }
171 }
172 )CONFIG";
173 const std::string CONFIG_WITHOUT_MCAST = R"CONFIG(
174 face_system
175 {
176 ether
177 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400178 listen no
Teng Liangbfea5752017-03-29 04:51:10 +0000179 mcast no
180 }
Junxiao Shi7003c602017-01-10 13:35:28 +0000181 }
182 )CONFIG";
183
Teng Liangbfea5752017-03-29 04:51:10 +0000184 parseConfig(CONFIG_WITHOUT_MCAST, false);
Junxiao Shi7003c602017-01-10 13:35:28 +0000185 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
Teng Liangbfea5752017-03-29 04:51:10 +0000186
187 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
188
189 parseConfig(CONFIG_WITH_MCAST, false);
190 g_io.poll();
191 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), netifs.size());
192
193 parseConfig(CONFIG_WITHOUT_MCAST, false);
194 g_io.poll();
195 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
196}
197
198BOOST_AUTO_TEST_CASE(McastAdHoc)
199{
200 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
201
202 const std::string CONFIG = R"CONFIG(
203 face_system
204 {
205 ether
206 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400207 listen no
208 mcast yes
Teng Liangbfea5752017-03-29 04:51:10 +0000209 mcast_ad_hoc yes
210 }
211 }
212 )CONFIG";
213
214 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400215 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(ndn::nfd::LINK_TYPE_MULTI_ACCESS), 0);
Teng Liangbfea5752017-03-29 04:51:10 +0000216 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(ndn::nfd::LINK_TYPE_AD_HOC), netifs.size());
217}
218
219BOOST_AUTO_TEST_CASE(ChangeMcastGroup)
220{
221 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
222
223 const std::string CONFIG1 = R"CONFIG(
224 face_system
225 {
226 ether
227 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400228 mcast_group 01:00:5e:90:10:01
Teng Liangbfea5752017-03-29 04:51:10 +0000229 }
230 }
231 )CONFIG";
232 const std::string CONFIG2 = R"CONFIG(
233 face_system
234 {
235 ether
236 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400237 mcast_group 01:00:5e:90:10:02
Teng Liangbfea5752017-03-29 04:51:10 +0000238 }
239 }
240 )CONFIG";
241
242 parseConfig(CONFIG1, false);
243 auto etherMcastFaces = this->listEtherMcastFaces();
244 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), netifs.size());
245 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getRemoteUri(),
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400246 FaceUri(ethernet::Address{0x01, 0x00, 0x5e, 0x90, 0x10, 0x01}));
Teng Liangbfea5752017-03-29 04:51:10 +0000247
248 parseConfig(CONFIG2, false);
249 g_io.poll();
250 etherMcastFaces = this->listEtherMcastFaces();
251 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), netifs.size());
252 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getRemoteUri(),
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400253 FaceUri(ethernet::Address{0x01, 0x00, 0x5e, 0x90, 0x10, 0x02}));
Junxiao Shi7003c602017-01-10 13:35:28 +0000254}
255
256BOOST_AUTO_TEST_CASE(Whitelist)
257{
258 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
259
260 std::string CONFIG = R"CONFIG(
261 face_system
262 {
263 ether
264 {
265 whitelist
266 {
267 ifname %ifname
268 }
269 }
270 }
271 )CONFIG";
Davide Pesaventob15276f2017-07-15 16:27:13 -0400272 auto ifname = netifs.front()->getName();
273 boost::replace_first(CONFIG, "%ifname", ifname);
Junxiao Shi7003c602017-01-10 13:35:28 +0000274
Junxiao Shi1b65ca12017-01-21 23:04:41 +0000275 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400276
Junxiao Shi7003c602017-01-10 13:35:28 +0000277 auto etherMcastFaces = this->listEtherMcastFaces();
278 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), 1);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400279 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getLocalUri(), FaceUri::fromDev(ifname));
Junxiao Shi7003c602017-01-10 13:35:28 +0000280}
281
282BOOST_AUTO_TEST_CASE(Blacklist)
283{
284 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
285
286 std::string CONFIG = R"CONFIG(
287 face_system
288 {
289 ether
290 {
291 blacklist
292 {
293 ifname %ifname
294 }
295 }
296 }
297 )CONFIG";
Davide Pesaventob15276f2017-07-15 16:27:13 -0400298 auto ifname = netifs.front()->getName();
299 boost::replace_first(CONFIG, "%ifname", ifname);
Junxiao Shi7003c602017-01-10 13:35:28 +0000300
Junxiao Shi1b65ca12017-01-21 23:04:41 +0000301 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400302
Junxiao Shi7003c602017-01-10 13:35:28 +0000303 auto etherMcastFaces = this->listEtherMcastFaces();
304 BOOST_CHECK_EQUAL(etherMcastFaces.size(), netifs.size() - 1);
Davide Pesavento494a9552018-02-04 22:16:05 -0500305 BOOST_CHECK(std::none_of(etherMcastFaces.begin(), etherMcastFaces.end(),
306 [ifname] (const nfd::Face* face) {
307 return face->getLocalUri() == FaceUri::fromDev(ifname);
308 }
309 ));
Junxiao Shi7003c602017-01-10 13:35:28 +0000310}
311
Teng Liangbfea5752017-03-29 04:51:10 +0000312BOOST_AUTO_TEST_CASE(Omitted)
Junxiao Shi7003c602017-01-10 13:35:28 +0000313{
Teng Liangbfea5752017-03-29 04:51:10 +0000314 const std::string CONFIG = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000315 face_system
316 {
Junxiao Shi7003c602017-01-10 13:35:28 +0000317 }
318 )CONFIG";
319
Teng Liangbfea5752017-03-29 04:51:10 +0000320 parseConfig(CONFIG, true);
321 parseConfig(CONFIG, false);
322
Junxiao Shi7003c602017-01-10 13:35:28 +0000323 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
Junxiao Shi7003c602017-01-10 13:35:28 +0000324}
325
Davide Pesavento494a9552018-02-04 22:16:05 -0500326BOOST_AUTO_TEST_CASE(BadListen)
327{
328 const std::string CONFIG = R"CONFIG(
329 face_system
330 {
331 ether
332 {
333 listen hello
334 }
335 }
336 )CONFIG";
337
338 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
339 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
340}
341
Davide Pesavento494a9552018-02-04 22:16:05 -0500342BOOST_AUTO_TEST_CASE(BadIdleTimeout)
343{
344 // not a number
345 const std::string CONFIG1 = R"CONFIG(
346 face_system
347 {
348 ether
349 {
350 idle_timeout hello
351 }
352 }
353 )CONFIG";
354
355 BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
356 BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
357
358 // negative number
359 const std::string CONFIG2 = R"CONFIG(
360 face_system
361 {
362 ether
363 {
364 idle_timeout -15
365 }
366 }
367 )CONFIG";
368
369 BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
370 BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
371}
372
Junxiao Shi7003c602017-01-10 13:35:28 +0000373BOOST_AUTO_TEST_CASE(BadMcast)
374{
375 const std::string CONFIG = R"CONFIG(
376 face_system
377 {
378 ether
379 {
380 mcast hello
381 }
382 }
383 )CONFIG";
384
385 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
386 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
387}
388
389BOOST_AUTO_TEST_CASE(BadMcastGroup)
390{
Davide Pesavento494a9552018-02-04 22:16:05 -0500391 // not an address
392 const std::string CONFIG1 = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000393 face_system
394 {
395 ether
396 {
Junxiao Shi7003c602017-01-10 13:35:28 +0000397 mcast_group hello
398 }
399 }
400 )CONFIG";
401
Davide Pesavento494a9552018-02-04 22:16:05 -0500402 BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
403 BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
Junxiao Shi7003c602017-01-10 13:35:28 +0000404
Davide Pesavento494a9552018-02-04 22:16:05 -0500405 // non-multicast address
406 const std::string CONFIG2 = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000407 face_system
408 {
409 ether
410 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400411 mcast_group 00:00:5e:00:53:5e
Junxiao Shi7003c602017-01-10 13:35:28 +0000412 }
413 }
414 )CONFIG";
415
Davide Pesavento494a9552018-02-04 22:16:05 -0500416 BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
417 BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
Junxiao Shi7003c602017-01-10 13:35:28 +0000418}
419
420BOOST_AUTO_TEST_CASE(UnknownOption)
421{
422 const std::string CONFIG = R"CONFIG(
423 face_system
424 {
425 ether
426 {
427 hello
428 }
429 }
430 )CONFIG";
431
432 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
433 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
434}
435
436BOOST_AUTO_TEST_SUITE_END() // ProcessConfig
Junxiao Shicde37ad2015-12-24 01:02:05 -0700437
438BOOST_AUTO_TEST_CASE(GetChannels)
439{
Davide Pesaventob15276f2017-07-15 16:27:13 -0400440 BOOST_CHECK_EQUAL(factory.getChannels().empty(), true);
441 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
442
Davide Pesavento14e71f02019-03-28 17:35:25 -0400443 factory.createChannel(netifs.front(), 1_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400444 checkChannelListEqual(factory, {FaceUri::fromDev(netifs.front()->getName()).toString()});
Junxiao Shicde37ad2015-12-24 01:02:05 -0700445}
446
Davide Pesaventob15276f2017-07-15 16:27:13 -0400447BOOST_AUTO_TEST_CASE(CreateChannel)
448{
449 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
450
Davide Pesavento14e71f02019-03-28 17:35:25 -0400451 auto channel1 = factory.createChannel(netifs.front(), 1_min);
452 auto channel1a = factory.createChannel(netifs.front(), 5_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400453 BOOST_CHECK_EQUAL(channel1, channel1a);
454 BOOST_CHECK_EQUAL(channel1->getUri().toString(), "dev://" + netifs.front()->getName());
455
456 SKIP_IF_ETHERNET_NETIF_COUNT_LT(2);
457
Davide Pesavento14e71f02019-03-28 17:35:25 -0400458 auto channel2 = factory.createChannel(netifs.back(), 1_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400459 BOOST_CHECK_NE(channel1, channel2);
460}
461
462BOOST_AUTO_TEST_CASE(CreateFace)
463{
464 createFace(factory,
465 FaceUri("ether://[00:00:5e:00:53:5e]"),
466 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700467 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400468 {CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
469
470 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
Davide Pesavento14e71f02019-03-28 17:35:25 -0400471 auto localUri = factory.createChannel(netifs.front(), 1_min)->getUri();
Davide Pesaventob15276f2017-07-15 16:27:13 -0400472
473 createFace(factory,
474 FaceUri("ether://[00:00:5e:00:53:5e]"),
475 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700476 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400477 {CreateFaceExpectedResult::SUCCESS, 0, ""});
478
479 createFace(factory,
480 FaceUri("ether://[00:00:5e:00:53:5e]"),
481 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700482 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400483 {CreateFaceExpectedResult::SUCCESS, 0, ""});
484
485 createFace(factory,
486 FaceUri("ether://[00:00:5e:00:53:53]"),
487 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700488 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, false},
Eric Newberry2642cd22017-07-13 21:34:53 -0400489 {CreateFaceExpectedResult::SUCCESS, 0, ""});
490
491 createFace(factory,
492 FaceUri("ether://[00:00:5e:00:53:57]"),
493 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700494 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, true, false},
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700495 {CreateFaceExpectedResult::SUCCESS, 0, ""});
496
497 createFace(factory,
498 FaceUri("ether://[00:00:5e:00:53:5b]"),
499 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700500 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, true},
501 {CreateFaceExpectedResult::SUCCESS, 0, ""});
502
503 createFace(factory,
504 FaceUri("ether://[00:00:5e:00:53:5c]"),
505 localUri,
506 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, 1000, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400507 {CreateFaceExpectedResult::SUCCESS, 0, ""});
508}
509
510BOOST_AUTO_TEST_CASE(UnsupportedCreateFace)
Junxiao Shicde37ad2015-12-24 01:02:05 -0700511{
Eric Newberry42602412016-08-27 09:33:18 -0700512 createFace(factory,
Davide Pesavento46afec42017-05-28 14:28:47 -0400513 FaceUri("ether://[00:00:5e:00:53:5e]"),
Eric Newberry78e32b02017-04-01 14:34:44 +0000514 {},
Eric Newberry812d6152018-06-06 15:06:01 -0700515 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400516 {CreateFaceExpectedResult::FAILURE, 406,
517 "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
518
519 createFace(factory,
520 FaceUri("ether://[00:00:5e:00:53:5e]"),
521 FaceUri("udp4://127.0.0.1:20071"),
Eric Newberry812d6152018-06-06 15:06:01 -0700522 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400523 {CreateFaceExpectedResult::FAILURE, 406,
524 "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
525
526 createFace(factory,
527 FaceUri("ether://[00:00:5e:00:53:5e]"),
528 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700529 {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400530 {CreateFaceExpectedResult::FAILURE, 406,
531 "Outgoing Ethernet faces do not support on-demand persistency"});
532
533 createFace(factory,
534 FaceUri("ether://[01:00:5e:90:10:5e]"),
535 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700536 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400537 {CreateFaceExpectedResult::FAILURE, 406,
538 "Cannot create multicast Ethernet faces"});
539
540 createFace(factory,
541 FaceUri("ether://[00:00:5e:00:53:5e]"),
542 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700543 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, true, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400544 {CreateFaceExpectedResult::FAILURE, 406,
545 "Local fields can only be enabled on faces with local scope"});
Junxiao Shicde37ad2015-12-24 01:02:05 -0700546}
547
548BOOST_AUTO_TEST_SUITE_END() // TestEthernetFactory
549BOOST_AUTO_TEST_SUITE_END() // Face
550
551} // namespace tests
Junxiao Shi7003c602017-01-10 13:35:28 +0000552} // namespace face
Junxiao Shicde37ad2015-12-24 01:02:05 -0700553} // namespace nfd