]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/include/seastar/net/stack.hh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / include / seastar / net / stack.hh
1 /*
2 * This file is open source software, licensed to you under the terms
3 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4 * distributed with this work for additional information regarding copyright
5 * ownership. You may not use this file except in compliance with the License.
6 *
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 */
18 /*
19 * Copyright 2015 Cloudius Systems
20 */
21 #pragma once
22
23 #include <chrono>
24 #include <seastar/net/api.hh>
25 #include <seastar/core/memory.hh>
26 #include "../core/internal/api-level.hh"
27
28 namespace seastar {
29
30 namespace net {
31
32 /// \cond internal
33 class connected_socket_impl {
34 public:
35 virtual ~connected_socket_impl() {}
36 virtual data_source source() = 0;
37 virtual data_sink sink() = 0;
38 virtual void shutdown_input() = 0;
39 virtual void shutdown_output() = 0;
40 virtual void set_nodelay(bool nodelay) = 0;
41 virtual bool get_nodelay() const = 0;
42 virtual void set_keepalive(bool keepalive) = 0;
43 virtual bool get_keepalive() const = 0;
44 virtual void set_keepalive_parameters(const keepalive_params&) = 0;
45 virtual keepalive_params get_keepalive_parameters() const = 0;
46 };
47
48 class socket_impl {
49 public:
50 virtual ~socket_impl() {}
51 virtual future<connected_socket> connect(socket_address sa, socket_address local, transport proto = transport::TCP) = 0;
52 virtual void set_reuseaddr(bool reuseaddr) = 0;
53 virtual bool get_reuseaddr() const = 0;
54 virtual void shutdown() = 0;
55 };
56
57
58 SEASTAR_INCLUDE_API_V2 namespace api_v2 {
59
60 class server_socket_impl {
61 public:
62 virtual ~server_socket_impl() {}
63 virtual future<accept_result> accept() = 0;
64 virtual void abort_accept() = 0;
65 virtual socket_address local_address() const = 0;
66 };
67
68 }
69
70 #if SEASTAR_API_LEVEL <= 1
71
72 SEASTAR_INCLUDE_API_V1 namespace api_v1 {
73
74 class server_socket_impl {
75 public:
76 virtual ~server_socket_impl() {}
77 virtual future<connected_socket, socket_address> accept() = 0;
78 virtual void abort_accept() = 0;
79 virtual socket_address local_address() const = 0;
80 };
81
82 }
83
84 #endif
85
86 class udp_channel_impl {
87 public:
88 virtual ~udp_channel_impl() {}
89 virtual socket_address local_address() const = 0;
90 virtual future<udp_datagram> receive() = 0;
91 virtual future<> send(const socket_address& dst, const char* msg) = 0;
92 virtual future<> send(const socket_address& dst, packet p) = 0;
93 virtual void shutdown_input() = 0;
94 virtual void shutdown_output() = 0;
95 virtual bool is_closed() const = 0;
96 virtual void close() = 0;
97 };
98
99 class network_interface_impl {
100 public:
101 virtual ~network_interface_impl() {}
102 virtual uint32_t index() const = 0;
103 virtual uint32_t mtu() const = 0;
104
105 virtual const sstring& name() const = 0;
106 virtual const sstring& display_name() const = 0;
107 virtual const std::vector<net::inet_address>& addresses() const = 0;
108 virtual const std::vector<uint8_t> hardware_address() const = 0;
109
110 virtual bool is_loopback() const = 0;
111 virtual bool is_virtual() const = 0;
112 virtual bool is_up() const = 0;
113 virtual bool supports_ipv6() const = 0;
114 };
115
116 /// \endcond
117
118 }
119
120 }