On Tue, 18 Nov 2003, Corinna Vinschen wrote: > On Mon, Nov 17, 2003 at 02:51:15PM -0800, Peter A. Castro wrote: > > After getting a successful login I did the following: > > [EMAIL PROTECTED] ~ $ od -c > > <ret> > > <ret> > > <ret> > > <ctrl-j> > > <ctrl-j> > > <ctrl-j> > > <ctrl-d> > > 0000000 \0 \n \0 \n \0 \n \0 \n \n \n > > 0000012 > > > > Notice the \0's ? From above, if the crlf option is turned off, the > > client sends 0x0d,0x00. It appears the telnet daemon is forwarding on > > the 0x00 as part of the data stream. According to RFC 854, a <cr><nul> > > combination is supposed to be treated as a straight carriage-return, so > > the daemon is supposed to turn that pair of characters into a single <cr> > > character. You can run c3270 in trace mode ("c3270 -trace <hostname>" > > Hmm, I had a look into telnetd and it actually does conform to RFC 854, > AFAICS. There's a function called "telrcv()", which apparently cares > for receiving characters from the client side. There's this stuff in > the code: > > case TS_CR: > state = TS_DATA; > /* Strip off \n or \0 after a \r */ > if ((c == 0) || (c == '\n')) { > break; > } > /* FALL THROUGH */ > case TS_DATA: > [...] > > As it turns out, telnetd is operating in so-called "LINEMODE". An > explanation of linemode is given in telnetd/termstat.c though it's > not entirely clear to me how it works, admittedly. Linemode seems > to speed up the connection at least.
The idea behind line-mode is that the client is suppose to do local editing of the input and only transmit data when enter or some other flush/sync character is received as input. The other mode is typically called "character-at-a-time" or "kludge linemode" in which all characters are sent, real time, and the client does no editing or buffering. > Anyway, if linemode is enabled (which is negotiated on server startup), > telnetd never calls the above code, since a few lines below it turns a > \r into a \n. When compiling telnetd without -DLINEMODE, that telnetd > is able to operate with c3270 as expected. It's also able to work > fine with a Linux and the Cygwin telnet client. What's interest to me is that a c3270 trace shows that the Cygwin telnetd is sending "DO LINEMODE" but c3270 is responding with "WONT LINEMODE" which is supposed to mean that telnetd should not assume LINEMODE semantics. A normal telnet client (using the "toggle options" command) flow often shows "DO LINEMODE", intially, but after some additional options are exchanged, later flows a "DONT LINEMODE". I haven't studied the BSD code in detail, and so can't really say what's going on. Alternatively, with other telnetd's (ie: Linux, AIX, Solaris) the telnet flow is often "DONT LINEMODE" initially. I tried starting the telnetd with the -k option, but to no avail. > On the other hand, telnetd on BSD systems is by default also build > with linemode on! So it's not quite clear to me what to do or if I > should do anything at all. I think this is just one of those odd peculiarities of telnet protocol implementation and not something you need to address. Again, c3270 isn't really ment to be used as a normal NVT client anyways. > Corinna -- Peter A. Castro <[EMAIL PROTECTED]> or <[EMAIL PROTECTED]> "Cats are just autistic Dogs" -- Dr. Tony Attwood