ssh_transport.c File Reference

SSH transport layer protocol. More...

#include "ssh/ssh.h"
#include "ssh/ssh_transport.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 sshSendIdString (SshConnection *connection)
 Send identification string. More...
 
error_t sshSendServiceRequest (SshConnection *connection)
 Send SSH_MSG_SERVICE_REQUEST message. More...
 
error_t sshSendServiceAccept (SshConnection *connection, const char_t *serviceName)
 Send SSH_MSG_SERVICE_ACCEPT message. More...
 
error_t sshSendDisconnect (SshConnection *connection, uint32_t reasonCode, const char_t *description)
 Send SSH_MSG_DISCONNECT message. More...
 
error_t sshSendUnimplemented (SshConnection *connection, const uint8_t *packetSeqNum)
 Send SSH_MSG_UNIMPLEMENTED message. More...
 
error_t sshFormatServiceRequest (SshConnection *connection, uint8_t *p, size_t *length)
 Format SSH_MSG_SERVICE_REQUEST message. More...
 
error_t sshFormatServiceAccept (SshConnection *connection, const char_t *serviceName, uint8_t *p, size_t *length)
 Format SSH_MSG_SERVICE_ACCEPT message. More...
 
error_t sshFormatDisconnect (SshConnection *connection, uint32_t reasonCode, const char_t *description, uint8_t *p, size_t *length)
 Format SSH_MSG_DISCONNECT message. More...
 
error_t sshFormatUnimplemented (SshConnection *connection, const uint8_t *packetSeqNum, uint8_t *p, size_t *length)
 Format SSH_MSG_UNIMPLEMENTED message. More...
 
error_t sshParseIdString (SshConnection *connection, const uint8_t *id, size_t length)
 Parse identification string. More...
 
error_t sshParseServiceRequest (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_SERVICE_REQUEST message. More...
 
error_t sshParseServiceAccept (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_SERVICE_ACCEPT message. More...
 
error_t sshParseIgnore (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_IGNORE message. More...
 
error_t sshParseDebug (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_DEBUG message. More...
 
error_t sshParseDisconnect (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_DISCONNECT message. More...
 
error_t sshParseUnimplemented (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_UNIMPLEMENTED message. More...
 
error_t sshParseUnrecognized (SshConnection *connection, const uint8_t *message, size_t length)
 Parse unrecognized message. More...
 

Detailed Description

SSH transport layer protocol.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2019-2026 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.6.6

Definition in file ssh_transport.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SSH_TRACE_LEVEL

Definition at line 32 of file ssh_transport.c.

Function Documentation

◆ sshFormatDisconnect()

error_t sshFormatDisconnect ( SshConnection *  connection,
uint32_t  reasonCode,
const char_t *  description,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_DISCONNECT message.

Parameters
[in]connectionPointer to the SSH connection
[in]reasonCodeReason in a machine-readable format
[in]descriptionSpecific explanation in a human-readable form
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 357 of file ssh_transport.c.

◆ sshFormatServiceAccept()

error_t sshFormatServiceAccept ( SshConnection *  connection,
const char_t *  serviceName,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_SERVICE_ACCEPT message.

Parameters
[in]connectionPointer to the SSH connection
[in]serviceNameNULL-terminating string that contains the service name
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 317 of file ssh_transport.c.

◆ sshFormatServiceRequest()

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

Format SSH_MSG_SERVICE_REQUEST 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 278 of file ssh_transport.c.

◆ sshFormatUnimplemented()

error_t sshFormatUnimplemented ( SshConnection *  connection,
const uint8_t *  packetSeqNum,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_UNIMPLEMENTED message.

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

Definition at line 413 of file ssh_transport.c.

◆ sshParseDebug()

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

Parse SSH_MSG_DEBUG 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 733 of file ssh_transport.c.

◆ sshParseDisconnect()

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

Parse SSH_MSG_DISCONNECT 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 817 of file ssh_transport.c.

◆ sshParseIdString()

error_t sshParseIdString ( SshConnection *  connection,
const uint8_t *  id,
size_t  length 
)

Parse identification string.

Parameters
[in]connectionPointer to the SSH connection
[in]idPointer to the identification string
[in]lengthLength of the identification string
Returns
Error code

Definition at line 445 of file ssh_transport.c.

◆ sshParseIgnore()

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

Parse SSH_MSG_IGNORE 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 674 of file ssh_transport.c.

◆ sshParseServiceAccept()

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

Parse SSH_MSG_SERVICE_ACCEPT 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 603 of file ssh_transport.c.

◆ sshParseServiceRequest()

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

Parse SSH_MSG_SERVICE_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 525 of file ssh_transport.c.

◆ sshParseUnimplemented()

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

Parse SSH_MSG_UNIMPLEMENTED 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 895 of file ssh_transport.c.

◆ sshParseUnrecognized()

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

Parse unrecognized 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 936 of file ssh_transport.c.

◆ sshSendDisconnect()

error_t sshSendDisconnect ( SshConnection *  connection,
uint32_t  reasonCode,
const char_t *  description 
)

Send SSH_MSG_DISCONNECT message.

Parameters
[in]connectionPointer to the SSH connection
[in]reasonCodeReason in a machine-readable format
[in]descriptionSpecific explanation in a human-readable form
Returns
Error code

Definition at line 194 of file ssh_transport.c.

◆ sshSendIdString()

error_t sshSendIdString ( SshConnection *  connection)

Send identification string.

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

Definition at line 51 of file ssh_transport.c.

◆ sshSendServiceAccept()

error_t sshSendServiceAccept ( SshConnection *  connection,
const char_t *  serviceName 
)

Send SSH_MSG_SERVICE_ACCEPT message.

Parameters
[in]connectionPointer to the SSH connection
[in]serviceNameNULL-terminating string that contains the service name
Returns
Error code

Definition at line 149 of file ssh_transport.c.

◆ sshSendServiceRequest()

error_t sshSendServiceRequest ( SshConnection *  connection)

Send SSH_MSG_SERVICE_REQUEST message.

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

Definition at line 100 of file ssh_transport.c.

◆ sshSendUnimplemented()

error_t sshSendUnimplemented ( SshConnection *  connection,
const uint8_t *  packetSeqNum 
)

Send SSH_MSG_UNIMPLEMENTED message.

Parameters
[in]connectionPointer to the SSH connection
[in]packetSeqNumPacket sequence number of rejected message
Returns
Error code

Definition at line 241 of file ssh_transport.c.