NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
transport.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#ifndef NDN_TRANSPORT_TRANSPORT_HPP
23
#define NDN_TRANSPORT_TRANSPORT_HPP
24
25
#include "../common.hpp"
26
#include "../encoding/block.hpp"
27
28
#include <boost/asio.hpp>
29
30
namespace
ndn
{
31
32
class
Transport
: noncopyable
33
{
34
public
:
35
class
Error
:
public
std::runtime_error
36
{
37
public
:
38
inline
Error
(
const
boost::system::error_code& code,
const
std::string& msg);
39
inline
Error
(
const
std::string& msg);
40
};
41
42
typedef
function<void (const Block& wire)>
ReceiveCallback
;
43
typedef
function<void ()>
ErrorCallback
;
44
45
inline
46
Transport
();
47
48
inline
virtual
49
~Transport
();
50
56
inline
virtual
void
57
connect
(boost::asio::io_service& io_service,
58
const
ReceiveCallback
& receiveCallback);
59
63
virtual
void
64
close
() = 0;
65
71
virtual
void
72
send
(
const
Block
& wire) = 0;
73
80
virtual
void
81
send
(
const
Block
& header,
const
Block
& payload) = 0;
82
83
virtual
void
84
pause
() = 0;
85
86
virtual
void
87
resume
() = 0;
88
89
inline
bool
90
isConnected
();
91
92
inline
bool
93
isExpectingData
();
94
95
protected
:
96
inline
void
97
receive
(
const
Block
& wire);
98
99
protected
:
100
boost::asio::io_service*
m_ioService
;
101
bool
m_isConnected
;
102
bool
m_isExpectingData
;
103
ReceiveCallback
m_receiveCallback
;
104
};
105
106
inline
107
Transport::Transport
()
108
: m_ioService(0)
109
, m_isConnected(false)
110
, m_isExpectingData(false)
111
{
112
}
113
114
inline
115
Transport::Error::Error
(
const
boost::system::error_code& code,
const
std::string& msg)
116
:
std
::runtime_error(msg + (code.value() ?
" ("
+ code.category().message(code.value()) +
")"
:
""
))
117
{
118
}
119
120
inline
121
Transport::Error::Error
(
const
std::string& msg)
122
:
std
::runtime_error(msg)
123
{
124
}
125
126
inline
127
Transport::~Transport
()
128
{
129
}
130
131
inline
void
132
Transport::connect
(boost::asio::io_service& ioService,
133
const
ReceiveCallback
& receiveCallback)
134
{
135
m_ioService
= &ioService;
136
m_receiveCallback
= receiveCallback;
137
}
138
139
inline
bool
140
Transport::isConnected
()
141
{
142
return
m_isConnected
;
143
}
144
145
inline
bool
146
Transport::isExpectingData
()
147
{
148
return
m_isExpectingData
;
149
}
150
151
inline
void
152
Transport::receive
(
const
Block
& wire)
153
{
154
m_receiveCallback
(wire);
155
}
156
157
}
// namespace ndn
158
159
#endif // NDN_TRANSPORT_TRANSPORT_HPP
ndn::Transport::connect
virtual void connect(boost::asio::io_service &io_service, const ReceiveCallback &receiveCallback)
Connect transport.
Definition:
transport.hpp:132
ndn::Transport::Error
Definition:
transport.hpp:35
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::Transport::Error::Error
Error(const boost::system::error_code &code, const std::string &msg)
Definition:
transport.hpp:115
ndn::Transport::close
virtual void close()=0
Close the connection.
std
STL namespace.
ndn::Transport::ErrorCallback
function< void()> ErrorCallback
Definition:
transport.hpp:43
ndn::Block
Class representing a wire element of NDN-TLV packet format.
Definition:
block.hpp:43
ndn::Transport::send
virtual void send(const Block &wire)=0
Send block of data from.
ndn::Transport::m_receiveCallback
ReceiveCallback m_receiveCallback
Definition:
transport.hpp:103
ndn::Transport::m_isExpectingData
bool m_isExpectingData
Definition:
transport.hpp:102
ndn::Transport::Transport
Transport()
Definition:
transport.hpp:107
ndn::Transport::ReceiveCallback
function< void(const Block &wire)> ReceiveCallback
Definition:
transport.hpp:42
ndn::Transport::resume
virtual void resume()=0
ndn::Transport::m_ioService
boost::asio::io_service * m_ioService
Definition:
transport.hpp:100
ndn::Transport::receive
void receive(const Block &wire)
Definition:
transport.hpp:152
ndn::Transport
Definition:
transport.hpp:32
ndn::Transport::pause
virtual void pause()=0
ndn::Transport::isConnected
bool isConnected()
Definition:
transport.hpp:140
ndn::Transport::m_isConnected
bool m_isConnected
Definition:
transport.hpp:101
ndn::Transport::~Transport
virtual ~Transport()
Definition:
transport.hpp:127
ndn::Transport::isExpectingData
bool isExpectingData()
Definition:
transport.hpp:146
ndnSIM
ndn-cxx
src
transport
transport.hpp
Generated on Fri Feb 23 2018 12:30:55 for ndnSIM by
1.8.14