shell_server.c File Reference

SSH secure shell server. More...

#include "ssh/ssh.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 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.

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

Definition in file shell_server.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SHELL_TRACE_LEVEL

Definition at line 32 of file shell_server.c.

Function Documentation

◆ shellServerClearHistory()

error_t shellServerClearHistory ( ShellServerSession session)

Clear command history.

Parameters
[in]sessionHandle 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]settingsStructure 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]contextPointer to the shell server context
[in]settingsShell 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]sessionHandle referencing a shell session
[out]dataBuffer where to store the incoming data
[in]sizeMaximum number of bytes that can be read
[out]receivedActual number of bytes that have been read
[in]flagsSet 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]sessionHandle referencing a shell session
[in]historyPointer to the buffer that contains the command history
[in]lengthLength 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]sessionHandle referencing a shell session
[out]historyOutput buffer where to store the command history
[in]sizeSize of the buffer, in bytes
[out]lengthActual 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]sessionHandle referencing a shell session
[in]bannerNULL-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]sessionHandle referencing a shell session
[in]promptNULL-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]sessionHandle referencing a shell session
[in]timeoutMaximum 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]contextPointer 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]paramPointer 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]sessionHandle referencing a shell session
[in]dataPointer to a buffer containing the data to be written
[in]lengthNumber of data bytes to write
[in]writtenNumber of bytes that have been written (optional parameter)
[in]flagsSet of flags that influences the behavior of this function
Returns
Error code

Definition at line 302 of file shell_server.c.