From 7ed1a9b16794d33826b7e93d8e907357cd1dad6b Mon Sep 17 00:00:00 2001 From: evgeny Date: Mon, 19 Oct 2026 14:46:47 +0200 Subject: [PATCH] Carry phone presence in existing BGP and member flag bytes --- src/chat/chat_member.h | 2 ++ src/routing_layer/topo_group.c | 1 + src/routing_layer/topo_node.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/chat/chat_member.h b/src/chat/chat_member.h index ce55230f..b0051cea 100644 --- a/src/chat/chat_member.h +++ b/src/chat/chat_member.h @@ -35,6 +35,8 @@ extern "C" { #define CHAT_MEMBER_FLAG_DELETED 0x08 #define CHAT_MEMBER_FLAG_RADIO 0x10 #define CHAT_MEMBER_FLAG_RADIO_MUTED 0x20 /* локальное отключение голоса участника */ +#define CHAT_MEMBER_FLAG_PHONE_KNOWN 0x40 /* опубликовано состояние телефонной занятости */ +#define CHAT_MEMBER_FLAG_PHONE_BUSY 0x80 /* занят звонком; цвет трубки в интерфейсе */ #define CHAT_MEMBER_DISPLAY_SIZE 158 diff --git a/src/routing_layer/topo_group.c b/src/routing_layer/topo_group.c index c529e19c..d2a265fa 100644 --- a/src/routing_layer/topo_group.c +++ b/src/routing_layer/topo_group.c @@ -1383,6 +1383,7 @@ int topo_group_process_nodeinfo(struct TOPO_GROUP* group, struct ETCP_CONN* from nodeinfo1->paths = paths; nodeinfo1->last_ver = new_ver; nodeinfo1->last_timestamp = incoming_timestamp; nodeinfo1->radio = (ni->flags & TOPO_FLAG_RADIO) ? 1 : 0; + nodeinfo1->phone_status = ni->flags & (TOPO_FLAG_PHONE_KNOWN | TOPO_FLAG_PHONE_BUSY); uint64_t hop_list[MAX_HOPS]; if (new_hop_count > 0) memcpy(hop_list, new_hop_list, new_hop_count * 8); diff --git a/src/routing_layer/topo_node.c b/src/routing_layer/topo_node.c index 4a3e72fe..f0233dc4 100644 --- a/src/routing_layer/topo_node.c +++ b/src/routing_layer/topo_node.c @@ -18,6 +18,7 @@ #include "../transport_layer/etcp_connections.h" #include "../lib/u_async.h" #include "../ntp_time.h" +#include "../call/call.h" /* Инкремент refcount узла: держит TOPO_NODE живым, пока на него ссылаются группы. */ void topo_node_ref(struct TOPO_NODE* ni) { @@ -526,6 +527,7 @@ int topo_node_serialize(struct TOPO_NODE* ni, struct TOPO_GROUP_NODE* nq, msg.client_activity = ni->client_activity; msg.cumulative_rtt = cumulative_rtt; if (nq->radio) msg.flags |= TOPO_FLAG_RADIO; + msg.flags |= nq->phone_status; size_t total = TOPOMSG_NODE_HDR_SIZE + (size_t)topo_node_dyn_size(&msg); if (total > out_max) return -1; @@ -1032,6 +1034,7 @@ int topo_group_update_my_nodeinfo(struct UTUN_INSTANCE* instance, struct TOPO_GR || (oni->client_type != instance->client_type) || (oni->client_activity != instance->client_activity) || (group->local_node->radio != group->radio_active) + || (group->local_node->phone_status != call_phone_status(instance)) || (memcmp(oni->ed25519_public_key, group->ed25519_public_key, SC_PUBKEY_SIZE) != 0); } } @@ -1065,6 +1068,7 @@ int topo_group_update_my_nodeinfo(struct UTUN_INSTANCE* instance, struct TOPO_GR ni->client_type = instance->client_type; ni->client_activity = instance->client_activity; lq->radio = group->radio_active; + lq->phone_status = call_phone_status(instance); memcpy(ni->public_key, instance->my_keys.public_key, SC_PUBKEY_SIZE); memcpy(ni->ed25519_public_key, group->ed25519_public_key, SC_PUBKEY_SIZE); ni->node_name = u_strdup(instance->name);