70 likes | 244 Views
Telnet Server API. Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions. Integrating a Telnet Server. Application Entry. TSInitServer(TS_ICONFIG_TYPE *ptr ). TSOpenPort(unsigned long *port , TS_UCONFIG_TYPE * ptr ).
E N D
Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions
Integrating a Telnet Server Application Entry TSInitServer(TS_ICONFIG_TYPE *ptr) TSOpenPort(unsigned long *port, TS_UCONFIG_TYPE *ptr) • Structure that defines: • Number of ports to Listen on • Structure that defines: • Telnet Port • Login retries • Client and server options TS_ECHO,TS_BINARY,TS_NOGA • Callbacks for connect, login, disconnect, receive and buffer management
Sample Telnet Port Setup TS_UCONFIG_TYPE; Properties & Callbacks Setup Telnet Listener Using Above Properties
Callback functions int (*connect_callback) (unsigned int session_id) int (*login_callback) (unsigned int session_id, int user_id) int (*disconnect_callback) (unsigned int session_id) int (*getbuf_callback) (unsigned int session_id, void **buf, int *bufSize) int (*receive_callback) (unsigned int session_id, void *buf, int len)
Setting Server and Client Options int TSSetServerOption( unsigned long session_id, unsigned long option, int mode) int TSSetClientOption( unsigned long session_id, unsigned long option, int mode) • mode – 0 off/1 on • Option • TS_TXBINARY (xmit binary data) • TS_NOECHO (echo) • TS_NOGA (go-ahead characters) • TS_CAMOUFLAGE (server only – “camouflage” password) (Note: “session_id” comes from connect or logon callback)
Other Telnet API Functions int TSClosePort (unsigned long port_id) int TSSendData (unsigned long session_id, char *buf, int len) int TSSendString (unsigned long session_id, char *buf) int TSCloseSession (unsigned long session_id) char *TSGetSessionUserName (unsigned long session_id)
Telnet Server Summary • Start with TSInitServer • Perform TSOpenPort for each port • TS_UCONFIG_TYPE structure provides parameters (including callback addresses) on port-by-port basis • Process client interaction via callbacks for connect, login, receive, disconnect and buffer acquisition • Use TSSendData or TSSendString to transmit to client. • Close session with TSCloseSession • Close out port with TSClosePort