2 * Routines for IGMP/IGAP packet disassembly
3 * 2003, Endoh Akria (see AUTHORS for email)
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 IGAP "Internet Group membership Authentication Protocol"
28 is defined in draft-hayashi-igap-03.txt.
31 Type Subtype Message Msize
32 -----------------------------------------------------
33 ---- 0x02 User password variable
35 ---- 0x04 Result of MD5 calculation 16
36 0x41 0x23 Challenge value ??
37 0x41 0x24 Authentication result code 1
38 0x41 0x25 Accounting status code 1
39 ---- 0x42 User password variable
41 ---- 0x44 Result of MD5 calculation 16
50 #include <epan/packet.h>
51 #include <epan/strutil.h>
52 #include "packet-igmp.h"
53 #include "packet-igap.h"
56 static int proto_igap = -1;
57 static int hf_type = -1;
58 static int hf_max_resp = -1;
59 static int hf_checksum = -1;
60 static int hf_checksum_bad = -1;
61 static int hf_maddr = -1;
62 static int hf_version = -1;
63 static int hf_subtype = -1;
64 static int hf_challengeid = -1;
65 static int hf_asize = -1;
66 static int hf_msize = -1;
67 static int hf_account = -1;
69 static int ett_igap = -1;
72 static const value_string igap_types[] = {
73 {IGMP_IGAP_JOIN, "Membership Report (Join)"},
74 {IGMP_IGAP_QUERY, "Membership Query"},
75 {IGMP_IGAP_LEAVE, "Leave Group"},
79 #define IGAP_VERSION_1 0x10
80 static const value_string igap_version[] = {
81 {IGAP_VERSION_1, "1"},
85 #define IGAP_SUBTYPE_PASSWORD_JOIN 0x02
86 #define IGAP_SUBTYPE_CHALLENGE_REQUEST_JOIN 0x03
87 #define IGAP_SUBTYPE_CHALLENGE_RESPONSE_JOIN 0x04
88 #define IGAP_SUBTYPE_BASIC_QUERY 0x21
89 #define IGAP_SUBTYPE_CHALLENGE 0x23
90 #define IGAP_SUBTYPE_AUTH_MESSAGE 0x24
91 #define IGAP_SUBTYPE_ACCOUNTING_MESSAGE 0x25
92 #define IGAP_SUBTYPE_BASIC_LEAVE 0x41
93 #define IGAP_SUBTYPE_PASSWORD_LEAVE 0x42
94 #define IGAP_SUBTYPE_CHALLENGE_REQUEST_LEAVE 0x43
95 #define IGAP_SUBTYPE_CHALLENGE_RESPONSE_LEAVE 0x44
96 static const value_string igap_subtypes[] = {
97 {IGAP_SUBTYPE_PASSWORD_JOIN, "Password Mechanism Join (Password-Join)"},
98 {IGAP_SUBTYPE_CHALLENGE_REQUEST_JOIN, "Challenge-Response Mechanism Join Request (Challenge-Request-Join)"},
99 {IGAP_SUBTYPE_CHALLENGE_RESPONSE_JOIN, "Challenge-Response Mechanism Join Response (Challenge-Response-Join)"},
100 {IGAP_SUBTYPE_BASIC_QUERY, "Basic Query"},
101 {IGAP_SUBTYPE_CHALLENGE, "Challenge-Response Mechanism Challenge (Challenge)"},
102 {IGAP_SUBTYPE_AUTH_MESSAGE, "Authentication Message"},
103 {IGAP_SUBTYPE_ACCOUNTING_MESSAGE, "Accounting Message"},
104 {IGAP_SUBTYPE_BASIC_LEAVE, "Basic Leave"},
105 {IGAP_SUBTYPE_PASSWORD_LEAVE, "Password Mechanism Leave (Password-Leave)"},
106 {IGAP_SUBTYPE_CHALLENGE_REQUEST_LEAVE, "Challenge-Response Mechanism Leave Challenge Request (Challenge-Request-Leave)"},
107 {IGAP_SUBTYPE_CHALLENGE_RESPONSE_LEAVE, "Challenge-Response Mechanism Response (Challenge-Response-Leave)"},
111 #define IGAP_AUTH_SUCCESS 0x11
112 #define IGAP_AUTH_FAIL 0x21
113 static const value_string igap_auth_result[] = {
114 {IGAP_AUTH_SUCCESS, "Authentication success"},
115 {IGAP_AUTH_FAIL, "Authentication failure"},
119 #define IGAP_ACCOUNT_START 0x11
120 #define IGAP_ACCOUNT_STOP 0x21
121 static const value_string igap_account_status[] = {
122 {IGAP_ACCOUNT_START, "Accounting start"},
123 {IGAP_ACCOUNT_STOP, "Accounting stop"},
127 #define ACCOUNT_SIZE 16
128 #define MESSAGE_SIZE 64
130 /* This function is only called from the IGMP dissector */
132 dissect_igap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
136 guint8 type, tsecs, subtype, asize, msize;
137 guchar account[ACCOUNT_SIZE+1], message[MESSAGE_SIZE+1];
139 if (!proto_is_protocol_enabled(find_protocol_by_id(proto_igap))) {
140 /* we are not enabled, skip entire packet to be nice
141 to the igmp layer. (so clicking on IGMP will display the data)
143 return offset + tvb_length_remaining(tvb, offset);
146 item = proto_tree_add_item(parent_tree, proto_igap, tvb, offset, -1, FALSE);
147 tree = proto_item_add_subtree(item, ett_igap);
149 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
150 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IGAP");
152 if (check_col(pinfo->cinfo, COL_INFO)) {
153 col_clear(pinfo->cinfo, COL_INFO);
156 type = tvb_get_guint8(tvb, offset);
157 if (check_col(pinfo->cinfo, COL_INFO)) {
158 col_add_str(pinfo->cinfo, COL_INFO,
159 val_to_str(type, igap_types, "Unknown Type: 0x%02x"));
161 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
164 tsecs = tvb_get_guint8(tvb, offset);
165 proto_tree_add_uint_format(tree, hf_max_resp, tvb, offset, 1, tsecs,
166 "Max Response Time: %.1f sec (0x%02x)", tsecs * 0.1, tsecs);
169 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
172 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
175 proto_tree_add_uint(tree, hf_version, tvb, offset, 1,
176 tvb_get_guint8(tvb, offset));
179 subtype = tvb_get_guint8(tvb, offset);
180 proto_tree_add_uint(tree, hf_subtype, tvb, offset, 1, subtype);
183 proto_tree_add_uint(tree, hf_challengeid, tvb, offset, 1,
184 tvb_get_guint8(tvb, offset));
187 asize = tvb_get_guint8(tvb, offset);
188 proto_tree_add_uint(tree, hf_asize, tvb, offset, 1, asize);
191 msize = tvb_get_guint8(tvb, offset);
192 proto_tree_add_uint(tree, hf_msize, tvb, offset, 1, msize);
196 if (asize > ACCOUNT_SIZE) {
197 /* Bogus account size.
199 asize = ACCOUNT_SIZE;
201 tvb_memcpy(tvb, account, offset, asize);
202 account[asize] = '\0';
203 proto_tree_add_string(tree, hf_account, tvb, offset, asize, account);
205 offset += ACCOUNT_SIZE;
208 if (msize > MESSAGE_SIZE) {
209 /* Bogus message size.
211 msize = MESSAGE_SIZE;
213 tvb_memcpy(tvb, message, offset, msize);
215 case IGAP_SUBTYPE_PASSWORD_JOIN:
216 case IGAP_SUBTYPE_PASSWORD_LEAVE:
217 /* Challenge field is user's password */
218 message[msize] = '\0';
219 proto_tree_add_text(tree, tvb, offset, msize,
220 "User password: %s", message);
222 case IGAP_SUBTYPE_CHALLENGE_RESPONSE_JOIN:
223 case IGAP_SUBTYPE_CHALLENGE_RESPONSE_LEAVE:
224 /* Challenge field is the results of MD5 calculation */
225 proto_tree_add_text(tree, tvb, offset, msize,
226 "Result of MD5 calculation: 0x%s",
227 bytes_to_str(message, msize));
229 case IGAP_SUBTYPE_CHALLENGE:
230 /* Challenge field is the challenge value */
231 proto_tree_add_text(tree, tvb, offset, msize,
233 bytes_to_str(message, msize));
235 case IGAP_SUBTYPE_AUTH_MESSAGE:
236 /* Challenge field indicates the result of the authenticaion */
237 proto_tree_add_text(tree, tvb, offset, msize,
238 "Authentication result: %s (0x%x)",
239 val_to_str(message[0], igap_auth_result,
240 "Unknown"), message[0]);
242 case IGAP_SUBTYPE_ACCOUNTING_MESSAGE:
243 /* Challenge field indicates the accounting status */
244 proto_tree_add_text(tree, tvb, offset, msize,
245 "Accounting status: %s (0x%x)",
246 val_to_str(message[0], igap_account_status,
247 "Unknown"), message[0]);
250 proto_tree_add_text(tree, tvb, offset, msize,
251 "Message: (Unknown)");
254 offset += MESSAGE_SIZE;
256 if (item) proto_item_set_len(item, offset);
262 proto_register_igap(void)
264 static hf_register_info hf[] = {
266 { "Type", "igap.type", FT_UINT8, BASE_HEX,
267 VALS(igap_types), 0, "IGAP Packet Type", HFILL }
271 { "Max Resp Time", "igap.max_resp", FT_UINT8, BASE_DEC,
272 NULL, 0, "Max Response Time", HFILL }
276 { "Checksum", "igap.checksum", FT_UINT16, BASE_HEX,
277 NULL, 0, "Checksum", HFILL }
281 { "Bad Checksum", "igap.checksum_bad", FT_BOOLEAN, BASE_NONE,
282 NULL, 0, "Bad Checksum", HFILL }
286 { "Multicast group address", "igap.maddr", FT_IPv4, BASE_NONE,
287 NULL, 0, "Multicast group address", HFILL }
291 { "Version", "igap.version", FT_UINT8, BASE_HEX,
292 VALS(igap_version), 0, "IGAP protocol version", HFILL }
296 { "Subtype", "igap.subtype", FT_UINT8, BASE_HEX,
297 VALS(igap_subtypes), 0, "Subtype", HFILL }
301 { "Challenge ID", "igap.challengeid", FT_UINT8, BASE_HEX,
302 NULL, 0, "Challenge ID", HFILL }
306 { "Account Size", "igap.asize", FT_UINT8, BASE_DEC,
307 NULL, 0, "Length of the User Account field", HFILL }
311 { "Message Size", "igap.msize", FT_UINT8, BASE_DEC,
312 NULL, 0, "Length of the Message field", HFILL }
316 { "User Account", "igap.account", FT_STRING, BASE_NONE,
317 NULL, 0, "User account", HFILL }
321 static gint *ett[] = {
325 proto_igap = proto_register_protocol
326 ("Internet Group membership Authentication Protocol",
328 proto_register_field_array(proto_igap, hf, array_length(hf));
329 proto_register_subtree_array(ett, array_length(ett));