2 * Routines for ASF packet dissection
4 * Duncan Laurie <duncan@sun.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * Copied from packet-rmcp.c
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.
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.
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
35 #include <epan/packet.h>
36 #include <epan/sminmpec.h>
40 * http://www.dmtf.org/standards/standard_alert.php
41 * http://www.dmtf.org/standards/documents/ASF/DSP0136.pdf
44 #define RMCP_CLASS_ASF 0x06
46 static int proto_asf = -1;
47 static int hf_asf_iana = -1;
48 static int hf_asf_type = -1;
49 static int hf_asf_tag = -1;
50 static int hf_asf_len = -1;
51 static int hf_asf_rssp_status_code = -1;
52 static int hf_asf_mgt_console_id = -1;
53 static int hf_asf_client_id = -1;
54 static int hf_asf_payload = -1;
55 static int hf_asf_payload_type = -1;
56 static int hf_asf_payload_len = -1;
57 static int hf_asf_payload_data = -1;
58 static int hf_asf_auth_alg = -1;
59 static int hf_asf_integrity_alg = -1;
60 static int hf_asf_reserved = -1;
62 static dissector_handle_t data_handle;
63 static gint ett_asf = -1;
64 static gint ett_asf_payload = -1;
65 static gint ett_asf_alg_payload = -1;
67 #define ASF_TYPE_RESET 0x10
68 #define ASF_TYPE_PWR_UP 0x11
69 #define ASF_TYPE_PWR_DOWN 0x12
70 #define ASF_TYPE_PWR_CYCLE 0x13
71 #define ASF_TYPE_PRES_PONG 0x40
72 #define ASF_TYPE_CAP_RESP 0x41
73 #define ASF_TYPE_SYS_STATE_RESP 0x42
74 #define ASF_TYPE_OPEN_SESS_RESP 0x43
75 #define ASF_TYPE_CLOSE_SESS_RESP 0x44
76 #define ASF_TYPE_PRES_PING 0x80
77 #define ASF_TYPE_CAP_RQST 0x81
78 #define ASF_TYPE_SYS_STATE_RQST 0x82
79 #define ASF_TYPE_OPEN_SESS_RQST 0x83
80 #define ASF_TYPE_CLOSE_SESS_RQST 0x84
81 #define ASF_TYPE_RAKP_MSG_1 0xC0
82 #define ASF_TYPE_RAKP_MSG_2 0xC1
83 #define ASF_TYPE_RAKP_MSG_3 0xC2
85 static const value_string asf_type_vals[] = {
86 { ASF_TYPE_RESET, "Reset" },
87 { ASF_TYPE_PWR_UP, "Power-up" },
88 { ASF_TYPE_PWR_DOWN, "Unconditional Power-down" },
89 { ASF_TYPE_PWR_CYCLE, "Power Cycle" },
90 { ASF_TYPE_PRES_PONG, "Presence Pong" },
91 { ASF_TYPE_CAP_RESP, "Capabilities Response" },
92 { ASF_TYPE_SYS_STATE_RESP, "System State Response" },
93 { ASF_TYPE_OPEN_SESS_RESP, "Open Session Response" },
94 { ASF_TYPE_CLOSE_SESS_RESP, "Close Session Response" },
95 { ASF_TYPE_PRES_PING, "Presence Ping" },
96 { ASF_TYPE_CAP_RQST, "Capabilities Request" },
97 { ASF_TYPE_SYS_STATE_RQST, "System State Request" },
98 { ASF_TYPE_OPEN_SESS_RQST, "Open Session Request" },
99 { ASF_TYPE_CLOSE_SESS_RQST, "Close Session Request" },
100 { ASF_TYPE_RAKP_MSG_1, "RAKP Message 1" },
101 { ASF_TYPE_RAKP_MSG_2, "RAKP Message 2" },
102 { ASF_TYPE_RAKP_MSG_3, "RAKP Message 3" },
106 static const value_string asf_rssp_status_code_vals[] = {
107 { 0x00, "No errors" },
108 { 0x01, "Insufficient resources to create a session" },
109 { 0x02, "Invalid session ID" },
110 { 0x03, "Invalid payload type" },
111 { 0x04, "Invalid authentication algorithm" },
112 { 0x05, "Invalid integrity algorithm" },
113 { 0x06, "No matching authentication payload" },
114 { 0x07, "No matching integrity payload" },
118 #define ASF_PAYLOAD_TYPE_NONE 0x00
119 #define ASF_PAYLOAD_TYPE_AUTHENTICATION 0x01
120 #define ASF_PAYLOAD_TYPE_INTEGRITY 0x02
122 static const value_string asf_payload_type_vals[] = {
123 { ASF_PAYLOAD_TYPE_NONE, "No payload present (end of list)" },
124 { ASF_PAYLOAD_TYPE_AUTHENTICATION, "Authentication algorithm payload" },
125 { ASF_PAYLOAD_TYPE_INTEGRITY, "Integrity algorithm payload" },
129 static const value_string asf_authentication_type_vals[] = {
130 { 0x01, "RAKP-HMAC-SHA1" },
134 static const value_string asf_integrity_type_vals[] = {
135 { 0x01, "HMAC-SHA1-96" },
139 static void dissect_asf_open_session_request(tvbuff_t *tvb, proto_tree *tree,
140 gint offset, gint len);
141 static void dissect_asf_open_session_response(tvbuff_t *tvb, proto_tree *tree,
142 gint offset, gint len);
143 static void dissect_asf_payloads(tvbuff_t *tvb, proto_tree *tree,
144 gint offset, gint len);
145 static void dissect_asf_payload_authentication(tvbuff_t *tvb, proto_tree *tree,
146 gint offset, gint len);
147 static void dissect_asf_payload_integrity(tvbuff_t *tvb, proto_tree *tree,
148 gint offset, gint len);
151 dissect_asf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
153 proto_tree *asf_tree = NULL;
159 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ASF");
161 col_clear(pinfo->cinfo, COL_INFO);
163 type = tvb_get_guint8(tvb, 4);
164 len = tvb_get_guint8(tvb, 7);
166 if (check_col(pinfo->cinfo, COL_INFO))
167 col_add_str(pinfo->cinfo, COL_INFO,
168 val_to_str(type, asf_type_vals, "Unknown (0x%02x)"));
171 ti = proto_tree_add_item(tree, proto_asf, tvb, 0, 8, FALSE);
172 asf_tree = proto_item_add_subtree(ti, ett_asf);
173 proto_tree_add_item(asf_tree, hf_asf_iana, tvb, 0, 4, FALSE);
174 proto_tree_add_item(asf_tree, hf_asf_type, tvb, 4, 1, FALSE);
175 proto_tree_add_item(asf_tree, hf_asf_tag, tvb, 5, 1, FALSE);
176 proto_tree_add_item(asf_tree, hf_asf_len, tvb, 7, 1, FALSE);
181 case ASF_TYPE_OPEN_SESS_RQST:
182 dissect_asf_open_session_request(tvb, asf_tree, 8, len);
184 case ASF_TYPE_OPEN_SESS_RESP:
185 dissect_asf_open_session_response(tvb, asf_tree, 8, len);
188 /* TODO: Add the rest as captures become available to test. */
191 next_tvb = tvb_new_subset(tvb, 8, len, len);
192 call_dissector(data_handle, next_tvb, pinfo, tree);
200 dissect_asf_open_session_request(tvbuff_t *tvb, proto_tree *tree,
201 gint offset, gint len)
203 proto_tree_add_item(tree, hf_asf_mgt_console_id, tvb, offset, 4, FALSE);
206 dissect_asf_payloads(tvb, tree, offset, len);
210 dissect_asf_open_session_response(tvbuff_t *tvb, proto_tree *tree,
211 gint offset, gint len)
213 proto_tree_add_item(tree, hf_asf_rssp_status_code, tvb, offset, 1, FALSE);
214 proto_tree_add_item(tree, hf_asf_mgt_console_id, tvb, offset + 4, 4, FALSE);
215 proto_tree_add_item(tree, hf_asf_client_id, tvb, offset + 8, 4, FALSE);
218 dissect_asf_payloads(tvb, tree, offset, len);
222 dissect_asf_payloads(tvbuff_t *tvb, proto_tree *tree,
223 gint offset, gint len)
232 ptype = tvb_get_guint8(tvb, offset);
233 plen = tvb_get_ntohs(tvb, offset + 2);
235 ti = proto_tree_add_none_format(tree, hf_asf_payload, tvb, offset,
236 plen, "%s: %u bytes",
237 val_to_str(ptype, asf_payload_type_vals, "Unknown (%u)"), plen);
238 ptree = proto_item_add_subtree(ti, ett_asf_payload);
239 proto_tree_add_item(ptree, hf_asf_payload_type, tvb, offset, 1, FALSE);
240 proto_tree_add_item(ptree, hf_asf_payload_len, tvb, offset + 2, 2, FALSE);
241 if ( ptype && (plen > 4) )
245 case ASF_PAYLOAD_TYPE_AUTHENTICATION:
246 dissect_asf_payload_authentication(tvb, ptree,
247 offset + 4, plen - 4);
249 case ASF_PAYLOAD_TYPE_INTEGRITY:
250 dissect_asf_payload_integrity(tvb, ptree,
251 offset + 4, plen - 4);
254 proto_tree_add_item(ptree, hf_asf_payload_data, tvb,
255 offset + 4, plen - 4, FALSE);
265 dissect_asf_payload_authentication(tvbuff_t *tvb, proto_tree *tree,
266 gint offset, gint len)
272 alg = tvb_get_guint8(tvb, offset);
273 ti = proto_tree_add_none_format(tree, hf_asf_payload_data, tvb, offset,
274 len, "Authentication Algorithm: %s",
275 val_to_str(alg, asf_authentication_type_vals, "Unknown (%u)"));
276 atree = proto_item_add_subtree(ti, ett_asf_alg_payload);
277 proto_tree_add_item(atree, hf_asf_auth_alg, tvb, offset, 1, FALSE);
278 proto_tree_add_item(atree, hf_asf_reserved, tvb, offset + 1, len - 1, FALSE);
282 dissect_asf_payload_integrity(tvbuff_t *tvb, proto_tree *tree,
283 gint offset, gint len)
289 alg = tvb_get_guint8(tvb, offset);
290 ti = proto_tree_add_none_format(tree, hf_asf_payload_data, tvb, offset,
291 len, "Integrity Algorithm: %s",
292 val_to_str(alg, asf_integrity_type_vals, "Unknown (%u)"));
293 atree = proto_item_add_subtree(ti, ett_asf_alg_payload);
294 proto_tree_add_item(atree, hf_asf_integrity_alg, tvb, offset, 1, FALSE);
295 proto_tree_add_item(atree, hf_asf_reserved, tvb, offset + 1, len - 1, FALSE);
299 proto_register_asf(void)
301 static hf_register_info hf[] = {
303 "IANA Enterprise Number", "asf.iana",
304 FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0,
307 "Message Type", "asf.type",
308 FT_UINT8, BASE_HEX, VALS(asf_type_vals), 0,
309 "ASF Message Type", HFILL }},
311 "Message Tag", "asf.tag",
312 FT_UINT8, BASE_HEX, NULL, 0,
313 "ASF Message Tag", HFILL }},
315 "Data Length", "asf.len",
316 FT_UINT8, BASE_DEC, NULL, 0,
317 "ASF Data Length", HFILL }},
318 { &hf_asf_rssp_status_code, {
319 "Status Code", "asf.rssp_status_code",
320 FT_UINT8, BASE_DEC, VALS(asf_rssp_status_code_vals), 0,
321 "Identifies the status of the previous message", HFILL }},
322 { &hf_asf_mgt_console_id, {
323 "Mgt Console Session ID", "asf.mgt_console_id",
324 FT_UINT32, BASE_DEC, NULL, 0,
326 { &hf_asf_client_id, {
327 "Managed Client Session ID", "asf.client_id",
328 FT_UINT32, BASE_DEC, NULL, 0,
331 "Payload", "asf.payload",
332 FT_NONE, BASE_NONE, NULL, 0,
334 { &hf_asf_payload_type, {
335 "Payload Type", "asf.payload.type",
336 FT_UINT8, BASE_DEC, VALS(asf_payload_type_vals), 0,
337 "Identifies the type of payload that follows", HFILL }},
338 { &hf_asf_payload_len, {
339 "Payload Length", "asf.payload.len",
340 FT_UINT16, BASE_DEC, NULL, 0,
341 "The total length in bytes of the payload including the header",
343 { &hf_asf_payload_data, {
344 "Data", "asf.payload.data",
345 FT_NONE, BASE_NONE, NULL, 0,
347 { &hf_asf_auth_alg, {
348 "Authentication Algorithm", "asf.auth_alg",
349 FT_UINT8, BASE_DEC, VALS(asf_authentication_type_vals), 0,
351 { &hf_asf_integrity_alg, {
352 "Integrity Algorithm", "asf.integrity_alg",
353 FT_UINT8, BASE_DEC, VALS(asf_integrity_type_vals), 0,
355 { &hf_asf_reserved, {
356 "Reserved", "asf.reserved",
357 FT_NONE, BASE_NONE, NULL, 0,
360 static gint *ett[] = {
366 proto_asf = proto_register_protocol(
367 "Alert Standard Forum", "ASF", "asf");
369 proto_register_field_array(proto_asf, hf, array_length(hf));
370 proto_register_subtree_array(ett, array_length(ett));
374 proto_reg_handoff_asf(void)
376 dissector_handle_t asf_handle;
378 data_handle = find_dissector("data");
380 asf_handle = new_create_dissector_handle(dissect_asf, proto_asf);
381 dissector_add_uint("rmcp.class", RMCP_CLASS_ASF, asf_handle);