SSH secure shell server. More...
#include "ssh/ssh_server.h"
Go to the source code of this file.
Data Structures | |
struct | ShellServerSettings |
Shell server settings. More... | |
struct | _ShellServerSession |
Shell session. More... | |
struct | _ShellServerContext |
shell server context More... | |
Macros | |
#define | SHELL_SERVER_SUPPORT DISABLED |
#define | SHELL_SERVER_STACK_SIZE 650 |
#define | SHELL_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL |
#define | SHELL_SERVER_MAX_SESSIONS 10 |
#define | SHELL_SERVER_TICK_INTERVAL 1000 |
#define | SHELL_SERVER_BUFFER_SIZE 256 |
#define | SHELL_SERVER_HISTORY_SUPPORT ENABLED |
#define | SHELL_SERVER_HISTORY_SIZE 256 |
#define | SHELL_SERVER_MAX_PROMPT_LEN 64 |
#define | SHELL_SERVER_DEFAULT_TERM_WIDTH 80 |
#define | SHELL_SERVER_DEFAULT_TERM_HEIGHT 60 |
#define | SHELL_SERVER_MAX_ESC_SEQ_LEN 7 |
#define | ShellServerContext struct _ShellServerContext |
#define | ShellServerSession struct _ShellServerSession |
Typedefs | |
typedef ShellAccessStatus(* | ShellServerCheckUserCallback) (ShellServerSession *session, const char_t *user) |
User verification callback function. More... | |
typedef error_t(* | ShellServerCommandLineCallback) (ShellServerSession *session, char_t *commandLine) |
Command line processing callback function. More... | |
typedef void(* | ShellServerCloseCallback) (ShellServerSession *session, const char_t *user) |
Session closing callback function. More... | |
Enumerations | |
enum | ShellAccessStatus { SHELL_ACCESS_DENIED = 0, SHELL_ACCESS_ALLOWED = 1 } |
Access status. More... | |
enum | ShellServerSessionState { SHELL_SERVER_SESSION_STATE_CLOSED = 0, SHELL_SERVER_SESSION_STATE_INIT = 1, SHELL_SERVER_SESSION_STATE_OPEN = 2, SHELL_SERVER_SESSION_STATE_EXEC = 3 } |
Shell session state. More... | |
Functions | |
void | shellServerGetDefaultSettings (ShellServerSettings *settings) |
Initialize settings with default values. More... | |
error_t | shellServerInit (ShellServerContext *context, const ShellServerSettings *settings) |
Initialize shell server context. More... | |
error_t | shellServerStart (ShellServerContext *context) |
Start shell server. More... | |
error_t | shellServerSetBanner (ShellServerSession *session, const char_t *banner) |
Set welcome banner. More... | |
error_t | shellServerSetPrompt (ShellServerSession *session, const char_t *prompt) |
Set shell prompt. More... | |
error_t | shellServerSetTimeout (ShellServerSession *session, systime_t timeout) |
Set timeout for read/write operations. More... | |
error_t | shellServerWriteStream (ShellServerSession *session, const void *data, size_t length, size_t *written, uint_t flags) |
Write to stdout stream. More... | |
error_t | shellServerReadStream (ShellServerSession *session, void *data, size_t size, size_t *received, uint_t flags) |
Read from stdin stream. More... | |
error_t | shellServerSaveHistory (ShellServerSession *session, char_t *history, size_t size, size_t *length) |
Save command history. More... | |
error_t | shellServerRestoreHistory (ShellServerSession *session, const char_t *history, size_t length) |
Restore command history. More... | |
error_t | shellServerClearHistory (ShellServerSession *session) |
Clear command history. More... | |
void | shellServerTask (void *param) |
Shell server task. More... | |
Detailed Description
SSH secure shell server.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2019-2024 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.4.4
Definition in file shell_server.h.
Macro Definition Documentation
◆ SHELL_SERVER_BUFFER_SIZE
#define SHELL_SERVER_BUFFER_SIZE 256 |
Definition at line 72 of file shell_server.h.
◆ SHELL_SERVER_DEFAULT_TERM_HEIGHT
#define SHELL_SERVER_DEFAULT_TERM_HEIGHT 60 |
Definition at line 107 of file shell_server.h.
◆ SHELL_SERVER_DEFAULT_TERM_WIDTH
#define SHELL_SERVER_DEFAULT_TERM_WIDTH 80 |
Definition at line 100 of file shell_server.h.
◆ SHELL_SERVER_HISTORY_SIZE
#define SHELL_SERVER_HISTORY_SIZE 256 |
Definition at line 86 of file shell_server.h.
◆ SHELL_SERVER_HISTORY_SUPPORT
#define SHELL_SERVER_HISTORY_SUPPORT ENABLED |
Definition at line 79 of file shell_server.h.
◆ SHELL_SERVER_MAX_ESC_SEQ_LEN
#define SHELL_SERVER_MAX_ESC_SEQ_LEN 7 |
Definition at line 113 of file shell_server.h.
◆ SHELL_SERVER_MAX_PROMPT_LEN
#define SHELL_SERVER_MAX_PROMPT_LEN 64 |
Definition at line 93 of file shell_server.h.
◆ SHELL_SERVER_MAX_SESSIONS
#define SHELL_SERVER_MAX_SESSIONS 10 |
Definition at line 58 of file shell_server.h.
◆ SHELL_SERVER_PRIORITY
#define SHELL_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL |
Definition at line 53 of file shell_server.h.
◆ SHELL_SERVER_STACK_SIZE
#define SHELL_SERVER_STACK_SIZE 650 |
Definition at line 46 of file shell_server.h.
◆ SHELL_SERVER_SUPPORT
#define SHELL_SERVER_SUPPORT DISABLED |
Definition at line 39 of file shell_server.h.
◆ SHELL_SERVER_TICK_INTERVAL
#define SHELL_SERVER_TICK_INTERVAL 1000 |
Definition at line 65 of file shell_server.h.
◆ ShellServerContext
#define ShellServerContext struct _ShellServerContext |
Definition at line 117 of file shell_server.h.
◆ ShellServerSession
#define ShellServerSession struct _ShellServerSession |
Definition at line 121 of file shell_server.h.
Typedef Documentation
◆ ShellServerCheckUserCallback
typedef ShellAccessStatus(* ShellServerCheckUserCallback) (ShellServerSession *session, const char_t *user) |
User verification callback function.
Definition at line 157 of file shell_server.h.
◆ ShellServerCloseCallback
typedef void(* ShellServerCloseCallback) (ShellServerSession *session, const char_t *user) |
Session closing callback function.
Definition at line 173 of file shell_server.h.
◆ ShellServerCommandLineCallback
typedef error_t(* ShellServerCommandLineCallback) (ShellServerSession *session, char_t *commandLine) |
Command line processing callback function.
Definition at line 165 of file shell_server.h.
Enumeration Type Documentation
◆ ShellAccessStatus
enum ShellAccessStatus |
Access status.
Enumerator | |
---|---|
SHELL_ACCESS_DENIED | |
SHELL_ACCESS_ALLOWED |
Definition at line 133 of file shell_server.h.
◆ ShellServerSessionState
Shell session state.
Enumerator | |
---|---|
SHELL_SERVER_SESSION_STATE_CLOSED | |
SHELL_SERVER_SESSION_STATE_INIT | |
SHELL_SERVER_SESSION_STATE_OPEN | |
SHELL_SERVER_SESSION_STATE_EXEC |
Definition at line 144 of file shell_server.h.
Function Documentation
◆ shellServerClearHistory()
error_t shellServerClearHistory | ( | ShellServerSession * | session | ) |
Clear command history.
- Parameters
-
[in] session Handle referencing a shell session
- Returns
- Error code
Definition at line 469 of file shell_server.c.
◆ shellServerGetDefaultSettings()
void shellServerGetDefaultSettings | ( | ShellServerSettings * | settings | ) |
Initialize settings with default values.
- Parameters
-
[out] settings Structure that contains shell server settings
Definition at line 50 of file shell_server.c.
◆ shellServerInit()
error_t shellServerInit | ( | ShellServerContext * | context, |
const ShellServerSettings * | settings | ||
) |
Initialize shell server context.
- Parameters
-
[in] context Pointer to the shell server context [in] settings Shell server specific settings
- Returns
- Error code
Definition at line 86 of file shell_server.c.
◆ shellServerReadStream()
error_t shellServerReadStream | ( | ShellServerSession * | session, |
void * | data, | ||
size_t | size, | ||
size_t * | received, | ||
uint_t | flags | ||
) |
Read from stdin stream.
- Parameters
-
[in] session Handle referencing a shell session [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 334 of file shell_server.c.
◆ shellServerRestoreHistory()
error_t shellServerRestoreHistory | ( | ShellServerSession * | session, |
const char_t * | history, | ||
size_t | length | ||
) |
Restore command history.
- Parameters
-
[in] session Handle referencing a shell session [in] history Pointer to the buffer that contains the command history [in] length Length of the command history, in bytes
- Returns
- Error code
Definition at line 414 of file shell_server.c.
◆ shellServerSaveHistory()
error_t shellServerSaveHistory | ( | ShellServerSession * | session, |
char_t * | history, | ||
size_t | size, | ||
size_t * | length | ||
) |
Save command history.
- Parameters
-
[in] session Handle referencing a shell session [out] history Output buffer where to store the command history [in] size Size of the buffer, in bytes [out] length Actual length of the command history, in bytes
- Returns
- Error code
Definition at line 365 of file shell_server.c.
◆ shellServerSetBanner()
error_t shellServerSetBanner | ( | ShellServerSession * | session, |
const char_t * | banner | ||
) |
Set welcome banner.
- Parameters
-
[in] session Handle referencing a shell session [in] banner NULL-terminated string containing the banner message
- Returns
- Error code
Definition at line 208 of file shell_server.c.
◆ shellServerSetPrompt()
error_t shellServerSetPrompt | ( | ShellServerSession * | session, |
const char_t * | prompt | ||
) |
Set shell prompt.
- Parameters
-
[in] session Handle referencing a shell session [in] prompt NULL-terminated string containing the prompt to be used
- Returns
- Error code
Definition at line 243 of file shell_server.c.
◆ shellServerSetTimeout()
error_t shellServerSetTimeout | ( | ShellServerSession * | session, |
systime_t | timeout | ||
) |
Set timeout for read/write operations.
- Parameters
-
[in] session Handle referencing a shell session [in] timeout Maximum time to wait
- Returns
- Error code
Definition at line 271 of file shell_server.c.
◆ shellServerStart()
error_t shellServerStart | ( | ShellServerContext * | context | ) |
Start shell server.
- Parameters
-
[in] context Pointer to the shell server context
- Returns
- Error code
Definition at line 157 of file shell_server.c.
◆ shellServerTask()
void shellServerTask | ( | void * | param | ) |
Shell server task.
- Parameters
-
[in] param Pointer to the shell session
Definition at line 494 of file shell_server.c.
◆ shellServerWriteStream()
error_t shellServerWriteStream | ( | ShellServerSession * | session, |
const void * | data, | ||
size_t | length, | ||
size_t * | written, | ||
uint_t | flags | ||
) |
Write to stdout stream.
- Parameters
-
[in] session Handle referencing a shell session [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 302 of file shell_server.c.