Commit 57807165 authored by rswindell's avatar rswindell
Browse files

Created send_telnet_cmd() method.

parent 5de635ce
......@@ -104,11 +104,9 @@ bool sbbs_t::answer()
if(!(sys_status&SS_RLOGIN)) {
/* Disable Telnet Terminal Echo */
sprintf(str,"%c%c%c",TELNET_IAC,TELNET_WILL,TELNET_ECHO);
putcom(str,3);
send_telnet_cmd(TELNET_WILL,TELNET_ECHO);
/* Will suppress Go Ahead */
sprintf(str,"%c%c%c",TELNET_IAC,TELNET_WILL,TELNET_SUP_GA);
putcom(str,3);
send_telnet_cmd(TELNET_WILL,TELNET_SUP_GA);
}
/* Detect terminal type */
......
......@@ -36,7 +36,7 @@
****************************************************************************/
#include "sbbs.h"
#include "telnet.h" // TELNET_IAC/NOP
#include "telnet.h" // TELNET_GA
/****************************************************************************/
/* Waits for remote or local user to hit a key. Inactivity timer is checked */
......@@ -47,7 +47,6 @@
char sbbs_t::getkey(long mode)
{
char ch,coldkey,c=0,spin=sbbs_random(5);
char telnet_cmd[16];
time_t last_telnet_cmd=0;
if(!online || !input_thread_running) {
......@@ -270,8 +269,7 @@ char sbbs_t::getkey(long mode)
if(now!=last_telnet_cmd && now-timeout>=60 && !((now-timeout)%60)) {
// Let's make sure the socket is up
// Sending will trigger a socket d/c detection
sprintf(telnet_cmd,"%c%c",TELNET_IAC,TELNET_GA);
putcom(telnet_cmd,2);
send_telnet_cmd(TELNET_GA,0);
last_telnet_cmd=now;
}
......
......@@ -787,8 +787,7 @@ static BOOL winsock_startup(void)
#endif
BYTE* telnet_interpret(sbbs_t* sbbs, BYTE* inbuf, int inlen,
static BYTE* telnet_interpret(sbbs_t* sbbs, BYTE* inbuf, int inlen,
BYTE* outbuf, int& outlen)
{
char str[32];
......@@ -862,10 +861,8 @@ BYTE* telnet_interpret(sbbs_t* sbbs, BYTE* inbuf, int inlen,
sbbs->telnet_mode|=TELNET_MODE_ECHO;
else if(sbbs->telnet_cmd[1]==TELNET_DONT) {
sbbs->telnet_mode&=~TELNET_MODE_ECHO;
if(!(sbbs->telnet_mode&TELNET_MODE_GATE)) {
sprintf(str,"%c%c%c",TELNET_IAC,TELNET_WILL,TELNET_ECHO);
sbbs->putcom(str,3);
}
if(!(sbbs->telnet_mode&TELNET_MODE_GATE))
sbbs->send_telnet_cmd(TELNET_WILL,TELNET_ECHO);
}
}
if(startup->options&BBS_OPT_DEBUG_TELNET)
......@@ -884,6 +881,28 @@ BYTE* telnet_interpret(sbbs_t* sbbs, BYTE* inbuf, int inlen,
return(outbuf);
}
void sbbs_t::send_telnet_cmd(uchar cmd, uchar opt)
{
char buf[16];
if(cmd<TELNET_WILL) {
if(startup->options&BBS_OPT_DEBUG_TELNET)
lprintf("Node %d sending telnet cmd: %s"
,cfg.node_num
,telnet_cmd_desc(cmd));
sprintf(buf,"%c%c",TELNET_IAC,cmd);
putcom(buf,2);
} else {
if(startup->options&BBS_OPT_DEBUG_TELNET)
lprintf("Node %d sending telnet cmd: %s %s"
,cfg.node_num
,telnet_cmd_desc(cmd)
,telnet_opt_desc(opt));
sprintf(buf,"%c%c%c",TELNET_IAC,cmd,opt);
putcom(buf,3);
}
}
void input_thread(void *arg)
{
BYTE inbuf[4000];
......
......@@ -223,8 +223,7 @@ void sbbs_t::telnet_gate(char* destaddr, ulong mode)
telnet_mode&=~TELNET_MODE_GATE;
/* Disable Telnet Terminal Echo */
sprintf(str,"%c%c%c",TELNET_IAC,TELNET_WILL,TELNET_ECHO);
putcom(str,3);
send_telnet_cmd(TELNET_WILL,TELNET_ECHO);
close_socket(remote_socket);
......
......@@ -838,8 +838,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
// Let's make sure the socket is up
// Sending will trigger a socket d/c detection
sprintf(str,"%c%c",TELNET_IAC,TELNET_GA);
putcom(str,2);
send_telnet_cmd(TELNET_GA,0);
// Check if the node has been interrupted
getnodedat(cfg.node_num,&thisnode,0);
......@@ -898,8 +897,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
rio_abortable=rio_abortable_save; // Restore abortable state
/* Got back to Text/NVT mode */
sprintf(str,"%c%c%c",TELNET_IAC,TELNET_DONT,TELNET_BINARY);
putcom(str,3);
send_telnet_cmd(TELNET_DONT,TELNET_BINARY);
telnet_mode&=~TELNET_MODE_BIN_RX;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment