Lines Matching refs:sub
278 struct bt_mesh_cdb_subnet *sub; in cdb_subnet_set() local
290 sub = bt_mesh_cdb_subnet_get(net_idx); in cdb_subnet_set()
294 if (!sub) { in cdb_subnet_set()
300 bt_mesh_cdb_subnet_del(sub, false); in cdb_subnet_set()
316 if (sub) { in cdb_subnet_set()
319 sub->kr_phase = key.kr_phase; in cdb_subnet_set()
320 bt_mesh_key_assign(&sub->keys[0].net_key, &tmp[0]); in cdb_subnet_set()
321 bt_mesh_key_assign(&sub->keys[1].net_key, &tmp[1]); in cdb_subnet_set()
326 sub = bt_mesh_cdb_subnet_alloc(net_idx); in cdb_subnet_set()
327 if (!sub) { in cdb_subnet_set()
332 sub->kr_phase = key.kr_phase; in cdb_subnet_set()
333 bt_mesh_key_assign(&sub->keys[0].net_key, &tmp[0]); in cdb_subnet_set()
334 bt_mesh_key_assign(&sub->keys[1].net_key, &tmp[1]); in cdb_subnet_set()
483 static void store_cdb_subnet(const struct bt_mesh_cdb_subnet *sub) in store_cdb_subnet() argument
489 LOG_DBG("NetKeyIndex 0x%03x NetKey %s", sub->net_idx, in store_cdb_subnet()
490 bt_hex(&sub->keys[0].net_key, sizeof(struct bt_mesh_key))); in store_cdb_subnet()
492 memcpy(&key.val[0], &sub->keys[0].net_key, sizeof(struct bt_mesh_key)); in store_cdb_subnet()
493 memcpy(&key.val[1], &sub->keys[1].net_key, sizeof(struct bt_mesh_key)); in store_cdb_subnet()
495 key.kr_phase = sub->kr_phase; in store_cdb_subnet()
497 snprintk(path, sizeof(path), "bt/mesh/cdb/Subnet/%x", sub->net_idx); in store_cdb_subnet()
652 static void update_cdb_subnet_settings(const struct bt_mesh_cdb_subnet *sub, in update_cdb_subnet_settings() argument
658 LOG_DBG("NetKeyIndex 0x%03x", sub->net_idx); in update_cdb_subnet_settings()
660 update = cdb_key_update_find(false, sub->net_idx, &free_slot); in update_cdb_subnet_settings()
669 store_cdb_subnet(sub); in update_cdb_subnet_settings()
671 clear_cdb_subnet(sub->net_idx); in update_cdb_subnet_settings()
677 free_slot->key_idx = sub->net_idx; in update_cdb_subnet_settings()
734 struct bt_mesh_cdb_subnet *sub; in bt_mesh_cdb_create() local
742 sub = bt_mesh_cdb_subnet_alloc(BT_MESH_KEY_PRIMARY); in bt_mesh_cdb_create()
743 if (sub == NULL) { in bt_mesh_cdb_create()
747 err = bt_mesh_key_import(BT_MESH_KEY_TYPE_NET, key, &sub->keys[0].net_key); in bt_mesh_cdb_create()
757 update_cdb_subnet_settings(sub, true); in bt_mesh_cdb_create()
814 struct bt_mesh_cdb_subnet *sub; in bt_mesh_cdb_subnet_alloc() local
822 sub = &bt_mesh_cdb.subnets[i]; in bt_mesh_cdb_subnet_alloc()
824 if (sub->net_idx != BT_MESH_KEY_UNUSED) { in bt_mesh_cdb_subnet_alloc()
828 sub->net_idx = net_idx; in bt_mesh_cdb_subnet_alloc()
830 return sub; in bt_mesh_cdb_subnet_alloc()
836 void bt_mesh_cdb_subnet_del(struct bt_mesh_cdb_subnet *sub, bool store) in bt_mesh_cdb_subnet_del() argument
838 LOG_DBG("NetIdx 0x%03x store %u", sub->net_idx, store); in bt_mesh_cdb_subnet_del()
841 update_cdb_subnet_settings(sub, false); in bt_mesh_cdb_subnet_del()
844 sub->net_idx = BT_MESH_KEY_UNUSED; in bt_mesh_cdb_subnet_del()
845 bt_mesh_key_destroy(&sub->keys[0].net_key); in bt_mesh_cdb_subnet_del()
846 bt_mesh_key_destroy(&sub->keys[1].net_key); in bt_mesh_cdb_subnet_del()
847 memset(sub->keys, 0, sizeof(sub->keys)); in bt_mesh_cdb_subnet_del()
863 void bt_mesh_cdb_subnet_store(const struct bt_mesh_cdb_subnet *sub) in bt_mesh_cdb_subnet_store() argument
866 update_cdb_subnet_settings(sub, true); in bt_mesh_cdb_subnet_store()
870 uint8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub) in bt_mesh_cdb_subnet_flags() argument
874 if (sub && SUBNET_KEY_TX_IDX(sub)) { in bt_mesh_cdb_subnet_flags()
885 int bt_mesh_cdb_subnet_key_import(struct bt_mesh_cdb_subnet *sub, int key_idx, in bt_mesh_cdb_subnet_key_import() argument
888 if (!bt_mesh_key_compare(in, &sub->keys[key_idx].net_key)) { in bt_mesh_cdb_subnet_key_import()
892 bt_mesh_key_destroy(&sub->keys[key_idx].net_key); in bt_mesh_cdb_subnet_key_import()
894 return bt_mesh_key_import(BT_MESH_KEY_TYPE_NET, in, &sub->keys[key_idx].net_key); in bt_mesh_cdb_subnet_key_import()
897 int bt_mesh_cdb_subnet_key_export(const struct bt_mesh_cdb_subnet *sub, int key_idx, in bt_mesh_cdb_subnet_key_export() argument
900 return bt_mesh_key_export(out, &sub->keys[key_idx].net_key); in bt_mesh_cdb_subnet_key_export()
1204 struct bt_mesh_cdb_subnet *sub; in store_cdb_pending_keys() local
1206 sub = bt_mesh_cdb_subnet_get(update->key_idx); in store_cdb_pending_keys()
1207 if (sub) { in store_cdb_pending_keys()
1208 store_cdb_subnet(sub); in store_cdb_pending_keys()