blob: f8114f519a55d1575c0d39f32fc356012d0df36d [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
Alexander Afanasyev52afb3f2014-03-07 09:05:35 +000039 pause();
40
41 virtual void
42 resume();
43
44 virtual void
Alexander Afanasyevf7ca3202014-02-14 22:28:31 -080045 send(const Block& wire);
46
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080047 virtual void
48 send(const Block& header, const Block& payload);
49
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080050private:
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080051 std::string m_unixSocket;
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080052
Alexander Afanasyev5964fb72014-02-18 12:42:45 -080053 typedef StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol> Impl;
54 friend class StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol>;
55 ptr_lib::shared_ptr< Impl > m_impl;
Alexander Afanasyevfe3b1502013-12-18 16:45:03 -080056};
57
58}
59
60#endif