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/multicast-udp-transport.hpp" |
Junxiao Shi | 5b8a2b2 | 2015-10-22 17:20:44 -0700 | [diff] [blame] | 27 | #include "transport-properties.hpp" |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 28 | |
| 29 | #include "tests/test-common.hpp" |
| 30 | |
| 31 | namespace nfd { |
| 32 | namespace face { |
| 33 | namespace tests { |
| 34 | |
| 35 | using namespace nfd::tests; |
| 36 | namespace ip = boost::asio::ip; |
| 37 | using ip::udp; |
| 38 | |
| 39 | BOOST_AUTO_TEST_SUITE(Face) |
| 40 | BOOST_FIXTURE_TEST_SUITE(TestMulticastUdpTransport, BaseFixture) |
| 41 | |
| 42 | BOOST_AUTO_TEST_CASE(StaticPropertiesIpv4) |
| 43 | { |
| 44 | udp::socket sockRx(g_io); |
| 45 | sockRx.open(udp::v4()); |
| 46 | sockRx.set_option(udp::socket::reuse_address(true)); |
| 47 | sockRx.bind(udp::endpoint(ip::address::from_string("127.0.0.1"), 7001)); |
| 48 | |
| 49 | udp::socket sockTx(g_io); |
| 50 | sockTx.open(udp::v4()); |
| 51 | sockTx.set_option(udp::socket::reuse_address(true)); |
| 52 | sockTx.bind(udp::endpoint(udp::v4(), 7001)); |
| 53 | |
| 54 | MulticastUdpTransport transport(sockRx.local_endpoint(), |
| 55 | udp::endpoint(ip::address::from_string("230.15.19.47"), 7001), |
| 56 | std::move(sockRx), std::move(sockTx)); |
Junxiao Shi | 5b8a2b2 | 2015-10-22 17:20:44 -0700 | [diff] [blame] | 57 | checkStaticPropertiesInitialized(transport); |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 58 | |
| 59 | BOOST_CHECK_EQUAL(transport.getLocalUri(), FaceUri("udp4://127.0.0.1:7001")); |
| 60 | BOOST_CHECK_EQUAL(transport.getRemoteUri(), FaceUri("udp4://230.15.19.47:7001")); |
| 61 | BOOST_CHECK_EQUAL(transport.getScope(), ndn::nfd::FACE_SCOPE_NON_LOCAL); |
| 62 | BOOST_CHECK_EQUAL(transport.getPersistency(), ndn::nfd::FACE_PERSISTENCY_PERMANENT); |
| 63 | BOOST_CHECK_EQUAL(transport.getLinkType(), ndn::nfd::LINK_TYPE_MULTI_ACCESS); |
| 64 | BOOST_CHECK_EQUAL(transport.getMtu(), 65535 - 60 - 8); |
| 65 | } |
| 66 | |
| 67 | BOOST_AUTO_TEST_SUITE_END() // TestMulticastUdpTransport |
| 68 | BOOST_AUTO_TEST_SUITE_END() // Face |
| 69 | |
| 70 | } // namespace tests |
| 71 | } // namespace face |
| 72 | } // namespace nfd |