NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
base.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015, Peter Thorson. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
6
* * Redistributions of source code must retain the above copyright
7
* notice, this list of conditions and the following disclaimer.
8
* * Redistributions in binary form must reproduce the above copyright
9
* notice, this list of conditions and the following disclaimer in the
10
* documentation and/or other materials provided with the distribution.
11
* * Neither the name of the WebSocket++ Project nor the
12
* names of its contributors may be used to endorse or promote products
13
* derived from this software without specific prior written permission.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
*
26
*/
27
28
#ifndef WEBSOCKETPP_TRANSPORT_ASIO_SOCKET_BASE_HPP
29
#define WEBSOCKETPP_TRANSPORT_ASIO_SOCKET_BASE_HPP
30
31
#include <
websocketpp/common/asio.hpp
>
32
#include <
websocketpp/common/memory.hpp
>
33
#include <
websocketpp/common/functional.hpp
>
34
#include <
websocketpp/common/system_error.hpp
>
35
#include <
websocketpp/common/cpp11.hpp
>
36
#include <
websocketpp/common/connection_hdl.hpp
>
37
38
#include <string>
39
40
// Interface that sockets/security policies must implement
41
42
/*
43
* Endpoint Interface
44
*
45
* bool is_secure() const;
46
* @return Whether or not the endpoint creates secure connections
47
*
48
* lib::error_code init(socket_con_ptr scon);
49
* Called by the transport after a new connection is created to initialize
50
* the socket component of the connection.
51
* @param scon Pointer to the socket component of the connection
52
* @return Error code (empty on success)
53
*/
54
55
56
// Connection
57
// TODO
58
// set_hostname(std::string hostname)
59
// pre_init(init_handler);
60
// post_init(init_handler);
61
62
namespace
websocketpp
{
63
namespace
transport {
64
namespace
asio
{
65
namespace
socket
{
66
67
typedef
lib::function<void(lib::asio::error_code const &)>
shutdown_handler
;
68
74
namespace
error {
76
enum
value
{
79
security
= 1,
80
83
socket
,
84
86
invalid_state
,
87
90
invalid_tls_context
,
91
93
tls_handshake_timeout
,
94
96
pass_through
,
97
99
missing_tls_init_handler
,
100
102
tls_handshake_failed
,
103
105
tls_failed_sni_hostname
106
};
107
}
// namespace error
108
110
class
socket_category
:
public
lib::error_category {
111
public
:
112
char
const
*
name
() const
_WEBSOCKETPP_NOEXCEPT_TOKEN_
{
113
return
"websocketpp.transport.asio.socket"
;
114
}
115
116
std::string
message
(
int
value
)
const
{
117
switch
(value) {
118
case
error::security
:
119
return
"Security policy error"
;
120
case
error::socket
:
121
return
"Socket component error"
;
122
case
error::invalid_state
:
123
return
"Invalid state"
;
124
case
error::invalid_tls_context
:
125
return
"Invalid or empty TLS context supplied"
;
126
case
error::tls_handshake_timeout
:
127
return
"TLS handshake timed out"
;
128
case
error::pass_through
:
129
return
"Pass through from socket policy"
;
130
case
error::missing_tls_init_handler
:
131
return
"Required tls_init handler not present."
;
132
case
error::tls_handshake_failed
:
133
return
"TLS handshake failed"
;
134
case
error::tls_failed_sni_hostname
:
135
return
"Failed to set TLS SNI hostname"
;
136
default
:
137
return
"Unknown"
;
138
}
139
}
140
};
141
142
inline
lib::error_category
const
&
get_socket_category
() {
143
static
socket_category
instance;
144
return
instance;
145
}
146
147
inline
lib::error_code
make_error_code
(
error::value
e) {
148
return
lib::error_code(static_cast<int>(e),
get_socket_category
());
149
}
150
152
typedef
lib::function<void(const lib::error_code&)>
init_handler
;
153
154
}
// namespace socket
155
}
// namespace asio
156
}
// namespace transport
157
}
// namespace websocketpp
158
159
#endif // WEBSOCKETPP_TRANSPORT_ASIO_SOCKET_BASE_HPP
websocketpp::transport::asio::socket::socket_category
Error category related to asio transport socket policies.
Definition:
base.hpp:110
_WEBSOCKETPP_NOEXCEPT_TOKEN_
#define _WEBSOCKETPP_NOEXCEPT_TOKEN_
Definition:
cpp11.hpp:113
websocketpp::transport::asio::socket::socket_category::name
char const * name() const _WEBSOCKETPP_NOEXCEPT_TOKEN_
Definition:
base.hpp:112
websocketpp::transport::asio::socket::error::value
value
Definition:
base.hpp:76
websocketpp::transport::asio::socket::error::missing_tls_init_handler
Required tls_init handler not present.
Definition:
base.hpp:99
websocketpp::transport::asio::socket::error::pass_through
pass_through from underlying library
Definition:
base.hpp:96
websocketpp::transport::asio::socket::error::tls_handshake_timeout
TLS Handshake Timeout.
Definition:
base.hpp:93
websocketpp::transport::asio::socket::error::security
Catch-all error for security policy errors that don't fit in other categories.
Definition:
base.hpp:79
websocketpp::transport::asio::socket::error::tls_handshake_failed
TLS Handshake Failed.
Definition:
base.hpp:102
system_error.hpp
websocketpp::transport::asio::socket::error::invalid_state
A function was called in a state that it was illegal to do so.
Definition:
base.hpp:86
websocketpp::transport::asio::socket::socket_category::message
std::string message(int value) const
Definition:
base.hpp:116
websocketpp::transport::asio::socket::error::invalid_tls_context
The application was prompted to provide a TLS context and it was empty or otherwise invalid...
Definition:
base.hpp:90
websocketpp
Namespace for the WebSocket++ project.
Definition:
base64.hpp:41
asio.hpp
websocketpp::transport::asio::socket::shutdown_handler
lib::function< void(lib::asio::error_code const &)> shutdown_handler
Definition:
base.hpp:67
ndn::security
Definition:
dummy-keychain.cpp:28
cpp11.hpp
websocketpp::lib::asio
Definition:
asio.hpp:94
connection_hdl.hpp
websocketpp::transport::asio::socket::error::tls_failed_sni_hostname
Failed to set TLS SNI hostname.
Definition:
base.hpp:105
websocketpp::transport::asio::socket::error::socket
Catch-all error for socket component errors that don't fit in other categories.
Definition:
base.hpp:83
websocketpp::transport::asio::socket::get_socket_category
lib::error_category const & get_socket_category()
Definition:
base.hpp:142
websocketpp::transport::asio::socket::make_error_code
lib::error_code make_error_code(error::value e)
Definition:
base.hpp:147
memory.hpp
websocketpp::transport::asio::socket::init_handler
lib::function< void(const lib::error_code &)> init_handler
Type of asio transport socket policy initialization handlers.
Definition:
base.hpp:152
functional.hpp
ndnSIM
NFD
websocketpp
websocketpp
transport
asio
security
base.hpp
Generated on Fri May 6 2022 12:34:15 for ndnSIM by
1.8.13