Forked tcpser to fix the telnet bug and add features
While tinkering with my BBS this week I again found myself frustrated with a couple of bugs in tcpser. The first one was that it only worked with 8N1 data. A few of the comm programs on my more obscure computers have no settings to choose parity, and will insist on either doing mark parity or even parity. That meant that I couldn’t even enter the AT command to dial out.
An easy fix would have been to just strip the high bit so that tcpser would see the AT commands, but that would still leave the problem of some bytes not having the proper parity when sent back to the computer. Some comm programs will simply ignore the parity bit on incoming data, others will silently drop the character.
Detecting parity is actually not too hard though, since the A has an even number of bits and the T has an odd number of bits. By looking at the two characters it’s fairly easy to see if the computer is using odd, even, or mark parity. Space parity and 8 bits with no parity look the same, so it is treated as 8N1.
As noted in my old article, another bug that has been a problem for a long time has been that tcpser was unable to connect to a real telnetd. It has worked fine for raw sockets with no protocol, which is what most BBSes use, but if you wanted to connect to any kind *nix box, the connection would hang and you couldn’t log in.
Fixing the telnet bug actually turned out to be pretty simple. In the parse_nvt_subcommand in nvt.c it was checking data when it should have been data. Changing that fixed the subcommand negotiation which fixed telnet. While I was there I also added sending the baud rate to the server.
At first with the parity detection and generation I had made it only work on the commands and messages to and from the modem, while still sending full 8-bit data to the socket. This of course caused problems because I couldn’t log in when using computers with parity since it wasn't sending 7-bit ASCII. Since telnet was designed to work with 7-bit ASCII, I changed things so that if odd, even, or mark parity is detected, only 7-bit ASCII will be sent and any negotiations to put telnet into binary mode will be refused.
With both telnet & parity working I’m now able to connect to more places with more computers.