blob: e56c147834fe21b2cdeaac6a0684f2d7494efa09 [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{
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
40void
41MulticastUdpFace::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
52bool
53MulticastUdpFace::isMultiAccess() const
54{
55 return true;
56}
57
58} // namespace nfd