You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.3 KiB
63 lines
2.3 KiB
#ifndef MEMBER_SYNC_H |
|
#define MEMBER_SYNC_H |
|
|
|
#ifdef __cplusplus |
|
extern "C" { |
|
#endif |
|
|
|
#include <stdint.h> |
|
#include <stddef.h> |
|
|
|
struct UTUN_INSTANCE; |
|
|
|
#define ETCP_RT_ID_MEMBER_SYNC 0x31 |
|
#define MS_MAX_BATCH 32 |
|
#define MS_MAX_LEVEL 5 |
|
#define MS_BUCKETS 32 |
|
#define MS_HASH_SIZE 32 |
|
|
|
/* Wire message types (etcp_router service 0x31) */ |
|
#define MS_MSG_HASHES 0x01 |
|
#define MS_MSG_REQUEST 0x02 |
|
#define MS_MSG_BATCH 0x03 |
|
|
|
/* === Initialization === */ |
|
int member_sync_init(struct UTUN_INSTANCE* inst); |
|
void member_sync_destroy(struct UTUN_INSTANCE* inst); |
|
|
|
/* === CRUD (DB write + tree recompute) === */ |
|
int member_sync_put(struct UTUN_INSTANCE* inst, const char* ch_id, |
|
uint64_t member_id, const uint8_t* x25519, |
|
const uint8_t* ed25519, const uint8_t* join_sig, |
|
const uint8_t* addrs_data, int addr_count); |
|
int member_sync_del(struct UTUN_INSTANCE* inst, const char* ch_id, uint64_t member_id); |
|
int member_sync_count(struct UTUN_INSTANCE* inst, const char* ch_id); |
|
|
|
/* === Online status (updates nodes.online + recomputes tree path) === */ |
|
void member_sync_set_online(struct UTUN_INSTANCE* inst, uint64_t node_id, int online); |
|
|
|
/* === Protocol primitives === */ |
|
int member_sync_get_level_hashes(struct UTUN_INSTANCE* inst, |
|
const char* ch_id, uint8_t level, |
|
uint64_t prefix, uint8_t prefix_bytes, |
|
uint32_t* bitmap, uint8_t hashes[MS_BUCKETS][MS_HASH_SIZE]); |
|
int member_sync_get_bucket_members(struct UTUN_INSTANCE* inst, |
|
const char* ch_id, uint8_t level, |
|
uint64_t prefix, uint8_t prefix_bytes, |
|
uint8_t* buf, size_t* len); |
|
|
|
/* === Background consistency check === */ |
|
int member_sync_bg_check(struct UTUN_INSTANCE* inst, const char* ch_id); |
|
|
|
/* === Sync sessions === */ |
|
void member_sync_start(struct UTUN_INSTANCE* inst, uint64_t peer, const char* ch_id); |
|
void member_sync_cancel_peer(struct UTUN_INSTANCE* inst, uint64_t peer); |
|
|
|
/* === Test helper === */ |
|
const uint8_t* member_sync_get_hash(struct UTUN_INSTANCE* inst, |
|
const char* ch_id, uint8_t level, uint64_t prefix64); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
#endif /* MEMBER_SYNC_H */
|
|
|