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?

Index: commands.c
===================================================================
RCS file: /cvs/src/usr.bin/telnet/commands.c,v
retrieving revision 1.73
diff -u -p -p -u -r1.73 commands.c
--- commands.c  25 Oct 2015 14:42:02 -0000      1.73
+++ commands.c  25 Oct 2015 16:11:17 -0000
@@ -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) {


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to