1
// Process server for soft ioc
2
// David H. Thompson 8/29/2003
3
// Ralph Lange 04/25/2008
4
// GNU Public License (GPLv3) applies - see www.gnu.org
6
#ifndef telnetStateMachineH
7
#define telnetStateMachineH
9
#include <arpa/telnet.h>
10
int TelnetStateMachine(char * buf,int len); // Returns new length
11
#define OPT_STRING_LEN 32
13
class telnetStateMachine
17
void SetConnectionItem(connectionItem * item)
20
sendInitialRequests();
22
int OnReceive(char * buf,int len,bool priority=false);
26
signed char _buf[128]; // Where to put data after an IAC
27
int _count; // This is normally -1, after IAC it is 0 + chars received
28
int _expected; // When to process the command
29
connectionItem * _item; // This is the client that owns us
32
// The constructor will set the ones that I want to negotiate
33
// If the server wants to negotiate then he will probably get a wont or dont
34
unsigned char _myOpts[NTELOPTS]; // Either I will, I wont, I do, I dont
35
unsigned char _otherOpts[NTELOPTS]; // Will he, wont he, he does, he does not.
36
unsigned char _myOptArg[NTELOPTS][OPT_STRING_LEN]; // Either I will, I wont, I do, I dont
37
unsigned char _otherOptArg[NTELOPTS][OPT_STRING_LEN]; // Will he, wont he, he does, he does not.
38
unsigned char _myOptArgLen[NTELOPTS]; // Either I will, I wont, I do, I dont
39
unsigned char _otherOptArgLen[NTELOPTS]; // Will he, wont he, he does, he does not.
42
void sendReply( int opt0, int opt1=-1,int opt2=-1, int opt3=-1,int opt4=-1);
43
void doCommand(); // The state is in _buf[]/_count;
44
void sendInitialRequests();
46
bool onChar(unsigned char c);
47
void onDo(unsigned char opt);
48
void onDont(unsigned char opt);
49
void onWill(unsigned char opt);
50
void onWont(unsigned char opt);
51
void onOpt(unsigned char opt);
66
unsigned char _workingOpt; // Used in state ON_OPT
69
#endif /*#ifndef telnetStateMachineH */