NetBurner 3.5.0
PDF Version
 
Command Processor

Topics

 Command Processor Disconnect Causes
 
 Command Processor Listen Channels
 
 Command Processor Response Codes
 

Functions

int CmdStartCommandProcessor (int priority)
 Start the command processor.
 
int CmdAddCommandFd (int fd, bool require_auth, bool time_out_conn, bool local_echo=true)
 Add an established FD connection to the list of fd's managed by the command processor.
 
int CmdRemoveCommandFd (int fd)
 Remove an established FD (either a TCP session, a serial connection, or an SSH session).
 
int CmdListenOnTcpPort (uint16_t port, int do_telnet_processing, int max_connections)
 Start listening for a connection over TCP.
 
int CmdListenQuietOnTcpPort (uint16_t port, int do_telnet_processing, int max_connections)
 Start listening for a connection over TCP, but without the siggnon or password.
 
int CmdListenOnSshPort (uint16_t port, int max_connections)
 Start listening for a connection over SSH.
 
int CmdListenQuietOnSshPort (uint16_t port, int max_connections)
 Start listening for a connection over SSH, but without the siggnon or password.
 
int CmdStopListeningOnTcpPort (uint16_t port)
 Stop Listening for connections on the specified port. Also closes all open connections that were based on that port.
 
int CmdStopListeningOnSshPort (uint16_t port)
 Stop Listening for connections on the specified port. Also closes all open connections that were based on that port.
 
void SendToAll (const char *buffer, int len, bool include_serial_ports)
 Send a message to all connected sockets, excluding "Listening sockets".
 

Variables

int(* CmdAuthenticateFunc )(const char *name, const char *passwd)
 External Authentication function CALLBACK for TCP connections, used to verify username and password. If this function pointer is not NULL then each new Telnet session will be asked to authenticate.
 
int(* CmdAuthenticateSshFunc )(const char *name, const char *authVal, AuthType authType)
 External Authentication function CALLBACK for SSH connections, used to verify username and password. If this function pointer is not NULL then each new SSH session will be asked to authenticate. If this function pointer is NULL, it tries to use CmdAuthenticateFunc instead.
 
int(* CmdCmd_func )(const char *command, FILE *fRespondto, void *pData)
 The command processing callback function for handling string commands.
 
int(* CmdChar_func )(char command, FILE *fRespondto, void *pData)
 The command processing callback function for handling single character commands. If this is implemented does not do echo or line editing this is the responsibility of the application programmer.
 
void *(* CmdConnect_func )(FILE *fRespondto)
 Connect callback function. If this function is not NULL, then the system will call this function every time a new session is started.
 
void(* CmdPrompt_func )(FILE *fRespondto, void *pData)
 Prompt callback function. If this function is not NULL, then the system will call this function every time a new prompt line needs to be displayed.
 
void(* CmdDisConnect_func )(FILE *fRespondto, int cause, void *pData)
 Dis-Connect callback function, if this function is not NULL then the system will call this function every time a session is terminated.
 
int CmdIdleTimeout
 
const char * Cmdlogin_prompt
 If this is defined, then it will be sent to the socket on connection before Authentication is tried.
 

Detailed Description

#include< command.h >

This is is NetBurner's Command Processor Library. It operates as a task and reads input one line at a time from multiple sources. When it has gathered a whole line, it sends it to a command processor that is defined by the user.

Function Documentation

◆ CmdAddCommandFd()

int CmdAddCommandFd ( int fd,
bool require_auth,
bool time_out_conn,
bool local_echo = true )

#include <command.h>

Add an established FD connection to the list of fd's managed by the command processor.

Parameters
fdThe file descriptor.
require_authDo we Authenticate the connection on this FD?
time_out_connDo we time out the connection on this FD?
local_echoDo we provide a local echo for this FD (default is true)?
Return values
CMD_OKCommand processor task started properly.
CMD_FAILCommand processor task failed to start.
CMD_TO_MANY_FDSToo many file descriptors are currently in use.

◆ CmdListenOnSshPort()

