o Make telnet[d] -S (IP TOS) flag really work. We do not have

/etc/iptos implementation so only numeric values supported.

o telnetd.8: steal the -S flag description from telnet.1, bump
the date of the document.

MFC after:	6 weeks


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@139937 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This commit is contained in:
maxim 2005-01-09 10:24:46 +00:00
parent 10faff8b17
commit 82ff960df9
3 changed files with 32 additions and 10 deletions

View File

@ -39,7 +39,7 @@ static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <sys/types.h> #include <sys/param.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -66,6 +66,8 @@ char *ipsec_policy_in = NULL;
char *ipsec_policy_out = NULL; char *ipsec_policy_out = NULL;
#endif #endif
extern int tos;
int family = AF_UNSPEC; int family = AF_UNSPEC;
/* /*
@ -115,8 +117,9 @@ usage(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
u_long ultmp;
int ch; int ch;
char *user; char *ep, *user;
char *src_addr = NULL; char *src_addr = NULL;
#ifdef FORWARD #ifdef FORWARD
extern int forward_flags; extern int forward_flags;
@ -181,9 +184,7 @@ main(int argc, char *argv[])
doaddrlookup = 0; doaddrlookup = 0;
break; break;
case 'S': case 'S':
{
#ifdef HAS_GETTOS #ifdef HAS_GETTOS
extern int tos;
if ((tos = parsetos(optarg, "tcp")) < 0) if ((tos = parsetos(optarg, "tcp")) < 0)
fprintf(stderr, "%s%s%s%s\n", fprintf(stderr, "%s%s%s%s\n",
@ -191,11 +192,16 @@ main(int argc, char *argv[])
optarg, optarg,
"; will try to use default TOS"); "; will try to use default TOS");
#else #else
fprintf(stderr, #define MAXTOS 255
"%s: Warning: -S ignored, no parsetos() support.\n", ultmp = strtoul(optarg, &ep, 0);
prompt); if (*ep || ep == optarg || ultmp > MAXTOS)
fprintf(stderr, "%s%s%s%s\n",
prompt, ": Bad TOS argument '",
optarg,
"; will try to use default TOS");
else
tos = ultmp;
#endif #endif
}
break; break;
case 'X': case 'X':
#ifdef AUTHENTICATION #ifdef AUTHENTICATION

View File

@ -32,7 +32,7 @@
.\" @(#)telnetd.8 8.4 (Berkeley) 6/1/94 .\" @(#)telnetd.8 8.4 (Berkeley) 6/1/94
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd January 5, 2005 .Dd January 9, 2005
.Dt TELNETD 8 .Dt TELNETD 8
.Os .Os
.Sh NAME .Sh NAME
@ -251,6 +251,13 @@ Specify an alternate
command to run to complete the login. The alternate command must command to run to complete the login. The alternate command must
understand the same command arguments as the standard login. understand the same command arguments as the standard login.
.It Fl S Ar tos .It Fl S Ar tos
Sets the IP type-of-service (TOS) option for the telnet
connection to the value
.Ar tos ,
which can be a numeric TOS value or, on systems that support it, a symbolic
TOS name found in the
.Pa /etc/iptos
file.
.It Fl u Ar len .It Fl u Ar len
This option is used to specify the size of the field This option is used to specify the size of the field
in the in the

View File

@ -131,12 +131,14 @@ char user_name[256];
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
u_long ultmp;
struct sockaddr_storage from; struct sockaddr_storage from;
int on = 1, fromlen; int on = 1, fromlen;
int ch; int ch;
#if defined(IPPROTO_IP) && defined(IP_TOS) #if defined(IPPROTO_IP) && defined(IP_TOS)
int tos = -1; int tos = -1;
#endif #endif
char *ep;
pfrontp = pbackp = ptyobuf; pfrontp = pbackp = ptyobuf;
netip = netibuf; netip = netibuf;
@ -273,7 +275,14 @@ main(int argc, char *argv[])
"bad TOS argument '", optarg, "bad TOS argument '", optarg,
"'; will try to use default TOS"); "'; will try to use default TOS");
#else #else
warnx("TOS option unavailable; -S flag not supported"); #define MAXTOS 255
ultmp = strtoul(optarg, &ep, 0);
if (*ep || ep == optarg || ultmp > MAXTOS)
warnx("%s%s%s",
"bad TOS argument '", optarg,
"'; will try to use default TOS");
else
tos = ultmp;
#endif #endif
break; break;