Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-zbee-nwk.h
1/* packet-zbee-nwk.h
2 * Dissector routines for the ZigBee Network Layer (NWK)
3 * By Owen Kirby <[email protected]>
4 * Copyright 2009 Exegin Technologies Limited
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <[email protected]>
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
130typedef struct{
131 bool security;
132 bool discovery;
133 bool multicast; /* ZigBee 2006 and Later */
134 bool route; /* ZigBee 2006 and Later */
135 bool ext_dst; /* ZigBee 2006 and Later */
136 bool ext_src; /* ZigBee 2006 and Later */
137 uint16_t type;
138 uint8_t version;
139
140 uint16_t dst;
141 uint16_t src;
142 uint64_t dst64; /* ZigBee 2006 and Later */
143 uint64_t src64; /* ZigBee 2006 and Later */
144 uint8_t radius;
145 uint8_t seqno;
146
147 uint8_t mcast_mode; /* ZigBee 2006 and Later */
148 uint8_t mcast_radius; /* ZigBee 2006 and Later */
149 uint8_t mcast_max_radius; /* ZigBee 2006 and Later */
150
151 uint8_t payload_offset;
152 uint8_t payload_len;
153
154 uint16_t 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. */
162typedef struct {
163 uint64_t lt_addr64; /* lesser than address */
164 uint64_t gt_addr64; /* greater than address */
166
167
168typedef 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. */
176typedef struct {
177 unsigned frame_num;
178 char *label;
179 uint8_t key[ZBEE_SEC_CONST_KEYSIZE];
181
182typedef struct {
183 int src_pan; /* source pan */
184 int src; /* short source address from nwk */
185#if 0
186 int 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 uint64_t joiner_addr64; /* long address from Relay frame */
194
195extern ieee802154_map_tab_t zbee_nwk_map;
196extern GHashTable *zbee_table_nwk_keyring;
197extern 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