Lines Matching refs:net_idx
64 .net_idx = BT_MESH_KEY_UNUSED,
75 static void clear_net_key(uint16_t net_idx) in clear_net_key() argument
80 LOG_DBG("NetKeyIndex 0x%03x", net_idx); in clear_net_key()
82 snprintk(path, sizeof(path), "bt/mesh/NetKey/%x", net_idx); in clear_net_key()
85 LOG_ERR("Failed to clear NetKeyIndex 0x%03x", net_idx); in clear_net_key()
87 LOG_DBG("Cleared NetKeyIndex 0x%03x", net_idx); in clear_net_key()
91 static void store_subnet(uint16_t net_idx) in store_subnet() argument
98 sub = bt_mesh_subnet_get(net_idx); in store_subnet()
100 LOG_WRN("NetKeyIndex 0x%03x not found", net_idx); in store_subnet()
104 LOG_DBG("NetKeyIndex 0x%03x", net_idx); in store_subnet()
106 snprintk(path, sizeof(path), "bt/mesh/NetKey/%x", net_idx); in store_subnet()
161 static void update_subnet_settings(uint16_t net_idx, bool store) in update_subnet_settings() argument
166 LOG_DBG("NetKeyIndex 0x%03x", net_idx); in update_subnet_settings()
168 update = net_key_update_find(net_idx, &free_slot); in update_subnet_settings()
178 store_subnet(net_idx); in update_subnet_settings()
180 clear_net_key(net_idx); in update_subnet_settings()
186 free_slot->key_idx = net_idx; in update_subnet_settings()
192 void bt_mesh_subnet_store(uint16_t net_idx) in bt_mesh_subnet_store() argument
194 update_subnet_settings(net_idx, true); in bt_mesh_subnet_store()
243 bt_mesh_subnet_store(sub->net_idx); in key_refresh()
264 static struct bt_mesh_subnet *subnet_alloc(uint16_t net_idx) in subnet_alloc() argument
270 if (subnets[i].net_idx == net_idx) { in subnet_alloc()
274 if (!sub && subnets[i].net_idx == BT_MESH_KEY_UNUSED) { in subnet_alloc()
285 update_subnet_settings(sub->net_idx, false); in subnet_del()
294 bt_mesh_net_loopback_clear(sub->net_idx); in subnet_del()
298 sub->net_idx = BT_MESH_KEY_UNUSED; in subnet_del()
371 uint8_t bt_mesh_subnet_add(uint16_t net_idx, const uint8_t key[16]) in bt_mesh_subnet_add() argument
376 LOG_DBG("0x%03x", net_idx); in bt_mesh_subnet_add()
378 sub = subnet_alloc(net_idx); in bt_mesh_subnet_add()
383 if (sub->net_idx == net_idx) { in bt_mesh_subnet_add()
396 sub->net_idx = net_idx; in bt_mesh_subnet_add()
409 bt_mesh_subnet_store(sub->net_idx); in bt_mesh_subnet_add()
415 bool bt_mesh_subnet_exists(uint16_t net_idx) in bt_mesh_subnet_exists() argument
417 return !!bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_exists()
420 uint8_t bt_mesh_subnet_update(uint16_t net_idx, const uint8_t key[16]) in bt_mesh_subnet_update() argument
425 LOG_DBG("0x%03x", net_idx); in bt_mesh_subnet_update()
427 sub = bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_update()
464 uint8_t bt_mesh_subnet_del(uint16_t net_idx) in bt_mesh_subnet_del() argument
468 LOG_DBG("0x%03x", net_idx); in bt_mesh_subnet_del()
470 sub = bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_del()
511 uint8_t bt_mesh_subnet_kr_phase_set(uint16_t net_idx, uint8_t *phase) in bt_mesh_subnet_kr_phase_set() argument
522 LOG_DBG("0x%03x", net_idx); in bt_mesh_subnet_kr_phase_set()
524 sub = bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_kr_phase_set()
550 uint8_t bt_mesh_subnet_kr_phase_get(uint16_t net_idx, uint8_t *phase) in bt_mesh_subnet_kr_phase_get() argument
554 sub = bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_kr_phase_get()
565 uint8_t bt_mesh_subnet_node_id_set(uint16_t net_idx, in bt_mesh_subnet_node_id_set() argument
574 sub = bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_node_id_set()
588 if (subnets[i].net_idx != BT_MESH_KEY_UNUSED && in bt_mesh_subnet_node_id_set()
607 uint8_t bt_mesh_subnet_node_id_get(uint16_t net_idx, in bt_mesh_subnet_node_id_get() argument
612 sub = bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_node_id_get()
627 uint8_t bt_mesh_subnet_priv_node_id_set(uint16_t net_idx, in bt_mesh_subnet_priv_node_id_set() argument
636 sub = bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_priv_node_id_set()
651 if (subnets[i].net_idx != BT_MESH_KEY_UNUSED && in bt_mesh_subnet_priv_node_id_set()
670 uint8_t bt_mesh_subnet_priv_node_id_get(uint16_t net_idx, in bt_mesh_subnet_priv_node_id_get() argument
675 sub = bt_mesh_subnet_get(net_idx); in bt_mesh_subnet_priv_node_id_get()
717 if (sub->net_idx == BT_MESH_KEY_UNUSED) { in bt_mesh_subnets_get()
730 net_idxs[count++] = sub->net_idx; in bt_mesh_subnets_get()
736 struct bt_mesh_subnet *bt_mesh_subnet_get(uint16_t net_idx) in bt_mesh_subnet_get() argument
741 if (sub->net_idx == net_idx) { in bt_mesh_subnet_get()
768 int bt_mesh_subnet_set(uint16_t net_idx, uint8_t kr_phase, const struct bt_mesh_key *old_key, in bt_mesh_subnet_set() argument
774 sub = subnet_alloc(net_idx); in bt_mesh_subnet_set()
779 if (sub->net_idx == net_idx) { in bt_mesh_subnet_set()
797 sub->net_idx = net_idx; in bt_mesh_subnet_set()
816 if (subnets[i].net_idx == BT_MESH_KEY_UNUSED) { in bt_mesh_subnet_find()
833 if (subnets[i].net_idx == BT_MESH_KEY_UNUSED) { in bt_mesh_subnet_foreach()
858 if (sub->net_idx != BT_MESH_KEY_UNUSED) { in bt_mesh_subnet_next()
876 if (sub->net_idx != BT_MESH_KEY_UNUSED) { in bt_mesh_net_keys_reset()
905 rx->ctx.net_idx = rx->sub->net_idx; in bt_mesh_net_cred_find()
936 rx->ctx.net_idx = rx->sub->net_idx; in bt_mesh_net_cred_find()
945 if (rx->sub->net_idx == BT_MESH_KEY_UNUSED) { in bt_mesh_net_cred_find()
957 rx->ctx.net_idx = rx->sub->net_idx; in bt_mesh_net_cred_find()
972 uint16_t net_idx; in net_key_set() local
979 net_idx = strtol(name, NULL, 16); in net_key_set()
991 LOG_DBG("NetKeyIndex 0x%03x recovered from storage", net_idx); in net_key_set()
994 net_idx, key.kr_phase, &val[0], in net_key_set()