diff --git a/src/redir.c b/src/redir.c index f1ad612b..73921b97 100644 --- a/src/redir.c +++ b/src/redir.c @@ -800,10 +800,12 @@ accept_cb(EV_P_ ev_io *w, int revents) if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv4 dscp failed: %d", errno); } +#ifdef IPV6_TCLASS rc = setsockopt(remotefd, IPPROTO_IPV6, IPV6_TCLASS, &listener->tos, sizeof(listener->tos)); if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv6 dscp failed: %d", errno); } +#endif } // Enable MPTCP diff --git a/src/udprelay.c b/src/udprelay.c index 0ebef4ff..34c333bf 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -508,11 +508,13 @@ create_server_socket(const char *host, const char *port) if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv4 dscp failed: %d", errno); } +#ifdef IPV6_TCLASS rc = setsockopt(server_sock, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)); if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv6 dscp failed: %d", errno); } #endif +#endif #ifdef MODULE_REDIR int sol = rp->ai_family == AF_INET ? SOL_IP : SOL_IPV6; @@ -675,11 +677,13 @@ resolv_cb(struct sockaddr *addr, void *data) if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv4 dscp failed: %d", errno); } +#ifdef IPV6_TCLASS rc = setsockopt(remotefd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)); if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv6 dscp failed: %d", errno); } #endif +#endif #ifdef SET_INTERFACE if (query_ctx->server_ctx->iface) { if (setinterface(remotefd, query_ctx->server_ctx->iface) == -1) @@ -872,10 +876,12 @@ remote_recv_cb(EV_P_ ev_io *w, int revents) if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv4 dscp failed: %d", errno); } +#ifdef IPV6_TCLASS rc = setsockopt(src_fd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)); if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv6 dscp failed: %d", errno); } +#endif #endif if (bind(src_fd, (struct sockaddr *)&dst_addr, remote_dst_addr_len) != 0) { ERROR("[udp] remote_recv_bind"); @@ -1213,11 +1219,13 @@ server_recv_cb(EV_P_ ev_io *w, int revents) if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv4 dscp failed: %d", errno); } +#ifdef IPV6_TCLASS rc = setsockopt(remotefd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)); if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv6 dscp failed: %d", errno); } #endif +#endif #ifdef SET_INTERFACE if (server_ctx->iface) { if (setinterface(remotefd, server_ctx->iface) == -1) @@ -1309,11 +1317,13 @@ server_recv_cb(EV_P_ ev_io *w, int revents) if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv4 dscp failed: %d", errno); } +#ifdef IPV6_TCLASS rc = setsockopt(remotefd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)); if (rc < 0 && errno != ENOPROTOOPT) { LOGE("setting ipv6 dscp failed: %d", errno); } #endif +#endif #ifdef SET_INTERFACE if (server_ctx->iface) { if (setinterface(remotefd, server_ctx->iface) == -1)