|
K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
|
Data Structures | |
| struct | kfsw_remexec_entry |
| struct | kfsw_remexec_allowlist |
| struct | kfsw_remexec_reply |
| struct | kfsw_remexec_stats |
Macros | |
| #define | KFSW_REMEXEC_PARAM_TABLE_ID 38U |
| #define | KFSW_REMEXEC_PARAM_TABLE_NAME "remexec" |
| #define | KFSW_REMEXEC_COMMAND_MAX 64U |
| #define | KFSW_REMEXEC_OUTPUT_MAX ((size_t)CONFIG_KFSW_REMEXEC_OUTPUT_MAX) |
| #define | KFSW_REMEXEC_REFUSAL_MAX 96U |
Enumerations | |
| enum | kfsw_remexec_status { KFSW_REMEXEC_OK = 0 , KFSW_REMEXEC_NOT_OFFERED = 1 , KFSW_REMEXEC_TOO_LONG = 2 , KFSW_REMEXEC_INVALID = 3 , KFSW_REMEXEC_BUSY = 4 , KFSW_REMEXEC_TIMEOUT = 5 , KFSW_REMEXEC_FAILED = 6 , KFSW_REMEXEC_UNAVAILABLE = 7 } |
Functions | |
| int | kfsw_remexec_init (const struct kfsw_remexec_allowlist *allowlist) |
| bool | kfsw_remexec_is_initialized (void) |
| void | kfsw_remexec_get_stats (struct kfsw_remexec_stats *stats) |
| const char * | kfsw_remexec_last_refusal (void) |
| const char * | kfsw_remexec_last_command (void) |
| const char * | kfsw_remexec_status_name (enum kfsw_remexec_status status) |
| void | kfsw_remexec_list_local (const char *prefix, struct kfsw_remexec_reply *reply) |
| void | kfsw_remexec_run_local (const char *line, struct kfsw_remexec_reply *reply) |
| int | kfsw_remexec_server_start (void) |
| int | kfsw_remexec_list_remote (uint16_t node, const char *prefix, struct kfsw_remexec_reply *reply) |
| int | kfsw_remexec_run_remote (uint16_t node, const char *line, struct kfsw_remexec_reply *reply) |
Variables | |
| const struct kfsw_param_definition_set | kfsw_remexec_param_definitions |
Reads which shell commands a node offers for remote execution and runs one of them, returning what it printed to the node that asked.
The allowlist the composition hands to kfsw_remexec_init() is the security boundary. A command is not reachable until it is marked there, the listing reports exactly the marked commands, and anything else is refused with a reason naming the command. There is no wildcard, no debug mode and no PIN: discovery and permission are one list, so they cannot disagree. A node that never calls kfsw_remexec_init(), or marks nothing, answers the listing with an empty reply and refuses every execution.
Output is bounded. A reply carries at most KFSW_REMEXEC_OUTPUT_MAX bytes and says how many it dropped, so a chatty command cannot flood the link and an operator is never left guessing whether the output was complete. Whether the command succeeded is reported separately from whether its output fitted.
| #define KFSW_REMEXEC_COMMAND_MAX 64U |
#include <remexec.h>
Longest command line accepted, excluding the terminator.
| #define KFSW_REMEXEC_OUTPUT_MAX ((size_t)CONFIG_KFSW_REMEXEC_OUTPUT_MAX) |
#include <remexec.h>
Largest output one reply carries, excluding the terminator.
| #define KFSW_REMEXEC_PARAM_TABLE_ID 38U |
#include <remexec.h>
Table 38: what remote execution accepted, refused and truncated.
| #define KFSW_REMEXEC_PARAM_TABLE_NAME "remexec" |
#include <remexec.h>
Parameter table name.
| #define KFSW_REMEXEC_REFUSAL_MAX 96U |
#include <remexec.h>
Longest refusal text kept and published, including the terminator.
| enum kfsw_remexec_status |
#include <remexec.h>
Outcome of one request.
| void kfsw_remexec_get_stats | ( | struct kfsw_remexec_stats * | stats | ) |
#include <remexec.h>
Read the lifetime totals.
| int kfsw_remexec_init | ( | const struct kfsw_remexec_allowlist * | allowlist | ) |
#include <remexec.h>
Adopt the allowlist and prepare the capture shell.
Call once, before the server starts. The entries are referenced, not copied, so they must have static lifetime.
| allowlist | Commands this node offers. NULL, or a count of zero, offers nothing and is a valid composition. |
| 0 | Adopted. |
| -E2BIG | More entries than CONFIG_KFSW_REMEXEC_MAX_ENTRIES. |
| -EINVAL | An entry has no command or no help text, or a command is empty, holds a byte that is not printable, or repeats another. |
| -ENAMETOOLONG | A command is longer than KFSW_REMEXEC_COMMAND_MAX. |
| -EALREADY | Already initialised. |
| -EAGAIN | The capture shell did not become ready, so a command's output could not be read back. Nothing is offered. |
| bool kfsw_remexec_is_initialized | ( | void | ) |
#include <remexec.h>
Whether an allowlist was adopted.
| const char * kfsw_remexec_last_command | ( | void | ) |
#include <remexec.h>
The last command line that was run, with its arguments.
Empty before the first one. It is what the node was asked to run, not what the command printed.
| const char * kfsw_remexec_last_refusal | ( | void | ) |
#include <remexec.h>
The most recent refusal, as the operator was told it.
Empty before any.
| void kfsw_remexec_list_local | ( | const char * | prefix, |
| struct kfsw_remexec_reply * | reply | ||
| ) |
#include <remexec.h>
Fill reply with the commands this node offers.
With an empty or NULL prefix the listing is one command name a line. With a prefix it is the matching command and its subcommands, each as name<TAB>help. A listing longer than the output cap is truncated and reports the bytes it dropped.
| int kfsw_remexec_list_remote | ( | uint16_t | node, |
| const char * | prefix, | ||
| struct kfsw_remexec_reply * | reply | ||
| ) |
#include <remexec.h>
Ask node which commands it offers.
| 0 | The node answered; the outcome is in reply. |
| -EINVAL | Node 0, the broadcast address or above, or the local node. |
| -EACCES | CSP is not running. |
| -ETIMEDOUT | No reply inside CONFIG_KFSW_REMEXEC_TIMEOUT_MS. |
| -EBADMSG | The reply did not match the request. |
| void kfsw_remexec_run_local | ( | const char * | line, |
| struct kfsw_remexec_reply * | reply | ||
| ) |
#include <remexec.h>
Run line on this node if the allowlist offers it.
Refuses rather than queues when an execution is already running. Must not be called from a shell command handler: the capture shell cannot execute from within an execution.
| int kfsw_remexec_run_remote | ( | uint16_t | node, |
| const char * | line, | ||
| struct kfsw_remexec_reply * | reply | ||
| ) |
#include <remexec.h>
Ask node to run line and return what it printed.
Errors are those of kfsw_remexec_list_remote(). A timeout leaves the outcome unknown: the serving node runs the command to completion whether or not the requester is still there, and discards a reply it cannot deliver.
| int kfsw_remexec_server_start | ( | void | ) |
#include <remexec.h>
Bind the remote execution port and start serving requests.
| const char * kfsw_remexec_status_name | ( | enum kfsw_remexec_status | status | ) |
#include <remexec.h>
Human-readable name for a status, for shell output and logs.
|
extern |
#include <remexec.h>
Parameter table 38.