ssh_request.c File Reference

Global request and channel request handling. More...

#include "ssh/ssh.h"
#include "ssh/ssh_request.h"
#include "ssh/ssh_channel.h"
#include "ssh/ssh_packet.h"
#include "ssh/ssh_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   SSH_TRACE_LEVEL
 

Functions

error_t sshSendGlobalRequest (SshConnection *connection, const char_t *requestName, const void *requestParams, bool_t wantReply)
 Send SSH_MSG_GLOBAL_REQUEST message. More...
 
error_t sshSendRequestSuccess (SshConnection *connection)
 Send SSH_MSG_REQUEST_SUCCESS message. More...
 
error_t sshSendRequestFailure (SshConnection *connection)
 Send SSH_MSG_REQUEST_FAILURE message. More...
 
error_t sshSendChannelRequest (SshChannel *channel, const char_t *requestType, const void *requestParams, bool_t wantReply)
 Send SSH_MSG_CHANNEL_REQUEST message. More...
 
error_t sshSendChannelSuccess (SshChannel *channel)
 Send SSH_MSG_CHANNEL_SUCCESS message. More...
 
error_t sshSendChannelFailure (SshChannel *channel)
 Send SSH_MSG_CHANNEL_FAILURE message. More...
 
error_t sshFormatGlobalRequest (SshConnection *connection, const char_t *requestName, const void *requestParams, bool_t wantReply, uint8_t *p, size_t *length)
 Format SSH_MSG_GLOBAL_REQUEST message. More...
 
error_t sshFormatTcpIpFwdParams (const SshTcpIpFwdParams *params, uint8_t *p, size_t *written)
 Format "tcpip-forward" global request parameters. More...
 
error_t sshFormatCancelTcpIpFwdParams (const SshCancelTcpIpFwdParams *params, uint8_t *p, size_t *written)
 Format "cancel-tcpip-forward" global request parameters. More...
 
error_t sshFormatElevationParams (const SshElevationParams *params, uint8_t *p, size_t *written)
 Format "elevation" global request parameters. More...
 
error_t sshFormatRequestSuccess (SshConnection *connection, uint8_t *p, size_t *length)
 Format SSH_MSG_REQUEST_SUCCESS message. More...
 
error_t sshFormatRequestFailure (SshConnection *connection, uint8_t *p, size_t *length)
 Format SSH_MSG_REQUEST_FAILURE message. More...
 
error_t sshFormatChannelRequest (SshChannel *channel, const char_t *requestType, const void *requestParams, bool_t wantReply, uint8_t *p, size_t *length)
 Format SSH_MSG_CHANNEL_REQUEST message. More...
 
error_t sshFormatPtyReqParams (const SshPtyReqParams *params, uint8_t *p, size_t *written)
 Format "pty-req" channel request parameters. More...
 
error_t sshFormatExecParams (const SshExecParams *params, uint8_t *p, size_t *written)
 Format "exec" channel request parameters. More...
 
error_t sshFormatSubsystemParams (const SshSubsystemParams *params, uint8_t *p, size_t *written)
 Format "subsystem" channel request parameters. More...
 
error_t sshFormatWindowChangeParams (const SshWindowChangeParams *params, uint8_t *p, size_t *written)
 Format "window-change" channel request parameters. More...
 
error_t sshFormatSignalParams (const SshSignalParams *params, uint8_t *p, size_t *written)
 Format "signal" channel request parameters. More...
 
error_t sshFormatExitStatusParams (const SshExitStatusParams *params, uint8_t *p, size_t *written)
 Format "exit-status" channel request parameters. More...
 
error_t sshFormatBreakParams (const SshBreakParams *params, uint8_t *p, size_t *written)
 Format "break" channel request parameters. More...
 
error_t sshFormatChannelSuccess (SshChannel *channel, uint8_t *p, size_t *length)
 Format SSH_MSG_CHANNEL_SUCCESS message. More...
 
error_t sshFormatChannelFailure (SshChannel *channel, uint8_t *p, size_t *length)
 Format SSH_MSG_CHANNEL_FAILURE message. More...
 
