Wireshark  4.3.0
The Wireshark network protocol analyzer
packet-zbee-nwk.h
1 /* packet-zbee-nwk.h
2  * Dissector routines for the ZigBee Network Layer (NWK)
3  * By Owen Kirby <osk@exegin.com>
4  * Copyright 2009 Exegin Technologies Limited
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12 #ifndef PACKET_ZBEE_NWK_H
13 #define PACKET_ZBEE_NWK_H
14 
15 /* ZigBee NWK FCF fields */
16 #define ZBEE_NWK_FCF_FRAME_TYPE 0x0003
17 #define ZBEE_NWK_FCF_VERSION 0x003C
18 #define ZBEE_NWK_FCF_DISCOVER_ROUTE 0x00C0
19 #define ZBEE_NWK_FCF_MULTICAST 0x0100 /* ZigBee 2006 and Later */
20 #define ZBEE_NWK_FCF_SECURITY 0x0200
21 #define ZBEE_NWK_FCF_SOURCE_ROUTE 0x0400 /* ZigBee 2006 and Later */
22 #define ZBEE_NWK_FCF_EXT_DEST 0x0800 /* ZigBee 2006 and Later */
23 #define ZBEE_NWK_FCF_EXT_SOURCE 0x1000 /* ZigBee 2006 and Later */
24 #define ZBEE_NWK_FCF_END_DEVICE_INITIATOR 0x2000 /* ZigBee PRO r21 */
25 
26 /* ZigBee NWK FCF Frame Types */
27 #define ZBEE_NWK_FCF_DATA 0x0000
28 #define ZBEE_NWK_FCF_CMD 0x0001
29 #define ZBEE_NWK_FCF_INTERPAN 0x0003
30 
31 /* ZigBee NWK Discovery Modes. */
32 #define ZBEE_NWK_FCF_DISCOVERY_SUPPRESS 0x0000
33 #define ZBEE_NWK_FCF_DISCOVERY_ENABLE 0x0001
34 #define ZBEE_NWK_FCF_DISCOVERY_FORCE 0x0003
35 
36 /* Multicast Control */
37 #define ZBEE_NWK_MCAST_MODE 0x03 /* ZigBee 2006 and later */
38 #define ZBEE_NWK_MCAST_RADIUS 0x1c /* ZigBee 2006 and later */
39 #define ZBEE_NWK_MCAST_MAX_RADIUS 0xe0 /* ZigBee 2006 and later */
40 #define ZBEE_NWK_MCAST_MODE_NONMEMBER 0x00 /* ZigBee 2006 and later */
41 #define ZBEE_NWK_MCAST_MODE_MEMBER 0x01 /* ZigBee 2006 and later */
42 
43 /* ZigBee NWK Command Types */
44 #define ZBEE_NWK_CMD_ROUTE_REQ 0x01
45 #define ZBEE_NWK_CMD_ROUTE_REPLY 0x02
46 #define ZBEE_NWK_CMD_NWK_STATUS 0x03
47 #define ZBEE_NWK_CMD_LEAVE 0x04 /* ZigBee 2006 and Later */
48 #define ZBEE_NWK_CMD_ROUTE_RECORD 0x05 /* ZigBee 2006 and later */
49 #define ZBEE_NWK_CMD_REJOIN_REQ 0x06 /* ZigBee 2006 and later */
50 #define ZBEE_NWK_CMD_REJOIN_RESP 0x07 /* ZigBee 2006 and later */
51 #define ZBEE_NWK_CMD_LINK_STATUS 0x08 /* ZigBee 2007 and later */
52 #define ZBEE_NWK_CMD_NWK_REPORT 0x09 /* ZigBee 2007 and later */
53 #define ZBEE_NWK_CMD_NWK_UPDATE 0x0a /* ZigBee 2007 and later */
54 #define ZBEE_NWK_CMD_ED_TIMEOUT_REQUEST 0x0b /* r21 */
55 #define ZBEE_NWK_CMD_ED_TIMEOUT_RESPONSE 0x0c /* r21 */
56 #define ZBEE_NWK_CMD_LINK_PWR_DELTA 0x0d /* r22 */
57 #define ZBEE_NWK_CMD_COMMISSIONING_REQUEST 0x0e /* r23 */
58 #define ZBEE_NWK_CMD_COMMISSIONING_RESPONSE 0x0f /* r23 */
59 
60 /* ZigBee NWK Route Options Flags */
61 #define ZBEE_NWK_CMD_ROUTE_OPTION_REPAIR 0x80 /* ZigBee 2004 only. */
62 #define ZBEE_NWK_CMD_ROUTE_OPTION_MCAST 0x40 /* ZigBee 2006 and later */
63 #define ZBEE_NWK_CMD_ROUTE_OPTION_DEST_EXT 0x20 /* ZigBee 2007 and later (route request only). */
64 #define ZBEE_NWK_CMD_ROUTE_OPTION_MANY_MASK 0x18 /* ZigBee 2007 and later (route request only). */
65 #define ZBEE_NWK_CMD_ROUTE_OPTION_RESP_EXT 0x20 /* ZigBee 2007 and layer (route reply only). */
66 #define ZBEE_NWK_CMD_ROUTE_OPTION_ORIG_EXT 0x10 /* ZigBee 2007 and later (route reply only). */
67 
68 /* Many-to-One modes, ZigBee 2007 and later (route request only). */
69 #define ZBEE_NWK_CMD_ROUTE_OPTION_MANY_NONE 0x00
70 #define ZBEE_NWK_CMD_ROUTE_OPTION_MANY_REC 0x01
71 #define ZBEE_NWK_CMD_ROUTE_OPTION_MANY_NOREC 0x02
72 
73 /* ZigBee NWK Leave Options Flags */
74 #define ZBEE_NWK_CMD_LEAVE_OPTION_CHILDREN 0x80
75 #define ZBEE_NWK_CMD_LEAVE_OPTION_REQUEST 0x40
76 #define ZBEE_NWK_CMD_LEAVE_OPTION_REJOIN 0x20
77 
78 /* ZigBee NWK Link Status Options. */
79 #define ZBEE_NWK_CMD_LINK_OPTION_LAST_FRAME 0x40
80 #define ZBEE_NWK_CMD_LINK_OPTION_FIRST_FRAME 0x20
81 #define ZBEE_NWK_CMD_LINK_OPTION_COUNT_MASK 0x1f
82 
83 /* ZigBee NWK Link Status cost fields. */
84 #define ZBEE_NWK_CMD_LINK_INCOMMING_COST_MASK 0x07
85 #define ZBEE_NWK_CMD_LINK_OUTGOING_COST_MASK 0x70
86 
87 /* ZigBee NWK Report Options. */
88 #define ZBEE_NWK_CMD_NWK_REPORT_COUNT_MASK 0x1f
89 #define ZBEE_NWK_CMD_NWK_REPORT_ID_MASK 0xe0
90 #define ZBEE_NWK_CMD_NWK_REPORT_ID_PAN_CONFLICT 0x00
91 #define ZBEE_NWK_CMD_NWK_REPORT_ID_ZBOSS_KEY_TRACE 6
92 
93 /* ZigBee NWK Update Options. */
94 #define ZBEE_NWK_CMD_NWK_UPDATE_COUNT_MASK 0x1f
95 #define ZBEE_NWK_CMD_NWK_UPDATE_ID_MASK 0xe0
96 #define ZBEE_NWK_CMD_NWK_UPDATE_ID_PAN_UPDATE 0x00
97 
98 /* ZigBee NWK Values of the Parent Information Bitmask (Table 3.47) */
99 #define ZBEE_NWK_CMD_ED_TIMEO_RSP_PRNT_INFO_MAC_DATA_POLL_KEEPAL_SUPP 0x01
100 #define ZBEE_NWK_CMD_ED_TIMEO_RSP_PRNT_INFO_ED_TIMOU_REQ_KEEPAL_SUPP 0x02
101 #define ZBEE_NWK_CMD_ED_TIMEO_RSP_PRNT_INFO_PWR_NEG_SUPP 0x04
102 
103 /* ZigBee NWK Link Power Delta Options */
104 #define ZBEE_NWK_CMD_NWK_LINK_PWR_DELTA_TYPE_MASK 0x03
105 
106 /* Network Status Code Definitions. */
107 #define ZBEE_NWK_STATUS_NO_ROUTE_AVAIL 0x00
108 #define ZBEE_NWK_STATUS_TREE_LINK_FAIL 0x01
109 #define ZBEE_NWK_STATUS_NON_TREE_LINK_FAIL 0x02
110 #define ZBEE_NWK_STATUS_LOW_BATTERY 0x03
111 #define ZBEE_NWK_STATUS_NO_ROUTING 0x04
112 #define ZBEE_NWK_STATUS_NO_INDIRECT 0x05
113 #define ZBEE_NWK_STATUS_INDIRECT_EXPIRE 0x06
114 #define ZBEE_NWK_STATUS_DEVICE_UNAVAIL 0x07
115 #define ZBEE_NWK_STATUS_ADDR_UNAVAIL 0x08
116 #define ZBEE_NWK_STATUS_PARENT_LINK_FAIL 0x09
117 #define ZBEE_NWK_STATUS_VALIDATE_ROUTE 0x0a
118 #define ZBEE_NWK_STATUS_SOURCE_ROUTE_FAIL 0x0b
119 #define ZBEE_NWK_STATUS_MANY_TO_ONE_FAIL 0x0c
120 #define ZBEE_NWK_STATUS_ADDRESS_CONFLICT 0x0d
121 #define ZBEE_NWK_STATUS_VERIFY_ADDRESS 0x0e
122 #define ZBEE_NWK_STATUS_PANID_UPDATE 0x0f
123 #define ZBEE_NWK_STATUS_ADDRESS_UPDATE 0x10
124 #define ZBEE_NWK_STATUS_BAD_FRAME_COUNTER 0x11
125 #define ZBEE_NWK_STATUS_BAD_KEY_SEQNO 0x12
126 #define ZBEE_NWK_STATUS_UNKNOWN_COMMAND 0x13
127 
128 #define ZBEE_SEC_CONST_KEYSIZE 16
129 
130 typedef struct{
131  gboolean security;
132  gboolean discovery;
133  gboolean multicast; /* ZigBee 2006 and Later */
134  gboolean route; /* ZigBee 2006 and Later */
135  gboolean ext_dst; /* ZigBee 2006 and Later */
136  gboolean ext_src; /* ZigBee 2006 and Later */
137  guint16 type;
138  guint8 version;
139 
140  guint16 dst;
141  guint16 src;
142  guint64 dst64; /* ZigBee 2006 and Later */
143  guint64 src64; /* ZigBee 2006 and Later */
144  guint8 radius;
145  guint8 seqno;
146 
147  guint8 mcast_mode; /* ZigBee 2006 and Later */
148  guint8 mcast_radius; /* ZigBee 2006 and Later */
149  guint8 mcast_max_radius; /* ZigBee 2006 and Later */
150 
151  guint8 payload_offset;
152  guint8 payload_len;
153 
154  guint16 cluster_id; /* an application-specific message identifier that
155  * happens to be included in the transport (APS) layer header.
156  */
157 
158  void *private_data; /* For ZigBee (sub)dissector specific data */
160 
161 /* Key used for link key hash table. */
162 typedef struct {
163  guint64 lt_addr64; /* lesser than address */
164  guint64 gt_addr64; /* greater than address */
166 
167 
168 typedef enum
169 {
170  ZBEE_APS_NO_RELAY,
171  ZBEE_APS_RELAY_UPSTREAM,
172  ZBEE_APS_RELAY_DOWNSTREAM
173 } aps_relay_type_t;
174 
175 /* Values in the key rings. */
176 typedef struct {
177  guint frame_num;
178  gchar *label;
179  guint8 key[ZBEE_SEC_CONST_KEYSIZE];
180 } key_record_t;
181 
182 typedef struct {
183  gint src_pan; /* source pan */
184  gint src; /* short source address from nwk */
185 #if 0
186  gint ieee_src; /* short source address from mac */
187 #endif
188  ieee802154_map_rec *map_rec; /* extended src from nwk */
189  key_record_t *nwk; /* Network key found for this packet */
190  key_record_t *link; /* Link key found for this packet */
191  aps_relay_type_t relay_type ; /* Is it upstream/downstream relayed packet? */
192  guint64 joiner_addr64; /* long address from Relay frame */
194 
195 extern ieee802154_map_tab_t zbee_nwk_map;
196 extern GHashTable *zbee_table_nwk_keyring;
197 extern GHashTable *zbee_table_link_keyring;
198 
199 /* Key Types */
200 #define ZBEE_USER_KEY 0x01
201 
202 /* ZigBee PRO beacons */
203 #define ZBEE_NWK_BEACON_PROTOCOL_ID 0x00
204 #define ZBEE_NWK_BEACON_STACK_PROFILE 0x000f
205 #define ZBEE_NWK_BEACON_PROTOCOL_VERSION 0x00f0
206 #define ZBEE_NWK_BEACON_ROUTER_CAPACITY 0x0400
207 #define ZBEE_NWK_BEACON_NETWORK_DEPTH 0x7800
208 #define ZBEE_NWK_BEACON_END_DEVICE_CAPACITY 0x8000
209 #define ZBEE_NWK_BEACON_LENGTH 15
210 
211 /* ZigBee IP beacons */
212 #define ZBEE_IP_BEACON_PROTOCOL_ID 0x02
213 #define ZBEE_IP_BEACON_ALLOW_JOIN 0x01
214 #define ZBEE_IP_BEACON_ROUTER_CAPACITY 0x02
215 #define ZBEE_IP_BEACON_HOST_CAPACITY 0x04
216 #define ZBEE_IP_BEACON_UNSECURE 0x80 /* Undocumented bit for test networks. */
217 
218 #define ZBEE_IP_BEACON_TLV_LENGTH_MASK 0x0f
219 #define ZBEE_IP_BEACON_TLV_TYPE_MASK 0xf0
220 #define ZBEE_IP_BEACON_TLV_TYPE_LFDI 0x0
221 
222 
223 #endif /* PACKET_ZBEE_NWK_H */
224 
225 /*
226  * Editor modelines - https://www.wireshark.org/tools/modelines.html
227  *
228  * Local variables:
229  * c-basic-offset: 4
230  * tab-width: 8
231  * indent-tabs-mode: nil
232  * End:
233  *
234  * vi: set shiftwidth=4 tabstop=8 expandtab:
235  * :indentSize=4:tabSize=8:noTabs=true:
236  */
Definition: packet-ieee802154.h:464
Definition: packet-ieee802154.h:447
Definition: packet-zbee-nwk.h:176
Definition: packet-zbee-nwk.h:182
Definition: packet-zbee-nwk.h:130