Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 26 | #include "face/unicast-udp-transport.hpp" |
Eric Newberry | 8717e87 | 2015-11-23 12:41:50 -0700 | [diff] [blame] | 27 | #include "transport-test-common.hpp" |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 28 | |
| 29 | namespace nfd { |
| 30 | namespace face { |
| 31 | namespace tests { |
| 32 | |
| 33 | using namespace nfd::tests; |
| 34 | namespace ip = boost::asio::ip; |
| 35 | using ip::udp; |
| 36 | |
| 37 | BOOST_AUTO_TEST_SUITE(Face) |
| 38 | BOOST_FIXTURE_TEST_SUITE(TestUnicastUdpTransport, BaseFixture) |
| 39 | |
| 40 | BOOST_AUTO_TEST_CASE(StaticPropertiesIpv4) |
| 41 | { |
| 42 | udp::socket sock(g_io, udp::endpoint(ip::address_v4::loopback(), 7001)); |
| 43 | sock.connect(udp::endpoint(ip::address_v4::loopback(), 7002)); |
| 44 | UnicastUdpTransport transport(std::move(sock), ndn::nfd::FACE_PERSISTENCY_PERSISTENT, time::seconds(300)); |
Junxiao Shi | 5b8a2b2 | 2015-10-22 17:20:44 -0700 | [diff] [blame] | 45 | checkStaticPropertiesInitialized(transport); |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 46 | |
| 47 | BOOST_CHECK_EQUAL(transport.getLocalUri(), FaceUri("udp4://127.0.0.1:7001")); |
| 48 | BOOST_CHECK_EQUAL(transport.getRemoteUri(), FaceUri("udp4://127.0.0.1:7002")); |
| 49 | BOOST_CHECK_EQUAL(transport.getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL); // UDP is never local |
| 50 | BOOST_CHECK_EQUAL(transport.getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT); |
| 51 | BOOST_CHECK_EQUAL(transport.getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 52 | BOOST_CHECK_EQUAL(transport.getMtu(), 65535 - 60 - 8); |
| 53 | } |
| 54 | |
| 55 | BOOST_AUTO_TEST_CASE(StaticPropertiesIpv6) |
| 56 | { |
| 57 | udp::socket sock(g_io, udp::endpoint(ip::address_v6::loopback(), 7001)); |
| 58 | sock.connect(udp::endpoint(ip::address_v6::loopback(), 7002)); |
| 59 | UnicastUdpTransport transport(std::move(sock), ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, time::seconds(300)); |
Junxiao Shi | 5b8a2b2 | 2015-10-22 17:20:44 -0700 | [diff] [blame] | 60 | checkStaticPropertiesInitialized(transport); |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 61 | |
| 62 | BOOST_CHECK_EQUAL(transport.getLocalUri(), FaceUri("udp6://[::1]:7001")); |
| 63 | BOOST_CHECK_EQUAL(transport.getRemoteUri(), FaceUri("udp6://[::1]:7002")); |
| 64 | BOOST_CHECK_EQUAL(transport.getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL); // UDP is never local |
| 65 | BOOST_CHECK_EQUAL(transport.getPersistency(), ndn::nfd::FACE_PERSISTENCY_ON_DEMAND); |
| 66 | BOOST_CHECK_EQUAL(transport.getLinkType(), ndn::nfd::LINK_TYPE_POINT_TO_POINT); |
| 67 | BOOST_CHECK_EQUAL(transport.getMtu(), 65535 - 8); |
| 68 | } |
| 69 | |
| 70 | BOOST_AUTO_TEST_SUITE_END() // TestUnicastUdpTransport |
| 71 | BOOST_AUTO_TEST_SUITE_END() // Face |
| 72 | |
| 73 | } // namespace tests |
| 74 | } // namespace face |
| 75 | } // namespace nfd |