Increase usefulness of telnet(1) as a protocol tester. By prepending

"+" to the port number, disable option negotiation and allow
transferring of data with high bit set.

OKed by:	markm (maintainer)
PR:		52032
Submitted by:	Valentin Nechayev <netch maybe-at netch stop kiev stop ua>
MFC After:	2 weeks


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@142790 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This commit is contained in:
tobez 2005-02-28 12:46:53 +00:00
parent 26fb67c648
commit 0f4e951657
3 changed files with 23 additions and 4 deletions

View File

@ -2299,6 +2299,9 @@ tn(int argc, char *argv[])
} else if (*portp == '-') {
portp++;
telnetport = 1;
} else if (*portp == '+') {
portp++;
telnetport = -1;
} else
telnetport = 0;

View File

@ -591,9 +591,10 @@ Prints out help information for the
command.
.El
.It Xo
.Ic open Ar host
.Ic open
.Op Fl l Ar user
.Op Oo Fl Oc Ns Ar port
.Op Ar host
.Op Oo Fl /+ Oc Ns Ar port
.Xc
Open a connection to the named host.
If no port number
@ -620,6 +621,13 @@ omits any automatic initiation of
options.
When the port number is preceded by a minus sign,
the initial option negotiation is done.
When, however, the port number
is preceded by a plus sign,
any option negotiation and understanding is prohibited,
making telnet dumb client for POP3/SMTP/NNTP/HTTP-like
protocols with any data including
.Tn TELNET
IAC character (0xff).
After establishing a connection, the file
.Pa \&.telnetrc
in the

View File

@ -217,6 +217,8 @@ send_do(int c, int init)
set_my_want_state_do(c);
do_dont_resp[c]++;
}
if (telnetport < 0)
return;
NET2ADD(IAC, DO);
NETADD(c);
printoption("SENT", DO, c);
@ -232,6 +234,8 @@ send_dont(int c, int init)
set_my_want_state_dont(c);
do_dont_resp[c]++;
}
if (telnetport < 0)
return;
NET2ADD(IAC, DONT);
NETADD(c);
printoption("SENT", DONT, c);
@ -247,6 +251,8 @@ send_will(int c, int init)
set_my_want_state_will(c);
will_wont_resp[c]++;
}
if (telnetport < 0)
return;
NET2ADD(IAC, WILL);
NETADD(c);
printoption("SENT", WILL, c);
@ -262,6 +268,8 @@ send_wont(int c, int init)
set_my_want_state_wont(c);
will_wont_resp[c]++;
}
if (telnetport < 0)
return;
NET2ADD(IAC, WONT);
NETADD(c);
printoption("SENT", WONT, c);
@ -1651,7 +1659,7 @@ telrcv(void)
/* FALLTHROUGH */
case TS_DATA:
if (c == IAC) {
if (c == IAC && telnetport >= 0) {
telrcv_state = TS_IAC;
break;
}
@ -2069,7 +2077,7 @@ telnet(char *user __unusedhere)
}
#endif
#endif
if (telnetport) {
if (telnetport > 0) {
#ifdef AUTHENTICATION
if (autologin)
send_will(TELOPT_AUTHENTICATION, 1);