2 * Dissector routines for the ZigBee Network Layer (NWK)
3 * By Owen Kirby <osk@exegin.com>
4 * Copyright 2009 Exegin Technologies Limited
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #endif /* HAVEHCONFIG_H */
36 #include <epan/proto.h>
37 #include <epan/packet.h>
38 #include <epan/prefs.h>
39 #include <epan/addr_resolv.h>
40 #include <epan/expert.h>
41 #include <epan/value_string.h>
43 #include "packet-zbee.h"
44 #include "packet-zbee-security.h"
45 #include "packet-zbee-nwk.h"
47 /*************************/
48 /* Function Declarations */
49 /*************************/
50 /* Dissector Routines */
51 static void dissect_zbee_nwk (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
52 static void dissect_zbee_nwk_cmd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
53 static void dissect_zbee_beacon (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
55 /* Command Dissector Helpers */
56 static guint dissect_zbee_nwk_route_req (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet * packet, guint offset);
57 static guint dissect_zbee_nwk_route_rep (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
58 static guint dissect_zbee_nwk_status (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
59 static guint dissect_zbee_nwk_leave (tvbuff_t *tvb, proto_tree *tree, guint offset);
60 static guint dissect_zbee_nwk_route_rec (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet * packet, guint offset);
61 static guint dissect_zbee_nwk_rejoin_req (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet * packet, guint offset);
62 static guint dissect_zbee_nwk_rejoin_resp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet * packet, guint offset);
63 static guint dissect_zbee_nwk_link_status(tvbuff_t *tvb, proto_tree *tree, guint offset);
64 static guint dissect_zbee_nwk_report (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
65 static guint dissect_zbee_nwk_update (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset);
68 /********************/
69 /* Global Variables */
70 /********************/
71 static int proto_zbee_nwk = -1;
72 static int hf_zbee_nwk_frame_type = -1;
73 static int hf_zbee_nwk_proto_version = -1;
74 static int hf_zbee_nwk_discover_route = -1;
75 static int hf_zbee_nwk_multicast = -1;
76 static int hf_zbee_nwk_security = -1;
77 static int hf_zbee_nwk_source_route = -1;
78 static int hf_zbee_nwk_ext_dst = -1;
79 static int hf_zbee_nwk_ext_src = -1;
80 static int hf_zbee_nwk_dst = -1;
81 static int hf_zbee_nwk_src = -1;
82 static int hf_zbee_nwk_radius = -1;
83 static int hf_zbee_nwk_seqno = -1;
84 static int hf_zbee_nwk_mcast_mode = -1;
85 static int hf_zbee_nwk_mcast_radius = -1;
86 static int hf_zbee_nwk_mcast_max_radius = -1;
87 static int hf_zbee_nwk_dst64 = -1;
88 static int hf_zbee_nwk_src64 = -1;
89 static int hf_zbee_nwk_relay_count = -1;
90 static int hf_zbee_nwk_relay_index = -1;
92 static int hf_zbee_nwk_cmd_id = -1;
93 static int hf_zbee_nwk_cmd_addr = -1;
94 static int hf_zbee_nwk_cmd_route_id = -1;
95 static int hf_zbee_nwk_cmd_route_dest = -1;
96 static int hf_zbee_nwk_cmd_route_orig = -1;
97 static int hf_zbee_nwk_cmd_route_resp = -1;
98 static int hf_zbee_nwk_cmd_route_dest_ext = -1;
99 static int hf_zbee_nwk_cmd_route_orig_ext = -1;
100 static int hf_zbee_nwk_cmd_route_resp_ext = -1;
101 static int hf_zbee_nwk_cmd_route_cost = -1;
102 static int hf_zbee_nwk_cmd_route_opt_repair = -1;
103 static int hf_zbee_nwk_cmd_route_opt_multicast = -1;
104 static int hf_zbee_nwk_cmd_route_opt_dest_ext = -1;
105 static int hf_zbee_nwk_cmd_route_opt_resp_ext = -1;
106 static int hf_zbee_nwk_cmd_route_opt_orig_ext = -1;
107 static int hf_zbee_nwk_cmd_route_opt_many_to_one = -1;
108 static int hf_zbee_nwk_cmd_nwk_status = -1;
109 static int hf_zbee_nwk_cmd_leave_rejoin = -1;
110 static int hf_zbee_nwk_cmd_leave_request = -1;
111 static int hf_zbee_nwk_cmd_leave_children = -1;
112 static int hf_zbee_nwk_cmd_relay_count = -1;
113 static int hf_zbee_nwk_cmd_cinfo_alt_coord = -1;
114 static int hf_zbee_nwk_cmd_cinfo_type = -1;
115 static int hf_zbee_nwk_cmd_cinfo_power = -1;
116 static int hf_zbee_nwk_cmd_cinfo_idle_rx = -1;
117 static int hf_zbee_nwk_cmd_cinfo_security = -1;
118 static int hf_zbee_nwk_cmd_cinfo_alloc = -1;
119 static int hf_zbee_nwk_cmd_rejoin_status = -1;
120 static int hf_zbee_nwk_cmd_link_last = -1;
121 static int hf_zbee_nwk_cmd_link_first = -1;
122 static int hf_zbee_nwk_cmd_link_count = -1;
123 static int hf_zbee_nwk_cmd_report_type = -1;
124 static int hf_zbee_nwk_cmd_report_count = -1;
125 static int hf_zbee_nwk_cmd_update_type = -1;
126 static int hf_zbee_nwk_cmd_update_count = -1;
127 static int hf_zbee_nwk_cmd_update_id = -1;
128 static int hf_zbee_nwk_cmd_epid = -1;
131 static int hf_zbee_beacon_protocol = -1;
132 static int hf_zbee_beacon_stack_profile = -1;
133 static int hf_zbee_beacon_version = -1;
134 static int hf_zbee_beacon_router_capacity = -1;
135 static int hf_zbee_beacon_depth = -1;
136 static int hf_zbee_beacon_end_device_capacity = -1;
137 static int hf_zbee_beacon_epid = -1;
138 static int hf_zbee_beacon_tx_offset = -1;
139 static int hf_zbee_beacon_update_id = -1;
141 static gint ett_zbee_nwk = -1;
142 static gint ett_zbee_beacon = -1;
143 static gint ett_zbee_nwk_fcf = -1;
144 static gint ett_zbee_nwk_mcast = -1;
145 static gint ett_zbee_nwk_route = -1;
146 static gint ett_zbee_nwk_cmd = -1;
147 static gint ett_zbee_nwk_cmd_options = -1;
148 static gint ett_zbee_nwk_cmd_cinfo = -1;
150 static dissector_handle_t data_handle;
151 static dissector_handle_t aps_handle;
153 /********************/
155 /********************/
157 static const value_string zbee_nwk_frame_types[] = {
158 { ZBEE_NWK_FCF_DATA, "Data" },
159 { ZBEE_NWK_FCF_CMD, "Command" },
163 /* Route Discovery Modes */
164 static const value_string zbee_nwk_discovery_modes[] = {
165 { ZBEE_NWK_FCF_DISCOVERY_SUPPRESS, "Suppress" },
166 { ZBEE_NWK_FCF_DISCOVERY_ENABLE, "Enable" },
167 { ZBEE_NWK_FCF_DISCOVERY_FORCE, "Force" },
172 static const value_string zbee_nwk_cmd_names[] = {
173 { ZBEE_NWK_CMD_ROUTE_REQ, "Route Request" },
174 { ZBEE_NWK_CMD_ROUTE_REPLY, "Route Reply" },
175 { ZBEE_NWK_CMD_NWK_STATUS, "Network Status" },
176 { ZBEE_NWK_CMD_LEAVE, "Leave" },
177 { ZBEE_NWK_CMD_ROUTE_RECORD, "Route Record" },
178 { ZBEE_NWK_CMD_REJOIN_REQ, "Rejoin Request" },
179 { ZBEE_NWK_CMD_REJOIN_RESP, "Rejoin Response" },
180 { ZBEE_NWK_CMD_LINK_STATUS, "Link Status" },
181 { ZBEE_NWK_CMD_NWK_REPORT, "Network Report" },
182 { ZBEE_NWK_CMD_NWK_UPDATE, "Network Update" },
186 /* Many-To-One Route Discovery Modes. */
187 static const value_string zbee_nwk_cmd_route_many_modes[] = {
188 { ZBEE_NWK_CMD_ROUTE_OPTION_MANY_NONE, "Not Many-to-One" },
189 { ZBEE_NWK_CMD_ROUTE_OPTION_MANY_REC, "With Source Routing" },
190 { ZBEE_NWK_CMD_ROUTE_OPTION_MANY_NOREC, "Without Source Routing" },
194 /* Rejoin Status Codes */
195 static const value_string zbee_nwk_rejoin_codes[] = {
196 { IEEE802154_CMD_ASRSP_AS_SUCCESS, "Success" },
197 { IEEE802154_CMD_ASRSP_PAN_FULL, "PAN Full" },
198 { IEEE802154_CMD_ASRSP_PAN_DENIED, "PAN Access Denied" },
202 /* Network Report Types */
203 static const value_string zbee_nwk_report_types[] = {
204 { ZBEE_NWK_CMD_NWK_REPORT_ID_PAN_CONFLICT, "PAN Identifier Conflict" },
208 /* Network Update Types */
209 static const value_string zbee_nwk_update_types[] = {
210 { ZBEE_NWK_CMD_NWK_UPDATE_ID_PAN_UPDATE, "PAN Identifier Update" },
214 /* Network Status Codes */
215 static const value_string zbee_nwk_status_codes[] = {
216 { ZBEE_NWK_STATUS_NO_ROUTE_AVAIL, "No Route Available" },
217 { ZBEE_NWK_STATUS_TREE_LINK_FAIL, "Tree Link Failure" },
218 { ZBEE_NWK_STATUS_NON_TREE_LINK_FAIL, "Non-tree Link Failure" },
219 { ZBEE_NWK_STATUS_LOW_BATTERY, "Low Battery" },
220 { ZBEE_NWK_STATUS_NO_ROUTING, "No Routing Capacity" },
221 { ZBEE_NWK_STATUS_NO_INDIRECT, "No Indirect Capacity" },
222 { ZBEE_NWK_STATUS_INDIRECT_EXPIRE, "Indirect Transaction Expiry" },
223 { ZBEE_NWK_STATUS_DEVICE_UNAVAIL, "Target Device Unavailable" },
224 { ZBEE_NWK_STATUS_ADDR_UNAVAIL, "Target Address Unallocated" },
225 { ZBEE_NWK_STATUS_PARENT_LINK_FAIL, "Parent Link Failure" },
226 { ZBEE_NWK_STATUS_VALIDATE_ROUTE, "Validate Route" },
227 { ZBEE_NWK_STATUS_SOURCE_ROUTE_FAIL, "Source Route Failure" },
228 { ZBEE_NWK_STATUS_MANY_TO_ONE_FAIL, "Many-to-One Route Failure" },
229 { ZBEE_NWK_STATUS_ADDRESS_CONFLICT, "Address Conflict" },
230 { ZBEE_NWK_STATUS_VERIFY_ADDRESS, "Verify Address" },
231 { ZBEE_NWK_STATUS_PANID_UPDATE, "PAN ID Update" },
232 { ZBEE_NWK_STATUS_ADDRESS_UPDATE, "Network Address Update" },
233 { ZBEE_NWK_STATUS_BAD_FRAME_COUNTER, "Bad Frame Counter" },
234 { ZBEE_NWK_STATUS_BAD_KEY_SEQNO, "Bad Key Sequence Number" },
238 /* Stack Profile Values. */
239 static const value_string zbee_nwk_stack_profiles[] = {
240 { 0x00, "Network Specific" },
241 { 0x01, "ZigBee Home" },
242 { 0x02, "ZigBee PRO" },
246 /*FUNCTION:------------------------------------------------------
248 * proto_tree_add_eui64
250 * Helper function to display an EUI-64 address to the tree.
260 *---------------------------------------------------------------
263 proto_tree_add_eui64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, gint length, gint64 value)
265 header_field_info *hf = proto_registrar_get_nth(hfindex);
266 return proto_tree_add_uint64_format(tree, hfindex, tvb, start, length, value, "%s: %s (%s)", hf->name, print_eui64_oui(value), print_eui64(value));
269 /*FUNCTION:------------------------------------------------------
273 * Extracts an integer sub-field from an int with a given mask
274 * if the mask is 0, this will return 0, if the mask is non-
275 * continuous the output is undefined.
281 *---------------------------------------------------------------
284 zbee_get_bit_field(guint input, guint mask)
286 /* Sanity Check, don't want infinite loops. */
287 if (mask == 0) return 0;
288 /* Shift input and mask together. */
289 while (!(mask & 0x1)) {
293 return (input & mask);
294 } /* zbee_get_bit_field */
296 /*FUNCTION:------------------------------------------------------
298 * dissect_zbee_nwk_heur
300 * Heuristic interpreter for the ZigBee network dissectors.
302 * tvbuff_t *tvb - pointer to buffer containing raw packet.
303 * packet_into *pinfo - pointer to packet information fields
304 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
306 * Boolean value, whether it handles the packet or not.
307 *---------------------------------------------------------------
310 dissect_zbee_nwk_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
312 ieee802154_packet *packet = pinfo->private_data;
314 /* All ZigBee frames must always have a 16-bit source address. */
315 if (packet->src_addr_mode != IEEE802154_FCF_ADDR_SHORT) {
318 /* ZigBee MAC frames must always contain a 16-bit destination address. */
319 if ( (packet->frame_type == IEEE802154_FCF_DATA) &&
320 (packet->dst_addr_mode == IEEE802154_FCF_ADDR_SHORT) ) {
321 dissect_zbee_nwk(tvb, pinfo, tree);
324 /* ZigBee MAC Beacons must have the first byte (protocol ID) equal to the
325 * ZigBee protocol ID. */
326 if ( (packet->frame_type == IEEE802154_FCF_BEACON) &&
327 (tvb_get_guint8(tvb, 0) == ZBEE_NWK_BEACON_PROCOL_ID) ) {
328 dissect_zbee_beacon(tvb, pinfo, tree);
331 /* If we get this far, then this packet did not meet the requirements for
335 } /* dissect_zbee_heur */
337 /*FUNCTION:------------------------------------------------------
341 * ZigBee packet dissection routine for Wireshark.
343 * tvbuff_t *tvb - pointer to buffer containing raw packet.
344 * packet_into *pinfo - pointer to packet information fields
345 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
348 *---------------------------------------------------------------
351 dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
353 tvbuff_t *payload_tvb = NULL;
355 proto_item *proto_root = NULL;
356 proto_item *ti = NULL;
357 proto_tree *nwk_tree = NULL;
358 proto_tree *field_tree = NULL;
360 zbee_nwk_packet packet;
363 gchar *src_addr = ep_alloc(32);
364 gchar *dst_addr = ep_alloc(32);
367 memset(&packet, 0, sizeof(packet));
369 /* Add ourself to the protocol column, clear the info column, and create the protocol tree. */
370 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZigBee");
371 col_clear(pinfo->cinfo, COL_INFO);
373 proto_root = proto_tree_add_protocol_format(tree, proto_zbee_nwk, tvb, offset, tvb_length(tvb), "ZigBee Network Layer");
374 nwk_tree = proto_item_add_subtree(proto_root, ett_zbee_nwk);
377 /* Get and parse the FCF */
378 fcf = tvb_get_letohs(tvb, offset);
379 packet.type = zbee_get_bit_field(fcf, ZBEE_NWK_FCF_FRAME_TYPE);
380 packet.version = zbee_get_bit_field(fcf, ZBEE_NWK_FCF_VERSION);
381 packet.discovery = zbee_get_bit_field(fcf, ZBEE_NWK_FCF_DISCOVER_ROUTE);
382 packet.security = zbee_get_bit_field(fcf, ZBEE_NWK_FCF_SECURITY);
383 packet.multicast = zbee_get_bit_field(fcf, ZBEE_NWK_FCF_MULTICAST);
384 packet.route = zbee_get_bit_field(fcf, ZBEE_NWK_FCF_SOURCE_ROUTE);
385 packet.ext_dst = zbee_get_bit_field(fcf, ZBEE_NWK_FCF_EXT_DEST);
386 packet.ext_src = zbee_get_bit_field(fcf, ZBEE_NWK_FCF_EXT_SOURCE);
387 pinfo->zbee_stack_vers = packet.version;
389 /* Display the FCF. */
391 /* Create a subtree for the FCF. */
392 ti = proto_tree_add_text(nwk_tree, tvb, offset, sizeof(guint16), "Frame Control Field: %s (0x%04x)",
393 val_to_str(packet.type, zbee_nwk_frame_types, "Unknown"), fcf);
394 field_tree = proto_item_add_subtree(ti, ett_zbee_nwk_fcf);
395 proto_tree_add_uint(field_tree, hf_zbee_nwk_frame_type, tvb, offset, sizeof(guint8), fcf & ZBEE_NWK_FCF_FRAME_TYPE);
397 /* Add the rest of the fcf fields to the subtree */
398 proto_tree_add_uint(field_tree, hf_zbee_nwk_proto_version, tvb, offset, sizeof(guint8), fcf & ZBEE_NWK_FCF_VERSION);
399 proto_tree_add_uint(field_tree, hf_zbee_nwk_discover_route, tvb, offset, sizeof(guint8), fcf & ZBEE_NWK_FCF_DISCOVER_ROUTE);
400 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
401 proto_tree_add_boolean(field_tree, hf_zbee_nwk_multicast, tvb, offset+sizeof(guint8), sizeof(guint8), fcf & ZBEE_NWK_FCF_MULTICAST);
403 proto_tree_add_boolean(field_tree, hf_zbee_nwk_security, tvb, offset+sizeof(guint8), sizeof(guint8), fcf & ZBEE_NWK_FCF_SECURITY);
404 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
405 proto_tree_add_boolean(field_tree, hf_zbee_nwk_source_route, tvb, offset+sizeof(guint8), sizeof(guint8), fcf & ZBEE_NWK_FCF_SOURCE_ROUTE);
406 proto_tree_add_boolean(field_tree, hf_zbee_nwk_ext_dst, tvb, offset+sizeof(guint8), sizeof(guint8), fcf & ZBEE_NWK_FCF_EXT_DEST);
407 proto_tree_add_boolean(field_tree, hf_zbee_nwk_ext_src, tvb, offset+sizeof(guint8), sizeof(guint8), fcf & ZBEE_NWK_FCF_EXT_SOURCE);
410 offset += sizeof(guint16);
412 /* Add the frame type to the info column and protocol root. */
414 proto_item_append_text(proto_root, " %s", val_to_str(packet.type, zbee_nwk_frame_types, "Unknown Type"));
416 if (check_col(pinfo->cinfo, COL_INFO)) {
417 col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(packet.type, zbee_nwk_frame_types, "Reserved Frame Type"));
420 /* Get the destination address. */
421 packet.dst = tvb_get_letohs(tvb, offset);
423 proto_tree_add_uint(nwk_tree, hf_zbee_nwk_dst, tvb, offset, sizeof(guint16), packet.dst);
425 offset += sizeof(guint16);
427 /* Display the destination address. */
428 if ( (packet.dst == ZBEE_BCAST_ALL)
429 || (packet.dst == ZBEE_BCAST_ACTIVE)
430 || (packet.dst == ZBEE_BCAST_ROUTERS)){
431 g_snprintf(dst_addr, 32, "Broadcast");
433 else g_snprintf(dst_addr, 32, "0x%04x", packet.dst);
434 SET_ADDRESS(&pinfo->dst, AT_STRINGZ, (int)strlen(dst_addr)+1, dst_addr);
435 SET_ADDRESS(&pinfo->net_dst, AT_STRINGZ, (int)strlen(dst_addr)+1, dst_addr);
437 proto_item_append_text(proto_root, ", Dst: %s", dst_addr);
439 if (check_col(pinfo->cinfo, COL_INFO) && (packet.type == ZBEE_NWK_FCF_DATA)) {
440 col_append_fstr(pinfo->cinfo, COL_INFO, ", Dst: %s", dst_addr);
443 /* Get the source address. */
444 packet.src = tvb_get_letohs(tvb, offset);
446 proto_tree_add_uint(nwk_tree, hf_zbee_nwk_src, tvb, offset, sizeof(guint16), packet.src);
448 offset += sizeof(guint16);
450 /* Display the source address. */
451 if ( (packet.src == ZBEE_BCAST_ALL)
452 || (packet.src == ZBEE_BCAST_ACTIVE)
453 || (packet.src == ZBEE_BCAST_ROUTERS)){
454 /* Source Broadcast doesn't make much sense. */
455 g_snprintf(src_addr, 32, "Broadcast");
457 else g_snprintf(src_addr, 32, "0x%04x", packet.src);
458 SET_ADDRESS(&pinfo->src, AT_STRINGZ, (int)strlen(src_addr)+1, src_addr);
459 SET_ADDRESS(&pinfo->net_src, AT_STRINGZ, (int)strlen(src_addr)+1, src_addr);
461 proto_item_append_text(proto_root, ", Src: %s", src_addr);
463 if (check_col(pinfo->cinfo, COL_INFO) && (packet.type == ZBEE_NWK_FCF_DATA)){
464 col_append_fstr(pinfo->cinfo, COL_INFO, ", Src: %s", src_addr);
467 /* Get and display the radius. */
468 packet.radius = tvb_get_guint8(tvb, offset);
470 proto_tree_add_uint(nwk_tree, hf_zbee_nwk_radius, tvb, offset, sizeof(guint8), packet.radius);
472 offset += sizeof(guint8);
474 /* Get and display the sequence number. */
475 packet.seqno = tvb_get_guint8(tvb, offset);
477 proto_tree_add_uint(nwk_tree, hf_zbee_nwk_seqno, tvb, offset, sizeof(guint8), packet.seqno);
479 offset += sizeof(guint8);
481 /* Add Multicast control field. (ZigBee 2006 and later). */
482 if ((pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) && packet.multicast) {
483 guint8 mcast_control = tvb_get_guint8(tvb, offset);
485 packet.mcast_mode = zbee_get_bit_field(mcast_control, ZBEE_NWK_MCAST_MODE);
486 packet.mcast_radius = zbee_get_bit_field(mcast_control, ZBEE_NWK_MCAST_RADIUS);
487 packet.mcast_max_radius = zbee_get_bit_field(mcast_control, ZBEE_NWK_MCAST_MAX_RADIUS);
489 /* Create a subtree for the multicast control field. */
490 ti = proto_tree_add_text(nwk_tree, tvb, offset, sizeof(guint8), "Multicast Control Field");
491 field_tree = proto_item_add_subtree(ti, ett_zbee_nwk_mcast);
492 /* Add the fields. */
493 ti = proto_tree_add_uint(field_tree, hf_zbee_nwk_mcast_mode, tvb, offset, sizeof(guint8), mcast_control & ZBEE_NWK_MCAST_MODE);
494 proto_tree_add_uint(field_tree, hf_zbee_nwk_mcast_radius, tvb, offset, sizeof(guint8), mcast_control & ZBEE_NWK_MCAST_RADIUS);
495 proto_tree_add_uint(field_tree, hf_zbee_nwk_mcast_max_radius, tvb, offset, sizeof(guint8), mcast_control & ZBEE_NWK_MCAST_MAX_RADIUS);
497 offset += sizeof(guint8);
500 /* Add the extended destination address (ZigBee 2006 and later). */
501 if ((pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) && packet.ext_dst) {
502 packet.dst64 = tvb_get_letoh64(tvb, offset);
504 proto_tree_add_eui64(nwk_tree, hf_zbee_nwk_dst64, tvb, offset, sizeof(guint64), packet.dst64);
506 offset += sizeof(guint64);
509 /* Add the extended source address. (ZigBee 2006 and later). */
510 if ((pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) && packet.ext_src) {
511 packet.src64 = tvb_get_letoh64(tvb, offset);
513 proto_tree_add_eui64(nwk_tree, hf_zbee_nwk_src64, tvb, offset, sizeof(guint64), packet.src64);
515 offset += sizeof(guint64);
518 /* Add the Source Route field. (ZigBee 2006 and later). */
519 if ((pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) && packet.route) {
526 /* Create a subtree for the source route field. */
527 ti = proto_tree_add_text(nwk_tree, tvb, offset, sizeof(guint8), "Source Route");
528 field_tree = proto_item_add_subtree(ti, ett_zbee_nwk_route);
531 /* Get and display the relay count. */
532 relay_count = tvb_get_guint8(tvb, offset);
534 proto_tree_add_uint(field_tree, hf_zbee_nwk_relay_count, tvb, offset, sizeof(guint8), relay_count);
535 proto_item_append_text(ti, ", Length: %d", relay_count);
537 offset += sizeof(guint8);
540 /* Correct the length of the source route fields. */
541 proto_item_set_len(ti, sizeof(guint8) + relay_count*sizeof(guint16));
544 /* Get and display the relay index. */
545 relay_index = tvb_get_guint8(tvb, offset);
547 proto_tree_add_uint(field_tree, hf_zbee_nwk_relay_index, tvb, offset, sizeof(guint8), relay_index);
549 offset += sizeof(guint8);
551 /* Get and display the relay list. */
552 for (i=0; i<relay_count; i++) {
553 relay_addr = tvb_get_letohs(tvb, offset);
555 proto_tree_add_text(field_tree, tvb, offset, sizeof(guint16), "Relay %d: 0x%04x", i+1, relay_addr);
557 offset += sizeof(guint16);
562 * Link the packet structure into the private data pointer so the
563 * APS layer can retrieve the network source address.
565 * BUGBUG: Ideally, the APS layer could just pull this out of the
566 * pinfo structure. But there is no suitable address type to use
567 * for ZigBee's 16-bit short address.
569 pinfo->private_data = (void *)&packet;
572 * Ensure that the payload exists. There are no valid ZigBee network
573 * packets that have no payload.
575 if (offset >= tvb_length(tvb)) {
576 /* Non-existent or truncated payload. */
577 expert_add_info_format(pinfo, proto_root, PI_MALFORMED, PI_ERROR, "Missing Payload");
580 /* Payload is encrypted, attempt security operations. */
581 else if (packet.security) {
582 payload_tvb = dissect_zbee_secure(tvb, pinfo, nwk_tree, offset, 0);
583 if (payload_tvb == NULL) {
584 /* If Payload_tvb is NULL, then the security dissector cleaned up. */
588 /* Plaintext payload. */
590 payload_tvb = tvb_new_subset_remaining(tvb, offset);
593 if (packet.type == ZBEE_NWK_FCF_CMD) {
594 /* Dissect the Network Command. */
595 dissect_zbee_nwk_cmd(payload_tvb, pinfo, nwk_tree);
597 else if (packet.type == ZBEE_NWK_FCF_DATA) {
598 /* Dissect the Network Payload (APS layer). */
599 call_dissector(aps_handle, payload_tvb, pinfo, tree);
603 call_dissector(data_handle, payload_tvb, pinfo, tree);
605 } /* dissect_zbee_nwk */
607 /*FUNCTION:------------------------------------------------------
609 * dissect_zbee_nwk_cmd
611 * ZigBee Network command packet dissection routine for Wireshark.
612 * note: this dissector differs from others in that is shouldn't be
613 * passed the main tree pointer, but the nwk tree instead.
615 * tvbuff_t *tvb - pointer to buffer containing raw packet.
616 * packet_into *pinfo - pointer to packet information fields
617 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
620 *---------------------------------------------------------------
622 static void dissect_zbee_nwk_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
624 proto_tree *cmd_tree = NULL;
625 proto_item *cmd_root = NULL;
627 zbee_nwk_packet *packet = pinfo->private_data;
630 guint8 cmd_id = tvb_get_guint8(tvb, offset);
632 /* Create a subtree for this command. */
634 cmd_root = proto_tree_add_text(tree, tvb, offset, tvb_length(tvb), "Command Frame: %s", val_to_str(cmd_id, zbee_nwk_cmd_names, "Unknown"));
635 cmd_tree = proto_item_add_subtree(cmd_root, ett_zbee_nwk_cmd);
637 /* Add the command ID. */
638 proto_tree_add_uint(cmd_tree, hf_zbee_nwk_cmd_id, tvb, offset, sizeof(guint8), cmd_id);
640 offset += sizeof(guint8);
642 /* Add the command name to the info column. */
643 if (check_col(pinfo->cinfo, COL_INFO)) {
644 col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(cmd_id, zbee_nwk_cmd_names, "Unknown Command"));
647 /* Handle the command. */
649 case ZBEE_NWK_CMD_ROUTE_REQ:
650 /* Route Request Command. */
651 offset = dissect_zbee_nwk_route_req(tvb, pinfo, cmd_tree, packet, offset);
654 case ZBEE_NWK_CMD_ROUTE_REPLY:
655 /* Route Reply Command. */
656 offset = dissect_zbee_nwk_route_rep(tvb, pinfo, cmd_tree, offset);
659 case ZBEE_NWK_CMD_NWK_STATUS:
660 /* Network Status Command. */
661 offset = dissect_zbee_nwk_status(tvb, pinfo, cmd_tree, offset);
664 case ZBEE_NWK_CMD_LEAVE:
666 offset = dissect_zbee_nwk_leave(tvb, cmd_tree, offset);
669 case ZBEE_NWK_CMD_ROUTE_RECORD:
670 /* Route Record Command. */
671 offset = dissect_zbee_nwk_route_rec(tvb, pinfo, cmd_tree, packet, offset);
674 case ZBEE_NWK_CMD_REJOIN_REQ:
675 /* Rejoin Request Command. */
676 offset = dissect_zbee_nwk_rejoin_req(tvb, pinfo, cmd_tree, packet, offset);
679 case ZBEE_NWK_CMD_REJOIN_RESP:
680 /* Rejoin Response Command. */
681 offset = dissect_zbee_nwk_rejoin_resp(tvb, pinfo, cmd_tree, packet, offset);
684 case ZBEE_NWK_CMD_LINK_STATUS:
685 /* Link Status Command. */
686 offset = dissect_zbee_nwk_link_status(tvb, cmd_tree, offset);
689 case ZBEE_NWK_CMD_NWK_REPORT:
690 /* Network Report Command. */
691 offset = dissect_zbee_nwk_report(tvb, pinfo, cmd_tree, offset);
694 case ZBEE_NWK_CMD_NWK_UPDATE:
695 /* Network Update Command. */
696 offset = dissect_zbee_nwk_update(tvb, pinfo, cmd_tree, offset);
700 /* Just break out and let the overflow handler deal with the payload. */
704 /* There is excess data in the packet. */
705 if (offset < tvb_length(tvb)) {
706 /* There are leftover bytes! */
707 guint leftover_len = tvb_length(tvb) - offset;
708 tvbuff_t *leftover_tvb = tvb_new_subset(tvb, offset, leftover_len, leftover_len);
709 proto_tree *root = NULL;
711 /* Correct the length of the command tree. */
713 root = proto_tree_get_root(tree);
714 proto_item_set_len(cmd_root, offset);
717 /* Dump the leftover to the data dissector. */
718 call_dissector(data_handle, leftover_tvb, pinfo, root);
720 } /* dissect_zbee_nwk_cmd */
722 /*FUNCTION:------------------------------------------------------
724 * dissect_zbee_nwk_route_req
726 * Helper dissector for the Route Request command.
728 * tvbuff_t *tvb - pointer to buffer containing raw packet.
729 * packet_into *pinfo - pointer to packet information fields
730 * proto_tree *tree - pointer to the command subtree.
731 * zbee_nwk_packet *packet - pointer to the network packet struct.
732 * offset - offset into the tvb to begin dissection.
734 * guint - offset after command dissection.
735 *---------------------------------------------------------------
738 dissect_zbee_nwk_route_req(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet * packet, guint offset)
740 proto_tree *field_tree;
743 guint8 route_options;
746 guint64 dest_ext_addr;
749 /* Get and display the route options field. */
750 route_options = tvb_get_guint8(tvb, offset);
752 /* Create a subtree for the command options. */
753 ti = proto_tree_add_text(tree, tvb, offset, sizeof(guint8), "Command Options (0x%02x)", route_options);
754 field_tree = proto_item_add_subtree(ti, ett_zbee_nwk_cmd_options);
756 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
757 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_route_opt_multicast, tvb, offset, sizeof(guint8), route_options & ZBEE_NWK_CMD_ROUTE_OPTION_MCAST);
758 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_route_opt_dest_ext, tvb, offset, sizeof(guint8), route_options & ZBEE_NWK_CMD_ROUTE_OPTION_DEST_EXT);
759 proto_tree_add_uint(field_tree, hf_zbee_nwk_cmd_route_opt_many_to_one, tvb, offset, sizeof(guint8), route_options & ZBEE_NWK_CMD_ROUTE_OPTION_MANY_MASK);
762 proto_tree_add_boolean(tree, hf_zbee_nwk_cmd_route_opt_repair, tvb, offset, sizeof(guint8), route_options & ZBEE_NWK_CMD_ROUTE_OPTION_REPAIR);
765 offset += sizeof(guint8);
767 /* Get and display the route request ID. */
768 route_id = tvb_get_guint8(tvb, offset);
770 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_route_id, tvb, offset, sizeof(guint8), route_id);
772 offset += sizeof(guint8);
774 /* Get and display the destination address. */
775 dest_addr = tvb_get_letohs(tvb, offset);
777 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_route_dest, tvb, offset, sizeof(guint16), dest_addr);
779 offset += sizeof(guint16);
781 /* Get and display the path cost. */
782 path_cost = tvb_get_guint8(tvb, offset);
784 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_route_cost, tvb, offset, sizeof(guint8), path_cost);
786 offset += sizeof(guint8);
788 /* Get and display the extended destination address. */
789 if (route_options & ZBEE_NWK_CMD_ROUTE_OPTION_DEST_EXT) {
790 dest_ext_addr = tvb_get_letoh64(tvb, offset);
792 proto_tree_add_eui64(tree, hf_zbee_nwk_cmd_route_dest_ext, tvb, offset, sizeof(guint64), dest_ext_addr);
794 offset += sizeof(guint64);
797 /* Update the info column. */
798 if (check_col(pinfo->cinfo, COL_INFO)) {
799 col_append_fstr(pinfo->cinfo, COL_INFO, ", Dst: 0x%04x, Src: 0x%04x", dest_addr, packet->src);
804 } /* dissect_zbee_nwk_route_req */
806 /*FUNCTION:------------------------------------------------------
808 * dissect_zbee_nwk_route_rep
810 * Helper dissector for the Route Reply command.
812 * tvbuff_t *tvb - pointer to buffer containing raw packet.
813 * packet_into *pinfo - pointer to packet information fields
814 * proto_tree *tree - pointer to the command subtree.
815 * offset - offset into the tvb to begin dissection.
817 * guint - offset after command dissection.
818 *---------------------------------------------------------------
821 dissect_zbee_nwk_route_rep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
823 proto_tree *field_tree;
826 guint8 route_options;
830 guint64 orig_ext_addr;
831 guint64 resp_ext_addr;
834 /* Get and display the route options field. */
835 route_options = tvb_get_guint8(tvb, offset);
837 /* Create a subtree for the command options. */
838 ti = proto_tree_add_text(tree, tvb, offset, sizeof(guint8), "Command Options (0x%02x)", route_options);
839 field_tree = proto_item_add_subtree(ti, ett_zbee_nwk_cmd_options);
841 if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
842 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_route_opt_multicast, tvb, offset, sizeof(guint8), route_options & ZBEE_NWK_CMD_ROUTE_OPTION_MCAST);
843 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_route_opt_resp_ext, tvb, offset, sizeof(guint8), route_options & ZBEE_NWK_CMD_ROUTE_OPTION_RESP_EXT);
844 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_route_opt_orig_ext, tvb, offset, sizeof(guint8), route_options & ZBEE_NWK_CMD_ROUTE_OPTION_ORIG_EXT);
847 proto_tree_add_boolean(tree, hf_zbee_nwk_cmd_route_opt_repair, tvb, offset, sizeof(guint8), route_options & ZBEE_NWK_CMD_ROUTE_OPTION_REPAIR);
850 offset += sizeof(guint8);
852 /* Get and display the route request ID. */
853 route_id = tvb_get_guint8(tvb, offset);
855 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_route_id, tvb, offset, sizeof(guint8), route_id);
857 offset += sizeof(guint8);
859 /* Get and display the originator address. */
860 orig_addr = tvb_get_letohs(tvb, offset);
862 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_route_orig, tvb, offset, sizeof(guint16), orig_addr);
864 offset += sizeof(guint16);
866 /* Get and display the responder address. */
867 resp_addr = tvb_get_letohs(tvb, offset);
869 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_route_resp, tvb, offset, sizeof(guint16), resp_addr);
871 offset += sizeof(guint16);
873 /* Get and display the path cost. */
874 path_cost = tvb_get_guint8(tvb, offset);
876 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_route_cost, tvb, offset, sizeof(guint8), path_cost);
878 offset += sizeof(guint8);
880 /* Get and display the originator extended address. */
881 if (route_options & ZBEE_NWK_CMD_ROUTE_OPTION_ORIG_EXT) {
882 orig_ext_addr = tvb_get_letoh64(tvb, offset);
884 proto_tree_add_eui64(tree, hf_zbee_nwk_cmd_route_orig_ext, tvb, offset, sizeof(guint64), orig_ext_addr);
886 offset += sizeof(guint64);
889 /* Get and display the responder extended address. */
890 if (route_options & ZBEE_NWK_CMD_ROUTE_OPTION_RESP_EXT) {
891 resp_ext_addr = tvb_get_letoh64(tvb, offset);
893 proto_tree_add_eui64(tree, hf_zbee_nwk_cmd_route_resp_ext, tvb, offset, sizeof(guint64), resp_ext_addr);
895 offset += sizeof(guint64);
898 /* Update the info column. */
899 if (check_col(pinfo->cinfo, COL_INFO)) {
900 col_append_fstr(pinfo->cinfo, COL_INFO, ", Dst: 0x%04x, Src: 0x%04x", resp_addr, orig_addr);
905 } /* dissect_zbee_nwk_route_rep */
907 /*FUNCTION:------------------------------------------------------
909 * dissect_zbee_nwk_status
911 * Helper dissector for the Network Status command.
913 * tvbuff_t *tvb - pointer to buffer containing raw packet.
914 * packet_into *pinfo - pointer to packet information fields
915 * proto_tree *tree - pointer to the command subtree.
916 * offset - offset into the tvb to begin dissection.
918 * guint - offset after command dissection.
919 *---------------------------------------------------------------
922 dissect_zbee_nwk_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
927 /* Get and display the status code. */
928 status_code = tvb_get_guint8(tvb, offset);
930 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_nwk_status, tvb, offset, sizeof(guint8), status_code);
932 offset += sizeof(guint8);
934 /* Get and display the destination address. */
935 addr = tvb_get_letohs(tvb, offset);
937 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_route_dest, tvb, offset, sizeof(guint16), addr);
939 offset += sizeof(guint16);
941 /* Update the info column. */
942 if (check_col(pinfo->cinfo, COL_INFO)) {
943 col_append_fstr(pinfo->cinfo, COL_INFO, ", 0x%04x: %s", addr, val_to_str(status_code, zbee_nwk_status_codes, "Unknown Status Code"));
948 } /* dissect_zbee_nwk_status */
950 /*FUNCTION:------------------------------------------------------
952 * dissect_zbee_nwk_leave
954 * Helper dissector for the Leave command.
956 * tvbuff_t *tvb - pointer to buffer containing raw packet.
957 * proto_tree *tree - pointer to the command subtree.
958 * offset - offset into the tvb to begin dissection.
960 * guint - offset after command dissection.
961 *---------------------------------------------------------------
964 dissect_zbee_nwk_leave(tvbuff_t *tvb, proto_tree *tree, guint offset)
966 guint8 leave_options;
968 /* Get and display the leave options. */
969 leave_options = tvb_get_guint8(tvb, offset);
971 proto_tree_add_boolean(tree, hf_zbee_nwk_cmd_leave_rejoin, tvb, offset, sizeof(guint8), leave_options & ZBEE_NWK_CMD_LEAVE_OPTION_REJOIN);
972 proto_tree_add_boolean(tree, hf_zbee_nwk_cmd_leave_request, tvb, offset, sizeof(guint8), leave_options & ZBEE_NWK_CMD_LEAVE_OPTION_REQUEST);
973 proto_tree_add_boolean(tree, hf_zbee_nwk_cmd_leave_children, tvb, offset, sizeof(guint8), leave_options & ZBEE_NWK_CMD_LEAVE_OPTION_CHILDREN);
975 offset += sizeof(guint8);
979 } /* dissect_zbee_nwk_leave */
981 /*FUNCTION:------------------------------------------------------
983 * dissect_zbee_nwk_route_rec
985 * Helper dissector for the Reoute Record command.
987 * tvbuff_t *tvb - pointer to buffer containing raw packet.
988 * packet_into *pinfo - pointer to packet information fields
989 * proto_tree *tree - pointer to the command subtree.
990 * zbee_nwk_packet *packet - pointer to the network packet struct.
991 * offset - offset into the tvb to begin dissection.
993 * guint - offset after command dissection.
994 *---------------------------------------------------------------
997 dissect_zbee_nwk_route_rec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet * packet, guint offset)
1003 /* Get and display the relay count. */
1004 relay_count = tvb_get_guint8(tvb, offset);
1006 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_relay_count, tvb, offset, sizeof(guint8), relay_count);
1008 offset += sizeof(guint8);
1010 /* Get and display the relay addresses. */
1011 for (i=0; i<relay_count; i++) {
1012 relay_addr = tvb_get_letohs(tvb, offset);
1014 proto_tree_add_text(tree, tvb, offset, sizeof(guint16), "Relay Device %d: 0x%04x", i+1, relay_addr);
1016 offset += sizeof(guint16);
1019 /* Update the info column. */
1020 if (check_col(pinfo->cinfo, COL_INFO)) {
1021 col_append_fstr(pinfo->cinfo, COL_INFO, ", Dst: 0x%04x", packet->dst);
1026 } /* dissect_zbee_nwk_route_rec */
1028 /*FUNCTION:------------------------------------------------------
1030 * dissect_zbee_nwk_rejoin_req
1032 * Helper dissector for the Rejoin Request command.
1034 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1035 * packet_into *pinfo - pointer to packet information fields
1036 * proto_tree *tree - pointer to the command subtree.
1037 * zbee_nwk_packet *packet - pointer to the network packet struct.
1038 * offset - offset into the tvb to begin dissection.
1040 * guint - offset after command dissection.
1041 *---------------------------------------------------------------
1044 dissect_zbee_nwk_rejoin_req(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet * packet, guint offset)
1046 proto_tree *field_tree;
1049 guint8 capabilities;
1051 /* Get and dispaly the capabilities information. */
1052 capabilities = tvb_get_guint8(tvb, offset);
1054 /* Create a subtree for the capability information. */
1055 ti = proto_tree_add_text(tree, tvb, offset, sizeof(guint8), "Capability Information");
1056 field_tree = proto_item_add_subtree(ti, ett_zbee_nwk_cmd_cinfo);
1058 /* Add the capability info flags. */
1059 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_cinfo_alt_coord, tvb, offset, sizeof(guint8), capabilities & ZBEE_CINFO_ALT_COORD);
1060 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_cinfo_type, tvb, offset, sizeof(guint8), capabilities & ZBEE_CINFO_FFD);
1061 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_cinfo_power, tvb, offset, sizeof(guint8), capabilities & ZBEE_CINFO_POWER);
1062 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_cinfo_idle_rx, tvb, offset, sizeof(guint8), capabilities & ZBEE_CINFO_IDLE_RX);
1063 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_cinfo_security, tvb, offset, sizeof(guint8), capabilities & ZBEE_CINFO_SECURITY);
1064 proto_tree_add_boolean(field_tree, hf_zbee_nwk_cmd_cinfo_alloc, tvb, offset, sizeof(guint8), capabilities & ZBEE_CINFO_ALLOC);
1066 offset += sizeof(guint8);
1068 /* Update the info column.*/
1069 if (check_col(pinfo->cinfo, COL_INFO)) {
1070 col_append_fstr(pinfo->cinfo, COL_INFO, ", Device: 0x%04x", packet->src);
1075 } /* dissect_zbee_nwk_rejoin_req */
1077 /*FUNCTION:------------------------------------------------------
1079 * dissect_zbee_nwk_rejoin_resp
1081 * Helper dissector for the Rejoin Response command.
1083 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1084 * packet_into *pinfo - pointer to packet information fields
1085 * proto_tree *tree - pointer to the command subtree.
1086 * zbee_nwk_packet *packet - pointer to the network packet struct.
1087 * offset - offset into the tvb to begin dissection.
1089 * guint - offset after command dissection.
1090 *---------------------------------------------------------------
1093 dissect_zbee_nwk_rejoin_resp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, zbee_nwk_packet * packet, guint offset)
1098 /* Get and display the short address. */
1099 addr = tvb_get_letohs(tvb, offset);
1101 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_addr, tvb, offset, sizeof(guint16), addr);
1103 offset += sizeof(guint16);
1105 /* Get and display the rejoin status. */
1106 status = tvb_get_guint8(tvb, offset);
1108 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_rejoin_status, tvb, offset, sizeof(guint8), status);
1110 offset += sizeof(guint8);
1112 /* Update the info column. */
1113 if (check_col(pinfo->cinfo, COL_INFO)) {
1114 if (status == IEEE802154_CMD_ASRSP_AS_SUCCESS) {
1115 col_append_fstr(pinfo->cinfo, COL_INFO, ", Address: 0x%04x", packet->src);
1118 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str(status, zbee_nwk_rejoin_codes, "Unknown Rejoin Response"));
1124 } /* dissect_zbee_nwk_rejoin_resp */
1126 /*FUNCTION:------------------------------------------------------
1128 * dissect_zbee_nwk_link_status
1130 * Helper dissector for the Link Status command.
1132 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1133 * proto_tree *tree - pointer to the command subtree.
1134 * offset - offset into the tvb to begin dissection.
1136 * guint - offset after command dissection.
1137 *---------------------------------------------------------------
1140 dissect_zbee_nwk_link_status(tvbuff_t *tvb, proto_tree *tree, guint offset)
1146 /* Get and Display the link status options. */
1147 options = tvb_get_guint8(tvb, offset);
1148 link_count = options & ZBEE_NWK_CMD_LINK_OPTION_COUNT_MASK;
1150 proto_tree_add_boolean(tree, hf_zbee_nwk_cmd_link_last, tvb, offset, sizeof(guint8), options & ZBEE_NWK_CMD_LINK_OPTION_LAST_FRAME);
1151 proto_tree_add_boolean(tree, hf_zbee_nwk_cmd_link_first, tvb, offset, sizeof(guint8), options & ZBEE_NWK_CMD_LINK_OPTION_FIRST_FRAME);
1152 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_link_count, tvb, offset, sizeof(guint8), link_count);
1154 offset += sizeof(guint8);
1156 /* Get and Display the link status list. */
1157 for (i=0; i<link_count; i++) {
1158 /* Get the address and link status. */
1159 addr = tvb_get_letohs(tvb, offset);
1160 options = tvb_get_guint8(tvb, offset+sizeof(guint16));
1162 proto_tree_add_text(tree, tvb, offset, sizeof(guint16)+sizeof(guint8), "0x%04x, Incoming Cost: %d Outgoing Cost: %d", addr, options & ZBEE_NWK_CMD_LINK_INCOMMING_COST_MASK, (options & ZBEE_NWK_CMD_LINK_OUTGOING_COST_MASK)>>4);
1164 offset += (sizeof(guint16)+sizeof(guint8));
1167 /* TODO: Update the info column. */
1169 } /* dissect_zbee_nwk_link_status */
1171 /*FUNCTION:------------------------------------------------------
1173 * dissect_zbee_nwk_report
1175 * Helper dissector for the Network Report command.
1177 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1178 * packet_into *pinfo - pointer to packet information fields
1179 * proto_tree *tree - pointer to the command subtree.
1180 * offset - offset into the tvb to begin dissection.
1182 * guint - offset after command dissection.
1183 *---------------------------------------------------------------
1186 dissect_zbee_nwk_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
1194 /* Get and display the command options field. */
1195 options = tvb_get_guint8(tvb, offset);
1196 report_count = options & ZBEE_NWK_CMD_NWK_REPORT_COUNT_MASK;
1197 report_type = options & ZBEE_NWK_CMD_NWK_REPORT_ID_MASK;
1199 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_report_type, tvb, offset, sizeof(guint8), report_type);
1200 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_report_count, tvb, offset, sizeof(guint8), report_count);
1202 offset += sizeof(guint8);
1204 /* Get and display the epid. */
1205 epid = tvb_get_letoh64(tvb, offset);
1207 proto_tree_add_uint64_format_value(tree, hf_zbee_nwk_cmd_epid, tvb, offset, sizeof(guint64), epid, "%s", print_eui64(epid));
1209 offset += sizeof(guint64);
1211 if (report_type == ZBEE_NWK_CMD_NWK_REPORT_ID_PAN_CONFLICT) {
1214 /* Report information contains a list of PANS with range of the sender. */
1215 for (i=0; i<report_count; i++) {
1216 panId = tvb_get_letohs(tvb, offset);
1218 proto_tree_add_text(tree, tvb, offset, sizeof(guint16), "PANID: 0x%04x", panId);
1220 offset += sizeof(guint16);
1224 /* Update the info column. */
1225 if (check_col(pinfo->cinfo, COL_INFO)) {
1226 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str(report_type, zbee_nwk_report_types, "Unknown Report Type"));
1231 } /* dissect_zbee_nwk_report */
1233 /*FUNCTION:------------------------------------------------------
1235 * dissect_zbee_nwk_update
1237 * Helper dissector for the Network Update command.
1239 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1240 * packet_into *pinfo - pointer to packet information fields
1241 * proto_tree *tree - pointer to the command subtree.
1242 * offset - offset into the tvb to begin dissection.
1244 * guint - offset after command dissection.
1245 *---------------------------------------------------------------
1248 dissect_zbee_nwk_update(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
1257 /* Get and display the command options field. */
1258 options = tvb_get_guint8(tvb, offset);
1259 update_count = options & ZBEE_NWK_CMD_NWK_UPDATE_COUNT_MASK;
1260 update_type = options & ZBEE_NWK_CMD_NWK_UPDATE_ID_MASK;
1262 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_update_type, tvb, offset, sizeof(guint8), update_type);
1263 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_update_count, tvb, offset, sizeof(guint8), update_count);
1265 offset += sizeof(guint8);
1267 /* Get and display the epid. */
1268 epid = tvb_get_letoh64(tvb, offset);
1270 proto_tree_add_uint64_format_value(tree, hf_zbee_nwk_cmd_epid, tvb, offset, sizeof(guint64), epid, "%s", print_eui64(epid));
1272 offset += sizeof(guint64);
1274 /* Get and display the updateID. */
1275 update_id = tvb_get_guint8(tvb, offset);
1277 proto_tree_add_uint(tree, hf_zbee_nwk_cmd_update_id, tvb, offset, sizeof(guint8), update_id);
1279 offset += sizeof(guint8);
1281 if (update_type == ZBEE_NWK_CMD_NWK_UPDATE_ID_PAN_UPDATE) {
1284 /* Report information contains a list of PANS with range of the sender. */
1285 for (i=0; i<update_count; i++) {
1286 panId = tvb_get_letohs(tvb, offset);
1288 proto_tree_add_text(tree, tvb, offset, sizeof(guint16), "PANID: 0x%04x", panId);
1290 offset += sizeof(guint16);
1294 /* Update the info column. */
1295 if (check_col(pinfo->cinfo, COL_INFO)) {
1296 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str(update_type, zbee_nwk_update_types, "Unknown Update Type"));
1301 } /* dissect_zbee_nwk_update */
1303 /*FUNCTION:------------------------------------------------------
1305 * dissect_zbee_beacon
1307 * Dissector for ZigBee network beacons.
1309 * tvbuff_t *tvb - pointer to buffer containing raw packet.
1310 * packet_into *pinfo - pointer to packet information fields
1311 * proto_tree *tree - pointer to data tree Wireshark uses to display packet.
1314 *---------------------------------------------------------------
1316 static void dissect_zbee_beacon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1318 ieee802154_packet *packet = pinfo->private_data;
1320 proto_item *beacon_root = NULL;
1321 proto_tree *beacon_tree = NULL;
1329 /* Add ourself to the protocol column. */
1330 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZigBee");
1331 /* Create the tree for this beacon. */
1333 beacon_root = proto_tree_add_protocol_format(tree, proto_zbee_nwk, tvb, 0, tvb_length(tvb), "ZigBee Beacon");
1334 beacon_tree = proto_item_add_subtree(beacon_root, ett_zbee_beacon);
1337 /* Update the info column. */
1338 if(check_col(pinfo->cinfo, COL_INFO)) {
1339 col_clear(pinfo->cinfo, COL_INFO);
1340 col_append_fstr(pinfo->cinfo, COL_INFO, "Beacon, Src: 0x%04x", packet->src.addr16);
1343 /* Get and display the protocol id, must be 0 on all ZigBee beacons. */
1344 temp = tvb_get_guint8(tvb, offset);
1346 proto_tree_add_uint(beacon_tree, hf_zbee_beacon_protocol, tvb, offset, sizeof(guint8), temp);
1348 offset += sizeof(guint8);
1350 /* Get and display the stack profile and protocol version. */
1351 temp = tvb_get_guint8(tvb, offset);
1352 pinfo->zbee_stack_vers = version = zbee_get_bit_field(temp, ZBEE_NWK_BEACON_PROTOCOL_VERSION);
1354 proto_tree_add_uint(beacon_tree, hf_zbee_beacon_stack_profile, tvb, offset, sizeof(guint8), zbee_get_bit_field(temp, ZBEE_NWK_BEACON_STACK_PROFILE));
1355 proto_tree_add_uint(beacon_tree, hf_zbee_beacon_version, tvb, offset, sizeof(guint8), version);
1357 offset += sizeof(guint8);
1359 /* Get and display the security level and flags. */
1360 temp = tvb_get_guint8(tvb, offset);
1362 proto_tree_add_boolean(beacon_tree, hf_zbee_beacon_router_capacity, tvb, offset, sizeof(guint8), zbee_get_bit_field(temp, ZBEE_NWK_BEACON_ROUTER_CAPACITY));
1363 proto_tree_add_uint(beacon_tree, hf_zbee_beacon_depth, tvb, offset, sizeof(guint8), zbee_get_bit_field(temp, ZBEE_NWK_BEACON_NETWORK_DEPTH));
1364 proto_tree_add_boolean(beacon_tree, hf_zbee_beacon_end_device_capacity, tvb, offset, sizeof(guint8), zbee_get_bit_field(temp, ZBEE_NWK_BEACON_END_DEVICE_CAPACITY));
1366 offset += sizeof(guint8);
1368 if (version >= ZBEE_VERSION_2007) {
1369 /* In ZigBee 2006 and later, the beacon contains an extended PAN ID. */
1370 epid = tvb_get_letoh64(tvb, offset);
1372 proto_tree_add_uint64_format_value(beacon_tree, hf_zbee_beacon_epid, tvb, offset, sizeof(guint64), epid, "%s", print_eui64(epid));
1374 offset += sizeof(guint64);
1376 /* Update the Info Column with the EPID. */
1377 if (check_col(pinfo->cinfo, COL_INFO)) {
1378 col_append_fstr(pinfo->cinfo, COL_INFO, ", EPID: %s", print_eui64(epid));
1381 /* In ZigBee 2007 and layer, the Tx-Offset is a required value. */
1382 tx_offset = tvb_get_letoh24(tvb, offset);
1384 proto_tree_add_uint(beacon_tree, hf_zbee_beacon_tx_offset, tvb, offset, 3, tx_offset);
1388 /* Get and display the update ID. */
1389 temp = tvb_get_guint8(tvb, offset);
1391 proto_tree_add_uint(beacon_tree, hf_zbee_beacon_update_id, tvb, offset, sizeof(guint8), temp);
1393 offset += sizeof(guint8);
1395 else if (tvb_bytes_exist(tvb, offset, 3)) {
1396 /* In ZigBee 2004, the Tx-Offset is an optional value. */
1397 tx_offset = tvb_get_letoh24(tvb, offset);
1399 proto_tree_add_uint(beacon_tree, hf_zbee_beacon_tx_offset, tvb, offset, 3, tx_offset);
1403 /* Update the info column with the PAN ID. */
1404 if (check_col(pinfo->cinfo, COL_INFO)) {
1405 col_append_fstr(pinfo->cinfo, COL_INFO, ", PAN: 0x%04x", packet->src_pan);
1409 /* Check for leftover bytes. */
1410 if (offset < tvb_length(tvb)) {
1411 /* Bytes leftover! */
1412 guint leftover_len = tvb_length(tvb) - offset;
1413 tvbuff_t *leftover_tvb = tvb_new_subset(tvb, offset, leftover_len, leftover_len);
1414 proto_tree *root = NULL;
1416 /* Correct the length of the beacon tree. */
1418 root = proto_tree_get_root(tree);
1419 proto_item_set_len(beacon_root, offset);
1422 /* Dump the leftover to the data dissector. */
1423 call_dissector(data_handle, leftover_tvb, pinfo, root);
1425 } /* dissect_zbee_beacon */
1427 /*FUNCTION:------------------------------------------------------
1429 * proto_register_zbee_nwk
1431 * ZigBee protocol registration routine.
1436 *---------------------------------------------------------------
1438 void proto_register_zbee_nwk(void)
1440 static hf_register_info hf[] = {
1442 { &hf_zbee_nwk_frame_type,
1443 { "Frame Type", "zbee.nwk.frame_type", FT_UINT16, BASE_HEX, VALS(zbee_nwk_frame_types), ZBEE_NWK_FCF_FRAME_TYPE,
1446 { &hf_zbee_nwk_proto_version,
1447 { "Protocol Version", "zbee.nwk.proto_version", FT_UINT16, BASE_DEC, NULL, ZBEE_NWK_FCF_VERSION,
1450 { &hf_zbee_nwk_discover_route,
1451 { "Discover Route", "zbee.nwk.discovery", FT_UINT16, BASE_HEX, VALS(zbee_nwk_discovery_modes), ZBEE_NWK_FCF_DISCOVER_ROUTE,
1452 "Determines how route discovery may be handled, if at all.", HFILL }},
1454 { &hf_zbee_nwk_multicast,
1455 { "Multicast", "zbee.nwk.multicast", FT_BOOLEAN, 16, NULL, ZBEE_NWK_FCF_MULTICAST,
1458 { &hf_zbee_nwk_security,
1459 { "Security", "zbee.nwk.security", FT_BOOLEAN, 16, NULL, ZBEE_NWK_FCF_SECURITY,
1460 "Whether or not security operations are performed on the network payload.", HFILL }},
1462 { &hf_zbee_nwk_source_route,
1463 { "Source Route", "zbee.nwk.src_route", FT_BOOLEAN, 16, NULL, ZBEE_NWK_FCF_SOURCE_ROUTE,
1466 { &hf_zbee_nwk_ext_dst,
1467 { "Extended Destination", "zbee.nwk.ext_dst", FT_BOOLEAN, 16, NULL, ZBEE_NWK_FCF_EXT_DEST,
1470 { &hf_zbee_nwk_ext_src,
1471 { "Extended Source", "zbee.nwk.ext_src", FT_BOOLEAN, 16, NULL, ZBEE_NWK_FCF_EXT_SOURCE,
1475 { "Destination", "zbee.nwk.dst", FT_UINT16, BASE_HEX, NULL, 0x0,
1479 { "Source", "zbee.nwk.src", FT_UINT16, BASE_HEX, NULL, 0x0,
1482 { &hf_zbee_nwk_radius,
1483 { "Radius", "zbee.nwk.radius", FT_UINT8, BASE_DEC, NULL, 0x0,
1484 "Number of hops remaining for a range-limited broadcast packet.", HFILL }},
1486 { &hf_zbee_nwk_seqno,
1487 { "Sequence Number", "zbee.nwk.seqno", FT_UINT8, BASE_DEC, NULL, 0x0,
1490 { &hf_zbee_nwk_mcast_mode,
1491 { "Multicast Mode", "zbee.nwk.multicast.mode", FT_UINT8, BASE_DEC, NULL, ZBEE_NWK_MCAST_MODE,
1492 "Controls whether this packet is permitted to be routed through non-members of the multicast group.", HFILL }},
1494 { &hf_zbee_nwk_mcast_radius,
1495 { "Non-Member Radius", "zbee.nwk.multicast.radius", FT_UINT8, BASE_DEC, NULL, ZBEE_NWK_MCAST_RADIUS,
1496 "Limits the range of multicast packets when being routed through non-members.", HFILL }},
1498 { &hf_zbee_nwk_mcast_max_radius,
1499 { "Max Non-Member Radius", "zbee.nwk.multicast.max_radius", FT_UINT8, BASE_DEC, NULL, ZBEE_NWK_MCAST_MAX_RADIUS,
1502 { &hf_zbee_nwk_dst64,
1503 { "Extended Destination", "zbee.nwk.dst64", FT_UINT64, BASE_HEX, NULL, 0x0,
1506 { &hf_zbee_nwk_src64,
1507 { "Extended Source", "zbee.nwk.scr64", FT_UINT64, BASE_HEX, NULL, 0x0,
1510 { &hf_zbee_nwk_relay_count,
1511 { "Relay Count", "zbee.nwk.relay.count", FT_UINT8, BASE_DEC, NULL, 0x0,
1512 "Number of entries in the relay list.", HFILL }},
1514 { &hf_zbee_nwk_relay_index,
1515 { "Relay Index", "zbee.nwk.relay.index", FT_UINT8, BASE_DEC, NULL, 0x0,
1516 "Number of relays required to route to the source device.", HFILL }},
1518 { &hf_zbee_nwk_cmd_id,
1519 { "Command Identifier", "zbee.nwk.cmd.id", FT_UINT8, BASE_HEX, VALS(zbee_nwk_cmd_names), 0x0,
1522 { &hf_zbee_nwk_cmd_addr,
1523 { "Address", "zbee.nwk.cmd.addr", FT_UINT16, BASE_HEX, NULL, 0x0,
1526 { &hf_zbee_nwk_cmd_route_id,
1527 { "Route ID", "zbee.nwk.cmd.route.id", FT_UINT8, BASE_DEC, NULL, 0x0,
1528 "A sequence number for routing commands.", HFILL }},
1530 { &hf_zbee_nwk_cmd_route_dest,
1531 { "Destination", "zbee.nwk.cmd.route.dest", FT_UINT16, BASE_HEX, NULL, 0x0,
1534 { &hf_zbee_nwk_cmd_route_orig,
1535 { "Originator", "zbee.nwk.cmd.route.orig", FT_UINT16, BASE_HEX, NULL, 0x0,
1538 { &hf_zbee_nwk_cmd_route_resp,
1539 { "Responder", "zbee.nwk.cmd.route.resp", FT_UINT16, BASE_HEX, NULL, 0x0,
1542 { &hf_zbee_nwk_cmd_route_dest_ext,
1543 { "Extended Destination", "zbee.nwk.cmd.route.dest_ext", FT_UINT64, BASE_HEX, NULL, 0x0,
1546 { &hf_zbee_nwk_cmd_route_orig_ext,
1547 { "Extended Originator", "zbee.nwk.cmd.route.orig_ext", FT_UINT64, BASE_HEX, NULL, 0x0,
1550 { &hf_zbee_nwk_cmd_route_resp_ext,
1551 { "Extended Responder", "zbee.nwk.cmd.route.resp_ext", FT_UINT64, BASE_HEX, NULL, 0x0,
1554 { &hf_zbee_nwk_cmd_route_cost,
1555 { "Path Cost", "zbee.nwk.cmd.route.cost", FT_UINT8, BASE_DEC, NULL, 0x0,
1556 "A value specifying the efficiency of this route.", HFILL }},
1558 { &hf_zbee_nwk_cmd_route_opt_repair,
1559 { "Route Repair", "zbee.nwk.cmd.route.opts.repair", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_ROUTE_OPTION_REPAIR,
1560 "Flag identifying whether the route request command was to repair a failed route.", HFILL }},
1562 { &hf_zbee_nwk_cmd_route_opt_multicast,
1563 { "Multicast", "zbee.nwk.cmd.route.opts.mcast", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_ROUTE_OPTION_MCAST,
1564 "Flag identifying this as a multicast route request.", HFILL }},
1566 { &hf_zbee_nwk_cmd_route_opt_dest_ext,
1567 { "Extended Destination", "zbee.nwk.cmd.route.opts.dest_ext", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_ROUTE_OPTION_DEST_EXT,
1570 { &hf_zbee_nwk_cmd_route_opt_resp_ext,
1571 { "Extended Responder", "zbee.nwk.cmd.route.opts.resp_ext", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_ROUTE_OPTION_RESP_EXT,
1574 { &hf_zbee_nwk_cmd_route_opt_orig_ext,
1575 { "Extended Originator", "zbee.nwk.cmd.route.opts.orig_ext", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_ROUTE_OPTION_ORIG_EXT,
1578 { &hf_zbee_nwk_cmd_route_opt_many_to_one,
1579 { "Many-to-One Discovery", "zbee.nwk.cmd.route.opts.many2one", FT_UINT8, BASE_HEX, VALS(zbee_nwk_cmd_route_many_modes), ZBEE_NWK_CMD_ROUTE_OPTION_MANY_MASK,
1582 { &hf_zbee_nwk_cmd_nwk_status,
1583 { "Status Code", "zbee.nwk.cmd.status", FT_UINT8, BASE_HEX, VALS(zbee_nwk_status_codes), 0x0,
1586 { &hf_zbee_nwk_cmd_leave_rejoin,
1587 { "Rejoin", "zbee.nwk.cmd.leave.rejoin", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_LEAVE_OPTION_REJOIN,
1588 "Flag instructing the device to rejoin the network.", HFILL }},
1590 { &hf_zbee_nwk_cmd_leave_request,
1591 { "Request", "zbee.nwk.cmd.leave.request", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_LEAVE_OPTION_REQUEST,
1592 "Flag identifying the direction of this command. 1=Request, 0=Indication", HFILL }},
1594 { &hf_zbee_nwk_cmd_leave_children,
1595 { "Remove Children", "zbee.nwk.cmd.leave.children", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_LEAVE_OPTION_CHILDREN,
1596 "Flag instructing the device to remove its children in addition to itself.", HFILL }},
1598 { &hf_zbee_nwk_cmd_relay_count,
1599 { "Relay Count", "zbee.nwk.cmd.relay_count", FT_UINT8, BASE_DEC, NULL, 0x0,
1600 "Number of relays required to route to the destination.", HFILL }},
1602 { &hf_zbee_nwk_cmd_cinfo_alt_coord,
1603 { "Alternate Coordinator", "zbee.nwk.cmd.cinfo.alt_coord", FT_BOOLEAN, 8, NULL, IEEE802154_CMD_CINFO_ALT_PAN_COORD,
1604 "Indicates that the device is able to operate as a PAN coordinator.", HFILL }},
1606 { &hf_zbee_nwk_cmd_cinfo_type,
1607 { "Full-Function Device", "zbee.nwk.cmd.cinfo.ffd", FT_BOOLEAN, 8, NULL, IEEE802154_CMD_CINFO_DEVICE_TYPE,
1610 { &hf_zbee_nwk_cmd_cinfo_power,
1611 { "AC Power", "zbee.nwk.cmd.cinfo.power", FT_BOOLEAN, 8, NULL, IEEE802154_CMD_CINFO_POWER_SRC,
1612 "Indicates this device is using AC/Mains power.", HFILL }},
1614 { &hf_zbee_nwk_cmd_cinfo_idle_rx,
1615 { "Rx On When Idle", "zbee.nwk.cmd.cinfo.power", FT_BOOLEAN, 8, NULL, IEEE802154_CMD_CINFO_IDLE_RX,
1616 "Indicates the receiver is active when the device is idle.", HFILL }},
1618 { &hf_zbee_nwk_cmd_cinfo_security,
1619 { "Security Capability", "zbee.nwk.cmd.cinfo.security", FT_BOOLEAN, 8, NULL, IEEE802154_CMD_CINFO_SEC_CAPABLE,
1620 "Indicates this device is capable of performing encryption/decryption.", HFILL }},
1622 { &hf_zbee_nwk_cmd_cinfo_alloc,
1623 { "Allocate Short Address", "zbee.nwk.cmd.cinfo.alloc", FT_BOOLEAN, 8, NULL, IEEE802154_CMD_CINFO_ALLOC_ADDR,
1624 "Flag requesting the parent to allocate a short address for this device.", HFILL }},
1626 { &hf_zbee_nwk_cmd_rejoin_status,
1627 { "Status", "zbee.nwk.cmd.rejoin_status", FT_UINT8, BASE_HEX, VALS(zbee_nwk_rejoin_codes), 0x0,
1630 { &hf_zbee_nwk_cmd_link_last,
1631 { "Last Frame", "zbee.nwk.cmd.link.last", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_LINK_OPTION_LAST_FRAME,
1632 "Flag indicating the last in a series of link status commands.", HFILL }},
1634 { &hf_zbee_nwk_cmd_link_first,
1635 { "First Frame", "zbee.nwk.cmd.link.first", FT_BOOLEAN, 8, NULL, ZBEE_NWK_CMD_LINK_OPTION_FIRST_FRAME,
1636 "Flag indicating the first in a series of link status commands.", HFILL }},
1638 { &hf_zbee_nwk_cmd_link_count,
1639 { "Link Status Count", "zbee.nwk.cmd.link.count", FT_UINT8, BASE_DEC, NULL, ZBEE_NWK_CMD_LINK_OPTION_COUNT_MASK,
1642 { &hf_zbee_nwk_cmd_report_type,
1643 { "Report Type", "zbee.nwk.cmd.report.type", FT_UINT8, BASE_HEX, VALS(zbee_nwk_report_types), ZBEE_NWK_CMD_NWK_REPORT_ID_MASK,
1646 { &hf_zbee_nwk_cmd_report_count,
1647 { "Report Information Count", "zbee.nwk.cmd.report.count", FT_UINT8, BASE_DEC, NULL, ZBEE_NWK_CMD_NWK_REPORT_COUNT_MASK,
1650 { &hf_zbee_nwk_cmd_update_type,
1651 { "Update Type", "zbee.nwk.cmd.update.type", FT_UINT8, BASE_HEX, VALS(zbee_nwk_update_types), ZBEE_NWK_CMD_NWK_UPDATE_ID_MASK,
1654 { &hf_zbee_nwk_cmd_update_count,
1655 { "Update Information Count", "zbee.nwk.cmd.update.count", FT_UINT8, BASE_DEC, NULL, ZBEE_NWK_CMD_NWK_UPDATE_COUNT_MASK,
1658 { &hf_zbee_nwk_cmd_update_id,
1659 { "Update ID", "zbee.nwk.cmd.update.id", FT_UINT8, BASE_DEC, NULL, 0x0,
1662 { &hf_zbee_nwk_cmd_epid,
1663 { "Extended PAN ID", "zbee.nwk.cmd.epid", FT_UINT64, BASE_HEX, NULL, 0x0,
1666 { &hf_zbee_beacon_protocol,
1667 { "Protocol ID", "zbee.beacon.protocol", FT_UINT8, BASE_DEC, NULL, 0x0,
1670 { &hf_zbee_beacon_stack_profile,
1671 { "Stack Profile", "zbee.beacon.profile", FT_UINT8, BASE_HEX, VALS(zbee_nwk_stack_profiles), 0x0,
1674 { &hf_zbee_beacon_version,
1675 { "Protocol Version", "zbee.beacon.version", FT_UINT8, BASE_DEC, NULL, 0x0,
1678 { &hf_zbee_beacon_router_capacity,
1679 { "Router Capacity", "zbee.beacon.router", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1680 "Whether the device can accept join requests from routing capable devices.", HFILL }},
1682 { &hf_zbee_beacon_depth,
1683 { "Device Depth", "zbee.beacon.depth", FT_UINT8, BASE_DEC, NULL, 0x0,
1684 "The tree depth of the device, 0 indicates the network coordinator.", HFILL }},
1686 { &hf_zbee_beacon_end_device_capacity,
1687 { "End Device Capacity", "zbee.beacon.end_dev", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1688 "Whether the device can accept join requests from ZigBee end devices.", HFILL }},
1690 { &hf_zbee_beacon_epid,
1691 { "Extended PAN ID", "zbee.beacon.ext_panid", FT_UINT64, BASE_HEX, NULL, 0x0,
1692 "Extended PAN identifier.", HFILL }},
1694 { &hf_zbee_beacon_tx_offset,
1695 { "Tx Offset", "zbee.beacon.tx_offset", FT_UINT32, BASE_DEC, NULL, 0x0,
1696 "The time difference between a device and its parent's beacon.", HFILL }},
1698 { &hf_zbee_beacon_update_id,
1699 { "Update ID", "zbee.beacon.update_id", FT_UINT8, BASE_DEC, NULL, 0x0,
1703 /* NWK Layer subtrees */
1704 static gint *ett[] = {
1708 &ett_zbee_nwk_mcast,
1709 &ett_zbee_nwk_route,
1711 &ett_zbee_nwk_cmd_options,
1712 &ett_zbee_nwk_cmd_cinfo
1715 /* Register the protocol with Wireshark. */
1716 proto_zbee_nwk = proto_register_protocol("ZigBee Network Layer", "ZigBee NWK", "zbee.nwk");
1717 proto_register_field_array(proto_zbee_nwk, hf, array_length(hf));
1718 proto_register_subtree_array(ett, array_length(ett));
1720 /* Register the dissectors with Wireshark. */
1721 register_dissector("zbee.nwk", dissect_zbee_nwk, proto_zbee_nwk);
1722 register_dissector("zbee.beacon", dissect_zbee_beacon, proto_zbee_nwk);
1724 /* Register the Security dissector. */
1725 zbee_security_register(NULL, proto_zbee_nwk);
1726 } /* proto_register_zbee */
1728 /*FUNCTION:------------------------------------------------------
1730 * proto_reg_handoff_zbee_nwk
1732 * Registers the zigbee dissector with Wireshark.
1737 *---------------------------------------------------------------
1739 void proto_reg_handoff_zbee_nwk(void)
1741 /* Find the other dissectors we need. */
1742 data_handle = find_dissector("data");
1743 aps_handle = find_dissector("zbee.aps");
1745 /* Register our dissector with IEEE 802.15.4 */
1746 heur_dissector_add("wpan", dissect_zbee_nwk_heur, proto_zbee_nwk);
1748 /* Handoff the ZigBee security dissector code. */
1749 zbee_security_handoff();
1750 } /* proto_reg_handoff_zbee */