1 /* packet-aim-location.c
2 * Routines for AIM Instant Messenger (OSCAR) dissection, SNAC Location
3 * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
4 * Copyright 2000, Ralf Hoelzer <ralf@well.com>
6 * $Id: packet-aim-location.c,v 1.1 2004/03/23 06:21:16 guy 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"
44 #define FAMILY_LOCATION 0x0002
46 /* Family Location Services */
47 #define FAMILY_LOCATION_ERROR 0x0001
48 #define FAMILY_LOCATION_REQRIGHTS 0x0002
49 #define FAMILY_LOCATION_RIGHTSINFO 0x0003
50 #define FAMILY_LOCATION_SETUSERINFO 0x0004
51 #define FAMILY_LOCATION_REQUSERINFO 0x0005
52 #define FAMILY_LOCATION_USERINFO 0x0006
53 #define FAMILY_LOCATION_WATCHERSUBREQ 0x0007
54 #define FAMILY_LOCATION_WATCHERNOT 0x0008
55 #define FAMILY_LOCATION_DEFAULT 0xffff
57 static const value_string aim_fnac_family_location[] = {
58 { FAMILY_LOCATION_ERROR, "Error" },
59 { FAMILY_LOCATION_REQRIGHTS, "Request Rights" },
60 { FAMILY_LOCATION_RIGHTSINFO, "Rights Info" },
61 { FAMILY_LOCATION_SETUSERINFO, "Set User Info" },
62 { FAMILY_LOCATION_REQUSERINFO, "Request User Info" },
63 { FAMILY_LOCATION_USERINFO, "User Info" },
64 { FAMILY_LOCATION_WATCHERSUBREQ, "Watcher Subrequest" },
65 { FAMILY_LOCATION_WATCHERNOT, "Watcher Notification" },
66 { FAMILY_LOCATION_DEFAULT, "Location Default" },
70 #define FAMILY_LOCATION_USERINFO_INFOENCODING 0x0001
71 #define FAMILY_LOCATION_USERINFO_INFOMSG 0x0002
72 #define FAMILY_LOCATION_USERINFO_AWAYENCODING 0x0003
73 #define FAMILY_LOCATION_USERINFO_AWAYMSG 0x0004
74 #define FAMILY_LOCATION_USERINFO_CAPS 0x0005
76 static const aim_tlv aim_fnac_family_location_userinfo_tlv[] = {
77 { FAMILY_LOCATION_USERINFO_INFOENCODING, "Info Msg Encoding", FT_STRING },
78 { FAMILY_LOCATION_USERINFO_INFOMSG, "Info Message", FT_STRING },
79 { FAMILY_LOCATION_USERINFO_AWAYENCODING, "Away Msg Encoding", FT_STRING },
80 { FAMILY_LOCATION_USERINFO_AWAYMSG, "Away Message", FT_STRING },
81 { FAMILY_LOCATION_USERINFO_CAPS, "Capabilities", FT_BYTES },
86 static int dissect_aim_snac_location_request_user_information(tvbuff_t *tvb, int offset, proto_tree *tree);
87 static int dissect_aim_snac_location_user_information(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree);
89 /* Initialize the protocol and registered fields */
90 static int proto_aim_location = -1;
91 static int hf_aim_snac_location_request_user_info_infotype = -1;
92 static int hf_aim_userinfo_warninglevel = -1;
93 static int hf_aim_userinfo_tlvcount = -1;
94 static int hf_aim_buddyname_len = -1;
95 static int hf_aim_buddyname = -1;
97 /* Initialize the subtree pointers */
98 static gint ett_aim_location = -1;
100 static int dissect_aim_location(tvbuff_t *tvb, packet_info *pinfo,
103 struct aiminfo *aiminfo = pinfo->private_data;
105 proto_item *ti = NULL;
106 proto_tree *loc_tree = NULL;
109 ti = proto_tree_add_text(tree, tvb, 0, -1,"AIM Location Service");
110 loc_tree = proto_item_add_subtree(ti, ett_aim_location);
113 switch(aiminfo->subtype)
115 case FAMILY_LOCATION_ERROR:
116 return dissect_aim_snac_error(tvb, pinfo, offset, loc_tree);
117 case FAMILY_LOCATION_REQUSERINFO:
118 return dissect_aim_snac_location_request_user_information(tvb, offset, loc_tree);
119 case FAMILY_LOCATION_USERINFO:
120 return dissect_aim_snac_location_user_information(tvb, pinfo, offset, loc_tree);
121 case FAMILY_LOCATION_REQRIGHTS:
122 case FAMILY_LOCATION_RIGHTSINFO:
123 case FAMILY_LOCATION_SETUSERINFO:
124 case FAMILY_LOCATION_WATCHERSUBREQ:
125 case FAMILY_LOCATION_WATCHERNOT:
132 static int dissect_aim_snac_location_request_user_information(tvbuff_t *tvb,
136 guint8 buddyname_length = 0;
139 proto_tree_add_item(tree, hf_aim_snac_location_request_user_info_infotype,
140 tvb, offset, 2, FALSE);
143 /* Buddy Name length */
144 buddyname_length = tvb_get_guint8(tvb, offset);
145 proto_tree_add_item(tree, hf_aim_buddyname_len, tvb, offset, 1, FALSE);
149 proto_tree_add_item(tree, hf_aim_buddyname, tvb, offset, buddyname_length, FALSE);
150 offset += buddyname_length;
154 static int dissect_aim_snac_location_user_information(tvbuff_t *tvb,
155 packet_info *pinfo _U_,
156 int offset, proto_tree *tree)
158 guint8 buddyname_length = 0;
159 guint16 tlv_count = 0;
162 /* Buddy Name length */
163 buddyname_length = tvb_get_guint8(tvb, offset);
164 proto_tree_add_item(tree, hf_aim_buddyname_len, tvb, offset, 1, FALSE);
168 proto_tree_add_item(tree, hf_aim_buddyname, tvb, offset, buddyname_length, FALSE);
169 offset += buddyname_length;
172 proto_tree_add_item(tree, hf_aim_userinfo_warninglevel, tvb, offset, 2, FALSE);
176 tlv_count = tvb_get_ntohs(tvb, offset);
177 proto_tree_add_item(tree, hf_aim_userinfo_tlvcount, tvb, offset, 2, FALSE);
180 /* Dissect the TLV array containing general user status */
181 while (i++ < tlv_count) {
182 offset = dissect_aim_tlv_buddylist(tvb, pinfo, offset, tree);
185 /* Dissect the TLV array containing the away message (or whatever info was
186 specifically requested) */
187 while (tvb_length_remaining(tvb, offset) > 0) {
188 offset = dissect_aim_tlv_specific(tvb, pinfo, offset, tree,
189 aim_fnac_family_location_userinfo_tlv);
195 proto_register_aim_location(void)
198 /* Setup list of header fields */
199 static hf_register_info hf[] = {
200 { &hf_aim_buddyname_len,
201 { "Buddyname len", "aim.buddynamelen", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
204 { "Buddy Name", "aim.buddyname", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }
206 { &hf_aim_userinfo_warninglevel,
207 { "Warning Level", "aim.userinfo.warninglevel", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
209 { &hf_aim_userinfo_tlvcount,
210 { "TLV Count", "aim.userinfo.tlvcount", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL },
214 /* Setup protocol subtree array */
215 static gint *ett[] = {
219 /* Register the protocol name and description */
220 proto_aim_location = proto_register_protocol("AIM Location", "AIM Location", "aim_location");
222 /* Required function calls to register the header fields and subtrees used */
223 proto_register_field_array(proto_aim_location, hf, array_length(hf));
224 proto_register_subtree_array(ett, array_length(ett));
228 proto_reg_handoff_aim_location(void)
230 dissector_handle_t aim_handle;
231 aim_handle = new_create_dissector_handle(dissect_aim_location, proto_aim_location);
232 dissector_add("aim.family", FAMILY_LOCATION, aim_handle);
233 aim_init_family(FAMILY_LOCATION, "Location", aim_fnac_family_location);