1 /* bttester.h - Bluetooth tester headers */
2 
3 /*
4  * Copyright (c) 2015-2016 Intel Corporation
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include <sys/util.h>
10 #include <bluetooth/addr.h>
11 
12 #define BTP_MTU 1024
13 #define BTP_DATA_MAX_SIZE (BTP_MTU - sizeof(struct btp_hdr))
14 
15 #define BTP_INDEX_NONE		0xff
16 
17 #define BTP_SERVICE_ID_CORE	0
18 #define BTP_SERVICE_ID_GAP	1
19 #define BTP_SERVICE_ID_GATT	2
20 #define BTP_SERVICE_ID_L2CAP	3
21 #define BTP_SERVICE_ID_MESH	4
22 
23 #define BTP_STATUS_SUCCESS	0x00
24 #define BTP_STATUS_FAILED	0x01
25 #define BTP_STATUS_UNKNOWN_CMD	0x02
26 #define BTP_STATUS_NOT_READY	0x03
27 
28 struct btp_hdr {
29 	uint8_t  service;
30 	uint8_t  opcode;
31 	uint8_t  index;
32 	uint16_t len;
33 	uint8_t  data[];
34 } __packed;
35 
36 #define BTP_STATUS			0x00
37 struct btp_status {
38 	uint8_t code;
39 } __packed;
40 
41 /* Core Service */
42 #define CORE_READ_SUPPORTED_COMMANDS	0x01
43 struct core_read_supported_commands_rp {
44 	uint8_t data[0];
45 } __packed;
46 
47 #define CORE_READ_SUPPORTED_SERVICES	0x02
48 struct core_read_supported_services_rp {
49 	uint8_t data[0];
50 } __packed;
51 
52 #define CORE_REGISTER_SERVICE		0x03
53 struct core_register_service_cmd {
54 	uint8_t id;
55 } __packed;
56 
57 #define CORE_UNREGISTER_SERVICE		0x04
58 struct core_unregister_service_cmd {
59 	uint8_t id;
60 } __packed;
61 
62 /* events */
63 #define CORE_EV_IUT_READY		0x80
64 
65 /* GAP Service */
66 /* commands */
67 #define GAP_READ_SUPPORTED_COMMANDS	0x01
68 struct gap_read_supported_commands_rp {
69 	uint8_t data[0];
70 } __packed;
71 
72 #define GAP_READ_CONTROLLER_INDEX_LIST	0x02
73 struct gap_read_controller_index_list_rp {
74 	uint8_t num;
75 	uint8_t index[];
76 } __packed;
77 
78 #define GAP_SETTINGS_POWERED		0
79 #define GAP_SETTINGS_CONNECTABLE	1
80 #define GAP_SETTINGS_FAST_CONNECTABLE	2
81 #define GAP_SETTINGS_DISCOVERABLE	3
82 #define GAP_SETTINGS_BONDABLE		4
83 #define GAP_SETTINGS_LINK_SEC_3		5
84 #define GAP_SETTINGS_SSP		6
85 #define GAP_SETTINGS_BREDR		7
86 #define GAP_SETTINGS_HS			8
87 #define GAP_SETTINGS_LE			9
88 #define GAP_SETTINGS_ADVERTISING	10
89 #define GAP_SETTINGS_SC			11
90 #define GAP_SETTINGS_DEBUG_KEYS		12
91 #define GAP_SETTINGS_PRIVACY		13
92 #define GAP_SETTINGS_CONTROLLER_CONFIG	14
93 #define GAP_SETTINGS_STATIC_ADDRESS	15
94 
95 #define GAP_READ_CONTROLLER_INFO	0x03
96 struct gap_read_controller_info_rp {
97 	uint8_t  address[6];
98 	uint32_t supported_settings;
99 	uint32_t current_settings;
100 	uint8_t  cod[3];
101 	uint8_t  name[249];
102 	uint8_t  short_name[11];
103 } __packed;
104 
105 #define GAP_RESET			0x04
106 struct gap_reset_rp {
107 	uint32_t current_settings;
108 } __packed;
109 
110 #define GAP_SET_POWERED			0x05
111 struct gap_set_powered_cmd {
112 	uint8_t powered;
113 } __packed;
114 struct gap_set_powered_rp {
115 	uint32_t current_settings;
116 } __packed;
117 
118 #define GAP_SET_CONNECTABLE		0x06
119 struct gap_set_connectable_cmd {
120 	uint8_t connectable;
121 } __packed;
122 struct gap_set_connectable_rp {
123 	uint32_t current_settings;
124 } __packed;
125 
126 #define GAP_SET_FAST_CONNECTABLE	0x07
127 struct gap_set_fast_connectable_cmd {
128 	uint8_t fast_connectable;
129 } __packed;
130 struct gap_set_fast_connectable_rp {
131 	uint32_t current_settings;
132 } __packed;
133 
134 #define GAP_NON_DISCOVERABLE		0x00
135 #define GAP_GENERAL_DISCOVERABLE	0x01
136 #define GAP_LIMITED_DISCOVERABLE	0x02
137 
138 #define GAP_SET_DISCOVERABLE		0x08
139 struct gap_set_discoverable_cmd {
140 	uint8_t discoverable;
141 } __packed;
142 struct gap_set_discoverable_rp {
143 	uint32_t current_settings;
144 } __packed;
145 
146 #define GAP_SET_BONDABLE		0x09
147 struct gap_set_bondable_cmd {
148 	uint8_t bondable;
149 } __packed;
150 struct gap_set_bondable_rp {
151 	uint32_t current_settings;
152 } __packed;
153 
154 #define GAP_START_ADVERTISING	0x0a
155 struct gap_start_advertising_cmd {
156 	uint8_t adv_data_len;
157 	uint8_t scan_rsp_len;
158 	uint8_t adv_sr_data[];
159 } __packed;
160 struct gap_start_advertising_rp {
161 	uint32_t current_settings;
162 } __packed;
163 
164 #define GAP_STOP_ADVERTISING		0x0b
165 struct gap_stop_advertising_rp {
166 	uint32_t current_settings;
167 } __packed;
168 
169 #define GAP_DISCOVERY_FLAG_LE			0x01
170 #define GAP_DISCOVERY_FLAG_BREDR		0x02
171 #define GAP_DISCOVERY_FLAG_LIMITED		0x04
172 #define GAP_DISCOVERY_FLAG_LE_ACTIVE_SCAN	0x08
173 #define GAP_DISCOVERY_FLAG_LE_OBSERVE		0x10
174 #define GAP_DISCOVERY_FLAG_OWN_ID_ADDR		0x20
175 
176 #define GAP_START_DISCOVERY		0x0c
177 struct gap_start_discovery_cmd {
178 	uint8_t flags;
179 } __packed;
180 
181 #define GAP_STOP_DISCOVERY		0x0d
182 
183 #define GAP_CONNECT			0x0e
184 struct gap_connect_cmd {
185 	uint8_t address_type;
186 	uint8_t address[6];
187 } __packed;
188 
189 #define GAP_DISCONNECT			0x0f
190 struct gap_disconnect_cmd {
191 	uint8_t  address_type;
192 	uint8_t  address[6];
193 } __packed;
194 
195 #define GAP_IO_CAP_DISPLAY_ONLY		0
196 #define GAP_IO_CAP_DISPLAY_YESNO	1
197 #define GAP_IO_CAP_KEYBOARD_ONLY	2
198 #define GAP_IO_CAP_NO_INPUT_OUTPUT	3
199 #define GAP_IO_CAP_KEYBOARD_DISPLAY	4
200 
201 #define GAP_SET_IO_CAP			0x10
202 struct gap_set_io_cap_cmd {
203 	uint8_t io_cap;
204 } __packed;
205 
206 #define GAP_PAIR			0x11
207 struct gap_pair_cmd {
208 	uint8_t address_type;
209 	uint8_t address[6];
210 } __packed;
211 
212 #define GAP_UNPAIR			0x12
213 struct gap_unpair_cmd {
214 	uint8_t address_type;
215 	uint8_t address[6];
216 } __packed;
217 
218 #define GAP_PASSKEY_ENTRY		0x13
219 struct gap_passkey_entry_cmd {
220 	uint8_t  address_type;
221 	uint8_t  address[6];
222 	uint32_t passkey;
223 } __packed;
224 
225 #define GAP_PASSKEY_CONFIRM		0x14
226 struct gap_passkey_confirm_cmd {
227 	uint8_t address_type;
228 	uint8_t address[6];
229 	uint8_t match;
230 } __packed;
231 
232 #define GAP_START_DIRECTED_ADV_HD	BIT(0)
233 #define GAP_START_DIRECTED_ADV_OWN_ID	BIT(1)
234 #define GAP_START_DIRECTED_ADV_PEER_RPA	BIT(2)
235 
236 #define GAP_START_DIRECTED_ADV		0x15
237 struct gap_start_directed_adv_cmd {
238 	uint8_t address_type;
239 	uint8_t address[6];
240 	uint16_t options;
241 } __packed;
242 struct gap_start_directed_adv_rp {
243 	uint32_t current_settings;
244 } __packed;
245 
246 #define GAP_CONN_PARAM_UPDATE		0x16
247 struct gap_conn_param_update_cmd {
248 	uint8_t address_type;
249 	uint8_t address[6];
250 	uint16_t interval_min;
251 	uint16_t interval_max;
252 	uint16_t latency;
253 	uint16_t timeout;
254 } __packed;
255 
256 #define GAP_PAIRING_CONSENT		0x17
257 struct gap_pairing_consent_cmd {
258 	uint8_t address_type;
259 	uint8_t address[6];
260 	uint8_t consent;
261 } __packed;
262 
263 #define GAP_OOB_LEGACY_SET_DATA		0x18
264 struct gap_oob_legacy_set_data_cmd {
265 	uint8_t oob_data[16];
266 } __packed;
267 
268 #define GAP_OOB_SC_GET_LOCAL_DATA	0x19
269 struct gap_oob_sc_get_local_data_rp {
270 	uint8_t rand[16];
271 	uint8_t conf[16];
272 } __packed;
273 
274 #define GAP_OOB_SC_SET_REMOTE_DATA	0x1a
275 struct gap_oob_sc_set_remote_data_cmd {
276 	uint8_t rand[16];
277 	uint8_t conf[16];
278 } __packed;
279 
280 #define GAP_SET_MITM			0x1b
281 struct gap_set_mitm {
282 	uint8_t mitm;
283 } __packed;
284 
285 #define GAP_SET_FILTER_LIST		0x1c
286 struct gap_set_filter_list {
287 	uint8_t cnt;
288 	bt_addr_le_t addr[0];
289 } __packed;
290 
291 /* events */
292 #define GAP_EV_NEW_SETTINGS		0x80
293 struct gap_new_settings_ev {
294 	uint32_t current_settings;
295 } __packed;
296 
297 #define GAP_DEVICE_FOUND_FLAG_RSSI	0x01
298 #define GAP_DEVICE_FOUND_FLAG_AD	0x02
299 #define GAP_DEVICE_FOUND_FLAG_SD	0x04
300 
301 #define GAP_EV_DEVICE_FOUND		0x81
302 struct gap_device_found_ev {
303 	uint8_t  address_type;
304 	uint8_t  address[6];
305 	int8_t   rssi;
306 	uint8_t  flags;
307 	uint16_t eir_data_len;
308 	uint8_t  eir_data[];
309 } __packed;
310 
311 #define GAP_EV_DEVICE_CONNECTED		0x82
312 struct gap_device_connected_ev {
313 	uint8_t address_type;
314 	uint8_t address[6];
315 	uint16_t interval;
316 	uint16_t latency;
317 	uint16_t timeout;
318 } __packed;
319 
320 #define GAP_EV_DEVICE_DISCONNECTED	0x83
321 struct gap_device_disconnected_ev {
322 	uint8_t address_type;
323 	uint8_t address[6];
324 } __packed;
325 
326 #define GAP_EV_PASSKEY_DISPLAY		0x84
327 struct gap_passkey_display_ev {
328 	uint8_t  address_type;
329 	uint8_t  address[6];
330 	uint32_t passkey;
331 } __packed;
332 
333 #define GAP_EV_PASSKEY_ENTRY_REQ	0x85
334 struct gap_passkey_entry_req_ev {
335 	uint8_t address_type;
336 	uint8_t address[6];
337 } __packed;
338 
339 #define GAP_EV_PASSKEY_CONFIRM_REQ	0x86
340 struct gap_passkey_confirm_req_ev {
341 	uint8_t  address_type;
342 	uint8_t  address[6];
343 	uint32_t passkey;
344 } __packed;
345 
346 #define GAP_EV_IDENTITY_RESOLVED	0x87
347 struct gap_identity_resolved_ev {
348 	uint8_t address_type;
349 	uint8_t address[6];
350 	uint8_t identity_address_type;
351 	uint8_t identity_address[6];
352 } __packed;
353 
354 #define GAP_EV_CONN_PARAM_UPDATE	0x88
355 struct gap_conn_param_update_ev {
356 	uint8_t address_type;
357 	uint8_t address[6];
358 	uint16_t interval;
359 	uint16_t latency;
360 	uint16_t timeout;
361 } __packed;
362 
363 #define GAP_SEC_LEVEL_UNAUTH_ENC	0x01
364 #define GAP_SEC_LEVEL_AUTH_ENC		0x02
365 #define GAP_SEC_LEVEL_AUTH_SC		0x03
366 
367 #define GAP_EV_SEC_LEVEL_CHANGED	0x89
368 struct gap_sec_level_changed_ev {
369 	uint8_t address_type;
370 	uint8_t address[6];
371 	uint8_t sec_level;
372 } __packed;
373 
374 #define GAP_EV_PAIRING_CONSENT_REQ	0x8a
375 struct gap_pairing_consent_req_ev {
376 	uint8_t address_type;
377 	uint8_t address[6];
378 } __packed;
379 
380 #define GAP_EV_BOND_LOST	0x8b
381 struct gap_bond_lost_ev {
382 	uint8_t address_type;
383 	uint8_t address[6];
384 } __packed;
385 
386 #define GAP_EV_PAIRING_FAILED		0x8c
387 struct gap_bond_pairing_failed_ev {
388 	uint8_t address_type;
389 	uint8_t address[6];
390 	uint8_t reason;
391 } __packed;
392 
393 /* GATT Service */
394 /* commands */
395 #define GATT_READ_SUPPORTED_COMMANDS	0x01
396 struct gatt_read_supported_commands_rp {
397 	uint8_t data[0];
398 } __packed;
399 
400 #define GATT_SERVICE_PRIMARY		0x00
401 #define GATT_SERVICE_SECONDARY		0x01
402 
403 #define GATT_ADD_SERVICE		0x02
404 struct gatt_add_service_cmd {
405 	uint8_t type;
406 	uint8_t uuid_length;
407 	uint8_t uuid[];
408 } __packed;
409 struct gatt_add_service_rp {
410 	uint16_t svc_id;
411 } __packed;
412 
413 #define GATT_ADD_CHARACTERISTIC		0x03
414 struct gatt_add_characteristic_cmd {
415 	uint16_t svc_id;
416 	uint8_t properties;
417 	uint8_t permissions;
418 	uint8_t uuid_length;
419 	uint8_t uuid[];
420 } __packed;
421 struct gatt_add_characteristic_rp {
422 	uint16_t char_id;
423 } __packed;
424 
425 #define GATT_ADD_DESCRIPTOR		0x04
426 struct gatt_add_descriptor_cmd {
427 	uint16_t char_id;
428 	uint8_t permissions;
429 	uint8_t uuid_length;
430 	uint8_t uuid[];
431 } __packed;
432 struct gatt_add_descriptor_rp {
433 	uint16_t desc_id;
434 } __packed;
435 
436 #define GATT_ADD_INCLUDED_SERVICE	0x05
437 struct gatt_add_included_service_cmd {
438 	uint16_t svc_id;
439 } __packed;
440 struct gatt_add_included_service_rp {
441 	uint16_t included_service_id;
442 } __packed;
443 
444 #define GATT_SET_VALUE			0x06
445 	struct gatt_set_value_cmd {
446 	uint16_t attr_id;
447 	uint16_t len;
448 	uint8_t value[];
449 } __packed;
450 
451 #define GATT_START_SERVER		0x07
452 struct gatt_start_server_rp {
453 	uint16_t db_attr_off;
454 	uint8_t db_attr_cnt;
455 } __packed;
456 
457 #define GATT_RESET_SERVER		0x08
458 
459 #define GATT_SET_ENC_KEY_SIZE		0x09
460 struct gatt_set_enc_key_size_cmd {
461 	uint16_t attr_id;
462 	uint8_t key_size;
463 } __packed;
464 
465 /* Gatt Client */
466 struct gatt_service {
467 	uint16_t start_handle;
468 	uint16_t end_handle;
469 	uint8_t uuid_length;
470 	uint8_t uuid[];
471 } __packed;
472 
473 struct gatt_included {
474 	uint16_t included_handle;
475 	struct gatt_service service;
476 } __packed;
477 
478 struct gatt_characteristic {
479 	uint16_t characteristic_handle;
480 	uint16_t value_handle;
481 	uint8_t properties;
482 	uint8_t uuid_length;
483 	uint8_t uuid[];
484 } __packed;
485 
486 struct gatt_descriptor {
487 	uint16_t descriptor_handle;
488 	uint8_t uuid_length;
489 	uint8_t uuid[];
490 } __packed;
491 
492 #define GATT_EXCHANGE_MTU		0x0a
493 struct gatt_exchange_mtu_cmd {
494 	uint8_t address_type;
495 	uint8_t address[6];
496 } __packed;
497 
498 #define GATT_DISC_ALL_PRIM		0x0b
499 struct gatt_disc_all_prim_cmd {
500 	uint8_t address_type;
501 	uint8_t address[6];
502 } __packed;
503 struct gatt_disc_all_prim_rp {
504 	uint8_t services_count;
505 	struct gatt_service services[];
506 } __packed;
507 
508 #define GATT_DISC_PRIM_UUID		0x0c
509 struct gatt_disc_prim_uuid_cmd {
510 	uint8_t address_type;
511 	uint8_t address[6];
512 	uint8_t uuid_length;
513 	uint8_t uuid[];
514 } __packed;
515 struct gatt_disc_prim_rp {
516 	uint8_t services_count;
517 	struct gatt_service services[];
518 } __packed;
519 
520 #define GATT_FIND_INCLUDED		0x0d
521 struct gatt_find_included_cmd {
522 	uint8_t address_type;
523 	uint8_t address[6];
524 	uint16_t start_handle;
525 	uint16_t end_handle;
526 } __packed;
527 struct gatt_find_included_rp {
528 	uint8_t services_count;
529 	struct gatt_included included[];
530 } __packed;
531 
532 #define GATT_DISC_ALL_CHRC		0x0e
533 struct gatt_disc_all_chrc_cmd {
534 	uint8_t address_type;
535 	uint8_t address[6];
536 	uint16_t start_handle;
537 	uint16_t end_handle;
538 } __packed;
539 struct gatt_disc_chrc_rp {
540 	uint8_t characteristics_count;
541 	struct gatt_characteristic characteristics[];
542 } __packed;
543 
544 #define GATT_DISC_CHRC_UUID		0x0f
545 struct gatt_disc_chrc_uuid_cmd {
546 	uint8_t address_type;
547 	uint8_t address[6];
548 	uint16_t start_handle;
549 	uint16_t end_handle;
550 	uint8_t uuid_length;
551 	uint8_t uuid[];
552 } __packed;
553 
554 #define GATT_DISC_ALL_DESC		0x10
555 struct gatt_disc_all_desc_cmd {
556 	uint8_t address_type;
557 	uint8_t address[6];
558 	uint16_t start_handle;
559 	uint16_t end_handle;
560 } __packed;
561 struct gatt_disc_all_desc_rp {
562 	uint8_t descriptors_count;
563 	struct gatt_descriptor descriptors[];
564 } __packed;
565 
566 #define GATT_READ			0x11
567 struct gatt_read_cmd {
568 	uint8_t address_type;
569 	uint8_t address[6];
570 	uint16_t handle;
571 } __packed;
572 struct gatt_read_rp {
573 	uint8_t att_response;
574 	uint16_t data_length;
575 	uint8_t data[];
576 } __packed;
577 
578 struct gatt_char_value {
579 	uint16_t handle;
580 	uint8_t data_len;
581 	uint8_t data[0];
582 } __packed;
583 
584 #define GATT_READ_UUID			0x12
585 struct gatt_read_uuid_cmd {
586 	uint8_t address_type;
587 	uint8_t address[6];
588 	uint16_t start_handle;
589 	uint16_t end_handle;
590 	uint8_t uuid_length;
591 	uint8_t uuid[];
592 } __packed;
593 struct gatt_read_uuid_rp {
594 	uint8_t att_response;
595 	uint8_t values_count;
596 	struct gatt_char_value values[0];
597 } __packed;
598 
599 #define GATT_READ_LONG			0x13
600 struct gatt_read_long_cmd {
601 	uint8_t address_type;
602 	uint8_t address[6];
603 	uint16_t handle;
604 	uint16_t offset;
605 } __packed;
606 struct gatt_read_long_rp {
607 	uint8_t att_response;
608 	uint16_t data_length;
609 	uint8_t data[];
610 } __packed;
611 
612 #define GATT_READ_MULTIPLE		0x14
613 struct gatt_read_multiple_cmd {
614 	uint8_t address_type;
615 	uint8_t address[6];
616 	uint8_t handles_count;
617 	uint16_t handles[];
618 } __packed;
619 struct gatt_read_multiple_rp {
620 	uint8_t att_response;
621 	uint16_t data_length;
622 	uint8_t data[];
623 } __packed;
624 
625 #define GATT_WRITE_WITHOUT_RSP		0x15
626 struct gatt_write_without_rsp_cmd {
627 	uint8_t address_type;
628 	uint8_t address[6];
629 	uint16_t handle;
630 	uint16_t data_length;
631 	uint8_t data[];
632 } __packed;
633 
634 #define GATT_SIGNED_WRITE_WITHOUT_RSP	0x16
635 struct gatt_signed_write_without_rsp_cmd {
636 	uint8_t address_type;
637 	uint8_t address[6];
638 	uint16_t handle;
639 	uint16_t data_length;
640 	uint8_t data[];
641 } __packed;
642 
643 #define GATT_WRITE			0x17
644 struct gatt_write_cmd {
645 	uint8_t address_type;
646 	uint8_t address[6];
647 	uint16_t handle;
648 	uint16_t data_length;
649 	uint8_t data[];
650 } __packed;
651 struct gatt_write_rp {
652 	uint8_t att_response;
653 } __packed;
654 
655 #define GATT_WRITE_LONG			0x18
656 struct gatt_write_long_cmd {
657 	uint8_t address_type;
658 	uint8_t address[6];
659 	uint16_t handle;
660 	uint16_t offset;
661 	uint16_t data_length;
662 	uint8_t data[];
663 } __packed;
664 struct gatt_write_long_rp {
665 	uint8_t att_response;
666 } __packed;
667 
668 #define GATT_RELIABLE_WRITE		0x19
669 struct gatt_reliable_write_cmd {
670 	uint8_t address_type;
671 	uint8_t address[6];
672 	uint16_t handle;
673 	uint16_t offset;
674 	uint16_t data_length;
675 	uint8_t data[];
676 } __packed;
677 struct gatt_reliable_write_rp {
678 	uint8_t att_response;
679 } __packed;
680 
681 #define GATT_CFG_NOTIFY			0x1a
682 #define GATT_CFG_INDICATE		0x1b
683 struct gatt_cfg_notify_cmd {
684 	uint8_t address_type;
685 	uint8_t address[6];
686 	uint8_t enable;
687 	uint16_t ccc_handle;
688 } __packed;
689 
690 #define GATT_GET_ATTRIBUTES		0x1c
691 struct gatt_get_attributes_cmd {
692 	uint16_t start_handle;
693 	uint16_t end_handle;
694 	uint8_t type_length;
695 	uint8_t type[];
696 } __packed;
697 struct gatt_get_attributes_rp {
698 	uint8_t attrs_count;
699 	uint8_t attrs[];
700 } __packed;
701 struct gatt_attr {
702 	uint16_t handle;
703 	uint8_t permission;
704 	uint8_t type_length;
705 	uint8_t type[];
706 } __packed;
707 
708 #define GATT_GET_ATTRIBUTE_VALUE	0x1d
709 struct gatt_get_attribute_value_cmd {
710 	uint8_t address_type;
711 	uint8_t address[6];
712 	uint16_t handle;
713 } __packed;
714 struct gatt_get_attribute_value_rp {
715 	uint8_t att_response;
716 	uint16_t value_length;
717 	uint8_t value[];
718 } __packed;
719 
720 #define GATT_CHANGE_DB			0x1e
721 struct gatt_change_db_cmd {
722 	uint16_t start_handle;
723 	uint8_t visibility;
724 } __packed;
725 
726 /* GATT events */
727 #define GATT_EV_NOTIFICATION		0x80
728 struct gatt_notification_ev {
729 	uint8_t address_type;
730 	uint8_t address[6];
731 	uint8_t type;
732 	uint16_t handle;
733 	uint16_t data_length;
734 	uint8_t data[];
735 } __packed;
736 
737 #define GATT_EV_ATTR_VALUE_CHANGED	0x81
738 struct gatt_attr_value_changed_ev {
739 	uint16_t handle;
740 	uint16_t data_length;
741 	uint8_t data[];
742 } __packed;
743 
tester_set_bit(uint8_t * addr,unsigned int bit)744 static inline void tester_set_bit(uint8_t *addr, unsigned int bit)
745 {
746 	uint8_t *p = addr + (bit / 8U);
747 
748 	*p |= BIT(bit % 8);
749 }
750 
tester_test_bit(const uint8_t * addr,unsigned int bit)751 static inline uint8_t tester_test_bit(const uint8_t *addr, unsigned int bit)
752 {
753 	const uint8_t *p = addr + (bit / 8U);
754 
755 	return *p & BIT(bit % 8);
756 }
757 
758 /* L2CAP Service */
759 /* commands */
760 #define L2CAP_READ_SUPPORTED_COMMANDS	0x01
761 struct l2cap_read_supported_commands_rp {
762 	uint8_t data[0];
763 } __packed;
764 
765 #define L2CAP_CONNECT_OPT_ECFC		0x01
766 #define L2CAP_CONNECT_OPT_HOLD_CREDIT	0x02
767 
768 #define L2CAP_CONNECT			0x02
769 struct l2cap_connect_cmd {
770 	uint8_t address_type;
771 	uint8_t address[6];
772 	uint16_t psm;
773 	uint16_t mtu;
774 	uint8_t num;
775 	uint8_t options;
776 } __packed;
777 struct l2cap_connect_rp {
778 	uint8_t num;
779 	uint8_t chan_id[];
780 } __packed;
781 
782 #define L2CAP_DISCONNECT		0x03
783 struct l2cap_disconnect_cmd {
784 	uint8_t chan_id;
785 } __packed;
786 
787 #define L2CAP_SEND_DATA			0x04
788 struct l2cap_send_data_cmd {
789 	uint8_t chan_id;
790 	uint16_t data_len;
791 	uint8_t data[];
792 } __packed;
793 
794 #define L2CAP_TRANSPORT_BREDR		0x00
795 #define L2CAP_TRANSPORT_LE		0x01
796 
797 #define L2CAP_CONNECTION_RESPONSE_SUCCESS		0x00
798 #define L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHEN		0x01
799 #define L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHOR		0x02
800 #define L2CAP_CONNECTION_RESPONSE_INSUFF_ENC_KEY		0x03
801 
802 #define L2CAP_LISTEN			0x05
803 struct l2cap_listen_cmd {
804 	uint16_t psm;
805 	uint8_t transport;
806 	uint16_t mtu;
807 	uint16_t response;
808 } __packed;
809 
810 #define L2CAP_ACCEPT_CONNECTION		0x06
811 struct l2cap_accept_connection_cmd {
812 	uint8_t chan_id;
813 	uint16_t result;
814 } __packed;
815 
816 #define L2CAP_RECONFIGURE		0x07
817 struct l2cap_reconfigure_cmd {
818 	uint8_t address_type;
819 	uint8_t address[6];
820 	uint16_t mtu;
821 	uint8_t num;
822 	uint8_t chan_id[];
823 } __packed;
824 
825 #define L2CAP_CREDITS		0x08
826 struct l2cap_credits_cmd {
827 	uint8_t chan_id;
828 } __packed;
829 
830 #define L2CAP_DISCONNECT_EATT_CHANS		0x09
831 struct l2cap_disconnect_eatt_chans_cmd {
832 	uint8_t address_type;
833 	uint8_t address[6];
834 	uint8_t count;
835 } __packed;
836 
837 /* events */
838 #define L2CAP_EV_CONNECTION_REQ		0x80
839 struct l2cap_connection_req_ev {
840 	uint8_t chan_id;
841 	uint16_t psm;
842 	uint8_t address_type;
843 	uint8_t address[6];
844 } __packed;
845 
846 #define L2CAP_EV_CONNECTED		0x81
847 struct l2cap_connected_ev {
848 	uint8_t chan_id;
849 	uint16_t psm;
850 	uint16_t mtu_remote;
851 	uint16_t mps_remote;
852 	uint16_t mtu_local;
853 	uint16_t mps_local;
854 	uint8_t address_type;
855 	uint8_t address[6];
856 } __packed;
857 
858 #define L2CAP_EV_DISCONNECTED		0x82
859 struct l2cap_disconnected_ev {
860 	uint16_t result;
861 	uint8_t chan_id;
862 	uint16_t psm;
863 	uint8_t address_type;
864 	uint8_t address[6];
865 } __packed;
866 
867 #define L2CAP_EV_DATA_RECEIVED		0x83
868 struct l2cap_data_received_ev {
869 	uint8_t chan_id;
870 	uint16_t data_length;
871 	uint8_t data[];
872 } __packed;
873 
874 #define L2CAP_EV_RECONFIGURED		0x84
875 struct l2cap_reconfigured_ev {
876 	uint8_t chan_id;
877 	uint16_t mtu_remote;
878 	uint16_t mps_remote;
879 	uint16_t mtu_local;
880 	uint16_t mps_local;
881 } __packed;
882 
883 /* MESH Service */
884 /* commands */
885 #define MESH_READ_SUPPORTED_COMMANDS	0x01
886 struct mesh_read_supported_commands_rp {
887 	uint8_t data[0];
888 } __packed;
889 
890 #define MESH_OUT_BLINK			BIT(0)
891 #define MESH_OUT_BEEP			BIT(1)
892 #define MESH_OUT_VIBRATE		BIT(2)
893 #define MESH_OUT_DISPLAY_NUMBER		BIT(3)
894 #define MESH_OUT_DISPLAY_STRING		BIT(4)
895 
896 #define MESH_IN_PUSH			BIT(0)
897 #define MESH_IN_TWIST			BIT(1)
898 #define MESH_IN_ENTER_NUMBER		BIT(2)
899 #define MESH_IN_ENTER_STRING		BIT(3)
900 
901 #define MESH_CONFIG_PROVISIONING	0x02
902 
903 struct set_keys {
904 	uint8_t pub_key[64];
905 	uint8_t priv_key[32];
906 } __packed;
907 
908 struct mesh_config_provisioning_cmd {
909 	uint8_t uuid[16];
910 	uint8_t static_auth[16];
911 	uint8_t out_size;
912 	uint16_t out_actions;
913 	uint8_t in_size;
914 	uint16_t in_actions;
915 	uint8_t auth_method;
916 	struct set_keys set_keys[0];
917 } __packed;
918 
919 #define MESH_PROVISION_NODE		0x03
920 struct mesh_provision_node_cmd {
921 	uint8_t net_key[16];
922 	uint16_t net_key_idx;
923 	uint8_t flags;
924 	uint32_t iv_index;
925 	uint32_t seq_num;
926 	uint16_t addr;
927 	uint8_t dev_key[16];
928 	uint8_t pub_key[0];
929 } __packed;
930 
931 #define MESH_INIT			0x04
932 #define MESH_RESET			0x05
933 #define MESH_INPUT_NUMBER		0x06
934 struct mesh_input_number_cmd {
935 	uint32_t number;
936 } __packed;
937 
938 #define MESH_INPUT_STRING		0x07
939 struct mesh_input_string_cmd {
940 	uint8_t string_len;
941 	uint8_t string[];
942 } __packed;
943 
944 #define MESH_IVU_TEST_MODE		0x08
945 struct mesh_ivu_test_mode_cmd {
946 	uint8_t enable;
947 } __packed;
948 
949 #define MESH_IVU_TOGGLE_STATE			0x09
950 
951 #define MESH_NET_SEND			0x0a
952 struct mesh_net_send_cmd {
953 	uint8_t ttl;
954 	uint16_t src;
955 	uint16_t dst;
956 	uint8_t payload_len;
957 	uint8_t payload[];
958 } __packed;
959 
960 #define MESH_HEALTH_GENERATE_FAULTS	0x0b
961 struct mesh_health_generate_faults_rp {
962 	uint8_t test_id;
963 	uint8_t cur_faults_count;
964 	uint8_t reg_faults_count;
965 	uint8_t current_faults[0];
966 	uint8_t registered_faults[0];
967 } __packed;
968 
969 #define MESH_HEALTH_CLEAR_FAULTS	0x0c
970 
971 #define MESH_LPN			0x0d
972 struct mesh_lpn_set_cmd {
973 	uint8_t enable;
974 } __packed;
975 
976 #define MESH_LPN_POLL			0x0e
977 
978 #define MESH_MODEL_SEND			0x0f
979 struct mesh_model_send_cmd {
980 	uint16_t src;
981 	uint16_t dst;
982 	uint8_t payload_len;
983 	uint8_t payload[];
984 } __packed;
985 
986 #define MESH_LPN_SUBSCRIBE		0x10
987 struct mesh_lpn_subscribe_cmd {
988 	uint16_t address;
989 } __packed;
990 
991 #define MESH_LPN_UNSUBSCRIBE		0x11
992 struct mesh_lpn_unsubscribe_cmd {
993 	uint16_t address;
994 } __packed;
995 
996 #define MESH_RPL_CLEAR			0x12
997 #define MESH_PROXY_IDENTITY		0x13
998 #define MESH_COMP_DATA_GET		0x14
999 struct mesh_comp_data_get_cmd {
1000 	uint16_t net_idx;
1001 	uint16_t address;
1002 	uint8_t page;
1003 } __packed;
1004 
1005 #define MESH_CFG_BEACON_GET		0x15
1006 struct mesh_cfg_val_get_cmd {
1007 	uint16_t net_idx;
1008 	uint16_t address;
1009 } __packed;
1010 
1011 #define MESH_CFG_BEACON_SET		0x16
1012 struct mesh_cfg_beacon_set_cmd {
1013 	uint16_t net_idx;
1014 	uint16_t address;
1015 	uint8_t val;
1016 } __packed;
1017 
1018 #define MESH_CFG_DEFAULT_TTL_GET		0x18
1019 #define MESH_CFG_DEFAULT_TTL_SET		0x19
1020 struct mesh_cfg_default_ttl_set_cmd {
1021 	uint16_t net_idx;
1022 	uint16_t address;
1023 	uint8_t val;
1024 } __packed;
1025 
1026 #define MESH_CFG_GATT_PROXY_GET		0x1a
1027 #define MESH_CFG_GATT_PROXY_SET		0x1b
1028 struct mesh_cfg_gatt_proxy_set_cmd {
1029 	uint16_t net_idx;
1030 	uint16_t address;
1031 	uint8_t val;
1032 } __packed;
1033 
1034 #define MESH_CFG_FRIEND_GET		0x1c
1035 #define MESH_CFG_FRIEND_SET		0x1d
1036 struct mesh_cfg_friend_set_cmd {
1037 	uint16_t net_idx;
1038 	uint16_t address;
1039 	uint8_t val;
1040 } __packed;
1041 
1042 #define MESH_CFG_RELAY_GET		0x1e
1043 #define MESH_CFG_RELAY_SET		0x1f
1044 struct mesh_cfg_relay_set_cmd {
1045 	uint16_t net_idx;
1046 	uint16_t address;
1047 	uint8_t new_relay;
1048 	uint8_t new_transmit;
1049 } __packed;
1050 
1051 #define MESH_CFG_MODEL_PUB_GET		0x20
1052 struct mesh_cfg_model_pub_get_cmd {
1053 	uint16_t net_idx;
1054 	uint16_t address;
1055 	uint16_t elem_address;
1056 	uint16_t model_id;
1057 } __packed;
1058 
1059 #define MESH_CFG_MODEL_PUB_SET		0x21
1060 struct mesh_cfg_model_pub_set_cmd {
1061 	uint16_t net_idx;
1062 	uint16_t address;
1063 	uint16_t elem_address;
1064 	uint16_t model_id;
1065 	uint16_t pub_addr;
1066 	uint16_t app_idx;
1067 	uint8_t cred_flag;
1068 	uint8_t ttl;
1069 	uint8_t period;
1070 	uint8_t transmit;
1071 } __packed;
1072 
1073 #define MESH_CFG_MODEL_SUB_ADD		0x22
1074 #define MESH_CFG_MODEL_SUB_DEL		0x23
1075 struct mesh_cfg_model_sub_cmd {
1076 	uint16_t net_idx;
1077 	uint16_t address;
1078 	uint16_t elem_address;
1079 	uint16_t sub_addr;
1080 	uint16_t model_id;
1081 } __packed;
1082 
1083 #define MESH_CFG_NETKEY_ADD		0x24
1084 struct mesh_cfg_netkey_add_cmd {
1085 	uint16_t net_idx;
1086 	uint16_t address;
1087 	uint8_t net_key[16];
1088 	uint16_t net_key_idx;
1089 } __packed;
1090 
1091 #define MESH_CFG_NETKEY_GET		0x25
1092 #define MESH_CFG_NETKEY_DEL		0x26
1093 struct mesh_cfg_netkey_del_cmd {
1094 	uint16_t net_idx;
1095 	uint16_t address;
1096 	uint16_t net_key_idx;
1097 } __packed;
1098 
1099 #define MESH_CFG_APPKEY_ADD		0x27
1100 struct mesh_cfg_appkey_add_cmd {
1101 	uint16_t net_idx;
1102 	uint16_t address;
1103 	uint16_t net_key_idx;
1104 	uint8_t app_key[16];
1105 	uint16_t app_key_idx;
1106 } __packed;
1107 
1108 #define MESH_CFG_APPKEY_DEL		0x28
1109 struct mesh_cfg_appkey_del_cmd {
1110 	uint16_t net_idx;
1111 	uint16_t address;
1112 	uint16_t net_key_idx;
1113 	uint16_t app_key_idx;
1114 } __packed;
1115 
1116 #define MESH_CFG_APPKEY_GET		0x29
1117 struct mesh_cfg_appkey_get_cmd {
1118 	uint16_t net_idx;
1119 	uint16_t address;
1120 	uint16_t net_key_idx;
1121 } __packed;
1122 
1123 #define MESH_CFG_MODEL_APP_BIND		0x2A
1124 #define MESH_CFG_MODEL_APP_UNBIND		0x2B
1125 struct mesh_cfg_model_app_bind_cmd {
1126 	uint16_t net_idx;
1127 	uint16_t address;
1128 	uint16_t elem_address;
1129 	uint16_t app_key_idx;
1130 	uint16_t mod_id;
1131 } __packed;
1132 
1133 #define MESH_CFG_MODEL_APP_GET		0x2C
1134 #define MESH_CFG_MODEL_APP_VND_GET		0x2D
1135 struct mesh_cfg_model_app_get_cmd {
1136 	uint16_t net_idx;
1137 	uint16_t address;
1138 	uint16_t elem_address;
1139 	uint16_t mod_id;
1140 	uint16_t cid;
1141 } __packed;
1142 
1143 #define MESH_CFG_HEARTBEAT_PUB_SET		0x2E
1144 struct mesh_cfg_heartbeat_pub_set_cmd {
1145 	uint16_t net_idx;
1146 	uint16_t address;
1147 	uint16_t net_key_idx;
1148 	uint16_t destination;
1149 	uint8_t count_log;
1150 	uint8_t period_log;
1151 	uint8_t ttl;
1152 	uint16_t features;
1153 } __packed;
1154 
1155 #define MESH_CFG_HEARTBEAT_PUB_GET		0x2F
1156 #define MESH_CFG_HEARTBEAT_SUB_SET		0x30
1157 struct mesh_cfg_heartbeat_sub_set_cmd {
1158 	uint16_t net_idx;
1159 	uint16_t address;
1160 	uint16_t source;
1161 	uint16_t destination;
1162 	uint8_t period_log;
1163 } __packed;
1164 
1165 #define MESH_CFG_HEARTBEAT_SUB_GET		0x31
1166 #define MESH_CFG_NET_TRANS_GET		0x32
1167 #define MESH_CFG_NET_TRANS_SET		0x33
1168 struct mesh_cfg_net_trans_set_cmd {
1169 	uint16_t net_idx;
1170 	uint16_t address;
1171 	uint8_t transmit;
1172 } __packed;
1173 
1174 #define MESH_CFG_MODEL_SUB_OVW		0x34
1175 #define MESH_CFG_MODEL_SUB_DEL_ALL		0x35
1176 struct mesh_cfg_model_sub_del_all_cmd {
1177 	uint16_t net_idx;
1178 	uint16_t address;
1179 	uint16_t elem_address;
1180 	uint16_t model_id;
1181 } __packed;
1182 
1183 #define MESH_CFG_MODEL_SUB_GET		0x36
1184 struct mesh_cfg_model_sub_get_cmd {
1185 	uint16_t net_idx;
1186 	uint16_t address;
1187 	uint16_t elem_address;
1188 	uint16_t model_id;
1189 } __packed;
1190 
1191 #define MESH_CFG_MODEL_SUB_GET_VND		0x37
1192 struct mesh_cfg_model_sub_get_vnd_cmd {
1193 	uint16_t net_idx;
1194 	uint16_t address;
1195 	uint16_t elem_address;
1196 	uint16_t model_id;
1197 	uint16_t cid;
1198 } __packed;
1199 
1200 #define MESH_CFG_MODEL_SUB_VA_ADD		0x38
1201 #define MESH_CFG_MODEL_SUB_VA_DEL		0x39
1202 #define MESH_CFG_MODEL_SUB_VA_OVW		0x3A
1203 struct mesh_cfg_model_sub_va_cmd {
1204 	uint16_t net_idx;
1205 	uint16_t address;
1206 	uint16_t elem_address;
1207 	uint16_t model_id;
1208 	uint8_t uuid[16];
1209 } __packed;
1210 
1211 #define MESH_CFG_NETKEY_UPDATE		0x3B
1212 #define MESH_CFG_APPKEY_UPDATE		0x3C
1213 #define MESH_CFG_NODE_IDT_SET		0x3D
1214 struct mesh_cfg_node_idt_set_cmd {
1215 	uint16_t net_idx;
1216 	uint16_t address;
1217 	uint16_t net_key_idx;
1218 	uint8_t new_identity;
1219 } __packed;
1220 
1221 #define MESH_CFG_NODE_IDT_GET		0x3E
1222 struct mesh_cfg_node_idt_get_cmd {
1223 	uint16_t net_idx;
1224 	uint16_t address;
1225 	uint16_t net_key_idx;
1226 } __packed;
1227 
1228 #define MESH_CFG_NODE_RESET		0x3F
1229 struct mesh_cfg_node_reset_cmd {
1230 	uint16_t net_idx;
1231 	uint16_t address;
1232 } __packed;
1233 
1234 #define MESH_CFG_LPN_TIMEOUT_GET		0x40
1235 struct mesh_cfg_lpn_timeout_cmd {
1236 	uint16_t net_idx;
1237 	uint16_t address;
1238 	uint16_t unicast_addr;
1239 } __packed;
1240 
1241 #define MESH_CFG_MODEL_PUB_VA_SET		0x41
1242 struct mesh_cfg_model_pub_va_set_cmd {
1243 	uint16_t net_idx;
1244 	uint16_t address;
1245 	uint16_t elem_address;
1246 	uint16_t model_id;
1247 	uint16_t app_idx;
1248 	uint8_t cred_flag;
1249 	uint8_t ttl;
1250 	uint8_t period;
1251 	uint8_t transmit;
1252 	uint8_t uuid[16];
1253 } __packed;
1254 
1255 #define MESH_CFG_MODEL_APP_BIND_VND		0x42
1256 struct mesh_cfg_model_app_bind_vnd_cmd {
1257 	uint16_t net_idx;
1258 	uint16_t address;
1259 	uint16_t elem_address;
1260 	uint16_t app_key_idx;
1261 	uint16_t mod_id;
1262 	uint16_t cid;
1263 } __packed;
1264 
1265 #define MESH_HEALTH_FAULT_GET		0x43
1266 struct mesh_health_fault_get_cmd {
1267 	uint16_t address;
1268 	uint16_t app_idx;
1269 	uint16_t cid;
1270 } __packed;
1271 
1272 #define MESH_HEALTH_FAULT_CLEAR		0x44
1273 struct mesh_health_fault_clear_cmd {
1274 	uint16_t address;
1275 	uint16_t app_idx;
1276 	uint16_t cid;
1277 	uint8_t ack;
1278 } __packed;
1279 
1280 #define MESH_HEALTH_FAULT_TEST		0x45
1281 struct mesh_health_fault_test_cmd {
1282 	uint16_t address;
1283 	uint16_t app_idx;
1284 	uint16_t cid;
1285 	uint8_t test_id;
1286 	uint8_t ack;
1287 } __packed;
1288 
1289 #define MESH_HEALTH_PERIOD_GET		0x46
1290 struct mesh_health_period_get_cmd {
1291 	uint16_t address;
1292 	uint16_t app_idx;
1293 } __packed;
1294 
1295 #define MESH_HEALTH_PERIOD_SET		0x47
1296 struct mesh_health_period_set_cmd {
1297 	uint16_t address;
1298 	uint16_t app_idx;
1299 	uint8_t divisor;
1300 	uint8_t ack;
1301 } __packed;
1302 
1303 #define MESH_HEALTH_ATTENTION_GET		0x48
1304 struct mesh_health_attention_get_cmd {
1305 	uint16_t address;
1306 	uint16_t app_idx;
1307 } __packed;
1308 
1309 #define MESH_HEALTH_ATTENTION_SET		0x49
1310 struct mesh_health_attention_set_cmd {
1311 	uint16_t address;
1312 	uint16_t app_idx;
1313 	uint8_t attention;
1314 	uint8_t ack;
1315 } __packed;
1316 
1317 #define MESH_PROVISION_ADV		0x4A
1318 struct mesh_provision_adv_cmd {
1319 	uint8_t uuid[16];
1320 	uint16_t net_idx;
1321 	uint16_t address;
1322 	uint8_t attention_duration;
1323 	uint8_t net_key[16];
1324 } __packed;
1325 
1326 #define MESH_CFG_KRP_GET		0x4B
1327 struct mesh_cfg_krp_get_cmd {
1328 	uint16_t net_idx;
1329 	uint16_t address;
1330 	uint16_t key_net_idx;
1331 } __packed;
1332 
1333 #define MESH_CFG_KRP_SET		0x4C
1334 struct mesh_cfg_krp_set_cmd {
1335 	uint16_t net_idx;
1336 	uint16_t address;
1337 	uint16_t key_net_idx;
1338 	uint8_t transition;
1339 } __packed;
1340 
1341 /* events */
1342 #define MESH_EV_OUT_NUMBER_ACTION	0x80
1343 struct mesh_out_number_action_ev {
1344 	uint16_t action;
1345 	uint32_t number;
1346 } __packed;
1347 
1348 #define MESH_EV_OUT_STRING_ACTION	0x81
1349 struct mesh_out_string_action_ev {
1350 	uint8_t string_len;
1351 	uint8_t string[];
1352 } __packed;
1353 
1354 #define MESH_EV_IN_ACTION		0x82
1355 struct mesh_in_action_ev {
1356 	uint16_t action;
1357 	uint8_t size;
1358 } __packed;
1359 
1360 #define MESH_EV_PROVISIONED		0x83
1361 
1362 #define MESH_PROV_BEARER_PB_ADV		0x00
1363 #define MESH_PROV_BEARER_PB_GATT	0x01
1364 #define MESH_EV_PROV_LINK_OPEN		0x84
1365 struct mesh_prov_link_open_ev {
1366 	uint8_t bearer;
1367 } __packed;
1368 
1369 #define MESH_EV_PROV_LINK_CLOSED	0x85
1370 struct mesh_prov_link_closed_ev {
1371 	uint8_t bearer;
1372 } __packed;
1373 
1374 #define MESH_EV_NET_RECV		0x86
1375 struct mesh_net_recv_ev {
1376 	uint8_t ttl;
1377 	uint8_t ctl;
1378 	uint16_t src;
1379 	uint16_t dst;
1380 	uint8_t payload_len;
1381 	uint8_t payload[];
1382 } __packed;
1383 
1384 #define MESH_EV_INVALID_BEARER		0x87
1385 struct mesh_invalid_bearer_ev {
1386 	uint8_t opcode;
1387 } __packed;
1388 
1389 #define MESH_EV_INCOMP_TIMER_EXP	0x88
1390 
1391 #define MESH_EV_FRND_ESTABLISHED	0x89
1392 struct mesh_frnd_established_ev {
1393 	uint16_t net_idx;
1394 	uint16_t lpn_addr;
1395 	uint8_t recv_delay;
1396 	uint32_t polltimeout;
1397 } __packed;
1398 
1399 #define MESH_EV_FRND_TERMINATED		0x8a
1400 struct mesh_frnd_terminated_ev {
1401 	uint16_t net_idx;
1402 	uint16_t lpn_addr;
1403 } __packed;
1404 
1405 #define MESH_EV_LPN_ESTABLISHED		0x8b
1406 struct mesh_lpn_established_ev {
1407 	uint16_t net_idx;
1408 	uint16_t friend_addr;
1409 	uint8_t queue_size;
1410 	uint8_t recv_win;
1411 } __packed;
1412 
1413 #define MESH_EV_LPN_TERMINATED		0x8c
1414 struct mesh_lpn_terminated_ev {
1415 	uint16_t net_idx;
1416 	uint16_t friend_addr;
1417 } __packed;
1418 
1419 #define MESH_EV_LPN_POLLED			0x8d
1420 struct mesh_lpn_polled_ev {
1421 	uint16_t net_idx;
1422 	uint16_t friend_addr;
1423 	uint8_t retry;
1424 } __packed;
1425 
1426 #define MESH_EV_PROV_NODE_ADDED		0x8e
1427 struct mesh_prov_node_added_ev {
1428 	uint16_t net_idx;
1429 	uint16_t addr;
1430 	uint8_t uuid[16];
1431 	uint8_t num_elems;
1432 } __packed;
1433 
1434 void tester_init(void);
1435 void tester_rsp(uint8_t service, uint8_t opcode, uint8_t index, uint8_t status);
1436 void tester_send(uint8_t service, uint8_t opcode, uint8_t index, uint8_t *data,
1437 		 size_t len);
1438 
1439 uint8_t tester_init_gap(void);
1440 uint8_t tester_unregister_gap(void);
1441 void tester_handle_gap(uint8_t opcode, uint8_t index, uint8_t *data,
1442 		       uint16_t len);
1443 uint8_t tester_init_gatt(void);
1444 uint8_t tester_unregister_gatt(void);
1445 void tester_handle_gatt(uint8_t opcode, uint8_t index, uint8_t *data,
1446 			uint16_t len);
1447 
1448 #if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
1449 uint8_t tester_init_l2cap(void);
1450 uint8_t tester_unregister_l2cap(void);
1451 void tester_handle_l2cap(uint8_t opcode, uint8_t index, uint8_t *data,
1452 			 uint16_t len);
1453 #endif /* CONFIG_BT_L2CAP_DYNAMIC_CHANNEL */
1454 
1455 #if defined(CONFIG_BT_MESH)
1456 uint8_t tester_init_mesh(void);
1457 uint8_t tester_unregister_mesh(void);
1458 void tester_handle_mesh(uint8_t opcode, uint8_t index, uint8_t *data, uint16_t len);
1459 #endif /* CONFIG_BT_MESH */
1460