|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
SCP (RCP) protocol wire codec - the pure, host-testable half of the SCP-over-SSH server (PROTOCORE_ENABLE_SSH_SCP). More...
#include "protocore_config.h"Go to the source code of this file.
Classes | |
| struct | ScpNs |
| Dispatch table. Addressed by offset, so the layout is asserted below. More... | |
Macros | |
| #define | PROTOCORE_SCP_ACK_OK 0 |
| proceed | |
| #define | PROTOCORE_SCP_ACK_WARN 1 |
| warning: followed by a message + ' ' | |
| #define | PROTOCORE_SCP_ACK_ERROR 2 |
| fatal error: followed by a message + ' ' | |
Typedefs | |
| typedef enum PROTO_ENUM_PACKED | ScpMode |
The role of an scp invocation, parsed from the exec command. | |
Enumerations | |
| enum | PROTO_ENUM_PACKED { SCP_MODE_INVALID = 0 , SCP_MODE_SINK , SCP_MODE_SOURCE } |
The role of an scp invocation, parsed from the exec command. More... | |
Functions | |
| PROTOCORE_NS_LAYOUT (ScpNs, parse_cmd, parse_cline, build_cline) | |
| ScpMode | protocore_scp_parse_cmd (uint8_t *work, const char *cmd, size_t cmd_len, char *path_out, size_t path_cap) |
Parse an exec command scp [-v] [-r] [-p] [-d] -t|-f <path> into . | |
| proto_bool | protocore_scp_parse_cline (uint8_t *work, const char *line, size_t len, uint32_t *mode_out, uint64_t *size_out, char *name_out, size_t name_cap) |
Parse a control line C<mode> <size> <name> (a trailing '' . | |
| size_t | protocore_scp_build_cline (uint8_t *work, uint32_t mode, uint64_t size, const char *name, char *out, size_t cap) |
Build a control line C<mode> <size> <name>\n for a source . | |
Variables | |
| PROTOCORE_NS ScpNs Scp | PROTOCORE_UNUSED |
| Module namespace. | |
SCP (RCP) protocol wire codec - the pure, host-testable half of the SCP-over-SSH server (PROTOCORE_ENABLE_SSH_SCP).
SCP transfers a file over an SSH exec "scp …" channel using the old rcp line protocol: the source side sends a control line C<mode> <size> <name>\n, the peer acks with a 0 byte, then the file bytes flow, ended by a 0 byte and another ack. This file parses/builds the command line and the control line and knows the ack bytes - no filesystem, no SSH, no Arduino, zero heap. The fs::FS sink/source state machine + the channel glue live in network_drivers/session/scp/ssh_scp.
work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.
Definition in file scp.h.
| #define PROTOCORE_SCP_ACK_WARN 1 |
| #define PROTOCORE_SCP_ACK_ERROR 2 |
| typedef enum PROTO_ENUM_PACKED ScpMode |
The role of an scp invocation, parsed from the exec command.
| enum PROTO_ENUM_PACKED |
| PROTOCORE_NS_LAYOUT | ( | ScpNs | , |
| parse_cmd | , | ||
| parse_cline | , | ||
| build_cline | |||
| ) |
| ScpMode protocore_scp_parse_cmd | ( | uint8_t * | work, |
| const char * | cmd, | ||
| size_t | cmd_len, | ||
| char * | path_out, | ||
| size_t | path_cap | ||
| ) |
Parse an exec command scp [-v] [-r] [-p] [-d] -t|-f <path> into .
| work | PROTOCORE_SCP_BORROW bytes the caller took. Not held past the call. |
| cmd | not NUL-terminated (cmd_len bytes). the mode; path_out gets the (NUL-terminated) target, |
| cmd_len | Cmd len |
| path_out | Path out |
| path_cap | Path cap |
| proto_bool protocore_scp_parse_cline | ( | uint8_t * | work, |
| const char * | line, | ||
| size_t | len, | ||
| uint32_t * | mode_out, | ||
| uint64_t * | size_out, | ||
| char * | name_out, | ||
| size_t | name_cap | ||
| ) |
Parse a control line C<mode> <size> <name> (a trailing '
' .
| work | PROTOCORE_SCP_BORROW bytes the caller took. Not held past the call. |
| line | Line |
| len | Len |
| mode_out | Mode out |
| size_out | Size out |
| name_out | Name out |
| name_cap | Name cap |
| size_t protocore_scp_build_cline | ( | uint8_t * | work, |
| uint32_t | mode, | ||
| uint64_t | size, | ||
| const char * | name, | ||
| char * | out, | ||
| size_t | cap | ||
| ) |
Build a control line C<mode> <size> <name>\n for a source .
| work | PROTOCORE_SCP_BORROW bytes the caller took. Not held past the call. |
| mode | Mode |
| size | Size |
| name | Name |
| out | Out |
| cap | Cap |
| PROTOCORE_NS ScpNs Scp PROTOCORE_UNUSED |
Module namespace.