Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-zbee-tlv.c
Line
Count
Source
1
/* packet-zbee-tlv.c
2
 * Dissector routines for the Zbee TLV (R23+)
3
 * Copyright 2021 DSR Corporation, http://dsr-wireless.com/
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include <config.h>
13
#include <epan/expert.h>
14
#include <epan/packet.h>
15
#include <epan/proto_data.h>
16
17
#include "packet-ieee802154.h"
18
#include "packet-ieee802154.h"
19
#include "packet-zbee-tlv.h"
20
#include "packet-zbee.h"
21
#include "packet-zbee-nwk.h"
22
#include "packet-zbee-zdp.h"
23
#include "packet-zbee-aps.h"
24
#include "packet-zbee-direct.h"
25
26
#include "conversation.h"
27
28
/*-------------------------------------
29
 * Dissector Function Prototypes
30
 *-------------------------------------
31
 */
32
static int   dissect_zbee_tlv_default(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_);
33
static unsigned dissect_zdp_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, unsigned cmd_id);
34
static unsigned dissect_aps_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, void *data, unsigned cmd_id);
35
static unsigned dissect_nwk_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, unsigned cmd_id);
36
static unsigned dissect_zbd_local_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset, void* data _U_, unsigned cmd_id);
37
static unsigned dissect_unknown_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
38
39
//Global TLV Dissector Routines
40
static unsigned dissect_zbee_tlv_manufacturer_specific(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t length);
41
static unsigned dissect_zbee_tlv_supported_key_negotiation_methods(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
42
static unsigned dissect_zbee_tlv_configuration_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
43
static unsigned dissect_zbee_tlv_dev_cap_ext(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
44
static unsigned dissect_zbee_tlv_panid_conflict_report(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
45
static unsigned dissect_zbee_tlv_next_pan_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
46
static unsigned dissect_zbee_tlv_next_channel_change(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
47
static unsigned dissect_zbee_tlv_passphrase(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
48
static unsigned dissect_zbee_tlv_router_information(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
49
static unsigned dissect_zbee_tlv_fragmentation_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
50
static unsigned dissect_zbee_tlv_potential_parents(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
51
52
//Local TLV Dissector Routines
53
static unsigned dissect_zbee_tlv_selected_key_negotiation_method(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
54
static unsigned dissect_zbee_tlv_public_point(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t length);
55
static unsigned dissect_zbee_tlv_eui64(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
56
static unsigned dissect_zbee_tlv_clear_all_bindigs_eui64(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
57
static unsigned dissect_zbee_tlv_requested_auth_token_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
58
static unsigned dissect_zbee_tlv_target_ieee_address(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
59
static unsigned dissect_zbee_tlv_device_auth_level(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
60
static unsigned dissect_zbee_tlv_chanmask(proto_tree *tree, tvbuff_t *tvb, unsigned offset, int hf_page, int hf_channel);
61
static unsigned dissect_zbee_tlv_ext_pan_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
62
static unsigned dissect_zbee_tlv_short_pan_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
63
static unsigned dissect_zbee_tlv_nwk_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
64
static unsigned dissect_zbee_tlv_dev_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
65
static unsigned dissect_zbee_tlv_nwk_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
66
static unsigned dissect_zbee_tlv_join_method(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
67
static unsigned dissect_zbee_tlv_ieee_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
68
static unsigned dissect_zbee_tlv_tc_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
69
static unsigned dissect_zbee_tlv_nwk_upd_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
70
static unsigned dissect_zbee_tlv_key_seq_num(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
71
static unsigned dissect_zbee_tlv_adm_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
72
static unsigned dissect_zbee_tlv_mj_prov_lnk_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
73
static unsigned dissect_zbee_tlv_mj_ieee_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
74
static unsigned dissect_zbee_tlv_mj_cmd(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
75
static unsigned dissect_zbee_tlv_nwk_channel_list(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
76
static unsigned dissect_zbee_tlv_link_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
77
static unsigned dissect_zbee_tlv_nwk_status_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset);
78
static unsigned dissect_zbee_tlv_status_code(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
79
static unsigned dissect_zbee_tlv_tunneling_npdu_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset, uint8_t length);
80
static unsigned dissect_zbee_tlv_key_neg_method(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
81
static unsigned dissect_zbee_tlv_mac_tag(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t mac_tag_size);
82
static unsigned dissect_zbee_tlv_nwk_key_seq_num(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
83
84
//Dissectors for ZB Direct
85
static unsigned dissect_zbd_msg_status_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
86
static unsigned dissect_zbd_msg_tunneling_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
87
static unsigned dissect_zbd_msg_manage_joiners_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
88
static unsigned dissect_zbd_msg_join_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
89
static unsigned dissect_zbd_msg_formation_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
90
static unsigned dissect_zbd_msg_secur_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset);
91
92
void proto_register_zbee_tlv(void);
93
void proto_reg_handoff_zbee_tlv(void);
94
95
/* Initialize Protocol and Registered fields */
96
static int proto_zbee_tlv;
97
static dissector_handle_t zigbee_aps_handle;
98
static dissector_handle_t zbee_nwk_handle;
99
100
static int hf_zbee_tlv_global_type;
101
static int hf_zbee_tlv_local_type_key_update_req_rsp;
102
static int hf_zbee_tlv_local_type_key_negotiation_req_rsp;
103
static int hf_zbee_tlv_local_type_get_auth_level_rsp;
104
static int hf_zbee_tlv_local_type_clear_all_bindings_req;
105
static int hf_zbee_tlv_local_type_req_security_get_auth_token;
106
static int hf_zbee_tlv_local_type_req_security_get_auth_level;
107
static int hf_zbee_tlv_local_type_req_security_decommission;
108
static int hf_zbee_tlv_local_type_req_beacon_survey;
109
static int hf_zbee_tlv_local_type_rsp_beacon_survey;
110
static int hf_zbee_tlv_local_type_req_challenge;
111
static int hf_zbee_tlv_local_type_rsp_challenge;
112
static int hf_zbee_tlv_local_type_rsp_set_configuration;
113
static int hf_zbee_tlv_local_type_lk_features;
114
static int hf_zbee_tlv_local_type_lk_features_capabilities;
115
static int hf_zbee_tlv_local_type_lk_features_capabilities_aps_fc_sync;
116
static int hf_zbee_tlv_local_type_route_req;
117
static int hf_zbee_tlv_local_type_route_reply;
118
static int hf_zbee_tlv_local_type_network_status;
119
120
static int hf_zbee_tlv_length;
121
static int hf_zbee_tlv_type;
122
static int hf_zbee_tlv_value;
123
static int hf_zbee_tlv_count;
124
static int hf_zbee_tlv_manufacturer_specific;
125
126
static int hf_zbee_tlv_local_status_count;
127
static int hf_zbee_tlv_local_type_id;
128
static int hf_zbee_tlv_local_proc_status;
129
130
static int hf_zbee_tlv_local_comm_ext_pan_id;
131
static int hf_zbee_tlv_local_comm_short_pan_id;
132
static int hf_zbee_tlv_local_comm_channel_mask;
133
static int hf_zbee_tlv_local_comm_channel_page;
134
static int hf_zbee_tlv_local_comm_channel_page_count;
135
static int hf_zbee_tlv_local_comm_nwk_key;
136
static int hf_zbee_tlv_local_comm_link_key;
137
static int hf_zbee_tlv_local_comm_link_key_flags;
138
static int hf_zbee_tlv_local_comm_link_key_flags_unique;
139
static int hf_zbee_tlv_local_comm_link_key_flags_provisional;
140
static int hf_zbee_tlv_local_comm_dev_type;
141
static int hf_zbee_tlv_local_comm_nwk_addr;
142
static int hf_zbee_tlv_local_comm_join_method;
143
static int hf_zbee_tlv_local_comm_tc_addr;
144
static int hf_zbee_tlv_local_comm_network_status_map;
145
static int hf_zbee_tlv_local_comm_network_status_map_joined_status;
146
static int hf_zbee_tlv_local_comm_network_status_map_open_status;
147
static int hf_zbee_tlv_network_status_map_network_type;
148
static int hf_zbee_tlv_local_comm_nwk_upd_id;
149
static int hf_zbee_tlv_local_comm_key_seq_num;
150
static int hf_zbee_tlv_local_comm_adm_key;
151
static int hf_zbee_tlv_local_comm_status_code_domain;
152
static int hf_zbee_tlv_local_comm_status_code_value;
153
static int hf_zbee_tlv_local_comm_mj_prov_lnk_key;
154
static int hf_zbee_tlv_local_comm_mj_ieee_addr;
155
static int hf_zbee_tlv_local_comm_mj_cmd;
156
157
static int hf_zbee_tlv_local_tunneling_npdu;
158
static int hf_zbee_tlv_local_tunneling_npdu_flags;
159
static int hf_zbee_tlv_local_tunneling_npdu_flags_security;
160
static int hf_zbee_tlv_local_tunneling_npdu_flags_reserved;
161
static int hf_zbee_tlv_local_tunneling_npdu_length;
162
163
static int hf_zbee_tlv_local_selected_key_method;
164
static int hf_zbee_tlv_local_selected_psk_secret;
165
static int hf_zbee_tlv_local_nwk_key_seq_num;
166
static int hf_zbee_tlv_local_mac_tag;
167
168
static int hf_zbee_tlv_zbd_comm_tlv;
169
static int hf_zbee_tlv_zbd_comm_mj_cmd_tlv;
170
static int hf_zbee_tlv_zbd_secur_tlv;
171
static int hf_zbee_tlv_zbd_tunneling_npdu_msg_tlv;
172
173
static int hf_zbee_tlv_next_pan_id;
174
static int hf_zbee_tlv_next_channel_change;
175
static int hf_zbee_tlv_passphrase;
176
static int hf_zbee_tlv_configuration_param;
177
static int hf_zbee_tlv_configuration_param_restricted_mode;
178
static int hf_zbee_tlv_configuration_param_link_key_enc;
179
static int hf_zbee_tlv_configuration_param_leave_req_allowed;
180
181
static int hf_zbee_tlv_dev_cap_ext_capability_information;
182
static int hf_zbee_tlv_dev_cap_ext_zbdirect_virt_device;
183
184
static int hf_zbee_tlv_challenge_value;
185
static int hf_zbee_tlv_aps_frame_counter;
186
static int hf_zbee_tlv_challenge_counter;
187
static int hf_zbee_tlv_mic64;
188
189
static int hf_zbee_tlv_lqa;
190
191
static int hf_zbee_tlv_router_information;
192
static int hf_zbee_tlv_router_information_hub_connectivity;
193
static int hf_zbee_tlv_router_information_uptime;
194
static int hf_zbee_tlv_router_information_pref_parent;
195
static int hf_zbee_tlv_router_information_battery_backup;
196
static int hf_zbee_tlv_router_information_enhanced_beacon_request_support;
197
static int hf_zbee_tlv_router_information_mac_data_poll_keepalive_support;
198
static int hf_zbee_tlv_router_information_end_device_keepalive_support;
199
static int hf_zbee_tlv_router_information_power_negotiation_support;
200
201
static int hf_zbee_tlv_node_id;
202
static int hf_zbee_tlv_frag_opt;
203
static int hf_zbee_tlv_max_reassembled_buf_size;
204
205
static int hf_zbee_tlv_supported_key_negotiation_methods;
206
static int hf_zbee_tlv_supported_key_negotiation_methods_key_request;
207
static int hf_zbee_tlv_supported_key_negotiation_methods_ecdhe_using_curve25519_aes_mmo128;
208
static int hf_zbee_tlv_supported_key_negotiation_methods_ecdhe_using_curve25519_sha256;
209
static int hf_zbee_tlv_supported_secrets;
210
static int hf_zbee_tlv_supported_preshared_secrets_auth_token;
211
static int hf_zbee_tlv_supported_preshared_secrets_ic;
212
static int hf_zbee_tlv_supported_preshared_secrets_passcode_pake;
213
static int hf_zbee_tlv_supported_preshared_secrets_basic_access_key;
214
static int hf_zbee_tlv_supported_preshared_secrets_admin_access_key;
215
216
static int hf_zbee_tlv_panid_conflict_cnt;
217
218
static int hf_zbee_tlv_selected_key_negotiation_method;
219
static int hf_zbee_tlv_selected_pre_shared_secret;
220
static int hf_zbee_tlv_device_eui64;
221
static int hf_zbee_tlv_public_point;
222
static int hf_zbee_tlv_global_tlv_id;
223
static int hf_zbee_tlv_local_ieee_addr;
224
static int hf_zbee_tlv_local_initial_join_method;
225
static int hf_zbee_tlv_local_active_lk_type;
226
227
static int hf_zbee_tlv_relay_msg_type;
228
static int hf_zbee_tlv_relay_msg_length;
229
static int hf_zbee_tlv_relay_msg_joiner_ieee;
230
231
static int hf_zbee_tlv_routing_sequence_number;
232
static int hf_zbee_tlv_initial_radius;
233
static int hf_zbee_tlv_concentrator_discovery_time;
234
static int hf_zbee_tlv_max_source_route_length;
235
static int hf_zbee_tlv_nwk_addr_of_interest;
236
237
static int ett_zbee_aps_tlv;
238
static int ett_zbee_aps_relay;
239
static int ett_zbee_tlv;
240
static int ett_zbee_tlv_supported_key_negotiation_methods;
241
static int ett_zbee_tlv_supported_secrets;
242
static int ett_zbee_tlv_router_information;
243
static int ett_zbee_tlv_configuration_param;
244
static int ett_zbee_tlv_capability_information;
245
246
static int ett_zbee_tlv_zbd_tunneling_npdu;
247
static int ett_zbee_tlv_zbd_tunneling_npdu_flags;
248
249
static int ett_zbee_tlv_link_key_flags;
250
static int ett_zbee_tlv_network_status_map;
251
static int ett_zbee_tlv_lk_features_capabilities;
252
253
static expert_field ei_zbee_tlv_max_recursion_depth_reached;
254
255
/* Cached protocol identifier */
256
static int proto_zbee_nwk;
257
258
static const value_string zbee_tlv_local_types_key_method_str[] =
259
{
260
    { ZBEE_TLV_TYPE_KEY_ECDHE_CURVE_25519_HASH_AESMMO128, "Curve 25519 / AESMMO-128" },
261
    { ZBEE_TLV_TYPE_KEY_ECDHE_CURVE_25519_HASH_SHA256,    "Curve 25519 / SHA-256" },
262
    { ZBEE_TLV_TYPE_KEY_ECDHE_CURVE_P256_HASH_SHA256,     "P-256 / SHA-256" },
263
    { 0, NULL }
264
};
265
266
static const value_string zbee_tlv_local_types_psk_secret_str[] =
267
{
268
    { ZBEE_TLV_TYPE_PSK_WELL_KNOWN_KEY,                   "Well known key" },
269
    { ZBEE_TLV_TYPE_PSK_SECRET_AUTH_TOKEN,                "Authorization token" },
270
    { ZBEE_TLV_TYPE_PSK_SECRET_INSTALL_CODE,              "Pre-configured link-ley derived from installation code" },
271
    { ZBEE_TLV_TYPE_PSK_SECRET_PAKE_PASSCODE,             "PAKE passcode" },
272
    { ZBEE_TLV_TYPE_PSK_SECRET_BASIC_ACCESS_KEY,          "Basic Access Key" },
273
    { ZBEE_TLV_TYPE_PSK_SECRET_ADMINISTRATIVE_ACCESS_KEY, "Administrative Access Key" },
274
    { 0, NULL }
275
};
276
277
static const value_string zbee_tlv_local_types_dev_type_str[] =
278
{
279
    { ZBEE_TLV_TYPE_DEV_TYPE_ZC, "ZigBee Coordinator" },
280
    { ZBEE_TLV_TYPE_DEV_TYPE_ZR, "ZigBee Router" },
281
    { ZBEE_TLV_TYPE_DEV_TYPE_ED, "ZigBee End Device" },
282
    { 0, NULL }
283
};
284
285
static const value_string zbee_tlv_local_types_join_method_str[] =
286
{
287
    { ZBEE_TLV_TYPE_JOIN_METHOD_MAC_ASS,           "MAC association" },
288
    { ZBEE_TLV_TYPE_JOIN_METHOD_NWK_REJ,           "NWK rejoin" },
289
    { ZBEE_TLV_TYPE_JOIN_METHOD_OOB_WITH_CHECK,    "Out-of-band commissioning (with check for nearby IEEE 802.15.4 beacons)" },
290
    { ZBEE_TLV_TYPE_JOIN_METHOD_OOB_WITHOUT_CHECK, "Out-of-band commissioning (without check for nearby IEEE 802.15.4 beacons)" },
291
    { 0, NULL }
292
};
293
294
static const value_string zbee_tlv_local_types_status_code_domain_str[] =
295
{
296
    { ZBEE_TLV_TYPE_ZBD_STATUS_DOMAIN_GENERAL,         "General domain or unspecific operation" },
297
    { ZBEE_TLV_TYPE_ZBD_STATUS_DOMAIN_FORM,            "Form Network Operation" },
298
    { ZBEE_TLV_TYPE_ZBD_STATUS_DOMAIN_JOIN,            "Join Network Operation" },
299
    { ZBEE_TLV_TYPE_ZBD_STATUS_DOMAIN_PERMIT_JOIN,     "Permit Joining Operation" },
300
    { ZBEE_TLV_TYPE_ZBD_STATUS_DOMAIN_LEAVE,           "Leave Network Operation" },
301
    { ZBEE_TLV_TYPE_ZBD_STATUS_DOMAIN_MANAGE_JOINERS,  "Manage Joiners Domain" },
302
    { ZBEE_TLV_TYPE_ZBD_STATUS_DOMAIN_IDENTIFY,        "Identify Operation" },
303
    { ZBEE_TLV_TYPE_ZBD_STATUS_DOMAIN_FINDING_BINDING, "Finding & Binding Domain" },
304
    { 0, NULL }
305
};
306
307
static const value_string zbee_tlv_local_types_joined_status_str[] =
308
{
309
    { ZBEE_TLV_TYPE_JOINED_STATUS_NO_NWK,           "No network" },
310
    { ZBEE_TLV_TYPE_JOINED_STATUS_JOINING,          "Joining" },
311
    { ZBEE_TLV_TYPE_JOINED_STATUS_JOINED,           "Joined" },
312
    { ZBEE_TLV_TYPE_JOINED_STATUS_JOINED_NO_PARENT, "Joined (no parent)" },
313
    { ZBEE_TLV_TYPE_JOINED_STATUS_LEAVING,          "Leaving" },
314
    { 0, NULL }
315
};
316
317
static const value_string zbee_tlv_local_types_nwk_type_str[] =
318
{
319
    { ZBEE_TLV_NWK_TYPE_DISTRIBUTED, "Distributed" },
320
    { ZBEE_TLV_NWK_TYPE_CENTRALIZED, "Centralized" },
321
    { 0, NULL }
322
};
323
324
static const value_string zbee_tlv_local_types_nwk_state_str[] =
325
{
326
    { ZBEE_TLV_TYPE_NWK_STATE_CLOSED, "Closed" },
327
    { ZBEE_TLV_TYPE_NWK_STATE_OPENED, "Opened" },
328
    { 0, NULL }
329
};
330
331
static const value_string zbee_tlv_local_types_mj_cmd_str[] =
332
{
333
    { ZBEE_TLV_TYPE_MANAGE_JOINERS_CMD_DROP,   "Drop all joiners' Provisional Link Keys" },
334
    { ZBEE_TLV_TYPE_MANAGE_JOINERS_CMD_ADD,    "Add a joiner's Provisional Link Key" },
335
    { ZBEE_TLV_TYPE_MANAGE_JOINERS_CMD_REMOVE, "Remove a joiner's Provisional Link Key" },
336
    { 0, NULL }
337
};
338
339
static const value_string zbee_tlv_local_types_lnk_key_unique_str[] =
340
{
341
    { ZBEE_TLV_TYPE_LINK_KEY_FLAG_GLOBAL, "Global" },
342
    { ZBEE_TLV_TYPE_LINK_KEY_FLAG_UNIQUE, "Unique" },
343
    { 0, NULL }
344
};
345
346
static const value_string zbee_tlv_local_types_lnk_key_provisional_str[] =
347
{
348
    { ZBEE_TLV_TYPE_LINK_KEY_FLAG_PERMANENT,   "Permanent" },
349
    { ZBEE_TLV_TYPE_LINK_KEY_FLAG_PROVISIONAL, "Provisional" },
350
    { 0, NULL }
351
};
352
353
static const value_string zbee_tlv_zbd_comm_types[] = {
354
    { ZBEE_TLV_TYPE_COMM_EXT_PAN_ID,      "Extended PAN ID" },
355
    { ZBEE_TLV_TYPE_COMM_SHORT_PAN_ID,    "Short PAN ID" },
356
    { ZBEE_TLV_TYPE_COMM_NWK_CH,          "Network Channel" },
357
    { ZBEE_TLV_TYPE_COMM_NWK_KEY,         "Network Key" },
358
    { ZBEE_TLV_TYPE_COMM_LNK_KEY,         "Link Key" },
359
    { ZBEE_TLV_TYPE_COMM_DEV_TYPE,        "Device Type" },
360
    { ZBEE_TLV_TYPE_COMM_NWK_ADDR,        "NWK Address" },
361
    { ZBEE_TLV_TYPE_COMM_JOIN_METHOD,     "Joining Method" },
362
    { ZBEE_TLV_TYPE_COMM_IEEE_ADDR,       "IEEE Address" },
363
    { ZBEE_TLV_TYPE_COMM_TC_ADDR,         "Trust Center Address" },
364
    { ZBEE_TLV_TYPE_COMM_NWK_STATUS_MAP,  "Network Status Map" },
365
    { ZBEE_TLV_TYPE_COMM_NWK_UPD_ID,      "NWK Update ID" },
366
    { ZBEE_TLV_TYPE_COMM_KEY_SEQ_NUM,     "NWK Active Key Seq Number" },
367
    { ZBEE_TLV_TYPE_COMM_ADMIN_KEY,       "Admin Key" },
368
    { ZBEE_TLV_TYPE_COMM_STATUS_CODE,     "Status Code" },
369
370
    // TODO: Not implemented yet
371
    // { 0x0f,                                      "Extended Status Code" },
372
    { 0, NULL }
373
};
374
375
static const value_string zbee_tlv_zbd_comm_mj_types[] = {
376
    { ZBEE_TLV_TYPE_COMM_MJ_PROVISIONAL_LINK_KEY,  "Provisional Link" },
377
    { ZBEE_TLV_TYPE_COMM_MJ_IEEE_ADDR,             "IEEE Address" },
378
    { ZBEE_TLV_TYPE_COMM_MJ_CMD,                   "Manage Joiners Command" },
379
380
    // 0x03-0xff - Reserved
381
    { 0, NULL }
382
};
383
384
static const value_string zbee_tlv_zbd_secur_types[] = {
385
    { ZBEE_TLV_TYPE_KEY_METHOD,        "ZBD Key Negotiation Method TLV" },
386
    { ZBEE_TLV_TYPE_PUB_POINT_P256,    "ZBD Key Negotiation P-256 Public Point TLV" },
387
    { ZBEE_TLV_TYPE_PUB_POINT_C25519,  "ZBD Key Negotiation Curve25519 Public Point TLV" },
388
    { ZBEE_TLV_TYPE_NWK_KEY_SEQ_NUM,   "Network KeySequence Number TLV" },
389
    { ZBEE_TLV_TYPE_MAC_TAG,           "MacTag Tlv" },
390
    { 0, NULL }
391
};
392
393
static const value_string zbee_aps_relay_tlvs[] = {
394
    { 0,          "Relay Message TLV" },
395
    { 0, NULL }
396
};
397
398
static const value_string zbee_tlv_global_types[] = {
399
    { ZBEE_TLV_TYPE_MANUFACTURER_SPECIFIC,                "Manufacturer Specific Global TLV" },
400
    { ZBEE_TLV_TYPE_SUPPORTED_KEY_NEGOTIATION_METHODS,    "Supported Key Negotiation Methods Global TLV" },
401
    { ZBEE_TLV_TYPE_PANID_CONFLICT_REPORT,                "PAN ID Conflict Report Global TLV"},
402
    { ZBEE_TLV_TYPE_NEXT_PAN_ID,                          "Next PAN ID Global TLV" },
403
    { ZBEE_TLV_TYPE_NEXT_CHANNEL_CHANGE,                  "Next Channel Change Global TLV" },
404
    { ZBEE_TLV_TYPE_PASSPHRASE,                           "Passphrase Global TLV" },
405
    { ZBEE_TLV_TYPE_ROUTER_INFORMATION,                   "Router Information Global TLV" },
406
    { ZBEE_TLV_TYPE_FRAGMENTATION_PARAMETERS,             "Fragmentation Parameters Global TLV" },
407
    { ZBEE_TLV_TYPE_JOINER_ENCAPSULATION_GLOBAL,          "Joiner Encapsulation Global TLV" },
408
    { ZBEE_TLV_TYPE_BEACON_APPENDIX_ENCAPSULATION_GLOBAL, "Beacon Appendix Encapsulation Global TLV" },
409
    { ZBEE_TLV_TYPE_CONFIGURATION_MODE_PARAMETERS,        "Configuration Mode Parameters Global TLV" },
410
    { ZBEE_TLV_TYPE_DEVICE_CAPABILITY_EXTENSION,          "Device Capability Extension Global TLV" },
411
    { 0, NULL }
412
};
413
414
static const value_string zbee_tlv_local_types_key_update_req_rsp[] = {
415
    { ZBEE_TLV_TYPE_KEY_UPD_REQ_SELECTED_KEY_NEGOTIATION_METHOD,   "Selected Key Negotiations Method Local TLV" },
416
    { 0, NULL }
417
};
418
419
static const value_string zbee_tlv_local_types_key_negotiation_req_rsp[] = {
420
    { ZBEE_TLV_TYPE_KEY_NEG_REQ_CURVE25519_PUBLIC_POINT,           "Curve25519 Public Point Local TLV" },
421
    { 0, NULL }
422
};
423
424
static const value_string zbee_tlv_local_types_get_auth_level_rsp[] = {
425
    { ZBEE_TLV_TYPE_GET_AUTH_LEVEL,                    "Device Authentication Level TLV" },
426
    { 0, NULL }
427
};
428
429
static const value_string zbee_tlv_local_types_clear_all_bindings_req[] = {
430
    { ZBEE_TLV_TYPE_CLEAR_ALL_BINDIGS_REQ_EUI64,       "Clear All Bindings Req EUI64 TLV" },
431
    { 0, NULL }
432
};
433
434
static const value_string zbee_tlv_local_types_req_security_get_auth_token[] = {
435
    { ZBEE_TLV_TYPE_REQUESTED_AUTH_TOKEN_ID,           "Requested Authentication Token ID TLV" },
436
    { 0, NULL }
437
};
438
439
static const value_string zbee_tlv_local_types_req_security_get_auth_level[] = {
440
    { ZBEE_TLV_TYPE_TARGET_IEEE_ADDRESS,               "Target IEEE Address TLV" },
441
    { 0, NULL }
442
};
443
444
static const value_string zbee_tlv_local_types_req_security_decommission[] = {
445
    { ZBEE_TLV_TYPE_EUI64,                             "EUI64 TLV" },
446
    { 0, NULL }
447
};
448
449
static const value_string zbee_tlv_local_types_req_beacon_survey[] = {
450
    { ZBEE_TLV_TYPE_BEACON_SURVEY_CONFIGURATION,       "Beacon Survey Configuration TLV" },
451
    { 0, NULL }
452
};
453
454
static const value_string zbee_tlv_local_types_req_challenge[] = {
455
    { 0,       "APS Frame Counter Challenge Request TLV" },
456
    { 0, NULL }
457
};
458
459
static const value_string zbee_tlv_local_types_rsp_challenge[] = {
460
    { 0,       "APS Frame Counter Challenge Response TLV" },
461
    { 0, NULL }
462
};
463
464
static const value_string zbee_tlv_local_types_rsp_set_configuration[] = {
465
    { 0,       "Processing status TLV" },
466
    { 0, NULL }
467
};
468
469
static const value_string zbee_tlv_local_types_route_req[] = {
470
    { ZBEE_TLV_TYPE_EXTENDED_ROUTE_INFO,       "Extended Route Information TLV" },
471
    { ZBEE_TLV_TYPE_CONCENTRATOR_INFO,         "Concentrator Information TLV" },
472
    { ZBEE_TLV_TYPE_SOURCE_ROUTE_SOLICIT_INFO, "Source Route Solicitation TLV"},
473
    { 0, NULL }
474
};
475
476
static const value_string zbee_tlv_local_types_route_reply[] = {
477
    { ZBEE_TLV_TYPE_EXTENDED_ROUTE_INFO,       "Extended Route Information TLV" },
478
    { 0, NULL }
479
};
480
481
static const value_string zbee_tlv_local_types_network_status[] = {
482
    { ZBEE_TLV_TYPE_EXTENDED_ROUTE_INFO,       "Extended Route Information TLV" },
483
    { 0, NULL }
484
};
485
486
static const value_string zbee_tlv_local_types_rsp_beacon_survey[] = {
487
    { ZBEE_TLV_TYPE_BEACON_SURVEY_CONFIGURATION,       "Beacon Survey Configuration TLV" },
488
    { ZBEE_TLV_TYPE_BEACON_SURVEY_RESULTS,             "Beacon Survey Results TLV" },
489
    { ZBEE_TLV_TYPE_BEACON_SURVEY_POTENTIAL_PARENTS,   "Beacon Survey Potential Parents TLV"},
490
    { 0, NULL }
491
};
492
493
static const value_string zbee_tlv_selected_key_negotiation_method[] = {
494
    { ZBEE_TLV_SELECTED_KEY_NEGOTIATION_METHODS_ZB_30,                             "Zigbee 3.0" },
495
    { ZBEE_TLV_SELECTED_KEY_NEGOTIATION_METHODS_ECDHE_USING_CURVE25519_AES_MMO128, "ECDHE using Curve25519 with Hash AES-MMO-128" },
496
    { ZBEE_TLV_SELECTED_KEY_NEGOTIATION_METHODS_ECDHE_USING_CURVE25519_SHA256,     "ECDHE using Curve25519 with Hash SHA-256" },
497
    { 0, NULL }
498
};
499
500
static const value_string zbee_tlv_selected_pre_shared_secret[] = {
501
    { ZBEE_TLV_SELECTED_PRE_SHARED_WELL_KNOWN_KEY,            "Well Known Key" },
502
    { ZBEE_TLV_SELECTED_PRE_SHARED_SECRET_AUTH_TOKEN,         "Symmetric Authentication Token" },
503
    { ZBEE_TLV_SELECTED_PRE_SHARED_SECRET_LINK_KEY_IC,        "Pre-configured link-ley derived from installation code" },
504
    { ZBEE_TLV_SELECTED_PRE_SHARED_SECRET_VLEN_PASSCODE,      "Variable-length pass code" },
505
    { ZBEE_TLV_SELECTED_PRE_SHARED_SECRET_BASIC_ACCESS_KEY,   "Basic Access Key" },
506
    { ZBEE_TLV_SELECTED_PRE_SHARED_SECRET_ADMIN_ACCESS_KEY,   "Administrative Access Key" },
507
    { 0, NULL }
508
};
509
510
static const value_string zbee_initial_join_methods[] = {
511
    { 0x00, "No authentication" },
512
    { 0x01, "Install Code Key" },
513
    { 0x02, "Anonymous key negotiation" },
514
    { 0x03, "Authentication Key Negotiation" },
515
    { 0, NULL }
516
};
517
518
static const value_string zbee_active_lk_types[] = {
519
    { 0x00, "Not Updated" },
520
    { 0x01, "Key Request Method" },
521
    { 0x02, "Unauthentication Key Negotiation" },
522
    { 0x03, "Authentication Key Negotiation" },
523
    { 0x04, "Application Defined Certificate Based Mutual" },
524
    { 0, NULL }
525
};
526
527
static unsigned
528
dissect_aps_relay_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, void *data)
529
14
{
530
14
  tvbuff_t    *relay_tvb;
531
14
  proto_item  *relayed_frame_root;
532
14
  proto_tree  *relayed_frame_tree;
533
14
  uint8_t     length;
534
14
  zbee_nwk_hints_t *nwk_hints;
535
536
14
  zigbee_aps_handle = find_dissector("zbee_aps");
537
538
14
  proto_tree_add_item(tree, hf_zbee_tlv_relay_msg_type, tvb, offset, 1, ENC_NA);
539
14
  offset += 1;
540
541
14
  length = tvb_get_uint8(tvb, offset) + 1;
542
14
  proto_tree_add_item(tree, hf_zbee_tlv_relay_msg_length, tvb, offset, 1, ENC_NA);
543
14
  offset += 1;
544
545
14
  proto_tree_add_item(tree, hf_zbee_tlv_relay_msg_joiner_ieee, tvb, offset, 8, ENC_LITTLE_ENDIAN);
546
14
  nwk_hints = (zbee_nwk_hints_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_zbee_nwk, 0);
547
14
  if (nwk_hints) {
548
14
    nwk_hints->joiner_addr64 = tvb_get_letoh64(tvb, offset);
549
14
  }
550
14
  offset += 8;
551
552
  /* The remainder is a relayed APS frame. */
553
14
  relay_tvb = tvb_new_subset_remaining(tvb, offset);
554
14
  relayed_frame_tree = proto_tree_add_subtree_format(tree, tvb, offset, length - 8, ett_zbee_aps_relay, &relayed_frame_root,
555
14
          "Relayed APS Frame");
556
14
  call_dissector_with_data(zigbee_aps_handle, relay_tvb, pinfo, relayed_frame_tree, data);
557
558
  /* Add column info */
559
14
  col_append_str(pinfo->cinfo, COL_INFO, ", Relay");
560
561
14
  return tvb_captured_length(tvb);
562
14
}
563
564
/**
565
 *Dissector for Link-Key Features & Capabilities TLV
566
 *
567
 *@param tvb pointer to buffer containing raw packet.
568
 *@param pinfo pointer to packet information fields
569
 *@param tree pointer to data tree Wireshark uses to display packet.
570
 *@param  offset into the tvb to begin dissection.
571
 *@return offset after command dissection.
572
 */
573
static unsigned
574
dissect_lk_features_capabilities_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
575
91
{
576
91
    static int * const features_capabilities_flags[] = {
577
91
        &hf_zbee_tlv_local_type_lk_features_capabilities_aps_fc_sync,
578
91
        NULL
579
91
    };
580
581
    /* Type */
582
91
    proto_tree_add_item(tree, hf_zbee_tlv_local_type_lk_features_capabilities, tvb, offset, 1, ENC_NA);
583
91
    offset += 1;
584
585
    /* Length */
586
91
    proto_tree_add_item(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA);
587
91
    offset += 1;
588
589
    /* Features and Capabilities bitmask. */
590
91
    proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_tlv_local_type_lk_features,
591
91
        ett_zbee_tlv_lk_features_capabilities, features_capabilities_flags, ENC_NA);
592
91
    offset += 1;
593
594
91
    return offset;
595
91
}
596
597
598
static unsigned
599
dissect_aps_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, void *data, unsigned cmd_id)
600
273
{
601
273
    switch (cmd_id) {
602
1
        case ZBEE_APS_CMD_RELAY_MSG_UPSTREAM:
603
        /* fallthrough */
604
14
        case ZBEE_APS_CMD_RELAY_MSG_DOWNSTREAM:
605
14
        {
606
14
            zbee_nwk_hints_t *nwk_hints  = (zbee_nwk_hints_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_zbee_nwk, 0);
607
14
            if (nwk_hints) {
608
14
                nwk_hints->relay_type = (cmd_id == ZBEE_APS_CMD_RELAY_MSG_DOWNSTREAM ? ZBEE_APS_RELAY_DOWNSTREAM : ZBEE_APS_RELAY_UPSTREAM);
609
14
            }
610
14
            offset = dissect_aps_relay_local_tlv(tvb, pinfo, tree, offset, data);
611
14
            break;
612
1
        }
613
614
91
        case ZBEE_APS_CMD_TRANSPORT_KEY:
615
91
        {
616
91
            offset = dissect_lk_features_capabilities_tlv(tvb, pinfo, tree, offset);
617
91
            break;
618
1
        }
619
620
168
        default:
621
168
        {
622
168
            offset = dissect_unknown_tlv(tvb, pinfo, tree, offset);
623
168
            break;
624
1
        }
625
273
    }
626
627
262
    return offset;
628
273
}
629
630
/**
631
 *Dissector for Route Request Extended Route Information TLV
632
 *
633
 *@param tvb pointer to buffer containing raw packet.
634
 *@param pinfo pointer to packet information fields
635
 *@param tree pointer to data tree Wireshark uses to display packet.
636
 *@param  offset into the tvb to begin dissection.
637
 *@return offset after command dissection.
638
 */
639
static unsigned
640
dissect_zbee_tlv_route_req_extended_route_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
641
17
{
642
17
    proto_tree_add_item(tree, hf_zbee_tlv_routing_sequence_number, tvb, offset, 2, ENC_LITTLE_ENDIAN);
643
17
    offset += 2;
644
645
17
    proto_tree_add_item(tree, hf_zbee_tlv_initial_radius, tvb, offset, 1, ENC_NA);
646
17
    offset += 1;
647
648
17
    return offset;
649
17
}
650
651
/**
652
 *Dissector for Route Request Concentrator Information TLV
653
 *
654
 *@param tvb pointer to buffer containing raw packet.
655
 *@param pinfo pointer to packet information fields
656
 *@param tree pointer to data tree Wireshark uses to display packet.
657
 *@param  offset into the tvb to begin dissection.
658
 *@return offset after command dissection.
659
 */
660
static unsigned
661
dissect_zbee_tlv_concentrator_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
662
5
{
663
5
    proto_tree_add_item(tree, hf_zbee_tlv_concentrator_discovery_time, tvb, offset, 1, ENC_NA);
664
5
    offset += 1;
665
666
5
    proto_tree_add_item(tree, hf_zbee_tlv_max_source_route_length, tvb, offset, 1, ENC_NA);
667
5
    offset += 1;
668
669
5
    return offset;
670
5
}
671
672
/**
673
 *Dissector for Route Request Source Route Solicitation TLV
674
 *
675
 *@param tvb pointer to buffer containing raw packet.
676
 *@param pinfo pointer to packet information fields
677
 *@param tree pointer to data tree Wireshark uses to display packet.
678
 *@param  offset into the tvb to begin dissection.
679
 *@return offset after command dissection.
680
 */
681
static unsigned
682
dissect_zbee_tlv_source_route_solicit(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int length, unsigned offset)
683
4
{
684
4
    uint8_t i;
685
4
    uint8_t addr_count = length / 2U;
686
687
81
    for (i = 0; i < (addr_count); i++)
688
77
    {
689
77
        proto_tree_add_item(tree, hf_zbee_tlv_nwk_addr_of_interest, tvb, offset, 2, ENC_LITTLE_ENDIAN);
690
77
        offset += 2;
691
77
    }
692
693
4
    return offset;
694
4
}
695
696
static unsigned
697
dissect_nwk_route_req_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
698
51
{
699
51
    uint8_t type;
700
51
    uint8_t length;
701
702
51
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_route_req, tvb, offset, 1, ENC_NA, &type);
703
51
    offset += 1;
704
705
51
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
706
51
    offset += 1;
707
708
51
    length += 1;
709
51
    switch (type) {
710
17
        case ZBEE_TLV_TYPE_EXTENDED_ROUTE_INFO:
711
17
            offset = dissect_zbee_tlv_route_req_extended_route_info(tvb, pinfo, tree, offset);
712
17
            break;
713
714
5
        case ZBEE_TLV_TYPE_CONCENTRATOR_INFO:
715
5
            offset = dissect_zbee_tlv_concentrator_info(tvb, pinfo, tree, offset);
716
5
            break;
717
718
4
        case ZBEE_TLV_TYPE_SOURCE_ROUTE_SOLICIT_INFO:
719
4
            offset = dissect_zbee_tlv_source_route_solicit(tvb, pinfo, tree, length, offset);
720
4
            break;
721
722
25
        default:
723
25
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
724
25
            offset += length;
725
25
            break;
726
51
    }
727
728
47
    return offset;
729
51
}
730
731
/**
732
 *Dissector for Extended Route Information TLV
733
 *
734
 *@param tvb pointer to buffer containing raw packet.
735
 *@param pinfo pointer to packet information fields
736
 *@param tree pointer to data tree Wireshark uses to display packet.
737
 *@param  offset into the tvb to begin dissection.
738
 *@return offset after command dissection.
739
 */
740
static unsigned
741
dissect_zbee_tlv_extended_route_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
742
157
{
743
157
    proto_tree_add_item(tree, hf_zbee_tlv_routing_sequence_number, tvb, offset, 2, ENC_LITTLE_ENDIAN);
744
157
    offset += 2;
745
746
157
    return offset;
747
157
}
748
749
static unsigned
750
dissect_nwk_route_reply_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
751
47
{
752
47
    uint8_t type;
753
47
    uint8_t length;
754
755
47
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_route_reply, tvb, offset, 1, ENC_NA, &type);
756
47
    offset += 1;
757
758
47
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
759
47
    offset += 1;
760
761
47
    length += 1;
762
47
    switch (type) {
763
11
        case ZBEE_TLV_TYPE_EXTENDED_ROUTE_INFO:
764
11
            offset = dissect_zbee_tlv_extended_route_info(tvb, pinfo, tree, offset);
765
11
            break;
766
767
36
        default:
768
36
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
769
36
            offset += length;
770
36
            break;
771
47
    }
772
773
45
    return offset;
774
47
}
775
776
static unsigned
777
dissect_nwk_status_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
778
167
{
779
167
    uint8_t type;
780
167
    uint8_t length;
781
782
167
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_network_status, tvb, offset, 1, ENC_NA, &type);
783
167
    offset += 1;
784
785
167
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
786
167
    offset += 1;
787
788
167
    length += 1;
789
167
    switch (type) {
790
146
        case ZBEE_TLV_TYPE_EXTENDED_ROUTE_INFO:
791
146
            offset = dissect_zbee_tlv_extended_route_info(tvb, pinfo, tree, offset);
792
146
            break;
793
794
21
        default:
795
21
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
796
21
            offset += length;
797
21
            break;
798
167
    }
799
800
166
    return offset;
801
167
}
802
803
static unsigned
804
dissect_nwk_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, unsigned cmd_id)
805
332
{
806
332
    switch (cmd_id) {
807
51
        case ZBEE_NWK_CMD_ROUTE_REQ:
808
51
            offset = dissect_nwk_route_req_local_tlv(tvb, pinfo, tree, offset);
809
51
            break;
810
811
47
        case ZBEE_NWK_CMD_ROUTE_REPLY:
812
47
            offset = dissect_nwk_route_reply_local_tlv(tvb, pinfo, tree, offset);
813
47
            break;
814
815
167
        case ZBEE_NWK_CMD_NWK_STATUS:
816
167
            offset = dissect_nwk_status_local_tlv(tvb, pinfo, tree, offset);
817
167
            break;
818
819
67
        default:
820
67
            offset = dissect_unknown_tlv(tvb, pinfo, tree, offset);
821
67
            break;
822
332
    }
823
824
318
    return offset;
825
332
}
826
827
/*
828
 *Helper dissector for the Security Decommission Request.
829
 *
830
 *@param tvb pointer to buffer containing raw packet.
831
 *@param pinfo pointer to packet information fields
832
 *@param tree pointer to the command subtree.
833
 *@param  offset into the tvb to begin dissection.
834
 *@return offset after command dissection.
835
*/
836
static unsigned
837
dissect_zdp_req_security_decommission_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
838
97
{
839
97
    uint8_t type;
840
97
    uint8_t length;
841
842
97
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_req_security_decommission, tvb, offset, 1, ENC_NA, &type);
843
97
    offset += 1;
844
845
97
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
846
97
    offset += 1;
847
848
97
    length += 1;
849
97
    switch (type) {
850
61
        case ZBEE_TLV_TYPE_EUI64:
851
61
            offset = dissect_zbee_tlv_eui64(tvb, pinfo, tree, offset);
852
61
            break;
853
854
36
        default:
855
36
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
856
36
            offset += length;
857
36
            break;
858
97
    }
859
860
88
    return offset;
861
97
}
862
863
/*
864
 *Helper dissector for the Security Get Authentication Level Request.
865
 *
866
 *@param tvb pointer to buffer containing raw packet.
867
 *@param pinfo pointer to packet information fields
868
 *@param tree pointer to the command subtree.
869
 *@param  offset into the tvb to begin dissection.
870
 *@return offset after command dissection.
871
*/
872
static unsigned
873
dissect_zdp_req_security_get_auth_level_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
874
58
{
875
58
    uint8_t type;
876
58
    uint8_t length;
877
878
58
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_req_security_get_auth_level, tvb, offset, 1, ENC_NA, &type);
879
58
    offset += 1;
880
881
58
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
882
58
    offset += 1;
883
884
58
    length += 1;
885
58
    switch (type) {
886
33
        case ZBEE_TLV_TYPE_TARGET_IEEE_ADDRESS:
887
33
            offset = dissect_zbee_tlv_target_ieee_address(tvb, pinfo, tree, offset);
888
33
            break;
889
890
25
        default:
891
25
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
892
25
            offset += length;
893
25
            break;
894
58
    }
895
896
55
    return offset;
897
58
}
898
/*
899
 *Helper dissector for the Security Get Authentication Token Request.
900
 *
901
 *@param tvb pointer to buffer containing raw packet.
902
 *@param pinfo pointer to packet information fields
903
 *@param tree pointer to the command subtree.
904
 *@param  offset into the tvb to begin dissection.
905
 *@return offset after command dissection.
906
*/
907
static unsigned
908
dissect_zdp_req_security_get_auth_token_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
909
165
{
910
165
    uint8_t type;
911
165
    uint8_t length;
912
913
165
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_req_security_get_auth_token, tvb, offset, 1, ENC_NA, &type);
914
165
    offset += 1;
915
916
165
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
917
165
    offset += 1;
918
919
165
    length += 1;
920
165
    switch (type) {
921
117
        case ZBEE_TLV_TYPE_REQUESTED_AUTH_TOKEN_ID:
922
117
            offset = dissect_zbee_tlv_requested_auth_token_id(tvb, pinfo, tree, offset);
923
117
            break;
924
925
48
        default:
926
48
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
927
48
            offset += length;
928
48
            break;
929
165
    }
930
931
156
    return offset;
932
165
}
933
934
/*
935
 *Helper dissector for the Clear All Bindings Request.
936
 *
937
 *@param tvb pointer to buffer containing raw packet.
938
 *@param pinfo pointer to packet information fields
939
 *@param tree pointer to the command subtree.
940
 *@param  offset into the tvb to begin dissection.
941
 *@return offset after command dissection.
942
*/
943
static unsigned
944
dissect_zdp_req_clear_all_bindings_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
945
199
{
946
199
    uint8_t type;
947
199
    uint8_t length;
948
949
199
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_clear_all_bindings_req, tvb, offset, 1, ENC_NA, &type);
950
199
    offset += 1;
951
952
199
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
953
199
    offset += 1;
954
955
199
    length += 1;
956
199
    switch (type) {
957
148
        case ZBEE_TLV_TYPE_CLEAR_ALL_BINDIGS_REQ_EUI64:
958
148
            offset = dissect_zbee_tlv_clear_all_bindigs_eui64(tvb, pinfo, tree, offset);
959
148
            break;
960
961
51
        default:
962
51
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
963
51
            offset += length;
964
51
            break;
965
199
    }
966
967
183
    return offset;
968
199
}
969
970
/*
971
 *Helper dissector for the Beacon Survey Request.
972
 *
973
 *@param tvb pointer to buffer containing raw packet.
974
 *@param pinfo pointer to packet information fields
975
 *@param tree pointer to the command subtree.
976
 *@param  offset into the tvb to begin dissection.
977
 *@return offset after command dissection.
978
*/
979
static unsigned
980
dissect_zdp_req_beacon_survey_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
981
125
{
982
125
    uint8_t type;
983
125
    uint8_t length;
984
985
125
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_req_beacon_survey, tvb, offset, 1, ENC_NA, &type);
986
125
    offset += 1;
987
988
125
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
989
125
    offset += 1;
990
991
125
    length += 1;
992
125
    switch (type) {
993
94
        case ZBEE_TLV_TYPE_BEACON_SURVEY_CONFIGURATION:
994
94
        {
995
94
            uint8_t cnt;
996
94
            uint8_t i;
997
998
94
            cnt = tvb_get_uint8(tvb, offset);
999
94
            proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_scan_mask_cnt, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1000
94
            offset += 1;
1001
1002
522
            for (i = 0; i < cnt; i++)
1003
428
            {
1004
428
              proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_scan_mask, tvb, offset, 4, ENC_LITTLE_ENDIAN);
1005
428
              offset += 4;
1006
428
            }
1007
1008
94
            proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_conf_mask, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1009
94
            offset += 1;
1010
94
            break;
1011
0
        }
1012
31
        default:
1013
31
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
1014
31
            offset += length;
1015
31
            break;
1016
125
    }
1017
1018
106
    return offset;
1019
125
}
1020
1021
/*
1022
 *Helper dissector for the Beacon Survey Response.
1023
 *
1024
 *@param tvb pointer to buffer containing raw packet.
1025
 *@param pinfo pointer to packet information fields
1026
 *@param tree pointer to the command subtree.
1027
 *@param  offset into the tvb to begin dissection.
1028
 *@return offset after command dissection.
1029
*/
1030
static unsigned
1031
dissect_zdp_rsp_beacon_survey_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1032
162
{
1033
162
    uint8_t type;
1034
162
    uint8_t length;
1035
1036
162
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_rsp_beacon_survey, tvb, offset, 1, ENC_NA, &type);
1037
162
    offset += 1;
1038
1039
162
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
1040
162
    offset += 1;
1041
1042
162
    length += 1;
1043
162
    switch (type) {
1044
96
        case ZBEE_TLV_TYPE_BEACON_SURVEY_CONFIGURATION:
1045
96
        {
1046
96
            uint8_t cnt;
1047
96
            uint8_t i;
1048
1049
96
            proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_conf_mask, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1050
96
            offset += 1;
1051
1052
96
            cnt = tvb_get_uint8(tvb, offset);
1053
96
            proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_scan_mask_cnt, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1054
96
            offset += 1;
1055
1056
361
            for (i = 0; i < cnt; i++)
1057
265
            {
1058
265
              proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_scan_mask, tvb, offset, 4, ENC_LITTLE_ENDIAN);
1059
265
              offset += 4;
1060
265
            }
1061
1062
96
            break;
1063
0
        }
1064
1065
8
        case ZBEE_TLV_TYPE_BEACON_SURVEY_RESULTS:
1066
8
        {
1067
8
            proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_total, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1068
8
            offset += 1;
1069
1070
8
            proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_cur_zbn, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1071
8
            offset += 1;
1072
1073
8
            proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_cur_zbn_potent_parents, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1074
8
            offset += 1;
1075
1076
8
            proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_other_zbn, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1077
8
            offset += 1;
1078
1079
8
            break;
1080
0
        }
1081
1082
32
        case ZBEE_TLV_TYPE_BEACON_SURVEY_POTENTIAL_PARENTS:
1083
32
            offset = dissect_zbee_tlv_potential_parents(tvb, pinfo, tree, offset);
1084
32
            break;
1085
1086
26
        default:
1087
26
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
1088
26
            offset += length;
1089
26
            break;
1090
162
    }
1091
1092
138
    return offset;
1093
162
}
1094
1095
/*
1096
 *Helper dissector for the Security Challenge Request.
1097
 *
1098
 *@param tvb pointer to buffer containing raw packet.
1099
 *@param pinfo pointer to packet information fields
1100
 *@param tree pointer to the command subtree.
1101
 *@param  offset into the tvb to begin dissection.
1102
 *@return offset after command dissection.
1103
*/
1104
static unsigned
1105
dissect_zdp_req_security_challenge_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1106
67
{
1107
67
    uint8_t type;
1108
67
    uint8_t length;
1109
1110
67
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_req_challenge, tvb, offset, 1, ENC_NA, &type);
1111
67
    offset += 1;
1112
1113
67
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
1114
67
    offset += 1;
1115
1116
67
    length += 1;
1117
67
    switch (type) {
1118
39
       case 0:
1119
39
       {
1120
39
           proto_tree_add_item(tree, hf_zbee_tlv_local_ieee_addr, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1121
39
           offset += 8;
1122
1123
39
           proto_tree_add_item(tree, hf_zbee_tlv_challenge_value, tvb, offset, 8, ENC_NA);
1124
39
           offset += 8;
1125
39
           break;
1126
0
       }
1127
28
       default:
1128
28
           proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
1129
28
           offset += length;
1130
28
           break;
1131
67
    }
1132
1133
64
    return offset;
1134
67
}
1135
1136
/*
1137
 *Helper dissector for the Security Challenge Response.
1138
 *
1139
 *@param tvb pointer to buffer containing raw packet.
1140
 *@param pinfo pointer to packet information fields
1141
 *@param tree pointer to the command subtree.
1142
 *@param  offset into the tvb to begin dissection.
1143
 *@return offset after command dissection.
1144
*/
1145
static unsigned
1146
dissect_zdp_rsp_security_challenge_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1147
0
{
1148
0
    uint8_t type;
1149
0
    uint8_t length;
1150
1151
0
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_rsp_challenge, tvb, offset, 1, ENC_NA, &type);
1152
0
    offset += 1;
1153
1154
0
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
1155
0
    offset += 1;
1156
1157
0
    length += 1;
1158
0
    switch (type) {
1159
0
       case 0:
1160
0
       {
1161
0
           proto_tree_add_item(tree, hf_zbee_tlv_local_ieee_addr, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1162
0
           offset += 8;
1163
1164
0
           proto_tree_add_item(tree, hf_zbee_tlv_challenge_value, tvb, offset, 8, ENC_NA);
1165
0
           offset += 8;
1166
1167
0
           proto_tree_add_item(tree, hf_zbee_tlv_aps_frame_counter, tvb, offset, 4, ENC_LITTLE_ENDIAN);
1168
0
           offset += 4;
1169
1170
0
           proto_tree_add_item(tree, hf_zbee_tlv_challenge_counter, tvb, offset, 4, ENC_LITTLE_ENDIAN);
1171
0
           offset += 4;
1172
1173
           /* TODO: should this really be shown as big endian? */
1174
0
           proto_tree_add_item(tree, hf_zbee_tlv_mic64, tvb, offset, 8, ENC_BIG_ENDIAN);
1175
0
           offset += 8;
1176
0
           break;
1177
0
       }
1178
0
       default:
1179
0
           proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
1180
0
           offset += length;
1181
0
           break;
1182
0
    }
1183
1184
0
    return offset;
1185
0
}
1186
1187
1188
/*
1189
 *Helper dissector for the Security Challenge Response.
1190
 *
1191
 *@param tvb pointer to buffer containing raw packet.
1192
 *@param pinfo pointer to packet information fields
1193
 *@param tree pointer to the command subtree.
1194
 *@param  offset into the tvb to begin dissection.
1195
 *@return offset after command dissection.
1196
*/
1197
static unsigned
1198
dissect_zdp_rsp_security_set_configuration_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1199
145
{
1200
145
  uint8_t type;
1201
145
  uint8_t length;
1202
1203
145
  proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_rsp_set_configuration, tvb, offset, 1, ENC_NA, &type);
1204
145
  offset += 1;
1205
1206
145
  proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
1207
145
  offset += 1;
1208
1209
145
  length += 1;
1210
145
  switch (type) {
1211
103
     case 0:
1212
103
     {
1213
103
         uint8_t     count;
1214
103
         uint8_t     i;
1215
1216
103
         proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_status_count, tvb, offset, 1, ENC_NA, &count);
1217
103
         offset += 1;
1218
1219
418
         for (i = 0; i < count; i++)
1220
315
         {
1221
315
             proto_tree_add_item(tree, hf_zbee_tlv_local_type_id, tvb, offset, 1, ENC_NA);
1222
315
             offset += 1;
1223
315
             proto_tree_add_item(tree, hf_zbee_tlv_local_proc_status, tvb, offset, 1, ENC_NA);
1224
315
             offset += 1;
1225
315
         }
1226
103
         break;
1227
0
     }
1228
42
     default:
1229
42
         proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
1230
42
         offset += length;
1231
42
         break;
1232
145
  }
1233
1234
135
  return offset;
1235
145
}
1236
1237
1238
/*
1239
 *Helper dissector for the Security Start Key Negotiation req/rsp
1240
 *
1241
 *@param tvb pointer to buffer containing raw packet.
1242
 *@param pinfo pointer to packet information fields
1243
 *@param tree pointer to the command subtree.
1244
 *@param  offset into the tvb to begin dissection.
1245
 *@return offset after command dissection.
1246
*/
1247
static unsigned
1248
dissect_zdp_security_start_key_neg_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1249
16
{
1250
16
    uint8_t type;
1251
16
    uint8_t length;
1252
1253
16
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_key_negotiation_req_rsp, tvb, offset, 1, ENC_NA, &type);
1254
16
    offset += 1;
1255
1256
16
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
1257
16
    offset += 1;
1258
1259
16
    length += 1; /* actual length */
1260
1261
16
    switch (type) {
1262
1263
8
       case ZBEE_TLV_TYPE_KEY_NEG_REQ_CURVE25519_PUBLIC_POINT:
1264
8
           offset = dissect_zbee_tlv_public_point(tvb, pinfo, tree, offset, length);
1265
8
           break;
1266
1267
8
       default:
1268
8
           proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
1269
8
           offset += length;
1270
8
           break;
1271
16
    }
1272
1273
9
    return offset;
1274
16
}
1275
1276
/*
1277
 *Helper dissector for the Security Start Key Update req/rsp
1278
 *
1279
 *@param tvb pointer to buffer containing raw packet.
1280
 *@param pinfo pointer to packet information fields
1281
 *@param tree pointer to the command subtree.
1282
 *@param  offset into the tvb to begin dissection.
1283
 *@return offset after command dissection.
1284
*/
1285
static unsigned
1286
dissect_zdp_security_key_upd_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1287
42
{
1288
42
    uint8_t type;
1289
42
    uint8_t length;
1290
42
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_key_update_req_rsp, tvb, offset, 1, ENC_NA, &type);
1291
42
    offset += 1;
1292
1293
42
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
1294
42
    offset += 1;
1295
1296
42
    length += 1; /* actual length */
1297
1298
42
    switch (type) {
1299
1300
23
       case ZBEE_TLV_TYPE_KEY_UPD_REQ_SELECTED_KEY_NEGOTIATION_METHOD:
1301
23
           offset = dissect_zbee_tlv_selected_key_negotiation_method(tvb, pinfo, tree, offset);
1302
23
           break;
1303
1304
19
       default:
1305
19
           proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
1306
19
           offset += length;
1307
19
           break;
1308
42
    }
1309
1310
37
    return offset;
1311
42
}
1312
/*
1313
 *Helper dissector for the Security Get Auth Level Response.
1314
 *
1315
 *@param tvb pointer to buffer containing raw packet.
1316
 *@param pinfo pointer to packet information fields
1317
 *@param tree pointer to the command subtree.
1318
 *@param  offset into the tvb to begin dissection.
1319
 *@return offset after command dissection.
1320
*/
1321
static unsigned
1322
dissect_zdp_rsp_security_get_auth_level_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1323
2
{
1324
2
    uint8_t type;
1325
2
    uint8_t length;
1326
1327
2
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_local_type_get_auth_level_rsp, tvb, offset, 1, ENC_NA, &type);
1328
2
    offset += 1;
1329
1330
2
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
1331
2
    offset += 1;
1332
1333
2
    length += 1;
1334
2
    switch (type) {
1335
1
       case ZBEE_TLV_TYPE_GET_AUTH_LEVEL:
1336
1
           offset = dissect_zbee_tlv_device_auth_level(tvb, pinfo, tree, offset);
1337
1
           break;
1338
1339
1
       default:
1340
1
           proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
1341
1
           offset += length;
1342
1
           break;
1343
2
    }
1344
1345
1
    return offset;
1346
2
}
1347
1348
1349
/*
1350
 *Helper dissector for the ZDP commands.
1351
 *
1352
 *@param tvb pointer to buffer containing raw packet.
1353
 *@param pinfo pointer to packet information fields
1354
 *@param tree pointer to the command subtree.
1355
 *@param  offset into the tvb to begin dissection.
1356
 *@param  cmd_id - ZDP command id .
1357
 *@return offset after command dissection.
1358
*/
1359
static unsigned
1360
dissect_zdp_local_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, unsigned cmd_id)
1361
1.21k
{
1362
1.21k
    unsigned total_tlv_length = 2 /*type + len fields*/ + tvb_get_uint8(tvb, offset + 1) + 1;
1363
1.21k
    unsigned tmp_offset = offset;
1364
1365
1.21k
    switch (cmd_id) {
1366
199
        case ZBEE_ZDP_REQ_CLEAR_ALL_BINDINGS:
1367
199
            offset = dissect_zdp_req_clear_all_bindings_local_tlv(tvb, pinfo, tree, offset);
1368
199
            break;
1369
1370
11
        case ZBEE_ZDP_REQ_SECURITY_START_KEY_UPDATE:
1371
23
        case ZBEE_ZDP_RSP_SECURITY_START_KEY_UPDATE:
1372
42
        case ZBEE_ZDP_RSP_NODE_DESC:
1373
42
            offset = dissect_zdp_security_key_upd_local_tlv(tvb, pinfo, tree, offset);
1374
42
            break;
1375
1376
16
        case ZBEE_ZDP_REQ_SECURITY_START_KEY_NEGOTIATION:
1377
16
        case ZBEE_ZDP_RSP_SECURITY_START_KEY_NEGOTIATION:
1378
16
            offset = dissect_zdp_security_start_key_neg_local_tlv(tvb, pinfo, tree, offset);
1379
16
            break;
1380
1381
165
        case ZBEE_ZDP_REQ_SECURITY_GET_AUTH_TOKEN:
1382
165
            offset = dissect_zdp_req_security_get_auth_token_local_tlv(tvb, pinfo, tree, offset);
1383
165
            break;
1384
1385
58
        case ZBEE_ZDP_REQ_SECURITY_GET_AUTH_LEVEL:
1386
58
            offset = dissect_zdp_req_security_get_auth_level_local_tlv(tvb, pinfo, tree, offset);
1387
58
            break;
1388
1389
97
        case ZBEE_ZDP_REQ_SECURITY_DECOMMISSION:
1390
97
            offset = dissect_zdp_req_security_decommission_local_tlv(tvb, pinfo, tree, offset);
1391
97
            break;
1392
1393
2
        case ZBEE_ZDP_RSP_SECURITY_GET_AUTH_LEVEL:
1394
2
            offset = dissect_zdp_rsp_security_get_auth_level_local_tlv(tvb, pinfo, tree, offset);
1395
2
            break;
1396
1397
125
        case ZBEE_ZDP_REQ_MGMT_NWK_BEACON_SURVEY:
1398
125
            offset = dissect_zdp_req_beacon_survey_local_tlv(tvb, pinfo, tree, offset);
1399
125
            break;
1400
1401
162
        case ZBEE_ZDP_RSP_MGMT_NWK_BEACON_SURVEY:
1402
162
            offset = dissect_zdp_rsp_beacon_survey_local_tlv(tvb, pinfo, tree, offset);
1403
162
            break;
1404
1405
67
        case ZBEE_ZDP_REQ_SECURITY_CHALLENGE:
1406
67
            offset = dissect_zdp_req_security_challenge_local_tlv(tvb, pinfo, tree, offset);
1407
67
            break;
1408
1409
0
        case ZBEE_ZDP_RSP_SECURITY_CHALLENGE:
1410
0
            offset = dissect_zdp_rsp_security_challenge_local_tlv(tvb, pinfo, tree, offset);
1411
0
            break;
1412
1413
145
        case ZBEE_ZDP_RSP_SECURITY_SET_CONFIGURATION:
1414
145
            offset = dissect_zdp_rsp_security_set_configuration_local_tlv(tvb, pinfo, tree, offset);
1415
145
            break;
1416
132
        default:
1417
132
        {
1418
132
            offset = dissect_unknown_tlv(tvb, pinfo, tree, offset);
1419
132
            break;
1420
16
        }
1421
1.21k
    }
1422
1423
    /* check extra bytes */
1424
1.09k
    if ((offset - tmp_offset) < total_tlv_length)
1425
72
    {
1426
72
      proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, total_tlv_length - (offset - tmp_offset), ENC_NA);
1427
72
      offset = tmp_offset + total_tlv_length;
1428
72
    }
1429
1430
1.09k
    return offset;
1431
1.21k
}
1432
1433
/**
1434
 * Helper dissector for a channel mask.
1435
 *
1436
 * @param  tree        pointer to data tree Wireshark uses to display packet.
1437
 * @param  tvb         pointer to buffer containing raw packet.
1438
 * @param  offset      offset into the tvb to find the status value.
1439
 * @param  hf_page     page field index
1440
 * @param  hf_channel  channel field index
1441
 * @return mask
1442
 */
1443
static unsigned
1444
dissect_zbee_tlv_chanmask(proto_tree *tree, tvbuff_t *tvb, unsigned offset, int hf_page, int hf_channel)
1445
0
{
1446
0
    uint32_t    i;
1447
0
    uint32_t    mask;
1448
0
    uint8_t     page;
1449
0
    proto_item *ti;
1450
1451
    /* Get and display the channel mask. */
1452
0
    mask = tvb_get_letohl(tvb, offset);
1453
1454
0
    page = (uint8_t)((mask >> 27) & 0x07);
1455
0
    mask &= UINT32_C(0x07FFFFFF);
1456
1457
0
    proto_tree_add_uint(tree, hf_page, tvb, offset, 4, page);
1458
0
    ti = proto_tree_add_uint_format(tree, hf_channel, tvb, offset, 4, mask, "Channels: ");
1459
1460
    /* Check if there are any channels to display. */
1461
0
    if (mask == 0)
1462
0
    {
1463
0
        proto_item_append_text(ti, "None");
1464
0
    }
1465
1466
    /* Display the first channel #. */
1467
0
    for (i = 0; i < 32; i++)
1468
0
    {
1469
0
        if ((1U << i) & mask)
1470
0
        {
1471
0
            proto_item_append_text(ti, "%d", i++);
1472
0
            break;
1473
0
        }
1474
0
    }
1475
1476
    /* Display the rest of the channels. */
1477
0
    for (; i < 32; i++)
1478
0
    {
1479
0
        if (!((1U << i) & mask))
1480
0
        {
1481
            /* This channel isn't selected. */
1482
0
            continue;
1483
0
        }
1484
1485
        /* If the previous channel wasn't selected,
1486
         * then display the channel number.
1487
         */
1488
0
        if (!((1 << (i - 1)) & mask))
1489
0
        {
1490
0
            proto_item_append_text(ti, ", %d", i);
1491
0
        }
1492
1493
        /* If the next channel is selected too,
1494
         * skip past it and display a range of values instead.
1495
         */
1496
0
        while ((i<31) && ((2U << i) & mask)) i++;
1497
0
        proto_item_append_text(ti, "-%d", i);
1498
0
    }
1499
1500
0
    offset += sizeof(uint32_t);
1501
1502
0
    return offset;
1503
0
}
1504
1505
/**
1506
 * Dissector Extended PAN ID TLV.
1507
 *
1508
 * @param  tvb     pointer to buffer containing raw packet
1509
 * @param  pinfo   pointer to packet information fields
1510
 * @param  tree    pointer to subtree
1511
 * @param  offset  offset into the tvb to begin dissection
1512
 * @return offset after dissection
1513
 */
1514
1515
static unsigned
1516
dissect_zbee_tlv_ext_pan_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1517
0
{
1518
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_ext_pan_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1519
0
    offset += 8;
1520
1521
0
    return offset;
1522
0
}
1523
1524
/**
1525
 * Dissector Short PAN ID TLV.
1526
 *
1527
 * @param  tvb     pointer to buffer containing raw packet
1528
 * @param  pinfo   pointer to packet information fields
1529
 * @param  tree    pointer to subtree
1530
 * @param  offset  offset into the tvb to begin dissection
1531
 * @return offset after dissection
1532
 */
1533
1534
static unsigned
1535
dissect_zbee_tlv_short_pan_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1536
0
{
1537
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_short_pan_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1538
0
    offset += 2;
1539
1540
0
    return offset;
1541
0
}
1542
1543
/**
1544
 * Dissector NWK Key TLV.
1545
 *
1546
 * @param  tvb     pointer to buffer containing raw packet
1547
 * @param  pinfo   pointer to packet information fields
1548
 * @param  tree    pointer to subtree
1549
 * @param  offset  offset into the tvb to begin dissection
1550
 * @return offset after dissection
1551
 */
1552
1553
static unsigned dissect_zbee_tlv_nwk_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1554
0
{
1555
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_nwk_key, tvb, offset, 16, ENC_NA);
1556
0
    offset += 16;
1557
1558
0
    return offset;
1559
0
}
1560
1561
/**
1562
 * Dissector Device Type TLV.
1563
 *
1564
 * @param  tvb     pointer to buffer containing raw packet
1565
 * @param  pinfo   pointer to packet information fields
1566
 * @param  tree    pointer to subtree
1567
 * @param  offset  offset into the tvb to begin dissection
1568
 * @return offset after dissection
1569
 */
1570
1571
static unsigned dissect_zbee_tlv_dev_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1572
0
{
1573
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_dev_type, tvb, offset, 1, ENC_NA);
1574
0
    offset += 1;
1575
1576
0
    return offset;
1577
0
}
1578
1579
/**
1580
 * Dissector NWK Address TLV.
1581
 *
1582
 * @param  tvb     pointer to buffer containing raw packet
1583
 * @param  pinfo   pointer to packet information fields
1584
 * @param  tree    pointer to subtree
1585
 * @param  offset  offset into the tvb to begin dissection
1586
 * @return offset after dissection
1587
 */
1588
1589
static unsigned dissect_zbee_tlv_nwk_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1590
0
{
1591
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_nwk_addr, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1592
0
    offset += 2;
1593
1594
0
    return offset;
1595
0
}
1596
1597
/**
1598
 * Dissector Joining Method TLV.
1599
 *
1600
 * @param  tvb     pointer to buffer containing raw packet
1601
 * @param  pinfo   pointer to packet information fields
1602
 * @param  tree    pointer to subtree
1603
 * @param  offset  offset into the tvb to begin dissection
1604
 * @return offset after dissection
1605
 */
1606
1607
static unsigned dissect_zbee_tlv_join_method(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1608
0
{
1609
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_join_method, tvb, offset, 1, ENC_NA);
1610
0
    offset += 1;
1611
1612
0
    return offset;
1613
0
}
1614
1615
/**
1616
 * Dissector IEEE Address TLV.
1617
 *
1618
 * @param  tvb     pointer to buffer containing raw packet
1619
 * @param  pinfo   pointer to packet information fields
1620
 * @param  tree    pointer to subtree
1621
 * @param  offset  offset into the tvb to begin dissection
1622
 * @return offset after dissection
1623
 */
1624
1625
static unsigned dissect_zbee_tlv_ieee_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1626
0
{
1627
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_ieee_addr, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1628
0
    offset += 8;
1629
1630
0
    return offset;
1631
0
}
1632
1633
/**
1634
 * Dissector Trust Center Address TLV.
1635
 *
1636
 * @param  tvb     pointer to buffer containing raw packet
1637
 * @param  pinfo   pointer to packet information fields
1638
 * @param  tree    pointer to subtree
1639
 * @param  offset  offset into the tvb to begin dissection
1640
 * @return offset after dissection
1641
 */
1642
1643
static unsigned dissect_zbee_tlv_tc_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1644
0
{
1645
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_tc_addr, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1646
0
    offset += 8;
1647
1648
0
    return offset;
1649
0
}
1650
1651
/**
1652
 * Dissector NWK Update ID TLV.
1653
 *
1654
 * @param  tvb     pointer to buffer containing raw packet
1655
 * @param  pinfo   pointer to packet information fields
1656
 * @param  tree    pointer to subtree
1657
 * @param  offset  offset into the tvb to begin dissection
1658
 * @return offset after dissection
1659
 */
1660
1661
static unsigned dissect_zbee_tlv_nwk_upd_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1662
0
{
1663
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_nwk_upd_id, tvb, offset, 1, ENC_NA);
1664
0
    offset += 1;
1665
1666
0
    return offset;
1667
0
}
1668
1669
/**
1670
 * Dissector NWK Active Key Seq Number TLV.
1671
 *
1672
 * @param  tvb     pointer to buffer containing raw packet
1673
 * @param  pinfo   pointer to packet information fields
1674
 * @param  tree    pointer to subtree
1675
 * @param  offset  offset into the tvb to begin dissection
1676
 * @return offset after dissection
1677
 */
1678
1679
static unsigned dissect_zbee_tlv_key_seq_num(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1680
0
{
1681
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_key_seq_num, tvb, offset, 1, ENC_NA);
1682
0
    offset += 1;
1683
1684
0
    return offset;
1685
0
}
1686
1687
/**
1688
 * Dissector Admin Key TLV.
1689
 *
1690
 * @param  tvb     pointer to buffer containing raw packet
1691
 * @param  pinfo   pointer to packet information fields
1692
 * @param  tree    pointer to subtree
1693
 * @param  offset  offset into the tvb to begin dissection
1694
 * @return offset after dissection
1695
 */
1696
1697
static unsigned dissect_zbee_tlv_adm_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1698
0
{
1699
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_adm_key, tvb, offset, 16, ENC_NA);
1700
0
    offset += 16;
1701
1702
0
    return offset;
1703
0
}
1704
1705
/**
1706
 * Dissector (Manager Joiners) Provisional Link Key TLV.
1707
 *
1708
 * @param  tvb     pointer to buffer containing raw packet
1709
 * @param  pinfo   pointer to packet information fields
1710
 * @param  tree    pointer to subtree
1711
 * @param  offset  offset into the tvb to begin dissection
1712
 * @return offset after dissection
1713
 */
1714
1715
static unsigned dissect_zbee_tlv_mj_prov_lnk_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1716
0
{
1717
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_mj_prov_lnk_key, tvb, offset, 16, ENC_NA);
1718
0
    offset += 16;
1719
1720
0
    return offset;
1721
0
}
1722
1723
/**
1724
 * Dissector (Manager Joiners) IEEE Address TLV.
1725
 *
1726
 * @param  tvb     pointer to buffer containing raw packet
1727
 * @param  pinfo   pointer to packet information fields
1728
 * @param  tree    pointer to subtree
1729
 * @param  offset  offset into the tvb to begin dissection
1730
 * @return offset after dissection
1731
 */
1732
1733
static unsigned dissect_zbee_tlv_mj_ieee_addr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1734
0
{
1735
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_mj_ieee_addr, tvb, offset, 8, ENC_LITTLE_ENDIAN);
1736
0
    offset += 8;
1737
1738
0
    return offset;
1739
0
}
1740
1741
/**
1742
 * Dissector (Manager Joiners) Command TLV.
1743
 *
1744
 * @param  tvb     pointer to buffer containing raw packet
1745
 * @param  pinfo   pointer to packet information fields
1746
 * @param  tree    pointer to subtree
1747
 * @param  offset  offset into the tvb to begin dissection
1748
 * @return offset after dissection
1749
 */
1750
1751
static unsigned dissect_zbee_tlv_mj_cmd(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1752
0
{
1753
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_mj_cmd, tvb, offset, 1, ENC_NA);
1754
0
    offset += 1;
1755
1756
0
    return offset;
1757
0
}
1758
1759
/**
1760
 * Dissector Channel List TLV.
1761
 *
1762
 * @param  tvb     pointer to buffer containing raw packet
1763
 * @param  pinfo   pointer to packet information fields
1764
 * @param  tree    pointer to subtree
1765
 * @param  offset  offset into the tvb to begin dissection
1766
 * @return offset after dissection
1767
 */
1768
static unsigned
1769
dissect_zbee_tlv_nwk_channel_list(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1770
0
{
1771
0
    uint32_t count = 0;
1772
1773
0
    proto_tree_add_item_ret_uint(tree, hf_zbee_tlv_local_comm_channel_page_count, tvb, offset, 1, ENC_LITTLE_ENDIAN, &count);
1774
0
    offset += 1;
1775
1776
0
    for (unsigned i = 0; i < count; i++)
1777
0
    {
1778
0
        offset = dissect_zbee_tlv_chanmask(tree, tvb, offset, hf_zbee_tlv_local_comm_channel_page, hf_zbee_tlv_local_comm_channel_mask);
1779
0
    }
1780
1781
0
    return offset;
1782
0
}
1783
1784
/**
1785
 * Dissector Link Key TLV.
1786
 *
1787
 * @param  tvb     pointer to buffer containing raw packet
1788
 * @param  pinfo   pointer to packet information fields
1789
 * @param  tree    pointer to subtree
1790
 * @param  offset  offset into the tvb to begin dissection
1791
 * @return offset after dissection
1792
 */
1793
static unsigned
1794
dissect_zbee_tlv_link_key(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1795
0
{
1796
0
    static int * const link_key_flags[] = {
1797
0
        &hf_zbee_tlv_local_comm_link_key_flags_unique,
1798
0
        &hf_zbee_tlv_local_comm_link_key_flags_provisional,
1799
0
        NULL
1800
0
    };
1801
1802
0
    proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_tlv_local_comm_link_key_flags, ett_zbee_tlv_link_key_flags, link_key_flags, ENC_NA);
1803
0
    offset += 1;
1804
1805
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_link_key, tvb, offset, 16, ENC_NA);
1806
0
    offset += 16;
1807
1808
0
    return offset;
1809
0
}
1810
1811
/**
1812
 * Dissector NWK Status Map TLV.
1813
 *
1814
 * @param  tvb     pointer to buffer containing raw packet
1815
 * @param  pinfo   pointer to packet information fields
1816
 * @param  tree    pointer to subtree
1817
 * @param  offset  offset into the tvb to begin dissection
1818
 * @return offset after dissection
1819
 */
1820
static unsigned
1821
dissect_zbee_tlv_nwk_status_map(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1822
0
{
1823
0
    uint8_t mask;
1824
0
    unsigned   joined, opened, centralized;
1825
1826
0
    static int * const network_status_map[] = {
1827
0
        &hf_zbee_tlv_local_comm_network_status_map_joined_status,
1828
0
        &hf_zbee_tlv_local_comm_network_status_map_open_status,
1829
0
        &hf_zbee_tlv_network_status_map_network_type,
1830
0
        NULL
1831
0
    };
1832
1833
0
    mask = tvb_get_uint8(tvb, offset);
1834
0
    proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_tlv_local_comm_network_status_map, ett_zbee_tlv_network_status_map, network_status_map, ENC_LITTLE_ENDIAN);
1835
1836
0
    offset += 1;
1837
1838
0
    joined      = (mask & ZBEE_TLV_STATUS_MAP_JOINED_STATUS) >> 0;
1839
0
    opened      = (mask & ZBEE_TLV_STATUS_MAP_OPEN_STATUS)   >> 3;
1840
0
    centralized = (mask & ZBEE_TLV_STATUS_MAP_NETWORK_TYPE)  >> 4;
1841
1842
1843
0
    if (joined == ZB_DIRECT_JOINED_STATUS_JOINED || joined == ZB_DIRECT_JOINED_STATUS_JOINED_NO_PARENT)
1844
0
    {
1845
0
        col_append_fstr(pinfo->cinfo,
1846
0
                        COL_INFO,
1847
0
                        " (%s, %s, %s)",
1848
0
                        val_to_str_const(joined, zbee_tlv_local_types_joined_status_str, "Reserved"),
1849
0
                        opened ? "Opened" : "Closed",
1850
0
                        centralized ? "Centralized" : "Distributed");
1851
0
    }
1852
0
    else
1853
0
    {
1854
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", val_to_str_const(joined, zbee_tlv_local_types_joined_status_str, "Reserved"));
1855
0
    }
1856
1857
0
    return offset;
1858
0
}
1859
1860
/**
1861
 * Dissector Status Code TLV.
1862
 *
1863
 * @param  tvb     pointer to buffer containing raw packet
1864
 * @param  pinfo   pointer to packet information fields
1865
 * @param  tree    pointer to subtree
1866
 * @param  offset  offset into the tvb to begin dissection
1867
 * @return offset after dissection
1868
 */
1869
static unsigned
1870
dissect_zbee_tlv_status_code(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1871
0
{
1872
0
    uint32_t code;
1873
0
    proto_item *code_item;
1874
1875
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_comm_status_code_domain, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1876
0
    offset += 1;
1877
1878
0
    code_item = proto_tree_add_item_ret_uint(tree, hf_zbee_tlv_local_comm_status_code_value, tvb, offset, 1, ENC_LITTLE_ENDIAN, &code);
1879
0
    offset += 1;
1880
1881
0
    proto_item_append_text(code_item, " (%s)", (code == 0) ? "Success" : "Failure");
1882
1883
0
    return offset;
1884
0
}
1885
1886
/**
1887
 * Helper dissector for Tunneling.
1888
 *
1889
 * @param  tvb     pointer to buffer containing raw packet
1890
 * @param  pinfo   pointer to packet information fields
1891
 * @param  tree    pointer to subtree
1892
 * @return offset after dissection
1893
 */
1894
static unsigned
1895
dissect_zbee_tlv_tunneling_npdu_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset,
1896
                                               uint8_t      length)
1897
0
{
1898
0
    uint32_t npdu_len = 0;
1899
1900
    /* Parse NPDU Message TLV */
1901
0
    {
1902
0
        proto_item *npdu_flags_item = proto_tree_add_item(tree, hf_zbee_tlv_local_tunneling_npdu_flags, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1903
0
        proto_tree *npdu_flags_tree = proto_item_add_subtree(npdu_flags_item, ett_zbee_tlv_zbd_tunneling_npdu_flags);
1904
0
        bool secur;
1905
1906
0
        proto_tree_add_item_ret_boolean(npdu_flags_tree, hf_zbee_tlv_local_tunneling_npdu_flags_security, tvb, offset, 1, ENC_LITTLE_ENDIAN, &secur);
1907
0
        proto_tree_add_item_ret_uint(tree, hf_zbee_tlv_local_tunneling_npdu_length, tvb, offset + 1, 1, ENC_LITTLE_ENDIAN, &npdu_len);
1908
1909
0
        proto_item_append_text(npdu_flags_item, ", Security: %s", secur ? "True" : "False");
1910
0
        proto_tree_add_item(npdu_flags_tree, hf_zbee_tlv_local_tunneling_npdu_flags_reserved, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1911
0
    }
1912
1913
    /* Proceed with NPDU that holds a Zigbee NWK frame */
1914
0
    {
1915
0
        proto_item *npdu_item = proto_tree_add_item(tree, hf_zbee_tlv_local_tunneling_npdu, tvb, offset + 2, npdu_len, ENC_NA);
1916
0
        proto_tree *npdu_tree = proto_item_add_subtree(npdu_item, ett_zbee_tlv_zbd_tunneling_npdu);
1917
1918
0
        ieee802154_packet packet;
1919
0
        memset(&packet, 0, sizeof(packet));
1920
        /* XXX - Every packet having a pointer to a global table seems odd. */
1921
0
        packet.short_table = ieee802154_map.short_table;
1922
        /* XXX - Ideally src_pan, etc. should be set with information from
1923
         * ZBD commissioning messages. */
1924
1925
0
        col_append_str(pinfo->cinfo, COL_PROTOCOL, "/");
1926
0
        col_set_fence(pinfo->cinfo, COL_PROTOCOL);
1927
0
        call_dissector_with_data(zbee_nwk_handle,
1928
0
                                 tvb_new_subset_length(tvb, offset + 2, npdu_len),
1929
0
                                 pinfo,
1930
0
                                 npdu_tree,
1931
0
                                 &packet);
1932
0
    }
1933
1934
0
    offset += length;
1935
1936
0
    return offset;
1937
0
}
1938
1939
/**
1940
 * Checks a curve, that was selected in the method.
1941
 *
1942
 * @param  tvb     pointer to buffer containing raw packet
1943
 * @param  pinfo   pointer to packet information fields
1944
 * @param  tree    pointer to the command subtree
1945
 * @param  offset  offset into the tvb to begin dissection
1946
 * @return offset after command dissection
1947
 */
1948
static unsigned
1949
dissect_zbee_tlv_key_neg_method(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1950
0
{
1951
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_selected_key_method, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1952
0
    offset += 1;
1953
1954
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_selected_psk_secret, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1955
0
    offset += 1;
1956
1957
0
    return offset;
1958
0
}
1959
1960
/**
1961
 * Helper dissector for the MAC tag.
1962
 *
1963
 * @param  tvb     pointer to buffer containing raw packet
1964
 * @param  pinfo   pointer to packet information fields
1965
 * @param  tree    pointer to the command subtree
1966
 * @param  offset  offset into the tvb to begin dissection
1967
 * @return offset after command dissection
1968
 */
1969
static unsigned
1970
dissect_zbee_tlv_mac_tag(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t mac_tag_size)
1971
0
{
1972
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_mac_tag, tvb, offset, mac_tag_size, ENC_NA);
1973
0
    offset += mac_tag_size;
1974
1975
0
    return offset;
1976
0
}
1977
1978
/**
1979
 * Helper dissector for the NWK key sequence number.
1980
 *
1981
 * @param  tvb     pointer to buffer containing raw packet
1982
 * @param  pinfo   pointer to packet information fields
1983
 * @param  tree    pointer to the command subtree
1984
 * @param  offset  offset into the tvb to begin dissection
1985
 * @return offset after command dissection
1986
 */
1987
static unsigned
1988
dissect_zbee_tlv_nwk_key_seq_num(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
1989
0
{
1990
0
    proto_tree_add_item(tree, hf_zbee_tlv_local_nwk_key_seq_num, tvb, offset, 1, ENC_LITTLE_ENDIAN);
1991
0
    offset += 1;
1992
1993
0
    return offset;
1994
0
}
1995
1996
/*
1997
 *Helper dissector for the ZB Direct Status.
1998
 *
1999
 *@param tvb pointer to buffer containing raw packet.
2000
 *@param pinfo pointer to packet information fields
2001
 *@param tree pointer to the command subtree.
2002
 *@param  offset into the tvb to begin dissection.
2003
 *@return offset after command dissection.
2004
*/
2005
static unsigned
2006
dissect_zbd_msg_status_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2007
0
{
2008
0
    uint8_t type;
2009
0
    uint8_t length;
2010
2011
0
    type = tvb_get_uint8(tvb, offset);
2012
0
    proto_tree_add_item(tree, hf_zbee_tlv_zbd_comm_tlv, tvb, offset, 1, ENC_NA);
2013
0
    offset += 1;
2014
2015
0
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
2016
0
    offset += 1;
2017
2018
0
    length += 1;
2019
2020
0
    switch (type)
2021
0
    {
2022
0
        case ZBEE_TLV_TYPE_COMM_IEEE_ADDR:
2023
0
            offset = dissect_zbee_tlv_ieee_addr(tvb, pinfo, tree, offset);
2024
0
            break;
2025
2026
0
        case ZBEE_TLV_TYPE_COMM_NWK_STATUS_MAP:
2027
0
            offset = dissect_zbee_tlv_nwk_status_map(tvb, pinfo, tree, offset);
2028
0
            break;
2029
2030
0
        case ZBEE_TLV_TYPE_COMM_TC_ADDR:
2031
0
            offset = dissect_zbee_tlv_tc_addr(tvb, pinfo, tree, offset);
2032
0
            break;
2033
2034
0
        case ZBEE_TLV_TYPE_COMM_EXT_PAN_ID:
2035
0
            offset = dissect_zbee_tlv_ext_pan_id(tvb, pinfo, tree, offset);
2036
0
            break;
2037
2038
0
        case ZBEE_TLV_TYPE_COMM_SHORT_PAN_ID:
2039
0
            offset = dissect_zbee_tlv_short_pan_id(tvb, pinfo, tree, offset);
2040
0
            break;
2041
2042
0
        case ZBEE_TLV_TYPE_COMM_NWK_CH:
2043
0
            offset = dissect_zbee_tlv_nwk_channel_list(tvb, pinfo, tree, offset);
2044
0
            break;
2045
2046
0
        case ZBEE_TLV_TYPE_COMM_NWK_KEY:
2047
0
            offset = dissect_zbee_tlv_nwk_key(tvb, pinfo, tree, offset);
2048
0
            break;
2049
2050
0
        case ZBEE_TLV_TYPE_COMM_NWK_ADDR:
2051
0
            offset = dissect_zbee_tlv_nwk_addr(tvb, pinfo, tree, offset);
2052
0
            break;
2053
2054
0
        case ZBEE_TLV_TYPE_COMM_NWK_UPD_ID:
2055
0
            offset = dissect_zbee_tlv_nwk_upd_id(tvb, pinfo, tree, offset);
2056
0
            break;
2057
2058
0
        case ZBEE_TLV_TYPE_COMM_KEY_SEQ_NUM:
2059
0
            offset = dissect_zbee_tlv_key_seq_num(tvb, pinfo, tree, offset);
2060
0
            break;
2061
2062
0
        case ZBEE_TLV_TYPE_COMM_DEV_TYPE:
2063
0
            offset = dissect_zbee_tlv_dev_type(tvb, pinfo, tree, offset);
2064
0
            break;
2065
2066
0
        case ZBEE_TLV_TYPE_COMM_STATUS_CODE:
2067
0
            offset = dissect_zbee_tlv_status_code(tvb, pinfo, tree, offset);
2068
0
            break;
2069
2070
0
        default:
2071
0
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
2072
0
            offset += length;
2073
0
            break;
2074
0
    }
2075
2076
0
    return offset;
2077
0
}
2078
2079
/*
2080
 *Helper dissector for the ZB Direct Tunneling.
2081
 *
2082
 *@param tvb pointer to buffer containing raw packet.
2083
 *@param pinfo pointer to packet information fields
2084
 *@param tree pointer to the command subtree.
2085
 *@param  offset into the tvb to begin dissection.
2086
 *@return offset after command dissection.
2087
*/
2088
static unsigned
2089
dissect_zbd_msg_tunneling_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2090
0
{
2091
0
    uint8_t opcode = tvb_get_uint8(tvb, offset);
2092
0
    uint8_t length;
2093
2094
0
    proto_tree_add_item(tree, hf_zbee_tlv_zbd_tunneling_npdu_msg_tlv, tvb, offset, 1, ENC_NA);
2095
0
    offset += 1;
2096
2097
0
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
2098
0
    offset += 1;
2099
2100
0
    length += 1;
2101
2102
0
    switch (opcode)
2103
0
    {
2104
0
        case ZBEE_TLV_TYPE_TUNNELING_NPDU_MESSAGE:
2105
0
        {
2106
0
            offset = dissect_zbee_tlv_tunneling_npdu_msg(tvb, pinfo, tree, offset, length);
2107
0
            break;
2108
0
        }
2109
2110
0
        default:
2111
0
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
2112
0
            offset += length;
2113
0
            break;
2114
0
    }
2115
2116
0
    return offset;
2117
0
}
2118
2119
/*
2120
 *Helper dissector for the ZB Direct Manage Joiners.
2121
 *
2122
 *@param tvb pointer to buffer containing raw packet.
2123
 *@param pinfo pointer to packet information fields
2124
 *@param tree pointer to the command subtree.
2125
 *@param  offset into the tvb to begin dissection.
2126
 *@return offset after command dissection.
2127
*/
2128
static unsigned
2129
dissect_zbd_msg_manage_joiners_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2130
0
{
2131
0
    uint8_t type;
2132
0
    uint8_t length;
2133
2134
0
    type = tvb_get_uint8(tvb, offset);
2135
2136
0
    proto_tree_add_item(tree, hf_zbee_tlv_zbd_comm_mj_cmd_tlv, tvb, offset, 1, ENC_NA);
2137
0
    offset += 1;
2138
2139
0
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
2140
0
    offset += 1;
2141
2142
0
    length += 1;
2143
2144
0
    switch (type)
2145
0
    {
2146
0
        case ZBEE_TLV_TYPE_COMM_MJ_CMD:
2147
0
            offset = dissect_zbee_tlv_mj_cmd(tvb, pinfo, tree, offset);
2148
0
            break;
2149
2150
0
        case ZBEE_TLV_TYPE_COMM_MJ_IEEE_ADDR:
2151
0
            offset = dissect_zbee_tlv_mj_ieee_addr(tvb, pinfo, tree, offset);
2152
0
            break;
2153
2154
0
        case ZBEE_TLV_TYPE_COMM_MJ_PROVISIONAL_LINK_KEY:
2155
0
            offset = dissect_zbee_tlv_mj_prov_lnk_key(tvb, pinfo, tree, offset);
2156
0
            break;
2157
2158
0
        default:
2159
0
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
2160
0
            offset += length;
2161
0
            break;
2162
0
    }
2163
2164
0
    return offset;
2165
0
}
2166
2167
/*
2168
 *Helper dissector for the ZB Direct Direct Join.
2169
 *
2170
 *@param tvb pointer to buffer containing raw packet.
2171
 *@param pinfo pointer to packet information fields
2172
 *@param tree pointer to the command subtree.
2173
 *@param  offset into the tvb to begin dissection.
2174
 *@return offset after command dissection.
2175
*/
2176
static unsigned
2177
dissect_zbd_msg_join_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2178
0
{
2179
0
    uint8_t type;
2180
0
    uint8_t length;
2181
2182
0
    type = tvb_get_uint8(tvb, offset);
2183
0
    proto_tree_add_item(tree, hf_zbee_tlv_zbd_comm_tlv, tvb, offset, 1, ENC_NA);
2184
0
    offset += 1;
2185
2186
0
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
2187
0
    offset += 1;
2188
2189
0
    length += 1;
2190
2191
0
    switch (type)
2192
0
    {
2193
0
        case ZBEE_TLV_TYPE_COMM_JOIN_METHOD:
2194
0
            offset = dissect_zbee_tlv_join_method(tvb, pinfo, tree, offset);
2195
0
            break;
2196
2197
0
        case ZBEE_TLV_TYPE_COMM_ADMIN_KEY:
2198
0
            offset = dissect_zbee_tlv_adm_key(tvb, pinfo, tree, offset);
2199
0
            break;
2200
2201
0
        case ZBEE_TLV_TYPE_COMM_TC_ADDR:
2202
0
            offset = dissect_zbee_tlv_tc_addr(tvb, pinfo, tree, offset);
2203
0
            break;
2204
2205
0
        case ZBEE_TLV_TYPE_COMM_EXT_PAN_ID:
2206
0
            offset = dissect_zbee_tlv_ext_pan_id(tvb, pinfo, tree, offset);
2207
0
            break;
2208
2209
0
        case ZBEE_TLV_TYPE_COMM_SHORT_PAN_ID:
2210
0
            offset = dissect_zbee_tlv_short_pan_id(tvb, pinfo, tree, offset);
2211
0
            break;
2212
2213
0
        case ZBEE_TLV_TYPE_COMM_NWK_CH:
2214
0
            offset = dissect_zbee_tlv_nwk_channel_list(tvb, pinfo, tree, offset);
2215
0
            break;
2216
2217
0
        case ZBEE_TLV_TYPE_COMM_NWK_KEY:
2218
0
            offset = dissect_zbee_tlv_nwk_key(tvb, pinfo, tree, offset);
2219
0
            break;
2220
2221
0
        case ZBEE_TLV_TYPE_COMM_LNK_KEY:
2222
0
            offset = dissect_zbee_tlv_link_key(tvb, pinfo, tree, offset);
2223
0
            break;
2224
2225
0
        case ZBEE_TLV_TYPE_COMM_NWK_ADDR:
2226
0
            offset = dissect_zbee_tlv_nwk_addr(tvb, pinfo, tree, offset);
2227
0
            break;
2228
2229
0
        case ZBEE_TLV_TYPE_COMM_NWK_UPD_ID:
2230
0
            offset = dissect_zbee_tlv_nwk_upd_id(tvb, pinfo, tree, offset);
2231
0
            break;
2232
2233
0
        case ZBEE_TLV_TYPE_COMM_KEY_SEQ_NUM:
2234
0
            offset = dissect_zbee_tlv_key_seq_num(tvb, pinfo, tree, offset);
2235
0
            break;
2236
2237
0
        default:
2238
0
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
2239
0
            offset += length;
2240
0
            break;
2241
0
    }
2242
2243
0
    return offset;
2244
0
}
2245
2246
/*
2247
 *Helper dissector for the ZB Direct Formation.
2248
 *
2249
 *@param tvb pointer to buffer containing raw packet.
2250
 *@param pinfo pointer to packet information fields
2251
 *@param tree pointer to the command subtree.
2252
 *@param  offset into the tvb to begin dissection.
2253
 *@return offset after command dissection.
2254
*/
2255
static unsigned
2256
dissect_zbd_msg_formation_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2257
0
{
2258
0
    uint8_t type;
2259
0
    uint8_t length;
2260
2261
0
    type = tvb_get_uint8(tvb, offset);
2262
0
    proto_tree_add_item(tree, hf_zbee_tlv_zbd_comm_tlv, tvb, offset, 1, ENC_NA);
2263
0
    offset += 1;
2264
2265
0
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
2266
0
    offset += 1;
2267
2268
0
    length += 1;
2269
2270
0
    switch (type)
2271
0
    {
2272
0
        case ZBEE_TLV_TYPE_COMM_ADMIN_KEY:
2273
0
            offset = dissect_zbee_tlv_adm_key(tvb, pinfo, tree, offset);
2274
0
            break;
2275
2276
0
        case ZBEE_TLV_TYPE_COMM_TC_ADDR:
2277
0
            offset = dissect_zbee_tlv_tc_addr(tvb, pinfo, tree, offset);
2278
0
            break;
2279
2280
0
        case ZBEE_TLV_TYPE_COMM_EXT_PAN_ID:
2281
0
            offset = dissect_zbee_tlv_ext_pan_id(tvb, pinfo, tree, offset);
2282
0
            break;
2283
2284
0
        case ZBEE_TLV_TYPE_COMM_SHORT_PAN_ID:
2285
0
            offset = dissect_zbee_tlv_short_pan_id(tvb, pinfo, tree, offset);
2286
0
            break;
2287
2288
0
        case ZBEE_TLV_TYPE_COMM_NWK_CH:
2289
0
            offset = dissect_zbee_tlv_nwk_channel_list(tvb, pinfo, tree, offset);
2290
0
            break;
2291
2292
0
        case ZBEE_TLV_TYPE_COMM_NWK_KEY:
2293
0
            offset = dissect_zbee_tlv_nwk_key(tvb, pinfo, tree, offset);
2294
0
            break;
2295
2296
0
        case ZBEE_TLV_TYPE_COMM_LNK_KEY:
2297
0
            offset = dissect_zbee_tlv_link_key(tvb, pinfo, tree, offset);
2298
0
            break;
2299
2300
0
        case ZBEE_TLV_TYPE_COMM_NWK_ADDR:
2301
0
            offset = dissect_zbee_tlv_nwk_addr(tvb, pinfo, tree, offset);
2302
0
            break;
2303
2304
0
        case ZBEE_TLV_TYPE_COMM_NWK_UPD_ID:
2305
0
            offset = dissect_zbee_tlv_nwk_upd_id(tvb, pinfo, tree, offset);
2306
0
            break;
2307
2308
0
        case ZBEE_TLV_TYPE_COMM_KEY_SEQ_NUM:
2309
0
            offset = dissect_zbee_tlv_key_seq_num(tvb, pinfo, tree, offset);
2310
0
            break;
2311
2312
0
        default:
2313
0
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
2314
0
            offset += length;
2315
0
            break;
2316
0
    }
2317
2318
0
    return offset;
2319
0
}
2320
2321
/*
2322
 *Helper dissector for the ZB Direct Security Messages.
2323
 *
2324
 *@param tvb pointer to buffer containing raw packet.
2325
 *@param pinfo pointer to packet information fields
2326
 *@param tree pointer to the command subtree.
2327
 *@param  offset into the tvb to begin dissection.
2328
 *@return offset after command dissection.
2329
*/
2330
static unsigned
2331
dissect_zbd_msg_secur_local_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2332
0
{
2333
0
    uint8_t type;
2334
0
    uint8_t length;
2335
2336
0
    type = tvb_get_uint8(tvb, offset);
2337
0
    proto_tree_add_item(tree, hf_zbee_tlv_zbd_secur_tlv, tvb, offset, 1, ENC_NA);
2338
0
    offset += 1;
2339
2340
0
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
2341
0
    offset += 1;
2342
2343
0
    length += 1;
2344
2345
0
    switch (type)
2346
0
    {
2347
0
        case ZBEE_TLV_TYPE_KEY_METHOD:
2348
0
            offset = dissect_zbee_tlv_key_neg_method(tvb, pinfo, tree, offset);
2349
0
            break;
2350
2351
0
        case ZBEE_TLV_TYPE_PUB_POINT_P256:
2352
0
        case ZBEE_TLV_TYPE_PUB_POINT_C25519:
2353
0
            offset = dissect_zbee_tlv_public_point(tvb, pinfo, tree, offset, length);
2354
0
            break;
2355
2356
0
        case ZBEE_TLV_TYPE_NWK_KEY_SEQ_NUM:
2357
0
            offset = dissect_zbee_tlv_nwk_key_seq_num(tvb, pinfo, tree, offset);
2358
0
            break;
2359
2360
0
        case ZBEE_TLV_TYPE_MAC_TAG:
2361
0
            offset = dissect_zbee_tlv_mac_tag(tvb, pinfo, tree, offset, length);
2362
0
            break;
2363
2364
0
        default:
2365
0
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
2366
0
            offset += length;
2367
0
            break;
2368
0
    }
2369
2370
0
    return offset;
2371
0
}
2372
2373
/*
2374
 *Helper dissector for the ZD Direct messages.
2375
 *
2376
 *@param  tvb pointer to buffer containing raw packet
2377
 *@param  pinfo pointer to packet information fields
2378
 *@param  tree pointer to the command subtree
2379
 *@param  offset into the tvb to begin dissection
2380
 *@param  cmd_id - ZB Direct local Message ID
2381
 *@return offset after command dissection
2382
*/
2383
static unsigned
2384
dissect_zbd_local_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset, void* data _U_, unsigned cmd_id)
2385
0
{
2386
0
    unsigned total_tlv_length = 2 /*type + len fields*/ + tvb_get_uint8(tvb, offset + 1) + 1;
2387
0
    unsigned tmp_offset = offset;
2388
2389
0
    switch (cmd_id)
2390
0
    {
2391
0
        case ZB_DIRECT_MSG_ID_STATUS:
2392
0
            offset = dissect_zbd_msg_status_local_tlv(tvb, pinfo, tree, offset);
2393
0
            break;
2394
2395
0
        case ZB_DIRECT_MSG_ID_TUNNELING:
2396
0
            offset = dissect_zbd_msg_tunneling_local_tlv(tvb, pinfo, tree, offset);
2397
0
            break;
2398
2399
0
        case ZB_DIRECT_MSG_ID_MANAGE_JOINERS:
2400
0
            offset = dissect_zbd_msg_manage_joiners_local_tlv(tvb, pinfo, tree, offset);
2401
0
            break;
2402
2403
0
        case ZB_DIRECT_MSG_ID_JOIN:
2404
0
            offset = dissect_zbd_msg_join_local_tlv(tvb, pinfo, tree, offset);
2405
0
            break;
2406
2407
0
        case ZB_DIRECT_MSG_ID_FORMATION:
2408
0
            offset = dissect_zbd_msg_formation_local_tlv(tvb, pinfo, tree, offset);
2409
0
            break;
2410
2411
0
        case ZB_DIRECT_MSG_ID_SECUR_C25519_AESMMO:
2412
0
        case ZB_DIRECT_MSG_ID_SECUR_C25519_SHA256:
2413
0
        case ZB_DIRECT_MSG_ID_SECUR_P256:
2414
0
            offset = dissect_zbd_msg_secur_local_tlv(tvb, pinfo, tree, offset);
2415
0
            break;
2416
2417
0
        default:
2418
0
            offset = dissect_unknown_tlv(tvb, pinfo, tree, offset);
2419
0
            break;
2420
0
    }
2421
2422
    /* check extra bytes */
2423
0
    if ((offset - tmp_offset) < total_tlv_length)
2424
0
    {
2425
0
        proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, total_tlv_length - (offset - tmp_offset), ENC_NA);
2426
0
        offset = tmp_offset + total_tlv_length;
2427
0
    }
2428
2429
0
    return offset;
2430
0
}
2431
2432
/**
2433
 * *Dissector for Zigbee Manufacturer Specific Global TLV
2434
 *
2435
 *@param tvb pointer to buffer containing raw packet.
2436
 *@param pinfo pointer to packet information fields
2437
 *@param tree pointer to data tree Wireshark uses to display packet.
2438
 *@param  offset into the tvb to begin dissection.
2439
 *@param  length of TLV data
2440
 *@return offset after command dissection.
2441
 */
2442
static unsigned
2443
dissect_zbee_tlv_manufacturer_specific(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t length)
2444
25
{
2445
25
    proto_tree_add_item(tree, hf_zbee_tlv_manufacturer_specific, tvb, offset, 2, ENC_LITTLE_ENDIAN);
2446
25
    offset += 2;
2447
2448
25
    proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length - 2, ENC_NA);
2449
25
    offset += length - 2;
2450
2451
25
    return offset;
2452
25
} /* dissect_zbee_tlv_manufacturer_specific */
2453
2454
/**
2455
 *Dissector for Zigbee Supported Key Negotiation Methods Global TLV
2456
 *
2457
 *@param tvb pointer to buffer containing raw packet.
2458
 *@param pinfo pointer to packet information fields
2459
 *@param tree pointer to data tree Wireshark uses to display packet.
2460
 *@param  offset into the tvb to begin dissection.
2461
 *@return offset after command dissection.
2462
 */
2463
static unsigned
2464
dissect_zbee_tlv_supported_key_negotiation_methods(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2465
21
{
2466
21
    static int * const supported_key_negotiation_methods[] = {
2467
21
        &hf_zbee_tlv_supported_key_negotiation_methods_key_request,
2468
21
        &hf_zbee_tlv_supported_key_negotiation_methods_ecdhe_using_curve25519_aes_mmo128,
2469
21
        &hf_zbee_tlv_supported_key_negotiation_methods_ecdhe_using_curve25519_sha256,
2470
21
        NULL
2471
21
    };
2472
2473
21
    static int * const supported_secrets[] = {
2474
21
        &hf_zbee_tlv_supported_preshared_secrets_auth_token,
2475
21
        &hf_zbee_tlv_supported_preshared_secrets_ic,
2476
21
        &hf_zbee_tlv_supported_preshared_secrets_passcode_pake,
2477
21
        &hf_zbee_tlv_supported_preshared_secrets_basic_access_key,
2478
21
        &hf_zbee_tlv_supported_preshared_secrets_admin_access_key,
2479
21
        NULL
2480
21
    };
2481
2482
21
    proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_tlv_supported_key_negotiation_methods, ett_zbee_tlv_supported_key_negotiation_methods, supported_key_negotiation_methods, ENC_NA);
2483
21
    offset += 1;
2484
2485
21
    proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_tlv_supported_secrets, ett_zbee_tlv_supported_secrets, supported_secrets, ENC_NA);
2486
21
    offset += 1;
2487
2488
21
    proto_tree_add_item(tree, hf_zbee_tlv_device_eui64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
2489
21
    offset += 8;
2490
2491
21
    return offset;
2492
21
} /* dissect_zbee_tlv_supported_key_negotiation_methods */
2493
2494
/**
2495
 *Dissector for Zigbee PAN ID conflict report Global TLV
2496
 *
2497
 *@param tvb pointer to buffer containing raw packet.
2498
 *@param pinfo pointer to packet information fields
2499
 *@param tree pointer to data tree Wireshark uses to display packet.
2500
 *@param  offset into the tvb to begin dissection.
2501
 *@return offset after command dissection.
2502
 */
2503
static unsigned
2504
dissect_zbee_tlv_panid_conflict_report(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2505
16
{
2506
16
    proto_tree_add_item(tree, hf_zbee_tlv_panid_conflict_cnt, tvb, offset, 2, ENC_LITTLE_ENDIAN);
2507
16
    offset += 2;
2508
2509
16
    return offset;
2510
16
}
2511
2512
2513
/**
2514
 * *Dissector for Zigbee Configuration Parameters Global TLV
2515
 *
2516
 *@param tvb pointer to buffer containing raw packet.
2517
 *@param pinfo pointer to packet information fields
2518
 *@param tree pointer to data tree Wireshark uses to display packet.
2519
 *@param  offset into the tvb to begin dissection.
2520
 *@return offset after command dissection.
2521
 */
2522
static unsigned
2523
dissect_zbee_tlv_configuration_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2524
17
{
2525
17
    static int * const bitmask[] = {
2526
17
        &hf_zbee_tlv_configuration_param_restricted_mode,
2527
17
        &hf_zbee_tlv_configuration_param_link_key_enc,
2528
17
        &hf_zbee_tlv_configuration_param_leave_req_allowed,
2529
17
        NULL
2530
17
    };
2531
2532
17
    proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_tlv_configuration_param, ett_zbee_tlv_configuration_param, bitmask, ENC_LITTLE_ENDIAN);
2533
17
    offset += 2;
2534
2535
17
    return offset;
2536
17
} /* dissect_zbee_tlv_configuration_parameters */
2537
2538
2539
/**
2540
 * *Dissector for Zigbee Configuration Parameters Global TLV
2541
 *
2542
 *@param tvb pointer to buffer containing raw packet.
2543
 *@param pinfo pointer to packet information fields
2544
 *@param tree pointer to data tree Wireshark uses to display packet.
2545
 *@param  offset into the tvb to begin dissection.
2546
 *@return offset after command dissection.
2547
 */
2548
static unsigned
2549
dissect_zbee_tlv_dev_cap_ext(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2550
16
{
2551
16
    static int * const bitmask[] = {
2552
16
        &hf_zbee_tlv_dev_cap_ext_zbdirect_virt_device,
2553
16
        NULL
2554
16
    };
2555
2556
16
    proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_tlv_dev_cap_ext_capability_information, ett_zbee_tlv_capability_information, bitmask, ENC_LITTLE_ENDIAN);
2557
16
    offset += 2;
2558
2559
16
    return offset;
2560
16
} /* dissect_zbee_tlv_configuration_parameters */
2561
2562
/**
2563
 * *Dissector for Zigbee CPotential Parents Global TLV
2564
 *
2565
 *@param tvb pointer to buffer containing raw packet.
2566
 *@param pinfo pointer to packet information fields
2567
 *@param tree pointer to data tree Wireshark uses to display packet.
2568
 *@param  offset into the tvb to begin dissection.
2569
 *@return offset after command dissection.
2570
 */
2571
static unsigned
2572
dissect_zbee_tlv_potential_parents(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2573
32
{
2574
32
  uint8_t count, i;
2575
2576
32
  proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_current_parent, tvb, offset, 2, ENC_LITTLE_ENDIAN);
2577
32
  offset += 2;
2578
2579
32
  proto_tree_add_item(tree, hf_zbee_tlv_lqa, tvb, offset, 1, ENC_LITTLE_ENDIAN);
2580
32
  offset += 1;
2581
2582
32
  count = tvb_get_uint8(tvb, offset);
2583
32
  proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_cnt_parents, tvb, offset, 1, ENC_LITTLE_ENDIAN);
2584
32
  offset += 1;
2585
2586
185
  for (i = 0; i < count; i++)
2587
153
  {
2588
153
    proto_tree_add_item(tree, hf_zbee_zdp_beacon_survey_parent, tvb, offset, 2, ENC_LITTLE_ENDIAN);
2589
153
    offset += 2;
2590
2591
153
    proto_tree_add_item(tree, hf_zbee_tlv_lqa, tvb, offset, 1, ENC_LITTLE_ENDIAN);
2592
153
    offset += 1;
2593
153
  }
2594
2595
32
  return offset;
2596
32
}
2597
2598
/**
2599
 * *Dissector for Zigbee Next PAN ID Change Global TLV
2600
 *
2601
 *@param tvb pointer to buffer containing raw packet.
2602
 *@param pinfo pointer to packet information fields
2603
 *@param tree pointer to data tree Wireshark uses to display packet.
2604
 *@param  offset into the tvb to begin dissection.
2605
 *@return offset after command dissection.
2606
 */
2607
static unsigned
2608
dissect_zbee_tlv_next_pan_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2609
13
{
2610
13
    proto_tree_add_item(tree, hf_zbee_tlv_next_pan_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
2611
13
    offset += 2;
2612
2613
13
    return offset;
2614
13
} /* dissect_zbee_tlv_next_pan_id */
2615
2616
/**
2617
 * *Dissector for Zigbee Next Channel Change Global TLV
2618
 *
2619
 *@param tvb pointer to buffer containing raw packet.
2620
 *@param pinfo pointer to packet information fields
2621
 *@param tree pointer to data tree Wireshark uses to display packet.
2622
 *@param  offset into the tvb to begin dissection.
2623
 *@return offset after command dissection.
2624
 */
2625
static unsigned
2626
dissect_zbee_tlv_next_channel_change(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2627
13
{
2628
    /* todo: fix this (do channel mask) */
2629
13
    proto_tree_add_item(tree, hf_zbee_tlv_next_channel_change, tvb, offset, 4, ENC_LITTLE_ENDIAN);
2630
13
    offset += 4;
2631
2632
13
    return offset;
2633
13
} /* dissect_zbee_tlv_next_channel_change */
2634
2635
/**
2636
 * *Dissector for Zigbee Passphrase Global TLV
2637
 *
2638
 *@param tvb pointer to buffer containing raw packet.
2639
 *@param pinfo pointer to packet information fields
2640
 *@param tree pointer to data tree Wireshark uses to display packet.
2641
 *@param  offset into the tvb to begin dissection.
2642
 *@return offset after command dissection.
2643
 */
2644
static unsigned
2645
dissect_zbee_tlv_passphrase(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2646
7
{
2647
7
    proto_tree_add_item(tree, hf_zbee_tlv_passphrase, tvb, offset, 16, ENC_NA);
2648
7
    offset += 16;
2649
2650
7
    return offset;
2651
7
} /* dissect_zbee_tlv_passphrase */
2652
2653
2654
/**
2655
 * *Dissector for Zigbee Router Information Global TLV
2656
 *
2657
 *@param tvb pointer to buffer containing raw packet.
2658
 *@param pinfo pointer to packet information fields
2659
 *@param tree pointer to data tree Wireshark uses to display packet.
2660
 *@param  offset into the tvb to begin dissection.
2661
 *@return offset after command dissection.
2662
 */
2663
static unsigned
2664
dissect_zbee_tlv_router_information(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2665
12
{
2666
12
    static int * const router_information[] = {
2667
12
        &hf_zbee_tlv_router_information_hub_connectivity,
2668
12
        &hf_zbee_tlv_router_information_uptime,
2669
12
        &hf_zbee_tlv_router_information_pref_parent,
2670
12
        &hf_zbee_tlv_router_information_battery_backup,
2671
12
        &hf_zbee_tlv_router_information_enhanced_beacon_request_support,
2672
12
        &hf_zbee_tlv_router_information_mac_data_poll_keepalive_support,
2673
12
        &hf_zbee_tlv_router_information_end_device_keepalive_support,
2674
12
        &hf_zbee_tlv_router_information_power_negotiation_support,
2675
12
        NULL
2676
12
    };
2677
2678
12
    proto_tree_add_bitmask(tree, tvb, offset, hf_zbee_tlv_router_information, ett_zbee_tlv_router_information, router_information, ENC_LITTLE_ENDIAN);
2679
12
    offset += 2;
2680
2681
12
    return offset;
2682
12
} /* dissect_zbee_tlv_router_information */
2683
2684
/**
2685
 * *Dissector for Zigbee Fragmentation Parameters Global TLV
2686
 *
2687
 *@param tvb pointer to buffer containing raw packet.
2688
 *@param pinfo pointer to packet information fields
2689
 *@param tree pointer to data tree Wireshark uses to display packet.
2690
 *@param  offset into the tvb to begin dissection.
2691
 *@return offset after command dissection.
2692
 */
2693
static unsigned
2694
dissect_zbee_tlv_fragmentation_parameters(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2695
15
{
2696
15
    proto_tree_add_item(tree, hf_zbee_tlv_node_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
2697
15
    offset += 2;
2698
2699
15
    proto_tree_add_item(tree, hf_zbee_tlv_frag_opt, tvb, offset, 1, ENC_NA);
2700
15
    offset += 1;
2701
2702
15
    proto_tree_add_item(tree, hf_zbee_tlv_max_reassembled_buf_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
2703
15
    offset += 2;
2704
2705
15
    return offset;
2706
15
} /* dissect_zbee_tlv_fragmentation_parameters */
2707
2708
/**
2709
 *Dissector for Zigbee Selected Key Negotiation Methods TLV
2710
 *
2711
 *@param tvb pointer to buffer containing raw packet.
2712
 *@param pinfo pointer to packet information fields
2713
 *@param tree pointer to data tree Wireshark uses to display packet.
2714
 *@param  offset into the tvb to begin dissection.
2715
 *@return offset after command dissection.
2716
 */
2717
static unsigned
2718
dissect_zbee_tlv_selected_key_negotiation_method(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2719
23
{
2720
23
    proto_tree_add_item(tree, hf_zbee_tlv_selected_key_negotiation_method, tvb, offset, 1, ENC_NA);
2721
23
    offset += 1;
2722
2723
23
    proto_tree_add_item(tree, hf_zbee_tlv_selected_pre_shared_secret, tvb, offset, 1, ENC_NA);
2724
23
    offset += 1;
2725
2726
23
    proto_tree_add_item(tree, hf_zbee_tlv_device_eui64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
2727
23
    offset += 8;
2728
2729
23
    return offset;
2730
23
} /* dissect_zbee_tlv_selected_key_negotiation_methods */
2731
2732
2733
/**
2734
 *Dissector for Public Point TLVs
2735
 *
2736
 *@param tvb pointer to buffer containing raw packet.
2737
 *@param pinfo pointer to packet information fields
2738
 *@param tree pointer to data tree Wireshark uses to display packet.
2739
 *@param  offset into the tvb to begin dissection.
2740
 *@return offset after command dissection.
2741
 */
2742
static unsigned
2743
dissect_zbee_tlv_public_point(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, uint8_t length)
2744
8
{
2745
8
    uint8_t public_point_length = length - 8;
2746
2747
8
    proto_tree_add_item(tree, hf_zbee_tlv_device_eui64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
2748
8
    offset += 8;
2749
2750
8
    proto_tree_add_item(tree, hf_zbee_tlv_public_point, tvb, offset, public_point_length, ENC_NA);
2751
8
    offset += public_point_length;
2752
2753
8
    return offset;
2754
8
} /* dissect_zbee_tlv_curve25519_public_point */
2755
2756
/*
2757
 *Dissector for Security Decommission Req EUI64 TLV
2758
 *
2759
 *@param tvb pointer to buffer containing raw packet.
2760
 *@param pinfo pointer to packet information fields
2761
 *@param tree pointer to data tree Wireshark uses to display packet.
2762
 *@param  offset into the tvb to begin dissection.
2763
 *@return offset after command dissection.
2764
 */
2765
static unsigned
2766
dissect_zbee_tlv_eui64(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2767
209
{
2768
209
    uint8_t eui64_count;
2769
209
    uint8_t i;
2770
2771
209
    eui64_count = tvb_get_uint8(tvb, offset);
2772
209
    proto_tree_add_item(tree, hf_zbee_tlv_count, tvb, offset, 1, ENC_NA);
2773
209
    offset += 1;
2774
2775
443
    for (i = 0; i < eui64_count; i++)
2776
234
    {
2777
234
        proto_tree_add_item(tree, hf_zbee_tlv_device_eui64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
2778
234
        offset += 8;
2779
234
    }
2780
2781
209
    return offset;
2782
209
}
2783
2784
/*
2785
 *Dissector for Clear All Bindings Req EUI64 TLV
2786
 *
2787
 *@param tvb pointer to buffer containing raw packet.
2788
 *@param pinfo pointer to packet information fields
2789
 *@param tree pointer to data tree Wireshark uses to display packet.
2790
 *@param  offset into the tvb to begin dissection.
2791
 *@return offset after command dissection.
2792
 */
2793
static unsigned
2794
dissect_zbee_tlv_clear_all_bindigs_eui64(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2795
148
{
2796
148
    return dissect_zbee_tlv_eui64(tvb, pinfo, tree, offset);
2797
148
}
2798
2799
/*
2800
 *Dissector for Requested Authentication Token ID TLV
2801
 *
2802
 *@param tvb pointer to buffer containing raw packet.
2803
 *@param pinfo pointer to packet information fields
2804
 *@param tree pointer to data tree Wireshark uses to display packet.
2805
 *@param  offset into the tvb to begin dissection.
2806
 *@return offset after command dissection.
2807
 */
2808
static unsigned
2809
dissect_zbee_tlv_requested_auth_token_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2810
117
{
2811
117
    proto_tree_add_item(tree, hf_zbee_tlv_global_tlv_id, tvb, offset, 1, ENC_NA);
2812
117
    offset += 1;
2813
2814
117
    return offset;
2815
117
}
2816
2817
/*
2818
 *Dissector for Target IEEE Address TLV
2819
 *
2820
 *@param tvb pointer to buffer containing raw packet.
2821
 *@param pinfo pointer to packet information fields
2822
 *@param tree pointer to data tree Wireshark uses to display packet.
2823
 *@param  offset into the tvb to begin dissection.
2824
 *@return offset after command dissection.
2825
 */
2826
static unsigned
2827
dissect_zbee_tlv_target_ieee_address(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2828
33
{
2829
33
    proto_tree_add_item(tree, hf_zbee_tlv_local_ieee_addr, tvb, offset, 8, ENC_LITTLE_ENDIAN);
2830
33
    offset += 8;
2831
2832
33
    return offset;
2833
33
}
2834
2835
/**
2836
 * *Dissector for Device Authentication Level TLV
2837
 *
2838
 *@param tvb pointer to buffer containing raw packet.
2839
 *@param pinfo pointer to packet information fields
2840
 *@param tree pointer to data tree Wireshark uses to display packet.
2841
 *@param  offset into the tvb to begin dissection.
2842
 *@return offset after command dissection.
2843
 */
2844
static unsigned
2845
dissect_zbee_tlv_device_auth_level(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2846
1
{
2847
2848
1
    proto_tree_add_item(tree, hf_zbee_tlv_local_ieee_addr, tvb, offset, 8, ENC_LITTLE_ENDIAN);
2849
1
    offset += 8;
2850
2851
1
    proto_tree_add_item(tree, hf_zbee_tlv_local_initial_join_method, tvb, offset, 1, ENC_NA);
2852
1
    offset += 1;
2853
2854
1
    proto_tree_add_item(tree, hf_zbee_tlv_local_active_lk_type, tvb, offset, 1, ENC_NA);
2855
1
    offset += 1;
2856
2857
1
    return offset;
2858
1
} /* dissect_zbee_tlv_device_auth_level */
2859
2860
/*
2861
 * ToDo: descr
2862
 */
2863
static unsigned
2864
// NOLINTNEXTLINE(misc-no-recursion)
2865
dissect_global_tlv (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2866
1.50k
{
2867
1.50k
    uint8_t type;
2868
1.50k
    uint8_t length;
2869
1.50k
    unsigned   tmp_offset;
2870
2871
1.50k
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_global_type, tvb, offset, 1, ENC_NA, &type);
2872
1.50k
    offset += 1;
2873
2874
1.50k
    proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
2875
1.50k
    offset += 1;
2876
2877
1.50k
    length += 1;
2878
1.50k
    tmp_offset = offset;
2879
1.50k
    switch (type) {
2880
25
        case ZBEE_TLV_TYPE_MANUFACTURER_SPECIFIC:
2881
25
            offset = dissect_zbee_tlv_manufacturer_specific(tvb, pinfo, tree, offset, length);
2882
25
            break;
2883
2884
21
        case ZBEE_TLV_TYPE_SUPPORTED_KEY_NEGOTIATION_METHODS:
2885
21
            offset = dissect_zbee_tlv_supported_key_negotiation_methods(tvb, pinfo, tree, offset);
2886
21
            break;
2887
2888
16
        case ZBEE_TLV_TYPE_PANID_CONFLICT_REPORT:
2889
16
            offset = dissect_zbee_tlv_panid_conflict_report(tvb, pinfo, tree, offset);
2890
16
            break;
2891
2892
13
        case ZBEE_TLV_TYPE_NEXT_PAN_ID:
2893
13
            offset = dissect_zbee_tlv_next_pan_id(tvb, pinfo, tree, offset);
2894
13
            break;
2895
2896
13
        case ZBEE_TLV_TYPE_NEXT_CHANNEL_CHANGE:
2897
13
            offset = dissect_zbee_tlv_next_channel_change(tvb, pinfo, tree, offset);
2898
13
            break;
2899
2900
7
        case ZBEE_TLV_TYPE_PASSPHRASE:
2901
7
            offset = dissect_zbee_tlv_passphrase(tvb, pinfo, tree, offset);
2902
7
            break;
2903
2904
12
        case ZBEE_TLV_TYPE_ROUTER_INFORMATION:
2905
12
            offset = dissect_zbee_tlv_router_information(tvb, pinfo, tree, offset);
2906
12
            break;
2907
2908
15
        case ZBEE_TLV_TYPE_FRAGMENTATION_PARAMETERS:
2909
15
            offset = dissect_zbee_tlv_fragmentation_parameters(tvb, pinfo, tree, offset);
2910
15
            break;
2911
2912
22
        case ZBEE_TLV_TYPE_JOINER_ENCAPSULATION_GLOBAL:
2913
22
            offset = dissect_zbee_tlvs(tvb, pinfo, tree, offset, NULL, ZBEE_TLV_SRC_TYPE_DEFAULT, 0);
2914
22
            break;
2915
2916
17
        case ZBEE_TLV_TYPE_BEACON_APPENDIX_ENCAPSULATION_GLOBAL:
2917
17
            offset = dissect_zbee_tlvs(tvb, pinfo, tree, offset, NULL, ZBEE_TLV_SRC_TYPE_DEFAULT, 0);
2918
17
            break;
2919
2920
17
        case ZBEE_TLV_TYPE_CONFIGURATION_MODE_PARAMETERS:
2921
17
            offset = dissect_zbee_tlv_configuration_parameters(tvb, pinfo, tree, offset);
2922
17
            break;
2923
2924
16
        case ZBEE_TLV_TYPE_DEVICE_CAPABILITY_EXTENSION:
2925
16
            offset = dissect_zbee_tlv_dev_cap_ext(tvb, pinfo, tree, offset);
2926
16
            break;
2927
2928
1.30k
        default:
2929
1.30k
            proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
2930
1.30k
            offset += length;
2931
1.30k
            break;
2932
1.50k
    }
2933
2934
    /* check extra bytes */
2935
1.33k
    if ((offset - tmp_offset) < length)
2936
124
    {
2937
124
      proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length - (offset - tmp_offset), ENC_NA);
2938
124
      offset = tmp_offset + length;
2939
124
    }
2940
2941
1.33k
    return offset;
2942
1.50k
}
2943
2944
/**
2945
 *Dissector for Unknown Zigbee TLV
2946
 *
2947
 *@param tvb pointer to buffer containing raw packet.
2948
 *@param pinfo pointer to packet information fields
2949
 *@param tree pointer to data tree Wireshark uses to display packet.
2950
 *@param  offset into the tvb to begin dissection.
2951
 *@return offset after command dissection.
2952
 */
2953
static unsigned
2954
dissect_unknown_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset)
2955
789
{
2956
789
  uint8_t      length;
2957
2958
789
  proto_tree_add_item(tree, hf_zbee_tlv_type, tvb, offset, 1, ENC_NA);
2959
789
  offset += 1;
2960
2961
789
  proto_tree_add_item_ret_uint8(tree, hf_zbee_tlv_length, tvb, offset, 1, ENC_NA, &length);
2962
789
  offset += 1;
2963
2964
789
  length += 1; /* length of tlv_val == tlv_len + 1 */
2965
789
  proto_tree_add_item(tree, hf_zbee_tlv_value, tvb, offset, length, ENC_NA);
2966
789
  offset += length;
2967
2968
789
  return offset;
2969
789
}
2970
2971
/**
2972
 *Dissector for Zigbee TLV
2973
 *
2974
 *@param tvb pointer to buffer containing raw packet.
2975
 *@param pinfo pointer to packet information fields
2976
 *@param tree pointer to data tree Wireshark uses to display packet.
2977
 *@param  offset into the tvb to begin dissection.
2978
 *@return offset after command dissection.
2979
 */
2980
static unsigned
2981
// NOLINTNEXTLINE(misc-no-recursion)
2982
dissect_zbee_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, void *data, uint8_t source_type, unsigned cmd_id)
2983
3.74k
{
2984
3.74k
    uint8_t      type;
2985
2986
3.74k
    type = tvb_get_uint8(tvb, offset);
2987
2988
3.74k
    if (type >= ZBEE_TLV_GLOBAL_START_NUMBER)
2989
1.50k
    {
2990
1.50k
        offset = dissect_global_tlv (tvb, pinfo, tree, offset);
2991
1.50k
    }
2992
2.23k
    else
2993
2.23k
    {
2994
2.23k
        switch (source_type)
2995
2.23k
        {
2996
1.21k
            case ZBEE_TLV_SRC_TYPE_ZBEE_ZDP:
2997
1.21k
                offset = dissect_zdp_local_tlv(tvb, pinfo, tree, offset, cmd_id);
2998
1.21k
                break;
2999
3000
273
            case ZBEE_TLV_SRC_TYPE_ZBEE_APS:
3001
273
                offset = dissect_aps_local_tlv(tvb, pinfo, tree, offset, data, cmd_id);
3002
273
                break;
3003
3004
332
            case ZBEE_TLV_SRC_TYPE_ZBEE_NWK:
3005
332
                offset = dissect_nwk_local_tlv(tvb, pinfo, tree, offset, cmd_id);
3006
332
                break;
3007
3008
0
            case ZBEE_TLV_SRC_TYPE_ZB_DIRECT:
3009
0
                offset = dissect_zbd_local_tlv(tvb, pinfo, tree, offset, data, cmd_id);
3010
0
                break;
3011
3012
422
            default:
3013
422
                offset = dissect_unknown_tlv(tvb, pinfo, tree, offset);
3014
422
                break;
3015
2.23k
        }
3016
2.23k
    }
3017
3018
3.53k
    return offset;
3019
3.74k
} /* dissect_zbee_tlv */
3020
3021
/**
3022
 *Dissector for Zigbee TLVs
3023
 *
3024
 *@param tvb pointer to buffer containing raw packet.
3025
 *@param pinfo pointer to packet information fields
3026
 *@param tree pointer to data tree Wireshark uses to display packet.
3027
 *@param  offset into the tvb to begin dissection.
3028
 *@param  source_type ToDo:
3029
 *@param  cmd_id ToDo:
3030
 *@return offset after command dissection.
3031
 */
3032
3033
617
#define ZBEE_TLV_MAX_RECURSION_DEPTH 5 // Arbitrarily chosen
3034
3035
unsigned
3036
// NOLINTNEXTLINE(misc-no-recursion)
3037
dissect_zbee_tlvs(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset, void *data, uint8_t source_type, unsigned cmd_id)
3038
617
{
3039
617
    proto_tree  *subtree;
3040
617
    uint8_t      length;
3041
617
    unsigned     recursion_depth = p_get_proto_depth(pinfo, proto_zbee_tlv);
3042
3043
617
    if (++recursion_depth >= ZBEE_TLV_MAX_RECURSION_DEPTH) {
3044
45
        proto_tree_add_expert(tree, pinfo, &ei_zbee_tlv_max_recursion_depth_reached, tvb, 0, 0);
3045
45
        return offset;
3046
45
    }
3047
3048
572
    p_set_proto_depth(pinfo, proto_zbee_tlv, recursion_depth);
3049
3050
4.31k
    while (tvb_bytes_exist(tvb, offset, ZBEE_TLV_HEADER_LENGTH)) {
3051
3.74k
        length = tvb_get_uint8(tvb, offset + 1) + 1;
3052
3.74k
        subtree = proto_tree_add_subtree(tree, tvb, offset, ZBEE_TLV_HEADER_LENGTH + length, ett_zbee_tlv, NULL, "TLV");
3053
3.74k
        offset = dissect_zbee_tlv(tvb, pinfo, subtree, offset, data, source_type, cmd_id);
3054
3.74k
    }
3055
3056
572
    recursion_depth = p_get_proto_depth(pinfo, proto_zbee_tlv);
3057
572
    p_set_proto_depth(pinfo, proto_zbee_tlv, recursion_depth - 1);
3058
3059
572
    return offset;
3060
617
} /* dissect_zbee_tlvs */
3061
3062
/**
3063
 * Dissector for ZBEE TLV.
3064
 *
3065
 * @param tvb pointer to buffer containing raw packet.
3066
 * @param pinfo pointer to packet information fields.
3067
 * @param tree pointer to data tree wireshark uses to display packet.
3068
 */
3069
static int
3070
dissect_zbee_tlv_default(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
3071
0
{
3072
0
  unsigned offset = 0;
3073
3074
0
  offset = dissect_zbee_tlvs(tvb, pinfo, tree, offset, data, ZBEE_TLV_SRC_TYPE_DEFAULT, 0);
3075
3076
  /* Check for leftover bytes. */
3077
0
  if (offset < tvb_captured_length(tvb)) {
3078
      /* Bytes leftover! */
3079
0
      tvbuff_t    *leftover_tvb   = tvb_new_subset_remaining(tvb, offset);
3080
      /* Dump the leftover to the data dissector. */
3081
0
      call_data_dissector(leftover_tvb, pinfo, tree);
3082
0
  }
3083
3084
0
  return tvb_captured_length(tvb);
3085
0
}
3086
3087
/**
3088
 * Proto ZBOSS Network Coprocessor product registration routine
3089
 */
3090
void proto_register_zbee_tlv(void)
3091
16
{
3092
    /* NCP protocol headers */
3093
16
    static hf_register_info hf[] = {
3094
16
        { &hf_zbee_tlv_relay_msg_type,
3095
16
        { "Type", "zbee_tlv.relay.type", FT_UINT8, BASE_HEX, VALS(zbee_aps_relay_tlvs), 0x0, NULL, HFILL }},
3096
3097
16
        { &hf_zbee_tlv_relay_msg_length,
3098
16
        { "Length", "zbee_tlv.relay.length", FT_UINT8, BASE_DEC, NULL, 0x0,  NULL, HFILL }},
3099
3100
16
        { &hf_zbee_tlv_relay_msg_joiner_ieee,
3101
16
        { "Joiner IEEE",        "zbee_tlv.relay.joiner_ieee", FT_EUI64, BASE_NONE, NULL, 0x0,
3102
16
            NULL, HFILL }},
3103
3104
16
        { &hf_zbee_tlv_global_type,
3105
16
          { "Type",        "zbee_tlv.type_global", FT_UINT8, BASE_HEX,
3106
16
            VALS(zbee_tlv_global_types), 0x0, NULL, HFILL }},
3107
3108
16
        { &hf_zbee_tlv_local_type_key_update_req_rsp,
3109
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3110
16
            VALS(zbee_tlv_local_types_key_update_req_rsp), 0x0, NULL, HFILL }},
3111
3112
16
        { &hf_zbee_tlv_local_type_key_negotiation_req_rsp,
3113
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3114
16
            VALS(zbee_tlv_local_types_key_negotiation_req_rsp), 0x0, NULL, HFILL }},
3115
3116
16
        { &hf_zbee_tlv_local_type_get_auth_level_rsp,
3117
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3118
16
            VALS(zbee_tlv_local_types_get_auth_level_rsp), 0x0, NULL, HFILL }},
3119
3120
16
        { &hf_zbee_tlv_local_type_clear_all_bindings_req,
3121
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3122
16
            VALS(zbee_tlv_local_types_clear_all_bindings_req), 0x0, NULL, HFILL }},
3123
3124
16
        { &hf_zbee_tlv_local_type_req_security_get_auth_token,
3125
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3126
16
            VALS(zbee_tlv_local_types_req_security_get_auth_token), 0x0, NULL, HFILL }},
3127
3128
16
        { &hf_zbee_tlv_local_type_req_security_get_auth_level,
3129
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3130
16
            VALS(zbee_tlv_local_types_req_security_get_auth_level), 0x0, NULL, HFILL }},
3131
3132
16
        { &hf_zbee_tlv_local_type_req_security_decommission,
3133
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3134
16
            VALS(zbee_tlv_local_types_req_security_decommission), 0x0, NULL, HFILL }},
3135
3136
16
        { &hf_zbee_tlv_local_type_req_beacon_survey,
3137
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3138
16
            VALS(zbee_tlv_local_types_req_beacon_survey), 0x0, NULL, HFILL }},
3139
3140
16
        { &hf_zbee_tlv_local_type_rsp_beacon_survey,
3141
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3142
16
            VALS(zbee_tlv_local_types_rsp_beacon_survey), 0x0, NULL, HFILL }},
3143
3144
16
        { &hf_zbee_tlv_local_type_req_challenge,
3145
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3146
16
            VALS(zbee_tlv_local_types_req_challenge), 0x0, NULL, HFILL }},
3147
3148
16
        { &hf_zbee_tlv_local_type_rsp_challenge,
3149
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3150
16
            VALS(zbee_tlv_local_types_rsp_challenge), 0x0, NULL, HFILL }},
3151
3152
16
        { &hf_zbee_tlv_local_type_rsp_set_configuration,
3153
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3154
16
            VALS(zbee_tlv_local_types_rsp_set_configuration), 0x0, NULL, HFILL }},
3155
3156
16
        { &hf_zbee_tlv_local_type_route_req,
3157
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3158
16
            VALS(zbee_tlv_local_types_route_req), 0x0, NULL, HFILL }},
3159
3160
16
        { &hf_zbee_tlv_local_type_route_reply,
3161
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3162
16
            VALS(zbee_tlv_local_types_route_reply), 0x0, NULL, HFILL }},
3163
3164
16
        { &hf_zbee_tlv_local_type_network_status,
3165
16
          { "Type",        "zbee_tlv.type_local", FT_UINT8, BASE_HEX,
3166
16
            VALS(zbee_tlv_local_types_network_status), 0x0, NULL, HFILL }},
3167
3168
16
        { &hf_zbee_tlv_type,
3169
16
          { "Unknown Type", "zbee_tlv.type", FT_UINT8, BASE_HEX,
3170
16
            NULL, 0x0, NULL, HFILL }},
3171
3172
16
        { &hf_zbee_tlv_length,
3173
16
          { "Length",      "zbee_tlv.length", FT_UINT8, BASE_DEC, NULL, 0x0,
3174
16
            NULL, HFILL }},
3175
3176
16
        { &hf_zbee_tlv_value,
3177
16
          { "Value",       "zbee_tlv.value", FT_BYTES, BASE_NONE, NULL, 0x0,
3178
16
            NULL, HFILL }},
3179
3180
16
        { &hf_zbee_tlv_count,
3181
16
          { "Count",       "zbee_tlv.count", FT_UINT8, BASE_DEC, NULL, 0x0,
3182
16
            NULL, HFILL }},
3183
3184
16
        { &hf_zbee_tlv_local_status_count,
3185
16
            { "TLV Status Count",           "zbee_tlv.tlv_status_count", FT_UINT8, BASE_DEC, NULL, 0x0,
3186
16
            NULL, HFILL }},
3187
3188
16
        { &hf_zbee_tlv_local_type_id,
3189
16
            { "TLV Type ID",                "zbee_tlv.tlv_type_id", FT_UINT8, BASE_HEX, VALS(zbee_tlv_global_types), 0x0,
3190
16
            NULL, HFILL }},
3191
3192
16
        { &hf_zbee_tlv_local_proc_status,
3193
16
            { "TLV Processing Status",      "zbee_tlv.tlv_proc_status", FT_UINT8, BASE_HEX, NULL, 0x0,
3194
16
            NULL, HFILL }},
3195
3196
16
        { &hf_zbee_tlv_manufacturer_specific,
3197
16
          { "ZigBee Manufacturer ID", "zbee_tlv.manufacturer_specific", FT_UINT16, BASE_HEX, NULL,
3198
16
            0x0, NULL, HFILL }},
3199
3200
16
        { &hf_zbee_tlv_supported_key_negotiation_methods,
3201
16
          { "Supported Key Negotiation Methods", "zbee_tlv.supported_key_negotiation_methods", FT_UINT8, BASE_HEX, NULL,
3202
16
            0x0, NULL, HFILL }},
3203
3204
16
        { &hf_zbee_tlv_supported_key_negotiation_methods_key_request,
3205
16
          { "Key Request (ZigBee 3.0)",             "zbee_tlv.supported_key_negotiation_methods.key_request", FT_BOOLEAN, 8, NULL,
3206
16
            ZBEE_TLV_SUPPORTED_KEY_NEGOTIATION_METHODS_KEY_REQUEST, NULL, HFILL }},
3207
3208
16
        { &hf_zbee_tlv_supported_key_negotiation_methods_ecdhe_using_curve25519_aes_mmo128,
3209
16
          { "ECDHE using Curve25519 with Hash AES-MMO-128", "zbee_tlv.supported_key_negotiation_methods.ecdhe_using_curve25519_aes_mmo128", FT_BOOLEAN, 8, NULL,
3210
16
            ZBEE_TLV_SUPPORTED_KEY_NEGOTIATION_METHODS_ANONYMOUS_ECDHE_USING_CURVE25519_AES_MMO128, NULL, HFILL }},
3211
3212
16
        { &hf_zbee_tlv_supported_key_negotiation_methods_ecdhe_using_curve25519_sha256,
3213
16
          { "ECDHE using Curve25519 with Hash SHA-256", "zbee_tlv.supported_key_negotiation_methods.ecdhe_using_curve25519_sha256", FT_BOOLEAN, 8, NULL,
3214
16
            ZBEE_TLV_SUPPORTED_KEY_NEGOTIATION_METHODS_ANONYMOUS_ECDHE_USING_CURVE25519_SHA256, NULL, HFILL }},
3215
3216
16
        { &hf_zbee_tlv_supported_secrets,
3217
16
          { "Supported Pre-shared Secrets Bitmask", "zbee_tlv.supported_secrets", FT_UINT8, BASE_HEX, NULL,
3218
16
            0x0, NULL, HFILL }},
3219
3220
16
        { &hf_zbee_tlv_supported_preshared_secrets_auth_token,
3221
16
          { "Symmetric Authentication Token", "zbee_tlv.supported_secrets.auth_token", FT_BOOLEAN, 8, NULL,
3222
16
            0x1, NULL, HFILL }},
3223
3224
16
        { &hf_zbee_tlv_supported_preshared_secrets_ic,
3225
16
          { "128-bit pre-configured link-key from install code", "zbee_tlv.supported_secrets.ic", FT_BOOLEAN, 8, NULL,
3226
16
            0x2, NULL, HFILL }},
3227
3228
16
        { &hf_zbee_tlv_supported_preshared_secrets_passcode_pake,
3229
16
          { "Variable-length pass code for PAKE protocols", "zbee_tlv.supported_secrets.passcode_pake", FT_BOOLEAN, 8, NULL,
3230
16
            0x4, NULL, HFILL }},
3231
3232
16
        { &hf_zbee_tlv_supported_preshared_secrets_basic_access_key,
3233
16
          { "Basic Access Key", "zbee_tlv.supported_secrets.basic_key", FT_BOOLEAN, 8, NULL,
3234
16
            0x8, NULL, HFILL }},
3235
3236
16
        { &hf_zbee_tlv_supported_preshared_secrets_admin_access_key,
3237
16
          { "Administrative Access Key", "zbee_tlv.supported_secrets.admin_key", FT_BOOLEAN, 8, NULL,
3238
16
            0x10, NULL, HFILL }},
3239
3240
16
        { &hf_zbee_tlv_panid_conflict_cnt,
3241
16
          { "PAN ID Conflict Count", "zbee_tlv.panid_conflict_cnt", FT_UINT16, BASE_DEC, NULL,
3242
16
            0x0, NULL, HFILL }},
3243
3244
16
        { &hf_zbee_tlv_next_pan_id,
3245
16
          { "Next PAN ID Change", "zbee_tlv.next_pan_id", FT_UINT16, BASE_HEX, NULL,
3246
16
            0x0, NULL, HFILL }},
3247
3248
16
        { &hf_zbee_tlv_next_channel_change,
3249
16
          { "Next Channel Change", "zbee_tlv.next_channel", FT_UINT32, BASE_HEX, NULL,
3250
16
            0x0, NULL, HFILL }},
3251
3252
16
        { &hf_zbee_tlv_passphrase,
3253
16
          { "128-bit Symmetric Passphrase", "zbee_tlv.passphrase", FT_BYTES, BASE_NONE, NULL,
3254
16
            0x0, NULL, HFILL }},
3255
3256
16
        { &hf_zbee_tlv_challenge_value,
3257
16
          { "Challenge Value", "zbee_tlv.challenge_val", FT_BYTES, BASE_NONE, NULL,
3258
16
            0x0, NULL, HFILL }},
3259
3260
16
        { &hf_zbee_tlv_aps_frame_counter,
3261
16
          { "APS Frame Counter", "zbee_tlv.aps_frame_cnt", FT_UINT32, BASE_HEX, NULL,
3262
16
            0x0, NULL, HFILL }},
3263
3264
16
        { &hf_zbee_tlv_challenge_counter,
3265
16
          { "Challenge Counter", "zbee_tlv.challenge_cnt", FT_UINT32, BASE_HEX, NULL,
3266
16
            0x0, NULL, HFILL }},
3267
3268
16
        { &hf_zbee_tlv_configuration_param,
3269
16
          { "Configuration Parameters", "zbee_tlv.configuration_parameters", FT_UINT16, BASE_HEX, NULL,
3270
16
            0x0, NULL, HFILL }},
3271
3272
16
        { &hf_zbee_tlv_configuration_param_restricted_mode,
3273
16
          { "apsZdoRestrictedMode", "zbee_tlv.conf_param.restricted_mode", FT_UINT16, BASE_DEC, NULL,
3274
16
            0x1, NULL, HFILL }},
3275
3276
16
        { &hf_zbee_tlv_configuration_param_link_key_enc,
3277
16
          { "requireLinkKeyEncryptionForApsTransportKey", "zbee_tlv.conf_param.req_link_key_enc", FT_UINT16, BASE_DEC, NULL,
3278
16
            0x2, NULL, HFILL }},
3279
3280
16
        { &hf_zbee_tlv_configuration_param_leave_req_allowed,
3281
16
          { "nwkLeaveRequestAllowed", "zbee_tlv.conf_param.leave_req_allowed", FT_UINT16, BASE_DEC, NULL,
3282
16
            0x4, NULL, HFILL }},
3283
3284
16
        { &hf_zbee_tlv_dev_cap_ext_capability_information,
3285
16
          { "Capability Information", "zbee_tlv.dev_cap_ext_cap_info", FT_UINT16, BASE_HEX, NULL,
3286
16
            0x0, NULL, HFILL }},
3287
3288
16
        { &hf_zbee_tlv_dev_cap_ext_zbdirect_virt_device,
3289
16
          { "Zigbee Direct Virtual Device", "zbee_tlv.dev_cap_ext.zbdirect_virt_dev", FT_UINT16, BASE_DEC, NULL,
3290
16
            0x1, NULL, HFILL }},
3291
3292
16
        { &hf_zbee_tlv_lqa,
3293
16
          { "LQA", "zbee_tlv.lqa", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3294
3295
16
        { &hf_zbee_tlv_router_information,
3296
16
          { "Router Information", "zbee_tlv.router_information", FT_UINT16, BASE_HEX, NULL,
3297
16
            0x0, NULL, HFILL }},
3298
3299
16
        { &hf_zbee_tlv_router_information_hub_connectivity,
3300
16
          { "Hub Connectivity",   "zbee_tlv.router_information.hub_connectivity", FT_BOOLEAN, 16, NULL,
3301
16
              ZBEE_TLV_ROUTER_INFORMATION_HUB_CONNECTIVITY, NULL, HFILL }},
3302
3303
16
        { &hf_zbee_tlv_router_information_uptime,
3304
16
          { "Uptime",             "zbee_tlv.router_information.uptime", FT_BOOLEAN, 16, NULL,
3305
16
              ZBEE_TLV_ROUTER_INFORMATION_UPTIME, NULL, HFILL }},
3306
3307
16
        { &hf_zbee_tlv_router_information_pref_parent,
3308
16
          { "Preferred parent",        "zbee_tlv.router_information.pref_parent", FT_BOOLEAN, 16, NULL,
3309
16
              ZBEE_TLV_ROUTER_INFORMATION_PREF_PARENT, NULL, HFILL }},
3310
3311
16
        { &hf_zbee_tlv_router_information_battery_backup,
3312
16
          { "Battery Backup",     "zbee_tlv.router_information.battery", FT_BOOLEAN, 16, NULL,
3313
16
              ZBEE_TLV_ROUTER_INFORMATION_BATTERY_BACKUP, NULL, HFILL }},
3314
3315
16
        { &hf_zbee_tlv_router_information_enhanced_beacon_request_support,
3316
16
          { "Enhanced Beacon Request Support", "zbee_tlv.router_information.enhanced_beacon", FT_BOOLEAN, 16, NULL,
3317
16
              ZBEE_TLV_ROUTER_INFORMATION_ENHANCED_BEACON_REQUEST_SUPPORT, NULL, HFILL }},
3318
3319
16
        { &hf_zbee_tlv_router_information_mac_data_poll_keepalive_support,
3320
16
          { "MAC Data Poll Keepalive Support", "zbee_tlv.router_information.mac_data_poll_keepalive", FT_BOOLEAN, 16, NULL,
3321
16
              ZBEE_TLV_ROUTER_INFORMATION_MAC_DATA_POLL_KEEPALIVE_SUPPORT, NULL, HFILL }},
3322
3323
16
        { &hf_zbee_tlv_router_information_end_device_keepalive_support,
3324
16
          { "End Device Keepalive Support", "zbee_tlv.router_information.end_dev_keepalive", FT_BOOLEAN, 16, NULL,
3325
16
              ZBEE_TLV_ROUTER_INFORMATION_END_DEVICE_KEEPALIVE_SUPPORT, NULL, HFILL }},
3326
3327
16
        { &hf_zbee_tlv_router_information_power_negotiation_support,
3328
16
          { "Power Negotiation Support", "zbee_tlv.router_information.power_negotiation", FT_BOOLEAN, 16, NULL,
3329
16
              ZBEE_TLV_ROUTER_INFORMATION_POWER_NEGOTIATION_SUPPORT, NULL, HFILL }},
3330
3331
16
        { &hf_zbee_tlv_node_id,
3332
16
          { "Node ID", "zbee_tlv.node_id", FT_UINT16, BASE_HEX, NULL,
3333
16
            0x0, NULL, HFILL }},
3334
3335
16
        { &hf_zbee_tlv_frag_opt,
3336
16
          { "Fragmentation Options", "zbee_tlv.frag_opt", FT_UINT8, BASE_HEX, NULL,
3337
16
            0x0, NULL, HFILL }},
3338
3339
16
        { &hf_zbee_tlv_max_reassembled_buf_size,
3340
16
          { "Maximum Reassembled Input Buffer Size", "zbee_tlv.max_buf_size", FT_UINT16, BASE_HEX, NULL,
3341
16
            0x0, NULL, HFILL }},
3342
3343
16
        { &hf_zbee_tlv_selected_key_negotiation_method,
3344
16
          { "Selected Key Negotiation Method", "zbee_tlv.selected_key_negotiation_method", FT_UINT8, BASE_HEX,
3345
16
            VALS(zbee_tlv_selected_key_negotiation_method), 0x0, NULL, HFILL }},
3346
3347
16
        { &hf_zbee_tlv_selected_pre_shared_secret,
3348
16
          { "Selected Pre Shared Secret", "zbee_tlv.selected_pre_shared_secret", FT_UINT8, BASE_HEX,
3349
16
            VALS(zbee_tlv_selected_pre_shared_secret), 0x0, NULL, HFILL }},
3350
3351
16
        { &hf_zbee_tlv_device_eui64,
3352
16
          { "Device EUI64", "zbee_tlv.device_eui64", FT_EUI64, BASE_NONE, NULL, 0x0,
3353
16
            NULL, HFILL }},
3354
3355
16
        { &hf_zbee_tlv_public_point,
3356
16
          { "Public Point", "zbee_tlv.public_point", FT_BYTES, BASE_NONE, NULL,
3357
16
            0x0, NULL, HFILL }},
3358
3359
16
        { &hf_zbee_tlv_global_tlv_id,
3360
16
          { "TLV Type ID", "zbee_tlv.global_tlv_id", FT_UINT8, BASE_HEX, VALS(zbee_tlv_global_types), 0x0,
3361
16
            NULL, HFILL }},
3362
3363
16
        { &hf_zbee_tlv_local_ieee_addr,
3364
16
          { "IEEE Addr", "zbee_tlv.ieee_addr", FT_EUI64, BASE_NONE, NULL, 0x0,
3365
16
            NULL, HFILL }},
3366
3367
16
        { &hf_zbee_tlv_routing_sequence_number,
3368
16
          { "Routing Sequence Number", "zbee_tlv.route_seq_num", FT_UINT16, BASE_HEX, NULL, 0x0,
3369
16
            NULL, HFILL }},
3370
3371
16
        { &hf_zbee_tlv_initial_radius,
3372
16
          { "Initial Radius", "zbee_tlv.initial_radius", FT_UINT8, BASE_HEX, NULL, 0x0,
3373
16
            NULL, HFILL }},
3374
3375
16
        { &hf_zbee_tlv_concentrator_discovery_time,
3376
16
          { "Concentrator Discovery Timer", "zbee_tlv.concentrator_discovery_time", FT_UINT8, BASE_HEX, NULL, 0x0,
3377
16
            NULL, HFILL }},
3378
3379
16
        { &hf_zbee_tlv_max_source_route_length,
3380
16
          { "Max Source Route Length", "zbee_tlv.max_source_route_length", FT_UINT8, BASE_HEX, NULL, 0x0,
3381
16
            NULL, HFILL }},
3382
3383
16
        { &hf_zbee_tlv_nwk_addr_of_interest,
3384
16
          { "Network Address of Interest", "zbee_tlv.nwk_addr_of_interest", FT_UINT16, BASE_HEX, NULL, 0x0,
3385
16
            NULL, HFILL }},
3386
3387
16
        { &hf_zbee_tlv_mic64,
3388
16
          { "MIC", "zbee_tlv.mic64", FT_UINT64, BASE_HEX, NULL, 0x0,
3389
16
            NULL, HFILL }},
3390
3391
16
        { &hf_zbee_tlv_local_initial_join_method,
3392
16
          { "Initial Join Method",        "zbee_tlv.init_method", FT_UINT8, BASE_HEX,
3393
16
            VALS(zbee_initial_join_methods), 0x0, NULL, HFILL }},
3394
3395
16
        { &hf_zbee_tlv_local_active_lk_type,
3396
16
          { "Active link key type",        "zbee_tlv.lk_type", FT_UINT8, BASE_HEX,
3397
16
            VALS(zbee_active_lk_types), 0x0, NULL, HFILL }},
3398
3399
16
        { &hf_zbee_tlv_zbd_comm_tlv,
3400
16
            { "ZBD Commissioning Service TLV Type ID", "zbee_tlv.zbd.comm_tlv_id", FT_UINT8, BASE_HEX,
3401
16
              VALS(zbee_tlv_zbd_comm_types), 0x0, NULL, HFILL }},
3402
3403
16
        { &hf_zbee_tlv_zbd_comm_mj_cmd_tlv,
3404
16
            { "ZBD Manage Joiners TLV Type ID", "zbee_tlv.zbd.comm_mj_tlv_id", FT_UINT8, BASE_HEX,
3405
16
              VALS(zbee_tlv_zbd_comm_mj_types), 0x0, NULL, HFILL }},
3406
3407
16
        { &hf_zbee_tlv_zbd_secur_tlv,
3408
16
            { "ZBD Secure Session TLV Type ID", "zbee_tlv.zbd.secur_tlv_id", FT_UINT8, BASE_HEX,
3409
16
              VALS(zbee_tlv_zbd_secur_types), 0x0, NULL, HFILL }},
3410
3411
16
        { &hf_zbee_tlv_local_tunneling_npdu,
3412
16
            { "NPDU", "zbee_tlv.zbd.npdu", FT_NONE, BASE_NONE,
3413
16
                NULL, 0x0, NULL, HFILL }
3414
16
        },
3415
16
        { &hf_zbee_tlv_zbd_tunneling_npdu_msg_tlv,
3416
16
            { "NPDU Message TLV", "zbee_tlv.zbd.tlv.tunneling.npdu_msg", FT_NONE, BASE_NONE,
3417
16
                NULL, 0x0, NULL, HFILL }
3418
16
        },
3419
16
        { &hf_zbee_tlv_local_comm_ext_pan_id,
3420
16
            { "Extended PAN ID", "zbee_tlv.zbd.comm.ext_pan_id", FT_UINT64, BASE_HEX,
3421
16
                NULL, 0x0, NULL, HFILL }
3422
16
        },
3423
16
        { &hf_zbee_tlv_local_comm_short_pan_id,
3424
16
            { "Short PAN ID", "zbee_tlv.zbd.comm.short_pan_id", FT_UINT16, BASE_HEX,
3425
16
                NULL, 0x0, NULL, HFILL }
3426
16
        },
3427
16
        { &hf_zbee_tlv_local_comm_channel_mask,
3428
16
            { "Network Channels", "zbee_tlv.zbd.comm.nwk_channel_mask", FT_UINT32, BASE_HEX,
3429
16
                NULL, 0x0, NULL, HFILL }
3430
16
        },
3431
16
        { &hf_zbee_tlv_local_comm_channel_page,
3432
16
            { "Channel Page", "zbee_tlv.zbd.comm.nwk_channel_page", FT_UINT8, BASE_DEC,
3433
16
                NULL, 0x0, NULL, HFILL }
3434
16
        },
3435
16
        { &hf_zbee_tlv_local_comm_channel_page_count,
3436
16
            { "Channel Page Count", "zbee_tlv.zbd.comm.nwk_channel_page_count", FT_UINT8, BASE_DEC,
3437
16
                NULL, 0x0, NULL, HFILL }
3438
16
        },
3439
16
        { &hf_zbee_tlv_local_comm_nwk_key,
3440
16
            { "Network key", "zbee_tlv.zbd.comm.nwk_key", FT_BYTES, BASE_NONE,
3441
16
                NULL, 0x0, NULL, HFILL }
3442
16
        },
3443
16
        { &hf_zbee_tlv_local_comm_link_key,
3444
16
            { "Link key", "zbee_tlv.zbd.comm.link_key", FT_BYTES, BASE_NONE,
3445
16
                NULL, 0x0, NULL, HFILL }
3446
16
        },
3447
16
        { &hf_zbee_tlv_local_comm_dev_type,
3448
16
            { "Device type", "zbee_tlv.zbd.comm.dev_type", FT_UINT8, BASE_HEX,
3449
16
                VALS(zbee_tlv_local_types_dev_type_str), 0x0, NULL, HFILL }
3450
16
        },
3451
16
        { &hf_zbee_tlv_local_comm_nwk_addr,
3452
16
            { "Network address", "zbee_tlv.zbd.comm.nwk_addr", FT_UINT16, BASE_HEX,
3453
16
                NULL, 0x0, NULL, HFILL }
3454
16
        },
3455
16
        { &hf_zbee_tlv_local_comm_join_method,
3456
16
            { "Join method", "zbee_tlv.zbd.comm.join_method", FT_UINT8, BASE_HEX,
3457
16
                VALS(zbee_tlv_local_types_join_method_str), 0x0, NULL, HFILL }
3458
16
        },
3459
16
        { &hf_zbee_tlv_local_comm_tc_addr,
3460
16
            { "TC address", "zbee_tlv.zbd.comm.tc_addr", FT_UINT64, BASE_HEX,
3461
16
                NULL, 0x0, NULL, HFILL }
3462
16
        },
3463
16
        { &hf_zbee_tlv_local_comm_nwk_upd_id,
3464
16
            { "Network update ID", "zbee_tlv.zbd.comm.nwk_upd_id", FT_UINT8, BASE_HEX,
3465
16
                NULL, 0x0, NULL, HFILL }
3466
16
        },
3467
16
        { &hf_zbee_tlv_local_comm_key_seq_num,
3468
16
            { "Network active key sequence number", "zbee_tlv.zbd.comm.nwk_key_seq_num", FT_UINT8, BASE_HEX,
3469
16
                NULL, 0x0, NULL, HFILL }
3470
16
        },
3471
16
        { &hf_zbee_tlv_local_comm_adm_key,
3472
16
            { "Admin key", "zbee_tlv.zbd.comm.admin_key", FT_BYTES, BASE_NONE,
3473
16
                NULL, 0x0, NULL, HFILL }
3474
16
        },
3475
16
        { &hf_zbee_tlv_local_comm_status_code_domain,
3476
16
            { "Domain", "zbee_tlv.zbd.comm.status_code_domain", FT_UINT8, BASE_HEX,
3477
16
                VALS(zbee_tlv_local_types_status_code_domain_str), 0x0, NULL, HFILL }
3478
16
        },
3479
16
        { &hf_zbee_tlv_local_comm_status_code_value,
3480
16
            { "Code", "zbee_tlv.zbd.comm.status_code_value", FT_UINT8, BASE_HEX,
3481
16
                NULL, 0x0, NULL, HFILL }
3482
16
        },
3483
16
        { &hf_zbee_tlv_local_comm_mj_prov_lnk_key,
3484
16
            { "Manage Joiners Provisional Link key", "zbee_tlv.zbd.comm.manage_joiners_prov_lnk_key", FT_BYTES, BASE_NONE,
3485
16
                NULL, 0x0, NULL, HFILL }
3486
16
        },
3487
16
        { &hf_zbee_tlv_local_comm_mj_ieee_addr,
3488
16
            { "Manage Joiners IEEE Address", "zbee_tlv.zbd.comm.manage_joiners_ieee_addr", FT_UINT64, BASE_HEX,
3489
16
                NULL, 0x0, NULL, HFILL }
3490
16
        },
3491
16
        { &hf_zbee_tlv_local_comm_mj_cmd,
3492
16
            { "Manage Joiners command", "zbee_tlv.zbd.comm.manage_joiners_cmd", FT_UINT8, BASE_HEX,
3493
16
                VALS(zbee_tlv_local_types_mj_cmd_str), 0x0, NULL, HFILL }
3494
16
        },
3495
16
        { &hf_zbee_tlv_local_tunneling_npdu_flags,
3496
16
            { "NPDU Flags", "zbee_tlv.zbd.tunneling.npdu_flags", FT_UINT8, BASE_HEX,
3497
16
                NULL, 0x0, NULL, HFILL }
3498
16
        },
3499
16
        { &hf_zbee_tlv_local_tunneling_npdu_flags_security,
3500
16
            { "Security Enabled", "zbee_tlv.zbd.tunneling.npdu_flags.security", FT_BOOLEAN, 8,
3501
16
                NULL, 0b00000001, NULL, HFILL }
3502
16
        },
3503
16
        { &hf_zbee_tlv_local_tunneling_npdu_flags_reserved,
3504
16
            { "Reserved", "zbee_tlv.zbd.tunneling.npdu_flags.reserved", FT_UINT8, BASE_DEC,
3505
16
                NULL, 0b11111110, NULL, HFILL }
3506
16
        },
3507
16
        { &hf_zbee_tlv_local_tunneling_npdu_length,
3508
16
            { "NPDU Length", "zbee_tlv.zbd.tunneling.npdu_length", FT_UINT8, BASE_DEC,
3509
16
                NULL, 0x0, NULL, HFILL }
3510
16
        },
3511
16
        { &hf_zbee_tlv_local_selected_key_method,
3512
16
            { "Selected Key Negotiation Method", "zbee_tlv.zbd.secur.key_method", FT_UINT8, BASE_HEX,
3513
16
                VALS(zbee_tlv_local_types_key_method_str), 0x0, NULL, HFILL }
3514
16
        },
3515
16
        { &hf_zbee_tlv_local_selected_psk_secret,
3516
16
            { "Selected PSK Secret", "zbee_tlv.zbd.secur.psk_secret", FT_UINT8, BASE_HEX,
3517
16
                VALS(zbee_tlv_local_types_psk_secret_str), 0x0, NULL, HFILL }
3518
16
        },
3519
16
        { &hf_zbee_tlv_local_nwk_key_seq_num,
3520
16
            { "Network Key Sequence Number", "zbee_tlv.zbd.secur.nwk_key_seq_num", FT_UINT8, BASE_DEC,
3521
16
                NULL, 0x0, NULL, HFILL }
3522
16
        },
3523
16
        { &hf_zbee_tlv_local_mac_tag,
3524
16
            { "MAC Tag", "zbee_tlv.zbd.secur.mac_tag", FT_BYTES, BASE_NONE,
3525
16
                NULL, 0x0, NULL, HFILL }
3526
16
        },
3527
16
        { &hf_zbee_tlv_local_comm_link_key_flags,
3528
16
            { "Link Key", "zbee_tlv.zbd.comm.join.link_key", FT_UINT8, BASE_HEX,
3529
16
                NULL, 0x0, NULL, HFILL }
3530
16
        },
3531
16
        { &hf_zbee_tlv_local_comm_link_key_flags_unique,
3532
16
            { "Unique", "zbee_tlv.zbd.comm.join.link_key.unique", FT_UINT8, BASE_DEC,
3533
16
                VALS(zbee_tlv_local_types_lnk_key_unique_str), ZBEE_TLV_LINK_KEY_UNIQUE, NULL, HFILL }
3534
16
        },
3535
16
        { &hf_zbee_tlv_local_comm_link_key_flags_provisional,
3536
16
            { "Provisional", "zbee_tlv.zbd.comm.join.link_key.provisional", FT_UINT8, BASE_DEC,
3537
16
                VALS(zbee_tlv_local_types_lnk_key_provisional_str), ZBEE_TLV_LINK_KEY_PROVISIONAL, NULL, HFILL }
3538
16
        },
3539
16
        { &hf_zbee_tlv_local_type_lk_features,
3540
16
            { "Features", "zbee_tlv.lk_features", FT_UINT8, BASE_HEX,
3541
16
                NULL, 0x0, NULL, HFILL }
3542
16
        },
3543
16
        { &hf_zbee_tlv_local_type_lk_features_capabilities,
3544
16
            { "Link-Key Features & Capabilities TLV", "zbee_tlv.lk_features_capabilities", FT_UINT8, BASE_HEX,
3545
16
                NULL, 0x0, NULL, HFILL }
3546
16
        },
3547
16
        { &hf_zbee_tlv_local_type_lk_features_capabilities_aps_fc_sync,
3548
16
            { "Frame Counter Synchronization Support", "zbee_tlv.lk_features_capabilities.aps_fc_sync", FT_BOOLEAN, 8,
3549
16
                NULL, ZBEE_TLV_LK_FEATURES_CAPABILITIES_FC_SYNC_SUPPORTED, NULL, HFILL }
3550
16
        },
3551
16
        { &hf_zbee_tlv_local_comm_network_status_map,
3552
16
            { "Network Status Map", "zbee_tlv.zbd.comm.status_map", FT_UINT8, BASE_HEX,
3553
16
                NULL, 0x0, NULL, HFILL }
3554
16
        },
3555
16
        { &hf_zbee_tlv_local_comm_network_status_map_joined_status,
3556
16
            { "Joined", "zbee_tlv.zbd.comm.status_map.joined_status", FT_UINT8, BASE_HEX,
3557
16
                VALS(zbee_tlv_local_types_joined_status_str), ZBEE_TLV_STATUS_MAP_JOINED_STATUS, NULL, HFILL }
3558
16
        },
3559
16
        { &hf_zbee_tlv_local_comm_network_status_map_open_status,
3560
16
            { "Open/Closed", "zbee_tlv.zbd.comm.status_map.open_status", FT_UINT8, BASE_DEC,
3561
16
                VALS(zbee_tlv_local_types_nwk_state_str), ZBEE_TLV_STATUS_MAP_OPEN_STATUS, NULL, HFILL }
3562
16
        },
3563
16
        { &hf_zbee_tlv_network_status_map_network_type,
3564
16
            { "Network Type", "zbee_tlv.zbd.comm.status_map.network_type", FT_UINT8, BASE_DEC,
3565
16
                VALS(zbee_tlv_local_types_nwk_type_str), ZBEE_TLV_STATUS_MAP_NETWORK_TYPE, NULL, HFILL }
3566
16
        },
3567
16
    };
3568
3569
    /* Protocol subtrees */
3570
16
    static int *ett[] =
3571
16
        {
3572
16
            &ett_zbee_aps_tlv,
3573
16
            &ett_zbee_aps_relay,
3574
16
            &ett_zbee_tlv,
3575
16
            &ett_zbee_tlv_supported_key_negotiation_methods,
3576
16
            &ett_zbee_tlv_supported_secrets,
3577
16
            &ett_zbee_tlv_router_information,
3578
16
            &ett_zbee_tlv_configuration_param,
3579
16
            &ett_zbee_tlv_capability_information,
3580
16
            &ett_zbee_tlv_zbd_tunneling_npdu,
3581
16
            &ett_zbee_tlv_zbd_tunneling_npdu_flags,
3582
16
            &ett_zbee_tlv_link_key_flags,
3583
16
            &ett_zbee_tlv_lk_features_capabilities,
3584
16
            &ett_zbee_tlv_network_status_map
3585
16
        };
3586
3587
16
    static ei_register_info ei[] = {
3588
16
        { &ei_zbee_tlv_max_recursion_depth_reached, { "zbee_tlv.max_recursion_depth_reached",
3589
16
            PI_PROTOCOL, PI_WARN, "Maximum allowed recursion depth reached - stop decoding", EXPFILL }}
3590
16
    };
3591
3592
16
    proto_zbee_tlv = proto_register_protocol("Zigbee TLV", "ZB TLV", "zbee_tlv");
3593
3594
16
    proto_register_field_array(proto_zbee_tlv, hf, array_length(hf));
3595
16
    proto_register_subtree_array(ett, array_length(ett));
3596
3597
16
    expert_module_t* expert_zbee_tlv = expert_register_protocol(proto_zbee_tlv);
3598
16
    expert_register_field_array(expert_zbee_tlv, ei, array_length(ei));
3599
3600
16
    register_dissector("zbee_tlv", dissect_zbee_tlv_default, proto_zbee_tlv);
3601
16
    zbee_nwk_handle = find_dissector("zbee_nwk");
3602
16
} /* proto_register_zbee_tlv */
3603
3604
void proto_reg_handoff_zbee_tlv(void)
3605
16
{
3606
16
    proto_zbee_nwk = proto_get_id_by_filter_name(ZBEE_PROTOABBREV_NWK);
3607
16
}