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) |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 15 | : DatagramFace<protocol>(FaceUri(socket->local_endpoint()), socket) |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 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 | { |
Alexander Afanasyev | 7e698e6 | 2014-03-07 16:48:35 +0000 | [diff] [blame^] | 31 | onSendInterest(interest); |
| 32 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 33 | NFD_LOG_DEBUG("Sending interest"); |
| 34 | m_socket->async_send_to(boost::asio::buffer(interest.wireEncode().wire(), |
| 35 | interest.wireEncode().size()), |
| 36 | m_multicastGroup, |
| 37 | bind(&DatagramFace<protocol>::handleSend, this, _1, interest.wireEncode())); |
| 38 | |
| 39 | // anything else should be done here? |
| 40 | } |
| 41 | |
| 42 | void |
| 43 | MulticastUdpFace::sendData(const Data& data) |
| 44 | { |
Alexander Afanasyev | 7e698e6 | 2014-03-07 16:48:35 +0000 | [diff] [blame^] | 45 | /// \todo After this method implements duplicate suppression, onSendData event should |
| 46 | /// be triggered only when data is actually sent out |
| 47 | onSendData(data); |
| 48 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 49 | NFD_LOG_DEBUG("Sending data"); |
| 50 | m_socket->async_send_to(boost::asio::buffer(data.wireEncode().wire(), |
| 51 | data.wireEncode().size()), |
| 52 | m_multicastGroup, |
| 53 | bind(&DatagramFace<protocol>::handleSend, this, _1, data.wireEncode())); |
| 54 | |
| 55 | // anything else should be done here? |
| 56 | } |
| 57 | |
| 58 | bool |
| 59 | MulticastUdpFace::isMultiAccess() const |
| 60 | { |
| 61 | return true; |
| 62 | } |
| 63 | |
| 64 | } // namespace nfd |