K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
Loading...
Searching...
No Matches

Public Headers

file  ftp.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_HK_PATH   "hk"
 
#define KFSW_FTP_BOOT_PATH   "boot"
 
#define KFSW_FTP_TMP_PATH   "tmp"
 
#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)
 
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_remove (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 file transfer over CSP/RDP with CRC32 validation.

kfsw_ftp_init() prepares storage. kfsw_ftp_start() binds the server after storage and the CSP router are ready. PUT and GET stream bounded chunks and atomically commit received files.

kfsw_ftp_list(), kfsw_ftp_stat(), kfsw_ftp_mkdir() and kfsw_ftp_remove() accept this node's own CSP address and then run against local storage without a connection. The shell exposes removal as ftp rm. kfsw_ftp_put() and kfsw_ftp_get() move a file between two nodes and return -ENOTSUP for the local address.

Macro Documentation

◆ KFSW_FTP_BOOT_PATH

#define KFSW_FTP_BOOT_PATH   "boot"

#include <ftp.h>

Firmware slots, read-only, with CONFIG_KFSW_FWU_FILES.

◆ KFSW_FTP_HK_PATH

#define KFSW_FTP_HK_PATH   "hk"

#include <ftp.h>

Housekeeping sample files, read-only.

◆ KFSW_FTP_PARAM_TABLE_ID

#define KFSW_FTP_PARAM_TABLE_ID   29U

#include <ftp.h>

Parameter table of this service, in the service band.

◆ KFSW_FTP_PARAM_TABLE_NAME

#define KFSW_FTP_PARAM_TABLE_NAME   "ftp"

#include <ftp.h>

Parameter table name.

◆ KFSW_FTP_READONLY_ROOT

#define KFSW_FTP_READONLY_ROOT   "/kfsw/hk"

#include <ftp.h>

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

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

◆ KFSW_FTP_TMP_PATH

#define KFSW_FTP_TMP_PATH   "tmp"

#include <ftp.h>

RAM scratch volume, writable and empty after every boot, with CONFIG_KFSW_STORAGE_TMP.

Enumeration Documentation

◆ kfsw_event_ftp_id

#include <ftp.h>

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)

#include <ftp.h>

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)

#include <ftp.h>

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 
)

#include <ftp.h>

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. Interrupted downloads continue in the same way as uploads, with the partial kept on this node.

◆ kfsw_ftp_get_chunk_size()

uint16_t kfsw_ftp_get_chunk_size ( void  )

#include <ftp.h>

Bytes of file data carried per message.

◆ kfsw_ftp_get_stats()

int kfsw_ftp_get_stats ( struct kfsw_ftp_stats *  stats)

#include <ftp.h>

Read the lifetime totals.

Returns -EINVAL for a NULL destination.

◆ kfsw_ftp_get_timeout_ms()

uint32_t kfsw_ftp_get_timeout_ms ( void  )

#include <ftp.h>

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

◆ kfsw_ftp_init()

int kfsw_ftp_init ( void  )

#include <ftp.h>

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

◆ kfsw_ftp_is_started()

bool kfsw_ftp_is_started ( void  )

#include <ftp.h>

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 
)

#include <ftp.h>

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 
)

#include <ftp.h>

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 
)

#include <ftp.h>

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.

An interrupted transfer leaves a partial file on the receiving node, and the next call for the same file continues from it instead of starting again. The partial is only continued when it belongs to this same content.

◆ kfsw_ftp_remove()

int kfsw_ftp_remove ( uint16_t  node,
const char *  path 
)

#include <ftp.h>

Remove one file or empty directory.

Directories with entries are refused.

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

◆ kfsw_ftp_set_chunk_size()

int kfsw_ftp_set_chunk_size ( uint16_t  chunk_size)

#include <ftp.h>

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)

#include <ftp.h>

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  )

#include <ftp.h>

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 
)

#include <ftp.h>

Return file/directory metadata and a file CRC32.

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

◆ kfsw_ftp_validate_path()

int kfsw_ftp_validate_path ( const char *  path,
bool  allow_root 
)

#include <ftp.h>

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

#include <ftp.h>

File-transfer counters and settings.