#ifndef CST_DISCOVER_H #define CST_DISCOVER_H #include #ifdef __cplusplus extern "C" { #endif /* Same-Realm peer discovery: UDP multicast beacon + local instance file. * mDNS (_cst-parliament._tcp) can replace the beacon later without changing * this surface. */ #define CST_DISCOVER_PORT 45454 #define CST_DISCOVER_GROUP "239.255.77.77" typedef struct { char instance_id[64]; char realm_fp[33]; char name[64]; char host[64]; int port; } cst_peer_info_t; typedef struct cst_discover cst_discover_t; /* Advertise this instance and collect peers that share realm_fp. * peer_port is the TCP parliament port peers should dial. */ cst_discover_t *cst_discover_start(const char *realm_fp, const char *instance_id, const char *name, int peer_port); void cst_discover_stop(cst_discover_t *d); /* Copy up to max known peers (excluding self). Returns count. */ int cst_discover_peers(cst_discover_t *d, cst_peer_info_t *out, int max); /* Same-machine registry under /realm/local-instances.json. */ int cst_discover_local_put(const char *realm_fp, const char *instance_id, const char *name, int peer_port); int cst_discover_local_del(const char *instance_id); int cst_discover_local_list(const char *realm_fp, cst_peer_info_t *out, int max); #ifdef __cplusplus } #endif #endif