Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame^] | 3 | * Copyright (C) 2013-2014 Regents of the University of California. |
Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NDN_UDPTRANSPORT_HPP |
| 8 | #define NDN_UDPTRANSPORT_HPP |
| 9 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 10 | #include "../common.hpp" |
Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 11 | #include "transport.hpp" |
| 12 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame^] | 13 | // forward declaration |
| 14 | namespace boost { namespace asio { namespace local { class stream_protocol; } } } |
| 15 | |
Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 16 | namespace ndn { |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame] | 17 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame^] | 18 | // forward declaration |
| 19 | template<class T, class U> |
| 20 | class StreamTransportImpl; |
| 21 | |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 22 | class UnixTransport : public Transport |
| 23 | { |
Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 24 | public: |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame] | 25 | UnixTransport(); |
| 26 | |
| 27 | UnixTransport(const std::string& unixSocket); |
Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 28 | ~UnixTransport(); |
| 29 | |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 30 | // from Transport |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame] | 31 | virtual void |
| 32 | connect(boost::asio::io_service& ioService, |
| 33 | const ReceiveCallback& receiveCallback); |
| 34 | |
| 35 | virtual void |
Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 36 | close(); |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 37 | |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame] | 38 | virtual void |
| 39 | send(const Block& wire); |
| 40 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame^] | 41 | virtual void |
| 42 | send(const Block& header, const Block& payload); |
| 43 | |
Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 44 | private: |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame^] | 45 | std::string m_unixSocket; |
Alexander Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 46 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame^] | 47 | 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 Afanasyev | fe3b150 | 2013-12-18 16:45:03 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | } |
| 53 | |
| 54 | #endif |