2 * Routines for BACnet (NPDU) dissection
3 * Copyright 2001, Hartmut Mueller <hartmut@abmlinux.org>, FH Dortmund
4 * Enhanced by Steve Karg, 2005, <skarg@users.sourceforge.net>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * Copied from README.developer,v 1.23
12 * SPDX-License-Identifier: GPL-2.0-or-later
17 #include <epan/packet.h>
19 #include <epan/llcsaps.h>
20 #include "packet-bacnet.h"
22 void proto_register_bacnet(void);
23 void proto_reg_handoff_bacnet(void);
25 static dissector_handle_t bacapp_handle
;
26 /* Defined to allow vendor identifier registration of private transfer dissectors */
27 static dissector_table_t bacnet_dissector_table
;
29 static const range_string bacnet_msgtype_rvals
[] = {
30 { 0x00, 0x00, "Who-Is-Router-To-Network" },
31 { 0x01, 0x01, "I-Am-Router-To-Network" },
32 { 0x02, 0x02, "I-Could-Be-Router-To-Network" },
33 { 0x03, 0x03, "Reject-Message-To-Network" },
34 { 0x04, 0x04, "Router-Busy-To-Network" },
35 { 0x05, 0x05, "Router-Available-To-Network" },
36 { 0x06, 0x06, "Initialize-Routing-Table" },
37 { 0x07, 0x07, "Initialize-Routing-Table-Ack" },
38 { 0x08, 0x08, "Establish-Connection-To-Network" },
39 { 0x09, 0x09, "Disconnect-Connection-To-Network" },
40 { 0x0A, 0x0A, "Challenge-Request" },
41 { 0x0B, 0x0B, "Security-Payload" },
42 { 0x0C, 0x0C, "Security-Response" },
43 { 0x0D, 0x0D, "Request-Key-Update" },
44 { 0x0E, 0x0E, "Update-Keyset" },
45 { 0x0F, 0x0F, "Update-distribution-Key" },
46 { 0x10, 0x10, "Request-Masterkey" },
47 { 0x11, 0x11, "Set-Masterkey" },
48 { 0x12, 0x12, "What-Is-Networknumber" },
49 { 0x13, 0x13, "Networknumber-Is" },
50 { 0x14, 0x7F, "Reserved for Use by ASHRAE" },
51 { 0x80, 0xFF, "Vendor Proprietary Message" },
55 static const range_string bacnet_rejectreason_name_rvals
[] = {
56 { 0x00, 0x00, "Other error." },
57 { 0x01, 0x01, "The router is not directly connected to DNET and cannot find a router to DNET on any directly connected network using Who-Is-Router-To-Network messages." },
58 { 0x02, 0x02, "The router is busy and unable to accept messages for the specified DNET at the present time." },
59 { 0x03, 0x03, "It is an unknown network layer message type." },
60 { 0x04, 0x04, "The message is too long to be routed to this DNET." },
61 { 0x05, 0x05, "The router is no longer directly connected to DNET but can reconnect if requested." },
62 { 0x06, 0x06, "The router is no longer directly connected to DNET and cannot reconnect even if requested." },
63 { 0x07, 0xFF, "Invalid Rejection Reason." },
67 /* Network Layer Control Information */
68 #define BAC_CONTROL_NET 0x80
69 #define BAC_CONTROL_RES1 0x40
70 #define BAC_CONTROL_DEST 0x20
71 #define BAC_CONTROL_RES2 0x10
72 #define BAC_CONTROL_SRC 0x08
73 #define BAC_CONTROL_EXPECT 0x04
74 #define BAC_CONTROL_PRIO_HIGH 0x02
75 #define BAC_CONTROL_PRIO_LOW 0x01
77 /* Network Layer Wrapper Control Information */
78 #define BAC_WRAPPER_CONTROL_NET 0x80
79 #define BAC_WRAPPER_MSG_ENCRYPED 0x40
80 #define BAC_WRAPPER_RESERVED 0x20
81 #define BAC_WRAPPER_AUTHD_PRESENT 0x10
82 #define BAC_WRAPPER_DO_NOT_UNWRAP 0x08
83 #define BAC_WRAPPER_DO_NOT_DECRPT 0x04
84 #define BAC_WRAPPER_NO_TRUST_SRC 0x02
85 #define BAC_WRAPPER_SECURE_BY_RTR 0x01
87 /* Network Layer Update Keyset Control Information */
88 #define BAC_UPDATE_CONTROL_SET1_TIMES_PRESENT 0x80
89 #define BAC_UPDATE_CONTROL_SET1_PARAMS_PRESENT 0x40
90 #define BAC_UPDATE_CONTROL_CLEAR_SET1 0x20
91 #define BAC_UPDATE_CONTROL_SET2_TIMES_PRESENT 0x10
92 #define BAC_UPDATE_CONTROL_SET2_PARAMS_PRESENT 0x08
93 #define BAC_UPDATE_CONTROL_CLEAR_SET2 0x04
94 #define BAC_UPDATE_CONTROL_MORE_FOLLOWS 0x02
95 #define BAC_UPDATE_CONTROL_REMOVE_KEYS 0x01
97 /* Network Layer Message Types */
98 #define BAC_NET_WHO_R 0x00
99 #define BAC_NET_IAM_R 0x01
100 #define BAC_NET_ICB_R 0x02
101 #define BAC_NET_REJ 0x03
102 #define BAC_NET_R_BUSY 0x04
103 #define BAC_NET_R_AVA 0x05
104 #define BAC_NET_INIT_RTAB 0x06
105 #define BAC_NET_INIT_RTAB_ACK 0x07
106 #define BAC_NET_EST_CON 0x08
107 #define BAC_NET_DISC_CON 0x09
108 #define BAC_NET_CHALL_REQ 0x0A
109 #define BAC_NET_SECUR_PAY 0x0B
110 #define BAC_NET_SECUR_RESP 0x0C
111 #define BAC_NET_REQ_KEY_UP 0x0D
112 #define BAC_NET_UPD_KEYSET 0x0E
113 #define BAC_NET_UPD_DKEY 0x0F
114 #define BAC_NET_REQ_MKEY 0x10
115 #define BAC_NET_SET_MKEY 0x11
116 #define BAC_NET_WHAT_NETNR 0x12
117 #define BAC_NET_NETNR_IS 0x13
120 static const true_false_string control_net_set_high
= {
121 "network layer message, message type field present.",
122 "BACnet APDU, message type field absent."
125 static const true_false_string control_res_high
= {
126 "Shall be zero, but is one.",
127 "Shall be zero and is zero."
129 static const true_false_string control_dest_high
= {
130 "DNET, DLEN and Hop Count present. If DLEN=0: broadcast, dest. address field absent.",
131 "DNET, DLEN, DADR and Hop Count absent."
134 static const true_false_string control_src_high
= {
135 "SNET, SLEN and SADR present, SLEN=0 invalid, SLEN specifies length of SADR",
136 "SNET, SLEN and SADR absent"
139 static const true_false_string control_expect_high
= {
140 "BACnet-Confirmed-Request-PDU, a segment of BACnet-ComplexACK-PDU or Network Message expecting a reply present.",
141 "Other than a BACnet-Confirmed-Request-PDU, segment of BACnet-ComplexACK-PDU or network layer message expecting a reply present."
144 static const true_false_string control_prio_high_high
= {
145 "Life Safety or Critical Equipment message.",
146 "Not a Life Safety or Critical Equipment message."
149 static const true_false_string control_prio_low_high
= {
154 static const true_false_string wrapper_control_msg_net
= {
155 "Message is networklayer message",
156 "Message is applicationlayer message"
159 static const true_false_string wrapper_control_msg_crypted
= {
160 "Message is encrypted message",
161 "Message is not encrypted message"
164 static const true_false_string wrapper_control_reserved
= {
165 "Shall be zero, but is one.",
166 "Shall be zero and is zero."
169 static const true_false_string wrapper_control_do_not_unwrap
= {
170 "Do not unwrap message",
171 "Message may be unwrapped"
174 static const true_false_string wrapper_control_do_not_decrypt
= {
175 "Do not decrypt message",
176 "Message may be decrypted"
179 static const true_false_string wrapper_control_trusted_source
= {
180 "Message received from trusted source",
181 "Message received from untrusted source"
184 static const true_false_string security_msg_challenged
= {
185 "Message is challenged",
186 "Message is not challenged"
189 static const true_false_string update_key_control_remove_keys
= {
194 static const true_false_string tfs_clear_do_not_clear
= {
199 static int proto_bacnet
;
200 static int hf_bacnet_version
;
201 static int hf_bacnet_control
;
202 static int hf_bacnet_control_net
;
203 static int hf_bacnet_control_res1
;
204 static int hf_bacnet_control_dest
;
205 static int hf_bacnet_control_res2
;
206 static int hf_bacnet_control_src
;
207 static int hf_bacnet_control_expect
;
208 static int hf_bacnet_control_prio_high
;
209 static int hf_bacnet_control_prio_low
;
210 static int hf_bacnet_dnet
;
211 static int hf_bacnet_dlen
;
212 static int hf_bacnet_dadr_eth
;
213 static int hf_bacnet_dadr_mstp
;
214 static int hf_bacnet_dadr_tmp
;
215 static int hf_bacnet_snet
;
216 static int hf_bacnet_slen
;
217 static int hf_bacnet_sadr_eth
;
218 static int hf_bacnet_sadr_mstp
;
219 static int hf_bacnet_sadr_tmp
;
220 static int hf_bacnet_hopc
;
221 static int hf_bacnet_mesgtyp
;
222 static int hf_bacnet_vendor
;
223 static int hf_bacnet_perf
;
224 static int hf_bacnet_rejectreason
;
225 static int hf_bacnet_rportnum
;
226 static int hf_bacnet_portid
;
227 static int hf_bacnet_pinfo
;
228 static int hf_bacnet_pinfolen
;
229 static int hf_bacnet_term_time_value
;
230 static int hf_bacnet_netno_status
;
232 static int hf_bacnet_wrapper_control
;
233 static int hf_bacnet_wrapper_control_secured_by_router
;
234 static int hf_bacnet_wrapper_control_non_trusted_source
;
235 static int hf_bacnet_wrapper_control_do_not_decrypt
;
236 static int hf_bacnet_wrapper_control_do_not_unwrap
;
237 static int hf_bacnet_wrapper_control_auth_data_present
;
238 static int hf_bacnet_wrapper_control_reserved
;
239 static int hf_bacnet_wrapper_control_msg_is_encrypted
;
240 static int hf_bacnet_wrapper_control_msg_is_networklayer
;
241 static int hf_bacnet_wrapper_key_revision
;
242 static int hf_bacnet_wrapper_key_identifier
;
243 static int hf_bacnet_wrapper_src_dev_instance
;
244 static int hf_bacnet_wrapper_message_id
;
245 static int hf_bacnet_wrapper_time_stamp
;
246 static int hf_bacnet_wrapper_dst_dev_instance
;
247 static int hf_bacnet_wrapper_dnet
;
248 static int hf_bacnet_wrapper_dlen
;
249 static int hf_bacnet_wrapper_dadr
;
250 static int hf_bacnet_wrapper_snet
;
251 static int hf_bacnet_wrapper_slen
;
252 static int hf_bacnet_wrapper_sadr
;
253 static int hf_bacnet_wrapper_auth_mech
;
254 static int hf_bacnet_wrapper_auth_usr_id
;
255 static int hf_bacnet_wrapper_auth_usr_role
;
256 static int hf_bacnet_wrapper_auth_len
;
257 static int hf_bacnet_wrapper_auth_data
;
258 static int hf_bacnet_wrapper_signature
;
259 static int hf_bacnet_wrapper_encrypted_data
;
260 static int hf_bacnet_msg_is_challenged
;
261 static int hf_bacnet_security_original_message_id
;
262 static int hf_bacnet_security_original_time_stamp
;
263 static int hf_bacnet_security_msg_len
;
264 static int hf_bacnet_security_response_code
;
265 static int hf_bacnet_security_response_expected_time_stamp
;
266 static int hf_bacnet_security_response_key_algo
;
267 static int hf_bacnet_security_response_key_id
;
268 static int hf_bacnet_security_response_original_authentication_mech
;
269 static int hf_bacnet_security_response_vendor_id
;
270 static int hf_bacnet_security_response_key_revision
;
271 static int hf_bacnet_security_response_number_keys
;
272 static int hf_bacnet_security_set1_key_reveision
;
273 static int hf_bacnet_security_set1_activation_time_stamp
;
274 static int hf_bacnet_security_set1_expiration_time_stamp
;
275 static int hf_bacnet_security_set1_key_algo
;
276 static int hf_bacnet_security_set1_key_id
;
277 static int hf_bacnet_security_set1_key_data
;
278 static int hf_bacnet_security_set2_key_reveision
;
279 static int hf_bacnet_security_set2_activation_time_stamp
;
280 static int hf_bacnet_security_set2_expiration_time_stamp
;
281 static int hf_bacnet_security_set2_key_algo
;
282 static int hf_bacnet_security_set2_key_id
;
283 static int hf_bacnet_security_set2_key_data
;
284 static int hf_bacnet_security_dist_key_revision
;
285 static int hf_bacnet_security_dist_key_algo
;
286 static int hf_bacnet_security_dist_key_id
;
287 static int hf_bacnet_security_dist_key_data
;
288 static int hf_bacnet_security_master_key_algo
;
289 static int hf_bacnet_security_master_key_id
;
290 static int hf_bacnet_security_master_key_data
;
291 static int hf_bacnet_update_control
;
292 static int hf_bacnet_update_control_remove
;
293 static int hf_bacnet_update_control_more_follows
;
294 static int hf_bacnet_update_control_clear_set2
;
295 static int hf_bacnet_update_control_set2_params_present
;
296 static int hf_bacnet_update_control_set2_times_present
;
297 static int hf_bacnet_update_control_clear_set1
;
298 static int hf_bacnet_update_control_set1_params_present
;
299 static int hf_bacnet_update_control_set1_times_present
;
301 static int ett_bacnet
;
302 static int ett_bacnet_control
;
303 static int ett_bacnet_wrapper_control
;
304 static int ett_bacnet_update_control
;
306 static dissector_handle_t bacnet_handle
;
308 static int * const control_flags
[] = {
309 &hf_bacnet_control_net
,
310 &hf_bacnet_control_res1
,
311 &hf_bacnet_control_dest
,
312 &hf_bacnet_control_res2
,
313 &hf_bacnet_control_src
,
314 &hf_bacnet_control_expect
,
315 &hf_bacnet_control_prio_high
,
316 &hf_bacnet_control_prio_low
,
320 static int * const update_control_flags
[] = {
321 &hf_bacnet_update_control_remove
,
322 &hf_bacnet_update_control_more_follows
,
323 &hf_bacnet_update_control_clear_set2
,
324 &hf_bacnet_update_control_set2_params_present
,
325 &hf_bacnet_update_control_set2_times_present
,
326 &hf_bacnet_update_control_clear_set1
,
327 &hf_bacnet_update_control_set1_params_present
,
328 &hf_bacnet_update_control_set1_times_present
,
332 static int * const wrapper_control_flags
[] = {
333 &hf_bacnet_wrapper_control_secured_by_router
,
334 &hf_bacnet_wrapper_control_non_trusted_source
,
335 &hf_bacnet_wrapper_control_do_not_decrypt
,
336 &hf_bacnet_wrapper_control_do_not_unwrap
,
337 &hf_bacnet_wrapper_control_auth_data_present
,
338 &hf_bacnet_wrapper_control_reserved
,
339 &hf_bacnet_wrapper_control_msg_is_encrypted
,
340 &hf_bacnet_wrapper_control_msg_is_networklayer
,
346 bacnet_dissect_sec_wrapper(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
,
347 int offset
, bool *pis_net_msg_flg
)
350 uint8_t bacnet_wrapper_control
;
354 /* get control octet from wrapper */
355 bacnet_wrapper_control
= tvb_get_uint8(tvb
, offset
);
357 *pis_net_msg_flg
= (bacnet_wrapper_control
& BAC_WRAPPER_CONTROL_NET
) != 0;
359 proto_tree_add_bitmask(tree
, tvb
, offset
, hf_bacnet_wrapper_control
,
360 ett_bacnet_wrapper_control
, wrapper_control_flags
, ENC_NA
);
363 proto_tree_add_item(tree
, hf_bacnet_wrapper_key_revision
,
364 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
367 proto_tree_add_item(tree
, hf_bacnet_wrapper_key_identifier
,
368 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
371 proto_tree_add_item(tree
, hf_bacnet_wrapper_src_dev_instance
,
372 tvb
, offset
, 3, ENC_BIG_ENDIAN
);
375 proto_tree_add_item(tree
, hf_bacnet_wrapper_message_id
,
376 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
379 proto_tree_add_item(tree
, hf_bacnet_wrapper_time_stamp
,
380 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
383 /* we only can use unencrypted data here */
384 if ((bacnet_wrapper_control
& BAC_WRAPPER_MSG_ENCRYPED
) == 0) {
385 proto_tree_add_item(tree
, hf_bacnet_wrapper_dst_dev_instance
,
386 tvb
, offset
, 3, ENC_BIG_ENDIAN
);
389 proto_tree_add_item(tree
, hf_bacnet_wrapper_dnet
,
390 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
393 bacnet_dlen
= tvb_get_uint8(tvb
, offset
);
394 proto_tree_add_item(tree
, hf_bacnet_wrapper_dlen
,
395 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
398 proto_tree_add_item(tree
,
399 hf_bacnet_wrapper_dadr
, tvb
, offset
,
400 bacnet_dlen
, ENC_NA
);
401 offset
+= bacnet_dlen
;
403 proto_tree_add_item(tree
, hf_bacnet_wrapper_snet
,
404 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
407 bacnet_dlen
= tvb_get_uint8(tvb
, offset
);
408 proto_tree_add_item(tree
, hf_bacnet_wrapper_slen
,
409 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
412 proto_tree_add_item(tree
,
413 hf_bacnet_wrapper_sadr
, tvb
, offset
,
414 bacnet_dlen
, ENC_NA
);
415 offset
+= bacnet_dlen
;
417 /* additional authentication data is optional */
418 if ((bacnet_wrapper_control
& BAC_WRAPPER_AUTHD_PRESENT
) != 0) {
419 bacnet_dlen
= tvb_get_uint8(tvb
, offset
);
420 proto_tree_add_item(tree
, hf_bacnet_wrapper_auth_mech
,
421 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
424 proto_tree_add_item(tree
, hf_bacnet_wrapper_auth_usr_id
,
425 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
428 proto_tree_add_item(tree
, hf_bacnet_wrapper_auth_usr_role
,
429 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
432 /* extra authentication data present if authentication mechanism != 0 */
433 if (bacnet_dlen
!= 0) {
434 bacnet_len
= tvb_get_uint16(tvb
, offset
, ENC_BIG_ENDIAN
);
435 proto_tree_add_item(tree
, hf_bacnet_wrapper_auth_len
,
436 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
439 proto_tree_add_item(tree
,
440 hf_bacnet_wrapper_auth_data
, tvb
, offset
,
442 offset
+= bacnet_len
;
446 /* signature is always present and not encryped in the last 16
447 bytes of a secured BACnet frame */
448 len
= tvb_reported_length_remaining(tvb
, 0) - 16;
449 proto_tree_add_item(tree
,
450 hf_bacnet_wrapper_signature
, tvb
, len
,
453 /* offset is pointing to the start of the secured service data which
454 is followed by the signature which we already have listed as part
455 of the wrapper so we remove the signature now */
456 tvb_set_reported_length(tvb
, len
);
459 /* signature is always present and not encryped in the last 16
460 bytes of a secured BACnet frame */
461 len
= tvb_reported_length_remaining(tvb
, 0) - 16;
462 proto_tree_add_item(tree
,
463 hf_bacnet_wrapper_signature
, tvb
, len
,
465 /* print the encrypted data now because we are not able to decode it anyway */
466 len
= tvb_reported_length_remaining(tvb
, offset
) - 16;
467 proto_tree_add_item(tree
,
468 hf_bacnet_wrapper_encrypted_data
, tvb
, offset
,
470 /* no further decoding possible */
471 tvb_set_reported_length(tvb
, 0);
480 // NOLINTNEXTLINE(misc-no-recursion)
481 dissect_bacnet_npdu(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int offset
)
484 proto_tree
*bacnet_tree
;
486 uint8_t bacnet_version
;
487 uint8_t bacnet_control
;
488 uint8_t bacnet_update_control
;
491 uint8_t bacnet_mesgtyp
;
492 uint8_t bacnet_rportnum
;
493 uint8_t bacnet_pinfolen
;
498 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BACnet-NPDU");
499 col_set_str(pinfo
->cinfo
, COL_INFO
, "Building Automation and Control Network NPDU");
501 bacnet_version
= tvb_get_uint8(tvb
, offset
);
502 bacnet_control
= tvb_get_uint8(tvb
, offset
+1);
504 /* I don't know the length of the NPDU yet; Setting the length after dissection */
505 ti
= proto_tree_add_item(tree
, proto_bacnet
, tvb
, 0, -1, ENC_NA
);
507 bacnet_tree
= proto_item_add_subtree(ti
, ett_bacnet
);
509 proto_tree_add_uint_format_value(bacnet_tree
, hf_bacnet_version
, tvb
,
511 bacnet_version
,"0x%02x (%s)",bacnet_version
,
512 (bacnet_version
== 0x01)?"ASHRAE 135-1995":"unknown");
514 proto_tree_add_bitmask(bacnet_tree
, tvb
, offset
, hf_bacnet_control
,
515 ett_bacnet_control
, control_flags
, ENC_NA
);
517 if (bacnet_control
& BAC_CONTROL_DEST
) { /* DNET, DLEN, DADR */
518 proto_tree_add_item(bacnet_tree
, hf_bacnet_dnet
,
519 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
521 bacnet_dlen
= tvb_get_uint8(tvb
, offset
);
522 /* DLEN = 0 is broadcast on dest.network */
523 if( bacnet_dlen
== 0) {
524 /* append to hf_bacnet_dlen: broadcast */
525 proto_tree_add_uint_format_value(bacnet_tree
,
526 hf_bacnet_dlen
, tvb
, offset
, 1, bacnet_dlen
,
527 "%d indicates Broadcast on Destination Network",
531 } else if (bacnet_dlen
==6) {
532 proto_tree_add_item(bacnet_tree
, hf_bacnet_dlen
,
533 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
536 proto_tree_add_item(bacnet_tree
,
537 hf_bacnet_dadr_eth
, tvb
, offset
,
538 bacnet_dlen
, ENC_NA
);
539 offset
+= bacnet_dlen
;
540 } else if (bacnet_dlen
==1) {
541 proto_tree_add_item(bacnet_tree
, hf_bacnet_dlen
,
542 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
544 /* MS/TP or ARCNET MAC */
545 proto_tree_add_item(bacnet_tree
,
546 hf_bacnet_dadr_mstp
, tvb
, offset
,
547 bacnet_dlen
, ENC_BIG_ENDIAN
);
548 offset
+= bacnet_dlen
;
549 } else if (bacnet_dlen
<7) {
550 proto_tree_add_item(bacnet_tree
, hf_bacnet_dlen
,
551 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
553 /* Other MAC formats should be included here */
554 proto_tree_add_item(bacnet_tree
,
555 hf_bacnet_dadr_tmp
, tvb
, offset
,
556 bacnet_dlen
, ENC_NA
);
557 offset
+= bacnet_dlen
;
559 proto_tree_add_uint_format_value(bacnet_tree
,
560 hf_bacnet_dlen
, tvb
, offset
, 1, bacnet_dlen
,
565 if (bacnet_control
& BAC_CONTROL_SRC
) { /* SNET, SLEN, SADR */
567 proto_tree_add_item(bacnet_tree
, hf_bacnet_snet
,
568 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
570 bacnet_slen
= tvb_get_uint8(tvb
, offset
);
571 if( bacnet_slen
== 0) { /* SLEN = 0 invalid */
572 proto_tree_add_uint_format_value(bacnet_tree
,
573 hf_bacnet_slen
, tvb
, offset
, 1, bacnet_slen
,
577 } else if (bacnet_slen
==6) {
579 proto_tree_add_item(bacnet_tree
, hf_bacnet_slen
,
580 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
583 proto_tree_add_item(bacnet_tree
,
584 hf_bacnet_sadr_eth
, tvb
, offset
,
585 bacnet_slen
, ENC_NA
);
586 offset
+= bacnet_slen
;
587 } else if (bacnet_slen
==1) {
589 proto_tree_add_item(bacnet_tree
, hf_bacnet_slen
,
590 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
592 /* MS/TP or ARCNET MAC */
593 proto_tree_add_item(bacnet_tree
,
594 hf_bacnet_sadr_mstp
, tvb
, offset
,
595 bacnet_slen
, ENC_BIG_ENDIAN
);
596 offset
+= bacnet_slen
;
597 } else if (bacnet_slen
<6) { /* LON MAC */
599 proto_tree_add_item(bacnet_tree
, hf_bacnet_slen
,
600 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
602 /* Other MAC formats should be included here */
603 proto_tree_add_item(bacnet_tree
,
604 hf_bacnet_sadr_tmp
, tvb
, offset
,
605 bacnet_slen
, ENC_NA
);
606 offset
+= bacnet_slen
;
608 proto_tree_add_uint_format_value(bacnet_tree
,
609 hf_bacnet_slen
, tvb
, offset
, 1, bacnet_slen
,
615 if (bacnet_control
& BAC_CONTROL_DEST
) { /* Hopcount */
616 proto_tree_add_item(bacnet_tree
, hf_bacnet_hopc
,
617 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
620 /* Network Layer Message Type */
621 if (bacnet_control
& BAC_CONTROL_NET
) {
622 bacnet_mesgtyp
= tvb_get_uint8(tvb
, offset
);
623 proto_tree_add_uint(bacnet_tree
, hf_bacnet_mesgtyp
, tvb
, offset
, 1, bacnet_mesgtyp
);
624 /* Put the NPDU Type in the info column */
625 col_add_str(pinfo
->cinfo
, COL_INFO
, rval_to_str_const(bacnet_mesgtyp
, bacnet_msgtype_rvals
, "Unknown"));
627 switch (bacnet_mesgtyp
) {
628 /* Performance Index (in I-Could-Be-Router-To-Network) */
630 proto_tree_add_item(bacnet_tree
, hf_bacnet_dnet
,
631 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
633 proto_tree_add_item(bacnet_tree
, hf_bacnet_perf
,
634 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
637 /* Reason, DNET (in Reject-Message-To-Network) */
639 proto_tree_add_item(bacnet_tree
,
640 hf_bacnet_rejectreason
,
641 tvb
, offset
, 1, ENC_NA
);
643 proto_tree_add_item(bacnet_tree
, hf_bacnet_dnet
,
644 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
647 /* N*DNET (in Router-Busy-To-Network,Router-Available-To-Network) */
652 while(tvb_reported_length_remaining(tvb
, offset
) > 1 ) {
653 proto_tree_add_item(bacnet_tree
, hf_bacnet_dnet
,
654 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
658 /* Initialize-Routing-Table */
659 case BAC_NET_INIT_RTAB
:
660 case BAC_NET_INIT_RTAB_ACK
:
661 bacnet_rportnum
= tvb_get_uint8(tvb
, offset
);
662 /* number of ports */
663 proto_tree_add_item(bacnet_tree
, hf_bacnet_rportnum
,
664 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
666 for (i
= 0; tvb_reported_length_remaining(tvb
, offset
) > 1 && i
< bacnet_rportnum
; i
++) {
668 proto_tree_add_item(bacnet_tree
, hf_bacnet_dnet
,
669 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
672 proto_tree_add_item(bacnet_tree
, hf_bacnet_portid
,
673 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
675 /* Port Info Length */
676 bacnet_pinfolen
= tvb_get_uint8(tvb
, offset
);
677 proto_tree_add_item(bacnet_tree
, hf_bacnet_pinfolen
,
678 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
680 proto_tree_add_item(bacnet_tree
, hf_bacnet_pinfo
, tvb
, offset
,
681 bacnet_pinfolen
, ENC_NA
);
682 offset
+= bacnet_pinfolen
;
685 /* Establish-Connection-To-Network */
686 case BAC_NET_EST_CON
:
687 proto_tree_add_item(bacnet_tree
, hf_bacnet_dnet
,
688 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
690 proto_tree_add_item(bacnet_tree
, hf_bacnet_term_time_value
,
691 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
694 /* Disconnect-Connection-To-Network */
695 case BAC_NET_DISC_CON
:
696 proto_tree_add_item(bacnet_tree
, hf_bacnet_dnet
,
697 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
700 /* What-Is-Networknumber */
701 case BAC_NET_WHAT_NETNR
:
703 /* Networknumber-Is */
704 case BAC_NET_NETNR_IS
:
705 proto_tree_add_item(bacnet_tree
, hf_bacnet_dnet
,
706 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
708 proto_tree_add_item(bacnet_tree
, hf_bacnet_netno_status
,
709 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
712 /* Challenge-Request */
713 case BAC_NET_CHALL_REQ
:
714 offset
= bacnet_dissect_sec_wrapper(tvb
, pinfo
, tree
, offset
, NULL
);
716 call_data_dissector(tvb
, pinfo
, tree
);
717 return tvb_captured_length(tvb
);
720 proto_tree_add_item(tree
, hf_bacnet_msg_is_challenged
,
721 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
724 proto_tree_add_item(tree
, hf_bacnet_security_original_message_id
,
725 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
728 proto_tree_add_item(tree
, hf_bacnet_security_original_time_stamp
,
729 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
732 /* Security-Payload */
733 case BAC_NET_SECUR_PAY
:
738 offset
= bacnet_dissect_sec_wrapper(tvb
, pinfo
, tree
, offset
, &is_net_msg_flg
);
740 call_data_dissector(tvb
, pinfo
, tree
);
741 return tvb_captured_length(tvb
);
743 /* get payload length */
744 bacnet_len
= tvb_get_uint16(tvb
, offset
, ENC_BIG_ENDIAN
);
745 proto_tree_add_item(tree
, hf_bacnet_security_msg_len
,
746 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
748 /* set length to reported length in header */
749 tvb_set_reported_length(tvb
, bacnet_len
);
750 if (is_net_msg_flg
) {
751 /* decode network layer message */
752 increment_dissection_depth(pinfo
);
753 int npdu_len
= dissect_bacnet_npdu(tvb
, pinfo
, tree
, offset
);
754 decrement_dissection_depth(pinfo
);
757 /* APDU - call the APDU dissector */
758 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
759 call_dissector(bacapp_handle
, next_tvb
, pinfo
, tree
);
760 return tvb_captured_length(tvb
);
762 /* Security-Response */
763 case BAC_NET_SECUR_RESP
:
765 uint8_t bacnet_responsecode
;
767 offset
= bacnet_dissect_sec_wrapper(tvb
, pinfo
, tree
, offset
, NULL
);
769 call_data_dissector(tvb
, pinfo
, tree
);
770 return tvb_captured_length(tvb
);
773 bacnet_responsecode
= tvb_get_uint8(tvb
, offset
);
774 proto_tree_add_item(tree
, hf_bacnet_security_response_code
,
775 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
778 proto_tree_add_item(tree
, hf_bacnet_security_original_message_id
,
779 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
782 proto_tree_add_item(tree
, hf_bacnet_security_original_time_stamp
,
783 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
786 switch (bacnet_responsecode
)
788 case 0x00: /* success */
789 case 0x01: /* accessDenied */
790 case 0x02: /* badDestinationAddress */
791 case 0x03: /* badDestinationDeviceId */
792 case 0x04: /* badSignature */
793 case 0x05: /* badSourceAddress */
794 case 0x08: /* cannotVerifyMessageId */
795 case 0x09: /* correctKeyRevision */
796 case 0x0A: /* destinationDeviceIdRequired */
797 case 0x0B: /* duplicateMessage */
798 case 0x0C: /* encryptionNotConfigured */
799 case 0x0D: /* encryptionRequired */
800 case 0x10: /* keyUpdateInProgress */
801 case 0x11: /* malformedMessage */
802 case 0x12: /* notKeyServer */
803 case 0x13: /* securityNotConfigured */
804 case 0x14: /* sourceSecurityRequired */
805 case 0x19: /* unknownSourceMessage */
807 /* no parameters are expected here */
809 case 0x06: /* badTimestamp */
810 proto_tree_add_item(tree
, hf_bacnet_security_response_expected_time_stamp
,
811 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
814 case 0x07: /* cannotUseKey */
815 case 0x0F: /* invalidKeyData */
816 case 0x17: /* unknownKey */
817 proto_tree_add_item(tree
, hf_bacnet_security_response_key_algo
,
818 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
820 proto_tree_add_item(tree
, hf_bacnet_security_response_key_id
,
821 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
824 case 0x0E: /* incorrectKey */
825 bacnet_responsecode
= tvb_get_uint8(tvb
, offset
);
827 while (tvb_reported_length_remaining(tvb
, offset
) > 1 && bacnet_responsecode
> 0) {
828 proto_tree_add_item(tree
, hf_bacnet_security_response_key_algo
,
829 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
831 proto_tree_add_item(tree
, hf_bacnet_security_response_key_id
,
832 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
834 bacnet_responsecode
--;
837 case 0x16: /* unknownAuthenticationType */
838 proto_tree_add_item(tree
, hf_bacnet_security_response_original_authentication_mech
,
839 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
841 proto_tree_add_item(tree
, hf_bacnet_security_response_vendor_id
,
842 tvb
, offset
, 2, ENC_BIG_ENDIAN
);
845 case 0x18: /* unknownKeyRevision */
846 proto_tree_add_item(tree
, hf_bacnet_security_response_key_revision
,
847 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
850 case 0x15: /* tooManyKeys */
851 proto_tree_add_item(tree
, hf_bacnet_security_response_number_keys
,
852 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
858 /* Request-Key-Update */
859 case BAC_NET_REQ_KEY_UP
:
860 offset
= bacnet_dissect_sec_wrapper(tvb
, pinfo
, tree
, offset
, NULL
);
862 call_data_dissector(tvb
, pinfo
, tree
);
863 return tvb_captured_length(tvb
);
866 proto_tree_add_item(tree
, hf_bacnet_security_set1_key_reveision
,
867 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
869 proto_tree_add_item(tree
, hf_bacnet_security_set1_activation_time_stamp
,
870 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
872 proto_tree_add_item(tree
, hf_bacnet_security_set1_expiration_time_stamp
,
873 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
876 proto_tree_add_item(tree
, hf_bacnet_security_set2_key_reveision
,
877 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
879 proto_tree_add_item(tree
, hf_bacnet_security_set2_activation_time_stamp
,
880 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
882 proto_tree_add_item(tree
, hf_bacnet_security_set2_expiration_time_stamp
,
883 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
886 proto_tree_add_item(tree
, hf_bacnet_security_dist_key_revision
,
887 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
891 case BAC_NET_UPD_KEYSET
:
892 offset
= bacnet_dissect_sec_wrapper(tvb
, pinfo
, tree
, offset
, NULL
);
894 call_data_dissector(tvb
, pinfo
, tree
);
895 return tvb_captured_length(tvb
);
898 bacnet_update_control
= tvb_get_uint8(tvb
, offset
);
899 proto_tree_add_bitmask(tree
, tvb
, offset
, hf_bacnet_update_control
,
900 ett_bacnet_update_control
, update_control_flags
, ENC_NA
);
903 if (bacnet_update_control
& BAC_UPDATE_CONTROL_SET1_TIMES_PRESENT
) {
904 proto_tree_add_item(tree
, hf_bacnet_security_set1_key_reveision
,
905 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
907 proto_tree_add_item(tree
, hf_bacnet_security_set1_activation_time_stamp
,
908 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
910 proto_tree_add_item(tree
, hf_bacnet_security_set1_expiration_time_stamp
,
911 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
915 if (bacnet_update_control
& BAC_UPDATE_CONTROL_SET1_PARAMS_PRESENT
) {
918 keycount
= tvb_get_uint8(tvb
, offset
);
921 for (i
= 0; tvb_reported_length_remaining(tvb
, offset
) > 1 && i
< keycount
; i
++) {
922 proto_tree_add_item(tree
, hf_bacnet_security_set1_key_algo
,
923 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
925 proto_tree_add_item(tree
, hf_bacnet_security_set1_key_id
,
926 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
929 bacnet_dlen
= tvb_get_uint8(tvb
, offset
);
932 proto_tree_add_item(tree
,
933 hf_bacnet_security_set1_key_data
, tvb
, offset
,
934 bacnet_dlen
, ENC_NA
);
935 offset
+= bacnet_dlen
;
939 if (bacnet_update_control
& BAC_UPDATE_CONTROL_SET2_TIMES_PRESENT
) {
940 proto_tree_add_item(tree
, hf_bacnet_security_set2_key_reveision
,
941 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
943 proto_tree_add_item(tree
, hf_bacnet_security_set2_activation_time_stamp
,
944 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
946 proto_tree_add_item(tree
, hf_bacnet_security_set2_expiration_time_stamp
,
947 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
951 if (bacnet_update_control
& BAC_UPDATE_CONTROL_SET2_PARAMS_PRESENT
) {
954 keycount
= tvb_get_uint8(tvb
, offset
);
957 for (i
= 0; tvb_reported_length_remaining(tvb
, offset
) > 1 && i
< keycount
; i
++) {
958 proto_tree_add_item(tree
, hf_bacnet_security_set2_key_algo
,
959 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
961 proto_tree_add_item(tree
, hf_bacnet_security_set2_key_id
,
962 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
965 bacnet_dlen
= tvb_get_uint8(tvb
, offset
);
968 proto_tree_add_item(tree
,
969 hf_bacnet_security_set2_key_data
, tvb
, offset
,
970 bacnet_dlen
, ENC_NA
);
971 offset
+= bacnet_dlen
;
975 /* Update-distribution-Key */
976 case BAC_NET_UPD_DKEY
:
977 offset
= bacnet_dissect_sec_wrapper(tvb
, pinfo
, tree
, offset
, NULL
);
979 call_data_dissector(tvb
, pinfo
, tree
);
980 return tvb_captured_length(tvb
);
983 proto_tree_add_item(tree
, hf_bacnet_security_dist_key_revision
,
984 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
986 proto_tree_add_item(tree
, hf_bacnet_security_dist_key_algo
,
987 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
989 proto_tree_add_item(tree
, hf_bacnet_security_dist_key_id
,
990 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
993 bacnet_dlen
= tvb_get_uint8(tvb
, offset
);
996 proto_tree_add_item(tree
,
997 hf_bacnet_security_dist_key_data
, tvb
, offset
,
998 bacnet_dlen
, ENC_NA
);
999 offset
+= bacnet_dlen
;
1001 /* Request-Masterkey */
1002 case BAC_NET_REQ_MKEY
:
1006 offset
= bacnet_dissect_sec_wrapper(tvb
, pinfo
, tree
, offset
, NULL
);
1008 call_data_dissector(tvb
, pinfo
, tree
);
1009 return tvb_captured_length(tvb
);
1012 keycount
= tvb_get_uint8(tvb
, offset
);
1014 while (tvb_reported_length_remaining(tvb
, offset
) > 1 && keycount
> 0) {
1015 proto_tree_add_item(tree
, hf_bacnet_security_master_key_algo
,
1016 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1023 case BAC_NET_SET_MKEY
:
1024 offset
= bacnet_dissect_sec_wrapper(tvb
, pinfo
, tree
, offset
, NULL
);
1026 call_data_dissector(tvb
, pinfo
, tree
);
1027 return tvb_captured_length(tvb
);
1030 proto_tree_add_item(tree
, hf_bacnet_security_master_key_algo
,
1031 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1033 proto_tree_add_item(tree
, hf_bacnet_security_master_key_id
,
1034 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1037 bacnet_dlen
= tvb_get_uint8(tvb
, offset
);
1040 proto_tree_add_item(tree
,
1041 hf_bacnet_security_master_key_data
, tvb
, offset
,
1042 bacnet_dlen
, ENC_NA
);
1043 offset
+= bacnet_dlen
;
1047 * The standard says: "If Bit 7 of the control octet is 1 and
1048 * the Message Type field contains a value in the range
1049 * X'80' - X'FF', then a Vendor ID field shall be present (...)."
1050 * We should not go any further in dissecting the packet if it's
1051 * not present, but we don't know about that: No length field...
1053 if (bacnet_mesgtyp
> 0x7f) {
1054 /* Note: our next_tvb includes message type and vendor id! */
1055 next_tvb
= tvb_new_subset_remaining(tvb
, offset
-1);
1056 vendor_id
= tvb_get_ntohs(tvb
, offset
);
1057 proto_tree_add_item(bacnet_tree
, hf_bacnet_vendor
, tvb
,
1058 offset
, 2, ENC_BIG_ENDIAN
);
1059 offset
+= 2; /* vendor_id */
1060 if (dissector_try_uint(bacnet_dissector_table
,
1061 vendor_id
, next_tvb
, pinfo
, bacnet_tree
)) {
1062 /* we parsed it so skip over length and we are done */
1063 /* Note: offset has now been bumped for message type and vendor
1064 id so we take that out of our next_tvb size */
1065 offset
+= tvb_reported_length(next_tvb
) -3;
1072 /* Now set NPDU length */
1073 proto_item_set_len(ti
, offset
);
1075 /* dissect BACnet APDU */
1076 next_tvb
= tvb_new_subset_remaining(tvb
,offset
);
1077 if (bacnet_control
& BAC_CONTROL_NET
) {
1078 /* Unknown function - dissect the payload as data */
1079 call_data_dissector(next_tvb
, pinfo
, tree
);
1081 /* APDU - call the APDU dissector */
1082 call_dissector(bacapp_handle
, next_tvb
, pinfo
, tree
);
1084 return tvb_captured_length(tvb
);
1088 dissect_bacnet(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
1090 return dissect_bacnet_npdu(tvb
, pinfo
, tree
, 0);
1094 proto_register_bacnet(void)
1096 static hf_register_info hf
[] = {
1097 { &hf_bacnet_version
,
1100 FT_UINT8
, BASE_DEC
, NULL
, 0,
1101 "BACnet Version", HFILL
}
1103 { &hf_bacnet_control
,
1106 FT_UINT8
, BASE_HEX
, NULL
, 0,
1107 "BACnet Control", HFILL
}
1109 { &hf_bacnet_control_net
,
1111 "bacnet.control_net",
1112 FT_BOOLEAN
, 8, TFS(&control_net_set_high
),
1113 BAC_CONTROL_NET
, "BACnet Control", HFILL
}
1115 { &hf_bacnet_control_res1
,
1117 "bacnet.control_res1",
1118 FT_BOOLEAN
, 8, TFS(&control_res_high
),
1119 BAC_CONTROL_RES1
, "BACnet Control", HFILL
}
1121 { &hf_bacnet_control_dest
,
1122 { "Destination Specifier",
1123 "bacnet.control_dest",
1124 FT_BOOLEAN
, 8, TFS(&control_dest_high
),
1125 BAC_CONTROL_DEST
, "BACnet Control", HFILL
}
1127 { &hf_bacnet_control_res2
,
1129 "bacnet.control_res2",
1130 FT_BOOLEAN
, 8, TFS(&control_res_high
),
1131 BAC_CONTROL_RES2
, "BACnet Control", HFILL
}
1133 { &hf_bacnet_control_src
,
1134 { "Source specifier",
1135 "bacnet.control_src",
1136 FT_BOOLEAN
, 8, TFS(&control_src_high
),
1137 BAC_CONTROL_SRC
, "BACnet Control", HFILL
}
1139 { &hf_bacnet_control_expect
,
1140 { "Expecting Reply",
1141 "bacnet.control_expect",
1142 FT_BOOLEAN
, 8, TFS(&control_expect_high
),
1143 BAC_CONTROL_EXPECT
, "BACnet Control", HFILL
}
1145 { &hf_bacnet_control_prio_high
,
1147 "bacnet.control_prio_high",
1148 FT_BOOLEAN
, 8, TFS(&control_prio_high_high
),
1149 BAC_CONTROL_PRIO_HIGH
, "BACnet Control", HFILL
}
1151 { &hf_bacnet_control_prio_low
,
1153 "bacnet.control_prio_low",
1154 FT_BOOLEAN
, 8, TFS(&control_prio_low_high
),
1155 BAC_CONTROL_PRIO_LOW
, "BACnet Control", HFILL
}
1158 { "Destination Network Address",
1160 FT_UINT16
, BASE_DEC
, NULL
, 0,
1164 { "Destination MAC Layer Address Length",
1166 FT_UINT8
, BASE_DEC
, NULL
, 0,
1169 { &hf_bacnet_dadr_eth
,
1170 { "Destination ISO 8802-3 MAC Address",
1172 FT_ETHER
, BASE_NONE
, NULL
, 0,
1175 { &hf_bacnet_dadr_mstp
,
1178 FT_UINT8
, BASE_DEC
, NULL
, 0,
1179 "Destination MS/TP or ARCNET MAC Address", HFILL
}
1181 { &hf_bacnet_dadr_tmp
,
1182 { "Unknown Destination MAC",
1184 FT_BYTES
, BASE_NONE
, NULL
, 0,
1188 { "Source Network Address",
1190 FT_UINT16
, BASE_DEC
, NULL
, 0,
1194 { "Source MAC Layer Address Length",
1196 FT_UINT8
, BASE_DEC
, NULL
, 0,
1199 { &hf_bacnet_sadr_eth
,
1202 FT_ETHER
, BASE_NONE
, NULL
, 0,
1203 "Source ISO 8802-3 MAC Address", HFILL
}
1205 { &hf_bacnet_sadr_mstp
,
1208 FT_UINT8
, BASE_DEC
, NULL
, 0,
1209 "Source MS/TP or ARCNET MAC Address", HFILL
}
1211 { &hf_bacnet_sadr_tmp
,
1212 { "Unknown Source MAC",
1214 FT_BYTES
, BASE_NONE
, NULL
, 0,
1220 FT_UINT8
, BASE_DEC
, NULL
, 0,
1223 { &hf_bacnet_mesgtyp
,
1224 { "Network Layer Message Type",
1226 FT_UINT8
, BASE_HEX
| BASE_RANGE_STRING
, RVALS(bacnet_msgtype_rvals
), 0,
1229 { &hf_bacnet_vendor
,
1232 FT_UINT16
, BASE_DEC
, NULL
, 0,
1236 { "Performance Index",
1238 FT_UINT8
, BASE_DEC
, NULL
, 0,
1241 { &hf_bacnet_rejectreason
,
1243 "bacnet.rejectreason",
1244 FT_UINT8
, BASE_DEC
| BASE_RANGE_STRING
, RVALS(bacnet_rejectreason_name_rvals
), 0,
1247 { &hf_bacnet_rportnum
,
1248 { "Number of Port Mappings",
1250 FT_UINT8
, BASE_DEC
, NULL
, 0,
1253 { &hf_bacnet_pinfolen
,
1254 { "Port Info Length",
1256 FT_UINT8
, BASE_DEC
, NULL
, 0,
1262 FT_BYTES
, BASE_NONE
, NULL
, 0,
1265 { &hf_bacnet_portid
,
1268 FT_UINT8
, BASE_HEX
, NULL
, 0,
1271 { &hf_bacnet_term_time_value
,
1272 { "Termination Time Value (seconds)",
1273 "bacnet.term_time_value",
1274 FT_UINT8
, BASE_DEC
, NULL
, 0,
1277 { &hf_bacnet_netno_status
,
1278 { "Network number status (enumerated)",
1279 "bacnet.netno_status",
1280 FT_UINT8
, BASE_DEC
, NULL
, 0,
1283 { &hf_bacnet_wrapper_control
,
1284 { "Wrapper control",
1285 "bacnet.wrappercontrol",
1286 FT_UINT8
, BASE_HEX
, NULL
, 0,
1287 "BACnet wrapper control", HFILL
}
1289 { &hf_bacnet_wrapper_control_secured_by_router
,
1290 { "Secured by router",
1291 "bacnet.wrappercontrol_secured_by_router",
1292 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
),
1293 BAC_WRAPPER_SECURE_BY_RTR
, "BACnet wrapper control", HFILL
}
1295 { &hf_bacnet_wrapper_control_non_trusted_source
,
1296 { "Non trusted source",
1297 "bacnet.wrappercontrol_non_trusted_source",
1298 FT_BOOLEAN
, 8, TFS(&wrapper_control_trusted_source
),
1299 BAC_WRAPPER_NO_TRUST_SRC
, "BACnet wrapper control", HFILL
}
1301 { &hf_bacnet_wrapper_control_do_not_decrypt
,
1303 "bacnet.wrappercontrol_do_not_decrypt",
1304 FT_BOOLEAN
, 8, TFS(&wrapper_control_do_not_decrypt
),
1305 BAC_WRAPPER_DO_NOT_DECRPT
, "BACnet wrapper control", HFILL
}
1307 { &hf_bacnet_wrapper_control_do_not_unwrap
,
1309 "bacnet.wrappercontrol_do_not_unwrap",
1310 FT_BOOLEAN
, 8, TFS(&wrapper_control_do_not_unwrap
),
1311 BAC_WRAPPER_DO_NOT_UNWRAP
, "BACnet wrapper control", HFILL
}
1313 { &hf_bacnet_wrapper_control_auth_data_present
,
1314 { "Authentication data present",
1315 "bacnet.wrappercontrol_auth_data_present",
1316 FT_BOOLEAN
, 8, TFS(&tfs_present_not_present
),
1317 BAC_WRAPPER_AUTHD_PRESENT
, "BACnet wrapper control", HFILL
}
1319 { &hf_bacnet_wrapper_control_reserved
,
1321 "bacnet.wrappercontrol_reserved",
1322 FT_BOOLEAN
, 8, TFS(&wrapper_control_reserved
),
1323 BAC_WRAPPER_RESERVED
, "BACnet wrapper control", HFILL
}
1325 { &hf_bacnet_wrapper_control_msg_is_encrypted
,
1326 { "Message is encrypted message",
1327 "bacnet.wrappercontrol_msg_is_crypted",
1328 FT_BOOLEAN
, 8, TFS(&wrapper_control_msg_crypted
),
1329 BAC_WRAPPER_MSG_ENCRYPED
, "BACnet wrapper control", HFILL
}
1331 { &hf_bacnet_wrapper_control_msg_is_networklayer
,
1332 { "Message is networklayer message",
1333 "bacnet.wrappercontrol_msg_is_netlayer",
1334 FT_BOOLEAN
, 8, TFS(&wrapper_control_msg_net
),
1335 BAC_WRAPPER_CONTROL_NET
, "BACnet wrapper control", HFILL
}
1337 { &hf_bacnet_wrapper_key_revision
,
1338 { "Wrapper Key Revision",
1339 "bacnet.wrapper_key_revision",
1340 FT_UINT8
, BASE_DEC
, NULL
, 0,
1343 { &hf_bacnet_wrapper_key_identifier
,
1344 { "Wrapper Key Identifier",
1345 "bacnet.wrapper_key_identifier",
1346 FT_UINT16
, BASE_DEC
, NULL
, 0,
1349 { &hf_bacnet_wrapper_src_dev_instance
,
1350 { "Wrapper Source Device Instance",
1351 "bacnet.wrapper_src_device_instance",
1352 FT_UINT24
, BASE_DEC
, NULL
, 0,
1355 { &hf_bacnet_wrapper_message_id
,
1356 { "Wrapper Message Id",
1357 "bacnet.wrapper_msg_id",
1358 FT_UINT32
, BASE_DEC
, NULL
, 0,
1361 { &hf_bacnet_wrapper_time_stamp
,
1362 { "Wrapper Message Timestamp",
1363 "bacnet.wrapper_time_stamp",
1364 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0,
1367 { &hf_bacnet_wrapper_dst_dev_instance
,
1368 { "Wrapper Destination Device Instance",
1369 "bacnet.wrapper_dst_device_instance",
1370 FT_UINT24
, BASE_DEC
, NULL
, 0,
1373 { &hf_bacnet_wrapper_dnet
,
1374 { "Wrapper Destination Network Address",
1375 "bacnet.wrapper_dnet",
1376 FT_UINT16
, BASE_DEC
, NULL
, 0,
1379 { &hf_bacnet_wrapper_dlen
,
1380 { "Wrapper Destination MAC Layer Address Length",
1381 "bacnet.wrapper_dlen",
1382 FT_UINT8
, BASE_DEC
, NULL
, 0,
1385 { &hf_bacnet_wrapper_dadr
,
1386 { "Wrapper Destination MAC",
1387 "bacnet.wrapper_dadr",
1388 FT_BYTES
, BASE_NONE
, NULL
, 0,
1391 { &hf_bacnet_wrapper_snet
,
1392 { "Wrapper Source Network Address",
1393 "bacnet.wrapper_snet",
1394 FT_UINT16
, BASE_DEC
, NULL
, 0,
1397 { &hf_bacnet_wrapper_slen
,
1398 { "Wrapper Source MAC Layer Address Length",
1399 "bacnet.wrapper_slen",
1400 FT_UINT8
, BASE_DEC
, NULL
, 0,
1403 { &hf_bacnet_wrapper_sadr
,
1404 { "Wrapper Source MAC",
1405 "bacnet.wrapper_sadr",
1406 FT_BYTES
, BASE_NONE
, NULL
, 0,
1409 { &hf_bacnet_wrapper_auth_mech
,
1410 { "Wrapper Authentication Mechanism",
1411 "bacnet.wrapper_auth_mech",
1412 FT_UINT8
, BASE_DEC
, NULL
, 0,
1415 { &hf_bacnet_wrapper_auth_usr_id
,
1416 { "Wrapper Authentication User Id",
1417 "bacnet.wrapper_auth_usr_id",
1418 FT_UINT16
, BASE_DEC
, NULL
, 0,
1421 { &hf_bacnet_wrapper_auth_usr_role
,
1422 { "Wrapper Authentication User Role",
1423 "bacnet.wrapper_auth_usr_role",
1424 FT_UINT8
, BASE_DEC
, NULL
, 0,
1427 { &hf_bacnet_wrapper_auth_len
,
1428 { "Wrapper Authentication Length",
1429 "bacnet.wrapper_auth_len",
1430 FT_UINT16
, BASE_DEC
, NULL
, 0,
1433 { &hf_bacnet_wrapper_auth_data
,
1434 { "Wrapper Authentication Data",
1435 "bacnet.wrapper_auth_data",
1436 FT_BYTES
, BASE_NONE
, NULL
, 0,
1439 { &hf_bacnet_wrapper_signature
,
1440 { "Wrapper Signature",
1441 "bacnet.wrapper_signature",
1442 FT_BYTES
, BASE_NONE
, NULL
, 0,
1445 { &hf_bacnet_wrapper_encrypted_data
,
1446 { "Wrapper Encrypted Data",
1447 "bacnet.wrapper_encrypted_data",
1448 FT_BYTES
, BASE_NONE
, NULL
, 0,
1451 { &hf_bacnet_msg_is_challenged
,
1452 { "Message is challenged message",
1453 "bacnet.is_challenged_message",
1454 FT_BOOLEAN
, 8, TFS(&security_msg_challenged
),
1455 1, "BACnet security", HFILL
}
1457 { &hf_bacnet_security_original_message_id
,
1458 { "Security Original Message Id",
1459 "bacnet.security_original_message_id",
1460 FT_UINT32
, BASE_DEC
, NULL
, 0,
1463 { &hf_bacnet_security_original_time_stamp
,
1464 { "Security Original Message Timestamp",
1465 "bacnet.security_original_time_stamp",
1466 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0,
1469 { &hf_bacnet_security_msg_len
,
1470 { "Security Message Length",
1471 "bacnet.security_message_length",
1472 FT_UINT16
, BASE_DEC
, NULL
, 0,
1475 { &hf_bacnet_security_response_code
,
1476 { "Security Response Code",
1477 "bacnet.security_response_code",
1478 FT_UINT8
, BASE_DEC
, NULL
, 0,
1481 { &hf_bacnet_security_response_expected_time_stamp
,
1482 { "Security Expected Timestamp",
1483 "bacnet.security_response_expected_time_stamp",
1484 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0,
1487 { &hf_bacnet_security_response_key_algo
,
1488 { "Security Response Key Algorithm",
1489 "bacnet.security_response_key_algorithm",
1490 FT_UINT8
, BASE_DEC
, NULL
, 0,
1493 { &hf_bacnet_security_response_key_id
,
1494 { "Security Response Key ID",
1495 "bacnet.security_response_key_id",
1496 FT_UINT8
, BASE_DEC
, NULL
, 0,
1499 { &hf_bacnet_security_response_original_authentication_mech
,
1500 { "Security Response Original Authentication Mechanism",
1501 "bacnet.security_response_original_authentication_mechanism",
1502 FT_UINT8
, BASE_DEC
, NULL
, 0,
1505 { &hf_bacnet_security_response_vendor_id
,
1506 { "Security Response Vendor ID",
1507 "bacnet.security_response_vendor_id",
1508 FT_UINT16
, BASE_DEC
, NULL
, 0,
1511 { &hf_bacnet_security_response_key_revision
,
1512 { "Security Response Key Revision",
1513 "bacnet.security_response_key_revision",
1514 FT_UINT8
, BASE_DEC
, NULL
, 0,
1517 { &hf_bacnet_security_response_number_keys
,
1518 { "Security Response Number Of Keys",
1519 "bacnet.security_response_number_of_keys",
1520 FT_UINT8
, BASE_DEC
, NULL
, 0,
1523 { &hf_bacnet_security_set1_key_reveision
,
1524 { "Security Set 1 Key Revision",
1525 "bacnet.security_set1_key_revision",
1526 FT_UINT8
, BASE_DEC
, NULL
, 0,
1529 { &hf_bacnet_security_set1_activation_time_stamp
,
1530 { "Security Set 1 Activation Timestamp",
1531 "bacnet.security_set1_activation_time_stamp",
1532 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0,
1535 { &hf_bacnet_security_set1_expiration_time_stamp
,
1536 { "Security Set 1 Expiration Timestamp",
1537 "bacnet.security_set1_expiration_time_stamp",
1538 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0,
1541 { &hf_bacnet_security_set1_key_algo
,
1542 { "Security Keyset 1 Algorithm",
1543 "bacnet.security_set1_key_algorithm",
1544 FT_UINT8
, BASE_DEC
, NULL
, 0,
1547 { &hf_bacnet_security_set1_key_id
,
1548 { "Security Keyset 1 Key ID",
1549 "bacnet.security_set1_key_id",
1550 FT_UINT8
, BASE_DEC
, NULL
, 0,
1553 { &hf_bacnet_security_set1_key_data
,
1554 { "Security Keyset 1 Key Data",
1555 "bacnet.security_set1_key_data",
1556 FT_BYTES
, BASE_NONE
, NULL
, 0,
1559 { &hf_bacnet_security_set2_key_reveision
,
1560 { "Security Set 2 Key Revision",
1561 "bacnet.security_set2_key_revision",
1562 FT_UINT8
, BASE_DEC
, NULL
, 0,
1565 { &hf_bacnet_security_set2_activation_time_stamp
,
1566 { "Security Set 2 Activation Timestamp",
1567 "bacnet.security_set2_activation_time_stamp",
1568 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0,
1571 { &hf_bacnet_security_set2_expiration_time_stamp
,
1572 { "Security Set 2 Expiration Timestamp",
1573 "bacnet.security_set2_expiration_time_stamp",
1574 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0,
1577 { &hf_bacnet_security_set2_key_algo
,
1578 { "Security Keyset 2 Algorithm",
1579 "bacnet.security_set2_key_algorithm",
1580 FT_UINT8
, BASE_DEC
, NULL
, 0,
1583 { &hf_bacnet_security_set2_key_id
,
1584 { "Security Keyset 2 Key ID",
1585 "bacnet.security_set2_key_id",
1586 FT_UINT8
, BASE_DEC
, NULL
, 0,
1589 { &hf_bacnet_security_set2_key_data
,
1590 { "Security Keyset 2 Key Data",
1591 "bacnet.security_set2_key_data",
1592 FT_BYTES
, BASE_NONE
, NULL
, 0,
1595 { &hf_bacnet_security_dist_key_revision
,
1596 { "Security Distribution Key Revision",
1597 "bacnet.security_distribution_key_revision",
1598 FT_UINT8
, BASE_DEC
, NULL
, 0,
1601 { &hf_bacnet_security_dist_key_algo
,
1602 { "Security Keyset 2 Algorithm",
1603 "bacnet.security_distribution_key_algorithm",
1604 FT_UINT8
, BASE_DEC
, NULL
, 0,
1607 { &hf_bacnet_security_dist_key_id
,
1608 { "Security Keyset 2 Key ID",
1609 "bacnet.security_distribution_key_id",
1610 FT_UINT8
, BASE_DEC
, NULL
, 0,
1613 { &hf_bacnet_security_dist_key_data
,
1614 { "Security Keyset 2 Key Data",
1615 "bacnet.security_distribution_key_data",
1616 FT_BYTES
, BASE_NONE
, NULL
, 0,
1619 { &hf_bacnet_security_master_key_algo
,
1620 { "Security Master Key Algorithm",
1621 "bacnet.security_master_key_algorithm",
1622 FT_UINT8
, BASE_DEC
, NULL
, 0,
1625 { &hf_bacnet_security_master_key_id
,
1626 { "Security Master Key ID",
1627 "bacnet.security_master_key_id",
1628 FT_UINT8
, BASE_DEC
, NULL
, 0,
1631 { &hf_bacnet_security_master_key_data
,
1632 { "Security Master Key Data",
1633 "bacnet.security_master_key_data",
1634 FT_BYTES
, BASE_NONE
, NULL
, 0,
1637 { &hf_bacnet_update_control
,
1639 "bacnet.update_control",
1640 FT_UINT8
, BASE_HEX
, NULL
, 0,
1641 "BACnet update control", HFILL
}
1643 { &hf_bacnet_update_control_remove
,
1644 { "Key Update Control Remove Keys",
1645 "bacnet.update_control_remove_keys",
1646 FT_BOOLEAN
, 8, TFS(&update_key_control_remove_keys
),
1647 BAC_UPDATE_CONTROL_REMOVE_KEYS
, "BACnet update keys control", HFILL
}
1649 { &hf_bacnet_update_control_more_follows
,
1650 { "Key Update Control More Keys Follow",
1651 "bacnet.update_control_more_keys_follow",
1652 FT_BOOLEAN
, 8, TFS(&tfs_yes_no
),
1653 BAC_UPDATE_CONTROL_MORE_FOLLOWS
, "BACnet update keys control", HFILL
}
1655 { &hf_bacnet_update_control_clear_set2
,
1656 { "Key Update Control Set 2 Clear",
1657 "bacnet.update_control_set2_clear",
1658 FT_BOOLEAN
, 8, TFS(&tfs_clear_do_not_clear
),
1659 BAC_UPDATE_CONTROL_CLEAR_SET2
, "BACnet update keys control", HFILL
}
1661 { &hf_bacnet_update_control_set2_params_present
,
1662 { "Key Update Control Set 2 Params Present",
1663 "bacnet.update_control_set2_params_present",
1664 FT_BOOLEAN
, 8, TFS(&tfs_present_not_present
),
1665 BAC_UPDATE_CONTROL_SET2_PARAMS_PRESENT
, "BACnet update keys control", HFILL
}
1667 { &hf_bacnet_update_control_set2_times_present
,
1668 { "Key Update Control Set 2 Time Present",
1669 "bacnet.update_control_set2_time_present",
1670 FT_BOOLEAN
, 8, TFS(&tfs_present_not_present
),
1671 BAC_UPDATE_CONTROL_SET2_TIMES_PRESENT
, "BACnet update keys control", HFILL
}
1673 { &hf_bacnet_update_control_clear_set1
,
1674 { "Key Update Control Set 1 Clear",
1675 "bacnet.update_control_set1_clear",
1676 FT_BOOLEAN
, 8, TFS(&tfs_clear_do_not_clear
),
1677 BAC_UPDATE_CONTROL_CLEAR_SET1
, "BACnet update keys control", HFILL
}
1679 { &hf_bacnet_update_control_set1_params_present
,
1680 { "Key Update Control Set 1 Params Present",
1681 "bacnet.update_control_set1_params_present",
1682 FT_BOOLEAN
, 8, TFS(&tfs_present_not_present
),
1683 BAC_UPDATE_CONTROL_SET1_PARAMS_PRESENT
, "BACnet update keys control", HFILL
}
1685 { &hf_bacnet_update_control_set1_times_present
,
1686 { "Key Update Control Set 1 Time Present",
1687 "bacnet.update_control_set1_time_present",
1688 FT_BOOLEAN
, 8, TFS(&tfs_present_not_present
),
1689 BAC_UPDATE_CONTROL_SET1_TIMES_PRESENT
, "BACnet update keys control", HFILL
}
1693 static int *ett
[] = {
1695 &ett_bacnet_control
,
1696 &ett_bacnet_wrapper_control
,
1697 &ett_bacnet_update_control
,
1700 proto_bacnet
= proto_register_protocol("Building Automation and Control Network NPDU", "BACnet", "bacnet");
1702 proto_register_field_array(proto_bacnet
, hf
, array_length(hf
));
1703 proto_register_subtree_array(ett
, array_length(ett
));
1705 bacnet_handle
= register_dissector("bacnet", dissect_bacnet
, proto_bacnet
);
1707 bacnet_dissector_table
= register_dissector_table("bacnet.vendor",
1708 "BACnet Vendor Identifier", proto_bacnet
,
1709 FT_UINT8
, BASE_HEX
);
1713 proto_reg_handoff_bacnet(void)
1715 dissector_add_uint("bvlc.function", 0x04, bacnet_handle
);
1716 dissector_add_uint("bvlc.function", 0x09, bacnet_handle
);
1717 dissector_add_uint("bvlc.function", 0x0a, bacnet_handle
);
1718 dissector_add_uint("bvlc.function", 0x0b, bacnet_handle
);
1719 dissector_add_uint("bvlc.function_ipv6", 0x01, bacnet_handle
);
1720 dissector_add_uint("bvlc.function_ipv6", 0x02, bacnet_handle
);
1721 dissector_add_uint("bvlc.function_ipv6", 0x0c, bacnet_handle
);
1722 dissector_add_uint("bvlc.function_ipv6", 0x08, bacnet_handle
);
1723 dissector_add_uint("bscvlc.function", 0x01, bacnet_handle
);
1724 dissector_add_uint("llc.dsap", SAP_BACNET
, bacnet_handle
);
1725 bacapp_handle
= find_dissector_add_dependency("bacapp", proto_bacnet
);
1729 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1734 * indent-tabs-mode: t
1737 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1738 * :indentSize=8:tabSize=8:noTabs=false: