K-FSW ec10f94
Modular flight software on Zephyr, for small satellites
Loading...
Searching...
No Matches
ftp.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <kfsw/services/parameter.h>

Data Structures

struct  kfsw_ftp_entry
 
struct  kfsw_ftp_stat
 
struct  kfsw_ftp_transfer_result
 
struct  kfsw_ftp_stats
 

Macros

#define KFSW_FTP_MAX_PATH_SIZE   96U
 
#define KFSW_FTP_CHUNK_SIZE   192U
 
#define KFSW_FTP_STORAGE_ROOT   "/kfsw/ftp"
 
#define KFSW_FTP_READONLY_ROOT   "/kfsw/hk"
 
#define KFSW_FTP_TIMEOUT_MIN_MS   1000U
 
#define KFSW_FTP_TIMEOUT_MAX_MS   120000U
 
#define KFSW_FTP_PARAM_TABLE_ID   29U
 
#define KFSW_FTP_PARAM_TABLE_NAME   "ftp"
 

Types

typedef bool(* kfsw_ftp_list_visitor_t) (const struct kfsw_ftp_entry *entry, void *context)
 

Enumerations

enum  kfsw_ftp_entry_type { KFSW_FTP_ENTRY_FILE = 1 , KFSW_FTP_ENTRY_DIRECTORY = 2 }
 
enum  kfsw_event_ftp_id { KFSW_EVENT_FTP_PUT_DONE = 1 , KFSW_EVENT_FTP_GET_DONE = 2 , KFSW_EVENT_FTP_TRANSFER_FAILED = 3 }
 

Functions

int kfsw_ftp_get_stats (struct kfsw_ftp_stats *stats)
 
uint32_t kfsw_ftp_get_timeout_ms (void)
 
int kfsw_ftp_set_timeout_ms (uint32_t timeout_ms)
 
int kfsw_ftp_check_timeout_ms (uint32_t timeout_ms)
 
uint16_t kfsw_ftp_get_chunk_size (void)
 
int kfsw_ftp_set_chunk_size (uint16_t chunk_size)
 
int kfsw_ftp_check_chunk_size (uint16_t chunk_size)
 
int kfsw_ftp_init (void)
 
int kfsw_ftp_start (void)
 
int kfsw_ftp_stop (void)
 
bool kfsw_ftp_is_started (void)
 
int kfsw_ftp_validate_path (const char *path, bool allow_root)
 
int kfsw_ftp_list (uint16_t node, const char *path, kfsw_ftp_list_visitor_t visitor, void *context)
 
int kfsw_ftp_stat (uint16_t node, const char *path, struct kfsw_ftp_stat *info)
 
int kfsw_ftp_mkdir (uint16_t node, const char *path)
 
int kfsw_ftp_put (uint16_t node, const char *local_path, const char *remote_path, struct kfsw_ftp_transfer_result *result)
 
int kfsw_ftp_get (uint16_t node, const char *remote_path, const char *local_path, struct kfsw_ftp_transfer_result *result)
 

Variables

const struct kfsw_param_definition_set kfsw_ftp_param_definitions
 

Description

Sandboxed CSP/RDP file-transfer API.

Macro Documentation

◆ KFSW_FTP_PARAM_TABLE_ID

#define KFSW_FTP_PARAM_TABLE_ID   29U

Parameter table of this service, in the service band.

◆ KFSW_FTP_PARAM_TABLE_NAME

#define KFSW_FTP_PARAM_TABLE_NAME   "ftp"

Parameter table name.

◆ KFSW_FTP_READONLY_ROOT

#define KFSW_FTP_READONLY_ROOT   "/kfsw/hk"

A second, read-only root with the housekeeping files.

Writes, renames, deletes and mkdir under it are refused.

Enumeration Documentation

◆ kfsw_event_ftp_id

Event IDs of the file transfer service.

IDs are never reused. Transfer payload: peer node as big-endian u16, then the byte count and CRC32 as big-endian u32.

Enumerator
KFSW_EVENT_FTP_PUT_DONE 

An upload committed on the peer.

KFSW_EVENT_FTP_GET_DONE 

A download committed locally.

