2 * Routines for ASF packet dissection
4 * Duncan Laurie <duncan@sun.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-rmcp.c
12 * SPDX-License-Identifier: GPL-2.0-or-later
17 #include <epan/packet.h>
18 #include <epan/expert.h>
19 #include <epan/addr_resolv.h>
23 * http://www.dmtf.org/standards/standard_alert.php
24 * https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf
27 void proto_register_asf(void);
28 void proto_reg_handoff_asf(void);
30 static dissector_handle_t asf_handle
;
32 #define RMCP_CLASS_ASF 0x06
35 static int hf_asf_iana
;
36 static int hf_asf_type
;
37 static int hf_asf_tag
;
38 static int hf_asf_len
;
39 static int hf_asf_rssp_status_code
;
40 static int hf_asf_mgt_console_id
;
41 static int hf_asf_client_id
;
42 static int hf_asf_payload
;
43 static int hf_asf_payload_type
;
44 static int hf_asf_payload_len
;
45 static int hf_asf_payload_data
;
46 static int hf_asf_auth_alg
;
47 static int hf_asf_integrity_alg
;
48 static int hf_asf_reserved
;
51 static int ett_asf_payload
;
52 static int ett_asf_alg_payload
;
54 static expert_field ei_asf_payload_too_short
;
57 #define ASF_TYPE_RESET 0x10
58 #define ASF_TYPE_PWR_UP 0x11
59 #define ASF_TYPE_PWR_DOWN 0x12
60 #define ASF_TYPE_PWR_CYCLE 0x13
61 #define ASF_TYPE_PRES_PONG 0x40
62 #define ASF_TYPE_CAP_RESP 0x41
63 #define ASF_TYPE_SYS_STATE_RESP 0x42
64 #define ASF_TYPE_OPEN_SESS_RESP 0x43
65 #define ASF_TYPE_CLOSE_SESS_RESP 0x44
66 #define ASF_TYPE_PRES_PING 0x80
67 #define ASF_TYPE_CAP_RQST 0x81
68 #define ASF_TYPE_SYS_STATE_RQST 0x82
69 #define ASF_TYPE_OPEN_SESS_RQST 0x83
70 #define ASF_TYPE_CLOSE_SESS_RQST 0x84
71 #define ASF_TYPE_RAKP_MSG_1 0xC0
72 #define ASF_TYPE_RAKP_MSG_2 0xC1
73 #define ASF_TYPE_RAKP_MSG_3 0xC2
75 static const value_string asf_type_vals
[] = {
76 { ASF_TYPE_RESET
, "Reset" },
77 { ASF_TYPE_PWR_UP
, "Power-up" },
78 { ASF_TYPE_PWR_DOWN
, "Unconditional Power-down" },
79 { ASF_TYPE_PWR_CYCLE
, "Power Cycle" },
80 { ASF_TYPE_PRES_PONG
, "Presence Pong" },
81 { ASF_TYPE_CAP_RESP
, "Capabilities Response" },
82 { ASF_TYPE_SYS_STATE_RESP
, "System State Response" },
83 { ASF_TYPE_OPEN_SESS_RESP
, "Open Session Response" },
84 { ASF_TYPE_CLOSE_SESS_RESP
, "Close Session Response" },
85 { ASF_TYPE_PRES_PING
, "Presence Ping" },
86 { ASF_TYPE_CAP_RQST
, "Capabilities Request" },
87 { ASF_TYPE_SYS_STATE_RQST
, "System State Request" },
88 { ASF_TYPE_OPEN_SESS_RQST
, "Open Session Request" },
89 { ASF_TYPE_CLOSE_SESS_RQST
, "Close Session Request" },
90 { ASF_TYPE_RAKP_MSG_1
, "RAKP Message 1" },
91 { ASF_TYPE_RAKP_MSG_2
, "RAKP Message 2" },
92 { ASF_TYPE_RAKP_MSG_3
, "RAKP Message 3" },
96 static const value_string asf_rssp_status_code_vals
[] = {
97 { 0x00, "No errors" },
98 { 0x01, "Insufficient resources to create a session" },
99 { 0x02, "Invalid session ID" },
100 { 0x03, "Invalid payload type" },
101 { 0x04, "Invalid authentication algorithm" },
102 { 0x05, "Invalid integrity algorithm" },
103 { 0x06, "No matching authentication payload" },
104 { 0x07, "No matching integrity payload" },
108 #define ASF_PAYLOAD_TYPE_NONE 0x00
109 #define ASF_PAYLOAD_TYPE_AUTHENTICATION 0x01
110 #define ASF_PAYLOAD_TYPE_INTEGRITY 0x02
112 static const value_string asf_payload_type_vals
[] = {
113 { ASF_PAYLOAD_TYPE_NONE
, "No payload present (end of list)" },
114 { ASF_PAYLOAD_TYPE_AUTHENTICATION
, "Authentication algorithm payload" },
115 { ASF_PAYLOAD_TYPE_INTEGRITY
, "Integrity algorithm payload" },
119 static const value_string asf_authentication_type_vals
[] = {
120 { 0x01, "RAKP-HMAC-SHA1" },
124 static const value_string asf_integrity_type_vals
[] = {
125 { 0x01, "HMAC-SHA1-96" },
129 static void dissect_asf_open_session_request(tvbuff_t
*tvb
, packet_info
*pinfo
,
130 proto_tree
*tree
, int offset
, int len
);
131 static void dissect_asf_open_session_response(tvbuff_t
*tvb
, packet_info
*pinfo
,
132 proto_tree
*tree
, int offset
, int len
);
133 static void dissect_asf_payloads(tvbuff_t
*tvb
, packet_info
*pinfo
,
134 proto_tree
*tree
, int offset
, int len
);
135 static void dissect_asf_payload_authentication(tvbuff_t
*tvb
, proto_tree
*tree
,
136 int offset
, int len
);
137 static void dissect_asf_payload_integrity(tvbuff_t
*tvb
, proto_tree
*tree
,
138 int offset
, int len
);
141 dissect_asf(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
143 proto_tree
*asf_tree
= NULL
;
149 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ASF");
151 col_clear(pinfo
->cinfo
, COL_INFO
);
153 type
= tvb_get_uint8(tvb
, 4);
154 len
= tvb_get_uint8(tvb
, 7);
156 col_add_str(pinfo
->cinfo
, COL_INFO
,
157 val_to_str(type
, asf_type_vals
, "Unknown (0x%02x)"));
160 ti
= proto_tree_add_item(tree
, proto_asf
, tvb
, 0, 8,ENC_NA
);
161 asf_tree
= proto_item_add_subtree(ti
, ett_asf
);
162 proto_tree_add_item(asf_tree
, hf_asf_iana
, tvb
, 0, 4,ENC_BIG_ENDIAN
);
163 proto_tree_add_item(asf_tree
, hf_asf_type
, tvb
, 4, 1,ENC_BIG_ENDIAN
);
164 proto_tree_add_item(asf_tree
, hf_asf_tag
, tvb
, 5, 1,ENC_BIG_ENDIAN
);
165 proto_tree_add_item(asf_tree
, hf_asf_len
, tvb
, 7, 1,ENC_BIG_ENDIAN
);
170 case ASF_TYPE_OPEN_SESS_RQST
:
171 dissect_asf_open_session_request(tvb
, pinfo
, asf_tree
, 8, len
);
173 case ASF_TYPE_OPEN_SESS_RESP
:
174 dissect_asf_open_session_response(tvb
, pinfo
, asf_tree
, 8, len
);
177 /* TODO: Add the rest as captures become available to test. */
180 next_tvb
= tvb_new_subset_length(tvb
, 8, len
);
181 call_data_dissector(next_tvb
, pinfo
, tree
);
189 dissect_asf_open_session_request(tvbuff_t
*tvb
, packet_info
*pinfo
,
190 proto_tree
*tree
, int offset
, int len
)
192 proto_tree_add_item(tree
, hf_asf_mgt_console_id
, tvb
, offset
, 4,ENC_BIG_ENDIAN
);
195 dissect_asf_payloads(tvb
, pinfo
, tree
, offset
, len
);
199 dissect_asf_open_session_response(tvbuff_t
*tvb
, packet_info
*pinfo
,
200 proto_tree
*tree
, int offset
, int len
)
202 proto_tree_add_item(tree
, hf_asf_rssp_status_code
, tvb
, offset
, 1,ENC_BIG_ENDIAN
);
203 proto_tree_add_item(tree
, hf_asf_mgt_console_id
, tvb
, offset
+ 4, 4,ENC_BIG_ENDIAN
);
204 proto_tree_add_item(tree
, hf_asf_client_id
, tvb
, offset
+ 8, 4,ENC_BIG_ENDIAN
);
207 dissect_asf_payloads(tvb
, pinfo
, tree
, offset
, len
);
211 dissect_asf_payloads(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
221 ptype
= tvb_get_uint8(tvb
, offset
);
222 plen
= tvb_get_ntohs(tvb
, offset
+ 2);
224 ti
= proto_tree_add_none_format(tree
, hf_asf_payload
, tvb
, offset
,
225 plen
, "%s: %u bytes",
226 val_to_str(ptype
, asf_payload_type_vals
, "Unknown (%u)"), plen
);
227 ptree
= proto_item_add_subtree(ti
, ett_asf_payload
);
228 proto_tree_add_item(ptree
, hf_asf_payload_type
, tvb
, offset
, 1,ENC_BIG_ENDIAN
);
229 ti
= proto_tree_add_item(ptree
, hf_asf_payload_len
, tvb
, offset
+ 2, 2,ENC_BIG_ENDIAN
);
232 expert_add_info(pinfo
, ti
, &ei_asf_payload_too_short
);
235 if ( ptype
&& (plen
> 4) )
239 case ASF_PAYLOAD_TYPE_AUTHENTICATION
:
240 dissect_asf_payload_authentication(tvb
, ptree
,
241 offset
+ 4, plen
- 4);
243 case ASF_PAYLOAD_TYPE_INTEGRITY
:
244 dissect_asf_payload_integrity(tvb
, ptree
,
245 offset
+ 4, plen
- 4);
248 proto_tree_add_item(ptree
, hf_asf_payload_data
, tvb
,
249 offset
+ 4, plen
- 4,ENC_NA
);
259 dissect_asf_payload_authentication(tvbuff_t
*tvb
, proto_tree
*tree
,
266 alg
= tvb_get_uint8(tvb
, offset
);
267 ti
= proto_tree_add_none_format(tree
, hf_asf_payload_data
, tvb
, offset
,
268 len
, "Authentication Algorithm: %s",
269 val_to_str(alg
, asf_authentication_type_vals
, "Unknown (%u)"));
270 atree
= proto_item_add_subtree(ti
, ett_asf_alg_payload
);
271 proto_tree_add_item(atree
, hf_asf_auth_alg
, tvb
, offset
, 1,ENC_BIG_ENDIAN
);
272 proto_tree_add_item(atree
, hf_asf_reserved
, tvb
, offset
+ 1, len
- 1,ENC_NA
);
276 dissect_asf_payload_integrity(tvbuff_t
*tvb
, proto_tree
*tree
,
283 alg
= tvb_get_uint8(tvb
, offset
);
284 ti
= proto_tree_add_none_format(tree
, hf_asf_payload_data
, tvb
, offset
,
285 len
, "Integrity Algorithm: %s",
286 val_to_str(alg
, asf_integrity_type_vals
, "Unknown (%u)"));
287 atree
= proto_item_add_subtree(ti
, ett_asf_alg_payload
);
288 proto_tree_add_item(atree
, hf_asf_integrity_alg
, tvb
, offset
, 1,ENC_BIG_ENDIAN
);
289 proto_tree_add_item(atree
, hf_asf_reserved
, tvb
, offset
+ 1, len
- 1,ENC_NA
);
293 proto_register_asf(void)
295 static hf_register_info hf
[] = {
297 "IANA Enterprise Number", "asf.iana",
298 FT_UINT32
, BASE_ENTERPRISES
, STRINGS_ENTERPRISES
, 0,
301 "Message Type", "asf.type",
302 FT_UINT8
, BASE_HEX
, VALS(asf_type_vals
), 0,
303 "ASF Message Type", HFILL
}},
305 "Message Tag", "asf.tag",
306 FT_UINT8
, BASE_HEX
, NULL
, 0,
307 "ASF Message Tag", HFILL
}},
309 "Data Length", "asf.len",
310 FT_UINT8
, BASE_DEC
, NULL
, 0,
311 "ASF Data Length", HFILL
}},
312 { &hf_asf_rssp_status_code
, {
313 "Status Code", "asf.rssp_status_code",
314 FT_UINT8
, BASE_DEC
, VALS(asf_rssp_status_code_vals
), 0,
315 "Identifies the status of the previous message", HFILL
}},
316 { &hf_asf_mgt_console_id
, {
317 "Mgt Console Session ID", "asf.mgt_console_id",
318 FT_UINT32
, BASE_DEC
, NULL
, 0,
320 { &hf_asf_client_id
, {
321 "Managed Client Session ID", "asf.client_id",
322 FT_UINT32
, BASE_DEC
, NULL
, 0,
325 "Payload", "asf.payload",
326 FT_NONE
, BASE_NONE
, NULL
, 0,
328 { &hf_asf_payload_type
, {
329 "Payload Type", "asf.payload.type",
330 FT_UINT8
, BASE_DEC
, VALS(asf_payload_type_vals
), 0,
331 "Identifies the type of payload that follows", HFILL
}},
332 { &hf_asf_payload_len
, {
333 "Payload Length", "asf.payload.len",
334 FT_UINT16
, BASE_DEC
, NULL
, 0,
335 "The total length in bytes of the payload including the header",
337 { &hf_asf_payload_data
, {
338 "Data", "asf.payload.data",
339 FT_NONE
, BASE_NONE
, NULL
, 0,
341 { &hf_asf_auth_alg
, {
342 "Authentication Algorithm", "asf.auth_alg",
343 FT_UINT8
, BASE_DEC
, VALS(asf_authentication_type_vals
), 0,
345 { &hf_asf_integrity_alg
, {
346 "Integrity Algorithm", "asf.integrity_alg",
347 FT_UINT8
, BASE_DEC
, VALS(asf_integrity_type_vals
), 0,
349 { &hf_asf_reserved
, {
350 "Reserved", "asf.reserved",
351 FT_NONE
, BASE_NONE
, NULL
, 0,
354 static int *ett
[] = {
360 static ei_register_info ei
[] = {
361 { &ei_asf_payload_too_short
, { "asf.payload_too_short", PI_MALFORMED
, PI_ERROR
, "Payload length too short to include the type and length", EXPFILL
}},
364 expert_module_t
* expert_asf
;
366 proto_asf
= proto_register_protocol("Alert Standard Forum", "ASF", "asf");
368 proto_register_field_array(proto_asf
, hf
, array_length(hf
));
369 proto_register_subtree_array(ett
, array_length(ett
));
370 expert_asf
= expert_register_protocol(proto_asf
);
371 expert_register_field_array(expert_asf
, ei
, array_length(ei
));
373 asf_handle
= register_dissector("asf", dissect_asf
, proto_asf
);
377 proto_reg_handoff_asf(void)
379 dissector_add_uint("rmcp.class", RMCP_CLASS_ASF
, asf_handle
);
383 * Editor modelines - https://www.wireshark.org/tools/modelines.html
388 * indent-tabs-mode: t
391 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
392 * :indentSize=8:tabSize=8:noTabs=false: