blob: 605d3e281d5069159abadf7813a27470b7108b32 [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());
154}
155
Teng Liangbfea5752017-03-29 04:51:10 +0000156BOOST_AUTO_TEST_CASE(EnableDisableMcast)
Junxiao Shi7003c602017-01-10 13:35:28 +0000157{
Teng Liangbfea5752017-03-29 04:51:10 +0000158 const std::string CONFIG_WITH_MCAST = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000159 face_system
160 {
Teng Liangbfea5752017-03-29 04:51:10 +0000161 ether
162 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400163 listen no
Teng Liangbfea5752017-03-29 04:51:10 +0000164 mcast yes
165 }
166 }
167 )CONFIG";
168 const std::string CONFIG_WITHOUT_MCAST = R"CONFIG(
169 face_system
170 {
171 ether
172 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400173 listen no
Teng Liangbfea5752017-03-29 04:51:10 +0000174 mcast no
175 }
Junxiao Shi7003c602017-01-10 13:35:28 +0000176 }
177 )CONFIG";
178
Teng Liangbfea5752017-03-29 04:51:10 +0000179 parseConfig(CONFIG_WITHOUT_MCAST, false);
Junxiao Shi7003c602017-01-10 13:35:28 +0000180 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
Teng Liangbfea5752017-03-29 04:51:10 +0000181
182 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
183
184 parseConfig(CONFIG_WITH_MCAST, false);
185 g_io.poll();
186 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), netifs.size());
187
188 parseConfig(CONFIG_WITHOUT_MCAST, false);
189 g_io.poll();
190 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
191}
192
193BOOST_AUTO_TEST_CASE(McastAdHoc)
194{
195 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
196
197 const std::string CONFIG = R"CONFIG(
198 face_system
199 {
200 ether
201 {
Davide Pesaventob15276f2017-07-15 16:27:13 -0400202 listen no
203 mcast yes
Teng Liangbfea5752017-03-29 04:51:10 +0000204 mcast_ad_hoc yes
205 }
206 }
207 )CONFIG";
208
209 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400210 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(ndn::nfd::LINK_TYPE_MULTI_ACCESS), 0);
Teng Liangbfea5752017-03-29 04:51:10 +0000211 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(ndn::nfd::LINK_TYPE_AD_HOC), netifs.size());
212}
213
214BOOST_AUTO_TEST_CASE(ChangeMcastGroup)
215{
216 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
217
218 const std::string CONFIG1 = R"CONFIG(
219 face_system
220 {
221 ether
222 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400223 mcast_group 01:00:5e:90:10:01
Teng Liangbfea5752017-03-29 04:51:10 +0000224 }
225 }
226 )CONFIG";
227 const std::string CONFIG2 = R"CONFIG(
228 face_system
229 {
230 ether
231 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400232 mcast_group 01:00:5e:90:10:02
Teng Liangbfea5752017-03-29 04:51:10 +0000233 }
234 }
235 )CONFIG";
236
237 parseConfig(CONFIG1, false);
238 auto etherMcastFaces = this->listEtherMcastFaces();
239 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), netifs.size());
240 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getRemoteUri(),
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400241 FaceUri(ethernet::Address{0x01, 0x00, 0x5e, 0x90, 0x10, 0x01}));
Teng Liangbfea5752017-03-29 04:51:10 +0000242
243 parseConfig(CONFIG2, false);
244 g_io.poll();
245 etherMcastFaces = this->listEtherMcastFaces();
246 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), netifs.size());
247 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getRemoteUri(),
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400248 FaceUri(ethernet::Address{0x01, 0x00, 0x5e, 0x90, 0x10, 0x02}));
Junxiao Shi7003c602017-01-10 13:35:28 +0000249}
250
251BOOST_AUTO_TEST_CASE(Whitelist)
252{
253 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
254
255 std::string CONFIG = R"CONFIG(
256 face_system
257 {
258 ether
259 {
260 whitelist
261 {
262 ifname %ifname
263 }
264 }
265 }
266 )CONFIG";
Davide Pesaventob15276f2017-07-15 16:27:13 -0400267 auto ifname = netifs.front()->getName();
268 boost::replace_first(CONFIG, "%ifname", ifname);
Junxiao Shi7003c602017-01-10 13:35:28 +0000269
Junxiao Shi1b65ca12017-01-21 23:04:41 +0000270 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400271
Junxiao Shi7003c602017-01-10 13:35:28 +0000272 auto etherMcastFaces = this->listEtherMcastFaces();
273 BOOST_REQUIRE_EQUAL(etherMcastFaces.size(), 1);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400274 BOOST_CHECK_EQUAL(etherMcastFaces.front()->getLocalUri(), FaceUri::fromDev(ifname));
Junxiao Shi7003c602017-01-10 13:35:28 +0000275}
276
277BOOST_AUTO_TEST_CASE(Blacklist)
278{
279 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
280
281 std::string CONFIG = R"CONFIG(
282 face_system
283 {
284 ether
285 {
286 blacklist
287 {
288 ifname %ifname
289 }
290 }
291 }
292 )CONFIG";
Davide Pesaventob15276f2017-07-15 16:27:13 -0400293 auto ifname = netifs.front()->getName();
294 boost::replace_first(CONFIG, "%ifname", ifname);
Junxiao Shi7003c602017-01-10 13:35:28 +0000295
Junxiao Shi1b65ca12017-01-21 23:04:41 +0000296 parseConfig(CONFIG, false);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400297
Junxiao Shi7003c602017-01-10 13:35:28 +0000298 auto etherMcastFaces = this->listEtherMcastFaces();
299 BOOST_CHECK_EQUAL(etherMcastFaces.size(), netifs.size() - 1);
Davide Pesavento494a9552018-02-04 22:16:05 -0500300 BOOST_CHECK(std::none_of(etherMcastFaces.begin(), etherMcastFaces.end(),
301 [ifname] (const nfd::Face* face) {
302 return face->getLocalUri() == FaceUri::fromDev(ifname);
303 }
304 ));
Junxiao Shi7003c602017-01-10 13:35:28 +0000305}
306
Teng Liangbfea5752017-03-29 04:51:10 +0000307BOOST_AUTO_TEST_CASE(Omitted)
Junxiao Shi7003c602017-01-10 13:35:28 +0000308{
Teng Liangbfea5752017-03-29 04:51:10 +0000309 const std::string CONFIG = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000310 face_system
311 {
Junxiao Shi7003c602017-01-10 13:35:28 +0000312 }
313 )CONFIG";
314
Teng Liangbfea5752017-03-29 04:51:10 +0000315 parseConfig(CONFIG, true);
316 parseConfig(CONFIG, false);
317
Junxiao Shi7003c602017-01-10 13:35:28 +0000318 BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
Junxiao Shi7003c602017-01-10 13:35:28 +0000319}
320
Davide Pesavento494a9552018-02-04 22:16:05 -0500321BOOST_AUTO_TEST_CASE(BadListen)
322{
323 const std::string CONFIG = R"CONFIG(
324 face_system
325 {
326 ether
327 {
328 listen hello
329 }
330 }
331 )CONFIG";
332
333 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
334 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
335}
336
Davide Pesavento494a9552018-02-04 22:16:05 -0500337BOOST_AUTO_TEST_CASE(BadIdleTimeout)
338{
339 // not a number
340 const std::string CONFIG1 = R"CONFIG(
341 face_system
342 {
343 ether
344 {
345 idle_timeout hello
346 }
347 }
348 )CONFIG";
349
350 BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
351 BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
352
353 // negative number
354 const std::string CONFIG2 = R"CONFIG(
355 face_system
356 {
357 ether
358 {
359 idle_timeout -15
360 }
361 }
362 )CONFIG";
363
364 BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
365 BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
366}
367
Junxiao Shi7003c602017-01-10 13:35:28 +0000368BOOST_AUTO_TEST_CASE(BadMcast)
369{
370 const std::string CONFIG = R"CONFIG(
371 face_system
372 {
373 ether
374 {
375 mcast hello
376 }
377 }
378 )CONFIG";
379
380 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
381 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
382}
383
384BOOST_AUTO_TEST_CASE(BadMcastGroup)
385{
Davide Pesavento494a9552018-02-04 22:16:05 -0500386 // not an address
387 const std::string CONFIG1 = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000388 face_system
389 {
390 ether
391 {
Junxiao Shi7003c602017-01-10 13:35:28 +0000392 mcast_group hello
393 }
394 }
395 )CONFIG";
396
Davide Pesavento494a9552018-02-04 22:16:05 -0500397 BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
398 BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
Junxiao Shi7003c602017-01-10 13:35:28 +0000399
Davide Pesavento494a9552018-02-04 22:16:05 -0500400 // non-multicast address
401 const std::string CONFIG2 = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000402 face_system
403 {
404 ether
405 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400406 mcast_group 00:00:5e:00:53:5e
Junxiao Shi7003c602017-01-10 13:35:28 +0000407 }
408 }
409 )CONFIG";
410
Davide Pesavento494a9552018-02-04 22:16:05 -0500411 BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
412 BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
Junxiao Shi7003c602017-01-10 13:35:28 +0000413}
414
415BOOST_AUTO_TEST_CASE(UnknownOption)
416{
417 const std::string CONFIG = R"CONFIG(
418 face_system
419 {
420 ether
421 {
422 hello
423 }
424 }
425 )CONFIG";
426
427 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
428 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
429}
430
431BOOST_AUTO_TEST_SUITE_END() // ProcessConfig
Junxiao Shicde37ad2015-12-24 01:02:05 -0700432
433BOOST_AUTO_TEST_CASE(GetChannels)
434{
Davide Pesaventob15276f2017-07-15 16:27:13 -0400435 BOOST_CHECK_EQUAL(factory.getChannels().empty(), true);
436 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
437
Davide Pesavento14e71f02019-03-28 17:35:25 -0400438 factory.createChannel(netifs.front(), 1_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400439 checkChannelListEqual(factory, {FaceUri::fromDev(netifs.front()->getName()).toString()});
Junxiao Shicde37ad2015-12-24 01:02:05 -0700440}
441
Davide Pesaventob15276f2017-07-15 16:27:13 -0400442BOOST_AUTO_TEST_CASE(CreateChannel)
443{
444 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
445
Davide Pesavento14e71f02019-03-28 17:35:25 -0400446 auto channel1 = factory.createChannel(netifs.front(), 1_min);
447 auto channel1a = factory.createChannel(netifs.front(), 5_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400448 BOOST_CHECK_EQUAL(channel1, channel1a);
449 BOOST_CHECK_EQUAL(channel1->getUri().toString(), "dev://" + netifs.front()->getName());
450
451 SKIP_IF_ETHERNET_NETIF_COUNT_LT(2);
452
Davide Pesavento14e71f02019-03-28 17:35:25 -0400453 auto channel2 = factory.createChannel(netifs.back(), 1_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400454 BOOST_CHECK_NE(channel1, channel2);
455}
456
457BOOST_AUTO_TEST_CASE(CreateFace)
458{
459 createFace(factory,
460 FaceUri("ether://[00:00:5e:00:53:5e]"),
461 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700462 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400463 {CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
464
465 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
Davide Pesavento14e71f02019-03-28 17:35:25 -0400466 auto localUri = factory.createChannel(netifs.front(), 1_min)->getUri();
Davide Pesaventob15276f2017-07-15 16:27:13 -0400467
468 createFace(factory,
469 FaceUri("ether://[00:00:5e:00:53:5e]"),
470 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700471 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400472 {CreateFaceExpectedResult::SUCCESS, 0, ""});
473
474 createFace(factory,
475 FaceUri("ether://[00:00:5e:00:53:5e]"),
476 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700477 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400478 {CreateFaceExpectedResult::SUCCESS, 0, ""});
479
480 createFace(factory,
481 FaceUri("ether://[00:00:5e:00:53:53]"),
482 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700483 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, false},
Eric Newberry2642cd22017-07-13 21:34:53 -0400484 {CreateFaceExpectedResult::SUCCESS, 0, ""});
485
486 createFace(factory,
487 FaceUri("ether://[00:00:5e:00:53:57]"),
488 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700489 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, true, false},
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700490 {CreateFaceExpectedResult::SUCCESS, 0, ""});
491
492 createFace(factory,
493 FaceUri("ether://[00:00:5e:00:53:5b]"),
494 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700495 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, true},
496 {CreateFaceExpectedResult::SUCCESS, 0, ""});
497
498 createFace(factory,
499 FaceUri("ether://[00:00:5e:00:53:5c]"),
500 localUri,
501 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, 1000, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400502 {CreateFaceExpectedResult::SUCCESS, 0, ""});
503}
504
505BOOST_AUTO_TEST_CASE(UnsupportedCreateFace)
Junxiao Shicde37ad2015-12-24 01:02:05 -0700506{
Eric Newberry42602412016-08-27 09:33:18 -0700507 createFace(factory,
Davide Pesavento46afec42017-05-28 14:28:47 -0400508 FaceUri("ether://[00:00:5e:00:53:5e]"),
Eric Newberry78e32b02017-04-01 14:34:44 +0000509 {},
Eric Newberry812d6152018-06-06 15:06:01 -0700510 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400511 {CreateFaceExpectedResult::FAILURE, 406,
512 "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
513
514 createFace(factory,
515 FaceUri("ether://[00:00:5e:00:53:5e]"),
516 FaceUri("udp4://127.0.0.1:20071"),
Eric Newberry812d6152018-06-06 15:06:01 -0700517 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400518 {CreateFaceExpectedResult::FAILURE, 406,
519 "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
520
521 createFace(factory,
522 FaceUri("ether://[00:00:5e:00:53:5e]"),
523 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700524 {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400525 {CreateFaceExpectedResult::FAILURE, 406,
526 "Outgoing Ethernet faces do not support on-demand persistency"});
527
528 createFace(factory,
529 FaceUri("ether://[01:00:5e:90:10:5e]"),
530 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700531 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400532 {CreateFaceExpectedResult::FAILURE, 406,
533 "Cannot create multicast Ethernet faces"});
534
535 createFace(factory,
536 FaceUri("ether://[00:00:5e:00:53:5e]"),
537 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700538 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, true, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400539 {CreateFaceExpectedResult::FAILURE, 406,
540 "Local fields can only be enabled on faces with local scope"});
Junxiao Shicde37ad2015-12-24 01:02:05 -0700541}
542
543BOOST_AUTO_TEST_SUITE_END() // TestEthernetFactory
544BOOST_AUTO_TEST_SUITE_END() // Face
545
546} // namespace tests
Junxiao Shi7003c602017-01-10 13:35:28 +0000547} // namespace face
Junxiao Shicde37ad2015-12-24 01:02:05 -0700548} // namespace nfd