int CmdListenOnSshPort ( uint16_t port,
int max_connections )

#include <command.h>

Start listening for a connection over SSH.

Parameters
portThe port number to listen on.
max_connectionsWhat are the max number of connections we should allow on this port?
Return values
CMD_OKSuccessfully removed the file descriptor.
CMD_TO_MANY_FDSToo many file descriptors are currently in use.
CMD_FAILED_SSH_KEY_GENUnable to generate the key needed for SSH communication.

◆ CmdListenOnTcpPort()

int CmdListenOnTcpPort ( uint16_t port,
int do_telnet_processing,
int max_connections )

#include <command.h>

Start listening for a connection over TCP.

Parameters
portThe port number to listen on.
do_telnet_processingShould we treat the port as telnet and process telnet negotiations?
max_connectionsWhat are the max number of connections we should allow on this port?
Return values
CMD_OKSuccessfully removed the file descriptor.
CMD_TO_MANY_FDSToo many file descriptors are currently in use.

◆ CmdListenQuietOnSshPort()

int CmdListenQuietOnSshPort ( uint16_t port,
int max_connections )

#include <command.h>

Start listening for a connection over SSH, but without the siggnon or password.

Parameters
portThe port number to listen on.
max_connectionsWhat are the max number of connections we should allow on this port?
Return values
CMD_OKSuccessfully removed the file descriptor.
CMD_TO_MANY_FDSToo many file descriptors are currently in use.
CMD_FAILED_SSH_KEY_GENUnable to generate the key needed for SSH communication.

◆ CmdListenQuietOnTcpPort()

int CmdListenQuietOnTcpPort ( uint16_t port,
int do_telnet_processing,
int max_connections )

#include <command.h>

Start listening for a connection over TCP, but without the siggnon or password.

Parameters
portThe port number to listen on.
do_telnet_processingShould we treat the port as telnet and process telnet negotiations?
max_connectionsWhat are the max number of connections we should allow on this port?
Return values
CMD_OKSuccessfully removed the file descriptor.
CMD_TO_MANY_FDSToo many file descriptors are currently in use.

◆ CmdRemoveCommandFd()

int CmdRemoveCommandFd ( int fd)

#include <command.h>

Remove an established FD (either a TCP session, a serial connection, or an SSH session).

Parameters
fdThe file descriptor to remove.
Return values
CMD_OKSuccessfully removed the file descriptor.
CMD_FAILFailed to remove the file descriptor.

◆ CmdStartCommandProcessor()

int CmdStartCommandProcessor ( int priority)

#include <command.h>

Start the command processor.

Parameters
priorityThe NBRTOS task priority to run at.
Return values
CMD_OKCommand processor task started properly.
CMD_FAILCommand processor task failed to start.

◆ CmdStopListeningOnSshPort()

int CmdStopListeningOnSshPort ( uint16_t port)

#include <command.h>

Stop Listening for connections on the specified port. Also closes all open connections that were based on that port.

Parameters
portThe port number to listen on.
Return values
CMD_OKSuccessfully removed the file descriptor.
CMD_FAILPort requested wasn't listening for a connection.

◆ CmdStopListeningOnTcpPort()

int CmdStopListeningOnTcpPort ( uint16_t port)

#include <command.h>

Stop Listening for connections on the specified port. Also closes all open connections that were based on that port.

Parameters
portThe port number to listen on.
Return values
CMD_OKSuccessfully removed the file descriptor.
CMD_FAILPort requested wasn't listening for a connection.

◆ SendToAll()

void SendToAll ( const char * buffer,
int len,
bool include_serial_ports )

#include <command.h>

Send a message to all connected sockets, excluding "Listening sockets".

Parameters
bufferA buffer holding the message to send.
lenThe length of the buffer to send.
include_serial_portsAlso send to serial ports?

Variable Documentation

◆ CmdAuthenticateFunc

int(* CmdAuthenticateFunc) (const char *name, const char *passwd) ( const char * name,
const char * passwd )
extern

