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;
|
2018-01-07 06:34:02 +01:00
|
|
|
|
2019-03-25 00:20:05 +01:00
|
|
|
bool v6only(const socket &);
|
2018-01-07 06:34:02 +01:00
|
|
|
bool blocking(const socket &);
|
|
|
|
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
|
|
|
|
2019-03-25 00:20:05 +01:00
|
|
|
void v6only(socket &, const bool &);
|
2018-01-07 06:34:02 +01:00
|
|
|
void blocking(socket &, const bool &);
|
|
|
|
void nodelay(socket &, const bool &);
|
2020-12-25 02:40:31 +01:00
|
|
|
void quickack(socket &, const bool &);
|
2018-01-07 06:34:02 +01:00
|
|
|
void keepalive(socket &, const bool &);
|
|
|
|
void linger(socket &, const time_t &); // -1 is OFF; >= 0 is ON
|
|
|
|
void read_bufsz(socket &, const size_t &bytes);
|
|
|
|
void write_bufsz(socket &, const size_t &bytes);
|
|
|
|
void read_lowat(socket &, const size_t &bytes);
|
|
|
|
void write_lowat(socket &, const size_t &bytes);
|
2022-07-08 01:42:14 +02:00
|
|
|
void attach(const int &sd, const int &fd);
|
|
|
|
void attach(socket &, const int &fd);
|
|
|
|
void detach(const int &sd, const int &fd);
|
|
|
|
void 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
|
|
|
|
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
|
|
|
};
|