1 2 class LATSession 3 { 4 public: LATSession(class LATConnection & p,unsigned char remid,unsigned char localid,bool _clean)5 LATSession(class LATConnection &p, 6 unsigned char remid, unsigned char localid, bool _clean): 7 pid(-1), 8 parent(p), 9 remote_session(remid), 10 local_session(localid), 11 max_read_size(250), 12 clean(_clean), 13 credit(0), 14 request_id(0), 15 stopped(false), 16 remote_credit(0), 17 master_conn(NULL) 18 {} 19 virtual ~LATSession(); 20 21 int send_data_to_process(unsigned char *buf, int len); 22 int read_pty(); 23 void remove_session(); 24 void send_disabled_message(); 25 void add_credit(signed short c); 26 void set_port(unsigned char *inbuf); get_remote_credit()27 int get_remote_credit() { return remote_credit; } inc_remote_credit(int inc)28 void inc_remote_credit(int inc) { remote_credit+=inc; } 29 void got_connection(unsigned char _remid); isConnected()30 bool isConnected() { return connected; } waiting_start()31 bool waiting_start() { return state == STARTING; } 32 33 virtual void disconnect_session(int reason); 34 virtual int new_session(unsigned char *_remote_node, 35 char *service, char *port, unsigned char c)=0; do_read()36 virtual void do_read() {} 37 virtual void connect(); 38 39 // These two are for queuedsession really, but we don't 40 // know what type of session we have in the connection dtor set_master_conn(LATConnection ** master)41 void set_master_conn(LATConnection **master) 42 { 43 master_conn = master; 44 } get_master_conn()45 LATConnection *get_master_conn() 46 { 47 if (master_conn) 48 return *master_conn; 49 else 50 return NULL; 51 } 52 53 protected: 54 enum {NEW, STARTING, RUNNING, STOPPED} state; 55 char remote_node[32]; // Node name 56 char remote_service[32]; // Service name 57 char remote_port[32]; 58 char ptyname[256]; 59 int master_fd; 60 pid_t pid; 61 bool echo_expected; 62 bool connected; 63 class LATConnection &parent; 64 unsigned char remote_session; 65 unsigned char local_session; 66 int max_read_size; 67 bool clean; // Connection should be 8bit clean 68 char ltaname[255]; 69 unsigned short request_id; 70 71 // Flow control 72 int credit; 73 bool stopped; 74 int remote_credit; 75 LATConnection **master_conn; 76 77 78 protected: 79 int send_data(unsigned char *buf, int msglen, int ); 80 void send_issue(); 81 int send_break(); 82 void add_slot(unsigned char *buf, int &ptr, int slotcmd, unsigned char *slotdata, int len); 83 void crlf_to_lf(unsigned char *buf, int len, unsigned char *newbuf, int *newlen); 84 int writeall(int fd, unsigned char *buf, int len); 85 }; 86