2 * Routines for AIM Instant Messenger (OSCAR) dissection, SNAC Signon
3 * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
4 * Copyright 2000, Ralf Hoelzer <ralf@well.com>
6 * $Id: packet-aim-signon.c,v 1.3 2004/04/26 18:21:10 obiot Exp $
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include <epan/packet.h>
39 #include <epan/strutil.h>
41 #include "packet-aim.h"
43 #define FAMILY_SIGNON 0x0017
46 #define FAMILY_SIGNON_ERROR 0x0001
47 #define FAMILY_SIGNON_LOGON 0x0002
48 #define FAMILY_SIGNON_LOGON_REPLY 0x0003
49 #define FAMILY_SIGNON_UIN_REQ 0x0004
50 #define FAMILY_SIGNON_UIN_REPL 0x0005
51 #define FAMILY_SIGNON_SIGNON 0x0006
52 #define FAMILY_SIGNON_SIGNON_REPLY 0x0007
53 #define FAMILY_SIGNON_S_SECUREID_REQ 0x000a
54 #define FAMILY_SIGNON_C_SECUREID_REP 0x000b
56 static const value_string aim_fnac_family_signon[] = {
57 { FAMILY_SIGNON_LOGON, "Logon" },
58 { FAMILY_SIGNON_LOGON_REPLY, "Logon Reply" },
59 { FAMILY_SIGNON_UIN_REQ, "Request UIN" },
60 { FAMILY_SIGNON_UIN_REPL, "New UIN response" },
61 { FAMILY_SIGNON_SIGNON, "Sign-on" },
62 { FAMILY_SIGNON_SIGNON_REPLY, "Sign-on Reply" },
63 { FAMILY_SIGNON_S_SECUREID_REQ, "Server SecureID Request" },
64 { FAMILY_SIGNON_C_SECUREID_REP, "Client SecureID Reply" },
68 static int dissect_aim_snac_signon(tvbuff_t *tvb, packet_info *pinfo,
70 static int dissect_aim_snac_signon_logon(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree);
71 static int dissect_aim_snac_signon_logon_reply(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree);
72 static int dissect_aim_snac_signon_signon(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree);
73 static int dissect_aim_snac_signon_signon_reply(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree);
75 /* Initialize the protocol and registered fields */
76 static int proto_aim_signon = -1;
77 static int hf_aim_infotype = -1;
78 static int hf_aim_signon_challenge_len = -1;
79 static int hf_aim_signon_challenge = -1;
82 /* Initialize the subtree pointers */
83 static gint ett_aim_signon = -1;
85 static int dissect_aim_snac_signon(tvbuff_t *tvb, packet_info *pinfo,
88 struct aiminfo *aiminfo = pinfo->private_data;
91 proto_item *ti = NULL;
92 proto_tree *signon_tree = NULL;
94 ti = proto_tree_add_text(tree, tvb, 0, -1,"AIM Signon");
95 signon_tree = proto_item_add_subtree(ti, ett_aim_signon);
98 switch(aiminfo->subtype)
100 case FAMILY_SIGNON_ERROR:
101 return dissect_aim_snac_error(tvb, pinfo, offset, signon_tree);
102 case FAMILY_SIGNON_LOGON:
103 return dissect_aim_snac_signon_logon(tvb, pinfo, offset, signon_tree);
104 case FAMILY_SIGNON_LOGON_REPLY:
105 return dissect_aim_snac_signon_logon_reply(tvb, pinfo, offset, signon_tree);
106 case FAMILY_SIGNON_SIGNON:
107 return dissect_aim_snac_signon_signon(tvb, pinfo, offset, signon_tree);
108 case FAMILY_SIGNON_SIGNON_REPLY:
109 return dissect_aim_snac_signon_signon_reply(tvb, pinfo, offset, signon_tree);
110 case FAMILY_SIGNON_S_SECUREID_REQ:
113 case FAMILY_SIGNON_UIN_REQ:
114 case FAMILY_SIGNON_UIN_REPL:
115 case FAMILY_SIGNON_C_SECUREID_REP:
122 static int dissect_aim_snac_signon_logon(tvbuff_t *tvb, packet_info *pinfo,
123 int offset, proto_tree *tree)
125 while (tvb_length_remaining(tvb, offset) > 0) {
126 offset = dissect_aim_tlv(tvb, pinfo, offset, tree, client_tlvs);
131 static int dissect_aim_snac_signon_logon_reply(tvbuff_t *tvb,
133 int offset, proto_tree *tree)
135 if (check_col(pinfo->cinfo, COL_INFO))
136 col_append_fstr(pinfo->cinfo, COL_INFO, ", Login information reply");
138 while (tvb_length_remaining(tvb, offset) > 0) {
139 offset = dissect_aim_tlv(tvb, pinfo, offset, tree, client_tlvs);
144 static int dissect_aim_snac_signon_signon(tvbuff_t *tvb, packet_info *pinfo,
145 int offset, proto_tree *tree)
147 guint8 buddyname_length = 0;
148 char buddyname[MAX_BUDDYNAME_LENGTH + 1];
151 proto_tree_add_item(tree, hf_aim_infotype, tvb, offset, 2, FALSE);
158 buddyname_length = aim_get_buddyname( buddyname, tvb, offset, offset + 1 );
160 if (check_col(pinfo->cinfo, COL_INFO)) {
161 col_append_fstr(pinfo->cinfo, COL_INFO, " Username: %s", buddyname);
165 proto_tree_add_text(tree, tvb, offset + 1, buddyname_length,
166 "Screen Name: %s", buddyname);
169 offset += buddyname_length + 1;
173 static int dissect_aim_snac_signon_signon_reply(tvbuff_t *tvb,
175 int offset, proto_tree *tree)
177 guint16 challenge_length = 0;
179 if (check_col(pinfo->cinfo, COL_INFO))
180 col_append_fstr(pinfo->cinfo, COL_INFO, ", Sign-on reply");
182 /* Logon Challenge Length */
183 challenge_length = tvb_get_ntohs(tvb, offset);
184 proto_tree_add_item(tree, hf_aim_signon_challenge_len, tvb, offset, 2, FALSE);
188 proto_tree_add_item(tree, hf_aim_signon_challenge, tvb, offset, challenge_length, FALSE);
189 offset += challenge_length;
193 /* Register the protocol with Ethereal */
195 proto_register_aim_signon(void)
198 /* Setup list of header fields */
199 static hf_register_info hf[] = {
201 { "Infotype", "aim.infotype", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }
203 { &hf_aim_signon_challenge_len,
204 { "Signon challenge length", "aim.signon.challengelen", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }
206 { &hf_aim_signon_challenge,
207 { "Signon challenge", "aim.signon.challenge", FT_STRING, BASE_HEX, NULL, 0x0, "", HFILL }
211 /* Setup protocol subtree array */
212 static gint *ett[] = {
216 /* Register the protocol name and description */
217 proto_aim_signon = proto_register_protocol("AIM Signon", "AIM Signon", "aim_signon");
219 /* Required function calls to register the header fields and subtrees used */
220 proto_register_field_array(proto_aim_signon, hf, array_length(hf));
221 proto_register_subtree_array(ett, array_length(ett));
225 proto_reg_handoff_aim_signon(void)
227 dissector_handle_t aim_handle;
229 aim_handle = new_create_dissector_handle(dissect_aim_snac_signon, proto_aim_signon);
230 dissector_add("aim.family", FAMILY_SIGNON, aim_handle);
231 aim_init_family(FAMILY_SIGNON, "Signon", aim_fnac_family_signon);