Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Grant Ramsay <grant.ramsay@hotmail.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_NET_SSH_COMMON_H_
8#define ZEPHYR_INCLUDE_NET_SSH_COMMON_H_
9
21
22#include <zephyr/kernel.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
29
30struct ssh_transport;
31struct ssh_channel;
32struct ssh_client;
33struct ssh_server;
34
36
46
74
94
101 /* TODO: Union of request type data */
102};
103
109
124
134typedef int (*ssh_channel_event_callback_t)(struct ssh_channel *channel,
135 const struct ssh_channel_event *event,
136 void *user_data);
137
149
155
159 struct ssh_channel *channel;
160};
161
176
186typedef int (*ssh_transport_event_callback_t)(struct ssh_transport *transport,
187 const struct ssh_transport_event *event,
188 void *user_data);
189
191#define SSH_EXTENDED_DATA_STDERR 1
192
193#if defined(CONFIG_SSH_CLIENT) || defined(__DOXYGEN__)
201const char *ssh_transport_client_user_name(struct ssh_transport *transport);
202
212int ssh_transport_auth_password(struct ssh_transport *transport, const char *user_name,
213 const char *password);
214
224int ssh_transport_channel_open(struct ssh_transport *transport,
225 ssh_channel_event_callback_t callback, void *user_data);
226
227#endif /* CONFIG_SSH_CLIENT || __DOXYGEN__ */
228
229#if defined(CONFIG_SSH_SERVER) || defined(__DOXYGEN__)
240int ssh_channel_open_result(struct ssh_channel *channel, bool success,
241 ssh_channel_event_callback_t callback, void *user_data);
242
243#endif /* CONFIG_SSH_SERVER || __DOXYGEN__ */
244
253int ssh_channel_request_result(struct ssh_channel *channel, bool success);
254
255#if defined(CONFIG_SSH_CLIENT) || defined(__DOXYGEN__)
263int ssh_channel_request_shell(struct ssh_channel *channel);
264
265#endif /* CONFIG_SSH_CLIENT || __DOXYGEN__ */
266
276int ssh_channel_read(struct ssh_channel *channel, void *data, uint32_t len);
277
287int ssh_channel_write(struct ssh_channel *channel, const void *data, uint32_t len);
288
298int ssh_channel_read_stderr(struct ssh_channel *channel, void *data, uint32_t len);
299
309int ssh_channel_write_stderr(struct ssh_channel *channel, const void *data, uint32_t len);
310
319typedef void (*ssh_service_client_cb_t)(struct ssh_client *ssh,
320 int instance,
321 void *user_data);
322
330
339typedef void (*ssh_service_server_cb_t)(struct ssh_server *sshd,
340 int instance,
341 void *user_data);
342
350
351
352#ifdef __cplusplus
353}
354#endif
355
359
360#endif /* ZEPHYR_INCLUDE_NET_SSH_COMMON_H_ */
int ssh_channel_open_result(struct ssh_channel *channel, bool success, ssh_channel_event_callback_t callback, void *user_data)
Reply to a channel open request.
int ssh_transport_channel_open(struct ssh_transport *transport, ssh_channel_event_callback_t callback, void *user_data)
Open a new channel on an SSH transport.
int(* ssh_channel_event_callback_t)(struct ssh_channel *channel, const struct ssh_channel_event *event, void *user_data)
SSH channel event callback.
Definition common.h:134
int ssh_channel_request_shell(struct ssh_channel *channel)
Request an interactive shell on a channel.
ssh_transport_event_type
Types of events emitted for an SSH transport.
Definition common.h:139
int ssh_channel_request_result(struct ssh_channel *channel, bool success)
Reply to a channel request.
int ssh_channel_read_stderr(struct ssh_channel *channel, void *data, uint32_t len)
Read channel standard error data.
int ssh_channel_read(struct ssh_channel *channel, void *data, uint32_t len)
Read channel data.
int ssh_channel_write(struct ssh_channel *channel, const void *data, uint32_t len)
Write channel data.
const char * ssh_transport_client_user_name(struct ssh_transport *transport)
Get the authenticated client username for a transport.
ssh_auth_type
Authentication methods supported by SSH transports.
Definition common.h:38
int ssh_channel_write_stderr(struct ssh_channel *channel, const void *data, uint32_t len)
Write channel standard error data.
ssh_channel_request_type
Types of SSH channel requests.
Definition common.h:48
void(* ssh_service_client_cb_t)(struct ssh_client *ssh, int instance, void *user_data)
Callback used while iterating over SSH client connections.
Definition common.h:319
int ssh_transport_auth_password(struct ssh_transport *transport, const char *user_name, const char *password)
Authenticate an SSH transport using a password.
ssh_channel_event_type
Types of events emitted for an SSH channel.
Definition common.h:76
int(* ssh_transport_event_callback_t)(struct ssh_transport *transport, const struct ssh_transport_event *event, void *user_data)
SSH transport event callback.
Definition common.h:186
void(* ssh_service_server_cb_t)(struct ssh_server *sshd, int instance, void *user_data)
Callback used while iterating over SSH server connections.
Definition common.h:339
void ssh_client_foreach(ssh_service_client_cb_t cb, void *user_data)
Go through all SSH client connections.
void ssh_server_foreach(ssh_service_server_cb_t cb, void *user_data)
Go through all SSH server connections.
@ SSH_TRANSPORT_EVENT_AUTHENTICATE_RESULT
Authentication attempt result.
Definition common.h:145
@ SSH_TRANSPORT_EVENT_SERVICE_ACCEPTED
Requested SSH service was accepted by the peer.
Definition common.h:143
@ SSH_TRANSPORT_EVENT_CLOSED
Transport has been closed.
Definition common.h:141
@ SSH_TRANSPORT_EVENT_CHANNEL_OPEN
Server received a request to open a channel.
Definition common.h:147
@ SSH_AUTH_NONE
No authentication method selected.
Definition common.h:40
@ SSH_AUTH_PASSWORD
Username and password authentication.
Definition common.h:42
@ SSH_AUTH_PUBKEY
Public key authentication.
Definition common.h:44
@ SSH_CHANNEL_REQUEST_UNKNOWN
Unknown or unsupported channel request type.
Definition common.h:50
@ SSH_CHANNEL_REQUEST_FLOW_CONTROL
Request flow control.
Definition common.h:66
@ SSH_CHANNEL_REQUEST_PSEUDO_TERMINAL
Request a pseudo-terminal.
Definition common.h:52
@ SSH_CHANNEL_REQUEST_EXIT_STATUS
Report process exit status.
Definition common.h:70
@ SSH_CHANNEL_REQUEST_X11_FORWARD
Request X11 forwarding.
Definition common.h:54
@ SSH_CHANNEL_REQUEST_SUBSYSTEM
Start a subsystem.
Definition common.h:62
@ SSH_CHANNEL_REQUEST_EXEC
Execute a command.
Definition common.h:60
@ SSH_CHANNEL_REQUEST_EXIT_SIGNAL
Report process exit signal.
Definition common.h:72
@ SSH_CHANNEL_REQUEST_SHELL
Start an interactive shell.
Definition common.h:58
@ SSH_CHANNEL_REQUEST_SIGNAL
Send a signal to the remote process.
Definition common.h:68
@ SSH_CHANNEL_REQUEST_ENV_VAR
Set an environment variable.
Definition common.h:56
@ SSH_CHANNEL_REQUEST_WINDOW_CHANGE
Notify of terminal window size changes.
Definition common.h:64
@ SSH_CHANNEL_EVENT_RX_STDERR_DATA_READY
Standard error data is available to read.
Definition common.h:88
@ SSH_CHANNEL_EVENT_REQUEST_RESULT
Result of a previously sent channel request on the client side.
Definition common.h:82
@ SSH_CHANNEL_EVENT_OPEN_RESULT
Result of an open request on the client side.
Definition common.h:78
@ SSH_CHANNEL_EVENT_REQUEST
Incoming channel request on the server side.
Definition common.h:80
@ SSH_CHANNEL_EVENT_RX_DATA_READY
Channel data is available to read.
Definition common.h:84
@ SSH_CHANNEL_EVENT_EOF
End-of-file received for the channel.
Definition common.h:90
@ SSH_CHANNEL_EVENT_CLOSED
Channel has been closed.
Definition common.h:92
@ SSH_CHANNEL_EVENT_TX_DATA_READY
Channel can accept more transmit data.
Definition common.h:86
Public kernel APIs.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Data for SSH_CHANNEL_EVENT_REQUEST_RESULT event.
Definition common.h:105
bool success
True if the request succeeded.
Definition common.h:107
Data for SSH_CHANNEL_EVENT_REQUEST event.
Definition common.h:96
bool want_reply
True if the peer expects a reply.
Definition common.h:100
enum ssh_channel_request_type type
Requested channel operation.
Definition common.h:98
SSH channel event information.
Definition common.h:111
enum ssh_channel_event_type type
Types of events emitted for an SSH channel.
Definition common.h:113
struct ssh_channel_event_channel_request_result channel_request_result
Data for SSH_CHANNEL_EVENT_REQUEST_RESULT.
Definition common.h:121
struct ssh_channel_event_channel_request channel_request
Data for SSH_CHANNEL_EVENT_REQUEST.
Definition common.h:118
Data for SSH_TRANSPORT_EVENT_AUTHENTICATE_RESULT event.
Definition common.h:151
bool success
True if authentication succeeded.
Definition common.h:153
Data for SSH_TRANSPORT_EVENT_CHANNEL_OPEN event.
Definition common.h:157
struct ssh_channel * channel
Newly opened channel.
Definition common.h:159
SSH transport event information.
Definition common.h:163
struct ssh_transport_event_channel_open channel_open
Data for SSH_TRANSPORT_EVENT_CHANNEL_OPEN.
Definition common.h:173
struct ssh_transport_event_authenticate_result authenticate_result
Data for SSH_TRANSPORT_EVENT_AUTHENTICATE_RESULT.
Definition common.h:170
enum ssh_transport_event_type type
Types of events emitted for an SSH transport.
Definition common.h:165