blob: e204ceeb8a1896537e89ecc3a79c4050a44455aa [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 Pesavento14e71f02019-03-28 17:35:25 -04003 * Copyright (c) 2014-2019, 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
337BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(BadIdleTimeout, 2) // Bug #4489
338BOOST_AUTO_TEST_CASE(BadIdleTimeout)
339{
340 // not a number
341 const std::string CONFIG1 = R"CONFIG(
342 face_system
343 {
344 ether
345 {
346 idle_timeout hello
347 }
348 }
349 )CONFIG";
350
351 BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
352 BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
353
354 // negative number
355 const std::string CONFIG2 = R"CONFIG(
356 face_system
357 {
358 ether
359 {
360 idle_timeout -15
361 }
362 }
363 )CONFIG";
364
365 BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
366 BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
367}
368
Junxiao Shi7003c602017-01-10 13:35:28 +0000369BOOST_AUTO_TEST_CASE(BadMcast)
370{
371 const std::string CONFIG = R"CONFIG(
372 face_system
373 {
374 ether
375 {
376 mcast hello
377 }
378 }
379 )CONFIG";
380
381 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
382 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
383}
384
385BOOST_AUTO_TEST_CASE(BadMcastGroup)
386{
Davide Pesavento494a9552018-02-04 22:16:05 -0500387 // not an address
388 const std::string CONFIG1 = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000389 face_system
390 {
391 ether
392 {
Junxiao Shi7003c602017-01-10 13:35:28 +0000393 mcast_group hello
394 }
395 }
396 )CONFIG";
397
Davide Pesavento494a9552018-02-04 22:16:05 -0500398 BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
399 BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
Junxiao Shi7003c602017-01-10 13:35:28 +0000400
Davide Pesavento494a9552018-02-04 22:16:05 -0500401 // non-multicast address
402 const std::string CONFIG2 = R"CONFIG(
Junxiao Shi7003c602017-01-10 13:35:28 +0000403 face_system
404 {
405 ether
406 {
Davide Pesavento43ff2a92017-05-18 19:50:57 -0400407 mcast_group 00:00:5e:00:53:5e
Junxiao Shi7003c602017-01-10 13:35:28 +0000408 }
409 }
410 )CONFIG";
411
Davide Pesavento494a9552018-02-04 22:16:05 -0500412 BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
413 BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
Junxiao Shi7003c602017-01-10 13:35:28 +0000414}
415
416BOOST_AUTO_TEST_CASE(UnknownOption)
417{
418 const std::string CONFIG = R"CONFIG(
419 face_system
420 {
421 ether
422 {
423 hello
424 }
425 }
426 )CONFIG";
427
428 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
429 BOOST_CHECK_THROW(parseConfig(CONFIG, false), ConfigFile::Error);
430}
431
432BOOST_AUTO_TEST_SUITE_END() // ProcessConfig
Junxiao Shicde37ad2015-12-24 01:02:05 -0700433
434BOOST_AUTO_TEST_CASE(GetChannels)
435{
Davide Pesaventob15276f2017-07-15 16:27:13 -0400436 BOOST_CHECK_EQUAL(factory.getChannels().empty(), true);
437 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
438
Davide Pesavento14e71f02019-03-28 17:35:25 -0400439 factory.createChannel(netifs.front(), 1_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400440 checkChannelListEqual(factory, {FaceUri::fromDev(netifs.front()->getName()).toString()});
Junxiao Shicde37ad2015-12-24 01:02:05 -0700441}
442
Davide Pesaventob15276f2017-07-15 16:27:13 -0400443BOOST_AUTO_TEST_CASE(CreateChannel)
444{
445 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
446
Davide Pesavento14e71f02019-03-28 17:35:25 -0400447 auto channel1 = factory.createChannel(netifs.front(), 1_min);
448 auto channel1a = factory.createChannel(netifs.front(), 5_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400449 BOOST_CHECK_EQUAL(channel1, channel1a);
450 BOOST_CHECK_EQUAL(channel1->getUri().toString(), "dev://" + netifs.front()->getName());
451
452 SKIP_IF_ETHERNET_NETIF_COUNT_LT(2);
453
Davide Pesavento14e71f02019-03-28 17:35:25 -0400454 auto channel2 = factory.createChannel(netifs.back(), 1_min);
Davide Pesaventob15276f2017-07-15 16:27:13 -0400455 BOOST_CHECK_NE(channel1, channel2);
456}
457
458BOOST_AUTO_TEST_CASE(CreateFace)
459{
460 createFace(factory,
461 FaceUri("ether://[00:00:5e:00:53:5e]"),
462 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700463 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400464 {CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
465
466 SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
Davide Pesavento14e71f02019-03-28 17:35:25 -0400467 auto localUri = factory.createChannel(netifs.front(), 1_min)->getUri();
Davide Pesaventob15276f2017-07-15 16:27:13 -0400468
469 createFace(factory,
470 FaceUri("ether://[00:00:5e:00:53:5e]"),
471 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700472 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400473 {CreateFaceExpectedResult::SUCCESS, 0, ""});
474
475 createFace(factory,
476 FaceUri("ether://[00:00:5e:00:53:5e]"),
477 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700478 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400479 {CreateFaceExpectedResult::SUCCESS, 0, ""});
480
481 createFace(factory,
482 FaceUri("ether://[00:00:5e:00:53:53]"),
483 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700484 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, false},
Eric Newberry2642cd22017-07-13 21:34:53 -0400485 {CreateFaceExpectedResult::SUCCESS, 0, ""});
486
487 createFace(factory,
488 FaceUri("ether://[00:00:5e:00:53:57]"),
489 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700490 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, true, false},
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700491 {CreateFaceExpectedResult::SUCCESS, 0, ""});
492
493 createFace(factory,
494 FaceUri("ether://[00:00:5e:00:53:5b]"),
495 localUri,
Eric Newberry812d6152018-06-06 15:06:01 -0700496 {ndn::nfd::FACE_PERSISTENCY_PERMANENT, {}, {}, {}, false, false, true},
497 {CreateFaceExpectedResult::SUCCESS, 0, ""});
498
499 createFace(factory,
500 FaceUri("ether://[00:00:5e:00:53:5c]"),
501 localUri,
502 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, 1000, false, false, false},
Davide Pesaventob15276f2017-07-15 16:27:13 -0400503 {CreateFaceExpectedResult::SUCCESS, 0, ""});
504}
505
506BOOST_AUTO_TEST_CASE(UnsupportedCreateFace)
Junxiao Shicde37ad2015-12-24 01:02:05 -0700507{
Eric Newberry42602412016-08-27 09:33:18 -0700508 createFace(factory,
Davide Pesavento46afec42017-05-28 14:28:47 -0400509 FaceUri("ether://[00:00:5e:00:53:5e]"),
Eric Newberry78e32b02017-04-01 14:34:44 +0000510 {},
Eric Newberry812d6152018-06-06 15:06:01 -0700511 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400512 {CreateFaceExpectedResult::FAILURE, 406,
513 "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
514
515 createFace(factory,
516 FaceUri("ether://[00:00:5e:00:53:5e]"),
517 FaceUri("udp4://127.0.0.1:20071"),
Eric Newberry812d6152018-06-06 15:06:01 -0700518 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400519 {CreateFaceExpectedResult::FAILURE, 406,
520 "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
521
522 createFace(factory,
523 FaceUri("ether://[00:00:5e:00:53:5e]"),
524 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700525 {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400526 {CreateFaceExpectedResult::FAILURE, 406,
527 "Outgoing Ethernet faces do not support on-demand persistency"});
528
529 createFace(factory,
530 FaceUri("ether://[01:00:5e:90:10:5e]"),
531 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700532 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, false, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400533 {CreateFaceExpectedResult::FAILURE, 406,
534 "Cannot create multicast Ethernet faces"});
535
536 createFace(factory,
537 FaceUri("ether://[00:00:5e:00:53:5e]"),
538 FaceUri("dev://eth0"),
Eric Newberry812d6152018-06-06 15:06:01 -0700539 {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, {}, {}, {}, true, false, false},
Davide Pesavento46afec42017-05-28 14:28:47 -0400540 {CreateFaceExpectedResult::FAILURE, 406,
541 "Local fields can only be enabled on faces with local scope"});
Junxiao Shicde37ad2015-12-24 01:02:05 -0700542}
543
544BOOST_AUTO_TEST_SUITE_END() // TestEthernetFactory
545BOOST_AUTO_TEST_SUITE_END() // Face
546
547} // namespace tests
Junxiao Shi7003c602017-01-10 13:35:28 +0000548} // namespace face
Junxiao Shicde37ad2015-12-24 01:02:05 -0700549} // namespace nfd