7
Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions

Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions

Embed Size (px)

Citation preview

Page 1: Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions

Telnet Server API

Setting up the Server

Callback Functions

Setting Server and Client Options

Other Telnet API Functions

Page 2: 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: • Telnet Port

• Login retries

• Client and server options TS_ECHO,TS_BINARY,TS_NOGA

• Callbacks for connect, login, disconnect, receive and buffer management

Structure that defines: • Number of ports to Listen on

Page 3: Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions

Sample Telnet Port Setup

TS_UCONFIG_TYPE;Properties

&Callbacks

Setup Telnet Listener Using

Above Properties

Page 4: Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions

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)

Page 5: Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions

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)

Page 6: Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions

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)

Page 7: Telnet Server API Setting up the Server Callback Functions Setting Server and Client Options Other Telnet API Functions

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