SSH secure shell client. More...
#include "ssh/ssh.h"Go to the source code of this file.
| Data Structures | |
| struct | _ShellClientContext | 
| Shell client context.  More... | |
| Macros | |
| #define | SHELL_CLIENT_SUPPORT DISABLED | 
| #define | SHELL_CLIENT_DEFAULT_TIMEOUT 20000 | 
| #define | SHELL_CLIENT_BUFFER_SIZE 512 | 
| #define | ShellClientContext struct _ShellClientContext | 
| Typedefs | |
| typedef error_t(* | ShellClientSshInitCallback) (ShellClientContext *context, SshContext *sshContext) | 
| SSH initialization callback function.  More... | |
| Enumerations | |
| enum | ShellClientState { SHELL_CLIENT_STATE_DISCONNECTED = 0, SHELL_CLIENT_STATE_CONNECTING_1 = 1, SHELL_CLIENT_STATE_CONNECTING_2 = 2, SHELL_CLIENT_STATE_CONNECTED = 3, SHELL_CLIENT_STATE_CHANNEL_INIT = 4, SHELL_CLIENT_STATE_CHANNEL_OPEN = 5, SHELL_CLIENT_STATE_CHANNEL_REQUEST = 6, SHELL_CLIENT_STATE_CHANNEL_REPLY = 7, SHELL_CLIENT_STATE_CHANNEL_DATA = 8, SHELL_CLIENT_STATE_CHANNEL_CLOSE = 9, SHELL_CLIENT_STATE_DISCONNECTING_1 = 10, SHELL_CLIENT_STATE_DISCONNECTING_2 = 11 } | 
| Shell client state.  More... | |
| Functions | |
| error_t | shellClientInit (ShellClientContext *context) | 
| Initialize shell client context.  More... | |
| error_t | shellClientRegisterSshInitCallback (ShellClientContext *context, ShellClientSshInitCallback callback) | 
| Register SSH initialization callback function.  More... | |
| error_t | shellClientSetTimeout (ShellClientContext *context, systime_t timeout) | 
| Set communication timeout.  More... | |
| error_t | shellClientBindToInterface (ShellClientContext *context, NetInterface *interface) | 
| Bind the shell client to a particular network interface.  More... | |
| error_t | shellClientConnect (ShellClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort) | 
| Establish a connection with the specified SSH server.  More... | |
| error_t | shellClientFormatCommand (ShellClientContext *context, const char_t *command,...) | 
| Format a command line.  More... | |
| error_t | shellClientExecuteCommand (ShellClientContext *context, const char_t *command) | 
| Execute a command line.  More... | |
| error_t | shellClientWriteStream (ShellClientContext *context, const void *data, size_t length, size_t *written, uint_t flags) | 
| Write to stdin stream.  More... | |
| error_t | shellClientFlushStream (ShellClientContext *context) | 
| Flush stdin stream.  More... | |
| error_t | shellClientReadStream (ShellClientContext *context, void *data, size_t size, size_t *received, uint_t flags) | 
| Read from stdout stream.  More... | |
| error_t | shellClientCloseStream (ShellClientContext *context) | 
| Close stream.  More... | |
| uint32_t | shellClientGetExitStatus (ShellClientContext *context) | 
| Retrieve exit status.  More... | |
| error_t | shellClientDisconnect (ShellClientContext *context) | 
| Gracefully disconnect from the SSH server.  More... | |
| error_t | shellClientClose (ShellClientContext *context) | 
| Close the connection with the SSH server.  More... | |
| void | shellClientDeinit (ShellClientContext *context) | 
| Release shell client context.  More... | |
Detailed Description
SSH secure shell client.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2019-2025 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneSSH Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.5.4
Definition in file shell_client.h.
Macro Definition Documentation
◆ SHELL_CLIENT_BUFFER_SIZE
| #define SHELL_CLIENT_BUFFER_SIZE 512 | 
Definition at line 53 of file shell_client.h.
◆ SHELL_CLIENT_DEFAULT_TIMEOUT
| #define SHELL_CLIENT_DEFAULT_TIMEOUT 20000 | 
Definition at line 46 of file shell_client.h.
◆ SHELL_CLIENT_SUPPORT
| #define SHELL_CLIENT_SUPPORT DISABLED | 
Definition at line 39 of file shell_client.h.
◆ ShellClientContext
| #define ShellClientContext struct _ShellClientContext | 
Definition at line 60 of file shell_client.h.
Typedef Documentation
◆ ShellClientSshInitCallback
| typedef error_t(* ShellClientSshInitCallback) (ShellClientContext *context, SshContext *sshContext) | 
SSH initialization callback function.
Definition at line 93 of file shell_client.h.
Enumeration Type Documentation
◆ ShellClientState
| enum ShellClientState | 
Shell client state.
Definition at line 72 of file shell_client.h.
Function Documentation
◆ shellClientBindToInterface()
| error_t shellClientBindToInterface | ( | ShellClientContext * | context, | 
| NetInterface * | interface | ||
| ) | 
Bind the shell client to a particular network interface.
- Parameters
- 
  [in] context Pointer to the shell client context [in] interface Network interface to be used 