error_t sshParseGlobalRequest (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_GLOBAL_REQUEST message. More...
 
error_t sshParseTcpIpFwdParams (const uint8_t *p, size_t length, SshTcpIpFwdParams *params)
 Parse "tcpip-forward" global request parameters. More...
 
error_t sshParseCancelTcpIpFwdParams (const uint8_t *p, size_t length, SshCancelTcpIpFwdParams *params)
 Parse "cancel-tcpip-forward" global request parameters. More...
 
error_t sshParseElevationParams (const uint8_t *p, size_t length, SshElevationParams *params)
 Parse "elevation" global request parameters. More...
 
error_t sshParseRequestSuccess (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_REQUEST_SUCCESS message. More...
 
error_t sshParseRequestFailure (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_REQUEST_FAILURE message. More...
 
error_t sshParseChannelRequest (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_CHANNEL_REQUEST message. More...
 
error_t sshParsePtyReqParams (const uint8_t *p, size_t length, SshPtyReqParams *params)
 Parse "pty-req" channel request parameters. More...
 
error_t sshParseExecParams (const uint8_t *p, size_t length, SshExecParams *params)
 Parse "exec" channel request parameters. More...
 
bool_t sshGetExecArg (const SshExecParams *params, uint_t index, SshString *arg)
 Retrieve the specified argument from an "exec" request. More...
 
error_t sshParseSubsystemParams (const uint8_t *p, size_t length, SshSubsystemParams *params)
 Parse "subsystem" channel request parameters. More...
 
error_t sshParseWindowChangeParams (const uint8_t *p, size_t length, SshWindowChangeParams *params)
 Parse "window-change" channel request parameters. More...
 
error_t sshParseSignalParams (const uint8_t *p, size_t length, SshSignalParams *params)
 Parse "signal" channel request parameters. More...
 
error_t sshParseExitStatusParams (const uint8_t *p, size_t length, SshExitStatusParams *params)
 Parse "exit-status" channel request parameters. More...
 
error_t sshParseBreakParams (const uint8_t *p, size_t length, SshBreakParams *params)
 Parse "break" channel request parameters. More...
 
error_t sshParseChannelSuccess (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_CHANNEL_SUCCESS message. More...
 
error_t sshParseChannelFailure (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_CHANNEL_FAILURE message. More...
 

Detailed Description

Global request and channel request handling.

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 ssh_request.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SSH_TRACE_LEVEL

Definition at line 32 of file ssh_request.c.

Function Documentation

◆ sshFormatBreakParams()

error_t sshFormatBreakParams ( const SshBreakParams params,
uint8_t *  p,
size_t *  written 
)

Format "break" channel request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 899 of file ssh_request.c.

◆ sshFormatCancelTcpIpFwdParams()

error_t sshFormatCancelTcpIpFwdParams ( const SshCancelTcpIpFwdParams params,
uint8_t *  p,
size_t *  written 
)

Format "cancel-tcpip-forward" global request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 445 of file ssh_request.c.

◆ sshFormatChannelFailure()

error_t sshFormatChannelFailure ( SshChannel channel,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_CHANNEL_FAILURE message.

Parameters
[in]channelHandle referencing an SSH channel
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 957 of file ssh_request.c.

◆ sshFormatChannelRequest()

error_t sshFormatChannelRequest ( SshChannel channel,
const char_t requestType,
const void *  requestParams,
bool_t  wantReply,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_CHANNEL_REQUEST message.

Parameters
[in]channelHandle referencing an SSH channel
[in]requestTypeNULL-terminated string containing the request type
[in]requestParamsPointer to the request specific parameters
[in]wantReplyThis flag specifies whether a reply is expected
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 563 of file ssh_request.c.

◆ sshFormatChannelSuccess()

error_t sshFormatChannelSuccess ( SshChannel channel,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_CHANNEL_SUCCESS message.

Parameters
[in]channelHandle referencing an SSH channel
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 925 of file ssh_request.c.

◆ sshFormatElevationParams()

error_t sshFormatElevationParams ( const SshElevationParams params,
uint8_t *  p,
size_t *  written 
)

Format "elevation" global request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 488 of file ssh_request.c.

◆ sshFormatExecParams()

error_t sshFormatExecParams ( const SshExecParams params,
uint8_t *  p,
size_t *  written 
)

Format "exec" channel request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 745 of file ssh_request.c.

◆ sshFormatExitStatusParams()

error_t sshFormatExitStatusParams ( const SshExitStatusParams params,
uint8_t *  p,
size_t *  written 
)

Format "exit-status" channel request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 873 of file ssh_request.c.

◆ sshFormatGlobalRequest()

error_t sshFormatGlobalRequest ( SshConnection connection,
const char_t requestName,
const void *  requestParams,
bool_t  wantReply,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_GLOBAL_REQUEST message.

Parameters
[in]connectionPointer to the SSH connection
[in]requestNameNULL-terminated string containing the request name
[in]requestParamsPointer to the request specific parameters
[in]wantReplyThis flag specifies whether a reply is expected
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 324 of file ssh_request.c.

◆ sshFormatPtyReqParams()

error_t sshFormatPtyReqParams ( const SshPtyReqParams params,
uint8_t *  p,
size_t *  written 
)

Format "pty-req" channel request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 670 of file ssh_request.c.

◆ sshFormatRequestFailure()

error_t sshFormatRequestFailure ( SshConnection connection,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_REQUEST_FAILURE message.

Parameters
[in]connectionPointer to the SSH connection
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 538 of file ssh_request.c.

◆ sshFormatRequestSuccess()

error_t sshFormatRequestSuccess ( SshConnection connection,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_REQUEST_SUCCESS message.

Parameters
[in]connectionPointer to the SSH connection
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 515 of file ssh_request.c.

◆ sshFormatSignalParams()

error_t sshFormatSignalParams ( const SshSignalParams params,
uint8_t *  p,
size_t *  written 
)

Format "signal" channel request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 847 of file ssh_request.c.

◆ sshFormatSubsystemParams()

error_t sshFormatSubsystemParams ( const SshSubsystemParams params,
uint8_t *  p,
size_t *  written 
)

Format "subsystem" channel request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 771 of file ssh_request.c.

◆ sshFormatTcpIpFwdParams()

error_t sshFormatTcpIpFwdParams ( const SshTcpIpFwdParams params,
uint8_t *  p,
size_t *  written 
)

Format "tcpip-forward" global request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 400 of file ssh_request.c.

◆ sshFormatWindowChangeParams()

error_t sshFormatWindowChangeParams ( const SshWindowChangeParams params,
uint8_t *  p,
size_t *  written 
)

Format "window-change" channel request parameters.

Parameters
[in]paramsPointer to the request specific parameters
[out]pOutput stream where to write the request specific data
[out]writtenTotal number of bytes that have been written
Returns
Error code

Definition at line 797 of file ssh_request.c.

◆ sshGetExecArg()

bool_t sshGetExecArg ( const SshExecParams params,
uint_t  index,
SshString arg 
)

Retrieve the specified argument from an "exec" request.

Parameters
[in]paramsPointer to the "exec" request parameters
[in]indexZero-based index of the argument
[out]argValue of the argument
Returns
TRUE if the index is valid, else FALSE

Definition at line 1540 of file ssh_request.c.

◆ sshParseBreakParams()

error_t sshParseBreakParams ( const uint8_t *  p,
size_t  length,
SshBreakParams params 
)

Parse "break" channel request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1733 of file ssh_request.c.

◆ sshParseCancelTcpIpFwdParams()

error_t sshParseCancelTcpIpFwdParams ( const uint8_t *  p,
size_t  length,
SshCancelTcpIpFwdParams params 
)

Parse "cancel-tcpip-forward" global request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1143 of file ssh_request.c.

◆ sshParseChannelFailure()

error_t sshParseChannelFailure ( SshConnection connection,
const uint8_t *  message,
size_t  length 
)

Parse SSH_MSG_CHANNEL_FAILURE message.

Parameters
[in]connectionPointer to the SSH connection
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 1849 of file ssh_request.c.

◆ sshParseChannelRequest()

error_t sshParseChannelRequest ( SshConnection connection,
const uint8_t *  message,
size_t  length 
)

Parse SSH_MSG_CHANNEL_REQUEST message.

Parameters
[in]connectionPointer to the SSH connection
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 1280 of file ssh_request.c.

◆ sshParseChannelSuccess()

error_t sshParseChannelSuccess ( SshConnection connection,
const uint8_t *  message,
size_t  length 
)

Parse SSH_MSG_CHANNEL_SUCCESS message.

Parameters
[in]connectionPointer to the SSH connection
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 1759 of file ssh_request.c.

◆ sshParseElevationParams()

error_t sshParseElevationParams ( const uint8_t *  p,
size_t  length,
SshElevationParams params 
)

Parse "elevation" global request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1186 of file ssh_request.c.

◆ sshParseExecParams()

error_t sshParseExecParams ( const uint8_t *  p,
size_t  length,
SshExecParams params 
)

Parse "exec" channel request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1512 of file ssh_request.c.

◆ sshParseExitStatusParams()

error_t sshParseExitStatusParams ( const uint8_t *  p,
size_t  length,
SshExitStatusParams params 
)

Parse "exit-status" channel request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1708 of file ssh_request.c.

◆ sshParseGlobalRequest()

error_t sshParseGlobalRequest ( SshConnection connection,
const uint8_t *  message,
size_t  length 
)

Parse SSH_MSG_GLOBAL_REQUEST message.

Parameters
[in]connectionPointer to the SSH connection
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 989 of file ssh_request.c.

◆ sshParsePtyReqParams()

error_t sshParsePtyReqParams ( const uint8_t *  p,
size_t  length,
SshPtyReqParams params 
)

Parse "pty-req" channel request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1424 of file ssh_request.c.

◆ sshParseRequestFailure()

error_t sshParseRequestFailure ( SshConnection connection,
const uint8_t *  message,
size_t  length 
)

Parse SSH_MSG_REQUEST_FAILURE message.

Parameters
[in]connectionPointer to the SSH connection
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 1245 of file ssh_request.c.

◆ sshParseRequestSuccess()

error_t sshParseRequestSuccess ( SshConnection connection,
const uint8_t *  message,
size_t  length 
)

Parse SSH_MSG_REQUEST_SUCCESS message.

Parameters
[in]connectionPointer to the SSH connection
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 1210 of file ssh_request.c.

◆ sshParseSignalParams()

error_t sshParseSignalParams ( const uint8_t *  p,
size_t  length,
SshSignalParams params 
)

Parse "signal" channel request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1680 of file ssh_request.c.

◆ sshParseSubsystemParams()

error_t sshParseSubsystemParams ( const uint8_t *  p,
size_t  length,
SshSubsystemParams params 
)

Parse "subsystem" channel request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1590 of file ssh_request.c.

◆ sshParseTcpIpFwdParams()

error_t sshParseTcpIpFwdParams ( const uint8_t *  p,
size_t  length,
SshTcpIpFwdParams params 
)

Parse "tcpip-forward" global request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1098 of file ssh_request.c.

◆ sshParseWindowChangeParams()

error_t sshParseWindowChangeParams ( const uint8_t *  p,
size_t  length,
SshWindowChangeParams params 
)

Parse "window-change" channel request parameters.

Parameters
[in]pPointer to the request specific data
[in]lengthLength of the request specific data, in bytes
[out]paramsInformation resulting from the parsing process
Returns
Error code

Definition at line 1618 of file ssh_request.c.

◆ sshSendChannelFailure()

error_t sshSendChannelFailure ( SshChannel channel)

Send SSH_MSG_CHANNEL_FAILURE message.

Parameters
[in]channelHandle referencing an SSH channel
Returns
Error code

Definition at line 281 of file ssh_request.c.

◆ sshSendChannelRequest()

error_t sshSendChannelRequest ( SshChannel channel,
const char_t requestType,
const void *  requestParams,
bool_t  wantReply 
)

Send SSH_MSG_CHANNEL_REQUEST message.

Parameters
[in]channelHandle referencing an SSH channel
[in]requestTypeNULL-terminated string containing the request type
[in]requestParamsPointer to the request specific parameters
[in]wantReplyThis flag specifies whether a reply is expected
Returns
Error code

Definition at line 179 of file ssh_request.c.

◆ sshSendChannelSuccess()

error_t sshSendChannelSuccess ( SshChannel channel)

Send SSH_MSG_CHANNEL_SUCCESS message.

Parameters
[in]channelHandle referencing an SSH channel
Returns
Error code

Definition at line 236 of file ssh_request.c.

◆ sshSendGlobalRequest()

error_t sshSendGlobalRequest ( SshConnection connection,
const char_t requestName,
const void *  requestParams,
bool_t  wantReply 
)

Send SSH_MSG_GLOBAL_REQUEST message.

Parameters
[in]connectionPointer to the SSH connection
[in]requestNameNULL-terminated string containing the request name
[in]requestParamsPointer to the request specific parameters
[in]wantReplyThis flag specifies whether a reply is expected
Returns
Error code

Definition at line 55 of file ssh_request.c.

◆ sshSendRequestFailure()

error_t sshSendRequestFailure ( SshConnection connection)

Send SSH_MSG_REQUEST_FAILURE message.

Parameters
[in]connectionPointer to the SSH connection
Returns
Error code

Definition at line 142 of file ssh_request.c.

◆ sshSendRequestSuccess()

error_t sshSendRequestSuccess ( SshConnection connection)

Send SSH_MSG_REQUEST_SUCCESS message.

Parameters
[in]connectionPointer to the SSH connection
Returns
Error code

Definition at line 108 of file ssh_request.c.