diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2015-10-26 00:33:04 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2015-10-26 00:33:04 +0000 |
commit | c5a9b264d33b351022973c38a57165f115c5f06b (patch) | |
tree | 6a7cf27a741200efc0ee0506fdd55287e4f1511f | |
parent | b8f1c6400ce5ae33a066c4b59d5ae23017b2353b (diff) |
Set low-delay traffic class for IPv6 connections as well
While here, there is no option to pass a different tos, and no other
use of the "tos" variable out of tn(), so move the "tos" variable in tn()
and assign it the right value from the start.
ok millert@
-rw-r--r-- | usr.bin/telnet/commands.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 18533121a0a..e2d1052f9c4 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.73 2015/10/25 14:42:02 jca Exp $ */ +/* $OpenBSD: commands.c,v 1.74 2015/10/26 00:33:03 jca Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -54,8 +54,6 @@ #define PATH_SKEY "/usr/bin/skey" #endif -int tos = -1; - char *hostname; typedef struct { @@ -1850,7 +1848,7 @@ tn(int argc, char *argv[]) struct addrinfo hints, *res, *res0; char *cmd, *hostp = 0, *portp = 0, *user = 0, *aliasp = 0; int error, retry; - const int niflags = NI_NUMERICHOST; + const int niflags = NI_NUMERICHOST, tos = IPTOS_LOWDELAY; if (connected) { printf("?Already connected to %s\r\n", hostname); @@ -1973,13 +1971,18 @@ tn(int argc, char *argv[]) } freeaddrinfo(ares); } - if (res->ai_family == AF_INET) { - if (tos < 0) - tos = IPTOS_LOWDELAY; /* Low Delay bit */ - if (tos - && (setsockopt(net, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0) - && (errno != ENOPROTOOPT)) - perror("telnet: setsockopt (IP_TOS) (ignored)"); + + switch (res->ai_family) { + case AF_INET: + if (setsockopt(net, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0 + && errno != ENOPROTOOPT) + perror("telnet: setsockopt (IP_TOS) (ignored)"); + break; + case AF_INET6: + if (setsockopt(net, IPPROTO_IPV6, IPV6_TCLASS, &tos, + sizeof(tos)) < 0 && errno != ENOPROTOOPT) + perror("telnet: setsockopt (IPV6_TCLASS) (ignored)"); + break; } if (debug) { |