event/ServerSocket: add ip_tos setting
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "ServerSocket.hxx"
|
#include "ServerSocket.hxx"
|
||||||
#include "lib/fmt/ExceptionFormatter.hxx"
|
#include "lib/fmt/ExceptionFormatter.hxx"
|
||||||
#include "net/IPv4Address.hxx"
|
#include "net/IPv4Address.hxx"
|
||||||
@@ -36,7 +35,6 @@
|
|||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@@ -183,6 +181,16 @@ ServerSocket::OneServerSocket::Open()
|
|||||||
SOCK_STREAM, 0,
|
SOCK_STREAM, 0,
|
||||||
address, 5);
|
address, 5);
|
||||||
|
|
||||||
|
#ifdef HAVE_TCP
|
||||||
|
if (parent.ip_tos >= 0 && address.GetFamily() == AF_INET &&
|
||||||
|
!_fd.SetIntOption(IPPROTO_IP, IP_TOS, parent.ip_tos)) {
|
||||||
|
const SocketErrorMessage msg;
|
||||||
|
FmtError(server_socket_domain,
|
||||||
|
"Could not set TOS option: {}",
|
||||||
|
(const char *)msg);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UN
|
#ifdef HAVE_UN
|
||||||
/* allow everybody to connect */
|
/* allow everybody to connect */
|
||||||
|
|
||||||
|
@@ -20,6 +20,9 @@
|
|||||||
#ifndef MPD_SERVER_SOCKET_HXX
|
#ifndef MPD_SERVER_SOCKET_HXX
|
||||||
#define MPD_SERVER_SOCKET_HXX
|
#define MPD_SERVER_SOCKET_HXX
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
class SocketAddress;
|
class SocketAddress;
|
||||||
@@ -38,6 +41,14 @@ class ServerSocket {
|
|||||||
|
|
||||||
std::list<OneServerSocket> sockets;
|
std::list<OneServerSocket> sockets;
|
||||||
|
|
||||||
|
#ifdef HAVE_TCP
|
||||||
|
/**
|
||||||
|
* A non-negative value sets the IPPROTO_IP/IP_TOS socket
|
||||||
|
* option.
|
||||||
|
*/
|
||||||
|
int ip_tos = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned next_serial = 1;
|
unsigned next_serial = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -48,6 +59,14 @@ public:
|
|||||||
return loop;
|
return loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_TCP
|
||||||
|
void SetIpTos(int _ip_tos) noexcept {
|
||||||
|
assert(sockets.empty());
|
||||||
|
|
||||||
|
ip_tos = _ip_tos;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename A>
|
template<typename A>
|
||||||
OneServerSocket &AddAddress(A &&address) noexcept;
|
OneServerSocket &AddAddress(A &&address) noexcept;
|
||||||
|
Reference in New Issue
Block a user