Skip Menu |
 

Download (untitled) / with headers
text/plain 13.8KiB
From jhawk@bbnplanet.com Fri Oct 4 04:40:38 1996
Received: from MIT.EDU (SOUTH-STATION-ANNEX.MIT.EDU [18.72.1.2]) by rt-11.MIT.EDU (8.7.5/8.7.3) with SMTP id EAA19522 for <bugs@RT-11.MIT.EDU>; Fri, 4 Oct 1996 04:40:37 -0400
Received: from all-purpose-gunk.near.net by MIT.EDU with SMTP
id AA22212; Fri, 4 Oct 96 04:40:37 EDT
Received: (from jhawk@localhost) by all-purpose-gunk.near.net (8.8.0/8.8.0) id EAA04733; Fri, 4 Oct 1996 04:40:36 -0400 (EDT)
Message-Id: <199610040840.EAA04733@all-purpose-gunk.near.net>
Date: Fri, 4 Oct 1996 04:40:36 -0400 (EDT)
From: John Hawkinson <jhawk@bbnplanet.com>
To: krb5-bugs@MIT.EDU
Subject: -S support for systems without gettosbyname()

Show quoted text
>Number: 57
>Category: telnet
>Synopsis: -S support for systems without gettosbyname()
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: hartmans
>State: open
>Class: change-request
>Submitter-Id: unknown
>Arrival-Date: Fri Oct e 04:41:01 EDT 1996
>Last-Modified: Wed Nov 20 16:45:46 EST 1996
>Originator: John Hawkinson
>Organization:
BBN Planet
Show quoted text
>Release: beta-7
>Environment:
System: SunOS all-purpo 4.1.4 4 sun4m
Architecture: sun4

Show quoted text
>Description:

Systems that allow setsockopt() for IP_TOS do not have gettosbyname(),
with the singular exception of UNICOS.

Telnet's support for setting the TOS with -S is predicated on support for
gettosbyname().

This is a shame if you'd like to (or have a requirement for) setting the TOS
to a nonstandard value.

The attached patch comes from Greg Christy <gchristy@cisco.com>. I'm
somewhat reluctant to modify the semantics of it to introduce
incompatibility with other folks who may have applied this patch, but
it appears there may be a conflict in it's assumptions about radix and
those of libtelnet/parsetos.c's parsetos() [this is sscanf("%x")
versus strtol()]. I'm unsure what to do about this apparent conflict,
perhaps Sam and I should discuss it (?).

It occurs to me (belatedly) that one thing to add would be support for
setting the TOS in .telnetrc. Whenever I get around to doing this
(relatively far down on my todo list) I'll send in an attachment to
this PR if it is still open, or do something else creative.

Show quoted text
>How-To-Repeat:

[all-purpose-gunk!jhawk] ~> /usr/local/krb5/bin/telnet -Sc0 127.1 127
telnet: Warning: -S ignored, no parsetos() support.
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
[all-purpose-gunk!jhawk] ~> /usr/local/krb5/bin/telnet -S0xc0 127.1 127
telnet: Warning: -S ignored, no parsetos() support.
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused


Show quoted text
>Fix:

*** telnet.1 1996/10/04 08:24:13 1.1
--- appl/telnet/telnet/telnet.1 1996/10/04 08:24:25 1.2
***************
*** 82,88 ****
Set the IP type-of-service (TOS) option for the telnet connection to the
value
.I tos,
! which can be a numeric TOS value or, on systems that support it, a
symbolic TOS name found in the /etc/iptos file.
.TP
\fB\-X\fP \fIatype\fP
--- 82,88 ----
Set the IP type-of-service (TOS) option for the telnet connection to the
value
.I tos,
! which can be a numeric TOS value in hex or, on systems that support it, a
symbolic TOS name found in the /etc/iptos file.
.TP
\fB\-X\fP \fIatype\fP
*** main.c 1996/10/04 08:17:50 1.1
--- appl/telnet/telnet/main.c 1996/10/04 08:24:25 1.2
***************
*** 41,46 ****
--- 41,50 ----

#include <sys/types.h>

