Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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/internal/api-level.hh>
26#include <seastar/core/memory.hh>
27
28namespace seastar {
29
30namespace net {
31
33class connected_socket_impl {
34public:
35 virtual ~connected_socket_impl() {}
36 virtual data_source source() = 0;
37 virtual data_source source(connected_socket_input_stream_config csisc);
38 virtual data_sink sink() = 0;
39 virtual void shutdown_input() = 0;
40 virtual void shutdown_output() = 0;
41 virtual void set_nodelay(bool nodelay) = 0;
42 virtual bool get_nodelay() const = 0;
43 virtual void set_keepalive(bool keepalive) = 0;
44 virtual bool get_keepalive() const = 0;
45 virtual void set_keepalive_parameters(const keepalive_params&) = 0;
46 virtual keepalive_params get_keepalive_parameters() const = 0;
47 virtual void set_sockopt(int level, int optname, const void* data, size_t len) = 0;
48 virtual int get_sockopt(int level, int optname, void* data, size_t len) const = 0;
49 virtual socket_address local_address() const noexcept = 0;
50 virtual socket_address remote_address() const noexcept = 0;
51 virtual future<> wait_input_shutdown() = 0;
52};
53
54class socket_impl {
55public:
56 socket_impl() = default;
57 socket_impl(const socket_impl&) = delete;
58 socket_impl(socket_impl&&) = default;
59 virtual ~socket_impl() {}
60 virtual future<connected_socket> connect(socket_address sa, socket_address local, transport proto = transport::TCP) = 0;
61 virtual void set_reuseaddr(bool reuseaddr) = 0;
62 virtual bool get_reuseaddr() const = 0;
63 virtual void shutdown() = 0;
64};
65
66
67class server_socket_impl {
68public:
69 virtual ~server_socket_impl() {}
70 virtual future<accept_result> accept() = 0;
71 virtual void abort_accept() = 0;
72 virtual socket_address local_address() const = 0;
73};
74
75class datagram_channel_impl {
76public:
77 virtual ~datagram_channel_impl() {}
78 virtual socket_address local_address() const = 0;
79 virtual future<datagram> receive() = 0;
80 virtual future<> send(const socket_address& dst, const char* msg) = 0;
81 virtual future<> send(const socket_address& dst, packet p) = 0;
82 virtual void shutdown_input() = 0;
83 virtual void shutdown_output() = 0;
84 virtual bool is_closed() const = 0;
85 virtual void close() = 0;
86};
87
88using udp_channel_impl = datagram_channel_impl;
89
90class network_interface_impl {
91protected:
92 network_interface_impl() = default;
93 network_interface_impl(const network_interface_impl&) = default;
94 virtual ~network_interface_impl() {}
95public:
96 virtual uint32_t index() const = 0;
97 virtual uint32_t mtu() const = 0;
98
99 virtual const sstring& name() const = 0;
100 virtual const sstring& display_name() const = 0;
101 virtual const std::vector<net::inet_address>& addresses() const = 0;
102 virtual const std::vector<uint8_t> hardware_address() const = 0;
103
104 virtual bool is_loopback() const = 0;
105 virtual bool is_virtual() const = 0;
106 virtual bool is_up() const = 0;
107 virtual bool supports_ipv6() const = 0;
108};
109
111
112}
113
114}
future< connected_socket > connect(socket_address sa)
Seastar API namespace.
Definition: abort_on_ebadf.hh:26