#include <command.h>

External Authentication function CALLBACK for TCP connections, used to verify username and password. If this function pointer is not NULL then each new Telnet session will be asked to authenticate.

Parameters
nameThe user name trying to authenticate.
passwdThe password provided for the user.
Return values
CMD_OKIf the authentication was successful.
CMD_CLOSEIf the authentication was not successful.

◆ CmdAuthenticateSshFunc

int(* CmdAuthenticateSshFunc) (const char *name, const char *authVal, AuthType authType) ( const char * name,
const char * authVal,
AuthType authType )
extern

#include <command.h>

External Authentication function CALLBACK for SSH connections, used to verify username and password. If this function pointer is not NULL then each new SSH session will be asked to authenticate. If this function pointer is NULL, it tries to use CmdAuthenticateFunc instead.

Parameters
nameThe user name trying to authenticate.
authValThe authorization value provided for the user.
authTypeThe type of authorization value passed in.
Return values
CMD_OKIf the authentication was successful.
CMD_CLOSEIf the authentication was not successful.

◆ CmdChar_func

int(* CmdChar_func) (char command, FILE *fRespondto, void *pData) ( char command,
FILE * fRespondto,
void * pData )
extern

#include <command.h>

The command processing callback function for handling single character commands. If this is implemented does not do echo or line editing this is the responsibility of the application programmer.

Parameters
commandThe single command character.
fRespondtoThe FILE * all responses should be set to (use fprintf).
pDataAny data that is associated from the session. This is returned by CmdConnect_func.
Return values
CMD_OKIf the command was okay.
CMD_CLOSEIf the command causes the session to terminate (Close).
See also
CmdCmd_func
CmdConnect_func

◆ CmdCmd_func

int(* CmdCmd_func) (const char *command, FILE *fRespondto, void *pData) ( const char * command,
FILE * fRespondto,
void * pData )
extern

#include <command.h>

The command processing callback function for handling string commands.

Parameters
commandA pointer to the null terminated ASCII text of the command.
fRespondtoThe FILE * all responses should be set to (use fprintf).
pDataAny data that is associated from the session and is returned by CmdConnect_func.
Return values
CMD_OKIf the command was okay.
CMD_CLOSEIf the command causes the session to terminate (Close).
See also
CmdChar_func
CmdConnect_func

◆ CmdConnect_func

void *(* CmdConnect_func) (FILE *fRespondto) ( FILE * fRespondto)
extern

#include <command.h>

Connect callback function. If this function is not NULL, then the system will call this function every time a new session is started.

Parameters
fRespondtoThe FILE * all responses should be set to (use fprintf).
Return values
Returnsan arbitrary void* data item to be associated with the session. This data item is the same pData item used in other callback functions such as CmdPrompt_func.
See also
CmdCmd_func
CmdChar_func

◆ CmdDisConnect_func

void(* CmdDisConnect_func) (FILE *fRespondto, int cause, void *pData) ( FILE * fRespondto,
int cause,
void * pData )
extern

#include <command.h>

Dis-Connect callback function, if this function is not NULL then the system will call this function every time a session is terminated.

Parameters
fRespondtoThe FILE * all responses should be set to (use fprintf).
causeWhy it disconnected. Can be any value from Command Processor Disconnect Causes.
pDataAny data that is associated from the session. This is returned by CmdConnect_func.
See also
CmdConnect_func

◆ CmdIdleTimeout

int CmdIdleTimeout
extern

#include <command.h>

User defined value that specifies the number of seconds a connection is idle before it is terminated due to inactivity.

◆ CmdPrompt_func

void(* CmdPrompt_func) (FILE *fRespondto, void *pData) ( FILE * fRespondto,
void * pData )
extern

#include <command.h>

Prompt callback function. If this function is not NULL, then the system will call this function every time a new prompt line needs to be displayed.

Parameters
fRespondtoThe FILE * all responses should be set to (use fprintf).
pDataAny data that is associated from the session. This is returned by CmdConnect_func.
See also
CmdConnect_func