Currently: $ nc -T lowdelay ::1 22 nc: set IP ToS: Invalid argument With the diff below: $ ./obj/nc -T lowdelay ::1 22 SSH-2.0-OpenSSH_6.7
ok? Index: netcat.c =================================================================== RCS file: /cvs/src/usr.bin/nc/netcat.c,v retrieving revision 1.126 diff -u -p -r1.126 netcat.c --- netcat.c 30 Oct 2014 16:08:31 -0000 1.126 +++ netcat.c 14 Feb 2015 20:46:01 -0000 @@ -113,7 +113,7 @@ int udptest(int); int unix_bind(char *); int unix_connect(char *); int unix_listen(char *); -void set_common_sockopts(int); +void set_common_sockopts(int, int); int map_tos(char *, int *); void report_connect(const struct sockaddr *, socklen_t); void usage(int); @@ -619,7 +619,7 @@ remote_connect(const char *host, const c freeaddrinfo(ares); } - set_common_sockopts(s); + set_common_sockopts(s, res0->ai_family); if (timeout_connect(s, res0->ai_addr, res0->ai_addrlen) == 0) break; @@ -712,7 +712,7 @@ local_listen(char *host, char *port, str if (ret == -1) err(1, NULL); - set_common_sockopts(s); + set_common_sockopts(s, res0->ai_family); if (bind(s, (struct sockaddr *)res0->ai_addr, res0->ai_addrlen) == 0) @@ -1128,7 +1128,7 @@ udptest(int s) } void -set_common_sockopts(int s) +set_common_sockopts(int s, int af) { int x = 1; @@ -1143,8 +1143,17 @@ set_common_sockopts(int s) err(1, NULL); } if (Tflag != -1) { - if (setsockopt(s, IPPROTO_IP, IP_TOS, - &Tflag, sizeof(Tflag)) == -1) + int proto, option; + + if (af == AF_INET6) { + proto = IPPROTO_IPV6; + option = IPV6_TCLASS; + } else { + proto = IPPROTO_IP; + option = IP_TOS; + } + + if (setsockopt(s, proto, option, &Tflag, sizeof(Tflag)) == -1) err(1, "set IP ToS"); } if (Iflag) { -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE