2 * Routines for IGMP/IGAP packet disassembly
3 * 2003, Endoh Akria (see AUTHORS for email)
5 * $Id: packet-igap.c,v 1.1 2003/12/10 19:21:55 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
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"},
128 /* This function is only called from the IGMP dissector */
130 dissect_igap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
134 guint8 type, tsecs, subtype, asize, msize, account[17], message[65];
136 if (!proto_is_protocol_enabled(find_protocol_by_id(proto_igap))) {
137 /* we are not enabled, skip entire packet to be nice
138 to the igmp layer. (so clicking on IGMP will display the data)
140 return offset + tvb_length_remaining(tvb, offset);
143 item = proto_tree_add_item(parent_tree, proto_igap, tvb, offset, -1, FALSE);
144 tree = proto_item_add_subtree(item, ett_igap);
146 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
147 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IGAP");
149 if (check_col(pinfo->cinfo, COL_INFO)) {
150 col_clear(pinfo->cinfo, COL_INFO);
153 type = tvb_get_guint8(tvb, offset);
154 if (check_col(pinfo->cinfo, COL_INFO)) {
155 col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
156 val_to_str(type, igap_types, "Unknown Type: 0x%02x"));
158 proto_tree_add_uint(tree, hf_type, tvb, offset, 1, type);
161 tsecs = tvb_get_guint8(tvb, offset);
162 proto_tree_add_uint_format(tree, hf_max_resp, tvb, offset, 1, tsecs,
163 "Max Response Time: %.1f sec (0x%02x)", tsecs * 0.1, tsecs);
166 igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
169 proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, FALSE);
172 proto_tree_add_uint(tree, hf_version, tvb, offset, 1,
173 tvb_get_guint8(tvb, offset));
176 subtype = tvb_get_guint8(tvb, offset);
177 proto_tree_add_uint(tree, hf_subtype, tvb, offset, 1, subtype);
180 proto_tree_add_uint(tree, hf_challengeid, tvb, offset, 1,
181 tvb_get_guint8(tvb, offset));
184 asize = tvb_get_guint8(tvb, offset);
185 proto_tree_add_uint(tree, hf_asize, tvb, offset, 1, asize);
188 msize = tvb_get_guint8(tvb, offset);
189 proto_tree_add_uint(tree, hf_msize, tvb, offset, 1, msize);
193 tvb_memcpy(tvb, account, offset, asize);
194 account[asize] = '\0';
195 proto_tree_add_string(tree, hf_account, tvb, offset, asize, account);
200 tvb_memcpy(tvb, message, offset, msize);
202 case IGAP_SUBTYPE_PASSWORD_JOIN:
203 case IGAP_SUBTYPE_PASSWORD_LEAVE:
204 /* Challenge field is user's password */
205 message[msize] = '\0';
206 proto_tree_add_text(tree, tvb, offset, msize,
207 "User password: %s", message);
209 case IGAP_SUBTYPE_CHALLENGE_RESPONSE_JOIN:
210 case IGAP_SUBTYPE_CHALLENGE_RESPONSE_LEAVE:
211 /* Challenge field is the results of MD5 calculation */
212 proto_tree_add_text(tree, tvb, offset, msize,
213 "Result of MD5 calculation: 0x%s",
214 bytes_to_str(message, msize));
216 case IGAP_SUBTYPE_CHALLENGE:
217 /* Challenge field is the challenge value */
218 proto_tree_add_text(tree, tvb, offset, msize,
220 bytes_to_str(message, msize));
222 case IGAP_SUBTYPE_AUTH_MESSAGE:
223 /* Challenge field indicates the result of the authenticaion */
224 proto_tree_add_text(tree, tvb, offset, msize,
225 "Authentication result: %s (0x%x)",
226 val_to_str(message[0], igap_auth_result,
227 "Unknown"), message[0]);
229 case IGAP_SUBTYPE_ACCOUNTING_MESSAGE:
230 /* Challenge field indicates the accounting status */
231 proto_tree_add_text(tree, tvb, offset, msize,
232 "Accounting status: %s (0x%x)",
233 val_to_str(message[0], igap_account_status,
234 "Unknown"), message[0]);
237 proto_tree_add_text(tree, tvb, offset, msize,
238 "Message: (Unknown)");
243 if (item) proto_item_set_len(item, offset);
249 proto_register_igap(void)
251 static hf_register_info hf[] = {
253 { "Type", "igap.type", FT_UINT8, BASE_HEX,
254 VALS(igap_types), 0, "IGAP Packet Type", HFILL }
258 { "Max Resp Time", "igap.max_resp", FT_UINT8, BASE_DEC,
259 NULL, 0, "Max Response Time", HFILL }
263 { "Checksum", "igap.checksum", FT_UINT16, BASE_HEX,
264 NULL, 0, "Checksum", HFILL }
268 { "Bad Checksum", "igap.checksum_bad", FT_BOOLEAN, BASE_NONE,
269 NULL, 0, "Bad Checksum", HFILL }
273 { "Multicast group address", "igap.maddr", FT_IPv4, BASE_NONE,
274 NULL, 0, "Multicast group address", HFILL }
278 { "Version", "igap.version", FT_UINT8, BASE_HEX,
279 VALS(igap_version), 0, "IGAP protocol version", HFILL }
283 { "Subtype", "igap.subtype", FT_UINT8, BASE_HEX,
284 VALS(igap_subtypes), 0, "Subtype", HFILL }
288 { "Challenge ID", "igap.challengeid", FT_UINT8, BASE_HEX,
289 NULL, 0, "Challenge ID", HFILL }
293 { "Account Size", "igap.asize", FT_UINT8, BASE_DEC,
294 NULL, 0, "Length of the User Account field", HFILL }
298 { "Message Size", "igap.msize", FT_UINT8, BASE_DEC,
299 NULL, 0, "Length of the Message field", HFILL }
303 { "User Account", "igap.account", FT_STRING, BASE_NONE,
304 NULL, 0, "User account", HFILL }
308 static gint *ett[] = {
312 proto_igap = proto_register_protocol
313 ("Internet Group membership Authentication Protocol",
315 proto_register_field_array(proto_igap, hf, array_length(hf));
316 proto_register_subtree_array(ett, array_length(ett));