2 * Routines for IGMP/IGAP packet disassembly
3 * 2003, Endoh Akria (see AUTHORS for email)
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
13 IGAP "Internet Group membership Authentication Protocol"
14 is defined in draft-hayashi-igap-03.txt.
17 Type Subtype Message Msize
18 -----------------------------------------------------
19 ---- 0x02 User password variable
21 ---- 0x04 Result of MD5 calculation 16
22 0x41 0x23 Challenge value ??
23 0x41 0x24 Authentication result code 1
24 0x41 0x25 Accounting status code 1
25 ---- 0x42 User password variable
27 ---- 0x44 Result of MD5 calculation 16
33 #include <epan/packet.h>
34 #include <epan/expert.h>
35 #include "packet-igmp.h"
37 void proto_register_igap(void);
38 void proto_reg_handoff_igap(void);
40 static dissector_handle_t igap_handle
;
42 static int proto_igap
;
44 static int hf_max_resp
;
45 static int hf_checksum
;
46 static int hf_checksum_status
;
48 static int hf_version
;
49 static int hf_subtype
;
50 static int hf_challengeid
;
53 static int hf_account
;
55 /* Generated from convert_proto_tree_add_text.pl */
56 static int hf_igap_challenge
;
57 static int hf_igap_user_password
;
58 static int hf_igap_authentication_result
;
59 static int hf_igap_result_of_md5_calculation
;
60 static int hf_igap_accounting_status
;
61 static int hf_igap_unknown_message
;
65 static expert_field ei_checksum
;
67 static const value_string igap_types
[] = {
68 {IGMP_IGAP_JOIN
, "Membership Report (Join)"},
69 {IGMP_IGAP_QUERY
, "Membership Query"},
70 {IGMP_IGAP_LEAVE
, "Leave Group"},
74 #define IGAP_VERSION_1 0x10
75 static const value_string igap_version
[] = {
76 {IGAP_VERSION_1
, "1"},
80 #define IGAP_SUBTYPE_PASSWORD_JOIN 0x02
81 #define IGAP_SUBTYPE_CHALLENGE_REQUEST_JOIN 0x03
82 #define IGAP_SUBTYPE_CHALLENGE_RESPONSE_JOIN 0x04
83 #define IGAP_SUBTYPE_BASIC_QUERY 0x21
84 #define IGAP_SUBTYPE_CHALLENGE 0x23
85 #define IGAP_SUBTYPE_AUTH_MESSAGE 0x24
86 #define IGAP_SUBTYPE_ACCOUNTING_MESSAGE 0x25
87 #define IGAP_SUBTYPE_BASIC_LEAVE 0x41
88 #define IGAP_SUBTYPE_PASSWORD_LEAVE 0x42
89 #define IGAP_SUBTYPE_CHALLENGE_REQUEST_LEAVE 0x43
90 #define IGAP_SUBTYPE_CHALLENGE_RESPONSE_LEAVE 0x44
91 static const value_string igap_subtypes
[] = {
92 {IGAP_SUBTYPE_PASSWORD_JOIN
, "Password Mechanism Join (Password-Join)"},
93 {IGAP_SUBTYPE_CHALLENGE_REQUEST_JOIN
, "Challenge-Response Mechanism Join Request (Challenge-Request-Join)"},
94 {IGAP_SUBTYPE_CHALLENGE_RESPONSE_JOIN
, "Challenge-Response Mechanism Join Response (Challenge-Response-Join)"},
95 {IGAP_SUBTYPE_BASIC_QUERY
, "Basic Query"},
96 {IGAP_SUBTYPE_CHALLENGE
, "Challenge-Response Mechanism Challenge (Challenge)"},
97 {IGAP_SUBTYPE_AUTH_MESSAGE
, "Authentication Message"},
98 {IGAP_SUBTYPE_ACCOUNTING_MESSAGE
, "Accounting Message"},
99 {IGAP_SUBTYPE_BASIC_LEAVE
, "Basic Leave"},
100 {IGAP_SUBTYPE_PASSWORD_LEAVE
, "Password Mechanism Leave (Password-Leave)"},
101 {IGAP_SUBTYPE_CHALLENGE_REQUEST_LEAVE
, "Challenge-Response Mechanism Leave Challenge Request (Challenge-Request-Leave)"},
102 {IGAP_SUBTYPE_CHALLENGE_RESPONSE_LEAVE
, "Challenge-Response Mechanism Response (Challenge-Response-Leave)"},
106 #define IGAP_AUTH_SUCCESS 0x11
107 #define IGAP_AUTH_FAIL 0x21
108 static const value_string igap_auth_result
[] = {
109 {IGAP_AUTH_SUCCESS
, "Authentication success"},
110 {IGAP_AUTH_FAIL
, "Authentication failure"},
114 #define IGAP_ACCOUNT_START 0x11
115 #define IGAP_ACCOUNT_STOP 0x21
116 static const value_string igap_account_status
[] = {
117 {IGAP_ACCOUNT_START
, "Accounting start"},
118 {IGAP_ACCOUNT_STOP
, "Accounting stop"},
122 #define ACCOUNT_SIZE 16
123 #define MESSAGE_SIZE 64
125 /* This function is only called from the IGMP dissector */
127 dissect_igap(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void* data _U_
)
131 uint8_t type
, tsecs
, subtype
, asize
, msize
;
132 uint8_t authentication_result
, accounting_status
;
135 item
= proto_tree_add_item(parent_tree
, proto_igap
, tvb
, offset
, -1, ENC_NA
);
136 tree
= proto_item_add_subtree(item
, ett_igap
);
138 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "IGAP");
139 col_clear(pinfo
->cinfo
, COL_INFO
);
141 type
= tvb_get_uint8(tvb
, offset
);
142 col_add_str(pinfo
->cinfo
, COL_INFO
,
143 val_to_str(type
, igap_types
, "Unknown Type: 0x%02x"));
144 proto_tree_add_uint(tree
, hf_type
, tvb
, offset
, 1, type
);
147 tsecs
= tvb_get_uint8(tvb
, offset
);
148 proto_tree_add_uint_format_value(tree
, hf_max_resp
, tvb
, offset
, 1, tsecs
,
149 "%.1f sec (0x%02x)", tsecs
* 0.1, tsecs
);
152 igmp_checksum(tree
, tvb
, hf_checksum
, hf_checksum_status
, &ei_checksum
, pinfo
, 0);
155 proto_tree_add_item(tree
, hf_maddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
158 proto_tree_add_item(tree
, hf_version
, tvb
, offset
, 1, ENC_NA
);
161 subtype
= tvb_get_uint8(tvb
, offset
);
162 proto_tree_add_uint(tree
, hf_subtype
, tvb
, offset
, 1, subtype
);
165 proto_tree_add_item(tree
, hf_challengeid
, tvb
, offset
, 1, ENC_NA
);
168 asize
= tvb_get_uint8(tvb
, offset
);
169 proto_tree_add_uint(tree
, hf_asize
, tvb
, offset
, 1, asize
);
172 msize
= tvb_get_uint8(tvb
, offset
);
173 proto_tree_add_uint(tree
, hf_msize
, tvb
, offset
, 1, msize
);
177 if (asize
> ACCOUNT_SIZE
) {
178 /* Bogus account size.
180 asize
= ACCOUNT_SIZE
;
182 /* XXX - encoding? */
183 proto_tree_add_item(tree
, hf_account
, tvb
, offset
, asize
, ENC_ASCII
);
185 offset
+= ACCOUNT_SIZE
;
188 if (msize
> MESSAGE_SIZE
) {
189 /* Bogus message size.
191 msize
= MESSAGE_SIZE
;
194 case IGAP_SUBTYPE_PASSWORD_JOIN
:
195 case IGAP_SUBTYPE_PASSWORD_LEAVE
:
196 /* Challenge field is user's password */
197 /* XXX - encoding? */
198 proto_tree_add_item(tree
, hf_igap_user_password
, tvb
, offset
, msize
, ENC_ASCII
);
200 case IGAP_SUBTYPE_CHALLENGE_RESPONSE_JOIN
:
201 case IGAP_SUBTYPE_CHALLENGE_RESPONSE_LEAVE
:
202 /* Challenge field is the results of MD5 calculation */
203 proto_tree_add_item(tree
, hf_igap_result_of_md5_calculation
, tvb
, offset
, msize
, ENC_NA
);
205 case IGAP_SUBTYPE_CHALLENGE
:
206 /* Challenge field is the challenge value */
207 proto_tree_add_item(tree
, hf_igap_challenge
, tvb
, offset
, msize
, ENC_NA
);
209 case IGAP_SUBTYPE_AUTH_MESSAGE
:
210 /* Challenge field indicates the result of the authentication */
211 /* XXX - what if the length isn't 1? */
212 authentication_result
= tvb_get_uint8(tvb
, offset
);
213 proto_tree_add_uint(tree
, hf_igap_authentication_result
, tvb
, offset
, msize
, authentication_result
);
215 case IGAP_SUBTYPE_ACCOUNTING_MESSAGE
:
216 /* Challenge field indicates the accounting status */
217 /* XXX - what if the length isn't 1? */
218 accounting_status
= tvb_get_uint8(tvb
, offset
);
219 proto_tree_add_uint(tree
, hf_igap_accounting_status
, tvb
, offset
, msize
, accounting_status
);
222 proto_tree_add_item(tree
, hf_igap_unknown_message
, tvb
, offset
, msize
, ENC_NA
);
225 offset
+= MESSAGE_SIZE
;
227 if (item
) proto_item_set_len(item
, offset
);
233 proto_register_igap(void)
235 static hf_register_info hf
[] = {
237 { "Type", "igap.type",
238 FT_UINT8
, BASE_HEX
, VALS(igap_types
), 0,
239 "IGAP Packet Type", HFILL
}
242 { "Max Response Time", "igap.max_resp",
243 FT_UINT8
, BASE_DEC
, NULL
, 0,
247 { "Checksum", "igap.checksum",
248 FT_UINT16
, BASE_HEX
, NULL
, 0,
251 { &hf_checksum_status
,
252 { "Checksum Status", "igap.checksum.status",
253 FT_UINT8
, BASE_NONE
, VALS(proto_checksum_vals
), 0x0,
257 { "Multicast group address", "igap.maddr",
258 FT_IPv4
, BASE_NONE
, NULL
, 0,
262 { "Version", "igap.version",
263 FT_UINT8
, BASE_HEX
, VALS(igap_version
), 0,
264 "IGAP protocol version", HFILL
}
267 { "Subtype", "igap.subtype",
268 FT_UINT8
, BASE_HEX
, VALS(igap_subtypes
), 0,
272 { "Challenge ID", "igap.challengeid",
273 FT_UINT8
, BASE_HEX
, NULL
, 0,
277 { "Account Size", "igap.asize",
278 FT_UINT8
, BASE_DEC
, NULL
, 0,
279 "Length of the User Account field", HFILL
}
282 { "Message Size", "igap.msize",
283 FT_UINT8
, BASE_DEC
, NULL
, 0,
284 "Length of the Message field", HFILL
}
287 { "User Account", "igap.account",
288 FT_STRING
, BASE_NONE
, NULL
, 0,
292 /* Generated from convert_proto_tree_add_text.pl */
293 { &hf_igap_user_password
,
294 { "User password", "igap.user_password",
295 FT_STRING
, BASE_NONE
, NULL
, 0x0,
298 { &hf_igap_result_of_md5_calculation
,
299 { "Result of MD5 calculation", "igap.result_of_md5_calculation",
300 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
303 { &hf_igap_challenge
,
304 { "Challenge", "igap.challenge",
305 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
308 { &hf_igap_authentication_result
,
309 { "Authentication result", "igap.authentication_result",
310 FT_UINT8
, BASE_HEX
, VALS(igap_auth_result
), 0x0,
313 { &hf_igap_accounting_status
,
314 { "Accounting status", "igap.accounting_status",
315 FT_UINT8
, BASE_HEX
, VALS(igap_account_status
), 0x0,
318 { &hf_igap_unknown_message
,
319 { "Unknown message", "igap.unknown_message",
320 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
325 static ei_register_info ei
[] = {
326 { &ei_checksum
, { "igap.bad_checksum", PI_CHECKSUM
, PI_ERROR
, "Bad checksum", EXPFILL
}},
329 expert_module_t
* expert_igap
;
331 static int *ett
[] = {
335 proto_igap
= proto_register_protocol("Internet Group membership Authentication Protocol", "IGAP", "igap");
336 proto_register_field_array(proto_igap
, hf
, array_length(hf
));
337 proto_register_subtree_array(ett
, array_length(ett
));
338 expert_igap
= expert_register_protocol(proto_igap
);
339 expert_register_field_array(expert_igap
, ei
, array_length(ei
));
341 igap_handle
= register_dissector("igap", dissect_igap
, proto_igap
);
345 proto_reg_handoff_igap(void)
347 dissector_add_uint("igmp.type", IGMP_IGAP_JOIN
, igap_handle
);
348 dissector_add_uint("igmp.type", IGMP_IGAP_QUERY
, igap_handle
);
349 dissector_add_uint("igmp.type", IGMP_IGAP_LEAVE
, igap_handle
);
353 * Editor modelines - https://www.wireshark.org/tools/modelines.html
358 * indent-tabs-mode: nil
361 * vi: set shiftwidth=4 tabstop=8 expandtab:
362 * :indentSize=4:tabSize=8:noTabs=true: