shell_server_misc.h File Reference

Helper functions for SSH secure shell server. More...

Go to the source code of this file.

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...
 
ShellServerSessionshellServerFindSession (ShellServerContext *context, SshChannel *channel)
 Find the shell session that matches a given SSH channel. More...
 
ShellServerSessionshellServerOpenSession (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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file shell_server_misc.h.

Function Documentation

◆ shellServerAddCommandLine()

void shellServerAddCommandLine ( ShellServerSession session,
const char_t commandLine 
)

Add command line to history.

Parameters
[in]sessionHandle referencing an shell session
[in]commandLineNULL-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]channelHandle referencing an SSH channel
[in]typeRequest type
[in]dataRequest-specific data
[in]lengthLength of the request-specific data, in bytes
[in]paramPointer 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]sessionHandle 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]contextPointer to the shell server context
[in]channelHandle 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]sessionHandle referencing an shell session
[out]commandLinePointer to the first command line
[out]lengthLength 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]sessionHandle referencing an shell session
[out]commandLinePointer to the last command line
[out]lengthLength 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]sessionHandle referencing an shell session
[out]commandLinePointer to the next command line
[out]lengthLength 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]sessionHandle referencing an shell session
[out]commandLinePointer to the previous command line
[out]lengthLength 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]contextPointer to the shell server context
[in]channelHandle 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]sessionHandle referencing an shell session
[in]termModesEncoded terminal modes
[in]lengthLength 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]sessionHandle referencing an shell session
[in]commandLineNULL-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]contextPointer to the shell server context

Definition at line 52 of file shell_server_misc.c.