Authenticate admission fixture members for radio interaction

This commit is contained in:
evgeny committed 2026-10-26 14:56:54 +01:00
1 parent 56a06da35f
commit 9838384d43
1 file changed
+25 -2
+25 -2
View File
@@ -77,7 +77,7 @@ static void admission_event(struct UTUN_INSTANCE *inst, int type, const uint8_t
ev->count++; break;
case CHAT_EVT_CALL_ERROR: ev->count++; ev->errors++; break;
case CHAT_EVT_RADIO_CALL:
if (length == 26 && data[24] == RADIO_CALL_FINISHED) { ev->radio_finished++; ev->radio_reason = data[25]; }
if (length == 27 && data[24] == RADIO_CALL_FINISHED) { ev->radio_finished++; ev->radio_reason = data[25]; }
break;
default: break;
}
@@ -91,6 +91,26 @@ static unsigned admission_live(struct UTUN_INSTANCE *inst) {
return count;
}
/* Рация требует проверенного членства: дополняем старый call fixture join/update/tree подписями. */
static int admission_members(struct admission_test *t) {
uint64_t version = (uint64_t)ntp_time_get_seconds(t->inst[0]) + 1;
for (int member = 0; member < 2; member++) {
struct UTUN_INSTANCE *inst = t->inst[member];
uint8_t body[MS_USERINFO_MAX + 112], join[64], tree[64], update[64];
const char *userinfo = member ? "{\"name\":\"B\"}" : "{\"name\":\"A\"}";
int size = member_sync_build_join_msg(g_sh.ch_x_pub, g_sh.ch_ed_pub, inst->node_id,
inst->my_keys.public_key, version, body, sizeof(body));
ADMISSION_CHECK(t, size > 0 && sc_ed25519_sign(inst->my_ed25519_privkey, body, (size_t)size, join) == SC_OK);
ADMISSION_CHECK(t, member_sync_sign_pubkey(g_sh.ch_ed_priv, inst->my_keys.public_key, tree) == 0);
size = member_sync_build_update_msg(join, version + 1, userinfo, body, sizeof(body));
ADMISSION_CHECK(t, size > 0 && sc_ed25519_sign(inst->my_ed25519_privkey, body, (size_t)size, update) == SC_OK);
for (int destination = 0; destination < 2; destination++)
ADMISSION_CHECK(t, member_sync_put(t->inst[destination], CH_ID, inst->node_id, inst->my_keys.public_key,
inst->my_ed25519_pubkey, join, version, update, version + 1, userinfo, NULL, NULL, 0, 0, tree) >= 0);
}
return 1;
}
/* Отказ не меняет существующий звонок, CM, таймеры, очередь и счётчики. */
static int admission_attempt(struct admission_test *t, int index, uint64_t original, const char *ch, uint64_t peer,
uint64_t requested, int busy_event) {
@@ -153,7 +173,9 @@ static int admission_step(struct admission_test *t) {
switch (t->phase) {
case 0:
if (!conn_up(a, b->node_id) || !conn_up(b, a->node_id)) return 1;
do_setup(a, IDX_A); do_setup(b, IDX_B); t->phase++; break;
do_setup(a, IDX_A); do_setup(b, IDX_B);
ADMISSION_CHECK(t, admission_members(t));
t->phase++; break;
case 1:
if (!bgp_has(a, b->node_id) || !bgp_has(b, a->node_id)) return 1;
for (int i = 0; i < 2; i++) {
@@ -265,6 +287,7 @@ static void admission_tick(void *arg) {
int main(void) {
debug_config_init(); debug_set_level(DEBUG_LEVEL_ERROR);
debug_set_category_level(DEBUG_CATEGORY_CALL, DEBUG_LEVEL_INFO);
debug_set_category_level(DEBUG_CATEGORY_RADIO, DEBUG_LEVEL_INFO);
utun_instance_set_tun_init_enabled(0); test_clock_init(TICK_TB); test_clock_sync_wall_time();
size_t allocated = u_get_allocated_count();
char dir[512] = "/tmp/utun_call_admission_XXXXXX";