aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Konovalov <maxim@FreeBSD.org>2005-01-09 10:24:46 +0000
committerMaxim Konovalov <maxim@FreeBSD.org>2005-01-09 10:24:46 +0000
commitde93353dad84a7550a38877dd98e6e296b14baae (patch)
treec05c1af1cd0973883c4b00dab171b9c38ae56f11
parentb6905f6f930476b5cf93a9642879791ec2723917 (diff)
downloadsrc-de93353dad84a7550a38877dd98e6e296b14baae.tar.gz
src-de93353dad84a7550a38877dd98e6e296b14baae.zip
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
Notes
Notes: svn path=/head/; revision=139937
-rw-r--r--contrib/telnet/telnet/main.c22
-rw-r--r--contrib/telnet/telnetd/telnetd.89
-rw-r--r--contrib/telnet/telnetd/telnetd.c11
3 files changed, 32 insertions, 10 deletions
diff --git a/contrib/telnet/telnet/main.c b/contrib/telnet/telnet/main.c
index ed5ee97b8334..f6eb1ffb08ef 100644
--- a/contrib/telnet/telnet/main.c
+++ b/contrib/telnet/telnet/main.c
@@ -39,7 +39,7 @@ static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
@@ -66,6 +66,8 @@ char *ipsec_policy_in = NULL;
char *ipsec_policy_out = NULL;
#endif
+extern int tos;
+
int family = AF_UNSPEC;
/*
@@ -115,8 +117,9 @@ usage(void)
int
main(int argc, char *argv[])
{
+ u_long ultmp;
int ch;
- char *user;
+ char *ep, *user;
char *src_addr = NULL;
#ifdef FORWARD
extern int forward_flags;
@@ -181,9 +184,7 @@ main(int argc, char *argv[])
doaddrlookup = 0;
break;
case 'S':
- {
#ifdef HAS_GETTOS
- extern int tos;
if ((tos = parsetos(optarg, "tcp")) < 0)
fprintf(stderr, "%s%s%s%s\n",
@@ -191,11 +192,16 @@ main(int argc, char *argv[])
optarg,
"; will try to use default TOS");
#else
- fprintf(stderr,
- "%s: Warning: -S ignored, no parsetos() support.\n",
- prompt);
+#define MAXTOS 255
+ ultmp = strtoul(optarg, &ep, 0);
+ 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
- }
break;
case 'X':
#ifdef AUTHENTICATION
diff --git a/contrib/telnet/telnetd/telnetd.8 b/contrib/telnet/telnetd/telnetd.8
index 0f3a15c2db19..ab990963c43f 100644
--- a/contrib/telnet/telnetd/telnetd.8
+++ b/contrib/telnet/telnetd/telnetd.8
@@ -32,7 +32,7 @@
.\" @(#)telnetd.8 8.4 (Berkeley) 6/1/94
.\" $FreeBSD$
.\"
-.Dd January 5, 2005
+.Dd January 9, 2005
.Dt TELNETD 8
.Os
.Sh NAME
@@ -251,6 +251,13 @@ Specify an alternate
command to run to complete the login. The alternate command must
understand the same command arguments as the standard login.
.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
This option is used to specify the size of the field
in the
diff --git a/contrib/telnet/telnetd/telnetd.c b/contrib/telnet/telnetd/telnetd.c
index 6e4bd4f91f1b..614bab9b4391 100644
--- a/contrib/telnet/telnetd/telnetd.c
+++ b/contrib/telnet/telnetd/telnetd.c
@@ -131,12 +131,14 @@ char user_name[256];
int
main(int argc, char *argv[])
{
+ u_long ultmp;
struct sockaddr_storage from;
int on = 1, fromlen;
int ch;
#if defined(IPPROTO_IP) && defined(IP_TOS)
int tos = -1;
#endif
+ char *ep;
pfrontp = pbackp = ptyobuf;
netip = netibuf;
@@ -273,7 +275,14 @@ main(int argc, char *argv[])
"bad TOS argument '", optarg,
"'; will try to use default TOS");
#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
break;