HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-aim-signon.c
blob12b989148d660e42ba3f833afab5cf5335df3078
1 /* packet-aim-signon.c
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$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "config.h"
29 #include <glib.h>
31 #include <epan/packet.h>
32 #include <epan/strutil.h>
34 #include "packet-aim.h"
36 void proto_register_aim_signon(void);
37 void proto_reg_handoff_aim_signon(void);
39 #define FAMILY_SIGNON 0x0017
42 /* Initialize the protocol and registered fields */
43 static int proto_aim_signon = -1;
44 static int hf_aim_infotype = -1;
45 static int hf_aim_signon_challenge_len = -1;
46 static int hf_aim_signon_challenge = -1;
49 /* Initialize the subtree pointers */
50 static gint ett_aim_signon = -1;
52 static int dissect_aim_snac_signon_logon(tvbuff_t *tvb, packet_info *pinfo,
53 proto_tree *tree)
55 int offset = 0;
56 while (tvb_length_remaining(tvb, offset) > 0) {
57 offset = dissect_aim_tlv(tvb, pinfo, offset, tree, aim_client_tlvs);
59 return offset;
62 static int dissect_aim_snac_signon_logon_reply(tvbuff_t *tvb,
63 packet_info *pinfo,
64 proto_tree *tree)
66 int offset = 0;
67 while (tvb_length_remaining(tvb, offset) > 0) {
68 offset = dissect_aim_tlv(tvb, pinfo, offset, tree, aim_client_tlvs);
70 return offset;
73 static int dissect_aim_snac_signon_signon(tvbuff_t *tvb, packet_info *pinfo,
74 proto_tree *tree)
76 guint8 buddyname_length = 0;
77 int offset = 0;
78 guchar buddyname[MAX_BUDDYNAME_LENGTH + 1];
80 /* Info Type */
81 proto_tree_add_item(tree, hf_aim_infotype, tvb, offset, 2, ENC_BIG_ENDIAN);
82 offset += 2;
84 /* Unknown */
85 offset += 1;
87 /* Buddy Name */
88 buddyname_length = aim_get_buddyname( buddyname, tvb, offset, offset + 1 );
90 col_append_fstr(pinfo->cinfo, COL_INFO, " Username: %s",
91 format_text(buddyname, buddyname_length));
93 if(tree) {
94 offset+=dissect_aim_buddyname(tvb, pinfo, offset, tree);
97 return offset;
100 static int dissect_aim_snac_signon_signon_reply(tvbuff_t *tvb,
101 packet_info *pinfo _U_,
102 proto_tree *tree)
104 int offset = 0;
105 guint16 challenge_length = 0;
107 /* Logon Challenge Length */
108 challenge_length = tvb_get_ntohs(tvb, offset);
109 proto_tree_add_item(tree, hf_aim_signon_challenge_len, tvb, offset, 2, ENC_BIG_ENDIAN);
110 offset += 2;
112 /* Challenge */
113 proto_tree_add_item(tree, hf_aim_signon_challenge, tvb, offset, challenge_length, ENC_ASCII|ENC_NA);
114 offset += challenge_length;
115 return offset;
118 static int dissect_aim_tlv_value_registration(proto_item *ti _U_, guint16 value_id _U_, tvbuff_t *tvb _U_, packet_info *pinfo _U_)
120 /* FIXME */
121 return 0;
124 #define REG_TLV_REGISTRATION_INFO 0x0001
126 static const aim_tlv aim_registration_tlvs[] = {
127 { REG_TLV_REGISTRATION_INFO, "Registration Info", dissect_aim_tlv_value_registration },
128 { 0, NULL, NULL },
131 static int dissect_aim_snac_register (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
133 return dissect_aim_tlv(tvb, pinfo, 0, tree, aim_registration_tlvs);
136 static const aim_subtype aim_fnac_family_signon[] = {
137 { 0x0001, "Error", dissect_aim_snac_error },
138 { 0x0002, "Logon", dissect_aim_snac_signon_logon },
139 { 0x0003, "Logon Reply", dissect_aim_snac_signon_logon_reply },
140 { 0x0004, "Request UIN", dissect_aim_snac_register },
141 { 0x0005, "New UIN response", dissect_aim_snac_register },
142 { 0x0006, "Sign-on", dissect_aim_snac_signon_signon },
143 { 0x0007, "Sign-on Reply", dissect_aim_snac_signon_signon_reply },
144 { 0x000a, "Server SecureID Request", NULL },
145 { 0x000b, "Client SecureID Reply", NULL },
146 { 0, NULL, NULL }
150 /* Register the protocol with Wireshark */
151 void
152 proto_register_aim_signon(void)
155 /* Setup list of header fields */
156 static hf_register_info hf[] = {
157 { &hf_aim_infotype,
158 { "Infotype", "aim_signon.infotype", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
160 { &hf_aim_signon_challenge_len,
161 { "Signon challenge length", "aim_signon.challengelen", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
163 { &hf_aim_signon_challenge,
164 { "Signon challenge", "aim_signon.challenge", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
168 /* Setup protocol subtree array */
169 static gint *ett[] = {
170 &ett_aim_signon,
173 /* Register the protocol name and description */
174 proto_aim_signon = proto_register_protocol("AIM Signon", "AIM Signon", "aim_signon");
176 /* Required function calls to register the header fields and subtrees used */
177 proto_register_field_array(proto_aim_signon, hf, array_length(hf));
178 proto_register_subtree_array(ett, array_length(ett));
181 void
182 proto_reg_handoff_aim_signon(void)
184 aim_init_family(proto_aim_signon, ett_aim_signon, FAMILY_SIGNON, aim_fnac_family_signon);