KFSW_EVENT_FTP_TRANSFER_FAILED 

A transfer failed.

Payload: peer node u16, then the errno as i32.

Function Documentation

◆ kfsw_ftp_check_chunk_size()

int kfsw_ftp_check_chunk_size ( uint16_t  chunk_size)

Whether a chunk size would be accepted, without applying it.

◆ kfsw_ftp_check_timeout_ms()

int kfsw_ftp_check_timeout_ms ( uint32_t  timeout_ms)

Whether a timeout would be accepted, without applying it.

◆ kfsw_ftp_get()

int kfsw_ftp_get ( uint16_t  node,
const char *  remote_path,
const char *  local_path,
struct kfsw_ftp_transfer_result *  result 
)

Stream a remote FTP-root file to a local FTP-root path.

Transfers are between two nodes; this node's own CSP address returns -ENOTSUP.

◆ kfsw_ftp_get_chunk_size()

uint16_t kfsw_ftp_get_chunk_size ( void  )

Bytes of file data carried per message.

◆ kfsw_ftp_get_stats()

int kfsw_ftp_get_stats ( struct kfsw_ftp_stats *  stats)

Read the lifetime totals.

Returns -EINVAL for a NULL destination.

◆ kfsw_ftp_get_timeout_ms()

uint32_t kfsw_ftp_get_timeout_ms ( void  )

Reply timeout used by the next transfer; a running one keeps its value.

◆ kfsw_ftp_init()

int kfsw_ftp_init ( void  )

Prepare the sandboxed local file-transfer root after storage is mounted.

◆ kfsw_ftp_is_started()

bool kfsw_ftp_is_started ( void  )

Return whether the local service is initialized and accepting connections.

◆ kfsw_ftp_list()

int kfsw_ftp_list ( uint16_t  node,
const char *  path,
kfsw_ftp_list_visitor_t  visitor,
void *  context 
)

List one directory.

Paths are relative to the FTP root.

A request addressed to this node's own CSP address is served directly from local storage, without a connection or a route.

◆ kfsw_ftp_mkdir()

int kfsw_ftp_mkdir ( uint16_t  node,
const char *  path 
)

Create one directory.

Parent directories must already exist.

A request addressed to this node's own CSP address is served locally.

◆ kfsw_ftp_put()

int kfsw_ftp_put ( uint16_t  node,
const char *  local_path,
const char *  remote_path,
struct kfsw_ftp_transfer_result *  result 
)

Stream a local FTP-root file to a remote FTP-root path.

Transfers are between two nodes; this node's own CSP address returns -ENOTSUP.

◆ kfsw_ftp_set_chunk_size()

int kfsw_ftp_set_chunk_size ( uint16_t  chunk_size)

Change how much file data each message carries.

Must fit the build-time buffer. Smaller chunks may help on lossy links.

Return values
0Applied to the next transfer.
-ERANGEZero, or larger than KFSW_FTP_CHUNK_SIZE.

◆ kfsw_ftp_set_timeout_ms()

int kfsw_ftp_set_timeout_ms ( uint32_t  timeout_ms)

Change the reply timeout used by new transfers.

Return values
0Applied to the next transfer.
-ERANGEOutside the range the composition could have been built with.

◆ kfsw_ftp_start()

int kfsw_ftp_start ( void  )

Bind the RDP/CRC32 CSP endpoint and start the static server threads.

◆ kfsw_ftp_stat()

int kfsw_ftp_stat ( uint16_t  node,
const char *  path,
struct kfsw_ftp_stat *  info 
)

Return file/directory metadata and a file CRC32.

A request addressed to this node's own CSP address is served locally.

◆ kfsw_ftp_stop()

int kfsw_ftp_stop ( void  )

Stop accepting new transfers and close the server endpoint.

◆ kfsw_ftp_validate_path()

int kfsw_ftp_validate_path ( const char *  path,
bool  allow_root 
)

Validate a virtual path using the same rules as the client and server.

Variable Documentation

◆ kfsw_ftp_param_definitions

const struct kfsw_param_definition_set kfsw_ftp_param_definitions
extern

File-transfer counters and settings.