Lines Matching refs:node

121 		struct bt_mesh_cdb_node *node = &bt_mesh_cdb.nodes[i];  in addr_is_free()  local
123 if (node->addr == BT_MESH_ADDR_UNASSIGNED) { in addr_is_free()
127 other_start = node->addr; in addr_is_free()
128 other_end = other_start + node->num_elem - 1; in addr_is_free()
216 struct bt_mesh_cdb_node *node; in cdb_node_set() local
233 node = bt_mesh_cdb_node_get(addr); in cdb_node_set()
234 if (node) { in cdb_node_set()
235 bt_mesh_cdb_node_del(node, false); in cdb_node_set()
247 node = bt_mesh_cdb_node_get(addr); in cdb_node_set()
248 if (!node) { in cdb_node_set()
249 node = bt_mesh_cdb_node_alloc(val.uuid, addr, val.num_elem, in cdb_node_set()
253 if (!node) { in cdb_node_set()
259 atomic_set_bit(node->flags, BT_MESH_CDB_NODE_CONFIGURED); in cdb_node_set()
262 memcpy(node->uuid, val.uuid, 16); in cdb_node_set()
268 bt_mesh_key_assign(&node->dev_key, &tmp); in cdb_node_set()
440 static void store_cdb_node(const struct bt_mesh_cdb_node *node) in store_cdb_node() argument
446 val.net_idx = node->net_idx; in store_cdb_node()
447 val.num_elem = node->num_elem; in store_cdb_node()
450 if (atomic_test_bit(node->flags, BT_MESH_CDB_NODE_CONFIGURED)) { in store_cdb_node()
454 memcpy(val.uuid, node->uuid, 16); in store_cdb_node()
455 memcpy(&val.dev_key, &node->dev_key, sizeof(struct bt_mesh_key)); in store_cdb_node()
457 snprintk(path, sizeof(path), "bt/mesh/cdb/Node/%x", node->addr); in store_cdb_node()
594 static void update_cdb_node_settings(const struct bt_mesh_cdb_node *node, in update_cdb_node_settings() argument
599 LOG_DBG("Node 0x%04x", node->addr); in update_cdb_node_settings()
601 update = cdb_node_update_find(node->addr, &free_slot); in update_cdb_node_settings()
610 store_cdb_node(node); in update_cdb_node_settings()
612 clear_cdb_node(node->addr); in update_cdb_node_settings()
617 free_slot->addr = node->addr; in update_cdb_node_settings()
914 struct bt_mesh_cdb_node *node = &bt_mesh_cdb.nodes[i]; in bt_mesh_cdb_node_alloc() local
916 if (node->addr == BT_MESH_ADDR_UNASSIGNED) { in bt_mesh_cdb_node_alloc()
917 memcpy(node->uuid, uuid, 16); in bt_mesh_cdb_node_alloc()
918 node->addr = addr; in bt_mesh_cdb_node_alloc()
919 node->num_elem = num_elem; in bt_mesh_cdb_node_alloc()
920 node->net_idx = net_idx; in bt_mesh_cdb_node_alloc()
921 atomic_set(node->flags, 0); in bt_mesh_cdb_node_alloc()
922 return node; in bt_mesh_cdb_node_alloc()
934 void bt_mesh_cdb_node_del(struct bt_mesh_cdb_node *node, bool store) in bt_mesh_cdb_node_del() argument
936 LOG_DBG("Node addr 0x%04x store %u", node->addr, store); in bt_mesh_cdb_node_del()
939 update_cdb_node_settings(node, false); in bt_mesh_cdb_node_del()
942 if (store && node->addr + node->num_elem > bt_mesh_cdb.lowest_avail_addr) { in bt_mesh_cdb_node_del()
943 bt_mesh_cdb.lowest_avail_addr = node->addr + node->num_elem; in bt_mesh_cdb_node_del()
950 node->addr = BT_MESH_ADDR_UNASSIGNED; in bt_mesh_cdb_node_del()
951 bt_mesh_key_destroy(&node->dev_key); in bt_mesh_cdb_node_del()
952 memset(&node->dev_key, 0, sizeof(node->dev_key)); in bt_mesh_cdb_node_del()
955 void bt_mesh_cdb_node_update(struct bt_mesh_cdb_node *node, uint16_t addr, in bt_mesh_cdb_node_update() argument
962 update_cdb_node_settings(node, false); in bt_mesh_cdb_node_update()
965 node->addr = addr; in bt_mesh_cdb_node_update()
966 node->num_elem = num_elem; in bt_mesh_cdb_node_update()
969 update_cdb_node_settings(node, true); in bt_mesh_cdb_node_update()
978 struct bt_mesh_cdb_node *node = &bt_mesh_cdb.nodes[i]; in bt_mesh_cdb_node_get() local
980 if (addr >= node->addr && in bt_mesh_cdb_node_get()
981 addr <= node->addr + node->num_elem - 1) { in bt_mesh_cdb_node_get()
982 return node; in bt_mesh_cdb_node_get()
989 void bt_mesh_cdb_node_store(const struct bt_mesh_cdb_node *node) in bt_mesh_cdb_node_store() argument
992 update_cdb_node_settings(node, true); in bt_mesh_cdb_node_store()
1012 int bt_mesh_cdb_node_key_import(struct bt_mesh_cdb_node *node, const uint8_t in[16]) in bt_mesh_cdb_node_key_import() argument
1014 if (!bt_mesh_key_compare(in, &node->dev_key)) { in bt_mesh_cdb_node_key_import()
1018 bt_mesh_key_destroy(&node->dev_key); in bt_mesh_cdb_node_key_import()
1020 return bt_mesh_key_import(BT_MESH_KEY_TYPE_DEV, in, &node->dev_key); in bt_mesh_cdb_node_key_import()
1023 int bt_mesh_cdb_node_key_export(const struct bt_mesh_cdb_node *node, uint8_t out[16]) in bt_mesh_cdb_node_key_export() argument
1025 return bt_mesh_key_export(out, &node->dev_key); in bt_mesh_cdb_node_key_export()
1162 struct bt_mesh_cdb_node *node; in store_cdb_pending_nodes() local
1164 node = bt_mesh_cdb_node_get(addr); in store_cdb_pending_nodes()
1165 if (node) { in store_cdb_pending_nodes()
1166 store_cdb_node(node); in store_cdb_pending_nodes()