2018-02-04 03:22:01 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2018-01-07 06:34:02 +01:00
|
|
|
|
|
|
|
#pragma once
|
2018-01-07 11:02:41 +01:00
|
|
|
#define HAVE_IRCD_NET_SOCK_OPTS_H
|
2018-01-07 06:34:02 +01:00
|
|
|
|
|
|
|
namespace ircd::net
|
|
|
|
{
|
2018-01-07 11:02:41 +01:00
|
|
|
struct sock_opts;
|
2023-03-20 02:34:43 +01:00
|
|
|
IRCD_OVERLOAD(system);
|
2018-01-07 06:34:02 +01:00
|
|
|
|
2019-03-25 00:20:05 +01:00
|
|
|
bool v6only(const socket &);
|
2023-03-20 02:34:43 +01:00
|
|
|
bool blocking(const socket &, system_t);
|
2018-01-07 06:34:02 +01:00
|
|
|
bool blocking(const socket &);
|
2023-03-03 02:56:27 +01:00
|
|
|
bool nopush(const socket &);
|
2023-03-20 03:48:06 +01:00
|
|
|
bool nodelay(const socket &, system_t);
|
2018-01-07 06:34:02 +01:00
|
|
|
bool nodelay(const socket &);
|
2020-12-25 02:40:31 +01:00
|
|
|
bool quickack(const socket &);
|
2018-01-07 06:34:02 +01:00
|
|
|
bool keepalive(const socket &);
|
|
|
|
time_t linger(const socket &);
|
|
|
|
size_t read_bufsz(const socket &);
|
|
|
|
size_t write_bufsz(const socket &);
|
|
|
|
size_t read_lowat(const socket &);
|
|
|
|
size_t write_lowat(const socket &);
|
2022-07-08 01:42:14 +02:00
|
|
|
int attach(const socket &);
|
2018-01-07 06:34:02 +01:00
|
|
|
|
2023-03-03 04:00:59 +01:00
|
|
|
// returns true if supported, false if unsupported; failures will throw.
|
2023-03-20 02:01:57 +01:00
|
|
|
bool v6only(socket &, const bool);
|
2023-03-20 02:34:43 +01:00
|
|
|
bool blocking(socket &, const bool, system_t);
|
2023-03-20 02:01:57 +01:00
|
|
|
bool blocking(socket &, const bool);
|
|
|
|
bool nopush(socket &, const bool);
|
2023-03-20 03:48:06 +01:00
|
|
|
bool nodelay(socket &, const bool, system_t);
|
2023-03-20 02:01:57 +01:00
|
|
|
bool nodelay(socket &, const bool);
|
|
|
|
bool quickack(socket &, const bool);
|
|
|
|
bool keepalive(socket &, const bool);
|
|
|
|
bool linger(socket &, const time_t); // -1 is OFF; >= 0 is ON
|
|
|
|
bool read_bufsz(socket &, const size_t bytes);
|
|
|
|
bool write_bufsz(socket &, const size_t bytes);
|
|
|
|
bool read_lowat(socket &, const size_t bytes);
|
|
|
|
bool write_lowat(socket &, const size_t bytes);
|
|
|
|
bool attach(const int sd, const int fd);
|
|
|
|
bool attach(socket &, const int fd);
|
|
|
|
bool detach(const int sd, const int fd);
|
|
|
|
bool detach(socket &, const int fd);
|
2018-01-07 06:34:02 +01:00
|
|
|
|
2018-01-07 11:02:41 +01:00
|
|
|
void set(socket &, const sock_opts &);
|
2018-01-07 06:34:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Socket options convenience aggregate. This structure allows observation
|
|
|
|
/// or manipulation of socket options all together. Pass an active socket to
|
2018-01-07 11:02:41 +01:00
|
|
|
/// the constructor to observe all options. Use net::set(socket, sock_opts) to
|
2018-01-07 06:34:02 +01:00
|
|
|
/// set all non-ignored options.
|
2018-01-07 11:02:41 +01:00
|
|
|
struct ircd::net::sock_opts
|
2018-01-07 06:34:02 +01:00
|
|
|
{
|
|
|
|
/// Magic value to not set this option on a set() pass.
|
|
|
|
static constexpr int8_t IGN { std::numeric_limits<int8_t>::min() };
|
|
|
|
|
2019-03-25 00:20:05 +01:00
|
|
|
int8_t v6only { IGN };
|
2018-01-07 06:34:02 +01:00
|
|
|
int8_t blocking { IGN }; // Simulates blocking behavior
|
2023-03-03 02:56:27 +01:00
|
|
|
int8_t nopush { IGN };
|
2018-01-07 06:34:02 +01:00
|
|
|
int8_t nodelay { IGN };
|
2020-12-25 02:40:31 +01:00
|
|
|
int8_t quickack { IGN };
|
2018-01-07 06:34:02 +01:00
|
|
|
int8_t keepalive { IGN };
|
|
|
|
time_t linger { IGN }; // -1 is OFF; >= 0 is ON
|
|
|
|
ssize_t read_bufsz { IGN };
|
|
|
|
ssize_t write_bufsz { IGN };
|
|
|
|
ssize_t read_lowat { IGN };
|
|
|
|
ssize_t write_lowat { IGN };
|
2022-07-08 01:42:14 +02:00
|
|
|
int ebpf { -1 };
|
2018-01-07 06:34:02 +01:00
|
|
|
|
2018-01-07 11:02:41 +01:00
|
|
|
sock_opts(const socket &); // Get options from socket
|
|
|
|
sock_opts() = default;
|
2018-01-07 06:34:02 +01:00
|
|
|
};
|