NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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/system/error_code.hpp>
29
30
// forward declaration
31
namespace
boost
{
32
namespace
asio {
33
class
io_service;
34
}
// namespace asio
35
}
// namespace boost
36
37
namespace
ndn
{
38
39
class
Transport
: noncopyable
40
{
41
public
:
42
class
Error
:
public
std::runtime_error
43
{
44
public
:
45
inline
Error
(
const
boost::system::error_code& code,
const
std::string& msg);
46
inline
Error
(
const
std::string& msg);
47
};
48
49
typedef
function<void (const Block& wire)>
ReceiveCallback
;
50
typedef
function<void ()>
ErrorCallback
;
51
52
inline
53
Transport
();
54
55
inline
virtual
56
~
Transport
();
57
63
inline
virtual
void
64
connect(boost::asio::io_service& io_service,
65
const
ReceiveCallback& receiveCallback);
66
70
virtual
void
71
close() = 0;
72
78
virtual
void
79
send(
const
Block
& wire) = 0;
80
87
virtual
void
88
send(
const
Block
& header,
const
Block
& payload) = 0;
89
90
virtual
void
91
pause() = 0;
92
93
virtual
void
94
resume() = 0;
95
96
inline
bool
97
isConnected();
98
99
inline
bool
100
isExpectingData();
101
102
protected
:
103
inline
void
104
receive(
const
Block
& wire);
105
106
protected
:
107
boost::asio::io_service*
m_ioService
;
108
bool
m_isConnected
;
109
bool
m_isExpectingData
;
110
ReceiveCallback
m_receiveCallback
;
111
};
112
113
inline
114
Transport::Transport
()
115
: m_ioService(0)
116
, m_isConnected(false)
117
, m_isExpectingData(false)
118
{
119
}
120
121
inline
122
Transport::Error::Error
(
const
boost::system::error_code& code,
const
std::string& msg)
123
:
std
::runtime_error(msg + (code.value() ?
" ("
+ code.category().message(code.value()) +
")"
:
""
))
124
{
125
}
126
127
inline
128
Transport::Error::Error
(
const
std::string& msg)
129
:
std
::runtime_error(msg)
130
{
131
}
132
133
inline
134
Transport::~Transport
()
135
{
136
}
137
138
inline
void
139
Transport::connect
(boost::asio::io_service& ioService,
140
const
ReceiveCallback
& receiveCallback)
141
{
142
m_ioService
= &ioService;
143
m_receiveCallback
= receiveCallback;
144
}
145
146
inline
bool
147
Transport::isConnected
()
148
{
149
return
m_isConnected
;
150
}
151
152
inline
bool
153
Transport::isExpectingData
()
154
{
155
return
m_isExpectingData
;
156
}
157
158
inline
void
159
Transport::receive
(
const
Block
& wire)
160
{
161
m_receiveCallback
(wire);
162
}
163
164
}
// namespace ndn
165
166
#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:139
ndn::Transport::Error
Definition:
transport.hpp:42
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
boost
Copyright (c) 2013-2015 Regents of the University of California.
Definition:
ndn-content-store.hpp:209
ndn::Transport::Error::Error
Error(const boost::system::error_code &code, const std::string &msg)
Definition:
transport.hpp:122
nfd::face::Transport
Transport
Definition:
transport.cpp:32
std
STL namespace.
ndn::Transport::ErrorCallback
function< void()> ErrorCallback
Definition:
transport.hpp:50
ndn::Block
Class representing a wire element of NDN-TLV packet format.
Definition:
block.hpp:43
ndn::Transport::m_receiveCallback
ReceiveCallback m_receiveCallback
Definition:
transport.hpp:110
ndn::Transport::m_isExpectingData
bool m_isExpectingData
Definition:
transport.hpp:109
ndn::Transport::ReceiveCallback
function< void(const Block &wire)> ReceiveCallback
Definition:
transport.hpp:49
ndn::Transport::m_ioService
boost::asio::io_service * m_ioService
Definition:
transport.hpp:107
ndn::Transport::receive
void receive(const Block &wire)
Definition:
transport.hpp:159
ndn::Transport
Definition:
transport.hpp:39
ndn::Transport::isConnected
bool isConnected()
Definition:
transport.hpp:147
ndn::Transport::m_isConnected
bool m_isConnected
Definition:
transport.hpp:108
ndn::Transport::~Transport
virtual ~Transport()
Definition:
transport.hpp:134
ndn::Transport::isExpectingData
bool isExpectingData()
Definition:
transport.hpp:153
ndnSIM
ndn-cxx
src
transport
transport.hpp
Generated on Sat Nov 12 2016 16:02:54 for ndnSIM by
1.8.12