Revert "[MSVC2015] TRy to fix Warnings turned errors."
[metze/wireshark/wip.git] / epan / dissectors / packet-btobex.c
1 /* packet-btobex.c
2  * Routines for Bluetooth OBEX dissection
3  *
4  * Copyright 2010, Allan M. Madsen
5  * Copyright 2013, Michal Labedzki for Tieto Corporation
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
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.
15  *
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.
20  *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include "config.h"
27
28 #include <epan/packet.h>
29 #include <epan/prefs.h>
30 #include <epan/reassemble.h>
31 #include <epan/expert.h>
32 #include <epan/decode_as.h>
33 #include "packet-bluetooth.h"
34 #include "packet-btrfcomm.h"
35 #include "packet-btl2cap.h"
36 #include "packet-btsdp.h"
37
38 /* Initialize the protocol and registered fields */
39 static int proto_btobex = -1;
40 static int hf_opcode = -1;
41 static int hf_response_code = -1;
42 static int hf_final_flag = -1;
43 static int hf_length = -1;
44 static int hf_version = -1;
45 static int hf_flags = -1;
46 static int hf_constants = -1;
47 static int hf_max_pkt_len = -1;
48 static int hf_set_path_flags_0 = -1;
49 static int hf_set_path_flags_1 = -1;
50 static int hf_headers = -1;
51 static int hf_header = -1;
52 static int hf_hdr_id = -1;
53 static int hf_hdr_id_encoding = -1;
54 static int hf_hdr_id_meaning = -1;
55 static int hf_hdr_length = -1;
56 static int hf_hdr_val_unicode = -1;
57 static int hf_hdr_val_byte_seq = -1;
58 static int hf_hdr_val_byte = -1;
59 static int hf_hdr_val_long = -1;
60 static int hf_authentication_parameter = -1;
61 static int hf_authentication_parameter_data = -1;
62 static int hf_authentication_challenge_tag = -1;
63 static int hf_authentication_response_tag = -1;
64 static int hf_authentication_key = -1;
65 static int hf_authentication_result_key = -1;
66 static int hf_authentication_user_id = -1;
67 static int hf_authentication_length = -1;
68 static int hf_authentication_info_charset = -1;
69 static int hf_authentication_info = -1;
70 static int hf_authentication_option_reserved = -1;
71 static int hf_authentication_option_user_id = -1;
72 static int hf_authentication_option_read_only = -1;
73 static int hf_application_parameter = -1;
74 static int hf_application_parameter_id = -1;
75 static int hf_application_parameter_length = -1;
76 static int hf_application_parameter_data = -1;
77 static int hf_bpp_application_parameter_id = -1;
78 static int hf_bpp_application_parameter_data_offset = -1;
79 static int hf_bpp_application_parameter_data_count = -1;
80 static int hf_bpp_application_parameter_data_job_id = -1;
81 static int hf_bpp_application_parameter_data_file_size = -1;
82 static int hf_bip_application_parameter_id = -1;
83 static int hf_bip_application_parameter_data_number_of_returned_handles = -1;
84 static int hf_bip_application_parameter_data_list_start_offset = -1;
85 static int hf_bip_application_parameter_data_latest_captured_images = -1;
86 static int hf_bip_application_parameter_data_partial_file_length = -1;
87 static int hf_bip_application_parameter_data_partial_file_start_offset = -1;
88 static int hf_bip_application_parameter_data_total_file_size = -1;
89 static int hf_bip_application_parameter_data_end_flag = -1;
90 static int hf_bip_application_parameter_data_remote_display = -1;
91 static int hf_bip_application_parameter_data_service_id = -1;
92 static int hf_bip_application_parameter_data_store_flag = -1;
93 static int hf_pbap_application_parameter_id = -1;
94 static int hf_pbap_application_parameter_data_order = -1;
95 static int hf_pbap_application_parameter_data_search_value = -1;
96 static int hf_pbap_application_parameter_data_search_attribute = -1;
97 static int hf_pbap_application_parameter_data_max_list_count = -1;
98 static int hf_pbap_application_parameter_data_list_start_offset = -1;
99 static int hf_pbap_application_parameter_data_filter = -1;
100 static int hf_pbap_application_parameter_vcard_selector = -1;
101 static int hf_pbap_application_parameter_data_filter_version = -1;
102 static int hf_pbap_application_parameter_data_filter_fn = -1;
103 static int hf_pbap_application_parameter_data_filter_n = -1;
104 static int hf_pbap_application_parameter_data_filter_photo = -1;
105 static int hf_pbap_application_parameter_data_filter_birthday = -1;
106 static int hf_pbap_application_parameter_data_filter_adr = -1;
107 static int hf_pbap_application_parameter_data_filter_label = -1;
108 static int hf_pbap_application_parameter_data_filter_tel = -1;
109 static int hf_pbap_application_parameter_data_filter_email = -1;
110 static int hf_pbap_application_parameter_data_filter_mailer = -1;
111 static int hf_pbap_application_parameter_data_filter_time_zone = -1;
112 static int hf_pbap_application_parameter_data_filter_geographic_position = -1;
113 static int hf_pbap_application_parameter_data_filter_title = -1;
114 static int hf_pbap_application_parameter_data_filter_role = -1;
115 static int hf_pbap_application_parameter_data_filter_logo = -1;
116 static int hf_pbap_application_parameter_data_filter_agent = -1;
117 static int hf_pbap_application_parameter_data_filter_name_of_organization = -1;
118 static int hf_pbap_application_parameter_data_filter_comments = -1;
119 static int hf_pbap_application_parameter_data_filter_revision = -1;
120 static int hf_pbap_application_parameter_data_filter_pronunciation_of_name = -1;
121 static int hf_pbap_application_parameter_data_filter_url = -1;
122 static int hf_pbap_application_parameter_data_filter_uid = -1;
123 static int hf_pbap_application_parameter_data_filter_key = -1;
124 static int hf_pbap_application_parameter_data_filter_nickname = -1;
125 static int hf_pbap_application_parameter_data_filter_categories = -1;
126 static int hf_pbap_application_parameter_data_filter_product_id = -1;
127 static int hf_pbap_application_parameter_data_filter_class = -1;
128 static int hf_pbap_application_parameter_data_filter_sort_string = -1;
129 static int hf_pbap_application_parameter_data_filter_timestamp = -1;
130 static int hf_pbap_application_parameter_data_filter_reserved_29_31 = -1;
131 static int hf_pbap_application_parameter_data_filter_reserved_32_38 = -1;
132 static int hf_pbap_application_parameter_data_filter_proprietary_filter = -1;
133 static int hf_pbap_application_parameter_data_filter_reserved_for_proprietary_filter_usage = -1;
134 static int hf_pbap_application_parameter_data_format = -1;
135 static int hf_pbap_application_parameter_data_phonebook_size = -1;
136 static int hf_pbap_application_parameter_data_new_missed_calls = -1;
137 static int hf_pbap_application_parameter_data_primary_version_counter = -1;
138 static int hf_pbap_application_parameter_data_secondary_version_counter = -1;
139 static int hf_pbap_application_parameter_data_database_identifier = -1;
140 static int hf_pbap_application_parameter_data_vcard_selector_operator = -1;
141 static int hf_pbap_application_parameter_data_reset_new_missed_calls = -1;
142 static int hf_pbap_application_parameter_data_supported_features = -1;
143 static int hf_pbap_application_parameter_data_supported_features_reserved = -1;
144 static int hf_pbap_application_parameter_data_supported_features_download = -1;
145 static int hf_pbap_application_parameter_data_supported_features_browsing = -1;
146 static int hf_pbap_application_parameter_data_supported_features_database_identifier = -1;
147 static int hf_pbap_application_parameter_data_supported_features_folder_version_counters = -1;
148 static int hf_pbap_application_parameter_data_supported_features_vcard_selecting = -1;
149 static int hf_pbap_application_parameter_data_supported_features_enhanced_missed_calls = -1;
150 static int hf_pbap_application_parameter_data_supported_features_x_bt_uci_vcard_property = -1;
151 static int hf_pbap_application_parameter_data_supported_features_x_bt_uid_vcard_property = -1;
152 static int hf_pbap_application_parameter_data_supported_features_contact_referencing = -1;
153 static int hf_pbap_application_parameter_data_supported_features_default_contact_image_format = -1;
154 static int hf_map_application_parameter_id = -1;
155 static int hf_map_application_parameter_data_max_list_count = -1;
156 static int hf_map_application_parameter_data_start_offset = -1;
157 static int hf_map_application_parameter_data_filter_message_type_reserved = -1;
158 static int hf_map_application_parameter_data_filter_message_type_mms = -1;
159 static int hf_map_application_parameter_data_filter_message_type_email = -1;
160 static int hf_map_application_parameter_data_filter_message_type_sms_cdma = -1;
161 static int hf_map_application_parameter_data_filter_message_type_sms_gsm = -1;
162 static int hf_map_application_parameter_data_filter_period_begin = -1;
163 static int hf_map_application_parameter_data_filter_period_end = -1;
164 static int hf_map_application_parameter_data_filter_read_status_reserved_6 = -1;
165 static int hf_map_application_parameter_data_filter_read_status_get_read = -1;
166 static int hf_map_application_parameter_data_filter_read_status_get_unread = -1;
167 static int hf_map_application_parameter_data_filter_recipient = -1;
168 static int hf_map_application_parameter_data_filter_originator = -1;
169 static int hf_map_application_parameter_data_filter_priority_reserved_6 = -1;
170 static int hf_map_application_parameter_data_filter_priority_get_high = -1;
171 static int hf_map_application_parameter_data_filter_priority_non_high = -1;
172 static int hf_map_application_parameter_data_reserved_7 = -1;
173 static int hf_map_application_parameter_data_attachment = -1;
174 static int hf_map_application_parameter_data_transparent = -1;
175 static int hf_map_application_parameter_data_retry = -1;
176 static int hf_map_application_parameter_data_new_message = -1;
177 static int hf_map_application_parameter_data_notification_status = -1;
178 static int hf_map_application_parameter_data_mas_instance_id = -1;
179 static int hf_map_application_parameter_data_parameter_mask_reserved = -1;
180 static int hf_map_application_parameter_data_parameter_mask_reply_to_addressing = -1;
181 static int hf_map_application_parameter_data_parameter_mask_protected = -1;
182 static int hf_map_application_parameter_data_parameter_mask_sent = -1;
183 static int hf_map_application_parameter_data_parameter_mask_read = -1;
184 static int hf_map_application_parameter_data_parameter_mask_priority = -1;
185 static int hf_map_application_parameter_data_parameter_mask_attachment_size = -1;
186 static int hf_map_application_parameter_data_parameter_mask_text = -1;
187 static int hf_map_application_parameter_data_parameter_mask_reception_status = -1;
188 static int hf_map_application_parameter_data_parameter_mask_size = -1;
189 static int hf_map_application_parameter_data_parameter_mask_type = -1;
190 static int hf_map_application_parameter_data_parameter_mask_recipient_addressing = -1;
191 static int hf_map_application_parameter_data_parameter_mask_recipient_name = -1;
192 static int hf_map_application_parameter_data_parameter_mask_sender_addressing = -1;
193 static int hf_map_application_parameter_data_parameter_mask_sender_name = -1;
194 static int hf_map_application_parameter_data_parameter_mask_datetime = -1;
195 static int hf_map_application_parameter_data_parameter_mask_subject = -1;
196 static int hf_map_application_parameter_data_folder_listing_size = -1;
197 static int hf_map_application_parameter_data_messages_listing_size = -1;
198 static int hf_map_application_parameter_data_subject_length = -1;
199 static int hf_map_application_parameter_data_charset = -1;
200 static int hf_map_application_parameter_data_fraction_request = -1;
201 static int hf_map_application_parameter_data_fraction_deliver = -1;
202 static int hf_map_application_parameter_data_status_indicator = -1;
203 static int hf_map_application_parameter_data_status_value = -1;
204 static int hf_map_application_parameter_data_mse_time = -1;
205 static int hf_gpp_application_parameter_id = -1;
206 static int hf_gpp_application_parameter_data_max_list_count = -1;
207 static int hf_gpp_application_parameter_data_list_start_offset = -1;
208 static int hf_gpp_application_parameter_data_reserved_7 = -1;
209 static int hf_gpp_application_parameter_data_notification_status = -1;
210 static int hf_gpp_application_parameter_data_instance_id = -1;
211 static int hf_gpp_application_parameter_data_listing_size = -1;
212 static int hf_ctn_application_parameter_id = -1;
213 static int hf_ctn_application_parameter_data_acoustic_alarm_status = -1;
214 static int hf_ctn_application_parameter_data_attachment = -1;
215 static int hf_ctn_application_parameter_data_send = -1;
216 static int hf_ctn_application_parameter_data_filter_period_begin = -1;
217 static int hf_ctn_application_parameter_data_filter_period_end = -1;
218 static int hf_ctn_application_parameter_data_parameter_mask = -1;
219 static int hf_ctn_application_parameter_data_parameter_mask_reserved = -1;
220 static int hf_ctn_application_parameter_data_parameter_mask_recurrent = -1;
221 static int hf_ctn_application_parameter_data_parameter_mask_send_status = -1;
222 static int hf_ctn_application_parameter_data_parameter_mask_alarm_status = -1;
223 static int hf_ctn_application_parameter_data_parameter_mask_pstatus = -1;
224 static int hf_ctn_application_parameter_data_parameter_mask_priority = -1;
225 static int hf_ctn_application_parameter_data_parameter_mask_originator_address = -1;
226 static int hf_ctn_application_parameter_data_parameter_mask_originator_name = -1;
227 static int hf_ctn_application_parameter_data_parameter_mask_end_time = -1;
228 static int hf_ctn_application_parameter_data_parameter_mask_summary = -1;
229 static int hf_ctn_application_parameter_data_parameter_mask_attachment = -1;
230 static int hf_ctn_application_parameter_data_status_indicator = -1;
231 static int hf_ctn_application_parameter_data_status_value = -1;
232 static int hf_ctn_application_parameter_data_postpone_val = -1;
233 static int hf_ctn_application_parameter_data_email_uri = -1;
234 static int hf_ctn_application_parameter_data_cse_time = -1;
235 static int hf_ctn_application_parameter_data_recurrent = -1;
236 static int hf_ctn_application_parameter_data_attach_id = -1;
237 static int hf_ctn_application_parameter_data_last_update = -1;
238 static int hf_profile = -1;
239 static int hf_type = -1;
240 static int hf_object_class = -1;
241 static int hf_time_iso8601 = -1;
242 static int hf_wan_uuid = -1;
243 static int hf_hdr_val_action = -1;
244 static int hf_hdr_val_single_response_mode = -1;
245 static int hf_hdr_val_single_response_mode_parameter = -1;
246 static int hf_session_parameter = -1;
247 static int hf_session_parameter_tag = -1;
248 static int hf_session_parameter_length = -1;
249 static int hf_session_parameter_data = -1;
250 static int hf_session_parameter_nonce = -1;
251 static int hf_session_parameter_session_id = -1;
252 static int hf_session_parameter_next_sequence_number = -1;
253 static int hf_session_parameter_timeout = -1;
254 static int hf_session_parameter_opcode = -1;
255 static int hf_sender_bd_addr = -1;
256 static int hf_count = -1;
257 static int hf_data_length = -1;
258 static int hf_connection_id = -1;
259 static int hf_name = -1;
260 static int hf_current_path = -1;
261 static int hf_request_in_frame = -1;
262 static int hf_response_in_frame = -1;
263
264 static const int *hfx_hdr_id[] = {
265     &hf_hdr_id_encoding,
266     &hf_hdr_id_meaning,
267     NULL
268 };
269
270 static const int *hfx_pbap_application_parameter_data_filter_1[] = {
271     &hf_pbap_application_parameter_data_filter_reserved_32_38,
272     &hf_pbap_application_parameter_data_filter_proprietary_filter,
273     &hf_pbap_application_parameter_data_filter_reserved_for_proprietary_filter_usage,
274     NULL
275 };
276
277 static const int *hfx_pbap_application_parameter_data_filter_0[] = {
278     &hf_pbap_application_parameter_data_filter_version,
279     &hf_pbap_application_parameter_data_filter_fn,
280     &hf_pbap_application_parameter_data_filter_n,
281     &hf_pbap_application_parameter_data_filter_photo,
282     &hf_pbap_application_parameter_data_filter_birthday,
283     &hf_pbap_application_parameter_data_filter_adr,
284     &hf_pbap_application_parameter_data_filter_label,
285     &hf_pbap_application_parameter_data_filter_tel,
286     &hf_pbap_application_parameter_data_filter_email,
287     &hf_pbap_application_parameter_data_filter_mailer,
288     &hf_pbap_application_parameter_data_filter_time_zone,
289     &hf_pbap_application_parameter_data_filter_geographic_position,
290     &hf_pbap_application_parameter_data_filter_title,
291     &hf_pbap_application_parameter_data_filter_role,
292     &hf_pbap_application_parameter_data_filter_logo,
293     &hf_pbap_application_parameter_data_filter_agent,
294     &hf_pbap_application_parameter_data_filter_name_of_organization,
295     &hf_pbap_application_parameter_data_filter_comments,
296     &hf_pbap_application_parameter_data_filter_revision,
297     &hf_pbap_application_parameter_data_filter_pronunciation_of_name,
298     &hf_pbap_application_parameter_data_filter_url,
299     &hf_pbap_application_parameter_data_filter_uid,
300     &hf_pbap_application_parameter_data_filter_key,
301     &hf_pbap_application_parameter_data_filter_nickname,
302     &hf_pbap_application_parameter_data_filter_categories,
303     &hf_pbap_application_parameter_data_filter_product_id,
304     &hf_pbap_application_parameter_data_filter_class,
305     &hf_pbap_application_parameter_data_filter_sort_string,
306     &hf_pbap_application_parameter_data_filter_timestamp,
307     &hf_pbap_application_parameter_data_filter_reserved_29_31,
308     NULL
309 };
310
311 static const int *hfx_pbap_application_parameter_data_supported_features[] = {
312     &hf_pbap_application_parameter_data_supported_features_reserved,
313     &hf_pbap_application_parameter_data_supported_features_default_contact_image_format,
314     &hf_pbap_application_parameter_data_supported_features_contact_referencing,
315     &hf_pbap_application_parameter_data_supported_features_x_bt_uid_vcard_property,
316     &hf_pbap_application_parameter_data_supported_features_x_bt_uci_vcard_property,
317     &hf_pbap_application_parameter_data_supported_features_enhanced_missed_calls,
318     &hf_pbap_application_parameter_data_supported_features_vcard_selecting,
319     &hf_pbap_application_parameter_data_supported_features_folder_version_counters,
320     &hf_pbap_application_parameter_data_supported_features_database_identifier,
321     &hf_pbap_application_parameter_data_supported_features_browsing,
322     &hf_pbap_application_parameter_data_supported_features_download,
323     NULL
324 };
325
326 static const int *hfx_ctn_application_parameter_data_parameter_mask[] = {
327     &hf_ctn_application_parameter_data_parameter_mask_reserved,
328     &hf_ctn_application_parameter_data_parameter_mask_recurrent,
329     &hf_ctn_application_parameter_data_parameter_mask_send_status,
330     &hf_ctn_application_parameter_data_parameter_mask_alarm_status,
331     &hf_ctn_application_parameter_data_parameter_mask_pstatus,
332     &hf_ctn_application_parameter_data_parameter_mask_priority,
333     &hf_ctn_application_parameter_data_parameter_mask_originator_address,
334     &hf_ctn_application_parameter_data_parameter_mask_originator_name,
335     &hf_ctn_application_parameter_data_parameter_mask_end_time,
336     &hf_ctn_application_parameter_data_parameter_mask_summary,
337     &hf_ctn_application_parameter_data_parameter_mask_attachment,
338     NULL
339 };
340
341 static expert_field ei_unexpected_data = EI_INIT;
342 static expert_field ei_application_parameter_length_bad = EI_INIT;
343 static expert_field ei_decoded_as_profile = EI_INIT;
344
345 static dissector_table_t btobex_profile;
346 static dissector_table_t media_type_dissector_table;
347
348
349 /* ************************************************************************* */
350 /*                   Header values for reassembly                            */
351 /* ************************************************************************* */
352 static int hf_btobex_fragments = -1;
353 static int hf_btobex_fragment = -1;
354 static int hf_btobex_fragment_overlap = -1;
355 static int hf_btobex_fragment_overlap_conflict = -1;
356 static int hf_btobex_fragment_multiple_tails = -1;
357 static int hf_btobex_fragment_too_long_fragment = -1;
358 static int hf_btobex_fragment_error = -1;
359 static int hf_btobex_fragment_count = -1;
360 static int hf_btobex_reassembled_in = -1;
361 static int hf_btobex_reassembled_length = -1;
362
363 static gint ett_btobex_fragment = -1;
364 static gint ett_btobex_fragments = -1;
365
366 static dissector_handle_t btobex_handle;
367 static dissector_handle_t raw_application_parameters_handle;
368 static dissector_handle_t bpp_application_parameters_handle;
369 static dissector_handle_t bip_application_parameters_handle;
370 static dissector_handle_t gpp_application_parameters_handle;
371 static dissector_handle_t ctn_application_parameters_handle;
372 static dissector_handle_t map_application_parameters_handle;
373 static dissector_handle_t pbap_application_parameters_handle;
374
375 static reassembly_table btobex_reassembly_table;
376
377 static const fragment_items btobex_frag_items = {
378     &ett_btobex_fragment,
379     &ett_btobex_fragments,
380     &hf_btobex_fragments,
381     &hf_btobex_fragment,
382     &hf_btobex_fragment_overlap,
383     &hf_btobex_fragment_overlap_conflict,
384     &hf_btobex_fragment_multiple_tails,
385     &hf_btobex_fragment_too_long_fragment,
386     &hf_btobex_fragment_error,
387     &hf_btobex_fragment_count,
388     &hf_btobex_reassembled_in,
389     &hf_btobex_reassembled_length,
390     /* Reassembled data field */
391     NULL,
392     "fragments"
393 };
394
395 /* Initialize the subtree pointers */
396 static gint ett_btobex = -1;
397 static gint ett_btobex_hdrs = -1;
398 static gint ett_btobex_hdr = -1;
399 static gint ett_btobex_hdr_id = -1;
400 static gint ett_btobex_filter = -1;
401 static gint ett_btobex_parameter = -1;
402 static gint ett_btobex_session_parameters = -1;
403 static gint ett_btobex_application_parameters = -1;
404 static gint ett_btobex_authentication_parameters = -1;
405
406 static wmem_tree_t *obex_path = NULL;
407 static wmem_tree_t *obex_profile = NULL;
408 static wmem_tree_t *obex_last_opcode = NULL;
409
410 static dissector_handle_t http_handle;
411 static dissector_handle_t xml_handle;
412 static dissector_handle_t data_handle;
413 static dissector_handle_t data_text_lines_handle;
414
415 static const gchar  *path_unknown = "?";
416 static const gchar  *path_root    = "/";
417
418 typedef struct _ext_value_string {
419     guint8       value[16];
420     gint         length;
421     const gchar *strptr;
422 } ext_value_string;
423
424 typedef struct _obex_path_data_t {
425     guint32  interface_id;
426     guint32  adapter_id;
427     guint16  chandle;
428     guint8   channel;
429 /* TODO: add OBEX ConnectionId */
430
431     const gchar  *path;
432 } obex_path_data_t;
433
434 typedef struct _obex_profile_data_t {
435     guint32  interface_id;
436     guint32  adapter_id;
437     guint16  chandle;
438     guint8   channel;
439 /* TODO: add OBEX ConnectionId */
440
441     gint     profile;
442 } obex_profile_data_t;
443
444 typedef struct _obex_last_opcode_data_t {
445     guint32 interface_id;
446     guint32 adapter_id;
447     guint16 chandle;
448     guint8  channel;
449 /* TODO: add OBEX ConnectionId */
450     gint    code;
451
452     gboolean final_flag;
453
454     guint32  request_in_frame;
455     guint32  response_in_frame;
456
457     union {
458         struct {
459             const gchar  *name;
460             gboolean      go_up;
461         } set_data;
462         struct {
463             gchar     *type;
464             gchar     *name;
465         } get_put;
466     } data;
467 } obex_last_opcode_data_t;
468
469
470 #define PROFILE_UNKNOWN  0
471 #define PROFILE_OPP      1
472 #define PROFILE_FTP      2
473 #define PROFILE_SYNCML   3
474 #define PROFILE_PBAP     4
475 #define PROFILE_MAP      5
476 #define PROFILE_BIP      6
477 #define PROFILE_BPP      7
478 #define PROFILE_SYNC     8
479 #define PROFILE_CTN      9
480 #define PROFILE_GPP     10
481
482 #define PROTO_DATA_MEDIA_TYPE       0x00
483 #define PROTO_DATA_BTOBEX_PROFILE   0x01
484
485 static const value_string profile_vals[] = {
486     { PROFILE_UNKNOWN, "Unknown" },
487     { PROFILE_OPP,     "OPP" },
488     { PROFILE_FTP,     "FTP" },
489     { PROFILE_SYNCML,  "SyncML" },
490     { PROFILE_PBAP,    "PBAP" },
491     { PROFILE_MAP,     "MAP" },
492     { PROFILE_BIP,     "BIP" },
493     { PROFILE_BPP,     "BPP" },
494     { PROFILE_SYNC,    "SYNC" },
495     { PROFILE_CTN,     "CTN" },
496     { PROFILE_GPP,     "GPP" },
497     { 0,               NULL }
498 };
499 static value_string_ext(profile_vals_ext) = VALUE_STRING_EXT_INIT(profile_vals);
500
501
502 static const ext_value_string target_vals[] = {
503     {   { 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 }, 16, "Folder Browsing" },
504     {   { 0x79, 0x61, 0x35, 0xf0, 0xf0, 0xc5, 0x11, 0xd8, 0x09, 0x66, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 }, 16, "Phone Book Access Profile" },
505     {   { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02 }, 16, "SyncML" },
506     {   { 0xE3, 0x3D, 0x95, 0x45, 0x83, 0x74, 0x4A, 0xD7, 0x9E, 0xC5, 0xC1, 0x6B, 0xE3, 0x1E, 0xDE, 0x8E }, 16, "Basic Imaging Profile - Push" },
507     {   { 0x8E, 0xE9, 0xB3, 0xD0, 0x46, 0x08, 0x11, 0xD5, 0x84, 0x1A, 0x00, 0x02, 0xA5, 0x32, 0x5B, 0x4E }, 16, "Basic Imaging Profile - Pull" },
508     {   { 0x92, 0x35, 0x33, 0x50, 0x46, 0x08, 0x11, 0xD5, 0x84, 0x1A, 0x00, 0x02, 0xA5, 0x32, 0x5B, 0x4E }, 16, "Basic Imaging Profile - Advanced Printing" },
509     {   { 0x94, 0x01, 0x26, 0xC0, 0x46, 0x08, 0x11, 0xD5, 0x84, 0x1A, 0x00, 0x02, 0xA5, 0x32, 0x5B, 0x4E }, 16, "Basic Imaging Profile - Automativ Archive" },
510     {   { 0x94, 0x7E, 0x74, 0x20, 0x46, 0x08, 0x11, 0xD5, 0x84, 0x1A, 0x00, 0x02, 0xA5, 0x32, 0x5B, 0x4E }, 16, "Basic Imaging Profile - Remote Camera" },
511     {   { 0x94, 0xC7, 0xCD, 0x20, 0x46, 0x08, 0x11, 0xD5, 0x84, 0x1A, 0x00, 0x02, 0xA5, 0x32, 0x5B, 0x4E }, 16, "Basic Imaging Profile - Remote Display" },
512     {   { 0x8E, 0x61, 0xF9, 0x5D, 0x1A, 0x79, 0x11, 0xD4, 0x8E, 0xA4, 0x00, 0x80, 0x5F, 0x9B, 0x98, 0x34 }, 16, "Basic Imaging Profile- Referenced Objects" },
513     {   { 0x8E, 0x61, 0xF9, 0x5D, 0x1A, 0x79, 0x11, 0xD4, 0x8E, 0xA4, 0x00, 0x80, 0x5F, 0x9B, 0x98, 0x34 }, 16, "Basic Imaging Profile - Archived Objects" },
514     {   { 0xbb, 0x58, 0x2b, 0x40, 0x42, 0x0c, 0x11, 0xdb, 0xb0, 0xde, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 }, 16, "Message Access Profile - Message Access Service" },
515     {   { 0xbb, 0x58, 0x2b, 0x41, 0x42, 0x0c, 0x11, 0xdb, 0xb0, 0xde, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 }, 16, "Message Access Profile - Message Notification Service" },
516     {   { 0x00, 0x00, 0x11, 0x18, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }, 16, "Basic Printing Profile - Direct Printing Service" },
517     {   { 0x00, 0x00, 0x11, 0x19, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }, 16, "Basic Printing Profile - Reference Printing Service" },
518     {   { 0x00, 0x00, 0x11, 0x20, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }, 16, "Basic Printing Profile - Direct Printing Referenced Objects Service" },
519     {   { 0x00, 0x00, 0x11, 0x21, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }, 16, "Basic Printing Profile - Reflected UI" },
520     {   { 0x00, 0x00, 0x11, 0x22, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }, 16, "Basic Printing Profile - Basic Printing" },
521     {   { 0x00, 0x00, 0x11, 0x23, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }, 16, "Basic Printing Profile - Printing Status" },
522     {   { "IRMC-SYNC" }, 9, "Synchronization Profile" },
523     {   { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, NULL },
524 };
525
526 /* This table must map tagets from "target_vals" to profile */
527 static const gint target_to_profile[] = {
528     PROFILE_FTP,
529     PROFILE_PBAP,
530     PROFILE_SYNCML,
531     PROFILE_BIP,
532     PROFILE_BIP,
533     PROFILE_BIP,
534     PROFILE_BIP,
535     PROFILE_BIP,
536     PROFILE_BIP,
537     PROFILE_BIP,
538     PROFILE_BIP,
539     PROFILE_MAP,
540     PROFILE_MAP,
541     PROFILE_BPP,
542     PROFILE_BPP,
543     PROFILE_BPP,
544     PROFILE_BPP,
545     PROFILE_BPP,
546     PROFILE_BPP,
547     PROFILE_SYNC
548 };
549
550 static const value_string version_vals[] = {
551     { 0x10, "1.0" },
552     { 0x11, "1.1" },
553     { 0x12, "1.2" },
554     { 0x13, "1.3" },
555     { 0x20, "2.0" },
556     { 0x21, "2.1" },
557     { 0,      NULL }
558 };
559
560 static const value_string header_id_encoding_vals[] = {
561     { 0x00, "Null terminated Unicode text, length prefixed with 2 byte Unsigned Integer" },
562     { 0x01, "Byte sequence, length prefixed with 2 byte Unsigned Integer" },
563     { 0x02, "1 byte quantity" },
564     { 0x03, "4 byte quantity (network order)" },
565     { 0,    NULL }
566 };
567
568 #define BTOBEX_CODE_VALS_CONNECT    0x00
569 #define BTOBEX_CODE_VALS_DISCONNECT 0x01
570 #define BTOBEX_CODE_VALS_PUT        0x02
571 #define BTOBEX_CODE_VALS_GET        0x03
572 #define BTOBEX_CODE_VALS_SET_PATH   0x05
573 #define BTOBEX_CODE_VALS_CONTINUE   0x10
574 #define BTOBEX_CODE_VALS_SUCCESS    0x20
575 #define BTOBEX_CODE_VALS_ABORT      0x7F
576 #define BTOBEX_CODE_VALS_MASK       0x7F
577
578 static const value_string code_vals[] = {
579     { 0x00, "Connect" },
580     { 0x01, "Disconnect" },
581     { 0x02, "Put" },
582     { 0x03, "Get"},
583     { 0x05, "Set Path" },
584     { 0x06, "Action" },
585     { 0x07, "Session" },
586     { 0x10, "Continue" },
587     { 0x20, "Success" },
588     { 0x21, "Created" },
589     { 0x22, "Accepted" },
590     { 0x23, "Non-Authoritative Information" },
591     { 0x24, "No Content" },
592     { 0x25, "Reset Content" },
593     { 0x26, "Partial Content" },
594     { 0x30, "Multiple Choices" },
595     { 0x31, "Moved Permanently" },
596     { 0x32, "Moved Temporarily" },
597     { 0x33, "See Other" },
598     { 0x34, "Not Modified" },
599     { 0x35, "Use Proxy" },
600     { 0x40, "Bad Request" },
601     { 0x41, "Unauthorised" },
602     { 0x42, "Payment Required" },
603     { 0x43, "Forbidden" },
604     { 0x44, "Not Found" },
605     { 0x45, "Method Not Allowed" },
606     { 0x46, "Not Acceptable" },
607     { 0x47, "Proxy Authentication Required" },
608     { 0x48, "Request Timeout" },
609     { 0x49, "Conflict" },
610     { 0x4a, "Gone" },
611     { 0x4b, "Length Required" },
612     { 0x4c, "Precondition Failed" },
613     { 0x4d, "Requested Entity Too Large" },
614     { 0x4e, "Requested URL Too Large" },
615     { 0x4f, "Unsupported Media Type" },
616     { 0x50, "Internal Server Error" },
617     { 0x51, "Not Implemented" },
618     { 0x52, "Bad Gateway" },
619     { 0x53, "Service Unavailable" },
620     { 0x54, "Gateway Timeout" },
621     { 0x55, "HTTP Version Not Supported" },
622     { 0x60, "Database Full" },
623     { 0x61, "Database Locked" },
624     { BTOBEX_CODE_VALS_ABORT, "Abort" },
625     { 0,      NULL }
626 };
627 static value_string_ext(code_vals_ext) = VALUE_STRING_EXT_INIT(code_vals);
628
629 static const value_string header_id_meaning_vals[] = {
630     { 0x00, "Count" },
631     { 0x01, "Name" },
632     { 0x02, "Type" },
633     { 0x03, "Length" },
634     { 0x04, "Time" },
635     { 0x05, "Description" },
636     { 0x06, "Target" },
637     { 0x07, "HTTP" },
638     { 0x08, "Body" },
639     { 0x09, "End Of Body" },
640     { 0x0A, "Who" },
641     { 0x0B, "Connection Id" },
642     { 0x0C, "Application Parameters" },
643     { 0x0D, "Authentication Challenge" },
644     { 0x0E, "Authentication Response" },
645     { 0x0F, "Creator" },
646     { 0x10, "WAN UUID" },
647     { 0x11, "Object Class" },
648     { 0x12, "Session Parameter" },
649     { 0x13, "Session Sequence Number" },
650     { 0x14, "Action" },
651     { 0x15, "Destination Name" },
652     { 0x16, "Permissions" },
653     { 0x17, "Single Response Mode" },
654     { 0x18, "Single Response Mode Parameter" },
655     { 0x30, "User Defined" },
656     { 0x31, "User Defined" },
657     { 0x32, "User Defined" },
658     { 0x33, "User Defined" },
659     { 0x34, "User Defined" },
660     { 0x35, "User Defined" },
661     { 0x36, "User Defined" },
662     { 0x37, "User Defined" },
663     { 0x38, "User Defined" },
664     { 0x39, "User Defined" },
665     { 0x3A, "User Defined" },
666     { 0x3B, "User Defined" },
667     { 0x3C, "User Defined" },
668     { 0x3D, "User Defined" },
669     { 0x3E, "User Defined" },
670     { 0x3F, "User Defined" },
671     { 0,      NULL }
672 };
673
674 static const value_string header_id_vals[] = {
675 /* 0x00 - 0x3F - Null terminated Unicode text, length prefixed with 2 byte Unsigned Integer */
676     { 0x01, "Name" },
677     { 0x05, "Description" },
678     { 0x15, "Destination Name" },
679     { 0x30, "User Defined" },
680     { 0x31, "User Defined" },
681     { 0x32, "User Defined" },
682     { 0x33, "User Defined" },
683     { 0x34, "User Defined" },
684     { 0x35, "User Defined" },
685     { 0x36, "User Defined" },
686     { 0x37, "User Defined" },
687     { 0x38, "User Defined" },
688     { 0x39, "User Defined" },
689     { 0x3a, "User Defined" },
690     { 0x3b, "User Defined" },
691     { 0x3c, "User Defined" },
692     { 0x3d, "User Defined" },
693     { 0x3e, "User Defined" },
694     { 0x3f, "User Defined" },
695 /* 0x40 - 0x07F -  Byte sequence, length prefixed with 2 byte Unsigned Integer */
696     { 0x42, "Type" },
697     { 0x44, "Time (ISO8601)" },
698     { 0x46, "Target" },
699     { 0x47, "HTTP" },
700     { 0x48, "Body" },
701     { 0x49, "End Of Body" },
702     { 0x4a, "Who" },
703     { 0x4c, "Application Parameters" },
704     { 0x4d, "Authentication Challenge" },
705     { 0x4e, "Authentication Response" },
706     { 0x50, "WAN UUID" },
707     { 0x51, "Object Class" },
708     { 0x52, "Session Parameter" },
709 /* 0x80 - 0xBF - 1 byte quantity */
710     { 0x93, "Session Sequence Number" },
711     { 0x94, "Action" },
712     { 0x97, "Single Response Mode" },
713     { 0x98, "Single Response Mode Parameter" },
714 /* 0xC0 - 0xFF - 4 byte quantity (network order) */
715     { 0xc0, "Count" },
716     { 0xc3, "Length" },
717     { 0xc4, "Time (UNIX)" },
718     { 0xcb, "Connection Id" },
719     { 0xcf, "Creator" },
720     { 0xd6, "Permissions" },
721     { 0,      NULL }
722 };
723 static value_string_ext header_id_vals_ext = VALUE_STRING_EXT_INIT(header_id_vals);
724
725 static const value_string map_application_parameters_vals[] = {
726     { 0x01, "Max List Count" },
727     { 0x02, "Start Offset" },
728     { 0x03, "Filter Message Type" },
729     { 0x04, "Filter Period Begin" },
730     { 0x05, "End Filter PeriodEnd" },
731     { 0x06, "Filter Read Status" },
732     { 0x07, "Filter Recipient" },
733     { 0x08, "Filter Originator" },
734     { 0x09, "Filter Priority" },
735     { 0x0A, "Attachment" },
736     { 0x0B, "Transparent" },
737     { 0x0C, "Retry" },
738     { 0x0D, "New Message" },
739     { 0x0E, "Notification Status" },
740     { 0x0F, "MAS Instance ID" },
741     { 0x10, "Parameter Mask" },
742     { 0x11, "Folder Listing Size" },
743     { 0x12, "Messages Listing Size" },
744     { 0x13, "Subject Length" },
745     { 0x14, "Charset" },
746     { 0x15, "Fraction Request" },
747     { 0x16, "Fraction Deliver" },
748     { 0x17, "Status Indicator" },
749     { 0x18, "Status Value" },
750     { 0x19, "MSE Time" },
751     { 0,    NULL }
752 };
753
754 static const value_string pbap_application_parameters_vals[] = {
755     { 0x01, "Order" },
756     { 0x02, "Search Value" },
757     { 0x03, "Search Attribute" },
758     { 0x04, "Max List Count" },
759     { 0x05, "List Start Offset" },
760     { 0x06, "Filter" },
761     { 0x07, "Format" },
762     { 0x08, "Phonebook Size" },
763     { 0x09, "New Missed Calls" },
764     { 0x0A, "Primary Version Counter" },
765     { 0x0B, "Secondary Version Counter" },
766     { 0x0C, "vCard Selector" },
767     { 0x0D, "Database Identifier" },
768     { 0x0E, "vCard Selector Operator" },
769     { 0x0F, "Reset New Missed Calls" },
770     { 0x10, "PBAP Supported Features" },
771     { 0,    NULL }
772 };
773
774 static const value_string bpp_application_parameters_vals[] = {
775     { 0x01, "Offset" },
776     { 0x02, "Count" },
777     { 0x03, "Job ID" },
778     { 0x04, "File Size" },
779     { 0,    NULL }
780 };
781
782 static const value_string bip_application_parameters_vals[] = {
783     { 0x01, "Number of Returned Handles" },
784     { 0x02, "List Start Offset" },
785     { 0x03, "Latest Captures Images" },
786     { 0x04, "Partial File Length" },
787     { 0x05, "Partial File Start Offset" },
788     { 0x06, "Total File Size" },
789     { 0x07, "End Flag" },
790     { 0x08, "Remote Display" },
791     { 0x09, "Service ID" },
792     { 0x0A, "Store Flag" },
793     { 0,    NULL }
794 };
795
796 static const value_string gpp_application_parameters_vals[] = {
797     { 0x41, "Max List Count" },
798     { 0x42, "List Start Offset" },
799     { 0x43, "Notification Status" },
800     { 0x44, "Instance ID" },
801     { 0x46, "Listing Size" },
802     { 0,    NULL }
803 };
804
805 static const value_string ctn_application_parameters_vals[] = {
806     { 0x01, "Acoustic Alarm Status" },
807     { 0x02, "Attachment" },
808     { 0x03, "Send" },
809     { 0x04, "Filter Period Begin" },
810     { 0x05, "Filter Period End" },
811     { 0x06, "Parameter Mask" },
812     { 0x07, "Status Indicator" },
813     { 0x08, "Status Value" },
814     { 0x09, "Postpone Val" },
815     { 0x0A, "Email URI" },
816     { 0x0B, "CSE Time" },
817     { 0x0C, "Recurrent" },
818     { 0x0D, "Attach ID" },
819     { 0x0E, "Last Update" },
820     { 0x41, "Max List Count" },
821     { 0x42, "List Start Offset" },
822     { 0x43, "Notification Status" },
823     { 0x44, "Instance ID" },
824     { 0x46, "Listing Size" },
825     { 0,    NULL }
826 };
827
828 static const value_string bip_remote_display_vals[] = {
829     { 0x01, "Next Image" },
830     { 0x02, "Previous Image" },
831     { 0x03, "Select Image" },
832     { 0x04, "Current Image" },
833     { 0,    NULL }
834 };
835
836 static const value_string pbap_order_vals[] = {
837     { 0x00, "Indexed" },
838     { 0x01, "Alphanumeric" },
839     { 0x02, "Phonetic" },
840     { 0,    NULL }
841 };
842
843 static const value_string pbap_format_vals[] = {
844     { 0x00, "2.1" },
845     { 0x01, "3.0" },
846     { 0,    NULL }
847 };
848
849 static const value_string pbap_search_attribute_vals[] = {
850     { 0x00, "Name" },
851     { 0x01, "Number" },
852     { 0x02, "Sound" },
853     { 0,    NULL }
854 };
855
856 static const value_string map_charset_vals[] = {
857     { 0x00, "Native" },
858     { 0x01, "UTF-8" },
859     { 0,    NULL }
860 };
861
862 static const value_string map_fraction_request_vals[] = {
863     { 0x00, "First" },
864     { 0x01, "Next" },
865     { 0,    NULL }
866 };
867
868 static const value_string map_fraction_deliver_vals[] = {
869     { 0x00, "More" },
870     { 0x01, "Last" },
871     { 0,    NULL }
872 };
873
874 static const value_string map_status_indicator_vals[] = {
875     { 0x00, "Read Status" },
876     { 0x01, "Deleted Status" },
877     { 0,    NULL }
878 };
879
880 static const value_string authentication_challenge_tag_vals[] = {
881     { 0x00, "Key" },
882     { 0x01, "Options" },
883     { 0x02, "Info" },
884     { 0,    NULL }
885 };
886
887 static const value_string authentication_response_tag_vals[] = {
888     { 0x00, "Result Key" },
889     { 0x01, "User ID" },
890     { 0x02, "Key" },
891     { 0,    NULL }
892 };
893
894 static const value_string info_charset_vals[] = {
895     { 0x00, "ASCII" },
896     { 0xFF, "Unicode" },
897     { 0,    NULL }
898 };
899
900 static const value_string action_vals[] = {
901     { 0x00, "Copy" },
902     { 0x01, "Move" },
903     { 0x02, "Set Permission" },
904     { 0,    NULL }
905 };
906
907 static const value_string single_response_mode_vals[] = {
908     { 0x00, "Disable" },
909     { 0x01, "Enable" },
910     { 0x02, "Indicate" },
911     { 0,    NULL }
912 };
913
914 static const value_string single_response_mode_parameter_vals[] = {
915     { 0x00, "Next" },
916     { 0x01, "Wait" },
917     { 0x02, "Next and Wait" },
918     { 0,    NULL }
919 };
920
921 static const value_string session_tag_vals[] = {
922     { 0x00, "Device Address" },
923     { 0x01, "Nonce" },
924     { 0x02, "Session ID" },
925     { 0x03, "Next Sequence Number" },
926     { 0x04, "Timeout" },
927     { 0x05, "Session Opcode" },
928     { 0,    NULL }
929 };
930
931 static const value_string session_opcode_vals[] = {
932     { 0x00, "Create Session" },
933     { 0x01, "Close Session" },
934     { 0x02, "Suspend Session" },
935     { 0x03, "Resume Session" },
936     { 0x04, "Set Timeout" },
937     { 0,    NULL }
938 };
939
940 static const value_string pbap_application_parameter_data_vcard_selector_operator_vals[] = {
941     { 0x00, "Or" },
942     { 0x01, "And" },
943     { 0,    NULL }
944 };
945
946 static const value_string pbap_application_parameter_data_reset_new_missed_calls_vals[] = {
947     { 0x01, "Reset" },
948     { 0,    NULL }
949 };
950
951 static const value_string off_on_vals[] = {
952     { 0x00, "Off" },
953     { 0x01, "On" },
954     { 0,    NULL }
955 };
956
957 static const value_string no_yes_vals[] = {
958     { 0x00, "No" },
959     { 0x01, "Yes" },
960     { 0,    NULL }
961 };
962
963 static const value_string ctn_application_parameter_data_attachment_vals[] = {
964     { 0x00, "On" },
965     { 0x01, "Off" },
966     { 0x02, "Selected" },
967     { 0,    NULL }
968 };
969
970 static const value_string ctn_application_parameter_data_status_indicator_vals[] = {
971     { 0x00, "pStatus" },
972     { 0x01, "Alarm Status" },
973     { 0x02, "Send Status" },
974     { 0x03, "Deleted Status" },
975     { 0,    NULL }
976 };
977
978 static const value_string ctn_application_parameter_data_status_value_vals[] = {
979     { 0x00, "No" },
980     { 0x01, "Yes" },
981     { 0x02, "Postpone" },
982     { 0x03, "Tentative" },
983     { 0x04, "Needs-action" },
984     { 0x05, "Accepted" },
985     { 0x06, "Declined" },
986     { 0x07, "Delegated" },
987     { 0x08, "Completed" },
988     { 0x09, "In-progress" },
989     { 0,    NULL }
990 };
991
992 static value_string_ext map_application_parameters_vals_ext = VALUE_STRING_EXT_INIT(map_application_parameters_vals);
993 static value_string_ext pbap_application_parameters_vals_ext = VALUE_STRING_EXT_INIT(pbap_application_parameters_vals);
994 static value_string_ext bpp_application_parameters_vals_ext = VALUE_STRING_EXT_INIT(bpp_application_parameters_vals);
995 static value_string_ext bip_application_parameters_vals_ext = VALUE_STRING_EXT_INIT(bip_application_parameters_vals);
996
997 void proto_register_btobex(void);
998 void proto_reg_handoff_btobex(void);
999
1000 static void
1001 save_path(packet_info *pinfo, const gchar *current_path, const gchar *name, gboolean go_up, int is_obex_over_l2cap, void *data)
1002 {
1003
1004 /* On Connect response sets "/"
1005    On SetPath sets what is needed
1006  */
1007     if (!pinfo->fd->flags.visited && data) {
1008         obex_path_data_t     *obex_path_data;
1009         guint32               interface_id;
1010         guint32               adapter_id;
1011         guint32               chandle;
1012         guint32               channel;
1013         wmem_tree_key_t       key[6];
1014         guint32               k_interface_id;
1015         guint32               k_adapter_id;
1016         guint32               k_frame_number;
1017         guint32               k_chandle;
1018         guint32               k_channel;
1019         const gchar          *path = path_unknown;
1020
1021         if (is_obex_over_l2cap) {
1022             btl2cap_data_t      *l2cap_data;
1023
1024             l2cap_data   = (btl2cap_data_t *) data;
1025             interface_id = l2cap_data->interface_id;
1026             adapter_id   = l2cap_data->adapter_id;
1027             chandle      = l2cap_data->chandle;
1028             channel      = l2cap_data->cid;
1029         } else {
1030             btrfcomm_data_t      *rfcomm_data;
1031
1032             rfcomm_data  = (btrfcomm_data_t *) data;
1033             interface_id = rfcomm_data->interface_id;
1034             adapter_id   = rfcomm_data->adapter_id;
1035             chandle      = rfcomm_data->chandle;
1036             channel      = rfcomm_data->dlci >> 1;
1037         }
1038
1039         k_interface_id = interface_id;
1040         k_adapter_id   = adapter_id;
1041         k_chandle      = chandle;
1042         k_channel      = channel;
1043         k_frame_number = pinfo->fd->num;
1044
1045         key[0].length = 1;
1046         key[0].key = &k_interface_id;
1047         key[1].length = 1;
1048         key[1].key = &k_adapter_id;
1049         key[2].length = 1;
1050         key[2].key = &k_chandle;
1051         key[3].length = 1;
1052         key[3].key = &k_channel;
1053         key[4].length = 1;
1054         key[4].key = &k_frame_number;
1055         key[5].length = 0;
1056         key[5].key = NULL;
1057
1058         obex_path_data = wmem_new(wmem_file_scope(), obex_path_data_t);
1059         obex_path_data->interface_id = interface_id;
1060         obex_path_data->adapter_id = adapter_id;
1061         obex_path_data->chandle = chandle;
1062         obex_path_data->channel = channel;
1063
1064         if (go_up == TRUE) {
1065             if (current_path != path_unknown && current_path != path_root) {
1066                 gchar *i_path;
1067
1068                 i_path = g_strrstr(current_path, "/");
1069                 if (!i_path) {
1070                     current_path = path_unknown;
1071                 } else {
1072                     if (i_path == current_path)
1073                         path = current_path = path_root;
1074                     else
1075                         path = current_path = wmem_strndup(wmem_epan_scope(), current_path, i_path - current_path - 1);
1076                 }
1077             }
1078         }
1079
1080         if (name && *name == '\0')
1081             path = path_root;
1082         else if (name && current_path == path_root)
1083             path = wmem_strdup_printf(wmem_file_scope(), "/%s", name);
1084         else if (name)
1085             path = wmem_strdup_printf(wmem_file_scope(), "%s/%s", current_path, name);
1086
1087         obex_path_data->path = path;
1088
1089         wmem_tree_insert32_array(obex_path, key, obex_path_data);
1090     }
1091 }
1092
1093 static void media_type_prompt(packet_info *pinfo, gchar* result)
1094 {
1095     gchar *value_data;
1096
1097     value_data = (gchar *) p_get_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_MEDIA_TYPE);
1098     if (value_data)
1099         g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Media Type %s as", (gchar *) value_data);
1100     else
1101         g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown Media Type");
1102 }
1103
1104 static gpointer media_type_value(packet_info *pinfo)
1105 {
1106     gchar *value_data;
1107
1108     value_data = (gchar *) p_get_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_MEDIA_TYPE);
1109
1110     if (value_data)
1111         return (gpointer) value_data;
1112
1113     return NULL;
1114 }
1115
1116 static void btobex_profile_prompt(packet_info *pinfo _U_, gchar* result)
1117 {
1118     gulong *value_data;
1119
1120     value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_BTOBEX_PROFILE);
1121     if (value_data)
1122         g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "OBEX Profile 0x%04x as", (guint) *value_data);
1123     else
1124         g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Unknown OBEX Profile");
1125 }
1126
1127 static gpointer btobex_profile_value(packet_info *pinfo _U_)
1128 {
1129     gulong *value_data;
1130
1131     value_data = (gulong *) p_get_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_BTOBEX_PROFILE);
1132
1133     if (value_data)
1134         return (gpointer) *value_data;
1135
1136     return NULL;
1137 }
1138
1139 static void
1140 defragment_init(void)
1141 {
1142     reassembly_table_init(&btobex_reassembly_table,
1143                           &addresses_reassembly_table_functions);
1144 }
1145
1146 static void
1147 defragment_cleanup(void)
1148 {
1149     reassembly_table_destroy(&btobex_reassembly_table);
1150 }
1151
1152 static int
1153 is_ascii_str(const guint8 *str, int length)
1154 {
1155     int i;
1156
1157     if ((length < 1) || (str[length-1] != '\0'))
1158         return 0;
1159
1160     for(i=0; i<length-1; i++) {
1161         if ((str[i] < 0x20) && (str[i] != 0x0a)) /* not strict ascii */
1162         break;
1163     }
1164
1165     if (i < (length-1))
1166         return 0;
1167
1168     return 1;
1169 }
1170
1171 static gint
1172 dissect_btobex_application_parameter_raw(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
1173 {
1174     proto_item  *parameter_item;
1175     proto_tree  *parameter_tree;
1176     guint8       parameter_id;
1177     gint         offset = 0;
1178     gint         parameters_length;
1179     gint         parameter_length;
1180
1181     parameters_length = tvb_reported_length(tvb);
1182
1183     while (parameters_length > 0) {
1184         parameter_id = tvb_get_guint8(tvb, offset);
1185         parameter_item = proto_tree_add_none_format(tree, hf_application_parameter, tvb, offset,
1186                 tvb_captured_length_remaining(tvb, offset), "Parameter: 0x%02x", parameter_id);
1187         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_application_parameters);
1188
1189         proto_tree_add_item(parameter_tree, hf_application_parameter_id, tvb, offset,
1190                 1, ENC_BIG_ENDIAN);
1191         offset += 1;
1192
1193         proto_tree_add_item(parameter_tree, hf_application_parameter_length, tvb, offset,
1194                 1, ENC_BIG_ENDIAN);
1195         parameter_length = tvb_get_guint8(tvb, offset);
1196         proto_item_set_len(parameter_item, parameter_length + 2);
1197         offset += 1;
1198
1199         proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset,
1200                 parameter_length, ENC_NA);
1201
1202         parameters_length -= 2 + parameter_length;
1203         offset += parameter_length;
1204     }
1205
1206     return offset;
1207 }
1208
1209 static gint
1210 dissect_btobex_application_parameter_bpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1211 {
1212     proto_item  *item;
1213     proto_item  *parameter_item;
1214     proto_tree  *parameter_tree;
1215     guint8       parameter_id;
1216     gint         offset = 0;
1217     gint         parameters_length;
1218     gint         parameter_length;
1219
1220     parameters_length = tvb_reported_length(tvb);
1221
1222     while (parameters_length > 0) {
1223         parameter_id = tvb_get_guint8(tvb, offset);
1224         parameter_length = tvb_get_guint8(tvb, offset + 1);
1225
1226         parameter_item = proto_tree_add_none_format(tree, hf_application_parameter, tvb, offset, parameter_length + 2,
1227                 "Parameter: %s", val_to_str_const(parameter_id,
1228                 bpp_application_parameters_vals, "Unknown"));
1229         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_application_parameters);
1230
1231         proto_tree_add_item(parameter_tree, hf_bpp_application_parameter_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1232         offset += 1;
1233
1234         item = proto_tree_add_item(parameter_tree, hf_application_parameter_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1235         offset += 1;
1236
1237         if (parameter_length != 4) {
1238                 proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1239                 expert_add_info_format(pinfo, item, &ei_application_parameter_length_bad,
1240                         "According to the specification this parameter length should be 4, but there is %i", parameter_length);
1241         } else switch (parameter_id) {
1242             case 0x01:
1243                proto_tree_add_item(parameter_tree, hf_bpp_application_parameter_data_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
1244                break;
1245             case 0x02:
1246                proto_tree_add_item(parameter_tree, hf_bpp_application_parameter_data_count, tvb, offset, 4, ENC_BIG_ENDIAN);
1247                break;
1248             case 0x03:
1249                proto_tree_add_item(parameter_tree, hf_bpp_application_parameter_data_job_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1250                break;
1251             case 0x04:
1252                proto_tree_add_item(parameter_tree, hf_bpp_application_parameter_data_file_size, tvb, offset, 4, ENC_BIG_ENDIAN);
1253                break;
1254             default:
1255                 proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1256         }
1257
1258         parameters_length -= 2 + parameter_length;
1259         offset += parameter_length;
1260     }
1261
1262     return offset;
1263 }
1264
1265 static gint
1266 dissect_btobex_application_parameter_bip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1267 {
1268     proto_item  *item;
1269     proto_item  *parameter_item;
1270     proto_tree  *parameter_tree;
1271     guint8       parameter_id;
1272     gint         offset = 0;
1273     gint         parameters_length;
1274     gint         parameter_length;
1275     static gint  required_length_map[] = {0, 2, 2, 1, 4, 4, 4, 1, 1, 16, 1};
1276
1277     parameters_length = tvb_reported_length(tvb);
1278
1279     while (parameters_length > 0) {
1280         parameter_id = tvb_get_guint8(tvb, offset);
1281         parameter_length = tvb_get_guint8(tvb, offset + 1);
1282
1283         parameter_item = proto_tree_add_none_format(tree, hf_application_parameter, tvb, offset, parameter_length + 2,
1284                 "Parameter: %s", val_to_str_const(parameter_id,
1285                 bip_application_parameters_vals, "Unknown"));
1286         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_application_parameters);
1287
1288         proto_tree_add_item(parameter_tree, hf_bip_application_parameter_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1289         offset += 1;
1290
1291         item = proto_tree_add_item(parameter_tree, hf_application_parameter_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1292         offset += 1;
1293
1294        if (parameter_id < (sizeof(required_length_map)/sizeof(gint)) &&
1295                 required_length_map[parameter_id] != parameter_length) {
1296             proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1297             expert_add_info_format(pinfo, item, &ei_application_parameter_length_bad,
1298                     "According to the specification this parameter length should be %i, but there is %i",
1299                     required_length_map[parameter_id], parameter_length);
1300         } else switch (parameter_id) {
1301             case 0x01:
1302                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_number_of_returned_handles, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1303                 break;
1304             case 0x02:
1305                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_list_start_offset, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1306                 break;
1307             case 0x03:
1308                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_latest_captured_images, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1309                 break;
1310             case 0x04:
1311                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_partial_file_length, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1312                 break;
1313             case 0x05:
1314                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_partial_file_start_offset, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1315                 break;
1316             case 0x06:
1317                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_total_file_size, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1318                 break;
1319             case 0x07:
1320                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_end_flag, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1321                 break;
1322             case 0x08:
1323                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_remote_display, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1324                 break;
1325             case 0x09:
1326                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_service_id, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1327                 break;
1328             case 0x0A:
1329                 proto_tree_add_item(parameter_tree, hf_bip_application_parameter_data_store_flag, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1330                 break;
1331             default:
1332                 proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1333         }
1334
1335         parameters_length -= 2 + parameter_length;
1336         offset += parameter_length;
1337     }
1338
1339     return offset;
1340 }
1341
1342 static gint
1343 dissect_btobex_application_parameter_pbap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1344 {
1345     proto_item  *item;
1346     proto_item  *parameter_item;
1347     proto_tree  *parameter_tree;
1348     guint8       parameter_id;
1349     gint         offset = 0;
1350     gint         parameters_length;
1351     gint         parameter_length;
1352     static gint  required_length_map[] = {0, 1, -1, 1, 2, 2, 8, 1, 2, 1, 16, 16, 8, 16, 1, 1};
1353
1354     parameters_length = tvb_reported_length(tvb);
1355
1356     while (parameters_length > 0) {
1357         parameter_id = tvb_get_guint8(tvb, offset);
1358         parameter_length = tvb_get_guint8(tvb, offset + 1);
1359
1360         parameter_item = proto_tree_add_none_format(tree, hf_application_parameter, tvb, offset, parameter_length + 2,
1361                 "Parameter: %s", val_to_str_const(parameter_id,
1362                 pbap_application_parameters_vals, "Unknown"));
1363         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_application_parameters);
1364
1365         proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1366         offset += 1;
1367
1368         item = proto_tree_add_item(parameter_tree, hf_application_parameter_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1369         offset += 1;
1370
1371         if (parameter_id < (sizeof(required_length_map)/sizeof(gint)) &&
1372                 required_length_map[parameter_id] != -1 &&
1373                 required_length_map[parameter_id] != parameter_length) {
1374             proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1375             expert_add_info_format(pinfo, item, &ei_application_parameter_length_bad,
1376                     "According to the specification this parameter length should be %i, but there is %i",
1377                     required_length_map[parameter_id], parameter_length);
1378         } else switch (parameter_id) {
1379             case 0x01: /* Order */
1380                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_order, tvb, offset, 1, ENC_BIG_ENDIAN);
1381                 break;
1382             case 0x02: /* Search Value */
1383                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_search_value, tvb, offset, parameter_length, ENC_ASCII | ENC_NA);
1384                 break;
1385             case 0x03: /* Search Attribute */
1386                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_search_attribute, tvb, offset, 1, ENC_BIG_ENDIAN);
1387                 break;
1388             case 0x04: /* Max List Count */
1389                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_max_list_count, tvb, offset, 2, ENC_BIG_ENDIAN);
1390                 break;
1391             case 0x05: /* List Start Offset */
1392                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_list_start_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
1393                 break;
1394             case 0x06: /* Filter */
1395                 proto_tree_add_bitmask(parameter_tree, tvb, offset, hf_pbap_application_parameter_data_filter, ett_btobex_filter,  hfx_pbap_application_parameter_data_filter_1, ENC_BIG_ENDIAN);
1396                 proto_tree_add_bitmask(parameter_tree, tvb, offset, hf_pbap_application_parameter_data_filter, ett_btobex_filter,  hfx_pbap_application_parameter_data_filter_0, ENC_BIG_ENDIAN);
1397                 break;
1398             case 0x07: /* Format */
1399                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_format, tvb, offset, 1, ENC_NA);
1400                 break;
1401             case 0x08: /* Phonebook Size */
1402                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_phonebook_size, tvb, offset, 2, ENC_BIG_ENDIAN);
1403                 break;
1404             case 0x09: /* New Missed Calls */
1405                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_new_missed_calls, tvb, offset, 1, ENC_NA);
1406                 break;
1407             case 0x0A: /* Primary Version Counter */
1408                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_primary_version_counter, tvb, offset, 16, ENC_NA);
1409                 break;
1410             case 0x0B: /* Secondary Version Counter */
1411                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_secondary_version_counter, tvb, offset, 16, ENC_NA);
1412                 break;
1413             case 0x0C: /* vCard Selector */
1414                 proto_tree_add_bitmask(parameter_tree, tvb, offset, hf_pbap_application_parameter_vcard_selector, ett_btobex_filter,  hfx_pbap_application_parameter_data_filter_1, ENC_BIG_ENDIAN);
1415                 proto_tree_add_bitmask(parameter_tree, tvb, offset, hf_pbap_application_parameter_vcard_selector, ett_btobex_filter,  hfx_pbap_application_parameter_data_filter_0, ENC_BIG_ENDIAN);
1416                 break;
1417             case 0x0D: /* Database Identifier */
1418                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_database_identifier, tvb, offset, 16, ENC_NA);
1419                 break;
1420             case 0x0E: /* vCard Selector Operator */
1421                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_vcard_selector_operator, tvb, offset, 1, ENC_NA);
1422                 break;
1423             case 0x0F: /* Reset New Missed Calls */
1424                 proto_tree_add_item(parameter_tree, hf_pbap_application_parameter_data_reset_new_missed_calls, tvb, offset, 1, ENC_NA);
1425                 break;
1426             case 0x10: /* PBAP Supported Features */
1427                 proto_tree_add_bitmask(parameter_tree, tvb, offset, hf_pbap_application_parameter_data_supported_features, ett_btobex_parameter,  hfx_pbap_application_parameter_data_supported_features, ENC_BIG_ENDIAN);
1428                 break;
1429             default:
1430                 proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1431         }
1432
1433         parameters_length -= 2 + parameter_length;
1434         offset += parameter_length;
1435     }
1436
1437     return offset;
1438 }
1439
1440 static gint
1441 dissect_btobex_application_parameter_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1442 {
1443     proto_item  *item;
1444     proto_item  *parameter_item;
1445     proto_tree  *parameter_tree;
1446     guint8       parameter_id;
1447     gint         offset = 0;
1448     gint         parameters_length;
1449     gint         parameter_length;
1450     static gint  required_length_map[] = {0, 2, 2, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 4, 2, 2, 1, 1, 1, 1, 1, 1, -1};
1451
1452     parameters_length = tvb_reported_length(tvb);
1453
1454     while (parameters_length > 0) {
1455         parameter_id = tvb_get_guint8(tvb, offset);
1456         parameter_length = tvb_get_guint8(tvb, offset + 1);
1457
1458         parameter_item = proto_tree_add_none_format(tree, hf_application_parameter, tvb, offset, parameter_length + 2,
1459                 "Parameter: %s", val_to_str_const(parameter_id,
1460                 map_application_parameters_vals, "Unknown"));
1461         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_application_parameters);
1462
1463         proto_tree_add_item(parameter_tree, hf_map_application_parameter_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1464         offset += 1;
1465
1466         item = proto_tree_add_item(parameter_tree, hf_application_parameter_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1467         offset += 1;
1468
1469         if (parameter_id < (sizeof(required_length_map)/sizeof(gint)) &&
1470                 required_length_map[parameter_id] != -1 &&
1471                 required_length_map[parameter_id] != parameter_length) {
1472             proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1473             expert_add_info_format(pinfo, item, &ei_application_parameter_length_bad,
1474                     "According to the specification this parameter length should be %i, but there is %i",
1475                     required_length_map[parameter_id], parameter_length);
1476         } else switch (parameter_id) {
1477             case 0x01:
1478                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_max_list_count, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1479                 break;
1480             case 0x02:
1481                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_start_offset, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1482                 break;
1483             case 0x03:
1484                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_message_type_reserved, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1485                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_message_type_mms,      tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1486                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_message_type_email,    tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1487                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_message_type_sms_cdma, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1488                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_message_type_sms_gsm,  tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1489                 break;
1490             case 0x04:
1491                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_period_begin, tvb, offset, parameter_length, ENC_ASCII | ENC_NA);
1492                 break;
1493             case 0x05:
1494                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_period_end, tvb, offset, parameter_length, ENC_ASCII | ENC_NA);
1495                 break;
1496             case 0x06:
1497                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_read_status_reserved_6, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1498                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_read_status_get_read, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1499                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_read_status_get_unread, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1500                 break;
1501             case 0x07:
1502                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_recipient, tvb, offset, parameter_length, ENC_ASCII | ENC_NA);
1503                 break;
1504             case 0x08:
1505                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_originator, tvb, offset, parameter_length, ENC_ASCII | ENC_NA);
1506                 break;
1507             case 0x09:
1508                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_priority_reserved_6, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1509                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_priority_get_high, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1510                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_filter_priority_non_high, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1511                 break;
1512             case 0x0A:
1513                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1514                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_attachment, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1515                 break;
1516             case 0x0B:
1517                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1518                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_transparent, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1519                 break;
1520             case 0x0C:
1521                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1522                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_retry, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1523                 break;
1524             case 0x0D:
1525                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1526                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_new_message, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1527                 break;
1528             case 0x0E:
1529                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1530                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_notification_status, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1531                 break;
1532             case 0x0F:
1533                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_mas_instance_id, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1534                 break;
1535             case 0x10:
1536                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_reserved,             tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1537                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_reply_to_addressing,  tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1538                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_protected,            tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1539                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_sent,                 tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1540                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_read,                 tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1541                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_priority,             tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1542                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_attachment_size,      tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1543                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_text,                 tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1544                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_reception_status,     tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1545                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_size,                 tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1546                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_type,                 tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1547                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_recipient_addressing, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1548                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_recipient_name,       tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1549                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_sender_addressing,    tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1550                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_sender_name,          tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1551                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_datetime,             tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1552                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_parameter_mask_subject,              tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1553
1554                 break;
1555             case 0x11:
1556                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_folder_listing_size, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1557                  break;
1558             case 0x12:
1559                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_messages_listing_size, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1560                 break;
1561             case 0x13:
1562                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_subject_length, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1563                 break;
1564             case 0x14:
1565                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1566                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_charset, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1567                 break;
1568             case 0x15:
1569                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1570                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_fraction_request, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1571                 break;
1572             case 0x16:
1573                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1574                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_fraction_deliver, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1575                 break;
1576             case 0x17:
1577                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1578                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_status_indicator, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1579                 break;
1580             case 0x18:
1581                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_reserved_7, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1582                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_status_value, tvb, offset, required_length_map[parameter_id], ENC_BIG_ENDIAN);
1583                 break;
1584             case 0x19:
1585                 proto_tree_add_item(parameter_tree, hf_map_application_parameter_data_mse_time, tvb, offset, parameter_length, ENC_ASCII | ENC_NA);
1586                 break;
1587             default:
1588                 proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1589         }
1590
1591         parameters_length -= 2 + parameter_length;
1592         offset += parameter_length;
1593     }
1594
1595    return offset;
1596 }
1597
1598 static gint
1599 dissect_btobex_application_parameter_gpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1600 {
1601     proto_item  *item;
1602     proto_item  *parameter_item;
1603     proto_tree  *parameter_tree;
1604     guint8       parameter_id;
1605     gint         offset = 0;
1606     gint         parameters_length;
1607     gint         parameter_length;
1608     static gint  required_length_map[] = {2, 2, 1, 1, 0, 2};
1609
1610     parameters_length = tvb_reported_length(tvb);
1611
1612     while (parameters_length > 0) {
1613         parameter_id = tvb_get_guint8(tvb, offset);
1614         parameter_length = tvb_get_guint8(tvb, offset + 1);
1615
1616         parameter_item = proto_tree_add_none_format(tree, hf_application_parameter, tvb, offset, parameter_length + 2,
1617                 "Parameter: %s", val_to_str_const(parameter_id,
1618                 gpp_application_parameters_vals, "Unknown"));
1619         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_application_parameters);
1620
1621         proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1622         offset += 1;
1623
1624         item = proto_tree_add_item(parameter_tree, hf_application_parameter_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1625         offset += 1;
1626
1627         if (parameter_id >= 0x41 && (guint8)(parameter_id - 0x41) < (sizeof(required_length_map)/sizeof(gint)) &&
1628                 required_length_map[parameter_id - 0x41] != -1 &&
1629                 required_length_map[parameter_id - 0x41] != parameter_length) {
1630             proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1631             expert_add_info_format(pinfo, item, &ei_application_parameter_length_bad,
1632                     "According to the specification this parameter length should be %i, but there is %i",
1633                     required_length_map[parameter_id - 0x41], parameter_length);
1634         } else switch (parameter_id) {
1635             case 0x41: /* Max List Count */
1636                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_max_list_count, tvb, offset, 2, ENC_BIG_ENDIAN);
1637                 break;
1638             case 0x42: /* List Start Offset */
1639                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_list_start_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
1640                 break;
1641             case 0x43: /* Notification Status */
1642                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_reserved_7, tvb, offset, 1, ENC_NA);
1643                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_notification_status, tvb, offset, 1, ENC_NA);
1644                 break;
1645             case 0x44: /* Instance ID */
1646                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_instance_id, tvb, offset, 1, ENC_NA);
1647                 break;
1648             case 0x46: /* Listing Size */
1649                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_listing_size, tvb, offset, 2, ENC_BIG_ENDIAN);
1650                 break;
1651             default:
1652                 proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1653         }
1654
1655         parameters_length -= 2 + parameter_length;
1656         offset += parameter_length;
1657     }
1658
1659     return offset;
1660 }
1661
1662 static gint
1663 dissect_btobex_application_parameter_ctn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1664 {
1665     proto_item  *item;
1666     proto_item  *parameter_item;
1667     proto_tree  *parameter_tree;
1668     guint8       parameter_id;
1669     gint         offset = 0;
1670     gint         parameters_length;
1671     gint         parameter_length;
1672     static gint  required_length_map[] = {0, 1, 1, 1, -1, -1, 4, 1, 1, 4, -1, -1, 1, 1, -1};
1673     static gint  required_length_map_gpp[] = {2, 2, 1, 1, -1, 2};
1674
1675     parameters_length = tvb_reported_length(tvb);
1676
1677     while (parameters_length > 0) {
1678         parameter_id = tvb_get_guint8(tvb, offset);
1679         parameter_length = tvb_get_guint8(tvb, offset + 1);
1680
1681         parameter_item = proto_tree_add_none_format(tree, hf_application_parameter, tvb, offset, parameter_length + 2,
1682                 "Parameter: %s", val_to_str_const(parameter_id,
1683                 ctn_application_parameters_vals, "Unknown"));
1684         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_application_parameters);
1685
1686         proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1687         offset += 1;
1688
1689         item = proto_tree_add_item(parameter_tree, hf_application_parameter_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1690         offset += 1;
1691
1692         if (parameter_id < 0x41 && parameter_id < (sizeof(required_length_map)/sizeof(gint)) &&
1693                 required_length_map[parameter_id] != -1 &&
1694                 required_length_map[parameter_id] != parameter_length) {
1695             proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1696             expert_add_info_format(pinfo, item, &ei_application_parameter_length_bad,
1697                     "According to the specification this parameter length should be %i, but there is %i",
1698                     required_length_map[parameter_id], parameter_length);
1699         } else if (parameter_id >= 0x41 && (guint8)(parameter_id - 0x41) < (sizeof(required_length_map_gpp)/sizeof(gint)) &&
1700                 required_length_map[parameter_id - 0x41] != -1 &&
1701                 required_length_map[parameter_id - 0x41] != parameter_length) {
1702             proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1703             expert_add_info_format(pinfo, item, &ei_application_parameter_length_bad,
1704                     "According to the specification this parameter length should be %i, but there is %i",
1705                     required_length_map_gpp[parameter_id - 0x41], parameter_length);
1706         } else switch (parameter_id) {
1707             case 0x41: /* Max List Count */
1708                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_max_list_count, tvb, offset, 2, ENC_BIG_ENDIAN);
1709                 break;
1710             case 0x42: /* List Start Offset */
1711                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_list_start_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
1712                 break;
1713             case 0x43: /* Notification Status */
1714                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_reserved_7, tvb, offset, 1, ENC_NA);
1715                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_notification_status, tvb, offset, 1, ENC_NA);
1716                 break;
1717             case 0x44: /* Instance ID */
1718                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_instance_id, tvb, offset, 1, ENC_NA);
1719                 break;
1720             case 0x46: /* Listing Size */
1721                 proto_tree_add_item(parameter_tree, hf_gpp_application_parameter_data_listing_size, tvb, offset, 2, ENC_BIG_ENDIAN);
1722                 break;
1723             case 0x01: /* Acoustic Alarm Status */
1724                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_acoustic_alarm_status, tvb, offset, 1, ENC_NA);
1725                 break;
1726             case 0x02: /* Attachment */
1727                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_attachment, tvb, offset, 1, ENC_NA);
1728                 break;
1729             case 0x03: /* Send */
1730                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_send, tvb, offset, 1, ENC_NA);
1731                 break;
1732             case 0x04: /* Filter Period Begin */
1733                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_filter_period_begin, tvb, offset, parameter_length, ENC_NA | ENC_ASCII);
1734                 break;
1735             case 0x05: /* Filter Period End */
1736                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_filter_period_end, tvb, offset, parameter_length, ENC_NA | ENC_ASCII);
1737                 break;
1738             case 0x06: /* Parameter Mask */
1739                 proto_tree_add_bitmask(parameter_tree, tvb, offset, hf_ctn_application_parameter_data_parameter_mask, ett_btobex_filter,  hfx_ctn_application_parameter_data_parameter_mask, ENC_BIG_ENDIAN);
1740                 break;
1741             case 0x07: /* Status Indicator */
1742                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_status_indicator, tvb, offset, 1, ENC_NA);
1743                 break;
1744             case 0x08: /* Status Value */
1745                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_status_value, tvb, offset, 1, ENC_NA);
1746                 break;
1747             case 0x09: /* Postpone Val */
1748                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_postpone_val, tvb, offset, 4, ENC_BIG_ENDIAN);
1749                 break;
1750             case 0x0A: /* Email URI */
1751                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_email_uri, tvb, offset, parameter_length, ENC_NA | ENC_ASCII);
1752                 break;
1753             case 0x0B: /* CSE Time */
1754                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_cse_time, tvb, offset, parameter_length, ENC_NA | ENC_ASCII);
1755                 break;
1756             case 0x0C: /* Recurrent */
1757                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_recurrent, tvb, offset, 1, ENC_NA);
1758                 break;
1759             case 0x0D: /* Attach ID */
1760                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_attach_id, tvb, offset, 1, ENC_NA);
1761                 break;
1762             case 0x0E: /* Last Update */
1763                 proto_tree_add_item(parameter_tree, hf_ctn_application_parameter_data_last_update, tvb, offset, parameter_length, ENC_NA | ENC_ASCII);
1764                 break;
1765             default:
1766                 proto_tree_add_item(parameter_tree, hf_application_parameter_data, tvb, offset, parameter_length, ENC_NA);
1767         }
1768
1769         parameters_length -= 2 + parameter_length;
1770         offset += parameter_length;
1771     }
1772
1773     return offset;
1774 }
1775
1776 static int
1777 dissect_headers(proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinfo,
1778         gint profile, gboolean is_obex_over_l2cap, obex_last_opcode_data_t *obex_last_opcode_data, void *data)
1779 {
1780     proto_tree *hdrs_tree   = NULL;
1781     proto_tree *hdr_tree    = NULL;
1782     proto_item *hdr         = NULL;
1783     proto_item *handle_item;
1784     tvbuff_t   *next_tvb;
1785     gint        new_offset;
1786     gint        item_length = 0;
1787     gint        value_length = 0;
1788     guint8      hdr_id, i;
1789     guint32     value;
1790     guint8      tag;
1791     gchar      *str = NULL;
1792     guint32     interface_id;
1793     guint32     adapter_id;
1794     guint32     chandle;
1795     guint32     channel;
1796
1797     if (is_obex_over_l2cap) {
1798         btl2cap_data_t      *l2cap_data;
1799
1800         l2cap_data   = (btl2cap_data_t *) data;
1801         interface_id = l2cap_data->interface_id;
1802         adapter_id   = l2cap_data->adapter_id;
1803         chandle      = l2cap_data->chandle;
1804         channel      = l2cap_data->cid;
1805     } else {
1806         btrfcomm_data_t      *rfcomm_data;
1807
1808         rfcomm_data  = (btrfcomm_data_t *) data;
1809         interface_id = rfcomm_data->interface_id;
1810         adapter_id   = rfcomm_data->adapter_id;
1811         chandle      = rfcomm_data->chandle;
1812         channel      = rfcomm_data->dlci >> 1;
1813     }
1814
1815     if (tvb_reported_length_remaining(tvb, offset) > 0) {
1816         proto_item *hdrs;
1817         hdrs      = proto_tree_add_item(tree, hf_headers, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA);
1818         hdrs_tree = proto_item_add_subtree(hdrs, ett_btobex_hdrs);
1819     }
1820     else {
1821         return offset;
1822     }
1823
1824     while (tvb_reported_length_remaining(tvb, offset) > 0) {
1825         hdr_id = tvb_get_guint8(tvb, offset);
1826
1827         switch(0xC0 & hdr_id)
1828         {
1829             case 0x00: /* null terminated unicode */
1830                 item_length = tvb_get_ntohs(tvb, offset + 1);
1831                 value_length = item_length - 3;
1832                 break;
1833             case 0x40:  /* byte sequence */
1834                 item_length = tvb_get_ntohs(tvb, offset + 1);
1835                 value_length = item_length - 3;
1836                 break;
1837             case 0x80:  /* 1 byte */
1838                 item_length = 1 + 1;
1839                 value_length = 1;
1840                 break;
1841             case 0xc0:  /* 4 bytes */
1842                 item_length = 1 + 4;
1843                 value_length = 4;
1844                 break;
1845         }
1846
1847         hdr = proto_tree_add_none_format(hdrs_tree, hf_header, tvb, offset, item_length, "%s",
1848                                   val_to_str_ext_const(hdr_id, &header_id_vals_ext, "Unknown"));
1849         hdr_tree = proto_item_add_subtree(hdr, ett_btobex_hdr);
1850
1851         proto_tree_add_bitmask_with_flags(hdr_tree, tvb, offset, hf_hdr_id, ett_btobex_hdr_id,  hfx_hdr_id, ENC_NA, BMT_NO_APPEND);
1852
1853         offset++;
1854
1855         switch(0xC0 & hdr_id)
1856         {
1857             case 0x00: /* null terminated unicode */
1858                 proto_tree_add_item(hdr_tree, hf_hdr_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1859                 offset += 2;
1860
1861                 switch (hdr_id) {
1862                 case 0x01: /* Name */
1863                     proto_tree_add_item(hdr_tree, hf_name, tvb, offset, value_length, ENC_UCS_2 | ENC_BIG_ENDIAN);
1864                     if (!pinfo->fd->flags.visited && obex_last_opcode_data) {
1865                         if (obex_last_opcode_data->code == BTOBEX_CODE_VALS_SET_PATH)
1866                             obex_last_opcode_data->data.set_data.name = tvb_get_string_enc(wmem_file_scope(), tvb, offset, value_length, ENC_UCS_2 | ENC_BIG_ENDIAN);
1867                         else if (obex_last_opcode_data->code == BTOBEX_CODE_VALS_GET || obex_last_opcode_data->code == BTOBEX_CODE_VALS_PUT)
1868                             obex_last_opcode_data->data.get_put.name = tvb_get_string_enc(wmem_file_scope(), tvb, offset, value_length, ENC_UCS_2 | ENC_BIG_ENDIAN);
1869                     }
1870                     break;
1871                 default:
1872                     proto_tree_add_item(hdr_tree, hf_hdr_val_unicode, tvb, offset, value_length, ENC_UCS_2 | ENC_BIG_ENDIAN);
1873                 }
1874                 str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_length, ENC_UCS_2 | ENC_BIG_ENDIAN);
1875                 proto_item_append_text(hdr_tree, ": \"%s\"", str);
1876
1877                 col_append_fstr(pinfo->cinfo, COL_INFO, " \"%s\"", str);
1878                 offset += value_length;
1879
1880                 break;
1881             case 0x40:  /* byte sequence */
1882                 proto_tree_add_item(hdr_tree, hf_hdr_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1883                 offset += 2;
1884
1885                 switch (hdr_id) {
1886                 case 0x4c: /* Application Parameters */
1887                     next_tvb = tvb_new_subset_length(tvb, offset, value_length);
1888                     if (!(new_offset = dissector_try_uint_new(btobex_profile, profile, next_tvb, pinfo, hdr_tree, TRUE, data))) {
1889                         new_offset = call_dissector(raw_application_parameters_handle, next_tvb, pinfo, hdr_tree);
1890                     }
1891                     offset += new_offset;
1892
1893                     break;
1894                 case 0x4d: /* Authentication Challenge */
1895                     while (value_length) {
1896                         guint8       parameter_id;
1897                         guint8       sub_parameter_length;
1898                         proto_item  *parameter_item;
1899                         proto_tree  *parameter_tree;
1900
1901                         parameter_id = tvb_get_guint8(tvb, offset);
1902                         sub_parameter_length = tvb_get_guint8(tvb, offset + 1);
1903
1904                         parameter_item = proto_tree_add_none_format(hdr_tree, hf_authentication_parameter, tvb, offset,
1905                                 2 + sub_parameter_length, "Tag: %s", val_to_str_const(parameter_id,
1906                                 authentication_challenge_tag_vals, "Unknown"));
1907                         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_authentication_parameters);
1908
1909                         proto_tree_add_item(parameter_tree, hf_authentication_challenge_tag, tvb, offset, 1, ENC_BIG_ENDIAN);
1910                         tag = tvb_get_guint8(tvb, offset);
1911                         offset += 1;
1912
1913                         proto_tree_add_item(parameter_tree, hf_authentication_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1914                         offset += 1;
1915
1916                         switch (tag) {
1917                         case 0x00:
1918                             proto_tree_add_item(parameter_tree, hf_authentication_key, tvb, offset, 16, ENC_NA);
1919                             offset += 16;
1920                             break;
1921                         case 0x01:
1922                             proto_tree_add_item(parameter_tree, hf_authentication_option_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
1923                             proto_tree_add_item(parameter_tree, hf_authentication_option_read_only, tvb, offset, 1, ENC_BIG_ENDIAN);
1924                             proto_tree_add_item(parameter_tree, hf_authentication_option_user_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1925                             offset += 1;
1926                             break;
1927                         case 0x02:
1928                             proto_tree_add_item(parameter_tree, hf_authentication_info_charset, tvb, offset, 1, ENC_BIG_ENDIAN);
1929                             offset += 1;
1930                             proto_tree_add_item(parameter_tree, hf_authentication_info, tvb, offset, sub_parameter_length - 1, ENC_ASCII|ENC_NA);
1931                             offset += sub_parameter_length - 1;
1932                             break;
1933                         default:
1934                             proto_tree_add_item(parameter_tree, hf_authentication_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
1935                             offset += sub_parameter_length;
1936                         }
1937
1938                         value_length -= 2 + sub_parameter_length;
1939                     }
1940                     break;
1941                 case 0x4e: /* Authentication Response */
1942                     while (value_length) {
1943                         guint8       parameter_id;
1944                         guint8       sub_parameter_length;
1945                         proto_item  *parameter_item;
1946                         proto_tree  *parameter_tree;
1947
1948                         parameter_id = tvb_get_guint8(tvb, offset);
1949                         sub_parameter_length = tvb_get_guint8(tvb, offset + 1);
1950
1951                         parameter_item = proto_tree_add_none_format(hdr_tree, hf_authentication_parameter, tvb, offset,
1952                                 2 + sub_parameter_length, "Tag: %s", val_to_str_const(parameter_id,
1953                                 authentication_response_tag_vals, "Unknown"));
1954                         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_authentication_parameters);
1955
1956                         proto_tree_add_item(parameter_tree, hf_authentication_response_tag, tvb, offset, 1, ENC_BIG_ENDIAN);
1957                         tag = tvb_get_guint8(tvb, offset);
1958                         offset += 1;
1959
1960                         proto_tree_add_item(parameter_tree, hf_authentication_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1961                         sub_parameter_length = tvb_get_guint8(tvb, offset);
1962                         offset += 1;
1963
1964                         switch (tag) {
1965                         case 0x00:
1966                             proto_tree_add_item(parameter_tree, hf_authentication_result_key, tvb, offset, 16, ENC_NA);
1967                             offset += 16;
1968                             break;
1969                         case 0x01:
1970                             proto_tree_add_item(parameter_tree, hf_authentication_user_id, tvb, offset, sub_parameter_length, ENC_NA);
1971                             offset += sub_parameter_length;
1972                             break;
1973                         case 0x02:
1974                             proto_tree_add_item(parameter_tree, hf_authentication_key, tvb, offset, 16, ENC_NA);
1975                             offset += 16;
1976                             break;
1977                         default:
1978                             proto_tree_add_item(parameter_tree, hf_authentication_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
1979                             offset += sub_parameter_length;
1980                             break;
1981                         }
1982
1983
1984                         value_length -= 2 + sub_parameter_length;
1985                     }
1986                     break;
1987                 case 0x42: /* Type */
1988                     proto_tree_add_item(hdr_tree, hf_type, tvb, offset, value_length, ENC_ASCII | ENC_NA);
1989                     proto_item_append_text(hdr_tree, ": \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_length, ENC_ASCII));
1990                     if (!pinfo->fd->flags.visited && obex_last_opcode_data && (obex_last_opcode_data->code == BTOBEX_CODE_VALS_GET || obex_last_opcode_data->code == BTOBEX_CODE_VALS_PUT)) {
1991                         obex_last_opcode_data->data.get_put.type = tvb_get_string_enc(wmem_file_scope(), tvb, offset, value_length, ENC_ASCII | ENC_NA);
1992                     }
1993                     if (p_get_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_MEDIA_TYPE) == NULL) {
1994                         guint8 *value_data;
1995
1996                         value_data = tvb_get_string_enc(wmem_file_scope(), tvb, offset, value_length, ENC_ASCII | ENC_NA);
1997
1998                         p_add_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_MEDIA_TYPE, value_data);
1999                     }
2000                     offset += value_length;
2001
2002                     break;
2003                 case 0x44: /* Time (ISO8601) */
2004                     proto_tree_add_item(hdr_tree, hf_time_iso8601, tvb, offset, value_length, ENC_ASCII | ENC_NA);
2005                     proto_item_append_text(hdr_tree, ": \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_length, ENC_ASCII));
2006
2007                     offset += value_length;
2008
2009                     break;
2010                 case 0x48: /* Body */
2011                 case 0x49: /* End Of Body */
2012                     proto_tree_add_item(hdr_tree, hf_hdr_val_byte_seq, tvb, offset, value_length, ENC_NA);
2013                     next_tvb = tvb_new_subset_length(tvb, offset, value_length);
2014
2015                     if (value_length > 0 && obex_last_opcode_data &&
2016                             (obex_last_opcode_data->code == BTOBEX_CODE_VALS_GET || obex_last_opcode_data->code == BTOBEX_CODE_VALS_PUT) &&
2017                             p_get_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_MEDIA_TYPE) == NULL) {
2018                         guint8 *value_data;
2019
2020                         value_data = obex_last_opcode_data->data.get_put.type;
2021
2022                         p_add_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_MEDIA_TYPE, value_data);
2023                     }
2024                     if (value_length > 0 && obex_last_opcode_data &&
2025                             (obex_last_opcode_data->code == BTOBEX_CODE_VALS_GET || obex_last_opcode_data->code == BTOBEX_CODE_VALS_PUT) &&
2026                             obex_last_opcode_data->data.get_put.type &&
2027                             dissector_try_string(media_type_dissector_table, obex_last_opcode_data->data.get_put.type, next_tvb, pinfo, tree, data) > 0) {
2028                         offset += value_length;
2029                     } else {
2030                         if (!tvb_strneql(tvb, offset, "<?xml", 5))
2031                         {
2032                             call_dissector(xml_handle, next_tvb, pinfo, tree);
2033                         } else if (is_ascii_str(tvb_get_ptr(tvb, offset, value_length), value_length)) {
2034                             proto_item_append_text(hdr_tree, ": \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_length, ENC_ASCII));
2035                             col_append_fstr(pinfo->cinfo, COL_INFO, " \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_length, ENC_ASCII));
2036                         }
2037                         offset += value_length;
2038                     }
2039
2040                     break;
2041                 case 0x46: /* Target */
2042                 case 0x4a: /* Who */
2043                     handle_item = proto_tree_add_item(hdr_tree, hf_hdr_val_byte_seq, tvb, offset, value_length, ENC_NA);
2044
2045                     if (value_length == 16) for (i = 0; target_vals[i].strptr != NULL; i++) {
2046                         if (tvb_memeql(tvb, offset, target_vals[i].value, target_vals[i].length) == 0) {
2047                             proto_item_append_text(handle_item, ": %s", target_vals[i].strptr);
2048                             proto_item_append_text(hdr_tree, ": %s", target_vals[i].strptr);
2049
2050                             col_append_fstr(pinfo->cinfo, COL_INFO, " - %s", target_vals[i].strptr);
2051                             if (!pinfo->fd->flags.visited) {
2052                                 obex_profile_data_t  *obex_profile_data;
2053
2054                                 wmem_tree_key_t       key[6];
2055                                 guint32               k_interface_id;
2056                                 guint32               k_adapter_id;
2057                                 guint32               k_frame_number;
2058                                 guint32               k_chandle;
2059                                 guint32               k_channel;
2060
2061                                 k_interface_id = interface_id;
2062                                 k_adapter_id   = adapter_id;
2063                                 k_chandle      = chandle;
2064                                 k_channel      = channel;
2065                                 k_frame_number = pinfo->fd->num;
2066
2067                                 key[0].length = 1;
2068                                 key[0].key = &k_interface_id;
2069                                 key[1].length = 1;
2070                                 key[1].key = &k_adapter_id;
2071                                 key[2].length = 1;
2072                                 key[2].key = &k_chandle;
2073                                 key[3].length = 1;
2074                                 key[3].key = &k_channel;
2075                                 key[4].length = 1;
2076                                 key[4].key = &k_frame_number;
2077                                 key[5].length = 0;
2078                                 key[5].key = NULL;
2079
2080                                 obex_profile_data = wmem_new(wmem_file_scope(), obex_profile_data_t);
2081                                 obex_profile_data->interface_id = interface_id;
2082                                 obex_profile_data->adapter_id = adapter_id;
2083                                 obex_profile_data->chandle = chandle;
2084                                 obex_profile_data->channel = channel;
2085                                 obex_profile_data->profile = target_to_profile[i];
2086
2087                                 wmem_tree_insert32_array(obex_profile, key, obex_profile_data);
2088                             }
2089                         }
2090                     }
2091                     offset += value_length;
2092
2093                     break;
2094                 case 0x47: /* HTTP */ {
2095                     next_tvb = tvb_new_subset_remaining(tvb, offset);
2096
2097                     call_dissector(http_handle, next_tvb, pinfo, hdr_tree);
2098
2099                     }
2100                     break;
2101                 case 0x50: /* WAN UUID */
2102                     if (value_length == 2) {
2103                         proto_tree_add_item(hdr_tree, hf_wan_uuid, tvb, offset, 2, ENC_BIG_ENDIAN);
2104                         offset += 2;
2105                     } else {
2106                         proto_tree_add_item(hdr_tree, hf_hdr_val_byte_seq, tvb, offset, value_length, ENC_NA);
2107                         offset += value_length;
2108                     }
2109
2110                     break;
2111                 case 0x51: /* Object Class */
2112                     proto_tree_add_item(hdr_tree, hf_object_class, tvb, offset, value_length, ENC_ASCII | ENC_NA);
2113                     proto_item_append_text(hdr_tree, ": \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_length, ENC_ASCII));
2114
2115                     offset += value_length;
2116
2117                     break;
2118                 case 0x52: /* Session Parameter */
2119                     while (value_length) {
2120                         guint8       parameter_id;
2121                         guint8       sub_parameter_length;
2122                         proto_item  *parameter_item;
2123                         proto_tree  *parameter_tree;
2124
2125                         parameter_id = tvb_get_guint8(tvb, offset);
2126                         sub_parameter_length = tvb_get_guint8(tvb, offset + 1);
2127
2128                         parameter_item = proto_tree_add_none_format(hdr_tree, hf_session_parameter, tvb, offset,
2129                                 2 + sub_parameter_length, "Tag: %s", val_to_str_const(parameter_id,
2130                                 session_tag_vals, "Unknown"));
2131                         parameter_tree = proto_item_add_subtree(parameter_item, ett_btobex_session_parameters);
2132
2133                         proto_tree_add_item(parameter_tree, hf_session_parameter_tag, tvb, offset, 1, ENC_BIG_ENDIAN);
2134                         tag = tvb_get_guint8(tvb, offset);
2135                         offset += 1;
2136
2137                         proto_tree_add_item(parameter_tree, hf_session_parameter_length, tvb, offset, 1, ENC_BIG_ENDIAN);
2138                         sub_parameter_length = tvb_get_guint8(tvb, offset);
2139                         offset += 1;
2140
2141                         switch (tag) {
2142                         case 0x00: /* Device Address */
2143                             if (sub_parameter_length == 6) {
2144                                 offset = dissect_bd_addr(hf_sender_bd_addr, pinfo, parameter_tree, tvb, offset, FALSE, interface_id, adapter_id, NULL);
2145                             } else {
2146                                 proto_tree_add_item(parameter_tree, hf_session_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
2147
2148                                 offset += sub_parameter_length;
2149                             }
2150
2151                             break;
2152                         case 0x01: /* Nonce */
2153                             if (sub_parameter_length >= 4 && sub_parameter_length <= 16) {
2154                                 proto_tree_add_item(parameter_tree, hf_session_parameter_nonce, tvb, offset, sub_parameter_length, ENC_NA);
2155
2156                                 offset += sub_parameter_length;
2157                             } else {
2158                                 proto_tree_add_item(parameter_tree, hf_session_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
2159
2160                                 offset += sub_parameter_length;
2161                             }
2162
2163                             break;
2164                         case 0x02: /* Session ID */
2165                             if (sub_parameter_length == 16) {
2166                                 proto_tree_add_item(parameter_tree, hf_session_parameter_session_id, tvb, offset, 16, ENC_NA);
2167
2168                                 offset += 16;
2169                             } else {
2170                                 proto_tree_add_item(parameter_tree, hf_session_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
2171
2172                                 offset += sub_parameter_length;
2173                             }
2174
2175                             break;
2176                         case 0x03: /* Next Sequence Number */
2177                             if (sub_parameter_length == 1) {
2178                                 proto_tree_add_item(parameter_tree, hf_session_parameter_next_sequence_number, tvb, offset, 1, ENC_NA);
2179
2180                                 offset += 1;
2181                             } else {
2182                                 proto_tree_add_item(parameter_tree, hf_session_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
2183
2184                                 offset += sub_parameter_length;
2185                             }
2186
2187                             break;
2188                         case 0x04: /* Timeout */
2189                             if (sub_parameter_length == 4) {
2190                                 proto_tree_add_item(parameter_tree, hf_session_parameter_timeout, tvb, offset, 4, ENC_BIG_ENDIAN);
2191
2192                                 offset += 4;
2193                             } else {
2194                                 proto_tree_add_item(parameter_tree, hf_session_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
2195
2196                                 offset += sub_parameter_length;
2197                             }
2198
2199                             break;
2200                         case 0x05: /* Session Opcode */
2201                             if (sub_parameter_length == 1) {
2202                                 proto_tree_add_item(parameter_tree, hf_session_parameter_opcode, tvb, offset, 1, ENC_NA);
2203
2204                                 offset += 1;
2205                             } else {
2206                                 proto_tree_add_item(parameter_tree, hf_session_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
2207
2208                                 offset += sub_parameter_length;
2209                             }
2210
2211                             break;
2212                         default:
2213                             proto_tree_add_item(parameter_tree, hf_session_parameter_data, tvb, offset, sub_parameter_length, ENC_NA);
2214                             offset += sub_parameter_length;
2215                             break;
2216                         }
2217
2218
2219                         value_length -= 2 + sub_parameter_length;
2220                     }
2221                     break;
2222                 default:
2223                     proto_tree_add_item(hdr_tree, hf_hdr_val_byte_seq, tvb, offset, value_length, ENC_NA);
2224                     offset += value_length;
2225                 }
2226
2227                 break;
2228             case 0x80:  /* 1 byte */
2229                 value = tvb_get_guint8(tvb, offset);
2230
2231                 switch (hdr_id) {
2232                 case 0x94: /* Action */
2233                     proto_tree_add_item(hdr_tree, hf_hdr_val_action, tvb, offset, 1, ENC_NA);
2234                     proto_item_append_text(hdr_tree, ": %s", val_to_str_const(value, action_vals, "Unknown"));
2235
2236                     break;
2237                 case 0x97: /* Single Response Mode */
2238                     proto_tree_add_item(hdr_tree, hf_hdr_val_single_response_mode, tvb, offset, 1, ENC_NA);
2239                     proto_item_append_text(hdr_tree, ": %s", val_to_str_const(value, single_response_mode_vals, "Unknown"));
2240
2241                     break;
2242                 case 0x98: /* Single Response Mode Parameter */
2243                     proto_tree_add_item(hdr_tree, hf_hdr_val_single_response_mode_parameter, tvb, offset, 1, ENC_NA);
2244                     proto_item_append_text(hdr_tree, ": %s", val_to_str_const(value, single_response_mode_parameter_vals, "Unknown"));
2245
2246                     break;
2247                 case 0x93: /* Session Sequence Number */
2248                 default:
2249                     proto_tree_add_item(hdr_tree, hf_hdr_val_byte, tvb, offset, 1, ENC_NA);
2250                     proto_item_append_text(hdr_tree, ": %i", value);
2251                 }
2252
2253                 offset += 1;
2254
2255                 break;
2256             case 0xC0:  /* 4 bytes */
2257                 switch (hdr_id) {
2258                 case 0xC0: /* Count */
2259                     proto_item_append_text(hdr_tree, ": %i", tvb_get_ntohl(tvb, offset));
2260                     proto_tree_add_item(hdr_tree, hf_count, tvb, offset, 4, ENC_BIG_ENDIAN);
2261
2262                     break;
2263                 case 0xC3: /* Length */
2264                     proto_item_append_text(hdr_tree, ": %i", tvb_get_ntohl(tvb, offset));
2265                     proto_tree_add_item(hdr_tree, hf_data_length, tvb, offset, 4, ENC_BIG_ENDIAN);
2266
2267                     break;
2268                 case 0xCB: /* Connection Id */
2269                     proto_item_append_text(hdr_tree, ": %i", tvb_get_ntohl(tvb, offset));
2270                     proto_tree_add_item(hdr_tree, hf_connection_id, tvb, offset, 4, ENC_BIG_ENDIAN);
2271
2272                     break;
2273                 case 0xC4: /* Time */
2274                 case 0xCF: /* Creator */
2275                 case 0xD6: /* Permissions */
2276                 default:
2277                     proto_item_append_text(hdr_tree, ": %i", tvb_get_ntohl(tvb, offset));
2278                     proto_tree_add_item(hdr_tree, hf_hdr_val_long, tvb, offset, 4, ENC_BIG_ENDIAN);
2279                 }
2280
2281                 offset += 4;
2282
2283                 break;
2284             default:
2285                 break;
2286         }
2287     }
2288
2289     return offset;
2290 }
2291
2292 static gint
2293 dissect_btobex(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
2294 {
2295     proto_item    *main_item;
2296     proto_tree    *main_tree;
2297     proto_item    *sub_item;
2298     fragment_head *frag_msg       = NULL;
2299     gboolean       save_fragmented, complete;
2300     tvbuff_t*      new_tvb        = NULL;
2301     tvbuff_t*      next_tvb       = NULL;
2302     gint           offset         = 0;
2303     gint           profile        = PROFILE_UNKNOWN;
2304     const gchar   *path           = path_unknown;
2305     gboolean       is_obex_over_l2cap = FALSE;
2306     obex_profile_data_t  *obex_profile_data;
2307     guint32               interface_id;
2308     guint32               adapter_id;
2309     guint32               chandle;
2310     guint32               channel;
2311     wmem_tree_key_t       key[6];
2312     guint32               k_interface_id;
2313     guint32               k_adapter_id;
2314     guint32               k_frame_number;
2315     guint32               k_chandle;
2316     guint32               k_channel;
2317     obex_last_opcode_data_t  *obex_last_opcode_data;
2318     obex_path_data_t         *obex_path_data;
2319     guint32                   length;
2320     guint8                   *profile_data;
2321     dissector_handle_t        current_handle;
2322     dissector_handle_t        default_handle;
2323
2324     /* Reject the packet if data is NULL */
2325     if (data == NULL)
2326         return 0;
2327
2328     col_set_str(pinfo->cinfo, COL_PROTOCOL, "OBEX");
2329
2330     main_item = proto_tree_add_item(tree, proto_btobex, tvb, 0, tvb_captured_length(tvb), ENC_NA);
2331     main_tree = proto_item_add_subtree(main_item, ett_btobex);
2332
2333     save_fragmented = pinfo->fragmented;
2334
2335     is_obex_over_l2cap = (proto_btl2cap == (gint) GPOINTER_TO_UINT(wmem_list_frame_data(
2336                 wmem_list_frame_prev(wmem_list_tail(pinfo->layers)))));
2337
2338     if (is_obex_over_l2cap) {
2339         btl2cap_data_t      *l2cap_data;
2340
2341         l2cap_data   = (btl2cap_data_t *) data;
2342
2343         interface_id = l2cap_data->interface_id;
2344         adapter_id   = l2cap_data->adapter_id;
2345         chandle      = l2cap_data->chandle;
2346         channel      = l2cap_data->cid;
2347     } else {
2348         btrfcomm_data_t      *rfcomm_data;
2349
2350         rfcomm_data  = (btrfcomm_data_t *) data;
2351
2352         interface_id = rfcomm_data->interface_id;
2353         adapter_id   = rfcomm_data->adapter_id;
2354         chandle      = rfcomm_data->chandle;
2355         channel      = rfcomm_data->dlci >> 1;
2356     }
2357
2358     k_interface_id = interface_id;
2359     k_adapter_id   = adapter_id;
2360     k_chandle      = chandle;
2361     k_channel      = channel;
2362     k_frame_number = pinfo->fd->num;
2363
2364     key[0].length = 1;
2365     key[0].key = &k_interface_id;
2366     key[1].length = 1;
2367     key[1].key = &k_adapter_id;
2368     key[2].length = 1;
2369     key[2].key = &k_chandle;
2370     key[3].length = 1;
2371     key[3].key = &k_channel;
2372     key[4].length = 1;
2373     key[4].key = &k_frame_number;
2374     key[5].length = 0;
2375     key[5].key = NULL;
2376
2377     profile_data = (guint8 *) p_get_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_BTOBEX_PROFILE);
2378     if (profile_data == NULL) {
2379         obex_profile_data = (obex_profile_data_t *)wmem_tree_lookup32_array_le(obex_profile, key);
2380         if (obex_profile_data && obex_profile_data->interface_id == interface_id &&
2381                 obex_profile_data->adapter_id == adapter_id &&
2382                 obex_profile_data->chandle == chandle &&
2383                 obex_profile_data->channel == channel) {
2384             profile = obex_profile_data->profile;
2385         }
2386
2387         profile_data = wmem_new(wmem_file_scope(), guint8);
2388         *profile_data = profile;
2389
2390         p_add_proto_data(pinfo->pool, pinfo, proto_btobex, PROTO_DATA_BTOBEX_PROFILE, profile_data);
2391     }
2392
2393     obex_path_data = (obex_path_data_t *)wmem_tree_lookup32_array_le(obex_path, key);
2394     if (obex_path_data && obex_path_data->interface_id == interface_id &&
2395             obex_path_data->adapter_id == adapter_id &&
2396             obex_path_data->chandle == chandle &&
2397             obex_path_data->channel == channel) {
2398         path = obex_path_data->path;
2399       }
2400
2401     sub_item = proto_tree_add_uint(main_tree, hf_profile, tvb, 0, 0, profile);
2402     PROTO_ITEM_SET_GENERATED(sub_item);
2403
2404     if (path) {
2405         sub_item = proto_tree_add_string(main_tree, hf_current_path, tvb, 0, 0, path);
2406         PROTO_ITEM_SET_GENERATED(sub_item);
2407     }
2408
2409     current_handle = dissector_get_uint_handle(btobex_profile, profile);
2410     default_handle = dissector_get_default_uint_handle("btobex.profile", profile);
2411     if (current_handle != default_handle) {
2412         expert_add_info_format(pinfo, main_item, &ei_decoded_as_profile, "Decoded As %s", dissector_handle_get_long_name(current_handle));
2413     }
2414
2415     complete = FALSE;
2416
2417     if (tvb_captured_length(tvb) == tvb_reported_length(tvb)) {
2418         frag_msg = fragment_get_reassembled_id(&btobex_reassembly_table, pinfo, pinfo->p2p_dir);
2419         if (frag_msg && pinfo->fd->num != frag_msg->reassembled_in) {
2420             /* reassembled but not last */
2421
2422             new_tvb = process_reassembled_data(tvb, 0, pinfo,
2423                     "Reassembled Obex packet", frag_msg, &btobex_frag_items, NULL, main_tree);
2424         } else if (frag_msg && pinfo->fd->num == frag_msg->reassembled_in) {
2425             /* reassembled and last, so dissect reassembled packet here */
2426
2427             new_tvb = process_reassembled_data(tvb, 0, pinfo,
2428                     "Reassembled Obex packet", frag_msg, &btobex_frag_items, NULL, main_tree);
2429         } else {
2430             frag_msg = fragment_get(&btobex_reassembly_table, pinfo, pinfo->p2p_dir, NULL);
2431
2432             if (frag_msg) {
2433                 /* not the first fragment */
2434
2435                 /* packet stream is guaranted to be sequence of fragments, one by one,
2436                    so find last fragment for its offset and length */
2437                 while (frag_msg->next) {
2438                     frag_msg = frag_msg->next;
2439                 }
2440
2441                 frag_msg = fragment_add_check(&btobex_reassembly_table,
2442                         tvb, 0, pinfo, pinfo->p2p_dir, NULL,
2443                         frag_msg->offset + frag_msg->len, tvb_reported_length(tvb),
2444                                 ((frag_msg->offset + frag_msg->len + tvb_reported_length(tvb)) <
2445                                     fragment_get_tot_len(&btobex_reassembly_table, pinfo, pinfo->p2p_dir, NULL)) ? TRUE : FALSE);
2446
2447                 new_tvb = process_reassembled_data(tvb, 0, pinfo,
2448                         "Reassembled Obex packet", frag_msg, &btobex_frag_items, NULL, main_tree);
2449
2450                 pinfo->fragmented = TRUE;
2451             } else {
2452                 if (tvb_reported_length(tvb) < 3) {
2453                     /* Packet length is in the second and the third bye of packet, anything shorter than 3 is bad */
2454                     col_add_fstr(pinfo->cinfo, COL_INFO, "%s OBEX packet too short",
2455                                 (pinfo->p2p_dir==P2P_DIR_SENT) ? "Sent" : "Rcvd");
2456                     call_dissector(data_handle, tvb, pinfo, main_tree);
2457                     return tvb_reported_length(tvb);
2458                 } else if (tvb_reported_length(tvb) >= 3 && tvb_reported_length(tvb) < tvb_get_ntohs(tvb, offset+1)) {
2459                     /* first fragment in a sequence */
2460                     frag_msg = fragment_add_check(&btobex_reassembly_table,
2461                                         tvb, 0, pinfo, pinfo->p2p_dir, NULL,
2462                                         0, tvb_reported_length(tvb), TRUE);
2463
2464                     fragment_set_tot_len(&btobex_reassembly_table,
2465                                         pinfo, pinfo->p2p_dir, NULL,
2466                                         tvb_get_ntohs(tvb, offset + 1));
2467
2468                     new_tvb = process_reassembled_data(tvb, 0, pinfo,
2469                                 "Reassembled Obex packet", frag_msg, &btobex_frag_items, NULL, main_tree);
2470                     pinfo->fragmented = TRUE;
2471                 } else if (tvb_reported_length(tvb) == tvb_get_ntohs(tvb, offset+1)) {
2472                     /* non-fragmented */
2473                     complete = TRUE;
2474                     pinfo->fragmented = FALSE;
2475                 }
2476             }
2477         }
2478     }
2479
2480     if (new_tvb) { /* take it all */
2481         next_tvb = new_tvb;
2482         complete = TRUE;
2483     } else { /* make a new subset */
2484         next_tvb = tvb_new_subset_remaining(tvb, offset);
2485     }
2486
2487     if (complete) {
2488         guint8       code;
2489         guint8       final_flag;
2490
2491         /* fully dissectable packet ready */
2492
2493         /* op/response code */
2494         code = tvb_get_guint8(next_tvb, offset) & BTOBEX_CODE_VALS_MASK;
2495         final_flag = tvb_get_guint8(next_tvb, offset) & 0x80;
2496
2497         switch (pinfo->p2p_dir) {
2498             case P2P_DIR_SENT:
2499                 col_set_str(pinfo->cinfo, COL_INFO, "Sent ");
2500                 break;
2501             case P2P_DIR_RECV:
2502                 col_set_str(pinfo->cinfo, COL_INFO, "Rcvd ");
2503                 break;
2504             default:
2505                 col_set_str(pinfo->cinfo, COL_INFO, "UnknownDirection ");
2506                 break;
2507         }
2508
2509         col_append_str(pinfo->cinfo, COL_INFO,
2510                         val_to_str_ext_const(code, &code_vals_ext, "Unknown"));
2511
2512         if (code < BTOBEX_CODE_VALS_CONTINUE || code == BTOBEX_CODE_VALS_ABORT) {
2513             proto_tree_add_item(main_tree, hf_opcode, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2514             if (!pinfo->fd->flags.visited &&
2515                     (pinfo->p2p_dir == P2P_DIR_SENT ||
2516                     pinfo->p2p_dir == P2P_DIR_RECV)) {
2517
2518                 if (is_obex_over_l2cap) {
2519                     btl2cap_data_t      *l2cap_data;
2520
2521                     l2cap_data   = (btl2cap_data_t *) data;
2522                     interface_id = l2cap_data->interface_id;
2523                     adapter_id   = l2cap_data->adapter_id;
2524                     chandle      = l2cap_data->chandle;
2525                     channel      = l2cap_data->cid;
2526                 } else {
2527                     btrfcomm_data_t      *rfcomm_data;
2528
2529                     rfcomm_data  = (btrfcomm_data_t *) data;
2530                     interface_id = rfcomm_data->interface_id;
2531                     adapter_id   = rfcomm_data->adapter_id;
2532                     chandle      = rfcomm_data->chandle;
2533                     channel      = rfcomm_data->dlci >> 1;
2534                 }
2535
2536                 k_interface_id = interface_id;
2537                 k_adapter_id   = adapter_id;
2538                 k_chandle      = chandle;
2539                 k_channel      = channel;
2540                 k_frame_number = pinfo->fd->num;
2541
2542                 key[0].length = 1;
2543                 key[0].key = &k_interface_id;
2544                 key[1].length = 1;
2545                 key[1].key = &k_adapter_id;
2546                 key[2].length = 1;
2547                 key[2].key = &k_chandle;
2548                 key[3].length = 1;
2549                 key[3].key = &k_channel;
2550                 key[4].length = 1;
2551                 key[4].key = &k_frame_number;
2552                 key[5].length = 0;
2553                 key[5].key = NULL;
2554
2555                 obex_last_opcode_data = wmem_new0(wmem_file_scope(), obex_last_opcode_data_t);
2556                 obex_last_opcode_data->interface_id = interface_id;
2557                 obex_last_opcode_data->adapter_id = adapter_id;
2558                 obex_last_opcode_data->chandle = chandle;
2559                 obex_last_opcode_data->channel = channel;
2560                 obex_last_opcode_data->code = code;
2561                 obex_last_opcode_data->final_flag = final_flag;
2562                 obex_last_opcode_data->request_in_frame = k_frame_number;
2563                 obex_last_opcode_data->response_in_frame = 0;
2564
2565                 wmem_tree_insert32_array(obex_last_opcode, key, obex_last_opcode_data);
2566             }
2567         } else {
2568             proto_tree_add_item(main_tree, hf_response_code, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2569         }
2570
2571         proto_tree_add_item(main_tree, hf_final_flag, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2572         offset++;
2573
2574         /* length */
2575         proto_tree_add_item(main_tree, hf_length, next_tvb, offset, 2, ENC_BIG_ENDIAN);
2576         length = tvb_get_ntohs(tvb, offset) - 3;
2577         offset += 2;
2578
2579
2580         if (is_obex_over_l2cap) {
2581             btl2cap_data_t      *l2cap_data;
2582
2583             l2cap_data   = (btl2cap_data_t *) data;
2584             interface_id = l2cap_data->interface_id;
2585             adapter_id   = l2cap_data->adapter_id;
2586             chandle      = l2cap_data->chandle;
2587             channel      = l2cap_data->cid;
2588         } else {
2589             btrfcomm_data_t      *rfcomm_data;
2590
2591             rfcomm_data  = (btrfcomm_data_t *) data;
2592             interface_id = rfcomm_data->interface_id;
2593             adapter_id   = rfcomm_data->adapter_id;
2594             chandle      = rfcomm_data->chandle;
2595             channel      = rfcomm_data->dlci >> 1;
2596         }
2597
2598         k_interface_id = interface_id;
2599         k_adapter_id   = adapter_id;
2600         k_chandle      = chandle;
2601         k_channel      = channel;
2602         k_frame_number = pinfo->fd->num;
2603
2604         key[0].length = 1;
2605         key[0].key = &k_interface_id;
2606         key[1].length = 1;
2607         key[1].key = &k_adapter_id;
2608         key[2].length = 1;
2609         key[2].key = &k_chandle;
2610         key[3].length = 1;
2611         key[3].key = &k_channel;
2612         key[4].length = 1;
2613         key[4].key = &k_frame_number;
2614         key[5].length = 0;
2615         key[5].key = NULL;
2616
2617         obex_last_opcode_data = (obex_last_opcode_data_t *)wmem_tree_lookup32_array_le(obex_last_opcode, key);
2618         if (obex_last_opcode_data && obex_last_opcode_data->interface_id == interface_id &&
2619                 obex_last_opcode_data->adapter_id == adapter_id &&
2620                 obex_last_opcode_data->chandle == chandle &&
2621                 obex_last_opcode_data->channel == channel) {
2622             if (obex_last_opcode_data->request_in_frame > 0 && obex_last_opcode_data->request_in_frame != pinfo->fd->num) {
2623                 sub_item = proto_tree_add_uint(main_tree, hf_request_in_frame, next_tvb, 0, 0, obex_last_opcode_data->request_in_frame);
2624                 PROTO_ITEM_SET_GENERATED(sub_item);
2625             }
2626
2627             if (!pinfo->fd->flags.visited && obex_last_opcode_data->response_in_frame == 0 && obex_last_opcode_data->request_in_frame < pinfo->fd->num) {
2628                 obex_last_opcode_data->response_in_frame = pinfo->fd->num;
2629             }
2630
2631             if (obex_last_opcode_data->response_in_frame > 0 && obex_last_opcode_data->response_in_frame != pinfo->fd->num) {
2632                 sub_item = proto_tree_add_uint(main_tree, hf_response_in_frame, next_tvb, 0, 0, obex_last_opcode_data->response_in_frame);
2633                 PROTO_ITEM_SET_GENERATED(sub_item);
2634             }
2635         }
2636
2637         switch(code)
2638         {
2639         case BTOBEX_CODE_VALS_CONNECT:
2640             proto_tree_add_item(main_tree, hf_version, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2641             offset++;
2642
2643             proto_tree_add_item(main_tree, hf_flags, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2644             offset++;
2645
2646             proto_tree_add_item(main_tree, hf_max_pkt_len, next_tvb, offset, 2, ENC_BIG_ENDIAN);
2647             offset += 2;
2648             break;
2649
2650         case BTOBEX_CODE_VALS_PUT:
2651         case BTOBEX_CODE_VALS_GET:
2652             col_append_fstr(pinfo->cinfo, COL_INFO, " %s",  (final_flag == 0x80) ? "final" : "continue");
2653             break;
2654
2655         case BTOBEX_CODE_VALS_SET_PATH:
2656             proto_tree_add_item(main_tree, hf_flags, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2657             proto_tree_add_item(main_tree, hf_set_path_flags_0, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2658             proto_tree_add_item(main_tree, hf_set_path_flags_1, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2659
2660             if (!pinfo->fd->flags.visited && obex_last_opcode_data) {
2661                 obex_last_opcode_data->data.set_data.go_up = tvb_get_guint8(tvb, offset) & 0x01;
2662                 obex_last_opcode_data->data.set_data.name = NULL;
2663             }
2664
2665             offset++;
2666
2667             proto_tree_add_item(main_tree, hf_constants, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2668             offset++;
2669             break;
2670
2671         case BTOBEX_CODE_VALS_DISCONNECT:
2672         case BTOBEX_CODE_VALS_ABORT:
2673             break;
2674
2675         default:
2676             if (length == 0 && tvb_reported_length_remaining(tvb, offset) > 0) {
2677                 proto_tree_add_expert(main_tree, pinfo, &ei_unexpected_data, tvb, offset, tvb_reported_length_remaining(tvb, offset));
2678                 offset += tvb_reported_length_remaining(tvb, offset);
2679                 break;
2680             } else if (length == 0) break;
2681
2682             if (obex_last_opcode_data &&  obex_last_opcode_data->code == BTOBEX_CODE_VALS_CONNECT) {
2683                 proto_tree_add_item(main_tree, hf_version, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2684                 offset++;
2685
2686                 proto_tree_add_item(main_tree, hf_flags, next_tvb, offset, 1, ENC_BIG_ENDIAN);
2687                 offset++;
2688
2689                 proto_tree_add_item(main_tree, hf_max_pkt_len, next_tvb, offset, 2, ENC_BIG_ENDIAN);
2690                 offset += 2;
2691
2692                 if (!pinfo->fd->flags.visited)
2693                     save_path(pinfo, path, "", FALSE, is_obex_over_l2cap, data);
2694             }
2695             break;
2696         }
2697
2698         dissect_headers(main_tree, next_tvb, offset, pinfo, profile, is_obex_over_l2cap, obex_last_opcode_data, data);
2699         if (!pinfo->fd->flags.visited &&
2700                     obex_last_opcode_data &&
2701                     obex_last_opcode_data->data.set_data.name &&
2702                     obex_last_opcode_data->code == BTOBEX_CODE_VALS_SET_PATH &&
2703                     code == BTOBEX_CODE_VALS_SUCCESS) {
2704             save_path(pinfo, path, obex_last_opcode_data->data.set_data.name, obex_last_opcode_data->data.set_data.go_up, is_obex_over_l2cap, data);
2705         }
2706     } else {
2707         /* packet fragment */
2708         col_add_fstr(pinfo->cinfo, COL_INFO, "%s OBEX fragment",
2709                      (pinfo->p2p_dir==P2P_DIR_SENT) ? "Sent" : "Rcvd");
2710         call_dissector(data_handle, next_tvb, pinfo, main_tree);
2711
2712         offset = tvb_reported_length(tvb);
2713     }
2714
2715     pinfo->fragmented = save_fragmented;
2716
2717     return offset;
2718 }
2719
2720
2721 void
2722 proto_register_btobex(void)
2723 {
2724     module_t        *module;
2725     expert_module_t *expert_btobex;
2726     int              proto_raw;
2727     int              proto_bpp;
2728     int              proto_bip;
2729     int              proto_map;
2730     int              proto_gpp;
2731     int              proto_ctn;
2732     int              proto_pbap;
2733
2734     static hf_register_info hf[] = {
2735         { &hf_opcode,
2736           { "Opcode", "btobex.opcode",
2737             FT_UINT8, BASE_HEX|BASE_EXT_STRING, &code_vals_ext, BTOBEX_CODE_VALS_MASK,
2738             "Request Opcode", HFILL}
2739         },
2740         { &hf_response_code,
2741           { "Response Code", "btobex.resp_code",
2742             FT_UINT8, BASE_HEX|BASE_EXT_STRING, &code_vals_ext, BTOBEX_CODE_VALS_MASK,
2743             NULL, HFILL}
2744         },
2745         { &hf_final_flag,
2746           { "Final Flag", "btobex.final_flag",
2747             FT_BOOLEAN, 8, NULL, 0x80,
2748             NULL, HFILL}
2749         },
2750         { &hf_length,
2751           { "Packet Length", "btobex.pkt_len",
2752             FT_UINT16, BASE_DEC, NULL, 0,
2753             NULL, HFILL}
2754         },
2755         { &hf_version,
2756           { "Version", "btobex.version",
2757             FT_UINT8, BASE_HEX, VALS(version_vals), 0x00,
2758             "Obex Protocol Version", HFILL}
2759         },
2760         { &hf_flags,
2761           { "Flags", "btobex.flags",
2762             FT_UINT8, BASE_HEX, NULL, 0x00,
2763             NULL, HFILL}
2764         },
2765         { &hf_constants,
2766           { "Constants", "btobex.constants",
2767             FT_UINT8, BASE_HEX, NULL, 0x00,
2768             NULL, HFILL}
2769         },
2770         { &hf_max_pkt_len,
2771           { "Max. Packet Length", "btobex.max_pkt_len",
2772             FT_UINT16, BASE_DEC, NULL, 0,
2773             NULL, HFILL}
2774         },
2775         { &hf_set_path_flags_0,
2776           { "Go back one folder (../) first", "btobex.set_path_flags_0",
2777             FT_BOOLEAN, 8, NULL, 0x01,
2778             NULL, HFILL}
2779         },
2780         { &hf_set_path_flags_1,
2781           { "Do not create folder, if not existing", "btobex.set_path_flags_1",
2782             FT_BOOLEAN, 8, NULL, 0x02,
2783             NULL, HFILL}
2784         },
2785         { &hf_headers,
2786           { "Headers", "btobex.headers",
2787             FT_NONE, BASE_NONE, NULL, 0x00,
2788             NULL, HFILL}
2789         },
2790         { &hf_header,
2791           { "Header", "btobex.header",
2792             FT_NONE, BASE_NONE, NULL, 0x00,
2793             NULL, HFILL}
2794         },
2795         { &hf_hdr_id,
2796           { "Header Id", "btobex.header.id",
2797             FT_UINT8, BASE_HEX|BASE_EXT_STRING, &header_id_vals_ext, 0x00,
2798             NULL, HFILL}
2799         },
2800         { &hf_hdr_id_encoding,
2801           { "Encoding", "btobex.header.id.encoding",
2802             FT_UINT8, BASE_HEX, VALS(header_id_encoding_vals), 0xC0,
2803             NULL, HFILL}
2804         },
2805         { &hf_hdr_id_meaning,
2806           { "Meaning", "btobex.header.id.meaning",
2807             FT_UINT8, BASE_HEX, VALS(header_id_meaning_vals), 0x3F,
2808             NULL, HFILL}
2809         },
2810         { &hf_hdr_length,
2811           { "Length", "btobex.header.length",
2812             FT_UINT16, BASE_DEC, NULL, 0,
2813             "Header Length", HFILL}
2814         },
2815         { &hf_hdr_val_unicode,
2816           { "Value", "btobex.header.value.unicode",
2817             FT_STRING, BASE_NONE, NULL, 0,
2818             "Unicode Value", HFILL }
2819         },
2820         { &hf_hdr_val_byte_seq,
2821           { "Value", "btobex.header.value.byte_sequence",
2822             FT_BYTES, BASE_NONE, NULL, 0,
2823             "Byte Sequence Value", HFILL}
2824         },
2825         { &hf_hdr_val_byte,
2826           { "Value", "btobex.header.value.byte",
2827             FT_UINT8, BASE_DEC_HEX, NULL, 0,
2828             "Byte Value", HFILL}
2829         },
2830         { &hf_hdr_val_long,
2831           { "Value", "btobex.header.value.long",
2832             FT_UINT32, BASE_DEC, NULL, 0,
2833             "4-byte Value", HFILL}
2834         },
2835         { &hf_count,
2836           { "Count", "btobex.count",
2837             FT_UINT32, BASE_DEC, NULL, 0,
2838             NULL, HFILL}
2839         },
2840         { &hf_data_length,
2841           { "Length", "btobex.length",
2842             FT_UINT32, BASE_DEC, NULL, 0,
2843             NULL, HFILL}
2844         },
2845         { &hf_connection_id,
2846           { "Connection ID", "btobex.connection_id",
2847             FT_UINT32, BASE_DEC, NULL, 0,
2848             NULL, HFILL}
2849         },
2850         { &hf_session_parameter,
2851           { "Session Parameter", "btobex.session",
2852             FT_UINT8, BASE_HEX, NULL, 0x00,
2853             NULL, HFILL}
2854         },
2855         { &hf_session_parameter_data,
2856           { "Parameter Value", "btobex.session.value",
2857             FT_BYTES, BASE_NONE, NULL, 0,
2858             NULL, HFILL}
2859         },
2860         { &hf_session_parameter_tag,
2861           { "Tag", "btobex.session.tag",
2862             FT_UINT8, BASE_HEX, VALS(session_tag_vals), 0x00,
2863             NULL, HFILL}
2864         },
2865         { &hf_session_parameter_length,
2866           { "Length", "btobex.session.length",
2867             FT_UINT8, BASE_DEC, NULL, 0,
2868             NULL, HFILL}
2869         },
2870         { &hf_session_parameter_nonce,
2871           { "Nonce", "btobex.session.nonce",
2872             FT_BYTES, BASE_NONE, NULL, 0,
2873             NULL, HFILL}
2874         },
2875         { &hf_session_parameter_session_id,
2876           { "Session ID", "btobex.session.session_id",
2877             FT_BYTES, BASE_NONE, NULL, 0,
2878             NULL, HFILL}
2879         },
2880         { &hf_session_parameter_next_sequence_number,
2881           { "Next Sequence Number", "btobex.session.next_sequence_number",
2882             FT_UINT8, BASE_DEC, NULL, 0,
2883             NULL, HFILL}
2884         },
2885         { &hf_session_parameter_timeout,
2886           { "Timeout", "btobex.session.timeout",
2887             FT_UINT32, BASE_DEC, NULL, 0,
2888             NULL, HFILL}
2889         },
2890         { &hf_session_parameter_opcode,
2891           { "Opcode", "btobex.session.opcode",
2892             FT_UINT8, BASE_HEX, VALS(session_opcode_vals), 0,
2893             NULL, HFILL}
2894         },
2895         { &hf_authentication_parameter,
2896           { "Autentication Parameter", "btobex.authentication",
2897             FT_UINT8, BASE_HEX, NULL, 0x00,
2898             NULL, HFILL}
2899         },
2900         { &hf_authentication_parameter_data,
2901           { "Parameter Value", "btobex.authentication.value",
2902             FT_BYTES, BASE_NONE, NULL, 0,
2903             NULL, HFILL}
2904         },
2905         { &hf_authentication_challenge_tag,
2906           { "Tag", "btobex.authentication.challenge_tag",
2907             FT_UINT8, BASE_HEX, VALS(authentication_challenge_tag_vals), 0x00,
2908             NULL, HFILL}
2909         },
2910         { &hf_authentication_response_tag,
2911           { "Tag", "btobex.authentication.response_tag",
2912             FT_UINT8, BASE_HEX, VALS(authentication_response_tag_vals), 0x00,
2913             NULL, HFILL}
2914         },
2915         { &hf_authentication_length,
2916           { "Length", "btobex.authentication.length",
2917             FT_UINT8, BASE_DEC, NULL, 0,
2918             NULL, HFILL}
2919         },
2920         { &hf_authentication_key,
2921           { "Key", "btobex.authentication.key",
2922             FT_BYTES, BASE_NONE, NULL, 0,
2923             NULL, HFILL}
2924         },
2925         { &hf_authentication_result_key,
2926           { "Result Key", "btobex.authentication.result_key",
2927             FT_BYTES, BASE_NONE, NULL, 0,
2928             NULL, HFILL}
2929         },
2930         { &hf_authentication_user_id,
2931           { "User Id", "btobex.authentication.user_id",
2932             FT_BYTES, BASE_NONE, NULL, 0,
2933             NULL, HFILL}
2934         },
2935         { &hf_authentication_option_reserved,
2936           { "Reserved", "btobex.authentication.option.reserved",
2937             FT_UINT8, BASE_HEX, NULL, 0xFC,
2938             NULL, HFILL}
2939         },
2940         { &hf_authentication_option_read_only,
2941           { "Read Only", "btobex.authentication.option.read_only",
2942             FT_BOOLEAN, 8, NULL, 0x02,
2943             NULL, HFILL}
2944         },
2945         { &hf_authentication_option_user_id,
2946           { "User ID", "btobex.authentication.option.user_id",
2947             FT_BOOLEAN, 8, NULL, 0x01,
2948             NULL, HFILL}
2949         },
2950         { &hf_authentication_info_charset,
2951           { "Charset", "btobex.authentication.info.charset",
2952             FT_UINT8, BASE_HEX, VALS(info_charset_vals), 0,
2953             NULL, HFILL}
2954         },
2955         { &hf_authentication_info,
2956           { "Info", "btobex.authentication.info",
2957             FT_STRING, BASE_NONE, NULL, 0,
2958             NULL, HFILL}
2959         },
2960         { &hf_application_parameter,
2961           { "Parameter", "btobex.parameter",
2962             FT_NONE, BASE_NONE, NULL, 0x00,
2963             NULL, HFILL}
2964         },
2965         { &hf_application_parameter_id,
2966           { "Parameter Id", "btobex.parameter.id",
2967             FT_UINT8, BASE_HEX, NULL, 0x00,
2968             NULL, HFILL}
2969         },
2970         { &hf_application_parameter_length,
2971           { "Parameter Length", "btobex.parameter.length",
2972             FT_UINT8, BASE_DEC, NULL, 0,
2973             NULL, HFILL}
2974         },
2975         { &hf_application_parameter_data,
2976           { "Parameter Value", "btobex.parameter.value",
2977             FT_BYTES, BASE_NONE, NULL, 0,
2978             NULL, HFILL}
2979         },
2980         /* application parameters for BPP */
2981         { &hf_bpp_application_parameter_id,
2982           { "Parameter Id", "btobex.parameter.id",
2983             FT_UINT8, BASE_HEX | BASE_EXT_STRING, &bpp_application_parameters_vals_ext, 0x00,
2984             NULL, HFILL}
2985         },
2986         { &hf_bpp_application_parameter_data_offset,
2987           { "Offset", "btobex.parameter.value.offset",
2988             FT_UINT32, BASE_DEC_HEX, NULL, 0,
2989             "The byte offset into the image or file.", HFILL}
2990         },
2991         { &hf_bpp_application_parameter_data_count,
2992           { "Count", "btobex.parameter.value.count",
2993             FT_INT32, BASE_DEC, NULL, 0,
2994             "The number of bytes of the image or file to be sent.", HFILL}
2995         },
2996         { &hf_bpp_application_parameter_data_job_id,
2997           { "Job ID", "btobex.parameter.value.job_id",
2998             FT_UINT32, BASE_DEC_HEX, NULL, 0,
2999             "The job identifier of the print job.", HFILL}
3000         },
3001         { &hf_bpp_application_parameter_data_file_size,
3002           { "File Size", "btobex.parameter.value.file_size",
3003             FT_INT32, BASE_DEC, NULL, 0,
3004             "The size (in bytes) of object or file.", HFILL}
3005         },
3006         /* application parameters for BIP */
3007         { &hf_bip_application_parameter_id,
3008           { "Parameter Id", "btobex.parameter.id",
3009             FT_UINT8, BASE_HEX | BASE_EXT_STRING, &bip_application_parameters_vals_ext, 0x00,
3010             NULL, HFILL}
3011         },
3012         { &hf_bip_application_parameter_data_number_of_returned_handles,
3013             { "Number of Returned Handles",   "btobex.parameter.value.number_of_returned_handles",
3014             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3015             NULL, HFILL }
3016         },
3017         { &hf_bip_application_parameter_data_list_start_offset,
3018             { "List Start Offset",   "btobex.parameter.value.list_start_offset",
3019             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3020             NULL, HFILL }
3021         },
3022         { &hf_bip_application_parameter_data_latest_captured_images,
3023             { "Latest Captured Images",   "btobex.parameter.value.latest_captured_images",
3024             FT_BOOLEAN, 8, NULL, 0x00,
3025             NULL, HFILL }
3026         },
3027         { &hf_bip_application_parameter_data_partial_file_length,
3028             { "Partial File Length",   "btobex.parameter.value.partial_file_length",
3029             FT_UINT32, BASE_DEC_HEX, NULL, 0x00,
3030             NULL, HFILL }
3031         },
3032         { &hf_bip_application_parameter_data_partial_file_start_offset,
3033             { "Partial File Start Offset",   "btobex.parameter.value.partial_file_start_offset",
3034             FT_UINT32, BASE_DEC_HEX, NULL, 0x00,
3035             NULL, HFILL }
3036         },
3037         { &hf_bip_application_parameter_data_total_file_size,
3038             { "Total File Size",   "btobex.parameter.value.total_file_size",
3039             FT_UINT32, BASE_DEC_HEX, NULL, 0x00,
3040             NULL, HFILL }
3041         },
3042         { &hf_bip_application_parameter_data_end_flag,
3043             { "End Flag",   "btobex.parameter.value.end_flag",
3044             FT_BOOLEAN, 8, NULL, 0x00,
3045             NULL, HFILL }
3046         },
3047         { &hf_bip_application_parameter_data_remote_display,
3048             { "Remote Display",   "btobex.parameter.value.remote_display",
3049             FT_UINT8, BASE_HEX, VALS(bip_remote_display_vals), 0x00,
3050             NULL, HFILL }
3051         },
3052         { &hf_bip_application_parameter_data_service_id,
3053             { "Service ID",   "btobex.parameter.value.service_id",
3054             FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_uuid_vals_ext, 0x00,
3055             NULL, HFILL }
3056         },
3057         { &hf_bip_application_parameter_data_store_flag,
3058             { "Store Flag",   "btobex.parameter.value.store_flag",
3059             FT_BOOLEAN, 8, NULL, 0x00,
3060             NULL, HFILL }
3061         },
3062         /* application parameters for PBAP */
3063         { &hf_pbap_application_parameter_id,
3064           { "Parameter Id", "btobex.parameter.id",
3065             FT_UINT8, BASE_HEX | BASE_EXT_STRING, &pbap_application_parameters_vals_ext, 0x00,
3066             NULL, HFILL}
3067         },
3068         { &hf_pbap_application_parameter_data_order,
3069           { "Max List Count", "btobex.parameter.value.order",
3070             FT_UINT8, BASE_HEX, VALS(pbap_order_vals), 0x00,
3071             NULL, HFILL}
3072         },
3073         { &hf_pbap_application_parameter_data_search_value,
3074           { "Search Value", "btobex.parameter.value.search_value",
3075             FT_STRING, BASE_NONE, NULL, 0x00,
3076             NULL, HFILL}
3077         },
3078         { &hf_pbap_application_parameter_data_search_attribute,
3079           { "Search Attribute", "btobex.parameter.value.search_attribute",
3080             FT_UINT8, BASE_HEX, VALS(pbap_search_attribute_vals), 0x00,
3081             NULL, HFILL}
3082         },
3083         { &hf_pbap_application_parameter_data_max_list_count,
3084           { "Max List Count", "btobex.parameter.value.max_list_count",
3085             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3086             NULL, HFILL}
3087         },
3088         { &hf_pbap_application_parameter_data_list_start_offset,
3089           { "List Start Offset", "btobex.parameter.value.list_start_offset",
3090             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3091             NULL, HFILL}
3092         },
3093         { &hf_pbap_application_parameter_data_filter,
3094           { "Filter", "btobex.parameter.value.filter",
3095             FT_UINT32, BASE_HEX, NULL, 0x0,
3096             NULL, HFILL}
3097         },
3098         { &hf_pbap_application_parameter_vcard_selector,
3099           { "vCard Selector", "btobex.parameter.value.filter",
3100             FT_UINT32, BASE_HEX, NULL, 0x0,
3101             NULL, HFILL}
3102         },
3103         { &hf_pbap_application_parameter_data_filter_version,
3104           { "vCard Version", "btobex.parameter.value.filter.version",
3105             FT_BOOLEAN, 32, NULL, 0x00000001,
3106             NULL, HFILL}
3107         },
3108         { &hf_pbap_application_parameter_data_filter_fn,
3109           { "Formatted Name", "btobex.parameter.value.filter.fn",
3110             FT_BOOLEAN, 32, NULL, 0x00000002,
3111             NULL, HFILL}
3112         },
3113         { &hf_pbap_application_parameter_data_filter_n,
3114           { "Structured Presentation of Name", "btobex.parameter.value.filter.n",
3115             FT_BOOLEAN, 32, NULL, 0x00000004,
3116             NULL, HFILL}
3117         },
3118         { &hf_pbap_application_parameter_data_filter_photo,
3119           { "Associated Image or Photo", "btobex.parameter.value.filter.photo",
3120             FT_BOOLEAN, 32, NULL, 0x00000008,
3121             NULL, HFILL}
3122         },
3123         { &hf_pbap_application_parameter_data_filter_birthday,
3124           { "Birthday", "btobex.parameter.value.filter.birthday",
3125             FT_BOOLEAN, 32, NULL, 0x00000010,
3126             NULL, HFILL}
3127         },
3128         { &hf_pbap_application_parameter_data_filter_adr,
3129           { "Delivery Address", "btobex.parameter.value.filter.adr",
3130             FT_BOOLEAN, 32, NULL, 0x00000020,
3131             NULL, HFILL}
3132         },
3133         { &hf_pbap_application_parameter_data_filter_label,
3134           { "Delivery", "btobex.parameter.value.filter.label",
3135             FT_BOOLEAN, 32, NULL, 0x00000040,
3136             NULL, HFILL}
3137         },
3138         { &hf_pbap_application_parameter_data_filter_tel,
3139           { "Telephone Number", "btobex.parameter.value.filter.tel",
3140             FT_BOOLEAN, 32, NULL, 0x00000080,
3141             NULL, HFILL}
3142         },
3143         { &hf_pbap_application_parameter_data_filter_email,
3144           { "Electronic Mail Address", "btobex.parameter.value.filter.email",
3145             FT_BOOLEAN, 32, NULL, 0x00000100,
3146             NULL, HFILL}
3147         },
3148         { &hf_pbap_application_parameter_data_filter_mailer,
3149           { "Electronic Mail", "btobex.parameter.value.filter.mailer",
3150             FT_BOOLEAN, 32, NULL, 0x00000200,
3151             NULL, HFILL}
3152         },
3153         { &hf_pbap_application_parameter_data_filter_time_zone,
3154           { "Time Zone", "btobex.parameter.value.filter.time_zone",
3155             FT_BOOLEAN, 32, NULL, 0x00000400,
3156             NULL, HFILL}
3157         },
3158         { &hf_pbap_application_parameter_data_filter_geographic_position,
3159           { "Geographic Position", "btobex.parameter.value.filter.geographic_position",
3160             FT_BOOLEAN, 32, NULL, 0x00000800,
3161             NULL, HFILL}
3162         },
3163         { &hf_pbap_application_parameter_data_filter_title,
3164           { "Job", "btobex.parameter.value.filter.title",
3165             FT_BOOLEAN, 32, NULL, 0x00001000,
3166             NULL, HFILL}
3167         },
3168         { &hf_pbap_application_parameter_data_filter_role,
3169           { "Role within the Organization", "btobex.parameter.value.filter.role",
3170             FT_BOOLEAN, 32, NULL, 0x00002000,
3171             NULL, HFILL}
3172         },
3173         { &hf_pbap_application_parameter_data_filter_logo,
3174           { "Organization Logo", "btobex.parameter.value.filter.logo",
3175             FT_BOOLEAN, 32, NULL, 0x00004000,
3176             NULL, HFILL}
3177         },
3178         { &hf_pbap_application_parameter_data_filter_agent,
3179           { "vCard of Person Representing", "btobex.parameter.value.filter.agent",
3180             FT_BOOLEAN, 32, NULL, 0x00008000,
3181             NULL, HFILL}
3182         },
3183         { &hf_pbap_application_parameter_data_filter_name_of_organization,
3184           { "Name of Organization", "btobex.parameter.value.filter.name_of_organization",
3185             FT_BOOLEAN, 32, NULL, 0x00010000,
3186             NULL, HFILL}
3187         },
3188         { &hf_pbap_application_parameter_data_filter_comments,
3189           { "Comments", "btobex.parameter.value.filter.comments",
3190             FT_BOOLEAN, 32, NULL, 0x00020000,
3191             NULL, HFILL}
3192         },
3193         { &hf_pbap_application_parameter_data_filter_revision,
3194           { "Revision", "btobex.parameter.value.filter.revision",
3195             FT_BOOLEAN, 32, NULL, 0x00040000,
3196             NULL, HFILL}
3197         },
3198         { &hf_pbap_application_parameter_data_filter_pronunciation_of_name,
3199           { "Pronunciation of Name", "btobex.parameter.value.filter.pronunciation_of_name",
3200             FT_BOOLEAN, 32, NULL, 0x00080000,
3201             NULL, HFILL}
3202         },
3203         { &hf_pbap_application_parameter_data_filter_url,
3204           { "Uniform Resource Locator", "btobex.parameter.value.filter.url",
3205             FT_BOOLEAN, 32, NULL, 0x00100000,
3206             NULL, HFILL}
3207         },
3208         { &hf_pbap_application_parameter_data_filter_uid,
3209           { "Unique ID", "btobex.parameter.value.filter.uid",
3210             FT_BOOLEAN, 32, NULL, 0x00200000,
3211             NULL, HFILL}
3212         },
3213         { &hf_pbap_application_parameter_data_filter_key,
3214           { "Public Encryption Key", "btobex.parameter.value.filter.key",
3215             FT_BOOLEAN, 32, NULL, 0x00400000,
3216             NULL, HFILL}
3217         },
3218         { &hf_pbap_application_parameter_data_filter_nickname,
3219           { "Nickname", "btobex.parameter.value.filter.nickname",
3220             FT_BOOLEAN, 32, NULL, 0x00800000,
3221             NULL, HFILL}
3222         },
3223         { &hf_pbap_application_parameter_data_filter_categories,
3224           { "Categories", "btobex.parameter.value.filter.categories",
3225             FT_BOOLEAN, 32, NULL, 0x01000000,
3226             NULL, HFILL}
3227         },
3228         { &hf_pbap_application_parameter_data_filter_product_id,
3229           { "Product ID", "btobex.parameter.value.filter.product_id",
3230             FT_BOOLEAN, 32, NULL, 0x02000000,
3231             NULL, HFILL}
3232         },
3233         { &hf_pbap_application_parameter_data_filter_class,
3234           { "Class Information", "btobex.parameter.value.filter.class",
3235             FT_BOOLEAN, 32, NULL, 0x04000000,
3236             NULL, HFILL}
3237         },
3238         { &hf_pbap_application_parameter_data_filter_sort_string,
3239           { "String Used For Sorting Operations", "btobex.parameter.value.filter.sort_string",
3240             FT_BOOLEAN, 32, NULL, 0x08000000,
3241             NULL, HFILL}
3242         },
3243         { &hf_pbap_application_parameter_data_filter_timestamp,
3244           { "Timestamp", "btobex.parameter.value.filter.timestamp",
3245             FT_BOOLEAN, 32, NULL, 0x10000000,
3246             NULL, HFILL}
3247         },
3248         { &hf_pbap_application_parameter_data_filter_reserved_29_31,
3249           { "Reserved", "btobex.parameter.value.filter.reserved_29_31",
3250             FT_UINT32, BASE_HEX, NULL, 0xE0000000,
3251             NULL, HFILL}
3252         },
3253         { &hf_pbap_application_parameter_data_filter_reserved_32_38,
3254           { "Reserved", "btobex.parameter.value.filter.reserved_32_38",
3255             FT_UINT32, BASE_HEX, NULL, 0x0000007F,
3256             NULL, HFILL}
3257         },
3258         { &hf_pbap_application_parameter_data_filter_proprietary_filter,
3259           { "Proprietary Filter", "btobex.parameter.value.filter.proprietary_filter",
3260             FT_BOOLEAN, 32, NULL, 0x00000080,
3261             NULL, HFILL}
3262         },
3263         { &hf_pbap_application_parameter_data_filter_reserved_for_proprietary_filter_usage,
3264           { "Reserved for Proprietary Filter Usage", "btobex.parameter.value.filter.reserved_for_proprietary_filter_usage",
3265             FT_UINT32, BASE_HEX, NULL, 0xFFFFFF00,
3266             NULL, HFILL}
3267         },
3268         { &hf_pbap_application_parameter_data_format,
3269           { "Format", "btobex.parameter.value.format",
3270             FT_UINT8, BASE_HEX, VALS(pbap_format_vals), 0x00,
3271             NULL, HFILL}
3272         },
3273         { &hf_pbap_application_parameter_data_phonebook_size,
3274           { "Phonebook Size", "btobex.parameter.value.phonebook_size",
3275             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3276             NULL, HFILL}
3277         },
3278         { &hf_pbap_application_parameter_data_new_missed_calls,
3279           { "New Missed Calls", "btobex.parameter.value.new_missed_calls",
3280             FT_UINT8, BASE_DEC, NULL, 0x00,
3281             NULL, HFILL}
3282         },
3283         { &hf_pbap_application_parameter_data_primary_version_counter,
3284           { "Primary Version Counter", "btobex.parameter.value.primary_version_counter",
3285             FT_BYTES, BASE_NONE, NULL, 0x00,
3286             NULL, HFILL}
3287         },
3288         { &hf_pbap_application_parameter_data_secondary_version_counter,
3289           { "Secondary Version Counter", "btobex.parameter.value.secondary_version_counter",
3290             FT_BYTES, BASE_NONE, NULL, 0x00,
3291             NULL, HFILL}
3292         },
3293         { &hf_pbap_application_parameter_data_database_identifier,
3294           { "Database Identifier", "btobex.parameter.value.database_identifier",
3295             FT_BYTES, BASE_NONE, NULL, 0x00,
3296             NULL, HFILL}
3297         },
3298         { &hf_pbap_application_parameter_data_vcard_selector_operator,
3299           { "vCard Selector Operator", "btobex.parameter.value.vcard_selector_operator",
3300             FT_UINT8, BASE_HEX, VALS(pbap_application_parameter_data_vcard_selector_operator_vals), 0x00,
3301             NULL, HFILL}
3302         },
3303         { &hf_pbap_application_parameter_data_reset_new_missed_calls,
3304           { "vCard Selector Operator", "btobex.parameter.value.reset_new_missed_calls",
3305             FT_UINT8, BASE_HEX, VALS(pbap_application_parameter_data_reset_new_missed_calls_vals), 0x00,
3306             NULL, HFILL}
3307         },
3308         { &hf_pbap_application_parameter_data_supported_features,
3309             { "Supported Features",              "btobex.parameter.supported_features",
3310             FT_UINT32, BASE_HEX, NULL, 0x0,
3311             NULL, HFILL }
3312         },
3313         { &hf_pbap_application_parameter_data_supported_features_reserved,
3314             { "Reserved",                        "btobex.parameter.supported_features.reserved",
3315             FT_UINT32, BASE_HEX, NULL, 0xFFFFFC00,
3316             NULL, HFILL }
3317         },
3318         { &hf_pbap_application_parameter_data_supported_features_default_contact_image_format,
3319             { "Default Contact Image Format",    "btobex.parameter.supported_features.default_contact_image_format",
3320             FT_BOOLEAN, 32, NULL, 0x00000200,
3321             NULL, HFILL }
3322         },
3323         { &hf_pbap_application_parameter_data_supported_features_contact_referencing,
3324             { "Contact Referencing",             "btobex.parameter.supported_features.contact_referencing",
3325             FT_BOOLEAN, 32, NULL, 0x00000100,
3326             NULL, HFILL }
3327         },
3328         { &hf_pbap_application_parameter_data_supported_features_x_bt_uid_vcard_property,
3329             { "X-BT-UID vCard Property",         "btobex.parameter.supported_features.x_bt_uid_vcard_property",
3330             FT_BOOLEAN, 32, NULL, 0x00000080,
3331             NULL, HFILL }
3332         },
3333         { &hf_pbap_application_parameter_data_supported_features_x_bt_uci_vcard_property,
3334             { "X-BT-UCI vCard Property",         "btobex.parameter.supported_features.x_bt_uci_vcard_property",
3335             FT_BOOLEAN, 32, NULL, 0x00000040,
3336             NULL, HFILL }
3337         },
3338         { &hf_pbap_application_parameter_data_supported_features_enhanced_missed_calls,
3339             { "Enhanced Missed Calls",           "btobex.parameter.supported_features.enhanced_missed_calls",
3340             FT_BOOLEAN, 32, NULL, 0x00000020,
3341             NULL, HFILL }
3342         },
3343         { &hf_pbap_application_parameter_data_supported_features_vcard_selecting,
3344             { "vCard Selecting",                 "btobex.parameter.supported_features.vcard_selecting",
3345             FT_BOOLEAN, 32, NULL, 0x00000010,
3346             NULL, HFILL }
3347         },
3348         { &hf_pbap_application_parameter_data_supported_features_folder_version_counters,
3349             { "Folder Version Counters",         "btobex.parameter.supported_features.folder_version_counters",
3350             FT_BOOLEAN, 32, NULL, 0x00000008,
3351             NULL, HFILL }
3352         },
3353         { &hf_pbap_application_parameter_data_supported_features_database_identifier,
3354             { "Database Identifier",             "btobex.parameter.supported_features.database_identifier",
3355             FT_BOOLEAN, 32, NULL, 0x00000004,
3356             NULL, HFILL }
3357         },
3358         { &hf_pbap_application_parameter_data_supported_features_browsing,
3359             { "Browsing",                        "btobex.parameter.supported_features.browsing",
3360             FT_BOOLEAN, 32, NULL, 0x00000002,
3361             NULL, HFILL }
3362         },
3363         { &hf_pbap_application_parameter_data_supported_features_download,
3364             { "Download",                        "btobex.parameter.supported_features.download",
3365             FT_BOOLEAN, 32, NULL, 0x00000001,
3366             NULL, HFILL }
3367         },
3368         /* application parameters for MAP */
3369         { &hf_map_application_parameter_id,
3370           { "Parameter Id", "btobex.parameter.id",
3371             FT_UINT8, BASE_HEX | BASE_EXT_STRING, &map_application_parameters_vals_ext, 0x00,
3372             NULL, HFILL}
3373         },
3374         { &hf_map_application_parameter_data_max_list_count,
3375           { "Max List Count", "btobex.parameter.value.max_list_count",
3376             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3377             NULL, HFILL}
3378         },
3379         { &hf_map_application_parameter_data_start_offset,
3380           { "Start Offset", "btobex.parameter.value.start_offset",
3381             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3382             NULL, HFILL}
3383         },
3384         { &hf_map_application_parameter_data_filter_message_type_reserved,
3385           { "Reserved", "btobex.parameter.value.filter_message_type.reserved",
3386             FT_UINT8, BASE_HEX, NULL, 0xF0,
3387             NULL, HFILL}
3388         },
3389         { &hf_map_application_parameter_data_filter_message_type_mms,
3390           { "MMS", "btobex.parameter.value.filter_message_type.mms",
3391             FT_BOOLEAN, 8, NULL, 0x08,
3392             "True to filter out, False to listing this type", HFILL}
3393         },
3394         { &hf_map_application_parameter_data_filter_message_type_email,
3395           { "EMAIL", "btobex.parameter.value.filter_message_type.sms_email",
3396             FT_BOOLEAN, 8, NULL, 0x04,
3397             "True to filter out, False to listing this type", HFILL}
3398         },
3399         { &hf_map_application_parameter_data_filter_message_type_sms_cdma,
3400           { "SMS_CDMA", "btobex.parameter.value.filter_message_type.sms_cdma",
3401             FT_BOOLEAN, 8, NULL, 0x02,
3402             "True to filter out, False to listing this type", HFILL}
3403         },
3404         { &hf_map_application_parameter_data_filter_message_type_sms_gsm,
3405           { "SMS_GSM", "btobex.parameter.value.filter_message_type.sms_gsm",
3406             FT_BOOLEAN, 8, NULL, 0x01,
3407             NULL, HFILL}
3408         },
3409         { &hf_map_application_parameter_data_filter_period_begin,
3410           { "Filter Period Begin", "btobex.parameter.value.filter_period_begin",
3411             FT_STRING, BASE_NONE, NULL, 0,
3412             NULL, HFILL}
3413         },
3414         { &hf_map_application_parameter_data_filter_period_end,
3415           { "Filter Period End", "btobex.parameter.value.filter_period_end",
3416             FT_STRING, BASE_NONE, NULL, 0,
3417             NULL, HFILL}
3418         },
3419         { &hf_map_application_parameter_data_filter_read_status_reserved_6,
3420           { "Filter Read Status: Reserved", "btobex.parameter.value.filter_read_status.reserved",
3421             FT_UINT8, BASE_HEX, NULL, 0xFC,
3422             NULL, HFILL}
3423         },
3424         { &hf_map_application_parameter_data_filter_read_status_get_read,
3425           { "Filter Read Status: Get Read", "btobex.parameter.value.filter_read_status.get_read",
3426             FT_BOOLEAN, 8, NULL, 0x02,
3427             NULL, HFILL}
3428         },
3429         { &hf_map_application_parameter_data_filter_read_status_get_unread,
3430           { "Filter Read Status: Get Unread", "btobex.parameter.value.filter_read_status.get_unread",
3431             FT_BOOLEAN, 8, NULL, 0x01,
3432             NULL, HFILL}
3433         },
3434         { &hf_map_application_parameter_data_filter_recipient,
3435           { "Filter Recipient", "btobex.parameter.value.filter_recipient",
3436             FT_STRING, BASE_NONE, NULL, 0,
3437             NULL, HFILL}
3438         },
3439         { &hf_map_application_parameter_data_filter_originator,
3440           { "Filter Originator", "btobex.parameter.value.filter_originator",
3441             FT_STRING, BASE_NONE, NULL, 0,
3442             NULL, HFILL}
3443         },
3444         { &hf_map_application_parameter_data_filter_priority_reserved_6,
3445           { "Filter Priority: Reserved", "btobex.parameter.value.filter_priority.reserved",
3446             FT_UINT8, BASE_HEX, NULL, 0xFC,
3447             NULL, HFILL}
3448         },
3449         { &hf_map_application_parameter_data_filter_priority_get_high,
3450           { "Filter Priority: Get Read", "btobex.parameter.value.filter_priority.get_high",
3451             FT_BOOLEAN, 8, NULL, 0x02,
3452             NULL, HFILL}
3453         },
3454         { &hf_map_application_parameter_data_filter_priority_non_high,
3455           { "Filter Priority: Get Non High", "btobex.parameter.value.filter_priority.non_high",
3456             FT_BOOLEAN, 8, NULL, 0x01,
3457             NULL, HFILL}
3458         },
3459         { &hf_map_application_parameter_data_reserved_7,
3460           { "Reserved", "btobex.parameter.value.reserved",
3461             FT_UINT8, BASE_HEX, NULL, 0xFE,
3462             NULL, HFILL}
3463         },
3464         { &hf_map_application_parameter_data_attachment,
3465           { "Attachment", "btobex.parameter.value.attachment",
3466             FT_BOOLEAN, 8, NULL, 0x01,
3467             NULL, HFILL}
3468         },
3469         { &hf_map_application_parameter_data_transparent,
3470           { "Transparent", "btobex.parameter.value.transparent",
3471             FT_BOOLEAN, 8, NULL, 0x01,
3472             NULL, HFILL}
3473         },
3474         { &hf_map_application_parameter_data_retry,
3475           { "Retry", "btobex.parameter.value.retry",
3476             FT_BOOLEAN, 8, NULL, 0x01,
3477             NULL, HFILL}
3478         },
3479         { &hf_map_application_parameter_data_new_message,
3480           { "New Message", "btobex.parameter.value.new_message",
3481             FT_BOOLEAN, 8, NULL, 0x01,
3482             NULL, HFILL}
3483         },
3484         { &hf_map_application_parameter_data_notification_status,
3485           { "Notification Status", "btobex.parameter.value.notification_status",
3486             FT_BOOLEAN, 8, NULL, 0x01,
3487             NULL, HFILL}
3488         },
3489         { &hf_map_application_parameter_data_mas_instance_id,
3490           { "MAS Instance ID", "btobex.parameter.value.mas_instance_id",
3491             FT_UINT8, BASE_DEC_HEX, NULL, 0,
3492             NULL, HFILL}
3493         },
3494         { &hf_map_application_parameter_data_parameter_mask_reserved,
3495           { "Parameter Mask: Reserved", "btobex.parameter.value.parameter_mask.reserved",
3496             FT_UINT32, BASE_HEX, NULL, 0xFFFF0000,
3497             NULL, HFILL}
3498         },
3499         { &hf_map_application_parameter_data_parameter_mask_reply_to_addressing,
3500           { "Parameter Mask: Reply to Addressing", "btobex.parameter.value.parameter_mask.reply_to_addressing",
3501             FT_BOOLEAN, 32, NULL, 0x8000,
3502             NULL, HFILL}
3503         },
3504         { &hf_map_application_parameter_data_parameter_mask_protected,
3505           { "Parameter Mask: Protected", "btobex.parameter.value.parameter_mask.protected",
3506             FT_BOOLEAN, 32, NULL, 0x4000,
3507             NULL, HFILL}
3508         },
3509         { &hf_map_application_parameter_data_parameter_mask_sent,
3510           { "Parameter Mask: Sent", "btobex.parameter.value.parameter_mask.sent",
3511             FT_BOOLEAN, 32, NULL, 0x2000,
3512             NULL, HFILL}
3513         },
3514         { &hf_map_application_parameter_data_parameter_mask_read,
3515           { "Parameter Mask: Read", "btobex.parameter.value.parameter_mask.read",
3516             FT_BOOLEAN, 32, NULL, 0x1000,
3517             NULL, HFILL}
3518         },
3519         { &hf_map_application_parameter_data_parameter_mask_priority,
3520           { "Parameter Mask: Priority", "btobex.parameter.value.parameter_mask.priority",
3521             FT_BOOLEAN, 32, NULL, 0x0800,
3522             NULL, HFILL}
3523         },
3524         { &hf_map_application_parameter_data_parameter_mask_attachment_size,
3525           { "Parameter Mask: Attachment Size", "btobex.parameter.value.parameter_mask.attachment_size",
3526             FT_BOOLEAN, 32, NULL, 0x0400,
3527             NULL, HFILL}
3528         },
3529         { &hf_map_application_parameter_data_parameter_mask_text,
3530           { "Parameter Mask: Text", "btobex.parameter.value.parameter_mask.text",
3531             FT_BOOLEAN, 32, NULL, 0x0200,
3532             NULL, HFILL}
3533         },
3534         { &hf_map_application_parameter_data_parameter_mask_reception_status,
3535           { "Parameter Mask: Reception Status", "btobex.parameter.value.parameter_mask.reception_status",
3536             FT_BOOLEAN, 32, NULL, 0x0100,
3537             NULL, HFILL}
3538         },
3539         { &hf_map_application_parameter_data_parameter_mask_size,
3540           { "Parameter Mask: Size", "btobex.parameter.value.parameter_mask.size",
3541             FT_BOOLEAN, 32, NULL, 0x0080,
3542             NULL, HFILL}
3543         },
3544         { &hf_map_application_parameter_data_parameter_mask_type,
3545           { "Parameter Mask: Type", "btobex.parameter.value.parameter_mask.type",
3546             FT_BOOLEAN, 32, NULL, 0x0040,
3547             NULL, HFILL}
3548         },
3549         { &hf_map_application_parameter_data_parameter_mask_recipient_addressing,
3550           { "Parameter Mask: Recipient Addressing", "btobex.parameter.value.parameter_mask.recipient_addressing",
3551             FT_BOOLEAN, 32, NULL, 0x0020,
3552             NULL, HFILL}
3553         },
3554         { &hf_map_application_parameter_data_parameter_mask_recipient_name,
3555           { "Parameter Mask: Recipient Name", "btobex.parameter.value.parameter_mask.recipient_name",
3556             FT_BOOLEAN, 32, NULL, 0x0010,
3557             NULL, HFILL}
3558         },
3559         { &hf_map_application_parameter_data_parameter_mask_sender_addressing,
3560           { "Parameter Mask: Sender Addressing", "btobex.parameter.value.parameter_mask.sender_addressing",
3561             FT_BOOLEAN, 32, NULL, 0x0008,
3562             NULL, HFILL}
3563         },
3564         { &hf_map_application_parameter_data_parameter_mask_sender_name,
3565           { "Parameter Mask: Sender Name", "btobex.parameter.value.parameter_mask.sender_name",
3566             FT_BOOLEAN, 32, NULL, 0x0004,
3567             NULL, HFILL}
3568         },
3569         { &hf_map_application_parameter_data_parameter_mask_datetime,
3570           { "Parameter Mask: Datetime", "btobex.parameter.value.parameter_mask.datetime",
3571             FT_BOOLEAN, 32, NULL, 0x0002,
3572             NULL, HFILL}
3573         },
3574         { &hf_map_application_parameter_data_parameter_mask_subject,
3575           { "Parameter Mask: Subject", "btobex.parameter.value.parameter_mask.subject",
3576             FT_BOOLEAN, 32, NULL, 0x0001,
3577             NULL, HFILL}
3578         },
3579         { &hf_map_application_parameter_data_folder_listing_size,
3580           { "Folder Listing Size", "btobex.parameter.value.folder_listing_size",
3581             FT_UINT16, BASE_DEC_HEX, NULL, 0,
3582             NULL, HFILL}
3583         },
3584         { &hf_map_application_parameter_data_messages_listing_size,
3585           { "Messages Listing Size", "btobex.parameter.value.messages_listing_size",
3586             FT_UINT16, BASE_DEC_HEX, NULL, 0,
3587             NULL, HFILL}
3588         },
3589         { &hf_map_application_parameter_data_subject_length,
3590           { "Subject Length", "btobex.parameter.value.subject_length",
3591             FT_UINT8, BASE_DEC_HEX, NULL, 0,
3592             NULL, HFILL}
3593         },
3594         { &hf_map_application_parameter_data_charset,
3595           { "Charset", "btobex.parameter.value.charset",
3596             FT_UINT8, BASE_HEX, VALS(map_charset_vals), 0x01,
3597             NULL, HFILL}
3598         },
3599         { &hf_map_application_parameter_data_fraction_request,
3600           { "Fraction Request", "btobex.parameter.value.fraction_request",
3601             FT_UINT8, BASE_HEX, VALS(map_fraction_request_vals), 0x01,
3602             NULL, HFILL}
3603         },
3604         { &hf_map_application_parameter_data_fraction_deliver,
3605           { "Fraction Deliver", "btobex.parameter.value.fraction_deliver",
3606             FT_UINT8, BASE_HEX, VALS(map_fraction_deliver_vals), 0x01,
3607             NULL, HFILL}
3608         },
3609         { &hf_map_application_parameter_data_status_indicator,
3610           { "Status Indicator", "btobex.parameter.value.status_indicator",
3611             FT_UINT8, BASE_HEX, VALS(map_status_indicator_vals), 0x01,
3612             NULL, HFILL}
3613         },
3614         { &hf_map_application_parameter_data_status_value,
3615           { "Status Value", "btobex.parameter.value.status_value",
3616             FT_BOOLEAN, 8, NULL, 0x01,
3617             NULL, HFILL}
3618         },
3619         { &hf_map_application_parameter_data_mse_time,
3620           { "MSE Time", "btobex.parameter.value.mse_time",
3621             FT_STRING, BASE_NONE, NULL, 0,
3622             NULL, HFILL}
3623         },
3624         /* application parameters for GPP */
3625         { &hf_gpp_application_parameter_id,
3626           { "Parameter Id", "btobex.parameter.gpp.id",
3627             FT_UINT8, BASE_HEX, VALS(gpp_application_parameters_vals), 0x00,
3628             NULL, HFILL}
3629         },
3630         { &hf_gpp_application_parameter_data_max_list_count,
3631           { "Max List Count", "btobex.parameter.gpp.value.max_list_count",
3632             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3633             NULL, HFILL}
3634         },
3635         { &hf_gpp_application_parameter_data_list_start_offset,
3636           { "List Start Offset", "btobex.parameter.gpp.value.list_start_offset",
3637             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3638             NULL, HFILL}
3639         },
3640         { &hf_gpp_application_parameter_data_reserved_7,
3641           { "Reserved", "btobex.parameter.gpp.value.reserved",
3642             FT_UINT8, BASE_HEX, NULL, 0xFE,
3643             NULL, HFILL}
3644         },
3645         { &hf_gpp_application_parameter_data_notification_status,
3646           { "Notification Status", "btobex.parameter.gpp.value.notification_status",
3647             FT_BOOLEAN, 8, NULL, 0x01,
3648             NULL, HFILL}
3649         },
3650         { &hf_gpp_application_parameter_data_instance_id,
3651           { "Instance ID", "btobex.parameter.gpp.value.instance_id",
3652             FT_UINT8, BASE_DEC_HEX, NULL, 0,
3653             NULL, HFILL}
3654         },
3655         { &hf_gpp_application_parameter_data_listing_size,
3656           { "Listing Size", "btobex.parameter.gpp.value.listing_size",
3657             FT_UINT16, BASE_DEC_HEX, NULL, 0x00,
3658             NULL, HFILL}
3659         },
3660         /* application parameters for CTN */
3661         { &hf_ctn_application_parameter_id,
3662           { "Parameter Id", "btobex.parameter.ctn.id",
3663             FT_UINT8, BASE_HEX, VALS(ctn_application_parameters_vals), 0x00,
3664             NULL, HFILL}
3665         },
3666         { &hf_ctn_application_parameter_data_acoustic_alarm_status,
3667           { "Acoustic Alarm Status", "btobex.parameter.ctn.acoustic_alarm_status",
3668             FT_UINT8, BASE_HEX, VALS(off_on_vals), 0x00,
3669             NULL, HFILL}
3670         },
3671         { &hf_ctn_application_parameter_data_attachment,
3672           { "Attachment", "btobex.parameter.ctn.attachment",
3673             FT_UINT8, BASE_HEX, VALS(ctn_application_parameter_data_attachment_vals), 0x00,
3674             NULL, HFILL}
3675         },
3676         { &hf_ctn_application_parameter_data_send,
3677           { "Attachment", "btobex.parameter.ctn.attachment",
3678             FT_UINT8, BASE_HEX, VALS(no_yes_vals), 0x00,
3679             NULL, HFILL}
3680         },
3681         { &hf_ctn_application_parameter_data_filter_period_begin,
3682           { "Filter Period Begin", "btobex.parameter.ctn.filter_period_begin",
3683             FT_STRING, STR_ASCII, NULL, 0x00,
3684             NULL, HFILL}
3685         },
3686         { &hf_ctn_application_parameter_data_filter_period_end,
3687           { "Filter Period End", "btobex.parameter.ctn.filter_period_end",
3688             FT_STRING, STR_ASCII, NULL, 0x00,
3689             NULL, HFILL}
3690         },
3691         { &hf_ctn_application_parameter_data_parameter_mask,
3692           { "Parameter Mask", "btobex.parameter.ctn.parameter_mask",
3693             FT_UINT32, BASE_HEX, NULL, 0x00,
3694             NULL, HFILL}
3695         },
3696         { &hf_ctn_application_parameter_data_parameter_mask_reserved,
3697           { "Reserved", "btobex.parameter.ctn.parameter_mask.reserved",
3698             FT_UINT32, BASE_HEX, NULL, 0xFFFFFC00,
3699             NULL, HFILL}
3700         },
3701         { &hf_ctn_application_parameter_data_parameter_mask_recurrent,
3702           { "Recurrent", "btobex.parameter.ctn.parameter_mask.recurrent",
3703             FT_UINT32, BASE_HEX, NULL, 0x00000200,
3704             NULL, HFILL}
3705         },
3706         { &hf_ctn_application_parameter_data_parameter_mask_send_status,
3707           { "Send Status", "btobex.parameter.ctn.parameter_mask.send_status",
3708             FT_UINT32, BASE_HEX, NULL, 0x00000100,
3709             NULL, HFILL}
3710         },
3711         { &hf_ctn_application_parameter_data_parameter_mask_alarm_status,
3712           { "Alarm Status", "btobex.parameter.ctn.parameter_mask.",
3713             FT_UINT32, BASE_HEX, NULL, 0x00000080,
3714             NULL, HFILL}
3715         },
3716         { &hf_ctn_application_parameter_data_parameter_mask_pstatus,
3717           { "pStatus", "btobex.parameter.ctn.parameter_mask.pstatus",
3718             FT_UINT32, BASE_HEX, NULL, 0x00000040,
3719             NULL, HFILL}
3720         },
3721         { &hf_ctn_application_parameter_data_parameter_mask_priority,
3722           { "Priority", "btobex.parameter.ctn.parameter_mask.priority",
3723             FT_UINT32, BASE_HEX, NULL, 0x00000020,
3724             NULL, HFILL}
3725         },
3726         { &hf_ctn_application_parameter_data_parameter_mask_originator_address,
3727           { "Originator Address", "btobex.parameter.ctn.parameter_mask.originator_address",
3728             FT_UINT32, BASE_HEX, NULL, 0x00000010,
3729             NULL, HFILL}
3730         },
3731         { &hf_ctn_application_parameter_data_parameter_mask_originator_name,
3732           { "Originator Name", "btobex.parameter.ctn.parameter_mask.originator_name",
3733             FT_UINT32, BASE_HEX, NULL, 0x00000008,
3734             NULL, HFILL}
3735         },
3736         { &hf_ctn_application_parameter_data_parameter_mask_end_time,
3737           { "End Time", "btobex.parameter.ctn.parameter_mask.end_time",
3738             FT_UINT32, BASE_HEX, NULL, 0x00000004,
3739             NULL, HFILL}
3740         },
3741         { &hf_ctn_application_parameter_data_parameter_mask_summary,
3742           { "Summary", "btobex.parameter.ctn.parameter_mask.summary",
3743             FT_UINT32, BASE_HEX, NULL, 0x00000002,
3744             NULL, HFILL}
3745         },
3746         { &hf_ctn_application_parameter_data_parameter_mask_attachment,
3747           { "Attachment", "btobex.parameter.ctn.parameter_mask.attachment",
3748             FT_UINT32, BASE_HEX, NULL, 0x00000001,
3749             NULL, HFILL}
3750         },
3751         { &hf_ctn_application_parameter_data_status_indicator,
3752           { "Status Indicator", "btobex.parameter.ctn.status_indicator",
3753             FT_UINT8, BASE_HEX, VALS(ctn_application_parameter_data_status_indicator_vals), 0x00,
3754             NULL, HFILL}
3755         },
3756         { &hf_ctn_application_parameter_data_status_value,
3757           { "Status Value", "btobex.parameter.ctn.status_value",
3758             FT_UINT8, BASE_HEX, VALS(ctn_application_parameter_data_status_value_vals), 0x00,
3759             NULL, HFILL}
3760         },
3761         { &hf_ctn_application_parameter_data_postpone_val,
3762           { "Postpone Val", "btobex.parameter.ctn.postpone_val",
3763             FT_UINT32, BASE_DEC, NULL, 0x00,
3764             NULL, HFILL}
3765         },
3766         { &hf_ctn_application_parameter_data_email_uri,
3767           { "Email URI", "btobex.parameter.ctn.email_uri",
3768             FT_STRING, STR_ASCII, NULL, 0x00,
3769             NULL, HFILL}
3770         },
3771         { &hf_ctn_application_parameter_data_cse_time,
3772           { "CSE Time", "btobex.parameter.ctn.cse_time",
3773             FT_STRING, STR_ASCII, NULL, 0x00,
3774             NULL, HFILL}
3775         },
3776         { &hf_ctn_application_parameter_data_recurrent,
3777           { "Recurrent", "btobex.parameter.ctn.recurrent",
3778             FT_UINT8, BASE_HEX, VALS(no_yes_vals), 0x00,
3779             NULL, HFILL}
3780         },
3781         { &hf_ctn_application_parameter_data_attach_id,
3782           { "Attach ID", "btobex.parameter.ctn.attach_id",
3783             FT_UINT8, BASE_DEC, NULL, 0x00,
3784             NULL, HFILL}
3785         },
3786         { &hf_ctn_application_parameter_data_last_update,
3787           { "Last Update", "btobex.parameter.ctn.last_update",
3788             FT_STRING, STR_ASCII, NULL, 0x00,
3789             NULL, HFILL}
3790         },
3791         /* for fragmentation */
3792         { &hf_btobex_fragment_overlap,
3793           { "Fragment overlap",   "btobex.fragment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3794             "Fragment overlaps with other fragments", HFILL }
3795         },
3796         { &hf_btobex_fragment_overlap_conflict,
3797           { "Conflicting data in fragment overlap",   "btobex.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3798             "Overlapping fragments contained conflicting data", HFILL }
3799         },
3800         { &hf_btobex_fragment_multiple_tails,
3801           { "Multiple tail fragments found",  "btobex.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3802             "Several tails were found when defragmenting the packet", HFILL }
3803         },
3804         { &hf_btobex_fragment_too_long_fragment,
3805           { "Fragment too long",  "btobex.fragment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3806             "Fragment contained data past end of packet", HFILL }
3807         },
3808         { &hf_btobex_fragment_error,
3809           { "Defragmentation error", "btobex.fragment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3810             "Defragmentation error due to illegal fragments", HFILL }
3811         },
3812         { &hf_btobex_fragment_count,
3813           { "Fragment count", "btobex.fragment.count", FT_UINT32, BASE_DEC, NULL, 0x0,
3814             NULL, HFILL }
3815         },
3816         { &hf_btobex_fragment,
3817           { "OBEX Fragment", "btobex.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3818             "btobex Fragment", HFILL }
3819         },
3820         { &hf_btobex_fragments,
3821           { "OBEX Fragments", "btobex.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
3822             "btobex Fragments", HFILL }
3823         },
3824         { &hf_btobex_reassembled_in,
3825           { "Reassembled OBEX in frame", "btobex.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3826             "This OBEX frame is reassembled in this frame", HFILL }
3827         },
3828         { &hf_btobex_reassembled_length,
3829           { "Reassembled OBEX length", "btobex.reassembled.length", FT_UINT32, BASE_DEC, NULL, 0x0,
3830             "The total length of the reassembled payload", HFILL }
3831         },
3832         { &hf_profile,
3833           { "Profile", "btobex.profile", FT_UINT32, BASE_DEC | BASE_EXT_STRING, &profile_vals_ext, 0x0,
3834             "Blutooth Profile used in this OBEX session", HFILL }
3835         },
3836         { &hf_type,
3837           { "Type", "btobex.type", FT_STRINGZ, STR_ASCII, NULL, 0x0,
3838             NULL, HFILL }
3839         },
3840         { &hf_object_class,
3841           { "Object Class", "btobex.object_class", FT_STRINGZ, STR_ASCII, NULL, 0x0,
3842             NULL, HFILL }
3843         },
3844         { &hf_time_iso8601,
3845           { "Time", "btobex.time", FT_STRINGZ, STR_ASCII, NULL, 0x0,
3846             NULL, HFILL }
3847         },
3848         { &hf_hdr_val_action,
3849           { "Action", "btobex.action", FT_UINT8, BASE_DEC, VALS(action_vals), 0x0,
3850             NULL, HFILL }
3851         },
3852         { &hf_hdr_val_single_response_mode,
3853           { "Single Response Mode", "btobex.single_response_mode", FT_UINT8, BASE_DEC, VALS(single_response_mode_vals), 0x0,
3854             NULL, HFILL }
3855         },
3856         { &hf_hdr_val_single_response_mode_parameter,
3857           { "Single Response Mode Parameter", "btobex.single_response_mode_parameter", FT_UINT8, BASE_DEC, VALS(single_response_mode_parameter_vals), 0x0,
3858             NULL, HFILL }
3859         },
3860         { &hf_wan_uuid,
3861             { "WAN UUID",   "btobex.wan_uuid",
3862             FT_UINT16, BASE_HEX, NULL, 0x00,
3863             NULL, HFILL }
3864         },
3865         { &hf_sender_bd_addr,
3866             { "Sender Address", "btobex.sender_bd_addr",
3867             FT_ETHER, BASE_NONE, NULL, 0x0,
3868             NULL, HFILL }
3869         },
3870         { &hf_name,
3871           { "Name", "btobex.name",
3872             FT_STRING, BASE_NONE, NULL, 0,
3873             NULL, HFILL }
3874         },
3875         { &hf_current_path,
3876           { "Current Path", "btobex.current_path",
3877             FT_STRINGZ, BASE_NONE, NULL, 0,
3878             NULL, HFILL }
3879         },
3880         { &hf_request_in_frame,
3881           { "Request in Frame", "btobex.request_in_frame", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
3882             NULL, HFILL}
3883         },
3884         { &hf_response_in_frame,
3885           { "Response in Frame", "btobex.response_in_frame", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
3886             NULL, HFILL}
3887         }
3888     };
3889
3890     /* Setup protocol subtree array */
3891     static gint *ett[] = {
3892         &ett_btobex,
3893         &ett_btobex_hdrs,
3894         &ett_btobex_hdr,
3895         &ett_btobex_hdr_id,
3896         &ett_btobex_filter,
3897         &ett_btobex_parameter,
3898         &ett_btobex_fragment,
3899         &ett_btobex_fragments,
3900         &ett_btobex_session_parameters,
3901         &ett_btobex_application_parameters,
3902         &ett_btobex_authentication_parameters
3903     };
3904
3905     static ei_register_info ei[] = {
3906         { &ei_application_parameter_length_bad, { "btobex.parameter.length.bad", PI_PROTOCOL, PI_WARN, "Parameter length bad", EXPFILL }},
3907         { &ei_unexpected_data, { "btobex.expert.unexpected_data", PI_PROTOCOL, PI_WARN, "Unexpected data", EXPFILL }},
3908         { &ei_decoded_as_profile, { "btobex.expert.decoded_as.profile", PI_PROTOCOL, PI_NOTE, "Decoded As", EXPFILL }},
3909     };
3910
3911     /* Decode As handling */
3912     static build_valid_func btobex_profile_da_build_value[1] = {btobex_profile_value};
3913     static decode_as_value_t btobex_profile_da_values = {btobex_profile_prompt, 1, btobex_profile_da_build_value};
3914     static decode_as_t btobex_profile_da = {"btobex", "OBEX Profile", "btobex.profile", 1, 0, &btobex_profile_da_values, NULL, NULL,
3915             decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
3916
3917     static build_valid_func media_type_da_build_value[1] = {media_type_value};
3918     static decode_as_value_t media_type_da_values = {media_type_prompt, 1, media_type_da_build_value};
3919     static decode_as_t media_type_da = {"btobex", "Media Type", "media_type",
3920             1, 0, &media_type_da_values, NULL, NULL,
3921             decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
3922
3923
3924     obex_path        = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
3925     obex_profile     = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
3926     obex_last_opcode = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
3927
3928     proto_btobex = proto_register_protocol("Bluetooth OBEX Protocol", "BT OBEX", "btobex");
3929
3930     btobex_handle = new_register_dissector("btobex", dissect_btobex, proto_btobex);
3931
3932     btobex_profile = register_dissector_table("btobex.profile", "BTOBEX Profile", FT_UINT8, BASE_DEC);
3933
3934     /* Required function calls to register the header fields and subtrees used */
3935     proto_register_field_array(proto_btobex, hf, array_length(hf));
3936     proto_register_subtree_array(ett, array_length(ett));
3937     expert_btobex = expert_register_protocol(proto_btobex);
3938     expert_register_field_array(expert_btobex, ei, array_length(ei));
3939
3940     register_init_routine(&defragment_init);
3941     register_cleanup_routine(&defragment_cleanup);
3942
3943     register_decode_as(&btobex_profile_da);
3944
3945     proto_raw = proto_register_protocol("BT OBEX Raw Application Parameters", "Raw Application Parameters", "btobex.parameter.raw");
3946     raw_application_parameters_handle  = new_register_dissector("btobex.parameter.raw",  dissect_btobex_application_parameter_raw, proto_raw);
3947
3948     proto_bpp = proto_register_protocol("BT OBEX BPP Application Parameters", "BPP Application Parameters", "btobex.parameter.bpp");
3949     bpp_application_parameters_handle  = new_register_dissector("btobex.parameter.bpp",  dissect_btobex_application_parameter_bpp, proto_bpp);
3950
3951     proto_bip = proto_register_protocol("BT OBEX BIP Application Parameters", "BIP Application Parameters", "btobex.parameter.bip");
3952     bip_application_parameters_handle  = new_register_dissector("btobex.parameter.bip",  dissect_btobex_application_parameter_bip, proto_bip);
3953
3954     proto_map = proto_register_protocol("BT OBEX MAP Application Parameters", "MAP Application Parameters", "btobex.parameter.map");
3955     map_application_parameters_handle  = new_register_dissector("btobex.parameter.map",  dissect_btobex_application_parameter_map, proto_map);
3956
3957     proto_gpp = proto_register_protocol("BT OBEX GPP Application Parameters", "GPP Application Parameters", "btobex.parameter.gpp");
3958     gpp_application_parameters_handle  = new_register_dissector("btobex.parameter.gpp",  dissect_btobex_application_parameter_gpp, proto_gpp);
3959
3960     proto_ctn = proto_register_protocol("BT OBEX CTN Application Parameters", "CTN Application Parameters", "btobex.parameter.ctn");
3961     ctn_application_parameters_handle  = new_register_dissector("btobex.parameter.ctn",  dissect_btobex_application_parameter_ctn, proto_ctn);
3962
3963     proto_pbap = proto_register_protocol("BT OBEX PBAP Application Parameters", "PBAP Application Parameters", "btobex.parameter.pbap");
3964     pbap_application_parameters_handle = new_register_dissector("btobex.parameter.pbap", dissect_btobex_application_parameter_pbap, proto_pbap);
3965
3966     register_decode_as(&media_type_da);
3967
3968     module = prefs_register_protocol(proto_btobex, NULL);
3969     prefs_register_static_text_preference(module, "obex.version",
3970             "Bluetooth Protocol OBEX support profiles: BIP 1.2, BPP 1.2, CTN 1.0, FTP 1.3, GOEP 1.3, GPP 1.0, MAP 1.2, OPP 1.2, PBAP 1.2, SYNCH 1.2",
3971             "Version of profiles supported by this dissector.");
3972 }
3973
3974 void
3975 proto_reg_handoff_btobex(void)
3976 {
3977     /* register in rfcomm and l2cap the profiles/services this dissector should handle */
3978     dissector_add_uint("btrfcomm.service", BTSDP_OPP_SERVICE_UUID,                          btobex_handle);
3979     dissector_add_uint("btrfcomm.service", BTSDP_FTP_SERVICE_UUID,                          btobex_handle);
3980     dissector_add_uint("btrfcomm.service", BTSDP_BPP_DIRECT_PRINTING_SERVICE_UUID,          btobex_handle);
3981     dissector_add_uint("btrfcomm.service", BTSDP_BPP_REFERENCE_PRINTING_SERVICE_UUID,       btobex_handle);
3982     dissector_add_uint("btrfcomm.service", BTSDP_BPP_DIRECT_PRINTING_REF_OBJ_SERVICE_UUID,  btobex_handle);
3983     dissector_add_uint("btrfcomm.service", BTSDP_BPP_REFLECTED_UI_SERVICE_UUID,             btobex_handle);
3984     dissector_add_uint("btrfcomm.service", BTSDP_BPP_SERVICE_UUID,                          btobex_handle);
3985     dissector_add_uint("btrfcomm.service", BTSDP_BPP_STATUS_SERVICE_UUID,                   btobex_handle);
3986     dissector_add_uint("btrfcomm.service", BTSDP_BIP_SERVICE_UUID,                          btobex_handle);
3987     dissector_add_uint("btrfcomm.service", BTSDP_BIP_RESPONDER_SERVICE_UUID,                btobex_handle);
3988     dissector_add_uint("btrfcomm.service", BTSDP_BIP_AUTO_ARCH_SERVICE_UUID,                btobex_handle);
3989     dissector_add_uint("btrfcomm.service", BTSDP_BIP_REF_OBJ_SERVICE_UUID,                  btobex_handle);
3990     dissector_add_uint("btrfcomm.service", BTSDP_PBAP_PCE_SERVICE_UUID,                     btobex_handle);
3991     dissector_add_uint("btrfcomm.service", BTSDP_PBAP_PSE_SERVICE_UUID,                     btobex_handle);
3992     dissector_add_uint("btrfcomm.service", BTSDP_PBAP_SERVICE_UUID,                         btobex_handle);
3993     dissector_add_uint("btrfcomm.service", BTSDP_MAP_SERVICE_UUID,                          btobex_handle);
3994     dissector_add_uint("btrfcomm.service", BTSDP_MAP_ACCESS_SRV_SERVICE_UUID,               btobex_handle);
3995     dissector_add_uint("btrfcomm.service", BTSDP_MAP_NOTIFICATION_SRV_SERVICE_UUID,         btobex_handle);
3996     dissector_add_uint("btrfcomm.service", BTSDP_SYNC_SERVICE_UUID,                         btobex_handle);
3997     dissector_add_uint("btrfcomm.service", BTSDP_SYNC_COMMAND_SERVICE_UUID,                 btobex_handle);
3998
3999     dissector_add_uint("btl2cap.service",  BTSDP_OPP_SERVICE_UUID,                          btobex_handle);
4000     dissector_add_uint("btl2cap.service",  BTSDP_FTP_SERVICE_UUID,                          btobex_handle);
4001     dissector_add_uint("btl2cap.service",  BTSDP_BPP_DIRECT_PRINTING_SERVICE_UUID,          btobex_handle);
4002     dissector_add_uint("btl2cap.service",  BTSDP_BPP_REFERENCE_PRINTING_SERVICE_UUID,       btobex_handle);
4003     dissector_add_uint("btl2cap.service",  BTSDP_BPP_DIRECT_PRINTING_REF_OBJ_SERVICE_UUID,  btobex_handle);
4004     dissector_add_uint("btl2cap.service",  BTSDP_BPP_REFLECTED_UI_SERVICE_UUID,             btobex_handle);
4005     dissector_add_uint("btl2cap.service",  BTSDP_BPP_SERVICE_UUID,                          btobex_handle);
4006     dissector_add_uint("btl2cap.service",  BTSDP_BPP_STATUS_SERVICE_UUID,                   btobex_handle);
4007     dissector_add_uint("btl2cap.service",  BTSDP_BIP_SERVICE_UUID,                          btobex_handle);
4008     dissector_add_uint("btl2cap.service",  BTSDP_BIP_RESPONDER_SERVICE_UUID,                btobex_handle);
4009     dissector_add_uint("btl2cap.service",  BTSDP_BIP_AUTO_ARCH_SERVICE_UUID,                btobex_handle);
4010     dissector_add_uint("btl2cap.service",  BTSDP_BIP_REF_OBJ_SERVICE_UUID,                  btobex_handle);
4011     dissector_add_uint("btl2cap.service",  BTSDP_PBAP_PCE_SERVICE_UUID,                     btobex_handle);
4012     dissector_add_uint("btl2cap.service",  BTSDP_PBAP_PSE_SERVICE_UUID,                     btobex_handle);
4013     dissector_add_uint("btl2cap.service",  BTSDP_PBAP_SERVICE_UUID,                         btobex_handle);
4014     dissector_add_uint("btl2cap.service",  BTSDP_MAP_SERVICE_UUID,                          btobex_handle);
4015     dissector_add_uint("btl2cap.service",  BTSDP_MAP_ACCESS_SRV_SERVICE_UUID,               btobex_handle);
4016     dissector_add_uint("btl2cap.service",  BTSDP_MAP_NOTIFICATION_SRV_SERVICE_UUID,         btobex_handle);
4017     dissector_add_uint("btl2cap.service",  BTSDP_SYNC_SERVICE_UUID,                         btobex_handle);
4018     dissector_add_uint("btl2cap.service",  BTSDP_SYNC_COMMAND_SERVICE_UUID,                 btobex_handle);
4019
4020     http_handle = find_dissector("http");
4021     xml_handle  = find_dissector("xml");
4022     data_handle = find_dissector("data");
4023     data_text_lines_handle = find_dissector("data-text-lines");
4024
4025     dissector_add_uint("btobex.profile", PROFILE_UNKNOWN,  raw_application_parameters_handle);
4026     dissector_add_uint("btobex.profile", PROFILE_BPP,      bpp_application_parameters_handle);
4027     dissector_add_uint("btobex.profile", PROFILE_BIP,      bip_application_parameters_handle);
4028     dissector_add_uint("btobex.profile", PROFILE_CTN,      ctn_application_parameters_handle);
4029     dissector_add_uint("btobex.profile", PROFILE_GPP,      gpp_application_parameters_handle);
4030     dissector_add_uint("btobex.profile", PROFILE_MAP,      map_application_parameters_handle);
4031     dissector_add_uint("btobex.profile", PROFILE_PBAP,    pbap_application_parameters_handle);
4032
4033     dissector_add_uint("btobex.profile", PROFILE_OPP,      raw_application_parameters_handle);
4034     dissector_add_uint("btobex.profile", PROFILE_FTP,      raw_application_parameters_handle);
4035     dissector_add_uint("btobex.profile", PROFILE_SYNCML,   raw_application_parameters_handle);
4036     dissector_add_uint("btobex.profile", PROFILE_SYNC,     raw_application_parameters_handle);
4037
4038     dissector_add_for_decode_as("btrfcomm.channel", btobex_handle);
4039     dissector_add_for_decode_as("btl2cap.psm", btobex_handle);
4040     dissector_add_for_decode_as("btl2cap.cid", btobex_handle);
4041
4042     /* PBAP */
4043     dissector_add_string("media_type", "x-bt/phonebook",      data_text_lines_handle);
4044     dissector_add_string("media_type", "x-bt/vcard",          data_text_lines_handle);
4045     dissector_add_string("media_type", "x-bt/vcard-listing",  xml_handle);
4046     /* MAP */
4047     dissector_add_string("media_type", "x-bt/message",                       data_text_lines_handle);
4048     dissector_add_string("media_type", "x-bt/messageStatus",                 data_text_lines_handle);
4049     dissector_add_string("media_type", "x-bt/MAP-messageUpdate",             data_text_lines_handle);
4050     dissector_add_string("media_type", "x-bt/MAP-NotificationRegistration",  data_text_lines_handle);
4051     dissector_add_string("media_type", "x-bt/MASInstanceInformation",        data_text_lines_handle);
4052     dissector_add_string("media_type", "x-bt/MAP-msg-listing",               xml_handle);
4053     dissector_add_string("media_type", "x-bt/MAP-event-report",              xml_handle);
4054     dissector_add_string("media_type", "x-obex/folder-listing",              xml_handle);
4055     /* CTN */
4056     dissector_add_string("media_type", "x-bt/CTN-EventReport",              xml_handle);
4057     dissector_add_string("media_type", "x-bt/CTN-Listing",                  xml_handle);
4058     dissector_add_string("media_type", "x-bt/CTN-NotificationRegistration", data_text_lines_handle);
4059     dissector_add_string("media_type", "x-bt/Calendar",                     data_text_lines_handle);
4060     dissector_add_string("media_type", "x-bt/CalendarStatus",               data_text_lines_handle);
4061     dissector_add_string("media_type", "x-bt/CTN-forward",                  data_text_lines_handle);
4062     dissector_add_string("media_type", "x-bt/InstanceDescription",          data_text_lines_handle);
4063     dissector_add_string("media_type", "x-bt/Update",                       data_text_lines_handle);
4064     /* BPP */
4065     dissector_add_string("media_type", "text/x-ref-simple",                 data_text_lines_handle);
4066     dissector_add_string("media_type", "text/x-ref-list",                   data_text_lines_handle);
4067     dissector_add_string("media_type", "x-obex/RUI",                        data_text_lines_handle);
4068     dissector_add_string("media_type", "x-obex/bt-SOAP",                    xml_handle);
4069     /* BIP */
4070     dissector_add_string("media_type", "x-bt/img-listing",                  xml_handle);
4071     dissector_add_string("media_type", "x-bt/img-properties",               xml_handle);
4072     dissector_add_string("media_type", "x-bt/img-capabilities",             xml_handle);
4073     dissector_add_string("media_type", "x-bt/img-print",                    data_text_lines_handle);
4074     dissector_add_string("media_type", "x-bt/img-img",                      data_handle);
4075     dissector_add_string("media_type", "x-bt/img-thm",                      data_handle);
4076     dissector_add_string("media_type", "x-bt/img-attachment",               data_handle);
4077     dissector_add_string("media_type", "x-bt/img-display",                  data_handle);
4078     dissector_add_string("media_type", "x-bt/img-partial",                  data_handle);
4079     dissector_add_string("media_type", "x-bt/img-archive",                  data_handle);
4080     dissector_add_string("media_type", "x-bt/img-status",                   data_handle);
4081     dissector_add_string("media_type", "x-bt/img-monitoring",               data_handle);
4082
4083     media_type_dissector_table = find_dissector_table("media_type");
4084 }
4085
4086 /*
4087  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
4088  *
4089  * Local variables:
4090  * c-basic-offset: 4
4091  * tab-width: 8
4092  * indent-tabs-mode: nil
4093  * End:
4094  *
4095  * vi: set shiftwidth=4 tabstop=8 expandtab:
4096  * :indentSize=4:tabSize=8:noTabs=true:
4097  */