|
K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
|
Public Headers | |
| file | csp.h |
Data Structures | |
| struct | kfsw_csp_info |
| struct | kfsw_csp_interface_info |
| struct | kfsw_csp_counters |
| struct | kfsw_csp_route_info |
| struct | kfsw_csp_interface_stats |
| struct | kfsw_csp_clock |
| struct | kfsw_csp_identity |
Macros | |
| #define | KFSW_CSP_AUTHENTICATED_CONNECTION 0U |
| #define | KFSW_CSP_AUTHENTICATED_SOCKET 0U |
| #define | KFSW_CSP_HOST_BITS 14U |
| #define | KFSW_CSP_BROADCAST_ADDRESS ((1U << KFSW_CSP_HOST_BITS) - 1U) |
| #define | KFSW_CSP_ROUTE_TABLE_MAX_LENGTH 99U |
| #define | KFSW_CSP_SECURE_OVERHEAD 32U |
| #define | KFSW_CSP_PAYLOAD_MAX (CONFIG_CSP_BUFFER_SIZE - KFSW_CSP_SECURE_OVERHEAD) |
| #define | KFSW_CSP_INTERFACE_NAME_SIZE 11U |
| #define | KFSW_CSP_IDENTITY_HOSTNAME_SIZE 21U |
| #define | KFSW_CSP_IDENTITY_MODEL_SIZE 31U |
| #define | KFSW_CSP_IDENTITY_REVISION_SIZE 21U |
| #define | KFSW_CSP_IDENTITY_DATE_SIZE 13U |
| #define | KFSW_CSP_IDENTITY_TIME_SIZE 10U |
Types | |
| typedef bool(* | kfsw_csp_interface_visitor_t) (const struct kfsw_csp_interface_info *interface_info, void *context) |
| typedef bool(* | kfsw_csp_route_visitor_t) (const struct kfsw_csp_route_info *route_info, void *context) |
Functions | |
| void | kfsw_csp_set_packet_trace (bool enabled) |
| bool | kfsw_csp_get_packet_trace (void) |
| int | kfsw_csp_set_rdp_trace (uint8_t level) |
| uint8_t | kfsw_csp_get_rdp_trace (void) |
| void | kfsw_csp_set_revision (const char *revision) |
| int | kfsw_csp_init (void) |
| int | kfsw_csp_start (void) |
| void | kfsw_csp_get_info (struct kfsw_csp_info *info) |
| void | kfsw_csp_visit_interfaces (kfsw_csp_interface_visitor_t visitor, void *context) |
| void | kfsw_csp_visit_routes (kfsw_csp_route_visitor_t visitor, void *context) |
| int | kfsw_csp_route_lookup (uint16_t address, struct kfsw_csp_route_info *info) |
| void | kfsw_csp_get_counters (struct kfsw_csp_counters *counters) |
| void | kfsw_csp_clear_counters (void) |
| const char * | kfsw_csp_error_name (uint8_t code) |
| const char * | kfsw_csp_can_error_name (uint8_t code) |
| int | kfsw_csp_route_table_check (const char *route_table, size_t *entry_count) |
| int | kfsw_csp_route_table_apply (const char *route_table) |
| int | kfsw_csp_ping (uint16_t node, uint32_t timeout_ms, size_t payload_size, uint32_t *round_trip_us) |
| int | kfsw_csp_interface_stats_read (uint16_t node, const char *name, uint32_t timeout_ms, struct kfsw_csp_interface_stats *stats) |
| void | kfsw_csp_clock_get (struct kfsw_csp_clock *clock) |
| bool | kfsw_csp_clock_is_set (const struct kfsw_csp_clock *clock) |
| int | kfsw_csp_clock_set (const struct kfsw_csp_clock *clock) |
| int | kfsw_csp_clock_read (uint16_t node, uint32_t timeout_ms, struct kfsw_csp_clock *clock) |
| int | kfsw_csp_clock_write (uint16_t node, uint32_t timeout_ms, struct kfsw_csp_clock *clock) |
| int | kfsw_csp_identify (uint16_t node, uint32_t timeout_ms, struct kfsw_csp_identity *identity) |
libcsp initialization, route inspection, and ping operations.
The application calls kfsw_csp_init() before registering CSP services and calls kfsw_csp_start() once to start the router thread.
| #define KFSW_CSP_AUTHENTICATED_CONNECTION 0U |
#include <csp.h>
Connection options for traffic this node originates.
Signing is the whole of phase one: a peer that holds the key can tell this node's traffic apart from anybody else's, and nothing is refused yet.
| #define KFSW_CSP_AUTHENTICATED_SOCKET 0U |
#include <csp.h>
Socket options for a service that changes state: commanding, remote execution, file transfer and firmware upload.
Empty unless this image was built to require authentication, so the policy lives here and not spelled out in each service.
| #define KFSW_CSP_BROADCAST_ADDRESS ((1U << KFSW_CSP_HOST_BITS) - 1U) |
#include <csp.h>
Highest CSP address, which is broadcast: 31 in CSP 1, 16383 in CSP 2.
Unicast nodes are 1 to KFSW_CSP_BROADCAST_ADDRESS - 1.
| #define KFSW_CSP_HOST_BITS 14U |
#include <csp.h>
Width of a CSP node address in the protocol version this image is built for: 5 bits in CSP 1, 14 in CSP 2.
libcsp reports CSP 2 limits until kfsw_csp_init() has run. Code that checks an address before then, or without CSP composed, uses these constants.
| #define KFSW_CSP_INTERFACE_NAME_SIZE 11U |
#include <csp.h>
Interface names in CMP have ten characters and a terminator.
| #define KFSW_CSP_PAYLOAD_MAX (CONFIG_CSP_BUFFER_SIZE - KFSW_CSP_SECURE_OVERHEAD) |
#include <csp.h>
Largest application payload that survives every K-FSW transport.
A service that sizes a full packet checks against this and not CSP_BUFFER_SIZE: the encrypted UHF link is the tightest and drops anything longer without reporting it.
| #define KFSW_CSP_ROUTE_TABLE_MAX_LENGTH 99U |
#include <csp.h>
Maximum route-table string length accepted by the pinned libcsp parser.
| #define KFSW_CSP_SECURE_OVERHEAD 32U |
#include <csp.h>
Framing the encrypted UHF link adds inside one CSP buffer: a 12-byte header, a 16-byte tag and a 4-byte checksum.
| const char * kfsw_csp_can_error_name | ( | uint8_t | code | ) |
#include <csp.h>
Name of a kfsw_csp_counters last_can_error code, or "unknown".
| void kfsw_csp_clear_counters | ( | void | ) |
#include <csp.h>
Clear the error counters.
| void kfsw_csp_clock_get | ( | struct kfsw_csp_clock * | clock | ) |
#include <csp.h>
Read this node's RTC clock.
| bool kfsw_csp_clock_is_set | ( | const struct kfsw_csp_clock * | clock | ) |
#include <csp.h>
Whether a clock reading has been set.
| int kfsw_csp_clock_read | ( | uint16_t | node, |
| uint32_t | timeout_ms, | ||
| struct kfsw_csp_clock * | clock | ||
| ) |
#include <csp.h>
Read another node's RTC clock.
Returns 0 and fills clock, or a negative errno: -EINVAL for node 0 or an address from KFSW_CSP_BROADCAST_ADDRESS up. A node whose clock was never set answers zero seconds.
| int kfsw_csp_clock_set | ( | const struct kfsw_csp_clock * | clock | ) |
#include <csp.h>
Set this node's RTC clock.
Returns 0 on success, -ENOTSUP where the composition carries no real-time clock, and -EINVAL for a time the platform will not accept.
| int kfsw_csp_clock_write | ( | uint16_t | node, |
| uint32_t | timeout_ms, | ||
| struct kfsw_csp_clock * | clock | ||
| ) |
#include <csp.h>
Set another node's clock.
clock is filled with the time the node reads back after setting it. The link delay is not compensated. -EINVAL for node 0 or an address from KFSW_CSP_BROADCAST_ADDRESS up.
| const char * kfsw_csp_error_name | ( | uint8_t | code | ) |
#include <csp.h>
Name of a kfsw_csp_counters last_error code, or "unknown".
| void kfsw_csp_get_counters | ( | struct kfsw_csp_counters * | counters | ) |
| void kfsw_csp_get_info | ( | struct kfsw_csp_info * | info | ) |
#include <csp.h>
Copy the current local CSP identity information.
| bool kfsw_csp_get_packet_trace | ( | void | ) |
#include <csp.h>
Whether packet tracing is currently on.
| uint8_t kfsw_csp_get_rdp_trace | ( | void | ) |
#include <csp.h>
The level the reliable transport is tracing at.
| int kfsw_csp_identify | ( | uint16_t | node, |
| uint32_t | timeout_ms, | ||
| struct kfsw_csp_identity * | identity | ||
| ) |
#include <csp.h>
Ask a remote node to identify itself.
Gets the hostname, model, revision, and build date and time.
| node | Remote CSP address. | |
| timeout_ms | Reply timeout in milliseconds. | |
| [out] | identity | Destination identity. |
| CSP_ERR_NONE | The node answered. |
| CSP_ERR_INVAL | CSP is not running, identity is NULL, or the address is out of range. |
| CSP_ERR_TIMEDOUT | No answer arrived in time. |
| int kfsw_csp_init | ( | void | ) |
#include <csp.h>
Initialize libcsp, the configured interfaces, and static routes once.
| int kfsw_csp_interface_stats_read | ( | uint16_t | node, |
| const char * | name, | ||
| uint32_t | timeout_ms, | ||
| struct kfsw_csp_interface_stats * | stats | ||
| ) |
#include <csp.h>
Read a named interface through CSP management.
Returns 0, -EINVAL for invalid arguments, -ENETDOWN before router start, -ETIMEDOUT for no complete reply (including unknown interfaces), or -EBADMSG for an inconsistent reply. Output is unchanged on failure. The query itself contributes traffic; counters are an observation, not an atomic snapshot.
| int kfsw_csp_ping | ( | uint16_t | node, |
| uint32_t | timeout_ms, | ||
| size_t | payload_size, | ||
| uint32_t * | round_trip_us | ||
| ) |
#include <csp.h>
Send a standard CSP ping using CRC32 and return its round-trip time, in microseconds from the monotonic clock rather than in system ticks.
| int kfsw_csp_route_lookup | ( | uint16_t | address, |
| struct kfsw_csp_route_info * | info | ||
| ) |
#include <csp.h>
Resolve an address using the router's outgoing interface precedence.
Local loopback and connected subnets precede the longest matching static prefix; default interfaces are the fallback. When several links carry the same destination, returns the first connected/default interface or the last matching static entry, as libcsp's lookup does. This is a route observation, not proof of delivery. Interface names remain owned by libcsp.
Returns 0 on success, -ENOENT when no route or interface matches, -ENETDOWN before initialization, or -EINVAL for an invalid address or NULL output. Output is unchanged on failure.
| int kfsw_csp_route_table_apply | ( | const char * | route_table | ) |
#include <csp.h>
Validate and replace routes after initialization, before router start.
| route_table | Table in libcsp's CIDR syntax. |
| 0 | The table is loaded. |
| CSP_ERR_NOTSUP | The router is running; routes remain unchanged. |
| CSP_ERR_INVAL | CSP is not initialized or the table is invalid. |
| int kfsw_csp_route_table_check | ( | const char * | route_table, |
| size_t * | entry_count | ||
| ) |
#include <csp.h>
Check a route table without applying it.
Returns 0 when the table is well formed, -ENETDOWN when CSP has not been initialised yet and the interfaces a table names do not exist, and a libcsp error otherwise.
| void kfsw_csp_set_packet_trace | ( | bool | enabled | ) |
#include <csp.h>
Print every packet the router receives and every packet this node sends.
Each line has the source and destination node and port, priority, flags and size. Off by default.
| enabled | True to trace, false to stop. |
| int kfsw_csp_set_rdp_trace | ( | uint8_t | level | ) |
#include <csp.h>
How much the reliable transport explains itself.
RDP is where a transfer stalls without saying why, so the detail is a dial rather than a switch: 0 says nothing, 1 reports the errors, 2 adds the protocol exchange, which is a line per segment and only worth it for one pass. Off by default, and not persisted: a reset returns to quiet.
| 0 | Applied. |
| -ERANGE | Above 2. |
| void kfsw_csp_set_revision | ( | const char * | revision | ) |
| int kfsw_csp_start | ( | void | ) |
#include <csp.h>
Start the CSP router thread.
| void kfsw_csp_visit_interfaces | ( | kfsw_csp_interface_visitor_t | visitor, |
| void * | context | ||
| ) |
#include <csp.h>
Call visitor for each registered interface, under libcsp's lock.
Return false from visitor to stop early.
| void kfsw_csp_visit_routes | ( | kfsw_csp_route_visitor_t | visitor, |
| void * | context | ||
| ) |