blob: 4871e3c9d4fe0f644ccfde3ece2c276bf9203ee7 [file] [log] [blame]
Yukai Tu16aabbc2015-10-06 05:08:42 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2015, Regents of the University of California,
4 * 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 "get-available-interface-ip.hpp"
27#include "transport-test-common.hpp"
28
Eric Newberryf68f3782015-12-11 00:31:32 -070029#include "tcp-transport-fixture.hpp"
Yukai Tu16aabbc2015-10-06 05:08:42 -070030
31namespace nfd {
32namespace face {
33namespace tests {
34
Yukai Tu16aabbc2015-10-06 05:08:42 -070035BOOST_AUTO_TEST_SUITE(Face)
Eric Newberry8717e872015-11-23 12:41:50 -070036BOOST_FIXTURE_TEST_SUITE(TestTcpTransport, TcpTransportFixture)
37
38BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv4)
39{
40 initialize();
41
42 checkStaticPropertiesInitialized(*transport);
43
44 BOOST_CHECK_EQUAL(transport->getLocalUri(), FaceUri("tcp4://127.0.0.1:" + to_string(localEp.port())));
45 BOOST_CHECK_EQUAL(transport->getRemoteUri(), FaceUri("tcp4://127.0.0.1:7070"));
46 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL);
47 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
48 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
49 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
Yukai Tu16aabbc2015-10-06 05:08:42 -070050}
51
Eric Newberry8717e872015-11-23 12:41:50 -070052BOOST_AUTO_TEST_CASE(StaticPropertiesLocalIpv6)
Yukai Tu16aabbc2015-10-06 05:08:42 -070053{
Eric Newberry8717e872015-11-23 12:41:50 -070054 initialize(ip::address_v6::loopback());
Yukai Tu16aabbc2015-10-06 05:08:42 -070055
Eric Newberry8717e872015-11-23 12:41:50 -070056 checkStaticPropertiesInitialized(*transport);
Yukai Tu16aabbc2015-10-06 05:08:42 -070057
Eric Newberry8717e872015-11-23 12:41:50 -070058 BOOST_CHECK_EQUAL(transport->getLocalUri(), FaceUri("tcp6://[::1]:" + to_string(localEp.port())));
59 BOOST_CHECK_EQUAL(transport->getRemoteUri(), FaceUri("tcp6://[::1]:7070"));
60 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_LOCAL);
61 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
62 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
63 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
64}
65
66BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv4)
67{
68 auto address = getAvailableInterfaceIp<ip::address_v4>();
69 SKIP_IF_IP_UNAVAILABLE(address);
70 initialize(address);
71
72 checkStaticPropertiesInitialized(*transport);
73
74 BOOST_CHECK_EQUAL(transport->getLocalUri(),
75 FaceUri("tcp4://" + address.to_string() + ":" + to_string(localEp.port())));
76 BOOST_CHECK_EQUAL(transport->getRemoteUri(),
77 FaceUri("tcp4://" + address.to_string() + ":7070"));
78 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL);
79 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
80 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
81 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
82}
83
84BOOST_AUTO_TEST_CASE(StaticPropertiesNonLocalIpv6)
85{
86 auto address = getAvailableInterfaceIp<ip::address_v6>();
87 SKIP_IF_IP_UNAVAILABLE(address);
88 initialize(address);
89
90 checkStaticPropertiesInitialized(*transport);
91
92 BOOST_CHECK_EQUAL(transport->getLocalUri(),
93 FaceUri("tcp6://[" + address.to_string() + "]:" + to_string(localEp.port())));
94 BOOST_CHECK_EQUAL(transport->getRemoteUri(),
95 FaceUri("tcp6://[" + address.to_string() + "]:7070"));
96 BOOST_CHECK_EQUAL(transport->getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL);
97 BOOST_CHECK_EQUAL(transport->getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
98 BOOST_CHECK_EQUAL(transport->getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT);
99 BOOST_CHECK_EQUAL(transport->getMtu(), MTU_UNLIMITED);
100}
101
Yukai Tu16aabbc2015-10-06 05:08:42 -0700102BOOST_AUTO_TEST_SUITE_END() // TestTcpTransport
103BOOST_AUTO_TEST_SUITE_END() // Face
104
105} // namespace tests
106} // namespace face
107} // namespace nfd