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 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <epan/packet.h>
31 #include "packet-aim.h"
33 void proto_register_aim_location(void);
34 void proto_reg_handoff_aim_location(void);
37 #define FAMILY_LOCATION 0x0002
39 #define AIM_LOCATION_RIGHTS_TLV_MAX_PROFILE_LENGTH 0x0001
40 #define AIM_LOCATION_RIGHTS_TLV_MAX_CAPABILITIES 0x0002
42 static const aim_tlv aim_location_rights_tlvs[] = {
43 { AIM_LOCATION_RIGHTS_TLV_MAX_PROFILE_LENGTH, "Max Profile Length", dissect_aim_tlv_value_uint16 },
44 { AIM_LOCATION_RIGHTS_TLV_MAX_CAPABILITIES, "Max capabilities", dissect_aim_tlv_value_uint16 },
48 #define AIM_LOCATE_TAG_TLV_SIG_TYPE 0x0001
49 #define AIM_LOCATE_TAG_TLV_SIG_DATA 0x0002
50 #define AIM_LOCATE_TAG_TLV_UNAVAILABLE_TYPE 0x0003
51 #define AIM_LOCATE_TAG_TLV_UNAVAILABLE_DATA 0x0004
52 #define AIM_LOCATE_TAG_TLV_CAPABILITIES 0x0005
53 #define AIM_LOCATE_TAG_TLV_SIG_TIME 0x000A
54 #define AIM_LOCATE_TAG_TLV_UNAVAILABLE_TIME 0x000B
55 #define AIM_LOCATE_TAG_TLV_SUPPORT_HOST_SIG 0x000C
56 #define AIM_LOCATE_TAG_TLV_HTML_INFO_TYPE 0x000D
57 #define AIM_LOCATE_TAG_TLV_HTML_INFO_DATA 0x000E
59 static const aim_tlv aim_locate_tags_tlvs[] = {
60 { AIM_LOCATE_TAG_TLV_SIG_TYPE, "Signature MIME Type" , dissect_aim_tlv_value_string },
61 { AIM_LOCATE_TAG_TLV_SIG_DATA, "Signature Data" , dissect_aim_tlv_value_string },
62 { AIM_LOCATE_TAG_TLV_UNAVAILABLE_TYPE, "Away Message MIME Type" , dissect_aim_tlv_value_string },
63 { AIM_LOCATE_TAG_TLV_UNAVAILABLE_DATA, "Away Message Data" , dissect_aim_tlv_value_string },
64 { AIM_LOCATE_TAG_TLV_CAPABILITIES, "Client Capabilities" , dissect_aim_tlv_value_client_capabilities },
65 { AIM_LOCATE_TAG_TLV_SIG_TIME, "Signature Time" , dissect_aim_tlv_value_time },
66 { AIM_LOCATE_TAG_TLV_UNAVAILABLE_TIME, "Away Message Time" , dissect_aim_tlv_value_time },
67 { AIM_LOCATE_TAG_TLV_SUPPORT_HOST_SIG, "Enable Server Based Profiles" , dissect_aim_tlv_value_uint8 },
68 { AIM_LOCATE_TAG_TLV_HTML_INFO_TYPE, "Host Based Buddy MIME Type" , dissect_aim_tlv_value_string },
69 { AIM_LOCATE_TAG_TLV_HTML_INFO_DATA, "Host Bases Buddy Data" , dissect_aim_tlv_value_string },
73 #define FAMILY_LOCATION_USERINFO_INFOTYPE_GENERALINFO 0x0001
74 #define FAMILY_LOCATION_USERINFO_INFOTYPE_AWAYMSG 0x0003
75 #define FAMILY_LOCATION_USERINFO_INFOTYPE_CAPS 0x0005
77 static const value_string aim_snac_location_request_user_info_infotypes[] = {
78 { FAMILY_LOCATION_USERINFO_INFOTYPE_GENERALINFO, "Request General Info" },
79 { FAMILY_LOCATION_USERINFO_INFOTYPE_AWAYMSG, "Request Away Message" },
80 { FAMILY_LOCATION_USERINFO_INFOTYPE_CAPS, "Request Capabilities" },
84 /* Initialize the protocol and registered fields */
85 static int proto_aim_location = -1;
86 static int hf_aim_snac_location_request_user_info_infotype = -1;
87 static int hf_aim_userinfo_warninglevel = -1;
88 static int hf_aim_buddyname_len = -1;
89 static int hf_aim_buddyname = -1;
91 /* Initialize the subtree pointers */
92 static gint ett_aim_location = -1;
94 static int dissect_aim_location_rightsinfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *loc_tree)
96 return dissect_aim_tlv_sequence(tvb, pinfo, 0, loc_tree, aim_location_rights_tlvs);
99 static int dissect_aim_location_setuserinfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *loc_tree)
101 return dissect_aim_tlv_sequence(tvb, pinfo, 0, loc_tree, aim_locate_tags_tlvs);
104 static int dissect_aim_location_watcher_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree *loc_tree)
107 while (tvb_length_remaining(tvb, offset) > 0) {
108 offset = dissect_aim_buddyname(tvb, pinfo, offset, loc_tree);
113 static int dissect_aim_location_user_info_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *loc_tree)
115 return dissect_aim_buddyname(tvb, pinfo, 4, loc_tree);
118 static int dissect_aim_snac_location_request_user_information(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
121 guint8 buddyname_length = 0;
124 proto_tree_add_item(tree, hf_aim_snac_location_request_user_info_infotype,
125 tvb, offset, 2, ENC_BIG_ENDIAN);
128 /* Buddy Name length */
129 buddyname_length = tvb_get_guint8(tvb, offset);
130 proto_tree_add_item(tree, hf_aim_buddyname_len, tvb, offset, 1, ENC_BIG_ENDIAN);
134 proto_tree_add_item(tree, hf_aim_buddyname, tvb, offset, buddyname_length, ENC_UTF_8|ENC_NA);
135 offset += buddyname_length;
140 static int dissect_aim_snac_location_user_information(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
143 guint8 buddyname_length = 0;
145 /* Buddy Name length */
146 buddyname_length = tvb_get_guint8(tvb, offset);
147 proto_tree_add_item(tree, hf_aim_buddyname_len, tvb, offset, 1, ENC_BIG_ENDIAN);
151 proto_tree_add_item(tree, hf_aim_buddyname, tvb, offset, buddyname_length, ENC_UTF_8|ENC_NA);
152 offset += buddyname_length;
155 proto_tree_add_item(tree, hf_aim_userinfo_warninglevel, tvb, offset, 2, ENC_BIG_ENDIAN);
158 offset = dissect_aim_tlv_list(tvb, pinfo, offset, tree, aim_onlinebuddy_tlvs);
160 return dissect_aim_tlv_sequence(tvb, pinfo, offset, tree, aim_locate_tags_tlvs);
163 static const aim_subtype aim_fnac_family_location[] = {
164 { 0x0001, "Error" , dissect_aim_snac_error },
165 { 0x0002, "Request Rights" , NULL },
166 { 0x0003, "Rights Info" , dissect_aim_location_rightsinfo },
167 { 0x0004, "Set User Info" , dissect_aim_location_setuserinfo },
168 { 0x0005, "Request User Info" , dissect_aim_snac_location_request_user_information },
169 { 0x0006, "User Info" , dissect_aim_snac_location_user_information },
170 { 0x0007, "Watcher Subrequest" , NULL },
171 { 0x0008, "Watcher Notification" , dissect_aim_location_watcher_notification },
172 { 0x0015, "User Info Query" , dissect_aim_location_user_info_query },
179 proto_register_aim_location(void)
182 /* Setup list of header fields */
183 static hf_register_info hf[] = {
184 { &hf_aim_buddyname_len,
185 { "Buddyname len", "aim_location.buddynamelen", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
188 { "Buddy Name", "aim_location.buddyname", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
190 { &hf_aim_userinfo_warninglevel,
191 { "Warning Level", "aim_location.userinfo.warninglevel", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL },
193 { &hf_aim_snac_location_request_user_info_infotype,
194 { "Infotype", "aim_location.snac.request_user_info.infotype", FT_UINT16, BASE_HEX, VALS(aim_snac_location_request_user_info_infotypes), 0x0,
199 /* Setup protocol subtree array */
200 static gint *ett[] = {
204 /* Register the protocol name and description */
205 proto_aim_location = proto_register_protocol("AIM Location", "AIM Location", "aim_location");
207 /* Required function calls to register the header fields and subtrees used */
208 proto_register_field_array(proto_aim_location, hf, array_length(hf));
209 proto_register_subtree_array(ett, array_length(ett));
213 proto_reg_handoff_aim_location(void)
215 aim_init_family(proto_aim_location, ett_aim_location, FAMILY_LOCATION, aim_fnac_family_location);