TrustCore SDK NanoSSH API reference  version 7.0
Async Server Connection Management Functions

Functions

MOC_EXTERN sbyte4 SSH_ASYNC_acceptConnection (TCP_SOCKET tempSocket, ubyte *pClientHelloString, ubyte4 clientHelloStringLength, ubyte *pServerHelloString, ubyte4 serverHelloStringLength)
 Register a secure SSH asynchronous connection and exchange public/private encryption keys. More...
 
MOC_EXTERN sbyte4 SSH_ASYNC_closeConnection (sbyte4 connectionInstance)
 Close a NanoSSH server session and releases all its resources. More...
 
MOC_EXTERN sbyte4 SSH_ASYNC_init (sbyte4 sshMaxConnections)
 Initialize NanoSSH server internal structures. More...
 
MOC_EXTERN sbyte4 SSH_ASYNC_setListeningPort (ubyte4 listeningPort)
 Set NanoSSH server listening port. More...
 
MOC_EXTERN sbyte4 SSH_ASYNC_startProtocolV2 (sbyte4 connectionInstance)
 Initiate sending a hello message. More...
 

Detailed Description

Function Documentation

◆ SSH_ASYNC_acceptConnection()

MOC_EXTERN sbyte4 SSH_ASYNC_acceptConnection ( TCP_SOCKET  tempSocket,
ubyte *  pClientHelloString,
ubyte4  clientHelloStringLength,
ubyte *  pServerHelloString,
ubyte4  serverHelloStringLength 
)

This function registers a secure SSH asynchronous connection, exchanges public/private encryption keys, and returns the connection's instance.

Since
1.41
Version
1.41 and later

To enable this function, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_ASYNC_SERVER_API__
Parameters
tempSocketSocket or TCB identifier returned by a call to accept().
pClientHelloString(Optional) Pointer to hello string received from client.
clientHelloStringLength(Optional) Number of bytes in hello string received from client (pClientHelloString).
pServerHelloString(Optional) Pointer to hello string sent to client.
serverHelloStringLength(Optional) Number of bytes in hello string sent to client (pServerHelloString).

ssh.h

Returns
Value > 0 is the connection instance; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to asynchronous servers.
intBoolean isBreakSignalRequest = FALSE
sbyte4 connectionInstance;
TCP_SOCKET socketClient;
status = TCP_ACCEPT_SOCKET(&socketClient, mListenSocket, &isBreakSignalRequest);
connectionInstance = SSH_ASNYC_acceptConnection(socketClient, 0,0,0,0);

ssh.h

◆ SSH_ASYNC_closeConnection()

MOC_EXTERN sbyte4 SSH_ASYNC_closeConnection ( sbyte4  connectionInstance)

This function closes a NanoSSH server session and releases all the resources that are managed by the NanoSSH server.

Note
This function does not close sockets or TCBs (transmission control blocks). Therefore, your integration code should explicitly close all TCP/IP sockets and TCBs.
Since
1.41
Version
1.41 and later

To enable this function, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_ASYNC_SERVER_API__
Parameters
connectionInstanceConnection instance returned from SSH_ASYNC_acceptConnection().

ssh.h

Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to asynchronous servers.
sbyte4 status = 0;sbyte4 connectionInstance;
status = SSH_closeConnection(connectionInstance);

ssh.h

◆ SSH_ASYNC_init()

MOC_EXTERN sbyte4 SSH_ASYNC_init ( sbyte4  sshMaxConnections)

This function initializes NanoSSH server internal structures. It should be called before starting your SSH daemon.

Since
1.41
Version
1.41 and later

To enable this function, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_ASYNC_SERVER_API__
Parameters
sshMaxConnectionsMaximum number of SSH asynchronous server connections to allow. (Each connection requires only a few bytes of memory.)

ssh.h

Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to asynchronous servers.
if (0 > SSH_ASYNC_init(MAX_SSH_CONNECTIONS_ALLOWED))
goto exit;

ssh.h

◆ SSH_ASYNC_setListeningPort()

MOC_EXTERN sbyte4 SSH_ASYNC_setListeningPort ( ubyte4  listeningPort)

This function resets the NanoSSH server's listening port from its default (port 22) to any desired port. To reset the port, you must call this function immediately after calling SSH_ASYNC_init().

Since
3.06
Version
3.06 and later

To enable this function, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_ASYNC_SERVER_API__
Parameters
listeningPortListening port number.

ssh.h

Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to asynchronous servers.
goto exit;

ssh.h

◆ SSH_ASYNC_startProtocolV2()

MOC_EXTERN sbyte4 SSH_ASYNC_startProtocolV2 ( sbyte4  connectionInstance)

This function initiates sending a hello message, contrary to the typical sequence of sending a hello in response to receiving a client hello. Use this function only in the rare instance that you are using two SSH stacks on the same port.

Since
1.41
Version
1.41 and later

To enable this function, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSH_ASYNC_SERVER_API__
Parameters
connectionInstanceConnection instance returned from SSH_ASYNC_acceptConnection.

ssh.h

Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
This function is applicable to asynchronous servers.

ssh.h