55 lines
2.3 KiB
C
55 lines
2.3 KiB
C
/*
|
|
* C ABI between bunshin (Rust) and the microReticulum carrier shim.
|
|
*
|
|
* The shim owns the Reticulum run loop on a dedicated thread; every callback
|
|
* below fires on that thread. link_id is always 16 bytes.
|
|
*/
|
|
#ifndef SMOLMAIL_RNS_H
|
|
#define SMOLMAIL_RNS_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Implemented in smolmail_rns.cpp, called from src/rns.rs.
|
|
* identity: 64 bytes, x25519 private (32) || ed25519 private (32), the same
|
|
* layout Identity::to_file writes and load_private_key expects.
|
|
* udp_forward_host may be NULL: with no forward target the interface sends
|
|
* to the source address of the last datagram received.
|
|
* Returns 0 on success, negative on failure. */
|
|
int smolmail_rns_start(const uint8_t *identity,
|
|
const char *storage_dir,
|
|
const char *udp_listen_host, uint16_t udp_listen_port,
|
|
const char *udp_forward_host, uint16_t udp_forward_port,
|
|
uint8_t *destination_hash_out);
|
|
|
|
/* Pure computation, no Reticulum state: the 16-byte destination hash of
|
|
* smolmail.server under this identity. microReticulum derives the identity's
|
|
* x25519 public key with an unclamped scalar multiplication, which differs
|
|
* from RFC 7748, so the hash must come from the library itself rather than
|
|
* an independent Rust derivation. */
|
|
int smolmail_rns_destination_hash(const uint8_t *identity,
|
|
uint8_t *destination_hash_out);
|
|
|
|
/* Implemented in src/rns.rs, called from the shim on the Reticulum loop
|
|
* thread. A request is `op u8 || body` (RNS.md sec 1); the response placed
|
|
* into the slot is `status u8 || payload`. on_request returns the response
|
|
* length and leaves the bytes in the slot; the shim must copy them out with
|
|
* take_response before the next on_request call. */
|
|
size_t smolmail_rns_on_request(const uint8_t *request, size_t request_len,
|
|
const uint8_t *link_id);
|
|
size_t smolmail_rns_take_response(uint8_t *out, size_t cap);
|
|
|
|
/* 0 = link admitted, 1 = over the concurrent-link cap (the shim tears the
|
|
* link down after the current loop iteration). */
|
|
int smolmail_rns_on_link_opened(const uint8_t *link_id);
|
|
void smolmail_rns_on_link_closed(const uint8_t *link_id);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* SMOLMAIL_RNS_H */
|