Zephyr Project API 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#include <zephyr/sys/slist.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
30
31struct ssh_transport;
32struct ssh_channel;
33struct ssh_client;
34struct ssh_server;
35
37
47
75
95
102 /* TODO: Union of request type data */
103};
104
110
125
135typedef int (*ssh_channel_event_callback_t)(struct ssh_channel *channel,
136 const struct ssh_channel_event *event,
137 void *user_data);
138
150
156
160 struct ssh_channel *channel;
161};
162
177
187typedef int (*ssh_transport_event_callback_t)(struct ssh_transport *transport,
188 const struct ssh_transport_event *event,
189 void *user_data);
190
204
206#define SSH_EXTENDED_DATA_STDERR 1
207
208#if defined(CONFIG_SSH_CLIENT) || defined(__DOXYGEN__)
216const char *ssh_transport_client_user_name(struct ssh_transport *transport);
217
227int ssh_transport_auth_password(struct ssh_transport *transport, const char *user_name,
228 const char *password);
229
239int ssh_transport_channel_open(struct ssh_transport *transport,
240 ssh_channel_event_callback_t callback, void *user_data);
241
242#endif /* CONFIG_SSH_CLIENT || __DOXYGEN__ */
243
244#if defined(CONFIG_SSH_SERVER) || defined(__DOXYGEN__)
255int ssh_channel_open_result(struct ssh_channel *channel, bool success,
256 ssh_channel_event_callback_t callback, void *user_data);
257
258#endif /* CONFIG_SSH_SERVER || __DOXYGEN__ */
259
268int ssh_channel_request_result(struct ssh_channel *channel, bool success);
269
270#if defined(CONFIG_SSH_CLIENT) || defined(__DOXYGEN__)
278int ssh_channel_request_shell(struct ssh_channel *channel);
279
280#endif /* CONFIG_SSH_CLIENT || __DOXYGEN__ */
281
291int ssh_channel_read(struct ssh_channel *channel, void *data, uint32_t len);
292
302int ssh_channel_write(struct ssh_channel *channel, const void *data, uint32_t len);
303
313int ssh_channel_read_stderr(struct ssh_channel *channel, void *data, uint32_t len);
314
324int ssh_channel_write_stderr(struct ssh_channel *channel, const void *data, uint32_t len);
325
337int ssh_channel_close(struct ssh_channel *channel);
338
347typedef void (*ssh_service_client_cb_t)(struct ssh_client *ssh,
348 int instance,
349 void *user_data);
350
358
367typedef void (*ssh_service_server_cb_t)(struct ssh_server *sshd,
368 int instance,
369 void *user_data);
370
378
398int ssh_transport_traverse_callbacks(bool is_server, struct ssh_transport *transport,
399 const struct ssh_transport_event *event);
400
401
402#ifdef __cplusplus
403}
404#endif
405
409
410#endif /* ZEPHYR_INCLUDE_NET_SSH_COMMON_H_ */
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:42
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:135
int ssh_transport_traverse_callbacks(bool is_server, struct ssh_transport *transport, const struct ssh_transport_event *event)
Call user configured callbacks for a given transport.
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:140
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:39
int ssh_channel_close(struct ssh_channel *channel)
Close an SSH channel.
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:49
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:347
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:77
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:187
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:367
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:146
@ SSH_TRANSPORT_EVENT_SERVICE_ACCEPTED
Requested SSH service was accepted by the peer.
Definition common.h:144
@ SSH_TRANSPORT_EVENT_CLOSED
Transport has been closed.
Definition common.h:142
@ SSH_TRANSPORT_EVENT_CHANNEL_OPEN
Server received a request to open a channel.
Definition common.h:148
@ SSH_AUTH_NONE
No authentication method selected.
Definition common.h:41
@ SSH_AUTH_PASSWORD
Username and password authentication.
Definition common.h:43
@ SSH_AUTH_PUBKEY
Public key authentication.
Definition common.h:45
@ SSH_CHANNEL_REQUEST_UNKNOWN
Unknown or unsupported channel request type.
Definition common.h:51
@ SSH_CHANNEL_REQUEST_FLOW_CONTROL
Request flow control.
Definition common.h:67
@ SSH_CHANNEL_REQUEST_PSEUDO_TERMINAL
Request a pseudo-terminal.
Definition common.h:53
@ SSH_CHANNEL_REQUEST_EXIT_STATUS
Report process exit status.
Definition common.h:71
@ SSH_CHANNEL_REQUEST_X11_FORWARD
Request X11 forwarding.
Definition common.h:55
@ SSH_CHANNEL_REQUEST_SUBSYSTEM
Start a subsystem.
Definition common.h:63
@ SSH_CHANNEL_REQUEST_EXEC
Execute a command.
Definition common.h:61
@ SSH_CHANNEL_REQUEST_EXIT_SIGNAL
Report process exit signal.
Definition common.h:73
@ SSH_CHANNEL_REQUEST_SHELL
Start an interactive shell.
Definition common.h:59
@ SSH_CHANNEL_REQUEST_SIGNAL
Send a signal to the remote process.
Definition common.h:69
@ SSH_CHANNEL_REQUEST_ENV_VAR
Set an environment variable.
Definition common.h:57
@ SSH_CHANNEL_REQUEST_WINDOW_CHANGE
Notify of terminal window size changes.
Definition common.h:65
@ SSH_CHANNEL_EVENT_RX_STDERR_DATA_READY
Standard error data is available to read.
Definition common.h:89
@ SSH_CHANNEL_EVENT_REQUEST_RESULT
Result of a previously sent channel request on the client side.
Definition common.h:83
@ SSH_CHANNEL_EVENT_OPEN_RESULT
Result of an open request on the client side.
Definition common.h:79
@ SSH_CHANNEL_EVENT_REQUEST
Incoming channel request on the server side.
Definition common.h:81
@ SSH_CHANNEL_EVENT_RX_DATA_READY
Channel data is available to read.
Definition common.h:85
@ SSH_CHANNEL_EVENT_EOF
End-of-file received for the channel.
Definition common.h:91
@ SSH_CHANNEL_EVENT_CLOSED
Channel has been closed.
Definition common.h:93
@ SSH_CHANNEL_EVENT_TX_DATA_READY
Channel can accept more transmit data.
Definition common.h:87
Public kernel APIs.
Header file for the single-linked list API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Data for SSH_CHANNEL_EVENT_REQUEST_RESULT event.
Definition common.h:106
bool success
True if the request succeeded.
Definition common.h:108
Data for SSH_CHANNEL_EVENT_REQUEST event.
Definition common.h:97
bool want_reply
True if the peer expects a reply.
Definition common.h:101
enum ssh_channel_request_type type
Requested channel operation.
Definition common.h:99
SSH channel event information.
Definition common.h:112
enum ssh_channel_event_type type
Types of events emitted for an SSH channel.
Definition common.h:114
struct ssh_channel_event_channel_request_result channel_request_result
Data for SSH_CHANNEL_EVENT_REQUEST_RESULT.
Definition common.h:122
struct ssh_channel_event_channel_request channel_request
Data for SSH_CHANNEL_EVENT_REQUEST.
Definition common.h:119
SSH transport callback configuration.
Definition common.h:192
void * user_data
User data to be passed to the callback function.
Definition common.h:202
ssh_transport_event_callback_t cb
Callback function to be called by the server to retrieve the transport for a client connection.
Definition common.h:199
sys_snode_t node
List node.
Definition common.h:194
Data for SSH_TRANSPORT_EVENT_AUTHENTICATE_RESULT event.
Definition common.h:152
bool success
True if authentication succeeded.
Definition common.h:154
Data for SSH_TRANSPORT_EVENT_CHANNEL_OPEN event.
Definition common.h:158
struct ssh_channel * channel
Newly opened channel.
Definition common.h:160
SSH transport event information.
Definition common.h:164
struct ssh_transport_event_channel_open channel_open
Data for SSH_TRANSPORT_EVENT_CHANNEL_OPEN.
Definition common.h:174
struct ssh_transport_event_authenticate_result authenticate_result
Data for SSH_TRANSPORT_EVENT_AUTHENTICATE_RESULT.
Definition common.h:171
enum ssh_transport_event_type type
Types of events emitted for an SSH transport.
Definition common.h:166