MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-zbee-nwk.h
blobdb08efd5d276a6e0d2b605291fd2e2f9859967d4
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
6 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #ifndef PACKET_ZBEE_NWK_H
27 #define PACKET_ZBEE_NWK_H
29 /* ZigBee NWK FCF fields */
30 #define ZBEE_NWK_FCF_FRAME_TYPE 0x0003
31 #define ZBEE_NWK_FCF_VERSION 0x003C
32 #define ZBEE_NWK_FCF_DISCOVER_ROUTE 0x00C0
33 #define ZBEE_NWK_FCF_MULTICAST 0x0100 /* ZigBee 2006 and Later */
34 #define ZBEE_NWK_FCF_SECURITY 0x0200
35 #define ZBEE_NWK_FCF_SOURCE_ROUTE 0x0400 /* ZigBee 2006 and Later */
36 #define ZBEE_NWK_FCF_EXT_DEST 0x0800 /* ZigBee 2006 and Later */
37 #define ZBEE_NWK_FCF_EXT_SOURCE 0x1000 /* ZigBee 2006 and Later */
39 /* ZigBee NWK FCF Frame Types */
40 #define ZBEE_NWK_FCF_DATA 0x0000
41 #define ZBEE_NWK_FCF_CMD 0x0001
43 /* ZigBee NWK Discovery Modes. */
44 #define ZBEE_NWK_FCF_DISCOVERY_SUPPRESS 0x0000
45 #define ZBEE_NWK_FCF_DISCOVERY_ENABLE 0x0001
46 #define ZBEE_NWK_FCF_DISCOVERY_FORCE 0x0003
48 /* Multicast Control */
49 #define ZBEE_NWK_MCAST_MODE 0x03 /* ZigBee 2006 and later */
50 #define ZBEE_NWK_MCAST_RADIUS 0x1c /* ZigBee 2006 and later */
51 #define ZBEE_NWK_MCAST_MAX_RADIUS 0xe0 /* ZigBee 2006 and later */
52 #define ZBEE_NWK_MCAST_MODE_NONMEMBER 0x00 /* ZigBee 2006 and later */
53 #define ZBEE_NWK_MCAST_MODE_MEMBER 0x01 /* ZigBee 2006 and later */
55 /* ZigBee NWK Command Types */
56 #define ZBEE_NWK_CMD_ROUTE_REQ 0x01
57 #define ZBEE_NWK_CMD_ROUTE_REPLY 0x02
58 #define ZBEE_NWK_CMD_NWK_STATUS 0x03
59 #define ZBEE_NWK_CMD_LEAVE 0x04 /* ZigBee 2006 and Later */
60 #define ZBEE_NWK_CMD_ROUTE_RECORD 0x05 /* ZigBee 2006 and later */
61 #define ZBEE_NWK_CMD_REJOIN_REQ 0x06 /* ZigBee 2006 and later */
62 #define ZBEE_NWK_CMD_REJOIN_RESP 0x07 /* ZigBee 2006 and later */
63 #define ZBEE_NWK_CMD_LINK_STATUS 0x08 /* ZigBee 2007 and later */
64 #define ZBEE_NWK_CMD_NWK_REPORT 0x09 /* ZigBee 2007 and later */
65 #define ZBEE_NWK_CMD_NWK_UPDATE 0x0a /* ZigBee 2007 and later */
67 /* ZigBee NWK Route Options Flags */
68 #define ZBEE_NWK_CMD_ROUTE_OPTION_REPAIR 0x80 /* ZigBee 2004 only. */
69 #define ZBEE_NWK_CMD_ROUTE_OPTION_MCAST 0x40 /* ZigBee 2006 and later */
70 #define ZBEE_NWK_CMD_ROUTE_OPTION_DEST_EXT 0x20 /* ZigBee 2007 and later (route request only). */
71 #define ZBEE_NWK_CMD_ROUTE_OPTION_MANY_MASK 0x18 /* ZigBee 2007 and later (route request only). */
72 #define ZBEE_NWK_CMD_ROUTE_OPTION_RESP_EXT 0x20 /* ZigBee 2007 and layer (route reply only). */
73 #define ZBEE_NWK_CMD_ROUTE_OPTION_ORIG_EXT 0x10 /* ZigBee 2007 and later (route reply only). */
75 /* Many-to-One modes, ZigBee 2007 and later (route request only). */
76 #define ZBEE_NWK_CMD_ROUTE_OPTION_MANY_NONE 0x00
77 #define ZBEE_NWK_CMD_ROUTE_OPTION_MANY_REC 0x01
78 #define ZBEE_NWK_CMD_ROUTE_OPTION_MANY_NOREC 0x02
80 /* ZigBee NWK Leave Options Flags */
81 #define ZBEE_NWK_CMD_LEAVE_OPTION_CHILDREN 0x80
82 #define ZBEE_NWK_CMD_LEAVE_OPTION_REQUEST 0x40
83 #define ZBEE_NWK_CMD_LEAVE_OPTION_REJOIN 0x20
85 /* ZigBee NWK Link Status Options. */
86 #define ZBEE_NWK_CMD_LINK_OPTION_LAST_FRAME 0x40
87 #define ZBEE_NWK_CMD_LINK_OPTION_FIRST_FRAME 0x20
88 #define ZBEE_NWK_CMD_LINK_OPTION_COUNT_MASK 0x1f
90 /* ZigBee NWK Link Status cost fields. */
91 #define ZBEE_NWK_CMD_LINK_INCOMMING_COST_MASK 0x07
92 #define ZBEE_NWK_CMD_LINK_OUTGOING_COST_MASK 0x70
94 /* ZigBee NWK Report Options. */
95 #define ZBEE_NWK_CMD_NWK_REPORT_COUNT_MASK 0x1f
96 #define ZBEE_NWK_CMD_NWK_REPORT_ID_MASK 0xe0
97 #define ZBEE_NWK_CMD_NWK_REPORT_ID_PAN_CONFLICT 0x00
99 /* ZigBee NWK Update Options. */
100 #define ZBEE_NWK_CMD_NWK_UPDATE_COUNT_MASK 0x1f
101 #define ZBEE_NWK_CMD_NWK_UPDATE_ID_MASK 0xe0
102 #define ZBEE_NWK_CMD_NWK_UPDATE_ID_PAN_UPDATE 0x00
104 /* Network Status Code Definitions. */
105 #define ZBEE_NWK_STATUS_NO_ROUTE_AVAIL 0x00
106 #define ZBEE_NWK_STATUS_TREE_LINK_FAIL 0x01
107 #define ZBEE_NWK_STATUS_NON_TREE_LINK_FAIL 0x02
108 #define ZBEE_NWK_STATUS_LOW_BATTERY 0x03
109 #define ZBEE_NWK_STATUS_NO_ROUTING 0x04
110 #define ZBEE_NWK_STATUS_NO_INDIRECT 0x05
111 #define ZBEE_NWK_STATUS_INDIRECT_EXPIRE 0x06
112 #define ZBEE_NWK_STATUS_DEVICE_UNAVAIL 0x07
113 #define ZBEE_NWK_STATUS_ADDR_UNAVAIL 0x08
114 #define ZBEE_NWK_STATUS_PARENT_LINK_FAIL 0x09
115 #define ZBEE_NWK_STATUS_VALIDATE_ROUTE 0x0a
116 #define ZBEE_NWK_STATUS_SOURCE_ROUTE_FAIL 0x0b
117 #define ZBEE_NWK_STATUS_MANY_TO_ONE_FAIL 0x0c
118 #define ZBEE_NWK_STATUS_ADDRESS_CONFLICT 0x0d
119 #define ZBEE_NWK_STATUS_VERIFY_ADDRESS 0x0e
120 #define ZBEE_NWK_STATUS_PANID_UPDATE 0x0f
121 #define ZBEE_NWK_STATUS_ADDRESS_UPDATE 0x10
122 #define ZBEE_NWK_STATUS_BAD_FRAME_COUNTER 0x11
123 #define ZBEE_NWK_STATUS_BAD_KEY_SEQNO 0x12
125 #define ZBEE_SEC_CONST_KEYSIZE 16
127 typedef struct{
128 gboolean security;
129 gboolean discovery;
130 gboolean multicast; /* ZigBee 2006 and Later */
131 gboolean route; /* ZigBee 2006 and Later */
132 gboolean ext_dst; /* ZigBee 2006 and Later */
133 gboolean ext_src; /* ZigBee 2006 and Later */
134 guint16 type;
135 guint8 version;
137 guint16 dst;
138 guint16 src;
139 guint64 dst64; /* ZigBee 2006 and Later */
140 guint64 src64; /* ZigBee 2006 and Later */
141 guint8 radius;
142 guint8 seqno;
144 guint8 mcast_mode; /* ZigBee 2006 and Later */
145 guint8 mcast_radius; /* ZigBee 2006 and Later */
146 guint8 mcast_max_radius; /* ZigBee 2006 and Later */
148 guint8 payload_offset;
149 guint8 payload_len;
151 guint16 cluster_id; /* an application-specific message identifier that
152 * happens to be included in the transport (APS) layer header.
155 void *private_data; /* For ZigBee (sub)dissector specific data */
156 } zbee_nwk_packet;
158 /* Key used for link key hash table. */
159 typedef struct {
160 guint64 lt_addr64; /* lesser than address */
161 guint64 gt_addr64; /* greater than address */
162 } table_link_key_t;
164 /* Values in the key rings. */
165 typedef struct {
166 guint frame_num;
167 gchar *label;
168 guint8 key[ZBEE_SEC_CONST_KEYSIZE];
169 } key_record_t;
171 typedef struct {
172 gint src_pan; /* source pan */
173 gint src; /* short source address from nwk */
174 #if 0
175 gint ieee_src; /* short source address from mac */
176 #endif
177 ieee802154_map_rec *map_rec; /* extended src from nwk */
178 key_record_t *nwk; /* Network key found for this packet */
179 key_record_t *link; /* Link key found for this packet */
180 } zbee_nwk_hints_t;
182 extern ieee802154_map_tab_t zbee_nwk_map;
183 extern GHashTable *zbee_table_nwk_keyring;
184 extern GHashTable *zbee_table_link_keyring;
186 /* Key Types */
187 #define ZBEE_USER_KEY 0x01
189 /* Beacon Definitions. */
190 #define ZBEE_NWK_BEACON_PROCOL_ID 0x00
191 #define ZBEE_NWK_BEACON_STACK_PROFILE 0x0f
192 #define ZBEE_NWK_BEACON_PROTOCOL_VERSION 0xf0
193 #define ZBEE_NWK_BEACON_ROUTER_CAPACITY 0x04
194 #define ZBEE_NWK_BEACON_NETWORK_DEPTH 0x78
195 #define ZBEE_NWK_BEACON_END_DEVICE_CAPACITY 0x80
197 #endif /* PACKET_ZBEE_NWK_H */