+ #ifdef unix
+ # include <netinet/in.h>
+ #endif
+
#include "ring.h"
#include "externs.h"
#include "defines.h"
***************
*** 168,173 ****
--- 172,183 ----
prompt, ": Bad TOS argument '",
optarg,
"; will try to use default TOS");
+ #endif
+ #if defined(IPPROTO_IP) && defined(IP_TOS)
+ extern int tos;
+
+ sscanf(optarg, "%x", &tos);
+ fprintf(stderr, "Setting TOS to 0x%x\n", tos);
#else
fprintf(stderr,
"%s: Warning: -S ignored, no parsetos() support.\n",
Show quoted text
>Audit-Trail:

State-Changed-From-To: open-analyzed State-Changed-By: hartmans
State-Changed-When: Mon Oct 14 01:11:46 1996 State-Changed-Why: I
don't like the provided patch because it does not fit into the
framework of the original options and does not significantly justify
the change. I agree that functionality should be added to the
product. However, I agree with the original author's intent that
numeric types should be parsed by strtol.


From: John Hawkinson <jhawk@bbnplanet.com>
To: krb5-bugs@MIT.EDU
Cc: krb5-prs@RT-11.MIT.EDU
Subject: Re: telnet/57: -S support for systems without gettosbyname()
Date: Fri, 1 Nov 1996 04:58:04 GMT

Sam and I had a discussion about some of the issues with regards to
the patches previously submitted.

I've updated them to be a bit more sane and no longer incompatible
with UNICOS (hey! I didn't write the original code).

Here we go, relative to beta7 and not the previous patches.
Previous patches should be ignored :-)

--jhawk

*** libtelnet/configure.in 1996/11/01 04:30:38 1.1
--- libtelnet/configure.in 1996/11/01 04:44:25 1.2
***************
*** 3,9 ****
AC_PROG_ARCHIVE
AC_PROG_ARCHIVE_ADD
AC_PROG_RANLIB
! AC_REPLACE_FUNCS([strcasecmp strdup setenv setsid strerror strftime getopt herror])
AC_FUNC_CHECK(cgetent,AC_DEFINE(HAS_CGETENT))
AC_CHECK_HEADERS(stdlib.h string.h)
LIBOBJS="$LIBOBJS getent.o"
--- 3,9 ----
AC_PROG_ARCHIVE
AC_PROG_ARCHIVE_ADD
AC_PROG_RANLIB
! AC_REPLACE_FUNCS([strcasecmp strdup setenv setsid strerror strftime getopt herror parsetos])
AC_FUNC_CHECK(cgetent,AC_DEFINE(HAS_CGETENT))
AC_CHECK_HEADERS(stdlib.h string.h)
LIBOBJS="$LIBOBJS getent.o"
*** libtelnet/Makefile.in 1996/11/01 04:22:51 1.1
--- libtelnet/Makefile.in 1996/11/01 04:44:25 1.2
***************
*** 40,45 ****
--- 40,46 ----
$(srcdir)/read_password.c \
$(srcdir)/setenv.c \
$(srcdir)/getent.c \
+ $(scrdir)/parsetos.c \
$(srcdir)/strdup.c \
$(srcdir)/strcasecmp.c \
$(srcdir)/strchr.c \
*** libtelnet/parsetos.c 1996/11/01 04:00:17 1.1
--- libtelnet/parsetos.c 1996/11/01 04:44:25 1.2
***************
*** 1,8 ****

/*
! * The routine parsetos() for UNICOS 6.0/6.1 systems. This
! * is part of UNICOS 7.0 and later.
*/
#include <stdio.h>
#include <sys/types.h>
#include <netdb.h>
--- 1,9 ----

/*
! * The routine parsetos() for UNICOS 6.0/6.1, as well as more traditional
! * Unix systems. This is part of UNICOS 7.0 and later.
*/
+
#include <stdio.h>
#include <sys/types.h>
#include <netdb.h>
***************
*** 19,40 ****
{
register char *c;
int tos;
struct tosent *tosp;

tosp = gettosbyname(name, proto);
! if (tosp) {
tos = tosp->t_tos;
! } else {
! for (c = name; *c; c++) {
! if (*c < '0' || *c > '9') {
! errno = EINVAL;
! return (-1);
! }
! }
tos = (int)strtol(name, (char **)NULL, 0);
! }
if (tos < MIN_TOS || tos > MAX_TOS) {
- errno = ERANGE;
return (-1);
}
return (tos);
--- 20,37 ----
{
register char *c;
int tos;
+
+ #ifdef HAS_GETTOS
struct tosent *tosp;

tosp = gettosbyname(name, proto);
! if (tosp)
tos = tosp->t_tos;
! else
! #endif
tos = (int)strtol(name, (char **)NULL, 0);
!
if (tos < MIN_TOS || tos > MAX_TOS) {
return (-1);
}
return (tos);
*** telnet/telnet.1 1996/10/04 08:24:13 1.1
--- telnet/telnet.1 1996/11/01 04:43:37 1.3
***************
*** 82,88 ****
Set the IP type-of-service (TOS) option for the telnet connection to the
value
.I tos,
! which can be a numeric TOS value or, on systems that support it, a
symbolic TOS name found in the /etc/iptos file.
.TP
\fB\-X\fP \fIatype\fP
--- 82,89 ----
Set the IP type-of-service (TOS) option for the telnet connection to the
value
.I tos,
! which can be a numeric TOS value (in decimal, or a hex value preceded
! by 0x, or an octal value preceded by a leading 0) or, on systems that support it, a
symbolic TOS name found in the /etc/iptos file.
.TP
\fB\-X\fP \fIatype\fP
*** telnet/main.c 1996/10/04 08:17:50 1.1
--- telnet/main.c 1996/11/01 04:43:04 1.3
***************
*** 41,46 ****
--- 41,50 ----

#include <sys/types.h>

+ #ifdef unix
+ # include <netinet/in.h>
+ #endif
+
#include "ring.h"
#include "externs.h"
#include "defines.h"
***************
*** 160,166 ****
break;
case 'S':
{
! #ifdef HAS_GETTOS
extern int tos;

if ((tos = parsetos(optarg, "tcp")) < 0)
--- 164,170 ----
break;
case 'S':
{
! #if defined(HAS_GETTOS) || (defined(IPPROTO_IP) && defined(IP_TOS))
extern int tos;

if ((tos = parsetos(optarg, "tcp")) < 0)
***************
*** 168,173 ****
--- 172,179 ----
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",

State-Changed-From-To: analyzed-closed
State-Changed-By: hartmans
State-Changed-When: Fri Nov 1 20:52:41 1996
State-Changed-Why:

Implemented using final supplied patch.


From: John Hawkinson <jhawk@bbnplanet.com>
To: krb5-bugs@MIT.EDU
Cc: krb5-prs@RT-11.MIT.EDU
Subject: Re: telnet/57: -S support for systems without gettosbyname()
Date: Thu, 14 Nov 1996 15:06:55 -0500 (EST)

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

Show quoted text
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
Show quoted text
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",
State-Changed-From-To: closed-open
State-Changed-By: gnats
State-Changed-When: Wed Nov 20 16:42:53 EST 1996
State-Changed-Why:
Re-open so I remember
to integrate bug and feature request
after 1.0

Show quoted text
>Unformatted: