1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
|
/* packet-btmesh-provisioning.c
* Routines for Bluetooth mesh Provisioning PDU dissection
*
* Copyright 2019, Piotr Winiarczyk <wino45@gmail.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Ref: Mesh Profile v1.0
* https://www.bluetooth.com/specifications/mesh-specifications
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/tfs.h>
#include "packet-btmesh.h"
#define PROVISIONING_INVITE_PDU 0x00
#define PROVISIONING_CAPABILITIES_PDU 0x01
#define PROVISIONING_START_PDU 0x02
#define PROVISIONING_PUBLIC_KEY_PDU 0x03
#define PROVISIONING_INPUT_COMPLETE_PDU 0x04
#define PROVISIONING_CONFIRMATION_PDU 0x05
#define PROVISIONING_RANDOM_PDU 0x06
#define PROVISIONING_DATA_PDU 0x07
#define PROVISIONING_COMPLETE_PDU 0x08
#define PROVISIONING_FAILED_PDU 0x09
#define NO_OOB_AUTHENTICATION_IS_USED 0x00
#define STATIC_OOB_AUTHENTICATION_IS_USED 0x01
#define OUTPUT_OOB_AUTHENTICATION_IS_USED 0x02
#define INPUT_OOB_AUTHENTICATION_IS_USED 0x03
void proto_register_btmesh_provisioning(void);
static int proto_btmesh_provisioning;
static int hf_btmesh_provisioning_pdu_type;
static int hf_btmesh_provisioning_pdu_padding;
static int hf_btmesh_provisioning_attention_duration;
static int hf_btmesh_provisioning_number_of_elements;
static int hf_btmesh_provisioning_algorithms;
static int hf_btmesh_provisioning_algorithms_p256;
static int hf_btmesh_provisioning_algorithms_rfu;
static int hf_btmesh_provisioning_public_key_type;
static int hf_btmesh_provisioning_public_key_type_oob;
static int hf_btmesh_provisioning_public_key_type_rfu;
static int hf_btmesh_provisioning_static_oob_type;
static int hf_btmesh_provisioning_static_oob_type_static_oob_available;
static int hf_btmesh_provisioning_static_oob_type_rfu;
static int hf_btmesh_provisioning_output_oob_size;
static int hf_btmesh_provisioning_output_oob_action;
static int hf_btmesh_provisioning_output_oob_action_blink;
static int hf_btmesh_provisioning_output_oob_action_beep;
static int hf_btmesh_provisioning_output_oob_action_vibrate;
static int hf_btmesh_provisioning_output_oob_action_output_numeric;
static int hf_btmesh_provisioning_output_oob_action_output_alphanumeric;
static int hf_btmesh_provisioning_output_oob_action_output_rfu;
static int hf_btmesh_provisioning_input_oob_size;
static int hf_btmesh_provisioning_input_oob_action;
static int hf_btmesh_provisioning_input_oob_action_push;
static int hf_btmesh_provisioning_input_oob_action_twist;
static int hf_btmesh_provisioning_input_oob_action_input_numeric;
static int hf_btmesh_provisioning_input_oob_action_input_alphanumeric;
static int hf_btmesh_provisioning_input_oob_action_rfu;
static int hf_btmesh_provisioning_algorithm;
static int hf_btmesh_provisioning_public_key;
static int hf_btmesh_provisioning_authentication_method;
static int hf_btmesh_provisioning_authentication_action_no_oob_action;
static int hf_btmesh_provisioning_authentication_action_static_oob_action;
static int hf_btmesh_provisioning_authentication_action_output_oob_action;
static int hf_btmesh_provisioning_authentication_action_input_oob_action;
static int hf_btmesh_provisioning_authentication_size_no_oob_action;
static int hf_btmesh_provisioning_authentication_size_static_oob_action;
static int hf_btmesh_provisioning_authentication_size_output_oob_action;
static int hf_btmesh_provisioning_authentication_size_input_oob_action;
static int hf_btmesh_provisioning_public_key_x;
static int hf_btmesh_provisioning_public_key_y;
static int hf_btmesh_provisioning_confirmation;
static int hf_btmesh_provisioning_random;
static int hf_btmesh_provisioning_encrypted_provisioning_data;
static int hf_btmesh_provisioning_decrypted_provisioning_data_mic;
static int hf_btmesh_provisioning_error_code;
static int hf_btmesh_provisioning_unknown_data;
static int ett_btmesh_provisioning;
static int ett_btmesh_provisioning_algorithms;
static int ett_btmesh_provisioning_public_key_type;
static int ett_btmesh_provisioning_static_oob_type;
static int ett_btmesh_provisioning_output_oob_action;
static int ett_btmesh_provisioning_output_oob_size;
static int ett_btmesh_provisioning_input_oob_action;
static int ett_btmesh_provisioning_input_oob_size;
static int ett_btmesh_provisioning_algorithm;
static int ett_btmesh_provisioning_public_key;
static int ett_btmesh_provisioning_authentication_method;
static int ett_btmesh_provisioning_authentication_action;
static int ett_btmesh_provisioning_authentication_size;
static int ett_btmesh_provisioning_error_code;
static expert_field ei_btmesh_provisioning_unknown_opcode;
static expert_field ei_btmesh_provisioning_unknown_payload;
static expert_field ei_btmesh_provisioning_unknown_authentication_method;
static expert_field ei_btmesh_provisioning_rfu_not_zero;
static expert_field ei_btmesh_provisioning_in_rfu_range;
static expert_field ei_btmesh_provisioning_prohibited;
static expert_field ei_btmesh_provisioning_zero_elements;
static const value_string btmesh_provisioning_pdu_type_format[] = {
{ 0, "Provisioning Invite PDU" },
{ 1, "Provisioning Capabilities PDU" },
{ 2, "Provisioning Start PDU" },
{ 3, "Provisioning Public Key PDU" },
{ 4, "Provisioning Input Complete PDU" },
{ 5, "Provisioning Confirmation PDU" },
{ 6, "Provisioning Random PDU" },
{ 7, "Provisioning Data PDU" },
{ 8, "Provisioning Complete PDU" },
{ 9, "Provisioning Failed PDU" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_error_code_format[] = {
{ 0, "Prohibited" },
{ 1, "Invalid PDU" },
{ 2, "Invalid Format" },
{ 3, "Unexpected PDU" },
{ 4, "Confirmation Failed" },
{ 5, "Out of Resources" },
{ 6, "Decryption Failed" },
{ 7, "Unexpected Error" },
{ 8, "Cannot Assign Addresses" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_algorithm_format[] = {
{ 0, "FIPS P-256 Elliptic Curve" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_public_key_format[] = {
{ 0, "No OOB Public Key is used" },
{ 1, "OOB Public Key is used" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_method_format[] = {
{ 0, "No OOB authentication is used" },
{ 1, "Static OOB authentication is used" },
{ 2, "Output OOB authentication is used" },
{ 3, "Input OOB authentication is used" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_action_no_oob_action_format[] = {
{ 0, "None" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_action_static_oob_action_format[] = {
{ 0, "None" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_action_output_oob_action_format[] = {
{ 0, "Blink" },
{ 1, "Beep" },
{ 2, "Vibrate" },
{ 3, "Output Numeric" },
{ 4, "Output Alphanumeric" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_action_input_oob_action_format[] = {
{ 0, "Push" },
{ 1, "Twist" },
{ 2, "Input Numeric" },
{ 3, "Input Alphanumeric" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_size_no_oob_action_format[] = {
{ 0, "None" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_size_static_oob_action_format[] = {
{ 0, "None" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_size_output_oob_action_format[] = {
{ 0, "Prohibited" },
{ 1, "The Output OOB size in characters to be used" },
{ 2, "The Output OOB size in characters to be used" },
{ 3, "The Output OOB size in characters to be used" },
{ 4, "The Output OOB size in characters to be used" },
{ 5, "The Output OOB size in characters to be used" },
{ 6, "The Output OOB size in characters to be used" },
{ 7, "The Output OOB size in characters to be used" },
{ 8, "The Output OOB size in characters to be used" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_authentication_size_input_oob_action_format[] = {
{ 0, "Prohibited" },
{ 1, "The Input OOB size in characters to be used" },
{ 2, "The Input OOB size in characters to be used" },
{ 3, "The Input OOB size in characters to be used" },
{ 4, "The Input OOB size in characters to be used" },
{ 5, "The Input OOB size in characters to be used" },
{ 6, "The Input OOB size in characters to be used" },
{ 7, "The Input OOB size in characters to be used" },
{ 8, "The Input OOB size in characters to be used" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_output_oob_size_format[] = {
{ 0, "The device does not support output OOB" },
{ 1, "Maximum size in octets supported by the device" },
{ 2, "Maximum size in octets supported by the device" },
{ 3, "Maximum size in octets supported by the device" },
{ 4, "Maximum size in octets supported by the device" },
{ 5, "Maximum size in octets supported by the device" },
{ 6, "Maximum size in octets supported by the device" },
{ 7, "Maximum size in octets supported by the device" },
{ 8, "Maximum size in octets supported by the device" },
{ 0, NULL }
};
static const value_string btmesh_provisioning_input_oob_size_format[] = {
{ 0, "The device does not support input OOB" },
{ 1, "Maximum size in octets supported by the device" },
{ 2, "Maximum size in octets supported by the device" },
{ 3, "Maximum size in octets supported by the device" },
{ 4, "Maximum size in octets supported by the device" },
{ 5, "Maximum size in octets supported by the device" },
{ 6, "Maximum size in octets supported by the device" },
{ 7, "Maximum size in octets supported by the device" },
{ 8, "Maximum size in octets supported by the device" },
{ 0, NULL }
};
static int
dissect_btmesh_provisioning_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
proto_item *item, *algorithms_item, *public_key_type_item;
proto_item *static_oob_type_item, *output_oob_action_item, *input_oob_action_item;
proto_tree *sub_tree, *algorithms_tree, *public_key_type_tree;
proto_tree *static_oob_type_tree, *output_oob_action_tree, *input_oob_action_tree;
proto_item *expert_item;
proto_tree *expert_tree;
int offset = 0;
btle_mesh_transport_ctx_t *tr_ctx;
btle_mesh_transport_ctx_t dummy_ctx = {E_BTMESH_TR_UNKNOWN, false, 0};
uint8_t authentication_method, authentication_action, authentication_size;
uint8_t provisioning_algorithm;
uint8_t prohibited_value, output_oob_size, input_oob_size;
uint16_t rfu_uint16;
uint8_t no_of_elements;
uint8_t error_code;
uint8_t provisioning_public_key;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BT Mesh Provisioning PDU");
if (data == NULL) {
tr_ctx = &dummy_ctx;
} else {
tr_ctx = (btle_mesh_transport_ctx_t *) data;
}
item = proto_tree_add_item(tree, proto_btmesh_provisioning, tvb, offset, -1, ENC_NA);
sub_tree = proto_item_add_subtree(item, ett_btmesh_provisioning);
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_pdu_type, tvb, offset, 1, ENC_NA);
uint8_t pdu_type = tvb_get_uint8(tvb, offset) & 0x3F;
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_pdu_padding, tvb, offset, 1, ENC_NA);
uint8_t pdu_padding = (tvb_get_uint8(tvb, offset) & 0xC0) >> 6;
if (pdu_padding != 0) {
//Padding should be 0
proto_tree_add_expert(sub_tree, pinfo, &ei_btmesh_provisioning_rfu_not_zero, tvb, offset, -1);
}
offset += 1;
col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(pdu_type, btmesh_provisioning_pdu_type_format, "Unknown Provisioning PDU"));
if (tr_ctx->fragmented) {
switch (tr_ctx->transport) {
case E_BTMESH_TR_ADV:
col_append_fstr(pinfo->cinfo, COL_INFO," (Message fragment %u)", tr_ctx->segment_index);
break;
case E_BTMESH_TR_PROXY:
col_append_str(pinfo->cinfo, COL_INFO," (Last Segment)");
break;
default:
//No default is needed since this is an additional information only
break;
}
}
switch(pdu_type) {
case PROVISIONING_INVITE_PDU:
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_attention_duration, tvb, offset, 1, ENC_NA);
offset += 1;
break;
case PROVISIONING_CAPABILITIES_PDU:
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_number_of_elements, tvb, offset, 1, ENC_NA);
no_of_elements = tvb_get_uint8(tvb, offset);
if (no_of_elements == 0) {
proto_tree_add_expert(sub_tree, pinfo, &ei_btmesh_provisioning_zero_elements, tvb, offset, -1);
}
offset += 1;
algorithms_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_algorithms, tvb, offset, 2, ENC_NA);
algorithms_tree = proto_item_add_subtree(algorithms_item, ett_btmesh_provisioning_algorithms);
proto_tree_add_item(algorithms_tree, hf_btmesh_provisioning_algorithms_p256, tvb, offset, 2, ENC_NA);
proto_tree_add_item(algorithms_tree, hf_btmesh_provisioning_algorithms_rfu, tvb, offset, 2, ENC_NA);
rfu_uint16 = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN) >> 1;
if (rfu_uint16 != 0) {
proto_tree_add_expert(algorithms_tree, pinfo, &ei_btmesh_provisioning_rfu_not_zero, tvb, offset, -1);
}
offset += 2;
public_key_type_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_public_key_type, tvb, offset, 1, ENC_NA);
public_key_type_tree = proto_item_add_subtree(public_key_type_item, ett_btmesh_provisioning_public_key_type);
proto_tree_add_item(public_key_type_tree, hf_btmesh_provisioning_public_key_type_oob, tvb, offset, 1, ENC_NA);
proto_tree_add_item(public_key_type_tree, hf_btmesh_provisioning_public_key_type_rfu, tvb, offset, 1, ENC_NA);
prohibited_value = tvb_get_uint8(tvb, offset) >> 1;
if (prohibited_value != 0) {
proto_tree_add_expert(public_key_type_tree, pinfo, &ei_btmesh_provisioning_prohibited, tvb, offset, -1);
}
offset += 1;
static_oob_type_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_static_oob_type, tvb, offset, 1, ENC_NA);
static_oob_type_tree = proto_item_add_subtree(static_oob_type_item, ett_btmesh_provisioning_static_oob_type);
proto_tree_add_item(static_oob_type_tree, hf_btmesh_provisioning_static_oob_type_static_oob_available, tvb, offset, 1, ENC_NA);
proto_tree_add_item(static_oob_type_tree, hf_btmesh_provisioning_static_oob_type_rfu, tvb, offset, 1, ENC_NA);
prohibited_value = tvb_get_uint8(tvb, offset) >> 1;
if (prohibited_value != 0) {
proto_tree_add_expert(static_oob_type_tree, pinfo, &ei_btmesh_provisioning_prohibited, tvb, offset, -1);
}
offset += 1;
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_output_oob_size, tvb, offset, 1, ENC_NA);
output_oob_size = tvb_get_uint8(tvb, offset);
if (output_oob_size >= 9) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_output_oob_size);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
output_oob_action_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_output_oob_action, tvb, offset, 2, ENC_NA);
output_oob_action_tree = proto_item_add_subtree(output_oob_action_item, ett_btmesh_provisioning_output_oob_action);
proto_tree_add_item(output_oob_action_tree, hf_btmesh_provisioning_output_oob_action_blink, tvb, offset, 2, ENC_NA);
proto_tree_add_item(output_oob_action_tree, hf_btmesh_provisioning_output_oob_action_beep, tvb, offset, 2, ENC_NA);
proto_tree_add_item(output_oob_action_tree, hf_btmesh_provisioning_output_oob_action_vibrate, tvb, offset, 2, ENC_NA);
proto_tree_add_item(output_oob_action_tree, hf_btmesh_provisioning_output_oob_action_output_numeric, tvb, offset, 2, ENC_NA);
proto_tree_add_item(output_oob_action_tree, hf_btmesh_provisioning_output_oob_action_output_alphanumeric, tvb, offset, 2, ENC_NA);
proto_tree_add_item(output_oob_action_tree, hf_btmesh_provisioning_output_oob_action_output_rfu, tvb, offset, 2, ENC_NA);
rfu_uint16 = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN) >> 5;
if (rfu_uint16 != 0) {
proto_tree_add_expert(output_oob_action_tree, pinfo, &ei_btmesh_provisioning_rfu_not_zero, tvb, offset, -1);
}
offset += 2;
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_input_oob_size, tvb, offset, 1, ENC_NA);
input_oob_size = tvb_get_uint8(tvb, offset);
if (input_oob_size >= 9) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_input_oob_size);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
input_oob_action_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_input_oob_action, tvb, offset, 2, ENC_NA);
input_oob_action_tree = proto_item_add_subtree(input_oob_action_item, ett_btmesh_provisioning_input_oob_action);
proto_tree_add_item(input_oob_action_tree, hf_btmesh_provisioning_input_oob_action_push, tvb, offset, 2, ENC_NA);
proto_tree_add_item(input_oob_action_tree, hf_btmesh_provisioning_input_oob_action_twist, tvb, offset, 2, ENC_NA);
proto_tree_add_item(input_oob_action_tree, hf_btmesh_provisioning_input_oob_action_input_numeric, tvb, offset, 2, ENC_NA);
proto_tree_add_item(input_oob_action_tree, hf_btmesh_provisioning_input_oob_action_input_alphanumeric, tvb, offset, 2, ENC_NA);
proto_tree_add_item(input_oob_action_tree, hf_btmesh_provisioning_input_oob_action_rfu, tvb, offset, 2, ENC_NA);
rfu_uint16 = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN) >> 4;
if (rfu_uint16 != 0) {
proto_tree_add_expert(input_oob_action_tree, pinfo, &ei_btmesh_provisioning_rfu_not_zero, tvb, offset, -1);
}
offset += 2;
break;
case PROVISIONING_START_PDU:
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_algorithm, tvb, offset, 1, ENC_NA);
provisioning_algorithm = tvb_get_uint8(tvb, offset);
if (provisioning_algorithm >= 1) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_algorithm);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_public_key, tvb, offset, 1, ENC_NA);
provisioning_public_key = tvb_get_uint8(tvb, offset);
if (provisioning_public_key >= 2) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_public_key);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_method, tvb, offset, 1, ENC_NA);
authentication_method = tvb_get_uint8(tvb, offset);
offset += 1;
switch(authentication_method){
case NO_OOB_AUTHENTICATION_IS_USED:
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_action_no_oob_action, tvb, offset, 1, ENC_NA);
authentication_action = tvb_get_uint8(tvb, offset);
if (authentication_action != 0) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_action);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_size_no_oob_action, tvb, offset, 1, ENC_NA);
authentication_size = tvb_get_uint8(tvb, offset);
if (authentication_size != 0) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_size);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
break;
case STATIC_OOB_AUTHENTICATION_IS_USED:
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_action_static_oob_action, tvb, offset, 1, ENC_NA);
authentication_action = tvb_get_uint8(tvb, offset);
if (authentication_action != 0) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_action);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_size_static_oob_action, tvb, offset, 1, ENC_NA);
authentication_size = tvb_get_uint8(tvb, offset);
if (authentication_size != 0) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_size);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
break;
case OUTPUT_OOB_AUTHENTICATION_IS_USED:
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_action_output_oob_action, tvb, offset, 1, ENC_NA);
authentication_action = tvb_get_uint8(tvb, offset);
if (authentication_action >= 5) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_action);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_size_output_oob_action, tvb, offset, 1, ENC_NA);
authentication_size = tvb_get_uint8(tvb, offset);
if (authentication_size >= 9) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_size);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
} else {
if (authentication_size == 0) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_size);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_prohibited, tvb, offset, -1);
}
}
offset += 1;
break;
case INPUT_OOB_AUTHENTICATION_IS_USED:
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_action_input_oob_action, tvb, offset, 1, ENC_NA);
authentication_action = tvb_get_uint8(tvb, offset);
if (authentication_action >= 4) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_action);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_authentication_size_input_oob_action, tvb, offset, 1, ENC_NA);
authentication_size = tvb_get_uint8(tvb, offset);
if (authentication_size >= 9) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_size);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
} else {
if (authentication_size == 0) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_size);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_prohibited, tvb, offset, -1);
}
}
offset += 1;
break;
default:
//RFU authentication method, display parameters and flag it
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_authentication_method);
proto_tree_add_item(expert_tree, hf_btmesh_provisioning_unknown_data, tvb, offset, -1, ENC_NA);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_unknown_authentication_method, tvb, offset, -1);
offset += tvb_captured_length_remaining(tvb, offset);
break;
}
break;
case PROVISIONING_PUBLIC_KEY_PDU:
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_public_key_x, tvb, offset, 32, ENC_NA);
offset += 32;
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_public_key_y, tvb, offset, 32, ENC_NA);
offset += 32;
break;
case PROVISIONING_INPUT_COMPLETE_PDU:
break;
case PROVISIONING_CONFIRMATION_PDU:
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_confirmation, tvb, offset, 16, ENC_NA);
offset += 16;
break;
case PROVISIONING_RANDOM_PDU:
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_random, tvb, offset, 16, ENC_NA);
offset += 16;
break;
case PROVISIONING_DATA_PDU:
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_encrypted_provisioning_data, tvb, offset, 25, ENC_NA);
offset += 25;
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_decrypted_provisioning_data_mic, tvb, offset, 8, ENC_NA);
offset += 8;
break;
case PROVISIONING_COMPLETE_PDU:
//No parameters for this PDU
break;
case PROVISIONING_FAILED_PDU:
expert_item = proto_tree_add_item(sub_tree, hf_btmesh_provisioning_error_code, tvb, offset, 1, ENC_NA);
error_code = tvb_get_uint8(tvb, offset);
if (error_code >= 9) {
expert_tree = proto_item_add_subtree(expert_item, ett_btmesh_provisioning_error_code);
proto_tree_add_expert(expert_tree, pinfo, &ei_btmesh_provisioning_in_rfu_range, tvb, offset, -1);
}
offset += 1;
break;
default:
//Unknown PDU Type, display data and flag it
proto_tree_add_item(sub_tree, hf_btmesh_provisioning_unknown_data, tvb, offset, -1, ENC_NA);
proto_tree_add_expert(sub_tree, pinfo, &ei_btmesh_provisioning_unknown_opcode, tvb, offset, -1);
offset += tvb_captured_length_remaining(tvb, offset);
break;
}
//There is still some data but all data should be already disssected
if (tvb_captured_length_remaining(tvb, offset) != 0) {
proto_tree_add_expert(sub_tree, pinfo, &ei_btmesh_provisioning_unknown_payload, tvb, offset, -1);
}
return tvb_reported_length(tvb);
}
void
proto_register_btmesh_provisioning(void)
{
static hf_register_info hf[] = {
{ &hf_btmesh_provisioning_pdu_type,
{ "Provisioning PDU Type", "provisioning.pdu_type",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_pdu_type_format), 0x3F,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_pdu_padding,
{ "Provisioning PDU Padding", "provisioning.pdu_padding",
FT_UINT8, BASE_DEC, NULL, 0xC0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_attention_duration,
{ "Attention Duration", "provisioning.attention_duration",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_number_of_elements,
{ "Number of Elements", "provisioning.number_of_elements",
FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_algorithms,
{ "Algorithms", "provisioning.algorithms",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_algorithms_p256,
{ "FIPS P-256 Elliptic Curve", "provisioning.algorithms.p256",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0001,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_algorithms_rfu,
{ "RFU", "provisioning.algorithms.rfu",
FT_UINT16, BASE_DEC, NULL, 0xFFFE,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_public_key_type,
{ "Public Key Type", "provisioning.public_key_type",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_public_key_type_oob,
{ "Public Key Type OOB", "provisioning.public_key_type.oob",
FT_BOOLEAN, 8, TFS(&tfs_available_not_available), 0x01,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_public_key_type_rfu,
{ "RFU", "provisioning.public_key_type.rfu",
FT_UINT8, BASE_DEC, NULL, 0xFE,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_static_oob_type,
{ "Static OOB Type", "provisioning.static_oob_type",
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_static_oob_type_static_oob_available,
{ "Static OOB Information", "provisioning.static_oob_type.static_oob_available",
FT_BOOLEAN, 8, TFS(&tfs_available_not_available), 0x01,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_static_oob_type_rfu,
{ "RFU", "provisioning.static_oob_type.rfu",
FT_UINT8, BASE_DEC, NULL, 0xFE,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_output_oob_size,
{ "Output OOB Size", "provisioning.output_oob_size",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_output_oob_size_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_output_oob_action,
{ "Output OOB Action", "provisioning.output_oob_action",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_output_oob_action_blink,
{ "Blink", "provisioning.output_oob_action.blink",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0001,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_output_oob_action_beep,
{ "Beep", "provisioning.output_oob_action.beep",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0002,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_output_oob_action_vibrate,
{ "Vibrate", "provisioning.output_oob_action.vibrate",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0004,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_output_oob_action_output_numeric,
{ "Output Numeric", "provisioning.output_oob_action.output_numeric",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0008,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_output_oob_action_output_alphanumeric,
{ "Output Alphanumeric", "provisioning.output_oob_action.output_alphanumeric",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0010,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_output_oob_action_output_rfu,
{ "RFU", "provisioning.output_oob_action.rfu",
FT_UINT16, BASE_DEC, NULL, 0xFFE0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_input_oob_size,
{ "Input OOB Size", "provisioning.input_oob_size",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_input_oob_size_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_input_oob_action,
{ "Input OOB Action", "provisioning.input_oob_action",
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_input_oob_action_push,
{ "Push", "provisioning.input_oob_action.push",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0001,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_input_oob_action_twist,
{ "Twist", "provisioning.input_oob_action.twist",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0002,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_input_oob_action_input_numeric,
{ "Input Numeric", "provisioning.input_oob_action.input_numeric",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0004,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_input_oob_action_input_alphanumeric,
{ "Input Alphanumeric", "provisioning.input_oob_action.input_alphanumeric",
FT_BOOLEAN, 16, TFS(&tfs_available_not_available), 0x0008,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_input_oob_action_rfu,
{ "RFU", "provisioning.input_oob_action.rfc",
FT_UINT16, BASE_DEC, NULL, 0xFFF0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_algorithm,
{ "Algorithm", "provisioning.algorithm",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_algorithm_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_public_key,
{ "Public Key", "provisioning.public_key",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_public_key_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_method,
{ "Authentication Method", "provisioning.authentication_method",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_method_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_action_no_oob_action,
{ "No OOB Authentication Action", "provisioning.authentication_action.no_oob_action",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_action_no_oob_action_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_action_static_oob_action,
{ "Static OOB Authentication Action", "provisioning.authentication_action.static_oob_action",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_action_static_oob_action_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_action_output_oob_action,
{ "Output OOB Authentication Action", "provisioning.authentication_action.output_oob_action",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_action_output_oob_action_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_action_input_oob_action,
{ "Input OOB Authentication Action", "provisioning.authentication_action.input_oob_action",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_action_input_oob_action_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_size_no_oob_action,
{ "No OOB Authentication Size", "provisioning.authentication_size.no_oob_action",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_size_no_oob_action_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_size_static_oob_action,
{ "Static OOB Authentication Size", "provisioning.authentication_size.static_oob_action",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_size_static_oob_action_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_size_output_oob_action,
{ "Output OOB Authentication Size", "provisioning.authentication_size.output_oob_action",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_size_output_oob_action_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_authentication_size_input_oob_action,
{ "Input OOB Authentication Size", "provisioning.authentication_size.input_oob_action",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_authentication_size_input_oob_action_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_public_key_x,
{ "Public Key X", "provisioning.public_key_x",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_public_key_y,
{ "Public Key Y", "provisioning.public_key_y",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_confirmation,
{ "Confirmation", "provisioning.confirmation",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_random,
{ "Random", "provisioning.random",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_encrypted_provisioning_data,
{ "Encrypted Provisioning Data", "provisioning.encrypted_provisioning_data",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_decrypted_provisioning_data_mic,
{ "Decrypted Provisioning Data MIC", "provisioning.decrypted_provisioning_data_mic",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_error_code,
{ "Error Code", "provisioning.error_code",
FT_UINT8, BASE_DEC, VALS(btmesh_provisioning_error_code_format), 0x0,
NULL, HFILL }
},
{ &hf_btmesh_provisioning_unknown_data,
{ "Unknown Data", "provisioning.unknown_data",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
};
static int *ett[] = {
&ett_btmesh_provisioning,
&ett_btmesh_provisioning_algorithms,
&ett_btmesh_provisioning_public_key_type,
&ett_btmesh_provisioning_static_oob_type,
&ett_btmesh_provisioning_output_oob_action,
&ett_btmesh_provisioning_output_oob_size,
&ett_btmesh_provisioning_input_oob_action,
&ett_btmesh_provisioning_input_oob_size,
&ett_btmesh_provisioning_algorithm,
&ett_btmesh_provisioning_public_key,
&ett_btmesh_provisioning_authentication_method,
&ett_btmesh_provisioning_authentication_action,
&ett_btmesh_provisioning_authentication_size,
&ett_btmesh_provisioning_error_code,
};
static ei_register_info ei[] = {
{ &ei_btmesh_provisioning_unknown_opcode,{ "provisioning.unknown_opcode", PI_PROTOCOL, PI_ERROR, "Unknown Opcode", EXPFILL } },
{ &ei_btmesh_provisioning_unknown_payload,{ "provisioning.unknown_payload", PI_PROTOCOL, PI_ERROR, "Unknown Payload", EXPFILL } },
{ &ei_btmesh_provisioning_unknown_authentication_method,{ "provisioning.unknown_authentication_method", PI_PROTOCOL, PI_ERROR, "Unknown Authentication Method", EXPFILL } },
{ &ei_btmesh_provisioning_rfu_not_zero,{ "provisioning.rfu_not_zero", PI_PROTOCOL, PI_WARN, "RFU value not equal to 0", EXPFILL } },
{ &ei_btmesh_provisioning_in_rfu_range,{ "provisioning.in_rfu_range", PI_PROTOCOL, PI_WARN, "Value in RFU range", EXPFILL } },
{ &ei_btmesh_provisioning_prohibited,{ "provisioning.prohibited", PI_PROTOCOL, PI_ERROR, "Prohibited value", EXPFILL } },
{ &ei_btmesh_provisioning_zero_elements,{ "provisioning.zero_elements", PI_PROTOCOL, PI_ERROR, "Number of Elements equal to 0 is Prohibited", EXPFILL } },
};
expert_module_t* expert_btmesh_provisioning;
proto_btmesh_provisioning = proto_register_protocol("Bluetooth Mesh Provisioning PDU", "BT Mesh Provisioning", "provisioning");
proto_register_field_array(proto_btmesh_provisioning, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_btmesh_provisioning = expert_register_protocol(proto_btmesh_provisioning);
expert_register_field_array(expert_btmesh_provisioning, ei, array_length(ei));
prefs_register_protocol_subtree("Bluetooth", proto_btmesh_provisioning, NULL);
register_dissector("btmesh.provisioning", dissect_btmesh_provisioning_msg, proto_btmesh_provisioning);
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|