blob: fd0d7ae9ad4ab31c32152efe09f89bbddffec5c3 [file] [log] [blame]
Yukai Tu16aabbc2015-10-06 05:08:42 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Davide Pesaventoeee53aa2016-04-11 17:20:21 +02003 * Copyright (c) 2014-2016, Regents of the University of California,
Yukai Tu16aabbc2015-10-06 05:08:42 -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
Eric Newberry65caf202015-12-17 15:08:16 -070026#include "transport-test-common.hpp"
27
Eric Newberryf68f3782015-12-11 00:31:32 -070028#include "tcp-transport-fixture.hpp"
Yukai Tu16aabbc2015-10-06 05:08:42 -070029
30namespace nfd {
31namespace face {
32namespace tests {
33
Yukai Tu16aabbc2015-10-06 05:08:42 -070034BOOST_AUTO_TEST_SUITE(Face)
Eric Newberry8717e872015-11-23 12:41:50 -070035BOOST_FIXTURE_TEST_SUITE(TestTcpTransport, TcpTransportFixture)
36
37BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4)
38{
Davide Pesaventoeee53aa2016-04-11 17:20:21 +020039 auto address = getTestIp<ip::address_v4>(LoopbackAddress::Yes);
40 SKIP_IF_IP_UNAVAILABLE(address);
41 initialize(address);
Eric Newberry8717e872015-11-23 12:41:50 -070042
43 checkStaticPropertiesInitialized(*transport);
44
45 BOOST_CHECK_EQUAL(transport->getLocalUri(), FaceUri("tcp4://127.0.0.1:" + to_string(localEp.port())));
46 BOOST_CHECK_EQUAL(transport->getRemoteUri(), FaceUri("tcp4://127.0.0.1:7070"));
47 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL);
48 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
49 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
50 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
Yukai Tu16aabbc2015-10-06 05:08:42 -070051}
52
Eric Newberry8717e872015-11-23 12:41:50 -070053BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv6)
Yukai Tu16aabbc2015-10-06 05:08:42 -070054{
Davide Pesaventoeee53aa2016-04-11 17:20:21 +020055 auto address = getTestIp<ip::address_v6>(LoopbackAddress::Yes);
56 SKIP_IF_IP_UNAVAILABLE(address);
57 initialize(address);
Yukai Tu16aabbc2015-10-06 05:08:42 -070058
Eric Newberry8717e872015-11-23 12:41:50 -070059 checkStaticPropertiesInitialized(*transport);
Yukai Tu16aabbc2015-10-06 05:08:42 -070060
Eric Newberry8717e872015-11-23 12:41:50 -070061 BOOST_CHECK_EQUAL(transport->getLocalUri(), FaceUri("tcp6://[::1]:" + to_string(localEp.port())));
62 BOOST_CHECK_EQUAL(transport->getRemoteUri(), FaceUri("tcp6://[::1]:7070"));
63 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL);
64 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
65 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
66 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
67}
68
69BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4)
70{
Davide Pesaventoeee53aa2016-04-11 17:20:21 +020071 auto address = getTestIp<ip::address_v4>(LoopbackAddress::No);
Eric Newberry8717e872015-11-23 12:41:50 -070072 SKIP_IF_IP_UNAVAILABLE(address);
73 initialize(address);
74
75 checkStaticPropertiesInitialized(*transport);
76
77 BOOST_CHECK_EQUAL(transport->getLocalUri(),
78 FaceUri("tcp4://" + address.to_string() + ":" + to_string(localEp.port())));
79 BOOST_CHECK_EQUAL(transport->getRemoteUri(),
80 FaceUri("tcp4://" + address.to_string() + ":7070"));
81 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL);
82 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
83 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
84 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
85}
86
87BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv6)
88{
Davide Pesaventoeee53aa2016-04-11 17:20:21 +020089 auto address = getTestIp<ip::address_v6>(LoopbackAddress::No);
Eric Newberry8717e872015-11-23 12:41:50 -070090 SKIP_IF_IP_UNAVAILABLE(address);
91 initialize(address);
92
93 checkStaticPropertiesInitialized(*transport);
94
95 BOOST_CHECK_EQUAL(transport->getLocalUri(),
96 FaceUri("tcp6://[" + address.to_string() + "]:" + to_string(localEp.port())));
97 BOOST_CHECK_EQUAL(transport->getRemoteUri(),
98 FaceUri("tcp6://[" + address.to_string() + "]:7070"));
99 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL);
100 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
101 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
102 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
103}
104
Yukai Tu16aabbc2015-10-06 05:08:42 -0700105BOOST_AUTO_TEST_SUITE_END() // TestTcpTransport
106BOOST_AUTO_TEST_SUITE_END() // Face
107
108} // namespace tests
109} // namespace face
110} // namespace nfd