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; -*- */
2
/*
3
* Copyright (c) 2013-2017 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#ifndef NDN_TRANSPORT_TRANSPORT_HPP
23
#define NDN_TRANSPORT_TRANSPORT_HPP
24
25
#include "../common.hpp"
26
#include "../encoding/block.hpp"
27
#include "../net/asio-fwd.hpp"
28
29
#include <boost/system/error_code.hpp>
30
31
namespace
ndn
{
32
35
class
Transport
: noncopyable
36
{
37
public
:
38
class
Error
:
public
std::runtime_error
39
{
40
public
:
41
Error
(
const
boost::system::error_code& code,
const
std::string& msg);
42
43
explicit
44
Error
(
const
std::string& msg);
45
};
46
47
typedef
function<void(const Block& wire)>
ReceiveCallback
;
48
typedef
function<void()>
ErrorCallback
;
49
50
Transport
();
51
52
virtual
53
~Transport
() =
default
;
54
59
virtual
void
60
connect
(
const
ReceiveCallback
& receiveCallback);
61
64
virtual
void
65
close
() = 0;
66
69
virtual
void
70
send
(
const
Block
& wire) = 0;
71
77
virtual
void
78
send
(
const
Block
& header,
const
Block
& payload) = 0;
79
85
virtual
void
86
pause
() = 0;
87
93
virtual
void
94
resume
() = 0;
95
99
bool
100
isConnected
()
const
;
101
105
bool
106
isReceiving
()
const
;
107
108
protected
:
111
void
112
receive
(
const
Block
& wire);
113
114
protected
:
115
bool
m_isConnected
;
116
bool
m_isReceiving
;
117
ReceiveCallback
m_receiveCallback
;
118
};
119
120
inline
bool
121
Transport::isConnected
()
const
122
{
123
return
m_isConnected
;
124
}
125
126
inline
bool
127
Transport::isReceiving
()
const
128
{
129
return
m_isReceiving
;
130
}
131
132
inline
void
133
Transport::receive
(
const
Block
& wire)
134
{
135
m_receiveCallback
(wire);
136
}
137
138
}
// namespace ndn
139
140
#endif // NDN_TRANSPORT_TRANSPORT_HPP
ndn::Transport::Error
Definition:
transport.hpp:38
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.cpp:26
ndn::Transport::close
virtual void close()=0
Close the connection.
ndn::Block
Represents a TLV element of NDN packet format.
Definition:
block.hpp:42
ndn::Transport::send
virtual void send(const Block &wire)=0
send a TLV block through the transport
ndn::Transport::isConnected
bool isConnected() const
Definition:
transport.hpp:121
ndn::Transport::m_receiveCallback
ReceiveCallback m_receiveCallback
Definition:
transport.hpp:117
ndn::Transport::isReceiving
bool isReceiving() const
Definition:
transport.hpp:127
ndn::Transport::Transport
Transport()
Definition:
transport.cpp:36
ndn::Transport::ErrorCallback
function< void()> ErrorCallback
Definition:
transport.hpp:48
ndn::Transport::resume
virtual void resume()=0
resume the transport
ndn::Transport::receive
void receive(const Block &wire)
invoke the receive callback
Definition:
transport.hpp:133
ndn::Transport::connect
virtual void connect(const ReceiveCallback &receiveCallback)
asynchronously open the connection
Definition:
transport.cpp:43
ndn::Transport
provides TLV-block delivery service
Definition:
transport.hpp:35
ndn::Transport::pause
virtual void pause()=0
pause the transport
ndn::Transport::m_isReceiving
bool m_isReceiving
Definition:
transport.hpp:116
ndn::Transport::m_isConnected
bool m_isConnected
Definition:
transport.hpp:115
ndn::Transport::~Transport
virtual ~Transport()=default
ndn::Transport::ReceiveCallback
function< void(const Block &wire)> ReceiveCallback
Definition:
transport.hpp:47
ndnSIM
ndn-cxx
src
transport
transport.hpp
Generated on Tue Aug 7 2018 16:19:17 for ndnSIM by
1.8.14