Lines Matching +full:multi +full:- +full:segment

6  * SPDX-License-Identifier: Apache-2.0
94 #define XACT_SEG_DATA(_seg) (&link.rx.buf->om_data[20 + ((_seg - 1) * 23)])
139 u8_t seg; /* Bit-field of unreceived segments */
140 u8_t last_seg; /* Last segment (to check length) */
214 BT_MESH_ADV(buf)->busy = 0; in free_segments()
234 if (prov->link_close) { in reset_link()
235 prov->link_close(BT_MESH_PROV_ADV); in reset_link()
348 return -ENOBUFS; in bearer_ctl_send()
369 len -= START_PAYLOAD_MAX; in last_seg()
390 BT_DBG("len %u: %s", msg->om_len, bt_hex(msg->om_data, msg->om_len)); in prov_send_adv()
396 return -ENOBUFS; in prov_send_adv()
403 net_buf_add_u8(start, GPC_START(last_seg(msg->om_len))); in prov_send_adv()
404 net_buf_add_be16(start, msg->om_len); in prov_send_adv()
405 net_buf_add_u8(start, bt_mesh_fcs_calc(msg->om_data, msg->om_len)); in prov_send_adv()
409 seg_len = min(msg->om_len, START_PAYLOAD_MAX); in prov_send_adv()
410 BT_DBG("seg 0 len %u: %s", seg_len, bt_hex(msg->om_data, seg_len)); in prov_send_adv()
411 net_buf_add_mem(start, msg->om_data, seg_len); in prov_send_adv()
415 for (seg_id = 1; msg->om_len > 0; seg_id++) { in prov_send_adv()
419 return -E2BIG; in prov_send_adv()
425 return -ENOBUFS; in prov_send_adv()
430 seg_len = min(msg->om_len, CONT_PAYLOAD_MAX); in prov_send_adv()
433 bt_hex(msg->om_data, seg_len)); in prov_send_adv()
438 net_buf_add_mem(buf, msg->om_data, seg_len); in prov_send_adv()
454 return -ENOTCONN; in prov_send_gatt()
508 /* Supported algorithms - FIPS P-256 Eliptic Curve */ in prov_invite()
516 net_buf_simple_add_u8(buf, prov->static_val ? BIT(0) : 0x00); in prov_invite()
519 net_buf_simple_add_u8(buf, prov->output_size); in prov_invite()
522 net_buf_simple_add_be16(buf, prov->output_actions); in prov_invite()
525 net_buf_simple_add_u8(buf, prov->input_size); in prov_invite()
528 net_buf_simple_add_be16(buf, prov->input_actions); in prov_invite()
530 memcpy(&link.conf_inputs[1], &buf->om_data[1], 11); in prov_invite()
608 return -EINVAL; in prov_auth()
615 return -EINVAL; in prov_auth()
618 memcpy(link.auth + 16 - prov->static_val_len, in prov_auth()
619 prov->static_val, prov->static_val_len); in prov_auth()
620 memset(link.auth, 0, sizeof(link.auth) - prov->static_val_len); in prov_auth()
626 return -EINVAL; in prov_auth()
629 if (!(prov->output_actions & output)) { in prov_auth()
630 return -EINVAL; in prov_auth()
633 if (size > prov->output_size) { in prov_auth()
634 return -EINVAL; in prov_auth()
649 str[i] += 'A' - 10; in prov_auth()
655 memset(link.auth + size, 0, sizeof(link.auth) - size); in prov_auth()
657 return prov->output_string((char *)str); in prov_auth()
664 num %= div[size - 1]; in prov_auth()
669 return prov->output_number(output, num); in prov_auth()
675 return -EINVAL; in prov_auth()
678 if (!(prov->input_actions & input)) { in prov_auth()
679 return -EINVAL; in prov_auth()
682 if (size > prov->input_size) { in prov_auth()
683 return -EINVAL; in prov_auth()
692 return prov->input(input, size); in prov_auth()
695 return -EINVAL; in prov_auth()
800 return -EINVAL; in bt_mesh_input_number()
823 return -EINVAL; in bt_mesh_input_string()
826 strncpy((char *)link.auth, str, prov->input_size); in bt_mesh_input_string()
881 /* Swap X and Y halves independently to big-endian */ in send_pub_key()
885 memcpy(&link.conf_inputs[81], &buf->om_data[1], 64); in send_pub_key()
887 BT_DBG("Local Public Key: %s", bt_hex(&buf->om_data[1], 64)); in send_pub_key()
891 /* Copy remote key in little-endian for bt_dh_key_gen(). in send_pub_key()
895 sys_memcpy_swap(buf->om_data, &link.conf_inputs[17], 32); in send_pub_key()
896 sys_memcpy_swap(&buf->om_data[32], &link.conf_inputs[49], 32); in send_pub_key()
898 if (bt_dh_key_gen(buf->om_data, prov_dh_key_cb)) { in send_pub_key()
1093 /* After PB-GATT provisioning we should start advertising in prov_data()
1168 if (k_uptime_get() - link.tx.start > TRANSACTION_TIMEOUT) { in prov_retransmit()
1181 if (BT_MESH_ADV(buf)->busy) { in prov_retransmit()
1185 BT_DBG("%u bytes: %s", buf->om_len, bt_hex(buf->om_data, buf->om_len)); in prov_retransmit()
1198 BT_INFO("link open: len %u", buf->om_len); in link_open()
1200 if (buf->om_len < 16) { in link_open()
1201 BT_ERR("Too short bearer open message (len %u)", buf->om_len); in link_open()
1207 if (link.id == rx->link_id && link.expect == PROV_INVITE) { in link_open()
1217 if (memcmp(buf->om_data, prov->uuid, 16)) { in link_open()
1222 if (prov->link_open) { in link_open()
1223 prov->link_open(BT_MESH_PROV_ADV); in link_open()
1226 link.id = rx->link_id; in link_open()
1237 BT_INFO("Link ack: len %u", buf->om_len); in link_ack()
1242 BT_INFO("Link close: len %u", buf->om_len); in link_close()
1249 BT_DBG("op 0x%02x len %u", BEARER_CTL(rx->gpc), buf->om_len); in gen_prov_ctl()
1251 switch (BEARER_CTL(rx->gpc)) { in gen_prov_ctl()
1270 BT_ERR("Unknown bearer opcode: 0x%02x", BEARER_CTL(rx->gpc)); in gen_prov_ctl()
1273 bt_test_mesh_prov_invalid_bearer(BEARER_CTL(rx->gpc)); in gen_prov_ctl()
1282 u8_t type = link.rx.buf->om_data[0]; in prov_msg_recv()
1284 BT_DBG("type 0x%02x len %u", type, link.rx.buf->om_len); in prov_msg_recv()
1307 if (1 + prov_handlers[type].len != link.rx.buf->om_len) { in prov_msg_recv()
1309 link.rx.buf->om_len, type); in prov_msg_recv()
1314 prov_handlers[type].func(&link.rx.buf->om_data[1]); in prov_msg_recv()
1319 u8_t seg = CONT_SEG_INDEX(rx->gpc); in gen_prov_cont()
1321 BT_DBG("len %u, seg_index %u", buf->om_len, seg); in gen_prov_cont()
1323 if (!link.rx.seg && link.rx.prev_id == rx->xact_id) { in gen_prov_cont()
1325 gen_prov_ack_send(rx->xact_id); in gen_prov_cont()
1329 if (rx->xact_id != link.rx.id) { in gen_prov_cont()
1331 rx->xact_id, link.rx.id); in gen_prov_cont()
1336 BT_ERR("Invalid segment index %u", seg); in gen_prov_cont()
1342 expect_len = (link.rx.buf->om_len - 20 - in gen_prov_cont()
1343 (23 * (link.rx.last_seg - 1))); in gen_prov_cont()
1344 if (expect_len != buf->om_len) { in gen_prov_cont()
1346 expect_len, buf->om_len); in gen_prov_cont()
1353 BT_WARN("Ignoring already received segment"); in gen_prov_cont()
1357 memcpy(XACT_SEG_DATA(seg), buf->om_data, buf->om_len); in gen_prov_cont()
1367 BT_DBG("len %u", buf->om_len); in gen_prov_ack()
1373 if (rx->xact_id == link.tx.id) { in gen_prov_ack()
1387 if (link.rx.prev_id == rx->xact_id) { in gen_prov_start()
1389 gen_prov_ack_send(rx->xact_id); in gen_prov_start()
1395 link.rx.buf->om_len = net_buf_simple_pull_be16(buf); in gen_prov_start()
1396 link.rx.id = rx->xact_id; in gen_prov_start()
1399 BT_DBG("len %u last_seg %u total_len %u fcs 0x%02x", buf->om_len, in gen_prov_start()
1400 START_LAST_SEG(rx->gpc), link.rx.buf->om_len, link.rx.fcs); in gen_prov_start()
1402 if (link.rx.buf->om_len < 1) { in gen_prov_start()
1403 BT_ERR("Ignoring zero-length provisioning PDU"); in gen_prov_start()
1408 if (link.rx.buf->om_len > trailing_space) { in gen_prov_start()
1410 link.rx.buf->om_len); in gen_prov_start()
1415 if (START_LAST_SEG(rx->gpc) > 0 && link.rx.buf->om_len <= 20) { in gen_prov_start()
1416 BT_ERR("Too small total length for multi-segment PDU"); in gen_prov_start()
1421 link.rx.seg = (1 << (START_LAST_SEG(rx->gpc) + 1)) - 1; in gen_prov_start()
1422 link.rx.last_seg = START_LAST_SEG(rx->gpc); in gen_prov_start()
1423 memcpy(link.rx.buf->om_data, buf->om_data, buf->om_len); in gen_prov_start()
1444 if (buf->om_len < gen_prov[GPCF(rx->gpc)].min_len) { in gen_prov_recv()
1445 BT_ERR("Too short GPC message type %u", GPCF(rx->gpc)); in gen_prov_recv()
1450 gen_prov[GPCF(rx->gpc)].require_link) { in gen_prov_recv()
1455 BT_INFO("prov_action: %d", GPCF(rx->gpc)); in gen_prov_recv()
1456 gen_prov[GPCF(rx->gpc)].func(rx, buf); in gen_prov_recv()
1464 BT_DBG("Ignoring provisioning PDU - already provisioned"); in bt_mesh_pb_adv_recv()
1468 if (buf->om_len < 6) { in bt_mesh_pb_adv_recv()
1469 BT_WARN("Too short provisioning packet (len %u)", buf->om_len); in bt_mesh_pb_adv_recv()
1493 BT_DBG("%u bytes: %s", buf->om_len, bt_hex(buf->om_data, buf->om_len)); in bt_mesh_pb_gatt_recv()
1497 return -ENOTCONN; in bt_mesh_pb_gatt_recv()
1500 if (buf->om_len < 1) { in bt_mesh_pb_gatt_recv()
1501 BT_WARN("Too short provisioning packet (len %u)", buf->om_len); in bt_mesh_pb_gatt_recv()
1502 return -EINVAL; in bt_mesh_pb_gatt_recv()
1509 return -EINVAL; in bt_mesh_pb_gatt_recv()
1514 return -EINVAL; in bt_mesh_pb_gatt_recv()
1517 if (prov_handlers[type].len != buf->om_len) { in bt_mesh_pb_gatt_recv()
1518 BT_ERR("Invalid length %u for type 0x%02x", buf->om_len, type); in bt_mesh_pb_gatt_recv()
1519 return -EINVAL; in bt_mesh_pb_gatt_recv()
1522 prov_handlers[type].func(buf->om_data); in bt_mesh_pb_gatt_recv()
1533 return -EBUSY; in bt_mesh_pb_gatt_open()
1539 if (prov->link_open) { in bt_mesh_pb_gatt_open()
1540 prov->link_open(BT_MESH_PROV_GATT); in bt_mesh_pb_gatt_open()
1554 return -ENOTCONN; in bt_mesh_pb_gatt_close()
1562 if (prov->link_close) { in bt_mesh_pb_gatt_close()
1563 prov->link_close(BT_MESH_PROV_GATT); in bt_mesh_pb_gatt_close()
1602 return -EINVAL; in bt_mesh_prov_init()
1638 if (prov->complete) { in bt_mesh_prov_complete()
1639 prov->complete(net_idx, addr); in bt_mesh_prov_complete()
1645 if (prov->reset) { in bt_mesh_prov_reset()
1646 prov->reset(); in bt_mesh_prov_reset()