blob: 49146acbb08a7e2c3a1c13757c1644b15d81c9ab [file] [log] [blame]
Giulio Grassi624f6c62014-02-18 19:42:14 +01001/* -*- 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
9namespace nfd {
10
11NFD_LOG_INIT("MulticastUdpFace");
12
13
14MulticastUdpFace::MulticastUdpFace(const shared_ptr<MulticastUdpFace::protocol::socket>& socket)
Alexander Afanasyeva39b90b2014-03-05 15:31:00 +000015 : DatagramFace<protocol>(FaceUri(socket->local_endpoint()), socket)
Giulio Grassi624f6c62014-02-18 19:42:14 +010016{
17 NFD_LOG_DEBUG("Face creation. Multicast group: "
18 << m_socket->local_endpoint());
19 m_multicastGroup = m_socket->local_endpoint();
20}
21
22const boost::asio::ip::udp::endpoint&
23MulticastUdpFace::getMulticastGroup() const
24{
25 return m_multicastGroup;
26}
27
28void
29MulticastUdpFace::sendInterest(const Interest& interest)
30{
Alexander Afanasyev7e698e62014-03-07 16:48:35 +000031 onSendInterest(interest);
32
Giulio Grassi624f6c62014-02-18 19:42:14 +010033 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
42void
43MulticastUdpFace::sendData(const Data& data)
44{
Alexander Afanasyev7e698e62014-03-07 16:48:35 +000045 /// \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 Grassi624f6c62014-02-18 19:42:14 +010049 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
58bool
59MulticastUdpFace::isMultiAccess() const
60{
61 return true;
62}
63
64} // namespace nfd