Commits (3)
/* telnet.c */
/* Synchronet telnet command/option functions */
/* $Id: telnet.c,v 1.10 2019/08/24 19:37:11 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -17,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -149,6 +133,11 @@ uchar telnet_opt_nak(uchar cmd)
return 0;
}
bool telnet_opt_enabled(uchar val)
{
return (val == TELNET_DO) || (val == TELNET_WILL);
}
/*****************************************************************************/
// Escapes Telnet IACs in 'inbuf' by doubling the IAC char
// 'result' may point to either inbuf (if there were no IACs) or outbuf
......
/* telnet.h */
/* Synchronet telnet-related constants and function prototypes */
/* $Id: telnet.h,v 1.21 2019/08/24 19:37:11 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -17,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -39,6 +23,7 @@
#define _TELNET_H
#include "gen_defs.h" /* uchar */
#include <stdbool.h>
/* commands */
......@@ -165,6 +150,7 @@ DLLEXPORT const char* telnet_cmd_desc(uchar cmd);
DLLEXPORT const char* telnet_opt_desc(uchar opt);
DLLEXPORT uchar telnet_opt_ack(uchar cmd);
DLLEXPORT uchar telnet_opt_nak(uchar cmd);
DLLEXPORT bool telnet_opt_enabled(uchar value);
DLLEXPORT size_t telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf, size_t outlen
,BOOL expand_cr, uchar** result);
......
......@@ -77,6 +77,7 @@ struct {
bool terminate_on_disconnect;
ulong data_rate;
bool server_echo;
bool server_binary;
char client_file[MAX_PATH + 1];
char ip_filter_file[MAX_PATH + 1];
char busy_notice[INI_MAX_VALUE_LEN];
......@@ -258,6 +259,7 @@ char* connected(struct modem* modem)
{
modem->online = true;
modem->ringing = false;
ResetEvent(hangup_event);
ResetEvent(hungup_event);
SetEvent(carrier_event);
return connect_result(modem);
......@@ -718,6 +720,10 @@ char* answer(struct modem* modem)
/* Disable Telnet Terminal Echo */
request_telnet_opt(TELNET_WILL,TELNET_ECHO);
}
if(cfg.server_binary) {
/* Will send in binary mode (no CR->CRLF expansion on receiver side) */
request_telnet_opt(TELNET_WILL,TELNET_BINARY_TX);
}
/* Will suppress Go Ahead */
request_telnet_opt(TELNET_WILL,TELNET_SUP_GA);
}
......@@ -1050,6 +1056,7 @@ bool read_ini(const char* ini_fname)
cfg.listen = iniGetBool(ini, ROOT_SECTION, "Listen", cfg.listen);
cfg.debug = iniGetBool(ini, ROOT_SECTION, "Debug", cfg.debug);
cfg.server_echo = iniGetBool(ini, ROOT_SECTION, "ServerEcho", cfg.server_echo);
cfg.server_binary = iniGetBool(ini, ROOT_SECTION, "ServerBinary", cfg.server_binary);
cfg.data_rate = iniGetLongInt(ini, ROOT_SECTION, "Rate", cfg.data_rate);
cfg.address_family = iniGetEnum(ini, ROOT_SECTION, "AddressFamily", addrFamilyNames, cfg.address_family);
char value[INI_MAX_VALUE_LEN];
......@@ -1089,6 +1096,7 @@ int main(int argc, char** argv)
// Default configuration values
mode = TELNET;
cfg.server_echo = TRUE;
cfg.server_binary = TRUE;
cfg.port = IPPORT_TELNET;
cfg.address_family = ADDRESS_FAMILY_UNSPEC;
SAFECOPY(cfg.client_file, "client.ini");
......@@ -1430,7 +1438,7 @@ int main(int argc, char** argv)
uint8_t* p = buf;
if(mode == TELNET) {
len = telnet_expand(buf, rd, telnet_buf, sizeof(telnet_buf)
,telnet.local_option[TELNET_BINARY_TX] != TELNET_WILL // expand_cr
,!telnet_opt_enabled(telnet.local_option[TELNET_BINARY_TX]) // expand_cr
,&p);
if(len != rd)
dprintf("Telnet expanded %d bytes to %d", rd, len);
......