VxWorks Reference Manual : Libraries
telnetdLib - telnet server library
telnetdInit( ) - initialize the telnet services
telnetdParserSet( ) - specify a command interpreter for telnet sessions
telnetdStart( ) - initialize the telnet services
telnetdExit( ) - close an active telnet session
The telnet protocol enables users on remote systems to login to VxWorks.
This library implements a telnet server which accepts remote telnet login requests and transfers input and output data between a command interpreter and the remote user. The default configuration redirects the input and output from the VxWorks shell if available. The telnetdParserSet( ) routine allows the installation of an alternative command interpreter to handle the remote input and provide the output responses. If the INCLUDE_SHELL configuration macro is not defined, installing a command interpreter is required.
The telnetdInit( ) routine initializes the telnet service when the configuration macro INCLUDE_TELNET is defined. If INCLUDE_SHELL is also defined, the telnetdStart( ) routine automatically starts the server. Client sessions will connect to the shell, which only supports one client at a time.
telnetLib.h
telnetdInit( ) - initialize the telnet services
STATUS telnetdInit ( int numClients, /* maximum number of simultaneous sessions */ BOOL staticFlag /* TRUE: create all tasks in advance of any clients */ )
This routine initializes the telnet server, which supports remote login to VxWorks via the telnet protocol. It is called automatically when the configuration macro INCLUDE_TELNET is defined. The telnet server supports simultaneous client sessions up to the limit specified by the TELNETD_MAX_CLIENTS setting provided in the numClients argument. The staticFlag argument is equal to the TELNETD_TASKFLAG setting. It allows the server to create all of the secondary input and output tasks and allocate all required resources in advance of any connection. The default value of FALSE causes the server to spawn a task pair and create the associated data structures after each new connection.
OK, or ERROR if initialization fails
telnetdParserSet( ) - specify a command interpreter for telnet sessions
STATUS telnetdParserSet ( FUNCPTR pParserCtrlRtn /* provides parser's file descriptors */ )
This routine provides the ability to handle telnet connections using a custom command interpreter or the default VxWorks shell. It is called automatically during system startup when the configuration macros INCLUDE_TELNET and INCLUDE_SHELL are defined to connect clients to that command interpreter. If the TELNETD_TASKFLAG setting creates all the input/output tasks in advance of any client connections, the command interpreter in use when the telnet server starts can never be changed.
The pParserCtrlRtn argument provides a routine using the following interface:
STATUS parserControlRtn ( int telnetdEvent, /* start or stop a telnet session */ UINT32 sessionId, /* a unique session identifier */ int * pInputFd, /* input to command interpreter */ int * pOutputFd /* output from command interpreter */ )The telnet server calls the control routine with a telnetdEvent parameter of REMOTE_START when a client establishes a new connection. The sessionId parameter provides a unique identifier for the session. The control routine must store the appropriate input and output file descriptors in the provided locations.In the default configuration, the telnet server calls the control routine with a telnetdEvent parameter of REMOTE_STOP when a session ends. The control routine must close the file descriptors associated with the sessionId value. The original values are included in the appropriate arguments.
The telnet server does not call the control routine when a session ends if it is configured to spawn all tasks and allocate all resources in advance of any connections. The associated file descriptors will be reused by later clients and cannot be released. In that case, the REMOTE_STOP operation only occurs to allow the command interpreter to close those files when the server encounters a fatal error.
A value of NULL for the control routine argument will prevent further client connections until a new routine is assigned.
OK if parser control routine installed, or ERROR otherwise.
telnetdStart( ) - initialize the telnet services
STATUS telnetdStart ( int port /* target port for accepting connections */ )
Following the telnet server initialization, this routine creates a socket for accepting remote connections and spawns the primary telnet server task. It executes automatically during system startup when the INCLUDE_SHELL and INCLUDE_TELNET configuration macros are defined since a parser control routine is available. The server will not accept connections otherwise.
By default, the server will spawn a pair of secondary input and output tasks after each client connection. Changing the TELNETD_TASKFLAG setting to TRUE causes this routine to create all of those tasks in advance of any connection. In that case, it calls the current parser control routine repeatedly to obtain file descriptors for each possible client based on the numClients argument to the initialization routine. The server will not start if the parser control routine returns ERROR.
The TELNETD_PORT constant provides the port argument which assigns the port where the server accepts connections. The default value is the standard setting of 23.
OK, or ERROR if startup fails
telnetdExit( ) - close an active telnet session
void telnetdExit ( UINT32 sessionId /* identifies the session to be deleted */ )
This routine supports the session exit command for a command intepreter (such as logout( ) for the VxWorks shell). Depending on the TELNETD_TASKFLAG setting, it causes the associated input and output tasks to restart or exit. The sessionId parameter must match a value provided to the command interpreter with the REMOTE_START option.
N/A.
N/A