ssh_connection.h
Go to the documentation of this file.
1 /**
2  * @file ssh_connection.h
3  * @brief SSH connection protocol
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSSH Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _SSH_CONNECTION_H
32 #define _SSH_CONNECTION_H
33 
34 //Dependencies
35 #include "ssh/ssh.h"
36 
37 //C++ guard
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 /**
44  * @brief "x11" channel specific parameters
45  **/
46 
47 typedef struct
48 {
50  uint32_t originatorPort;
52 
53 
54 /**
55  * @brief "forwarded-tcpip" channel specific parameters
56  **/
57 
58 typedef struct
59 {
61  uint32_t portConnected;
63  uint32_t originPort;
65 
66 
67 /**
68  * @brief "direct-tcpip" channel specific parameters
69  **/
70 
71 typedef struct
72 {
74  uint32_t portToConnect;
76  uint32_t originPort;
78 
79 
80 //SSH related functions
81 error_t sshSendChannelOpen(SshChannel *channel, const char_t *channelType,
82  const void *channelParams);
83 
85 
87  uint32_t recipientChannel, uint32_t reasonCode, const char_t *description);
88 
89 error_t sshSendChannelWindowAdjust(SshChannel *channel, size_t windowSizeInc);
93 
94 error_t sshFormatChannelOpen(SshChannel *channel, const char_t *channelType,
95  const void *channelParams, uint8_t *p, size_t *length);
96 
98  uint8_t *p, size_t *written);
99 
101  uint8_t *p, size_t *written);
102 
104  size_t *length);
105 
107  uint32_t recipientChannel, uint32_t reasonCode, const char_t *description,
108  uint8_t *p, size_t *length);
109 
110 error_t sshFormatChannelWindowAdjust(SshChannel *channel, size_t windowSizeInc,
111  uint8_t *p, size_t *length);
112 
114  uint8_t *p, size_t *length);
115 
116 error_t sshFormatChannelEof(SshChannel *channel, uint8_t *p, size_t *length);
117 error_t sshFormatChannelClose(SshChannel *channel, uint8_t *p, size_t *length);
118 
120  const uint8_t *message, size_t length);
121 
122 error_t sshParseForwardedTcpIpParams(const uint8_t *p, size_t length,
123  SshForwardedTcpIpParams *params);
124 
125 error_t sshParseDirectTcpIpParams(const uint8_t *p, size_t length,
126  SshDirectTcpIpParams *params);
127 
129  const uint8_t *message, size_t length);
130 
132  const uint8_t *message, size_t length);
133 
135  const uint8_t *message, size_t length);
136 
138  const uint8_t *message, size_t length);
139 
141  const uint8_t *message, size_t length);
142 
144  const uint8_t *message, size_t length);
145 
147  const uint8_t *message, size_t length);
148 
149 //C++ guard
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif
uint8_t message[]
Definition: chap.h:154
char char_t
Definition: compiler_port.h:48
error_t
Error codes.
Definition: error.h:43
uint8_t p
Definition: ndp.h:300
uint32_t dataLen
Definition: sftp_common.h:229
Secure Shell (SSH)
#define SshChannel
Definition: ssh.h:887
#define SshConnection
Definition: ssh.h:883
error_t sshParseForwardedTcpIpParams(const uint8_t *p, size_t length, SshForwardedTcpIpParams *params)
Parse "forwarded-tcpip" channel parameters.
error_t sshParseChannelClose(SshConnection *connection, const uint8_t *message, size_t length)
Parse SSH_MSG_CHANNEL_CLOSE message.
error_t sshFormatChannelOpen(SshChannel *channel, const char_t *channelType, const void *channelParams, uint8_t *p, size_t *length)
Format SSH_MSG_CHANNEL_OPEN message.
error_t sshParseChannelEof(SshConnection *connection, const uint8_t *message, size_t length)
Parse SSH_MSG_CHANNEL_EOF message.
error_t sshSendChannelClose(SshChannel *channel)
Send SSH_MSG_CHANNEL_CLOSE message.
error_t sshFormatChannelData(SshChannel *channel, size_t dataLen, uint8_t *p, size_t *length)
Format SSH_MSG_CHANNEL_DATA message.
error_t sshParseChannelData(SshConnection *connection, const uint8_t *message, size_t length)
Parse SSH_MSG_CHANNEL_DATA message.
error_t sshSendChannelOpenConfirmation(SshChannel *channel)
Send SSH_MSG_CHANNEL_OPEN_CONFIRMATION message.
error_t sshParseChannelOpenFailure(SshConnection *connection, const uint8_t *message, size_t length)
Parse SSH_MSG_CHANNEL_OPEN_FAILURE message.
error_t sshFormatForwardedTcpIpParams(const SshForwardedTcpIpParams *params, uint8_t *p, size_t *written)
Format "forwarded-tcpip" channel parameters.
error_t sshParseChannelWindowAdjust(SshConnection *connection, const uint8_t *message, size_t length)
Parse SSH_MSG_CHANNEL_WINDOW_ADJUST message.
error_t sshSendChannelOpenFailure(SshConnection *connection, uint32_t recipientChannel, uint32_t reasonCode, const char_t *description)
Format SSH_MSG_CHANNEL_OPEN_FAILURE message.
error_t sshFormatChannelEof(SshChannel *channel, uint8_t *p, size_t *length)
Format SSH_MSG_CHANNEL_EOF message.
error_t sshParseChannelOpenConfirmation(SshConnection *connection, const uint8_t *message, size_t length)
Parse SSH_MSG_CHANNEL_OPEN_CONFIRMATION message.
error_t sshSendChannelEof(SshChannel *channel)
Send SSH_MSG_CHANNEL_EOF message.
error_t sshParseChannelExtendedData(SshConnection *connection, const uint8_t *message, size_t length)
Parse SSH_MSG_CHANNEL_EXTENDED_DATA message.
error_t sshFormatChannelWindowAdjust(SshChannel *channel, size_t windowSizeInc, uint8_t *p, size_t *length)
Format SSH_MSG_CHANNEL_WINDOW_ADJUST message.
error_t sshParseDirectTcpIpParams(const uint8_t *p, size_t length, SshDirectTcpIpParams *params)
Parse "direct-tcpip" channel parameters.
error_t sshFormatChannelClose(SshChannel *channel, uint8_t *p, size_t *length)
Format SSH_MSG_CHANNEL_CLOSE message.
error_t sshFormatDirectTcpIpParams(const SshDirectTcpIpParams *params, uint8_t *p, size_t *written)
Format "direct-tcpip" channel parameters.
error_t sshSendChannelData(SshChannel *channel, size_t dataLen)
Send SSH_MSG_CHANNEL_DATA message.
error_t sshParseChannelOpen(SshConnection *connection, const uint8_t *message, size_t length)
Parse SSH_MSG_CHANNEL_OPEN message.
error_t sshSendChannelOpen(SshChannel *channel, const char_t *channelType, const void *channelParams)
Send SSH_MSG_CHANNEL_OPEN message.
error_t sshFormatChannelOpenFailure(SshConnection *connection, uint32_t recipientChannel, uint32_t reasonCode, const char_t *description, uint8_t *p, size_t *length)
Format SSH_MSG_CHANNEL_OPEN_FAILURE message.
error_t sshFormatChannelOpenConfirmation(SshChannel *channel, uint8_t *p, size_t *length)
Format SSH_MSG_CHANNEL_OPEN_CONFIRMATION message.
error_t sshSendChannelWindowAdjust(SshChannel *channel, size_t windowSizeInc)
Send SSH_MSG_CHANNEL_WINDOW_ADJUST message.
"direct-tcpip" channel specific parameters
"forwarded-tcpip" channel specific parameters
String.
Definition: ssh_types.h:56
"x11" channel specific parameters
SshString originatorAddr
uint8_t length
Definition: tcp.h:368
uint8_t description
Definition: tls.h:1855