Refresh both AGENTS guides and clarify module purpose, usage, ownership, threading, return values and wire formats in headers. Remove the unused timeout_heap freed_count field and unimplemented getter.
47 lines
1.9 KiB
C
47 lines
1.9 KiB
C
/* broadcast — рассылка данных соседям topo-группы с пересылкой и дедупликацией UUID.
|
|
* Контекст и кеш увиденных UUID принадлежат группе; TTL — срок хранения UUID, не счётчик сетевых хопов.
|
|
* init_instance регистрирует общий ETCP-диспетчер, init(group) создаёт состояние отдельной группы.
|
|
* Все вызовы/callbacks — uasync-поток; recv получает заимствованные uuid/data только на время callback.
|
|
* send копирует данные и возвращает 0 / -1; 0 не подтверждает доставку каждому участнику. */
|
|
#ifndef BROADCAST_H
|
|
#define BROADCAST_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
struct TOPO_GROUP;
|
|
struct UTUN_INSTANCE;
|
|
|
|
#define BROADCAST_MAX_DATA 1600
|
|
#define BROADCAST_UUID_SIZE 16
|
|
#define BROADCAST_CLEANUP_INTERVAL_TB 600000 // 1 минута
|
|
#define BROADCAST_TTL_TB 1200000 // 2 минуты
|
|
|
|
typedef void (*broadcast_recv_fn)(const uint8_t* uuid, const uint8_t* data, uint16_t data_len, void* arg);
|
|
|
|
struct broadcast_cbk_entry {
|
|
broadcast_recv_fn fn;
|
|
void* arg;
|
|
struct broadcast_cbk_entry* next;
|
|
};
|
|
|
|
struct broadcast_ctx;
|
|
|
|
int broadcast_init(struct TOPO_GROUP* group);
|
|
void broadcast_destroy(struct TOPO_GROUP* group);
|
|
int broadcast_send(struct TOPO_GROUP* group, const uint8_t* data, uint16_t data_len);
|
|
void broadcast_add_cbk(struct TOPO_GROUP* group, broadcast_recv_fn fn, void* arg);
|
|
void broadcast_remove_cbk(struct TOPO_GROUP* group, broadcast_recv_fn fn, void* arg);
|
|
|
|
int broadcast_init_instance(struct UTUN_INSTANCE* instance);
|
|
void broadcast_destroy_instance(struct UTUN_INSTANCE* instance);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|