IPV6_TCLASS instead of IP_TOS for IPv6
@@ -201,42 +201,42 @@ int picoquic_socket_set_ecn_options(SOCKET_TYPE sd, int af, int * recv_set, int
}
#else
if (af == AF_INET6) {
-#ifdef IP_RECVTOS
+#if defined(IPV6_TCLASS)
{
- unsigned char set = 0x03;
-
- /* Request receiving TOS reports in recvmsg */
- if (setsockopt(sd, IPPROTO_IP, IP_RECVTOS, &set, sizeof(set)) < 0) {
- DBG_PRINTF("setsockopt IPv6 IP_RECVTOS (0x%x) fails, errno: %d\n", set, errno);
+ unsigned int ecn = 2; /* ECN_ECT_0 */
+ /* Request setting ECN_1 in outgoing packets */
+ if (setsockopt(sd, IPPROTO_IPV6, IPV6_TCLASS, &ecn, sizeof(ecn)) < 0) {
+ DBG_PRINTF("setsockopt IPV6_TCLASS (0x%x) fails, errno: %d\n", ecn, errno);
ret = -1;
- *recv_set = 0;
+ *send_set = 0;
}
else {
- *recv_set = 1;
+ *send_set = 1;
ret = 0;
}
}
#else
- DBG_PRINTF("%s", "IP_RECVTOS is not defined\n");
- *recv_set = 0;
+ DBG_PRINTF("%s", "IP_TOS is not defined\n");
+ *send_set = 0;
#endif
-#if defined(IP_TOS)
+#ifdef IPV6_RECVTCLASS
{
- unsigned int ecn = 2; /* ECN_ECT_0 */
- /* Request setting ECN_1 in outgoing packets */
- if (setsockopt(sd, IPPROTO_IP, IP_TOS, &ecn, sizeof(ecn)) < 0){
- DBG_PRINTF("setsockopt IPv6 IP_TOS (0x%x) fails, errno: %d\n", ecn, errno);
+ unsigned char set = 0x03;
+
+ /* Request receiving TOS reports in recvmsg */
+ if (setsockopt(sd, IPPROTO_IPV6, IPV6_RECVTCLASS, &set, sizeof(set)) < 0) {
+ DBG_PRINTF("setsockopt IPv6 IPV6_RECVTCLASS (0x%x) fails, errno: %d\n", set, errno);
ret = -1;
- *send_set = 0;
+ *recv_set = 0;
}
else {
- *send_set = 1;
+ *recv_set = 1;
ret = 0;
}
}
#else
- DBG_PRINTF("%s", "IP_TOS is not defined\n");
- *send_set = 0;
+ DBG_PRINTF("%s", "IP_RECVTOS is not defined\n");
+ *recv_set = 0;
#endif
}
