blob: 4a89bc8e0015e298467c67f2bdd682b1b86a5eb9 [file] [log] [blame]
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyev5964fb72014-02-18 12:42:45 -08003 * Copyright (C) 2013-2014 Regents of the University of California.
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -08004 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_UDPTRANSPORT_HPP
8#define NDN_UDPTRANSPORT_HPP
9
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080010#include "../common.hpp"
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080011#include "transport.hpp"
12
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080013// forward declaration
14namespace boost { namespace asio { namespace local { class stream_protocol; } } }
15
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080016namespace ndn {
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080017
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080018// forward declaration
19template<class T, class U>
20class StreamTransportImpl;
21
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080022class UnixTransport : public Transport
23{
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080024public:
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080025 UnixTransport();
26
27 UnixTransport(const std::string& unixSocket);
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080028 ~UnixTransport();
29
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080030 // from Transport
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080031 virtual void
32 connect(boost::asio::io_service& ioService,
33 const ReceiveCallback& receiveCallback);
34
35 virtual void
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080036 close();
Alexander Afanasyeve2e0d752014-01-03 13:30:30 -080037
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080038 virtual void
39 send(const Block& wire);
40
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080041 virtual void
42 send(const Block& header, const Block& payload);
43
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080044private:
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080045 std::string m_unixSocket;
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080046
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080047 typedef StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol> Impl;
48 friend class StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol>;
49 ptr_lib::shared_ptr< Impl > m_impl;
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080050};
51
52}
53
54#endif