[2456] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

Re: telnet/57: -S support for systems without gettosbyname()

daemon@ATHENA.MIT.EDU (John Hawkinson)
Thu Nov 14 15:07:19 1996

Date: Thu, 14 Nov 1996 15:06:55 -0500 (EST)
To: krb5-bugs@MIT.EDU
Cc: krb5-prs@rt-11.mit.edu
From: John Hawkinson <jhawk@bbnplanet.com>


What I sent in before (and was committed) had a minor (cosmetic only)
bug:

telnet> [zygorthian-space-raiders!jhawk] ~> /mit/krb5/bin/telnet -S300
telnet: Bad TOS argument '300; will try to use default TOS
Setting TOS to 0xffffffff
telnet> 

Here's a fix, also adding support for "set tos".

--jhawk

*** libtelnet/parsetos.c	1996/11/01 04:44:25	1.2
--- libtelnet/parsetos.c	1996/11/14 19:58:48	1.3
***************
*** 18,24 ****
  char	*name;
  char	*proto;
  {
! 	register char	*c;
  	int		tos;
  
  #ifdef HAS_GETTOS
--- 18,24 ----
  char	*name;
  char	*proto;
  {
! 	char		*c;
  	int		tos;
  
  #ifdef HAS_GETTOS
***************
*** 29,37 ****
  		tos = tosp->t_tos;
  	else
  #endif
! 		tos = (int)strtol(name, (char **)NULL, 0);
  
! 	if (tos < MIN_TOS || tos > MAX_TOS) {
  		return (-1);
  	}
  	return (tos);
--- 29,38 ----
  		tos = tosp->t_tos;
  	else
  #endif
! 		tos = (int)strtol(name, &c, 0);
  
! 	if (tos < MIN_TOS || tos > MAX_TOS ||
! 	    (tos == 0 && c == name)) {
  		return (-1);
  	}
  	return (tos);
*** telnet/commands.c	1996/11/11 00:46:31	1.5
--- telnet/commands.c	1996/11/12 07:20:16
***************
*** 92,97 ****
--- 92,98 ----
  
  #if	defined(IPPROTO_IP) && defined(IP_TOS)
  int tos = -1;
+ unsigned char TOSstr[256] = "(default)";
  #endif	/* defined(IPPROTO_IP) && defined(IP_TOS) */
  
  char	*hostname;
***************
*** 885,890 ****
--- 886,894 ----
  #endif
      { "escape",	"character to escape back to telnet command mode", 0, &escape },
      { "rlogin", "rlogin escape character", 0, &rlogin },
+ #if defined(HAS_GETTOS) || (defined(IPPROTO_IP) && defined(IP_TOS))
+     { "tos", "type of service", SetTOS, (cc_t *)TOSstr },
+ #endif
      { "tracefile", "file to write trace information to", SetNetTrace, (cc_t *)NetTraceFile},
      { " ", "" },
      { " ", "The following need 'localchars' to be toggled true", 0, 0 },
***************
*** 1362,1367 ****
--- 1366,1399 ----
  	return 1;
  }
  
+ #if defined(IPPROTO_IP) && defined(IP_TOS)
+ 
+ void
+ SetTOS(s)
+ char *s;
+ {
+   extern int tos;
+   int newtos;
+ 
+   if ((newtos = parsetos(s, "tcp")) < 0) {
+     fprintf(stderr, "%s: Bad TOS argument '%s'\n",
+ 	    prompt, s);
+     if (tos >= 0)
+       sprintf(TOSstr, "0x%02x", tos);
+     else 
+       strcpy(TOSstr, "(default)");
+     return;
+   }
+   tos = newtos;
+   sprintf(TOSstr, "0x%02x", tos);
+   if (connected
+       && (setsockopt(net, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)
+       && (errno != ENOPROTOOPT))
+     perror("telnet: setsockopt (IP_TOS) (ignored)");
+ }
+ 
+ #endif
+ 
      /*VARARGS*/
      static int
  togcrmod()
***************
*** 2418,2423 ****
--- 2450,2457 ----
  		    (char *)&tos, sizeof(int)) < 0)
  		&& (errno != ENOPROTOOPT))
  		    perror("telnet: setsockopt (IP_TOS) (ignored)");
+ 	    else
+ 		sprintf(TOSstr, "0x%02x", tos);
  	}
  #endif	/* defined(IPPROTO_IP) && defined(IP_TOS) */
  
*** telnet/externs.h	1996/11/11 00:46:31	1.2
--- telnet/externs.h	1996/11/12 07:18:56
***************
*** 249,254 ****
--- 249,260 ----
  extern void
      SetNetTrace P((char *));	/* Function to change where debugging goes */
  
+ #if	defined(IPPROTO_IP) && defined(IP_TOS)
+ extern unsigned char
+     TOSstr[];		/* String representation of the current type of service */
+ void SetTOS();
+ #endif
+ 
  extern jmp_buf
      peerdied,
      toplevel;		/* For error conditions. */
*** telnet/main.c	1996/11/01 04:43:04	1.3
--- telnet/main.c	1996/11/12 07:24:51
***************
*** 164,179 ****
  			break;
  		case 'S':
  		    {
! #if defined(HAS_GETTOS) || (defined(IPPROTO_IP) && defined(IP_TOS))
! 			extern int tos;
! 
! 			if ((tos = parsetos(optarg, "tcp")) < 0)
! 				fprintf(stderr, "%s%s%s%s\n",
! 					prompt, ": Bad TOS argument '",
! 					optarg,
! 					"; will try to use default TOS");
! 
!                       fprintf(stderr, "Setting TOS to 0x%x\n", tos);
  #else
  			fprintf(stderr,
  			   "%s: Warning: -S ignored, no parsetos() support.\n",
--- 164,172 ----
  			break;
  		case 'S':
  		    {
! #if defined(IPPROTO_IP) && defined(IP_TOS)
! 			SetTOS(optarg);
! 			fprintf(stderr, "tos set to %s\n", TOSstr);
  #else
  			fprintf(stderr,
  			   "%s: Warning: -S ignored, no parsetos() support.\n",

home help back first fref pref prev next nref lref last post