2 * Routines for BACnet (APDU) dissection
3 * Copyright 2001, Hartmut Mueller <hartmut@abmlinux.org>, FH Dortmund
5 * $Id: packet-bacapp.c,v 1.9 2002/01/21 07:36:32 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * Copied from README.developer,v 1.23
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #ifdef HAVE_SYS_TYPES_H
37 # include <sys/types.h>
40 #ifdef HAVE_NETINET_IN_H
41 # include <netinet/in.h>
46 #ifdef NEED_SNPRINTF_H
47 # include "snprintf.h"
50 #include <epan/packet.h>
53 bacapp_type_name (guint8 bacapp_type){
54 static const char *type_names[] = {
55 "Confirmed-Request-PDU",
56 "Unconfirmed-Request-PDU",
64 return (bacapp_type > 7)? "unknown PDU" : type_names[bacapp_type];
67 static int proto_bacapp = -1;
68 static int hf_bacapp_type = -1;
70 static gint ett_bacapp = -1;
72 static dissector_handle_t data_handle;
75 dissect_bacapp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
78 proto_tree *bacapp_tree;
83 if (check_col(pinfo->cinfo, COL_PROTOCOL))
84 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BACnet-APDU");
85 if (check_col(pinfo->cinfo, COL_INFO))
86 col_add_str(pinfo->cinfo, COL_INFO, "BACnet APDU ");
89 bacapp_type = (tvb_get_guint8(tvb, offset) >> 4) & 0x0f;
91 if (check_col(pinfo->cinfo, COL_INFO))
92 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s)",
93 bacapp_type_name(bacapp_type));
95 ti = proto_tree_add_item(tree, proto_bacapp, tvb, offset, tvb_length(tvb), FALSE);
97 bacapp_tree = proto_item_add_subtree(ti, ett_bacapp);
99 proto_tree_add_uint_format(bacapp_tree, hf_bacapp_type, tvb,
100 offset, 1, bacapp_type, "APDU Type: %u (%s)", bacapp_type,
101 bacapp_type_name(bacapp_type));
105 next_tvb = tvb_new_subset(tvb,offset,-1,-1);
106 call_dissector(data_handle,next_tvb, pinfo, tree);
111 proto_register_bacapp(void)
113 static hf_register_info hf[] = {
115 { "APDU Type", "bacapp.bacapp_type",
116 FT_UINT8, BASE_DEC, NULL, 0xf0, "APDU Type", HFILL }
119 static gint *ett[] = {
122 proto_bacapp = proto_register_protocol("Building Automation and Control Network APDU",
124 proto_register_field_array(proto_bacapp, hf, array_length(hf));
125 proto_register_subtree_array(ett, array_length(ett));
126 register_dissector("bacapp", dissect_bacapp, proto_bacapp);
130 proto_reg_handoff_bacapp(void)
132 data_handle = find_dissector("data");