Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "multicast-udp-face.hpp" |
| 8 | |
| 9 | namespace nfd { |
| 10 | |
| 11 | NFD_LOG_INIT("MulticastUdpFace"); |
| 12 | |
| 13 | |
| 14 | MulticastUdpFace::MulticastUdpFace(const shared_ptr<MulticastUdpFace::protocol::socket>& socket) |
| 15 | : UdpFace(socket) |
| 16 | { |
| 17 | NFD_LOG_DEBUG("Face creation. Multicast group: " |
| 18 | << m_socket->local_endpoint()); |
| 19 | m_multicastGroup = m_socket->local_endpoint(); |
| 20 | } |
| 21 | |
| 22 | const boost::asio::ip::udp::endpoint& |
| 23 | MulticastUdpFace::getMulticastGroup() const |
| 24 | { |
| 25 | return m_multicastGroup; |
| 26 | } |
| 27 | |
| 28 | void |
| 29 | MulticastUdpFace::sendInterest(const Interest& interest) |
| 30 | { |
| 31 | NFD_LOG_DEBUG("Sending interest"); |
| 32 | m_socket->async_send_to(boost::asio::buffer(interest.wireEncode().wire(), |
| 33 | interest.wireEncode().size()), |
| 34 | m_multicastGroup, |
| 35 | bind(&DatagramFace<protocol>::handleSend, this, _1, interest.wireEncode())); |
| 36 | |
| 37 | // anything else should be done here? |
| 38 | } |
| 39 | |
| 40 | void |
| 41 | MulticastUdpFace::sendData(const Data& data) |
| 42 | { |
| 43 | NFD_LOG_DEBUG("Sending data"); |
| 44 | m_socket->async_send_to(boost::asio::buffer(data.wireEncode().wire(), |
| 45 | data.wireEncode().size()), |
| 46 | m_multicastGroup, |
| 47 | bind(&DatagramFace<protocol>::handleSend, this, _1, data.wireEncode())); |
| 48 | |
| 49 | // anything else should be done here? |
| 50 | } |
| 51 | |
| 52 | bool |
| 53 | MulticastUdpFace::isMultiAccess() const |
| 54 | { |
| 55 | return true; |
| 56 | } |
| 57 | |
| 58 | } // namespace nfd |