1 /*
2 * Copyright (c) 2016, Intel Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation and/or
13 * other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 #pragma once
31
32 /** @file
33 *
34 * Stubs ASIO interfaces called by libremote-processor. This is used when
35 * the user asks for networking support to be compiled out.
36 */
37
38 #include <system_error>
39
40 #include <netinet/in.h>
41
42 #define ASIO_OS_DEF(x) (x)
43
44 namespace asio
45 {
46 struct dummy_base
47 {
48 template <class... Args>
dummy_baseasio::dummy_base49 dummy_base(Args &&...)
50 {
51 }
set_optionasio::dummy_base52 void set_option(const dummy_base &) const {};
protocolasio::dummy_base53 int protocol() const { return 0; }
54 };
55 struct endpoint_base : dummy_base
56 {
57 using dummy_base::dummy_base;
58
protocolasio::endpoint_base59 dummy_base protocol() const { return {}; };
60 };
61
62 template <typename T>
63 struct basic_socket_acceptor : dummy_base
64 {
65 using dummy_base::dummy_base;
66
67 using reuse_address = dummy_base;
openasio::basic_socket_acceptor68 void open(const dummy_base &) const {};
bindasio::basic_socket_acceptor69 void bind(const dummy_base &) const {};
listenasio::basic_socket_acceptor70 void listen() const {};
async_acceptasio::basic_socket_acceptor71 void async_accept(const dummy_base &, const dummy_base &) const {};
72 };
73
write(const dummy_base &,const dummy_base &,const dummy_base &)74 inline bool write(const dummy_base &, const dummy_base &, const dummy_base &)
75 {
76 return true;
77 }
read(const dummy_base &,const dummy_base &,const dummy_base &)78 inline bool read(const dummy_base &, const dummy_base &, const dummy_base &)
79 {
80 return true;
81 }
82 using buffer = dummy_base;
83 struct io_service : dummy_base
84 {
85 template <class... Args>
io_serviceasio::io_service86 io_service(Args &&...)
87 {
88 throw std::runtime_error("Stub constructor called. Did you forget to set the "
89 "'TuningAllowed' attribute to 'false' in the Parameter "
90 "Framework's toplevel configuration file?");
91 }
92
runasio::io_service93 void run(const dummy_base &) const {};
stopasio::io_service94 void stop() const {};
95 };
96 struct socket_base : dummy_base
97 {
98 using dummy_base::dummy_base;
99
100 using linger = dummy_base;
101 using enable_connection_aborted = dummy_base;
closeasio::socket_base102 void close() const {};
103
local_endpointasio::socket_base104 const endpoint_base &local_endpoint() const { return base; }
105
106 endpoint_base base;
107 };
108
109 bool write(const dummy_base &, const dummy_base &, const dummy_base &);
110 bool read(const dummy_base &, const dummy_base &, const dummy_base &);
111
112 struct error_code : dummy_base, std::error_code
113 {
114 };
115 namespace error
116 {
117 static const error_code eof{};
118 }
119
120 namespace ip
121 {
122 namespace tcp
123 {
124 using v6 = dummy_base;
125 using no_delay = dummy_base;
126 using endpoint = endpoint_base;
127 using socket = socket_base;
128 using acceptor = basic_socket_acceptor<void>;
129 }
130 }
131
132 namespace generic
133 {
134 struct stream_protocol
135 {
136 using endpoint = endpoint_base;
137 using socket = socket_base;
138 };
139 };
140
141 namespace local
142 {
143 using stream_protocol = generic::stream_protocol;
144 }
145 }
146