Lines Matching refs:sub

78 static int private_beacon_create(struct bt_mesh_subnet *sub,
80 static int private_beacon_update(struct bt_mesh_subnet *sub);
83 static struct bt_mesh_beacon *subnet_beacon_get_by_type(struct bt_mesh_subnet *sub, bool priv) in subnet_beacon_get_by_type() argument
86 return priv ? &sub->priv_beacon : &sub->secure_beacon; in subnet_beacon_get_by_type()
88 return &sub->secure_beacon; in subnet_beacon_get_by_type()
92 static bool beacon_cache_match(struct bt_mesh_subnet *sub, void *data) in beacon_cache_match() argument
98 beacon = subnet_beacon_get_by_type(sub, params->private); in beacon_cache_match()
108 void bt_mesh_beacon_cache_clear(struct bt_mesh_subnet *sub) in bt_mesh_beacon_cache_clear() argument
110 (void)memset(sub->secure_beacon.cache, 0, sizeof(sub->secure_beacon.cache)); in bt_mesh_beacon_cache_clear()
112 (void)memset(sub->priv_beacon.cache, 0, sizeof(sub->priv_beacon.cache)); in bt_mesh_beacon_cache_clear()
138 static int secure_beacon_create(struct bt_mesh_subnet *sub, in secure_beacon_create() argument
141 uint8_t flags = bt_mesh_net_flags(sub); in secure_beacon_create()
146 keys = &sub->keys[SUBNET_KEY_TX_IDX(sub)]; in secure_beacon_create()
156 net_buf_simple_add_mem(buf, sub->secure_beacon.auth, 8); in secure_beacon_create()
158 LOG_DBG("net_idx 0x%04x flags 0x%02x NetID %s", sub->net_idx, flags, in secure_beacon_create()
160 LOG_DBG("IV Index 0x%08x Auth %s", bt_mesh.iv_index, bt_hex(sub->secure_beacon.auth, 8)); in secure_beacon_create()
197 static int private_beacon_update(struct bt_mesh_subnet *sub) in private_beacon_update() argument
199 struct bt_mesh_subnet_keys *keys = &sub->keys[SUBNET_KEY_TX_IDX(sub)]; in private_beacon_update()
200 uint8_t flags = bt_mesh_net_flags(sub); in private_beacon_update()
204 priv_random.val, sub->priv_beacon_ctx.data, in private_beacon_update()
205 sub->priv_beacon.auth); in private_beacon_update()
211 sub->priv_beacon_ctx.idx = priv_random.idx; in private_beacon_update()
215 static int private_beacon_create(struct bt_mesh_subnet *sub, in private_beacon_create() argument
226 if (sub->priv_beacon_ctx.idx != priv_random.idx) { in private_beacon_create()
227 err = private_beacon_update(sub); in private_beacon_create()
235 net_buf_simple_add_mem(buf, sub->priv_beacon_ctx.data, 5); in private_beacon_create()
236 net_buf_simple_add_mem(buf, sub->priv_beacon.auth, 8); in private_beacon_create()
238 LOG_DBG("0x%03x", sub->net_idx); in private_beacon_create()
243 int bt_mesh_beacon_create(struct bt_mesh_subnet *sub, struct net_buf_simple *buf, bool priv) in bt_mesh_beacon_create() argument
247 return private_beacon_create(sub, buf); in bt_mesh_beacon_create()
251 secure_beacon_create(sub, buf); in bt_mesh_beacon_create()
265 static int net_beacon_send(struct bt_mesh_subnet *sub, struct bt_mesh_beacon *beacon, in net_beacon_send() argument
266 int (*beacon_create)(struct bt_mesh_subnet *sub, in net_beacon_send() argument
296 err = beacon_create(sub, &adv->b); in net_beacon_send()
306 static int net_beacon_for_subnet_send(struct bt_mesh_subnet *sub) in net_beacon_for_subnet_send() argument
313 int (*create_fn)(struct bt_mesh_subnet *sub, struct net_buf_simple *buf); in net_beacon_for_subnet_send()
316 .beacon = &sub->secure_beacon, in net_beacon_for_subnet_send()
322 .beacon = &sub->priv_beacon, in net_beacon_for_subnet_send()
334 err = net_beacon_send(sub, beacons[i].beacon, beacons[i].create_fn); in net_beacon_for_subnet_send()
435 static void sub_update_beacon_observation(struct bt_mesh_subnet *sub) in sub_update_beacon_observation() argument
437 sub->secure_beacon.last = sub->secure_beacon.cur; in sub_update_beacon_observation()
438 sub->secure_beacon.cur = 0U; in sub_update_beacon_observation()
441 sub->priv_beacon.last = sub->priv_beacon.cur; in sub_update_beacon_observation()
442 sub->priv_beacon.cur = 0U; in sub_update_beacon_observation()
545 static bool secure_beacon_authenticate(struct bt_mesh_subnet *sub, void *cb_data) in secure_beacon_authenticate() argument
549 for (int i = 0; i < ARRAY_SIZE(sub->keys); i++) { in secure_beacon_authenticate()
550 if (sub->keys[i].valid && auth_match(&sub->keys[i], params)) { in secure_beacon_authenticate()
574 static bool priv_beacon_decrypt(struct bt_mesh_subnet *sub, void *cb_data) in priv_beacon_decrypt() argument
580 for (int i = 0; i < ARRAY_SIZE(sub->keys); i++) { in priv_beacon_decrypt()
581 if (!sub->keys[i].valid) { in priv_beacon_decrypt()
585 err = bt_mesh_beacon_decrypt(&sub->keys[i].priv_beacon, params->random, in priv_beacon_decrypt()
622 static void net_beacon_recv(struct bt_mesh_subnet *sub, in net_beacon_recv() argument
625 bt_mesh_kr_update(sub, BT_MESH_KEY_REFRESH(params->flags), in net_beacon_recv()
630 sub->net_idx != BT_MESH_KEY_PRIMARY) { in net_beacon_recv()
637 sub->net_idx, params->flags, params->iv_index, bt_mesh.iv_index); in net_beacon_recv()
650 bool (*matcher)(struct bt_mesh_subnet *sub, in net_beacon_resolve() argument
653 struct bt_mesh_subnet *sub; in net_beacon_resolve() local
656 sub = bt_mesh_subnet_find(beacon_cache_match, (void *)params); in net_beacon_resolve()
657 if (sub) { in net_beacon_resolve()
658 beacon = subnet_beacon_get_by_type(sub, params->private); in net_beacon_resolve()
665 sub = bt_mesh_subnet_find(matcher, params); in net_beacon_resolve()
666 if (!sub) { in net_beacon_resolve()
671 if (sub->kr_phase == BT_MESH_KR_PHASE_2 && !params->new_key) { in net_beacon_resolve()
676 beacon = subnet_beacon_get_by_type(sub, params->private); in net_beacon_resolve()
680 net_beacon_recv(sub, params); in net_beacon_resolve()
749 void bt_mesh_beacon_update(struct bt_mesh_subnet *sub) in bt_mesh_beacon_update() argument
751 uint8_t flags = bt_mesh_net_flags(sub); in bt_mesh_beacon_update()
754 keys = &sub->keys[SUBNET_KEY_TX_IDX(sub)]; in bt_mesh_beacon_update()
756 LOG_DBG("NetIndex 0x%03x Using %s key", sub->net_idx, in bt_mesh_beacon_update()
757 SUBNET_KEY_TX_IDX(sub) ? "new" : "current"); in bt_mesh_beacon_update()
762 sub->priv_beacon_ctx.idx = priv_random.idx - 1; in bt_mesh_beacon_update()
767 sub->secure_beacon.auth); in bt_mesh_beacon_update()
770 static void subnet_evt(struct bt_mesh_subnet *sub, enum bt_mesh_key_evt evt) in subnet_evt() argument
773 bt_mesh_beacon_update(sub); in subnet_evt()
807 static void subnet_beacon_enable(struct bt_mesh_subnet *sub) in subnet_beacon_enable() argument
809 sub->secure_beacon.last = 0U; in subnet_beacon_enable()
810 sub->secure_beacon.cur = 0U; in subnet_beacon_enable()
813 sub->priv_beacon.last = 0U; in subnet_beacon_enable()
814 sub->priv_beacon.cur = 0U; in subnet_beacon_enable()
817 bt_mesh_beacon_update(sub); in subnet_beacon_enable()