Helper functions for SSH secure shell server. More...
#include "ssh/ssh.h"
#include "ssh/ssh_request.h"
#include "ssh/ssh_misc.h"
#include "shell/shell_server.h"
#include "shell/shell_server_pty.h"
#include "shell/shell_server_misc.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL SHELL_TRACE_LEVEL |
Functions | |
void | shellServerTick (ShellServerContext *context) |
Handle periodic operations. More... | |
error_t | shellServerChannelRequestCallback (SshChannel *channel, const SshString *type, const uint8_t *data, size_t length, void *param) |
SSH channel request callback. More... | |
ShellServerSession * | shellServerFindSession (ShellServerContext *context, SshChannel *channel) |
Find the shell session that matches a given SSH channel. More... | |
ShellServerSession * | shellServerOpenSession (ShellServerContext *context, SshChannel *channel) |
Open a new shell session. More... | |
void | shellServerCloseSession (ShellServerSession *session) |
Close a shell session. More... | |
error_t | shellServerParseTermModes (ShellServerSession *session, const uint8_t *termModes, size_t length) |
Parse encoded terminal modes. More... | |
error_t | shellServerProcessCommandLine (ShellServerSession *session, char_t *commandLine) |
Command line processing. More... | |
void | shellServerAddCommandLine (ShellServerSession *session, const char_t *commandLine) |
Add command line to history. More... | |
error_t | shellServerGetPrevCommandLine (ShellServerSession *session, const char_t **commandLine, size_t *length) |
Extract previous command line from history. More... | |
error_t | shellServerGetNextCommandLine (ShellServerSession *session, const char_t **commandLine, size_t *length) |
Extract next command line from history. More... | |
error_t | shellServerGetFirstCommandLine (ShellServerSession *session, const char_t **commandLine, size_t *length) |
Extract first command line from history. More... | |
error_t | shellServerGetLastCommandLine (ShellServerSession *session, const char_t **commandLine, size_t *length) |
Extract last command line from history. More... | |
Detailed Description
Helper functions for 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_misc.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL SHELL_TRACE_LEVEL |
Definition at line 32 of file shell_server_misc.c.
Function Documentation
◆ shellServerAddCommandLine()
void shellServerAddCommandLine | ( | ShellServerSession * | session, |
const char_t * | commandLine | ||
) |
Add command line to history.
- Parameters
-
[in] session Handle referencing an shell session [in] commandLine NULL-terminated string that contains the command line
Definition at line 620 of file shell_server_misc.c.
◆ shellServerChannelRequestCallback()
error_t shellServerChannelRequestCallback | ( | SshChannel * | channel, |
const SshString * | type, | ||
const uint8_t * | data, | ||
size_t | length, | ||
void * | param | ||
) |
SSH channel request callback.
- Parameters
-
[in] channel Handle referencing an SSH channel [in] type Request type [in] data Request-specific data [in] length Length of the request-specific data, in bytes [in] param Pointer to the shell server context
- Returns
- Error code
Definition at line 67 of file shell_server_misc.c.
◆ shellServerCloseSession()
void shellServerCloseSession | ( | ShellServerSession * | session | ) |
Close a shell session.
- Parameters
-
[in] session Handle referencing a shell session
Definition at line 500 of file shell_server_misc.c.
◆ shellServerFindSession()
ShellServerSession* shellServerFindSession | ( | ShellServerContext * | context, |
SshChannel * | channel | ||
) |
Find the shell session that matches a given SSH channel.
- Parameters
-
[in] context Pointer to the shell server context [in] channel Handle referencing an SSH channel
- Returns
- Pointer to the matching shell session
Definition at line 381 of file shell_server_misc.c.
◆ shellServerGetFirstCommandLine()
error_t shellServerGetFirstCommandLine | ( | ShellServerSession * | session, |
const char_t ** | commandLine, | ||
size_t * | length | ||
) |
Extract first command line from history.
- Parameters
-
[in] session Handle referencing an shell session [out] commandLine Pointer to the first command line [out] length Length of the command line
- Returns
- error code
Definition at line 833 of file shell_server_misc.c.
◆ shellServerGetLastCommandLine()
error_t shellServerGetLastCommandLine | ( | ShellServerSession * | session, |
const char_t ** | commandLine, | ||
size_t * | length | ||
) |
Extract last command line from history.
- Parameters
-
[in] session Handle referencing an shell session [out] commandLine Pointer to the last command line [out] length Length of the command line
- Returns
- error code
Definition at line 875 of file shell_server_misc.c.
◆ shellServerGetNextCommandLine()
error_t shellServerGetNextCommandLine | ( | ShellServerSession * | session, |
const char_t ** | commandLine, | ||
size_t * | length | ||
) |
Extract next command line from history.
- Parameters
-
[in] session Handle referencing an shell session [out] commandLine Pointer to the next command line [out] length Length of the command line
- Returns
- error code
Definition at line 775 of file shell_server_misc.c.
◆ shellServerGetPrevCommandLine()
error_t shellServerGetPrevCommandLine | ( | ShellServerSession * | session, |
const char_t ** | commandLine, | ||
size_t * | length | ||
) |
Extract previous command line from history.
- Parameters
-
[in] session Handle referencing an shell session [out] commandLine Pointer to the previous command line [out] length Length of the command line
- Returns
- error code
Definition at line 723 of file shell_server_misc.c.
◆ shellServerOpenSession()
ShellServerSession* shellServerOpenSession | ( | ShellServerContext * | context, |
SshChannel * | channel | ||
) |
Open a new shell session.
- Parameters
-
[in] context Pointer to the shell server context [in] channel Handle referencing an SSH channel
- Returns
- Pointer to the newly created shell session
Definition at line 416 of file shell_server_misc.c.
◆ shellServerParseTermModes()
error_t shellServerParseTermModes | ( | ShellServerSession * | session, |
const uint8_t * | termModes, | ||
size_t | length | ||
) |
Parse encoded terminal modes.
- Parameters
-
[in] session Handle referencing an shell session [in] termModes Encoded terminal modes [in] length Length of the encoded terminal modes, in bytes
- Returns
- Error code
Definition at line 522 of file shell_server_misc.c.
◆ shellServerProcessCommandLine()
error_t shellServerProcessCommandLine | ( | ShellServerSession * | session, |
char_t * | commandLine | ||
) |
Command line processing.
- Parameters
-
[in] session Handle referencing an shell session [in] commandLine NULL-terminated string that contains the command line
- Returns
- error code
Definition at line 588 of file shell_server_misc.c.
◆ shellServerTick()
void shellServerTick | ( | ShellServerContext * | context | ) |
Handle periodic operations.
- Parameters
-
[in] context Pointer to the shell server context
Definition at line 52 of file shell_server_misc.c.