- Returns
- Error code
Definition at line 123 of file shell_client.c.
◆ shellClientClose()
| error_t shellClientClose | ( | ShellClientContext * | context | ) | 
Close the connection with the SSH server.
- Parameters
- 
  [in] context Pointer to the shell client context 
- Returns
- Error code
Definition at line 964 of file shell_client.c.
◆ shellClientCloseStream()
| error_t shellClientCloseStream | ( | ShellClientContext * | context | ) | 
Close stream.
- Parameters
- 
  [in] context Pointer to the shell client context 
- Returns
- Error code
Definition at line 737 of file shell_client.c.
◆ shellClientConnect()
| error_t shellClientConnect | ( | ShellClientContext * | context, | 
| const IpAddr * | serverIpAddr, | ||
| uint16_t | serverPort | ||
| ) | 
Establish a connection with the specified SSH server.
- Parameters
- 
  [in] context Pointer to the shell client context [in] serverIpAddr IP address of the SSH server to connect to [in] serverPort Port number 
- Returns
- Error code
Definition at line 146 of file shell_client.c.
◆ shellClientDeinit()
| void shellClientDeinit | ( | ShellClientContext * | context | ) | 
Release shell client context.
- Parameters
- 
  [in] context Pointer to the shell client context 
Definition at line 985 of file shell_client.c.
◆ shellClientDisconnect()
| error_t shellClientDisconnect | ( | ShellClientContext * | context | ) | 
Gracefully disconnect from the SSH server.
- Parameters
- 
  [in] context Pointer to the shell client context 
- Returns
- Error code
Definition at line 865 of file shell_client.c.
◆ shellClientExecuteCommand()
| error_t shellClientExecuteCommand | ( | ShellClientContext * | context, | 
| const char_t * | command | ||
| ) | 
Execute a command line.
- Parameters
- 
  [in] context Pointer to the shell client context [in] command NULL-terminating string containing the command line 
- Returns
- Error code
Definition at line 317 of file shell_client.c.
◆ shellClientFlushStream()
| error_t shellClientFlushStream | ( | ShellClientContext * | context | ) | 
Flush stdin stream.
- Parameters
- 
  [in] context Pointer to the shell client context 
- Returns
- Error code
Definition at line 612 of file shell_client.c.
◆ shellClientFormatCommand()
| error_t shellClientFormatCommand | ( | ShellClientContext * | context, | 
| const char_t * | command, | ||
| ... | |||
| ) | 
Format a command line.
- Parameters
- 
  [in] context Pointer to the shell client context [in] command NULL-terminating string containing the command line [in] ... Optional arguments 
- Returns
- Error code
Definition at line 238 of file shell_client.c.
◆ shellClientGetExitStatus()
| uint32_t shellClientGetExitStatus | ( | ShellClientContext * | context | ) | 
Retrieve exit status.
- Parameters
- 
  [in] context Pointer to the shell client context 
- Returns
- Exit status
Definition at line 838 of file shell_client.c.
◆ shellClientInit()
| error_t shellClientInit | ( | ShellClientContext * | context | ) | 
Initialize shell client context.
- Parameters
- 
  [in] context Pointer to the shell client context 
- Returns
- Error code
Definition at line 54 of file shell_client.c.
◆ shellClientReadStream()
| error_t shellClientReadStream | ( | ShellClientContext * | context, | 
| void * | data, | ||
| size_t | size, | ||
| size_t * | received, | ||
| uint_t | flags | ||
| ) | 
Read from stdout stream.
- Parameters
- 
  [in] context Pointer to the shell client context [out] data Buffer where to store the incoming data [in] size Maximum number of bytes that can be read [out] received Actual number of bytes that have been read [in] flags Set of flags that influences the behavior of this function 
- Returns
- Error code
Definition at line 650 of file shell_client.c.
◆ shellClientRegisterSshInitCallback()
| error_t shellClientRegisterSshInitCallback | ( | ShellClientContext * | context, | 
| ShellClientSshInitCallback | callback | ||
| ) | 
Register SSH initialization callback function.
- Parameters
- 
  [in] context Pointer to the shell client context [in] callback SSH initialization callback function 
- Returns
- Error code
Definition at line 80 of file shell_client.c.
◆ shellClientSetTimeout()
| error_t shellClientSetTimeout | ( | ShellClientContext * | context, | 
| systime_t | timeout | ||
| ) | 
Set communication timeout.
- Parameters
- 
  [in] context Pointer to the shell client context [in] timeout Timeout value, in milliseconds 
- Returns
- Error code
Definition at line 102 of file shell_client.c.
◆ shellClientWriteStream()
| error_t shellClientWriteStream | ( | ShellClientContext * | context, | 
| const void * | data, | ||
| size_t | length, | ||
| size_t * | written, | ||
| uint_t | flags | ||
| ) | 
Write to stdin stream.
- Parameters
- 
  [in] context Pointer to the shell client context [in] data Pointer to a buffer containing the data to be written [in] length Number of data bytes to write [in] written Number of bytes that have been written (optional parameter) [in] flags Set of flags that influences the behavior of this function 
- Returns
- Error code
Definition at line 520 of file shell_client.c.
