event/ServerSocket: rename ip_tos to dscp_class and support IPv6
This commit is contained in:
parent
16f7ec9950
commit
219c416a1e
@ -182,12 +182,18 @@ ServerSocket::OneServerSocket::Open()
|
||||
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);
|
||||
if (parent.dscp_class >= 0) {
|
||||
const int family = address.GetFamily();
|
||||
if ((family == AF_INET &&
|
||||
!_fd.SetIntOption(IPPROTO_IP, IP_TOS, parent.dscp_class)) ||
|
||||
(family == AF_INET6 &&
|
||||
!_fd.SetIntOption(IPPROTO_IPV6, IPV6_TCLASS,
|
||||
parent.dscp_class))) {
|
||||
const SocketErrorMessage msg;
|
||||
FmtError(server_socket_domain,
|
||||
"Could not set DSCP class: {}",
|
||||
(const char *)msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -43,10 +43,10 @@ class ServerSocket {
|
||||
|
||||
#ifdef HAVE_TCP
|
||||
/**
|
||||
* A non-negative value sets the IPPROTO_IP/IP_TOS socket
|
||||
* option.
|
||||
* A non-negative value sets the IPPROTO_IP/IP_TOS or
|
||||
* IPPROTO_IPV6/IPV6_TCLASS socket option.
|
||||
*/
|
||||
int ip_tos = -1;
|
||||
int dscp_class = -1;
|
||||
#endif
|
||||
|
||||
unsigned next_serial = 1;
|
||||
@ -60,10 +60,10 @@ public:
|
||||
}
|
||||
|
||||
#ifdef HAVE_TCP
|
||||
void SetIpTos(int _ip_tos) noexcept {
|
||||
void SetDscpClass(int _dscp_class) noexcept {
|
||||
assert(sockets.empty());
|
||||
|
||||
ip_tos = _ip_tos;
|
||||
dscp_class = _dscp_class;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user