Document the new Copy Profile button.
[obnox/wireshark/wip.git] / epan / dissectors / packet-asf.c
1 /* packet-asf.c
2  * Routines for ASF packet dissection
3  *
4  * Duncan Laurie <duncan@sun.com>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * Copied from packet-rmcp.c
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 
27  * 02111-1307, USA.
28  */
29
30 #ifdef HAVE_CONFIG_H
31 #include "config.h"
32 #endif
33
34 #include <glib.h>
35 #include <epan/packet.h>
36
37 /*
38  * See
39  *      http://www.dmtf.org/standards/standard_alert.php
40  *      http://www.dmtf.org/standards/documents/ASF/DSP0136.pdf
41  */
42
43 #define RMCP_CLASS_ASF 0x06
44
45 static int proto_asf = -1;
46 static int hf_asf_iana = -1;
47 static int hf_asf_type = -1;
48 static int hf_asf_tag = -1;
49 static int hf_asf_len = -1;
50
51 static dissector_handle_t data_handle;
52 static gint ett_asf = -1;
53
54 static const value_string asf_type_vals[] = {
55         { 0x10, "Reset" },
56         { 0x11, "Power-up" },
57         { 0x12, "Unconditional Power-down" },
58         { 0x13, "Power Cycle" },
59         { 0x40, "Presence Pong" },
60         { 0x41, "Capabilities Response" },
61         { 0x42, "System State Response" },
62         { 0x43, "Open Session Response" },
63         { 0x44, "Close Session Response" },
64         { 0x80, "Presence Ping" },
65         { 0x81, "Capabilities Request" },
66         { 0x82, "System State Request" },
67         { 0x83, "Open Session Request" },
68         { 0x84, "Close Session Request" },
69         { 0xC0, "RAKP Message 1" },
70         { 0xC1, "RAKP Message 2" },
71         { 0xC2, "RAKP Message 3" },
72         { 0x00, NULL }
73 };
74
75 static void
76 dissect_asf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
77 {
78         proto_tree      *asf_tree = NULL;
79         proto_item      *ti;
80         guint8          type;
81         guint8          len;
82         tvbuff_t        *next_tvb;
83
84         col_set_str(pinfo->cinfo, COL_PROTOCOL, "ASF");
85
86         col_clear(pinfo->cinfo, COL_INFO);
87
88         type = tvb_get_guint8(tvb, 4);
89         len = tvb_get_guint8(tvb, 7);
90
91         if (check_col(pinfo->cinfo, COL_INFO))
92                 col_add_str(pinfo->cinfo, COL_INFO,
93                      val_to_str(type, asf_type_vals, "Unknown (0x%02x)"));
94
95         if (tree) {
96                 ti = proto_tree_add_item(tree, proto_asf, tvb, 0, 8, FALSE);
97                 asf_tree = proto_item_add_subtree(ti, ett_asf);
98                 /* FIXME: resolve enterprise ID */
99                 proto_tree_add_item(asf_tree, hf_asf_iana, tvb, 0, 4, FALSE);
100                 proto_tree_add_item(asf_tree, hf_asf_type, tvb, 4, 1, FALSE);
101                 proto_tree_add_item(asf_tree, hf_asf_tag, tvb, 5, 1, FALSE);
102                 proto_tree_add_item(asf_tree, hf_asf_len, tvb, 7, 1, FALSE);
103         }
104
105         if (len) {
106                 next_tvb = tvb_new_subset(tvb, 8, -1, len);
107                 call_dissector(data_handle, next_tvb, pinfo, tree);
108         }
109 }
110
111 void
112 proto_register_asf(void)
113 {
114         static hf_register_info hf[] = {
115                 { &hf_asf_iana, {
116                         "IANA Enterprise Number", "asf.iana",
117                         FT_UINT32, BASE_HEX, NULL, 0,
118                         "ASF IANA Enterprise Number", HFILL }},
119                 { &hf_asf_type, {
120                         "Message Type", "asf.type",
121                         FT_UINT8, BASE_HEX, VALS(asf_type_vals), 0,
122                         "ASF Message Type", HFILL }},
123                 { &hf_asf_tag, {
124                         "Message Tag", "asf.tag",
125                         FT_UINT8, BASE_HEX, NULL, 0,
126                         "ASF Message Tag", HFILL }},
127                 { &hf_asf_len, {
128                         "Data Length", "asf.len",
129                         FT_UINT8, BASE_DEC, NULL, 0,
130                         "ASF Data Length", HFILL }},
131         };
132         static gint *ett[] = {
133                 &ett_asf,
134         };
135
136         proto_asf = proto_register_protocol(
137                 "Alert Standard Forum", "ASF", "asf");
138
139         proto_register_field_array(proto_asf, hf, array_length(hf));
140         proto_register_subtree_array(ett, array_length(ett));
141 }
142
143 void
144 proto_reg_handoff_asf(void)
145 {
146         dissector_handle_t asf_handle;
147
148         data_handle = find_dissector("data");
149
150         asf_handle = create_dissector_handle(dissect_asf, proto_asf);
151         dissector_add("rmcp.class", RMCP_CLASS_ASF, asf_handle);
152 }