1 /* public things from tcp.c */ 2 3 #ifndef _TCP_H_ 4 #define _TCP_H_ 5 6 extern int tcp_fd; /* current socket file descriptor */ 7 extern int tcp_main_fd; /* main session socket */ 8 extern int tcp_max_fd; /* highest used fd */ 9 10 extern int tcp_count; /* number of open connections */ 11 extern int tcp_attachcount; /* number of spawned or attached commands */ 12 13 extern int conn_max_index; /* 1 + highest used conn_list[] index */ 14 15 16 /* multiple connections control */ 17 18 /* state of telnet connection */ 19 #define NORMAL 0 20 #define ALTNORMAL 1 21 #define GOT_N 2 22 #define GOT_R 3 23 #define GOTIAC 4 24 #define GOTWILL 5 25 #define GOTWONT 6 26 #define GOTDO 7 27 #define GOTDONT 8 28 #define GOTSB 9 29 #define GOTSBIAC 10 30 31 /* connection flags: */ 32 /* ACTIVE: display remote output */ 33 /* SPAWN: spawned cmd, not a mud */ 34 /* IDEDITOR: sent #request editor */ 35 /* IDPROMPT: sent #request prompt */ 36 #define ACTIVE 1 37 #define SPAWN 2 38 #define IDEDITOR 4 39 #define IDPROMPT 8 40 41 typedef struct { 42 char *id; /* session id */ 43 char *host; /* address of remote host */ 44 int port; /* port number of remote host */ 45 int fd; /* fd number */ 46 char *fragment; /* for SPAWN connections: unprocessed text */ 47 char flags; 48 char state; 49 } connsess; 50 51 extern connsess conn_list[MAX_CONNECTS]; /* connection list */ 52 53 extern byte conn_table[MAX_FDSCAN]; /* fd -> index translation table */ 54 55 #define CONN_LIST(n) conn_list[conn_table[n]] 56 #define CONN_INDEX(n) conn_list[n] 57 58 extern fd_set fdset; /* set of descriptors to select() on */ 59 60 int tcp_connect __P ((char *addr, int port)); 61 int tcp_read __P ((int fd, char *buffer, int maxsize)); 62 void tcp_raw_write __P ((int fd, const char *data, int len)); 63 void tcp_write_escape_iac __P3 (int,fd, const char *,data, int,len); 64 void tcp_write_tty_size __P ((void)); 65 void tcp_write __P ((int fd, char *data)); 66 void tcp_main_write __P ((char *data)); 67 void tcp_flush __P ((void)); 68 void tcp_set_main __P ((int fd)); 69 void tcp_open __P ((char *id, char *initstring, char *host, int port)); 70 int tcp_find __P ((char *id)); 71 void tcp_show __P ((void)); 72 void tcp_close __P ((char *id)); 73 void tcp_togglesnoop __P ((char *id)); 74 void tcp_spawn __P ((char *id, char *cmd)); 75 int tcp_unIAC __P ((char *data, int len)); 76 int tcp_read_addIAC __P ((int fd, char *data, int len)); 77 78 #endif /* _TCP_H_ */ 79 80