![]() |
TrustCore SDK NanoSSH API reference
version 7.0
|
NanoSSH Client developer API header. More...
Go to the source code of this file.
Data Structures | |
struct | clientTerminalState |
struct | keyIntInfoReq |
struct | keyIntInfoResp |
struct | keyIntPrompt |
struct | keyIntResp |
struct | sftpcFileHandleDescr |
NanoSSH Client SFTP file handle descriptor. More... | |
struct | sshClientSettings |
Configuration settings and callback function pointers for SSH clients. More... | |
Typedefs | |
typedef struct certChain * | certChainPtr |
Functions | |
MSTATUS | SSHC_cancelRemotePortForwarding (sbyte4 connectionInstance, sbyte *pHostAddr, ubyte4 hostPort) |
MOC_EXTERN void | SSHC_close (sbyte4 connectionInstance) |
Close an SSH session and releases all its resources. More... | |
MOC_EXTERN sbyte4 | SSHC_closeDirectory (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Close a directory on an SFTP server. More... | |
MOC_EXTERN sbyte4 | SSHC_closeFile (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Close a file on an SFTP server. More... | |
MOC_EXTERN sbyte4 | SSHC_connect (TCP_SOCKET tempSocket, sbyte4 *pConnectionInstance, sbyte *pCommonName, struct certStore *pCertStore) |
Create a secure SSH connection with a remote server. More... | |
MOC_EXTERN sbyte4 | SSHC_doProtocolProcessPortForwardSession (sbyte4 connectionInstance, intBoolean useTimeout, ubyte4 timeout) |
MOC_EXTERN sbyte4 | SSHC_freeFilename (sbyte4 connectionInstance, ubyte **ppFreeFilename) |
Release memory used to store a filename. More... | |
MOC_EXTERN MSTATUS | SSHC_freeGenerateServerAuthKeyFile (ubyte **ppFreeEncodedAuthKey) |
Release an authentication key's memory. More... | |
MOC_EXTERN sbyte4 | SSHC_freeHandle (sbyte4 connectionInstance, sftpcFileHandleDescr **pp_sftpFileHandleDescr) |
Release (free) memory used to store a file/directory descriptor handle. More... | |
MOC_EXTERN MSTATUS | SSHC_generateServerAuthKeyFile (ubyte *pKeyBlob, ubyte4 keyBlobLen, ubyte **ppRetEncodedAuthKey, ubyte4 *pRetEncodedAuthKeyLen) |
Generate an exportable public key for an internal public key BLOB. More... | |
MOC_EXTERN sbyte4 | SSHC_getCookie (sbyte4 connectionInstance, void **pRetCookie) |
Get a connection's cookie containing custom (application-specific) information. More... | |
MOC_EXTERN sbyte4 | SSHC_getFileStat (sbyte4 connectionInstance, ubyte *pGetStatFile, ubyte4 getStatFileLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr) |
Get a file's statistics from an SFTP server. More... | |
MOC_EXTERN sbyte4 | SSHC_init (sbyte4 numClientConnections) |
Initialize NanoSSH client internal structures. More... | |
MOC_EXTERN sbyte4 | SSHC_initiateReKey (sbyte4 connectionInstance, ubyte4 msAllowToComply) |
Initiate an SSH re-key operation. More... | |
MOC_EXTERN sbyte4 | SSHC_lpfRegisterConnection (sbyte4 connectionInstance, ubyte4 *pChannel) |
Register the port number on which to listen for port forwarding messages from the SSH server. More... | |
MOC_EXTERN sbyte4 | SSHC_lpfSendMessage (sbyte4 connectionInstance, ubyte4 channel, sbyte *pBuffer, sbyte4 bufferSize, sbyte4 *pBytesSent) |
Send local port forwarding connection data from SSH client to SSH server. More... | |
MOC_EXTERN sbyte4 | SSHC_lpfStartConnection (sbyte4 connectionInstance, ubyte4 channel, ubyte *pConnectHost, ubyte4 connectPort, ubyte *pSrcHost, ubyte4 srcPort) |
Start a port forwarding session. More... | |
MOC_EXTERN sbyte4 | SSHC_lpfStopConnection (sbyte4 connectionInstance, ubyte4 channel) |
Stop port forwarding through the specified SSH connection. More... | |
MOC_EXTERN sbyte4 | SSHC_mkdir (sbyte4 connectionInstance, ubyte *pNewDirName, ubyte4 newDirNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr, void *pFuture) |
Create a directory on an SFTP server. More... | |
MOC_EXTERN sbyte4 | SSHC_negotiateCloseChannel (sbyte4 connectionInstance, sbyte4 channelNumber) |
Negotiate closing of a channel. More... | |
MOC_EXTERN sbyte4 | SSHC_negotiateConnection (sbyte4 connectionInstance) |
Authenticate a server (which establishes a secure connection). More... | |
MOC_EXTERN sbyte4 | SSHC_negotiatePtyTerminalChannelRequest (sbyte4 connectionInstance) |
Send an SSH PTY command on the specified connection. More... | |
MOC_EXTERN sbyte4 | SSHC_negotiateSession (sbyte4 connectionInstance) |
Negotiate a connection (the client is authenticated by the server). More... | |
MOC_EXTERN sbyte4 | SSHC_negotiateSFTPHello (sbyte4 connectionInstance) |
Start a NanoSSH client SFTP session. More... | |
MOC_EXTERN sbyte4 | SSHC_negotiateShellChannelRequest (sbyte4 connectionInstance) |
Send an SSH shell command on the specified connection. More... | |
MOC_EXTERN sbyte4 | SSHC_negotiateSubsystemSFTPChannelRequest (sbyte4 connectionInstance) |
Send an SSH exec sftp command on the specified connection. More... | |
MOC_EXTERN sbyte4 | SSHC_numBytesTransmitted (sbyte4 connectionInstance, ubyte8 *pRetNumBytes) |
Get the number of bytes sent and received through a given connectionInstance. More... | |
MOC_EXTERN sbyte4 | SSHC_openDirectory (sbyte4 connectionInstance, ubyte *pPath, ubyte4 pathLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr) |
MOC_EXTERN sbyte4 | SSHC_openFile (sbyte4 connectionInstance, ubyte *pFName, ubyte4 pFNameLen, sbyte4 readOrWrite, sftpcFileHandleDescr **pp_retSftpFileHandleDescr) |
Open a file on an SFTP server. More... | |
MOC_EXTERN MSTATUS | SSHC_parsePublicKeyBuffer (ubyte *pKeyFile, ubyte4 keyFileLen, AsymmetricKey *pAsymKey) |
Parses an public key and generates an AsymmetricKey object. More... | |
MOC_EXTERN MSTATUS | SSHC_parseServerAuthKeyFile (ubyte *pKeyFile, ubyte4 keyFileLen, AsymmetricKey *pAsymKey) |
Parses an exportable public key and generates an AsymmetricKey object. More... | |
MOC_EXTERN sbyte4 | SSHC_readDirectory (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte **ppRetFilename, ubyte4 *pRetFilenameLen) |
Get a directory's list of files (using a read directory request). More... | |
MOC_EXTERN sbyte4 | SSHC_readFile (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Read a file on an SFTP server. More... | |
MOC_EXTERN sbyte4 | SSHC_realpath (sbyte4 connectionInstance, ubyte *pRealpath, ubyte4 realpathLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr, ubyte **ppRetRealpath, ubyte4 *pRetRealpathLen) |
Get the fully-qualified directory path of an an SSH Client's virtual directory. More... | |
MOC_EXTERN sbyte4 | SSHC_recvMessage (sbyte4 connectionInstance, sbyte4 *pMessageType, sbyte *pRetMessage, sbyte4 *pNumBytesReceived, ubyte4 timeout) |
Get data from a connected server/client. More... | |
MOC_EXTERN sbyte4 | SSHC_removeFile (sbyte4 connectionInstance, ubyte *pRemoveFileName, ubyte4 removeFileNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr) |
Delete a file from an SFTP server. More... | |
MOC_EXTERN sbyte4 | SSHC_rmdir (sbyte4 connectionInstance, ubyte *pRemoveDirName, ubyte4 removeDirNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr) |
Delete a directory from an SFTP server. More... | |
MOC_EXTERN sbyte4 | SSHC_sendMessage (sbyte4 connectionInstance, ubyte *pBuffer, ubyte4 bufferSize, ubyte4 *pBytesSent) |
Send data to a server. More... | |
MOC_EXTERN sbyte4 | SSHC_setCookie (sbyte4 connectionInstance, void *cookie) |
Save a cookie containing custom information. More... | |
MOC_EXTERN sbyte4 | SSHC_setTerminalTextWindowSize (sbyte4 connectionInstance, ubyte4 width, ubyte4 height) |
Set a terminal window's dimensions. More... | |
MOC_EXTERN void * | SSHC_sftpGetCookie (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get a file's cookie value. More... | |
MOC_EXTERN void | SSHC_sftpGetDirEntryFilePermission (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFilePermission, intBoolean *pRetIsPresent) |
Determine whether a directory's file permission flag is set. More... | |
MOC_EXTERN void | SSHC_sftpGetDirEntryFileSize (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFileSize, intBoolean *pRetIsPresent) |
Get a directory's size (number of bytes). More... | |
MOC_EXTERN void | SSHC_sftpGetDirEntryFileType (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFileType, intBoolean *pRetIsPresent) |
Get a directory's type. More... | |
MOC_EXTERN sbyte4 | SSHC_sftpNumBytesRead (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get the number of bytes read from an open file. More... | |
MOC_EXTERN sbyte4 | SSHC_sftpNumBytesWritten (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get the number of bytes written to an open file. More... | |
MOC_EXTERN sbyte * | SSHC_sftpReadBuffer (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get a pointer to a file's read data buffer. More... | |
MOC_EXTERN sbyte4 | SSHC_sftpReadBufferSize (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get the number of bytes in a file's read buffer. More... | |
MOC_EXTERN sbyte4 | SSHC_sftpReadLocation (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get a file's current read location. More... | |
MOC_EXTERN sbyte4 | SSHC_sftpRequestStatusCode (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get a file's SFTP operation status. More... | |
MOC_EXTERN void | SSHC_sftpSetCookie (sftpcFileHandleDescr *p_sftpFileHandleDescr, void *sftpCookie) |
Set a file's cookie value (custom information). More... | |
MOC_EXTERN sbyte * | SSHC_sftpWriteBuffer (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get a pointer to a file's write data buffer. More... | |
MOC_EXTERN sbyte4 | SSHC_sftpWriteBufferSize (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get the number of bytes in a file's write buffer. More... | |
MOC_EXTERN sbyte4 | SSHC_sftpWriteLocation (sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Get a file's current write location. More... | |
MOC_EXTERN sbyte4 | SSHC_shutdown (void) |
Release memory initialized by SSHC_init(). More... | |
MOC_EXTERN sshClientSettings * | SSHC_sshClientSettings (void) |
Get a pointer to the session's NanoSSH Client settings. More... | |
MSTATUS | SSHC_startRemotePortForwarding (sbyte4 connectionInstance, sbyte *pBindAddr, ubyte4 bindPort, sbyte *pHostAddr, ubyte4 hostPort) |
MOC_EXTERN sbyte4 | SSHC_useThisCipher (sbyte4 connectionInstance, ubyte *pCipher) |
Set an SSH connection's cipher. More... | |
MOC_EXTERN sbyte4 | SSHC_useThisHmac (sbyte4 connectionInstance, ubyte *pHmac) |
Set an SSH connection's HMAC. More... | |
MOC_EXTERN sbyte4 | SSHC_writeFile (sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr) |
Write a file to an SFTP server. More... | |
This header file contains definitions, structures, and function declarations used by NanoSSH client.
(file sizes have changed...)
Whether the following flags are defined determines which enumerations, structures, and function declarations are enabled:
__ENABLE_MOCANA_SSH_FTP_CLIENT__
__ENABLE_MOCANA_SSH_PORT_FORWARDING__
__ENABLE_MOCANA_SSH_AUTH_BANNER__
MOC_EXTERN sbyte4 SSHC_negotiatePtyTerminalChannelRequest | ( | sbyte4 | connectionInstance | ) |
This function sends an SSH PTY
command on the specified connection. To start an interactive or scripted shell with a server, this function must be invoked during negotiation on the specified connection.
To enable this function, the following flag must be defined in moptions.h:
__ENABLE_MOCANA_SSH_CLIENT__
sshc.hconnectionInstance | Connection instance returned from SSHC_connect(). |
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.MOC_EXTERN sbyte4 SSHC_negotiateShellChannelRequest | ( | sbyte4 | connectionInstance | ) |
This function sends an SSH shell command on the specified connection. To start an interactive or scripted shell with a server, this function must be invoked during negotiation on the specified connection.
To enable this function, the following flag must be defined in moptions.h:
__ENABLE_MOCANA_SSH_CLIENT__
connectionInstance | Connection instance returned from SSHC_connect(). |
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.MOC_EXTERN sbyte4 SSHC_recvMessage | ( | sbyte4 | connectionInstance, |
sbyte4 * | pMessageType, | ||
sbyte * | pRetMessage, | ||
sbyte4 * | pNumBytesReceived, | ||
ubyte4 | timeout | ||
) |
This function retrieves data from a connected server/client. It should not be called until an SSH connection is established between the client and server.
To enable this function, the following flag must be defined in moptions.h:
__ENABLE_MOCANA_SSH_CLIENT__
connectionInstance | Connection instance returned from SSHC_connect(). |
pMessageType | Pointer to sshcSessionTypes enum buffer (see sshc.h) in which to write the message type, according to the message read operation. |
pRetMessage | Pointer to the buffer in which to write the received data. |
pNumBytesReceived | On return, pointer to the number of bytes received. |
timeout | Number of milliseconds the client will wait to receive the message. To specify no timeout (an infinite wait), set this parameter to 0. |
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.MOC_EXTERN sbyte4 SSHC_sendMessage | ( | sbyte4 | connectionInstance, |
ubyte * | pBuffer, | ||
ubyte4 | bufferSize, | ||
ubyte4 * | pBytesSent | ||
) |
This function sends data to a server.
To enable this function, the following flag must be defined in moptions.h:
__ENABLE_MOCANA_SSH_CLIENT__
connectionInstance | Connection instance returned from SSHC_connect(). |
pBuffer | Pointer to the buffer containing the data to send. |
bufferSize | Number of bytes in the send data buffer (pBuffer ). |
pBytesSent | On return, pointer to number of bytes successfully sent. |
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.MOC_EXTERN sbyte4 SSHC_setTerminalTextWindowSize | ( | sbyte4 | connectionInstance, |
ubyte4 | width, | ||
ubyte4 | height | ||
) |
This function sets (resizes from the default size of 80 x 24) a client terminal window's dimensions. This function is necessary when using the SSH client as an interactive shell. (For automated SSH client applications, this function is unnecessary.)
To enable this function, the following flag must be defined in moptions.h:
__ENABLE_MOCANA_SSH_CLIENT__
connectionInstance | Connection instance returned from SSHC_connect(). |
width | Terminal window's width, in characters. |
height | Terminal window's height in characters. |
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.