// rfc2217.h // // // Requires DDK Only // File created on 3/15/2006 // #ifndef __RFC2217_H__ #define __RFC2217_H__ /* Version id */ #define VersionId "2.2.1" #define SRedirdVersionId "Version " VersionId ", 20 February 2004" /* Locking constants */ #define LockOk 0 #define Locked 1 #define LockKo 2 /* Error conditions constants */ #define NoError 0 #define Error 1 #define OpenError -1 /* Maximum length of temporary strings */ #define TmpStrLen 255 /* Buffer size */ #define TN_BufferSize 512 /* File mode and file length for HDB (ASCII) stile lock file */ #define LockFileMode 0644 #define HDBHeaderLen 11 /* Base Telnet protocol constants (STD 8) */ #define TNSE ((unsigned char) 240) // F0 End of Sub Negotiation Parameters #define TNNOP ((unsigned char) 241) // F1 No Operation #define TNEND ((unsigned char) 249) // F9 Go Ahead Signal #define TNSB ((unsigned char) 250) // FA Sub Command #define TNWILL ((unsigned char) 251) // FB Will #define TNWONT ((unsigned char) 252) // FC Won't #define TNDO ((unsigned char) 253) // FD Do #define TNDONT ((unsigned char) 254) // FE Don't #define TNIAC ((unsigned char) 255) // FF Interpret As Command /* Base Telnet protocol options constants (STD 27, STD 28, STD 29) */ #define TN_TRANSMIT_BINARY ((unsigned char) 0) #define TN_ECHO ((unsigned char) 1) #define TN_SUPPRESS_GO_AHEAD ((unsigned char) 3) /* Base Telnet Com Port Control (CPC) protocol constants (RFC 2217) */ #define TNCOM_PORT_OPTION ((unsigned char) 44) // 2C //#define BUFFER_STATE /* CPC Client to Access Server constants */ #define TNCAS_SIGNATURE ((unsigned char) 0) #define TNCAS_SET_BAUDRATE ((unsigned char) 1) #define TNCAS_SET_DATASIZE ((unsigned char) 2) #define TNCAS_SET_PARITY ((unsigned char) 3) #define TNCAS_SET_STOPSIZE ((unsigned char) 4) #define TNCAS_SET_CONTROL ((unsigned char) 5) #define TNCAS_NOTIFY_LINESTATE ((unsigned char) 6) #define TNCAS_NOTIFY_MODEMSTATE ((unsigned char) 7) #define TNCAS_FLOWCONTROL_SUSPEND ((unsigned char) 8) #define TNCAS_FLOWCONTROL_RESUME ((unsigned char) 9) #define TNCAS_SET_LINESTATE_MASK ((unsigned char) 10) // A #define TNCAS_SET_MODEMSTATE_MASK ((unsigned char) 11) // B #define TNCAS_PURGE_DATA ((unsigned char) 12) // C #ifdef BUFFER_STATE #define TNCAS_NOTIFY_BUFFERSTATE ((unsigned char) 27) // 1B #endif /* CPC Access Server to Client constants */ #define TNASC_SIGNATURE ((unsigned char) 100) // 64 #define TNASC_SET_BAUDRATE ((unsigned char) 101) // 65 #define TNASC_SET_DATASIZE ((unsigned char) 102) // 66 #define TNASC_SET_PARITY ((unsigned char) 103) // 67 #define TNASC_SET_STOPSIZE ((unsigned char) 104) // 68 #define TNASC_SET_CONTROL ((unsigned char) 105) // 69 #define TNASC_NOTIFY_LINESTATE ((unsigned char) 106) // 6A #define TNASC_NOTIFY_MODEMSTATE ((unsigned char) 107) // 6B #define TNASC_FLOWCONTROL_SUSPEND ((unsigned char) 108) // 6C #define TNASC_FLOWCONTROL_RESUME ((unsigned char) 109) // 6D #define TNASC_SET_LINESTATE_MASK ((unsigned char) 110) // 6E #define TNASC_SET_MODEMSTATE_MASK ((unsigned char) 111) // 6F #define TNASC_PURGE_DATA ((unsigned char) 112) // 70 #ifdef BUFFER_STATE #define TNASC_NOTIFY_BUFFERSTATE ((unsigned char) 127) // 7F #endif #define TN_CONTROL_FLOW_REQUEST ((unsigned char) 0) #define TN_CONTROL_FLOW_NONE ((unsigned char) 1) #define TN_CONTROL_FLOW_XON_XOFF ((unsigned char) 2) #define TN_CONTROL_FLOW_HARDWARE ((unsigned char) 3) #define TN_CONTROL_BREAK_REQUEST ((unsigned char) 4) #define TN_CONTROL_BREAK_ON ((unsigned char) 5) #define TN_CONTROL_BREAK_OFF ((unsigned char) 6) #define TN_CONTROL_DTR_REQUEST ((unsigned char) 7) #define TN_CONTROL_DTR_ON ((unsigned char) 8) #define TN_CONTROL_DTR_OFF ((unsigned char) 9) #define TN_CONTROL_RTS_REQUEST ((unsigned char) 10) // A #define TN_CONTROL_RTS_ON ((unsigned char) 11) // B #define TN_CONTROL_RTS_OFF ((unsigned char) 12) // C #define TN_CONTROL_FLOW_CONTROL_REQUEST ((unsigned char) 13) // D #define TN_CONTROL_FLOW_CONTROL_NONE ((unsigned char) 14) // E #define TN_CONTROL_FLOW_CONTROL_XON_XOFF ((unsigned char) 15) // F #define TN_CONTROL_FLOW_CONTROL_HARDWARE ((unsigned char) 16) // 10 #define TN_CONTROL_FLOW_CONTROL_DCD ((unsigned char) 17) // 11 #define TN_CONTROL_FLOW_CONTROL_DTR ((unsigned char) 18) // 12 #define TN_CONTROL_FLOW_CONTROL_DSR ((unsigned char) 19) //13 #define TN_PURGE_RX_BUFFER ((unsigned char) 1) #define TN_PURGE_TX_BUFFER ((unsigned char) 2) #define TN_PURGE_RX_AND_TX_BUFFER ((unsigned char) 3) #define TN_LINESTATE_SHIFT_REG_EMPTY ((unsigned char) 0x40) #define TN_LINESTATE_HOLDING_REG_EMPTY ((unsigned char) 0x20) /* Modem state effective change mask */ #define ModemStateECMask ((unsigned char) 255) // FF #define LineStateECMask ((unsigned char) 255) // FF /* Default modem state polling in milliseconds (100 msec should be enough) */ #define ModemStatePolling 100 /* Standard boolean definition */ typedef enum { False, True } Boolean; /* Cisco IOS bug compatibility */ //Boolean CiscoIOSCompatible = False; #define MAX_TELNET_COMMANDS 256 /* Telnet State Machine */ typedef struct _CPR_TELNET_STATE { int sent_will:1; int sent_do:1; int sent_wont:1; int sent_dont:1; int is_will:1; int is_do:1; } CPR_TELNET_STATE, *PCPR_TELNET_STATE; /* Buffer structure */ typedef struct _CPR_BUFFER_TYPE { unsigned char Buffer[TN_BufferSize]; unsigned int RdPos; unsigned int WrPos; } CPR_BUFFER_TYPE, *PCPR_BUFFER_TYPE; /* Maximum log level to log in the system log */ //static int MaxLogLevel = LOG_DEBUG + 1; /* Status enumeration for IAC escaping and interpretation */ typedef enum { IACNormal, IACReceived, IACComReceiving } IACState; #ifdef COMMENT /* Current status of the line control lines */ static unsigned char LineState = ((unsigned char) 0); #endif /* Function prototypes */ /* initialize Telnet State Machine */ void InitTelnetStateMachine(CPR_TELNET_STATE tnstate[]); /* Initialize a buffer for operation */ void InitBuffer(CPR_BUFFER_TYPE * B); /* Check if the buffer is empty */ Boolean IsBufferEmpty(CPR_BUFFER_TYPE * B); /* Check if the buffer is full */ Boolean IsBufferFull(CPR_BUFFER_TYPE * B); /* Add a byte to a buffer */ void AddToBuffer(CPR_BUFFER_TYPE * B, unsigned char C); /* Get a byte from a buffer */ unsigned char GetFromBuffer(CPR_BUFFER_TYPE * B); /* Generic log function with log level control. Uses the same log levels of the syslog(3) system call */ //void LogMsg(int LogLevel, const char * const Msg); /* Send the specific telnet option to SockFd using Command as command */ void SendTelnetOption(CPR_BUFFER_TYPE * B, unsigned char Command, char Option); //void SendCPCFlowCommand(CPR_BUFFER_TYPE * B, unsigned char Command); /* Write a buffer to SockFd with IAC escaping */ void EscWriteBuffer(CPR_BUFFER_TYPE * B, unsigned char * Buffer, unsigned int BSize); #endif // __RFC2217_H__