From Jouni Malinen via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8711 Wi...
[metze/wireshark/wip.git] / epan / dissectors / packet-wifi-p2p.c
1 /* packet-wifi-p2p.c
2  *
3  * Wi-Fi P2P
4  *
5  * Copyright 2009-2010 Atheros Communications
6  *
7  * $Id$
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24 #include "config.h"
25
26 #include <glib.h>
27 #include <epan/packet.h>
28 #include <epan/expert.h>
29
30 #include "packet-ieee80211.h"
31 #include "packet-wifi-p2p.h"
32
33 enum {
34   P2P_ATTR_STATUS = 0,
35   P2P_ATTR_MINOR_REASON_CODE = 1,
36   P2P_ATTR_P2P_CAPABILITY = 2,
37   P2P_ATTR_P2P_DEVICE_ID = 3,
38   P2P_ATTR_GROUP_OWNER_INTENT = 4,
39   P2P_ATTR_CONFIGURATION_TIMEOUT = 5,
40   P2P_ATTR_LISTEN_CHANNEL = 6,
41   P2P_ATTR_P2P_GROUP_BSSID = 7,
42   P2P_ATTR_EXTENDED_LISTEN_TIMING = 8,
43   P2P_ATTR_INTENDED_P2P_INTERFACE_ADDRESS = 9,
44   P2P_ATTR_P2P_MANAGEABILITY = 10,
45   P2P_ATTR_CHANNEL_LIST = 11,
46   P2P_ATTR_NOTICE_OF_ABSENCE = 12,
47   P2P_ATTR_P2P_DEVICE_INFO = 13,
48   P2P_ATTR_P2P_GROUP_INFO = 14,
49   P2P_ATTR_P2P_GROUP_ID = 15,
50   P2P_ATTR_P2P_INTERFACE = 16,
51   P2P_ATTR_OPERATING_CHANNEL = 17,
52   P2P_ATTR_INVITATION_FLAGS = 18,
53   /* 19-220 Reserved */
54   P2P_ATTR_VENDOR_SPECIFIC = 221
55   /* 222-255 Reserved */
56 };
57
58 static const value_string p2p_attr_types[] = {
59   { P2P_ATTR_STATUS, "Status" },
60   { P2P_ATTR_MINOR_REASON_CODE, "Minor Reason Code" },
61   { P2P_ATTR_P2P_CAPABILITY, "P2P Capability" },
62   { P2P_ATTR_P2P_DEVICE_ID, "P2P Device ID" },
63   { P2P_ATTR_GROUP_OWNER_INTENT, "Group Owner Intent" },
64   { P2P_ATTR_CONFIGURATION_TIMEOUT, "Configuration Timeout" },
65   { P2P_ATTR_LISTEN_CHANNEL, "Listen Channel" },
66   { P2P_ATTR_P2P_GROUP_BSSID, "P2P Group BSSID" },
67   { P2P_ATTR_EXTENDED_LISTEN_TIMING, "Extended Listen Timing" },
68   { P2P_ATTR_INTENDED_P2P_INTERFACE_ADDRESS,
69     "Intended P2P Interface Address" },
70   { P2P_ATTR_P2P_MANAGEABILITY, "P2P Manageability" },
71   { P2P_ATTR_CHANNEL_LIST, "Channel List" },
72   { P2P_ATTR_NOTICE_OF_ABSENCE, "Notice of Absence" },
73   { P2P_ATTR_P2P_DEVICE_INFO, "P2P Device Info" },
74   { P2P_ATTR_P2P_GROUP_INFO, "P2P Group Info" },
75   { P2P_ATTR_P2P_GROUP_ID, "P2P Group ID" },
76   { P2P_ATTR_P2P_INTERFACE, "P2P Interface" },
77   { P2P_ATTR_OPERATING_CHANNEL, "Operating Channel" },
78   { P2P_ATTR_INVITATION_FLAGS, "Invitation Flags" },
79   { P2P_ATTR_VENDOR_SPECIFIC, "Vendor specific attribute" },
80   { 0, NULL }
81 };
82
83 #define P2P_DEV_CAPAB_SERVICE_DISCOVERY 0x01
84 #define P2P_DEV_CAPAB_P2P_CLIENT_DISCOVERABILITY 0x02
85 #define P2P_DEV_CAPAB_CONCURRENT_OPERATION 0x04
86 #define P2P_DEV_CAPAB_P2P_INFRASTRUCTURE_MANAGED 0x08
87 #define P2P_DEV_CAPAB_P2P_DEVICE_LIMIT 0x10
88 #define P2P_DEV_CAPAB_P2P_INVITATION_PROCEDURE 0x20
89
90 #define P2P_GROUP_CAPAB_P2P_GROUP_OWNER 0x01
91 #define P2P_GROUP_CAPAB_PERSISTENT_P2P_GROUP 0x02
92 #define P2P_GROUP_CAPAB_P2P_GROUP_LIMIT 0x04
93 #define P2P_GROUP_CAPAB_INTRA_BSS_DISTRIBUTION 0x08
94 #define P2P_GROUP_CAPAB_CROSS_CONNECTION 0x10
95 #define P2P_GROUP_CAPAB_PERSISTENT_RECONNECT 0x20
96 #define P2P_GROUP_CAPAB_GROUP_FORMATION 0x40
97
98 #define WPS_CONF_METH_USBA 0x0001
99 #define WPS_CONF_METH_ETHERNET 0x0002
100 #define WPS_CONF_METH_LABEL 0x0004
101 #define WPS_CONF_METH_DISPLAY 0x0008
102 #define WPS_CONF_METH_EXT_NFC_TOKEN 0x0010
103 #define WPS_CONF_METH_INT_NFC_TOKEN 0x0020
104 #define WPS_CONF_METH_NFC_INTERFACE 0x0040
105 #define WPS_CONF_METH_PUSHBUTTON 0x0080
106 #define WPS_CONF_METH_KEYPAD 0x0100
107
108 enum {
109   P2P_ACT_GO_NEG_REQ = 0,
110   P2P_ACT_GO_NEG_RESP = 1,
111   P2P_ACT_GO_NEG_CONF = 2,
112   P2P_ACT_INVITATION_REQ = 3,
113   P2P_ACT_INVITATION_RESP = 4,
114   P2P_ACT_DEV_DISC_REQ = 5,
115   P2P_ACT_DEV_DISC_RESP = 6,
116   P2P_ACT_PROV_DISC_REQ = 7,
117   P2P_ACT_PROV_DISC_RESP = 8
118 };
119
120 static const value_string p2p_public_action_subtypes[] = {
121   { P2P_ACT_GO_NEG_REQ, "GO Negotiation Request" },
122   { P2P_ACT_GO_NEG_RESP, "GO Negotiation Response" },
123   { P2P_ACT_GO_NEG_CONF, "GO Negotiation Confirmation" },
124   { P2P_ACT_INVITATION_REQ, "P2P Invitation Request" },
125   { P2P_ACT_INVITATION_RESP, "P2P Invitation Response" },
126   { P2P_ACT_DEV_DISC_REQ, "Device Discoverability Request" },
127   { P2P_ACT_DEV_DISC_RESP, "Device Discoverability Response" },
128   { P2P_ACT_PROV_DISC_REQ, "Provision Discovery Request" },
129   { P2P_ACT_PROV_DISC_RESP, "Provision Discovery Response" },
130   { 0, NULL }
131 };
132
133 enum {
134   P2P_ACT_NOA = 0,
135   P2P_ACT_P2P_PRESENCE_REQ = 1,
136   P2P_ACT_P2P_PRESENCE_RESP = 2,
137   P2P_ACT_GO_DISC_REQ = 3
138 };
139
140 static const value_string p2p_action_subtypes[] = {
141   { P2P_ACT_NOA, "Notice of Absence" },
142   { P2P_ACT_P2P_PRESENCE_REQ, "P2P Presence Request" },
143   { P2P_ACT_P2P_PRESENCE_RESP, "P2P Presence Response" },
144   { P2P_ACT_GO_DISC_REQ, "GO Discoverability Request" },
145   { 0, NULL }
146 };
147
148 enum {
149   P2P_STATUS_SUCCESS = 0,
150   P2P_FAIL_INFORMATION_CURRENTLY_UNAVAILABLE = 1,
151   P2P_FAIL_INCOMPATIBLE_PARAMETERS = 2,
152   P2P_FAIL_LIMIT_REACHED = 3,
153   P2P_FAIL_INVALID_PARAMETERS = 4,
154   P2P_FAIL_UNABLE_TO_ACCOMMODATE = 5,
155   P2P_FAIL_PREVIOUS_PROTOCOL_ERROR = 6,
156   P2P_FAIL_NO_COMMON_CHANNELS = 7,
157   P2P_FAIL_UNKNOWN_P2P_GROUP = 8,
158   P2P_FAIL_BOTH_DEVICES_GO = 9,
159   P2P_FAIL_INCOMPATIBLE_PROVISION_METHOD = 10,
160   P2P_FAIL_REJECTED_BY_USER = 11
161 };
162
163 static const value_string p2p_status_codes[] = {
164   { P2P_STATUS_SUCCESS, "Success" },
165   { P2P_FAIL_INFORMATION_CURRENTLY_UNAVAILABLE, "Fail; information is "
166     "currently unavailable" },
167   { P2P_FAIL_INCOMPATIBLE_PARAMETERS, "Fail; incompatible parameters" },
168   { P2P_FAIL_LIMIT_REACHED, "Fail; limit reached" },
169   { P2P_FAIL_INVALID_PARAMETERS, "Fail; invalid parameters" },
170   { P2P_FAIL_UNABLE_TO_ACCOMMODATE, "Fail; unable to accommodate request" },
171   { P2P_FAIL_PREVIOUS_PROTOCOL_ERROR, "Fail; previous protocol error, or "
172     "disruptive behavior" },
173   { P2P_FAIL_NO_COMMON_CHANNELS, "Fail; no common channels" },
174   { P2P_FAIL_UNKNOWN_P2P_GROUP, "Fail; unknown P2P Group" },
175   { P2P_FAIL_BOTH_DEVICES_GO, "Fail; both P2P Devices indicated an Intent of "
176     "15 in Group Owner Negotiation" },
177   { P2P_FAIL_INCOMPATIBLE_PROVISION_METHOD, "Fail; incompatible provisioning "
178     "method" },
179   { P2P_FAIL_REJECTED_BY_USER, "Fail; rejected by user" },
180   { 0, NULL }
181 };
182
183 enum {
184   P2P_MINOR_RESERVED = 0,
185   P2P_MINOR_DISCONNECT_DUE_TO_CROSS_CONNECTION = 1,
186   P2P_MINOR_DISCONNECT_DUE_TO_NOT_P2P_MANAGED = 2,
187   P2P_MINOR_DISCONNECT_DUE_TO_NO_COEXISTENCE = 3,
188   P2P_MINOR_DISCONNECT_DUE_TO_OUTSIDE_POLICY = 4
189 };
190
191 static const value_string p2p_minor_reason_codes[] = {
192   { P2P_MINOR_RESERVED, "Reserved" },
193   { P2P_MINOR_DISCONNECT_DUE_TO_CROSS_CONNECTION,
194     "Disconnected because Cross Connection capability is not allow" },
195   { P2P_MINOR_DISCONNECT_DUE_TO_NOT_P2P_MANAGED,
196     "Disconnected because P2P Infrastructure Managed not supported" },
197   { P2P_MINOR_DISCONNECT_DUE_TO_NO_COEXISTENCE,
198     "Disconnected because concurrent device is not setting coexistence "
199     "parameters" },
200   { P2P_MINOR_DISCONNECT_DUE_TO_OUTSIDE_POLICY,
201     "Disconnected because P2P operation is outside the IT defined policy" },
202   { 0, NULL }
203 };
204
205 static const value_string invitation_types[] = {
206   { 0, "Join active P2P Group" },
207   { 1, "Reinvoke Persistent Group" },
208   { 0, NULL }
209 };
210
211 static const value_string p2p_service_protocol_types[] = {
212   { 0, "All Service Protocol Types" },
213   { 1, "Bonjour" },
214   { 2, "UPnP" },
215   { 3, "WS-Discovery" },
216   { 4, "Wi-Fi Display" },
217   { 0, NULL }
218 };
219
220 static const value_string p2p_sd_status_codes[] = {
221   { 0, "Success" },
222   { 1, "Service Protocol Type not available" },
223   { 2, "Requested information not available" },
224   { 3, "Bad Request" },
225   { 0, NULL }
226 };
227
228 static int proto_p2p = -1;
229
230 static gint ett_p2p_tlv = -1;
231 static gint ett_p2p_service_tlv = -1;
232 static gint ett_p2p_client_descr = -1;
233
234 static int hf_p2p_attr_type = -1;
235 static int hf_p2p_attr_len = -1;
236
237 /* static int hf_p2p_attr_capab = -1; */
238 static int hf_p2p_attr_capab_device = -1;
239 static int hf_p2p_attr_capab_device_service_discovery = -1;
240 static int hf_p2p_attr_capab_device_client_discoverability = -1;
241 static int hf_p2p_attr_capab_device_concurrent_operation = -1;
242 static int hf_p2p_attr_capab_device_infrastructure_managed = -1;
243 static int hf_p2p_attr_capab_device_limit = -1;
244 static int hf_p2p_attr_capab_invitation_procedure = -1;
245 static int hf_p2p_attr_capab_group = -1;
246 static int hf_p2p_attr_capab_group_owner = -1;
247 static int hf_p2p_attr_capab_group_persistent = -1;
248 static int hf_p2p_attr_capab_group_limit = -1;
249 static int hf_p2p_attr_capab_group_intra_bss_distribution = -1;
250 static int hf_p2p_attr_capab_group_cross_connection = -1;
251 static int hf_p2p_attr_capab_group_persistent_reconnect = -1;
252 static int hf_p2p_attr_capab_group_group_formation = -1;
253
254 static int hf_p2p_attr_device_id = -1;
255
256 static int hf_p2p_attr_status = -1;
257
258 static int hf_p2p_attr_go_intent = -1;
259 static int hf_p2p_attr_go_intent_tie_breaker = -1;
260
261 /* static int hf_p2p_attr_listen_channel = -1; */
262 static int hf_p2p_attr_listen_channel_country = -1;
263 static int hf_p2p_attr_listen_channel_oper_class = -1;
264 static int hf_p2p_attr_listen_channel_number = -1;
265
266 /* static int hf_p2p_attr_operating_channel = -1; */
267 static int hf_p2p_attr_operating_channel_country = -1;
268 static int hf_p2p_attr_operating_channel_oper_class = -1;
269 static int hf_p2p_attr_operating_channel_number = -1;
270
271 /* static int hf_p2p_attr_channel_list = -1; */
272 static int hf_p2p_attr_channel_list_country = -1;
273 static int hf_p2p_attr_channel_list_oper_class = -1;
274 static int hf_p2p_attr_channel_list_num_chan = -1;
275 static int hf_p2p_attr_channel_list_chan = -1;
276
277 /* static int hf_p2p_attr_dev_info = -1; */
278 static int hf_p2p_attr_dev_info_p2p_dev_addr = -1;
279 static int hf_p2p_attr_dev_info_pri_dev_type = -1;
280 static int hf_p2p_attr_dev_info_pri_dev_type_category = -1;
281 static int hf_p2p_attr_dev_info_pri_dev_type_oui = -1;
282 static int hf_p2p_attr_dev_info_pri_dev_type_subcategory = -1;
283 static int hf_p2p_attr_dev_info_num_sec = -1;
284 static int hf_p2p_attr_dev_info_sec_dev_type = -1;
285 static int hf_p2p_attr_dev_info_dev_name_type = -1;
286 static int hf_p2p_attr_dev_info_dev_name_len = -1;
287 static int hf_p2p_attr_dev_info_dev_name = -1;
288 static int hf_p2p_attr_dev_info_config_methods = -1;
289 static int hf_p2p_attr_dev_info_config_methods_usba = -1;
290 static int hf_p2p_attr_dev_info_config_methods_ethernet = -1;
291 static int hf_p2p_attr_dev_info_config_methods_label = -1;
292 static int hf_p2p_attr_dev_info_config_methods_display = -1;
293 static int hf_p2p_attr_dev_info_config_methods_ext_nfc_token = -1;
294 static int hf_p2p_attr_dev_info_config_methods_int_nfc_token = -1;
295 static int hf_p2p_attr_dev_info_config_methods_nfc_interface = -1;
296 static int hf_p2p_attr_dev_info_config_methods_pushbutton = -1;
297 static int hf_p2p_attr_dev_info_config_methods_keypad = -1;
298 static int hf_p2p_attr_config_timeout_go = -1;
299 static int hf_p2p_attr_config_timeout_client = -1;
300 static int hf_p2p_attr_intended_interface_addr = -1;
301 static int hf_p2p_attr_extended_listen_timing_period = -1;
302 static int hf_p2p_attr_extended_listen_timing_interval = -1;
303 static int hf_p2p_attr_p2p_group_id_dev_addr = -1;
304 static int hf_p2p_attr_p2p_group_id_ssid = -1;
305 static int hf_p2p_attr_p2p_group_bssid = -1;
306
307 static int hf_p2p_attr_noa_index = -1;
308 static int hf_p2p_attr_noa_params = -1;
309 static int hf_p2p_attr_noa_params_opp_ps = -1;
310 static int hf_p2p_attr_noa_params_ctwindow = -1;
311 static int hf_p2p_attr_noa_count_type = -1;
312 static int hf_p2p_attr_noa_duration = -1;
313 static int hf_p2p_attr_noa_interval = -1;
314 static int hf_p2p_attr_noa_start_time = -1;
315
316 /* static int hf_p2p_attr_gi = -1; */
317 static int hf_p2p_attr_gi_length = -1;
318 static int hf_p2p_attr_gi_p2p_dev_addr = -1;
319 static int hf_p2p_attr_gi_p2p_iface_addr = -1;
320 static int hf_p2p_attr_gi_dev_capab = -1;
321 static int hf_p2p_attr_gi_dev_capab_service_discovery = -1;
322 static int hf_p2p_attr_gi_dev_capab_client_discoverability = -1;
323 static int hf_p2p_attr_gi_dev_capab_concurrent_operation = -1;
324 static int hf_p2p_attr_gi_dev_capab_infrastructure_managed = -1;
325 static int hf_p2p_attr_gi_dev_capab_limit = -1;
326 /* static int hf_p2p_attr_gi_dev_capab_invitation_procedure = -1; */
327 static int hf_p2p_attr_gi_config_methods = -1;
328 /* static int hf_p2p_attr_gi_config_methods_usba = -1; */
329 /* static int hf_p2p_attr_gi_config_methods_ethernet = -1; */
330 /* static int hf_p2p_attr_gi_config_methods_label = -1; */
331 /* static int hf_p2p_attr_gi_config_methods_display = -1; */
332 /* static int hf_p2p_attr_gi_config_methods_ext_nfc_token = -1; */
333 /* static int hf_p2p_attr_gi_config_methods_int_nfc_token = -1; */
334 /* static int hf_p2p_attr_gi_config_methods_nfc_interface = -1; */
335 /* static int hf_p2p_attr_gi_config_methods_pushbutton = -1; */
336 /* static int hf_p2p_attr_gi_config_methods_keypad = -1; */
337 static int hf_p2p_attr_gi_pri_dev_type = -1;
338 static int hf_p2p_attr_gi_pri_dev_type_category = -1;
339 static int hf_p2p_attr_gi_pri_dev_type_oui = -1;
340 static int hf_p2p_attr_gi_pri_dev_type_subcategory = -1;
341 static int hf_p2p_attr_gi_num_sec_dev_types = -1;
342 static int hf_p2p_attr_gi_sec_dev_type = -1;
343 static int hf_p2p_attr_gi_dev_name_type = -1;
344 static int hf_p2p_attr_gi_dev_name_len = -1;
345 static int hf_p2p_attr_gi_dev_name = -1;
346
347 static int hf_p2p_attr_invitation_flags = -1;
348 static int hf_p2p_attr_invitation_flags_type = -1;
349
350 static int hf_p2p_attr_manageability_bitmap = -1;
351 static int hf_p2p_attr_manageability_bitmap_mgmt = -1;
352 static int hf_p2p_attr_manageability_bitmap_cross_connect = -1;
353 static int hf_p2p_attr_manageability_bitmap_coex_opt = -1;
354
355 static int hf_p2p_attr_minor_reason_code = -1;
356
357 static int hf_p2p_anqp_service_update_indicator = -1;
358 static int hf_p2p_anqp_length = -1;
359 static int hf_p2p_anqp_service_protocol_type = -1;
360 static int hf_p2p_anqp_service_transaction_id = -1;
361 static int hf_p2p_anqp_query_data = -1;
362 static int hf_p2p_anqp_status_code = -1;
363 static int hf_p2p_anqp_response_data = -1;
364
365 static int hf_p2p_action_subtype = -1;
366 static int hf_p2p_action_dialog_token = -1;
367 static int hf_p2p_public_action_subtype = -1;
368 static int hf_p2p_public_action_dialog_token = -1;
369
370 static void dissect_wifi_p2p_capability(proto_item *tlv_root,
371                                         proto_item *tlv_item,
372                                         tvbuff_t *tvb, int offset)
373 {
374   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_device, tvb,
375                       offset + 3, 1, ENC_BIG_ENDIAN);
376   proto_tree_add_item(tlv_root,
377                       hf_p2p_attr_capab_device_service_discovery, tvb,
378                       offset + 3, 1, ENC_BIG_ENDIAN);
379   proto_tree_add_item(tlv_root,
380                       hf_p2p_attr_capab_device_client_discoverability,
381                       tvb, offset + 3, 1, ENC_BIG_ENDIAN);
382   proto_tree_add_item(tlv_root,
383                       hf_p2p_attr_capab_device_concurrent_operation,
384                       tvb, offset + 3, 1, ENC_BIG_ENDIAN);
385   proto_tree_add_item(tlv_root,
386                       hf_p2p_attr_capab_device_infrastructure_managed,
387                       tvb, offset + 3, 1, ENC_BIG_ENDIAN);
388   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_device_limit, tvb,
389                       offset + 3, 1, ENC_BIG_ENDIAN);
390   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_invitation_procedure, tvb,
391                       offset + 3, 1, ENC_BIG_ENDIAN);
392
393   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_group,
394                       tvb, offset + 4, 1, ENC_BIG_ENDIAN);
395   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_group_owner,
396                       tvb, offset + 4, 1, ENC_BIG_ENDIAN);
397   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_group_persistent,
398                       tvb, offset + 4, 1, ENC_BIG_ENDIAN);
399   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_group_limit,
400                       tvb, offset + 4, 1, ENC_BIG_ENDIAN);
401   proto_tree_add_item(tlv_root,
402                       hf_p2p_attr_capab_group_intra_bss_distribution,
403                       tvb, offset + 4, 1, ENC_BIG_ENDIAN);
404   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_group_cross_connection,
405                       tvb, offset + 4, 1, ENC_BIG_ENDIAN);
406   proto_tree_add_item(tlv_root,
407                       hf_p2p_attr_capab_group_persistent_reconnect,
408                       tvb, offset + 4, 1, ENC_BIG_ENDIAN);
409   proto_tree_add_item(tlv_root, hf_p2p_attr_capab_group_group_formation,
410                       tvb, offset + 4, 1, ENC_BIG_ENDIAN);
411
412   proto_item_append_text(tlv_item, ": Device 0x%x  Group 0x%x",
413                          tvb_get_guint8(tvb, offset + 3),
414                          tvb_get_guint8(tvb, offset + 4));
415 }
416
417 static void dissect_device_id(proto_item *tlv_root, proto_item *tlv_item,
418                               tvbuff_t *tvb, int offset)
419 {
420   guint8 addr[6];
421   proto_tree_add_item(tlv_root, hf_p2p_attr_device_id, tvb,
422                       offset + 3, 6, ENC_NA);
423   tvb_memcpy(tvb, addr, offset + 3, 6);
424   proto_item_append_text(tlv_item, ": %s", ether_to_str(addr));
425 }
426
427 static void dissect_group_owner_intent(proto_item *tlv_root,
428                                        proto_item *tlv_item,
429                                        tvbuff_t *tvb, int offset)
430 {
431   proto_tree_add_item(tlv_root, hf_p2p_attr_go_intent, tvb,
432                       offset + 3, 1, ENC_BIG_ENDIAN);
433   proto_tree_add_item(tlv_root, hf_p2p_attr_go_intent_tie_breaker, tvb,
434                       offset + 3, 1, ENC_BIG_ENDIAN);
435   proto_item_append_text(tlv_item, ": Intent %u  Tie breaker %u",
436                          tvb_get_guint8(tvb, offset + 3) >> 1,
437                          tvb_get_guint8(tvb, offset + 3) & 0x01);
438 }
439
440 static void dissect_status(proto_item *tlv_root, proto_item *tlv_item,
441                            tvbuff_t *tvb, int offset)
442 {
443   proto_tree_add_item(tlv_root, hf_p2p_attr_status, tvb,
444                       offset + 3, 1, ENC_BIG_ENDIAN);
445   proto_item_append_text(tlv_item, ": %u (%s)",
446                          tvb_get_guint8(tvb, offset + 3),
447                          val_to_str(tvb_get_guint8(tvb, offset + 3),
448                                     p2p_status_codes,
449                                     "Unknown Status Code (%u)"));
450 }
451
452 static void dissect_listen_channel(proto_item *tlv_root, proto_item *tlv_item,
453                                    tvbuff_t *tvb, int offset)
454 {
455   proto_tree_add_item(tlv_root, hf_p2p_attr_listen_channel_country, tvb,
456                       offset + 3, 3, ENC_ASCII|ENC_NA);
457   proto_tree_add_item(tlv_root, hf_p2p_attr_listen_channel_oper_class, tvb,
458                       offset + 6, 1, ENC_BIG_ENDIAN);
459   proto_tree_add_item(tlv_root, hf_p2p_attr_listen_channel_number, tvb,
460                       offset + 7, 1, ENC_BIG_ENDIAN);
461   proto_item_append_text(tlv_item, ": Operating Class %u  "
462                          "Channel Number %u",
463                          tvb_get_guint8(tvb, offset + 6),
464                          tvb_get_guint8(tvb, offset + 7));
465 }
466
467 static void dissect_operating_channel(proto_item *tlv_root,
468                                       proto_item *tlv_item,
469                                       tvbuff_t *tvb, int offset)
470 {
471   proto_tree_add_item(tlv_root, hf_p2p_attr_operating_channel_country, tvb,
472                       offset + 3, 3, ENC_ASCII|ENC_NA);
473   proto_tree_add_item(tlv_root, hf_p2p_attr_operating_channel_oper_class, tvb,
474                       offset + 6, 1, ENC_BIG_ENDIAN);
475   proto_tree_add_item(tlv_root, hf_p2p_attr_operating_channel_number, tvb,
476                       offset + 7, 1, ENC_BIG_ENDIAN);
477   proto_item_append_text(tlv_item, ": Operating Class %u  "
478                          "Channel Number %u",
479                          tvb_get_guint8(tvb, offset + 6),
480                          tvb_get_guint8(tvb, offset + 7));
481 }
482
483 static void dissect_channel_list(proto_item *tlv_root, tvbuff_t *tvb,
484                                  int offset, guint16 slen)
485 {
486   int s_offset = offset + 3;
487   guint8 num_chan;
488
489   proto_tree_add_item(tlv_root, hf_p2p_attr_channel_list_country, tvb,
490                       s_offset, 3, ENC_ASCII|ENC_NA);
491   s_offset += 3;
492
493   while (offset + 3 + slen > s_offset) {
494     proto_tree_add_item(tlv_root, hf_p2p_attr_channel_list_oper_class, tvb,
495                         s_offset, 1, ENC_BIG_ENDIAN);
496     s_offset++;
497
498     proto_tree_add_item(tlv_root, hf_p2p_attr_channel_list_num_chan, tvb,
499                         s_offset, 1, ENC_BIG_ENDIAN);
500     num_chan = tvb_get_guint8(tvb, s_offset);
501     s_offset++;
502
503     proto_tree_add_item(tlv_root, hf_p2p_attr_channel_list_chan, tvb,
504                         s_offset, num_chan, ENC_NA);
505     s_offset += num_chan;
506   }
507 }
508
509 static void dissect_wifi_p2p_device_info(packet_info *pinfo,
510                                          proto_item *tlv_root, tvbuff_t *tvb,
511                                          int offset, guint16 slen)
512 {
513   int s_offset, nlen;
514   guint8 num_sec;
515   guint16 attr_type, attr_len;
516   proto_item *item;
517
518   s_offset = offset + 3;
519
520   proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_p2p_dev_addr, tvb,
521                       s_offset, 6, ENC_NA);
522   s_offset += 6;
523
524   proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_config_methods,
525                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
526   proto_tree_add_item(tlv_root,
527                       hf_p2p_attr_dev_info_config_methods_usba,
528                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
529   proto_tree_add_item(tlv_root,
530                       hf_p2p_attr_dev_info_config_methods_ethernet,
531                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
532   proto_tree_add_item(tlv_root,
533                       hf_p2p_attr_dev_info_config_methods_label,
534                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
535   proto_tree_add_item(tlv_root,
536                       hf_p2p_attr_dev_info_config_methods_display,
537                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
538   proto_tree_add_item(tlv_root,
539                       hf_p2p_attr_dev_info_config_methods_ext_nfc_token,
540                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
541   proto_tree_add_item(tlv_root,
542                       hf_p2p_attr_dev_info_config_methods_int_nfc_token,
543                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
544   proto_tree_add_item(tlv_root,
545                       hf_p2p_attr_dev_info_config_methods_nfc_interface,
546                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
547   proto_tree_add_item(tlv_root,
548                       hf_p2p_attr_dev_info_config_methods_pushbutton,
549                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
550   proto_tree_add_item(tlv_root,
551                       hf_p2p_attr_dev_info_config_methods_keypad,
552                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
553
554   s_offset += 2;
555
556   proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_pri_dev_type, tvb,
557                       s_offset, 8, ENC_NA);
558   proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_pri_dev_type_category,
559                       tvb, s_offset, 2, ENC_BIG_ENDIAN);
560   proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_pri_dev_type_oui,
561                       tvb, s_offset + 2, 4, ENC_NA);
562   proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_pri_dev_type_subcategory,
563                       tvb, s_offset + 6, 2, ENC_BIG_ENDIAN);
564   s_offset += 8;
565
566   num_sec = tvb_get_guint8(tvb, s_offset);
567   proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_num_sec, tvb,
568                       s_offset, 1, ENC_BIG_ENDIAN);
569   s_offset++;
570
571   while (num_sec > 0) {
572     proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_sec_dev_type,
573                         tvb, s_offset, 8, ENC_NA);
574     s_offset += 8;
575     num_sec--;
576   }
577
578   item = proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_dev_name_type,
579                              tvb, s_offset, 2, ENC_BIG_ENDIAN);
580   attr_type = tvb_get_ntohs(tvb, s_offset);
581   if (attr_type != 0x1011) {
582     expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
583                            "Incorrect Device Name attribute type");
584   }
585   s_offset += 2;
586   item = proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_dev_name_len,
587                              tvb, s_offset, 2, ENC_BIG_ENDIAN);
588   attr_len = tvb_get_ntohs(tvb, s_offset);
589   s_offset += 2;
590   if (attr_len > offset + 3 + slen - s_offset) {
591     expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
592                            "Invalid Device Name attribute length");
593     return;
594   }
595   nlen = offset + 3 + slen - s_offset;
596   if (nlen > 0)
597     item = proto_tree_add_item(tlv_root, hf_p2p_attr_dev_info_dev_name,
598                                tvb, s_offset,
599                                nlen > attr_len ? attr_len : nlen,
600                                ENC_ASCII|ENC_NA);
601   if (nlen != attr_len) {
602     expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
603                            "Invalid Device Name attribute");
604   }
605 }
606
607 static void dissect_configuration_timeout(proto_item *tlv_root,
608                                           proto_item *tlv_item,
609                                           tvbuff_t *tvb, int offset)
610 {
611   proto_tree_add_item(tlv_root, hf_p2p_attr_config_timeout_go, tvb,
612                       offset + 3, 1, ENC_BIG_ENDIAN);
613   proto_tree_add_item(tlv_root, hf_p2p_attr_config_timeout_client, tvb,
614                       offset + 4, 1, ENC_BIG_ENDIAN);
615   proto_item_append_text(tlv_item, ": GO %u msec, client %u msec",
616                          tvb_get_guint8(tvb, offset + 3) * 10,
617                          tvb_get_guint8(tvb, offset + 4) * 10);
618 }
619
620 static void dissect_intended_interface_addr(proto_item *tlv_root,
621                                             proto_item *tlv_item,
622                                             tvbuff_t *tvb, int offset)
623 {
624   guint8 addr[6];
625   proto_tree_add_item(tlv_root, hf_p2p_attr_intended_interface_addr, tvb,
626                       offset + 3, 6, ENC_NA);
627   tvb_memcpy(tvb, addr, offset + 3, 6);
628   proto_item_append_text(tlv_item, ": %s", ether_to_str(addr));
629 }
630
631 static void dissect_extended_listen_timing(proto_item *tlv_root,
632                                            proto_item *tlv_item,
633                                            tvbuff_t *tvb, int offset)
634 {
635   guint16 period, interval;
636   period = tvb_get_letohs(tvb, offset + 3);
637   interval = tvb_get_letohs(tvb, offset + 5);
638   proto_tree_add_uint(tlv_root, hf_p2p_attr_extended_listen_timing_period, tvb,
639                       offset + 3, 2, period);
640   proto_tree_add_uint(tlv_root, hf_p2p_attr_extended_listen_timing_interval,
641                       tvb, offset + 5, 2, interval);
642   proto_item_append_text(tlv_item, ": Availability Period %u msec, "
643                          "Availability Interval %u msec", period, interval);
644 }
645
646 static void dissect_wifi_p2p_group_id(proto_item *tlv_root,
647                                       proto_item *tlv_item, tvbuff_t *tvb,
648                                       int offset, guint16 slen)
649 {
650   int s_offset;
651   guint8 addr[6];
652
653   s_offset = offset + 3;
654   proto_tree_add_item(tlv_root, hf_p2p_attr_p2p_group_id_dev_addr, tvb,
655                       s_offset, 6, ENC_NA);
656   tvb_memcpy(tvb, addr, offset + 3, 6);
657   proto_item_append_text(tlv_item, ": %s", ether_to_str(addr));
658   s_offset += 6;
659   proto_tree_add_item(tlv_root, hf_p2p_attr_p2p_group_id_ssid, tvb,
660                       s_offset, offset + 3 + slen - s_offset, ENC_ASCII|ENC_NA);
661 }
662
663 static void dissect_wifi_p2p_group_bssid(packet_info *pinfo,
664                                          proto_item *tlv_root,
665                                          proto_item *tlv_item, tvbuff_t *tvb,
666                                          int offset, guint16 slen)
667 {
668   int s_offset;
669   guint8 addr[6];
670
671   if (slen != 6) {
672     expert_add_info_format(pinfo, tlv_item, PI_MALFORMED, PI_ERROR,
673                            "Invalid ethernet address");
674     return;
675   }
676
677   s_offset = offset + 3;
678   proto_tree_add_item(tlv_root, hf_p2p_attr_p2p_group_bssid, tvb,
679                       s_offset, 6, ENC_NA);
680   tvb_memcpy(tvb, addr, offset + 3, 6);
681   proto_item_append_text(tlv_item, ": %s", ether_to_str(addr));
682 }
683
684 static void dissect_notice_of_absence(packet_info *pinfo, proto_item *tlv_root,
685                                       proto_item *tlv_item,
686                                       tvbuff_t *tvb, int offset, guint16 slen)
687 {
688   int s_offset = offset + 3;
689
690   if (slen < 2) {
691     expert_add_info_format(pinfo, tlv_item, PI_MALFORMED, PI_ERROR,
692                            "Too short NoA");
693     return;
694   }
695
696   proto_tree_add_item(tlv_root, hf_p2p_attr_noa_index, tvb, s_offset, 1,
697                       ENC_BIG_ENDIAN);
698   proto_tree_add_item(tlv_root, hf_p2p_attr_noa_params, tvb, s_offset + 1, 1,
699                       ENC_BIG_ENDIAN);
700   proto_tree_add_item(tlv_root, hf_p2p_attr_noa_params_opp_ps, tvb,
701                       s_offset + 1, 1, ENC_BIG_ENDIAN);
702   proto_tree_add_item(tlv_root, hf_p2p_attr_noa_params_ctwindow, tvb,
703                       s_offset + 1, 1, ENC_BIG_ENDIAN);
704
705   s_offset += 2;
706   while (offset + 3 + slen >= s_offset + 13) {
707     proto_tree_add_item(tlv_root, hf_p2p_attr_noa_count_type, tvb, s_offset, 1,
708                         ENC_BIG_ENDIAN);
709     s_offset++;
710     proto_tree_add_item(tlv_root, hf_p2p_attr_noa_duration, tvb, s_offset, 4,
711                         ENC_LITTLE_ENDIAN);
712     s_offset += 4;
713     proto_tree_add_item(tlv_root, hf_p2p_attr_noa_interval, tvb, s_offset, 4,
714                         ENC_LITTLE_ENDIAN);
715     s_offset += 4;
716     proto_tree_add_item(tlv_root, hf_p2p_attr_noa_start_time, tvb, s_offset, 4,
717                         ENC_LITTLE_ENDIAN);
718     s_offset += 4;
719   }
720 }
721
722 static void dissect_wifi_p2p_group_info(packet_info *pinfo,
723                                         proto_item *tlv_root,
724                                         proto_item *tlv_item,
725                                         tvbuff_t *tvb, int offset,
726                                         guint16 slen)
727 {
728   int s_offset = offset + 3;
729   int next_offset, ci_len, num_sec, left, nlen;
730   guint16 attr_type, attr_len;
731   proto_item *item;
732   proto_tree *tree;
733
734   while (offset + 3 + slen > s_offset) {
735     if (offset + 3 + slen - s_offset < 25) {
736       expert_add_info_format(pinfo, tlv_item, PI_MALFORMED, PI_ERROR,
737                              "Too short P2P Client Info Descriptor");
738       break;
739     }
740
741     ci_len = tvb_get_guint8(tvb, s_offset);
742     item = proto_tree_add_text(tlv_root, tvb, s_offset, 1 + ci_len,
743                                "P2P Client Info Descriptor");
744     tree = proto_item_add_subtree(item, ett_p2p_client_descr);
745
746     item = proto_tree_add_item(tree, hf_p2p_attr_gi_length, tvb, s_offset,
747                                1, ENC_BIG_ENDIAN);
748     if (ci_len < 24 || s_offset + ci_len > offset + 3 + slen) {
749       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
750                              "Invalid P2P Client Info Descriptor Length");
751       break;
752     }
753     s_offset++;
754     next_offset = s_offset + ci_len;
755
756     proto_tree_add_item(tree, hf_p2p_attr_gi_p2p_dev_addr, tvb, s_offset,
757                         6, ENC_NA);
758     proto_item_append_text(tree, ": %s", tvb_ether_to_str(tvb, s_offset));
759     s_offset += 6;
760
761     proto_tree_add_item(tree, hf_p2p_attr_gi_p2p_iface_addr, tvb, s_offset,
762                         6, ENC_NA);
763     s_offset += 6;
764
765     proto_tree_add_item(tree, hf_p2p_attr_gi_dev_capab, tvb, s_offset, 1,
766                         ENC_BIG_ENDIAN);
767     proto_tree_add_item(tree,
768                         hf_p2p_attr_gi_dev_capab_service_discovery, tvb,
769                         s_offset, 1, ENC_BIG_ENDIAN);
770     proto_tree_add_item(tree,
771                         hf_p2p_attr_gi_dev_capab_client_discoverability,
772                         tvb, s_offset, 1, ENC_BIG_ENDIAN);
773     proto_tree_add_item(tree,
774                         hf_p2p_attr_gi_dev_capab_concurrent_operation,
775                         tvb, s_offset, 1, ENC_BIG_ENDIAN);
776     proto_tree_add_item(tree,
777                         hf_p2p_attr_gi_dev_capab_infrastructure_managed,
778                         tvb, s_offset, 1, ENC_BIG_ENDIAN);
779     proto_tree_add_item(tree, hf_p2p_attr_gi_dev_capab_limit, tvb,
780                         s_offset, 1, ENC_BIG_ENDIAN);
781     proto_tree_add_item(tree, hf_p2p_attr_capab_invitation_procedure, tvb,
782                         s_offset, 1, ENC_BIG_ENDIAN);
783     s_offset++;
784
785     proto_tree_add_item(tree, hf_p2p_attr_gi_config_methods, tvb, s_offset,
786                         2, ENC_BIG_ENDIAN);
787     s_offset += 2;
788
789     proto_tree_add_item(tree, hf_p2p_attr_gi_pri_dev_type, tvb,
790                         s_offset, 8, ENC_NA);
791     proto_tree_add_item(tree, hf_p2p_attr_gi_pri_dev_type_category,
792                         tvb, s_offset, 2, ENC_BIG_ENDIAN);
793     proto_tree_add_item(tree, hf_p2p_attr_gi_pri_dev_type_oui,
794                         tvb, s_offset + 2, 4, ENC_NA);
795     proto_tree_add_item(tree, hf_p2p_attr_gi_pri_dev_type_subcategory,
796                         tvb, s_offset + 6, 2, ENC_BIG_ENDIAN);
797     s_offset += 8;
798
799     item = proto_tree_add_item(tree, hf_p2p_attr_gi_num_sec_dev_types, tvb,
800                                s_offset, 1, ENC_BIG_ENDIAN);
801     num_sec = tvb_get_guint8(tvb, s_offset);
802     s_offset++;
803     left = offset + 3 + slen - s_offset;
804     if (left < 8 * num_sec) {
805       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
806                              "Invalid Secondary Device Type List");
807       break;
808     }
809     while (num_sec > 0) {
810       proto_tree_add_item(tree, hf_p2p_attr_gi_sec_dev_type,
811                           tvb, s_offset, 8, ENC_NA);
812       s_offset += 8;
813       num_sec--;
814     }
815
816     item = proto_tree_add_item(tree, hf_p2p_attr_gi_dev_name_type,
817                                tvb, s_offset, 2, ENC_BIG_ENDIAN);
818     attr_type = tvb_get_ntohs(tvb, s_offset);
819     if (attr_type != 0x1011) {
820       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
821                              "Incorrect Device Name attribute type");
822     }
823     s_offset += 2;
824     item = proto_tree_add_item(tree, hf_p2p_attr_gi_dev_name_len,
825                                tvb, s_offset, 2, ENC_BIG_ENDIAN);
826     attr_len = tvb_get_ntohs(tvb, s_offset);
827     s_offset += 2;
828     if (attr_len > offset + 3 + slen - s_offset) {
829       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
830                              "Invalid Device Name attribute length");
831       break;
832     }
833     nlen = next_offset - s_offset;
834     if (nlen > 0)
835       item = proto_tree_add_item(tree, hf_p2p_attr_gi_dev_name,
836                                  tvb, s_offset,
837                                  nlen > attr_len ? attr_len : nlen,
838                                  ENC_ASCII|ENC_NA);
839     if (nlen != attr_len) {
840       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
841                              "Invalid Device Name attribute");
842     }
843
844     s_offset = next_offset;
845   }
846 }
847
848 static void dissect_invitation_flags(proto_item *tlv_root,
849                                      proto_item *tlv_item,
850                                      tvbuff_t *tvb, int offset)
851 {
852   proto_tree_add_item(tlv_root, hf_p2p_attr_invitation_flags, tvb,
853                       offset + 3, 1, ENC_BIG_ENDIAN);
854   proto_tree_add_item(tlv_root, hf_p2p_attr_invitation_flags_type, tvb,
855                       offset + 3, 1, ENC_BIG_ENDIAN);
856   proto_item_append_text(tlv_item, ": Invitation Flags 0x%x",
857                          tvb_get_guint8(tvb, offset + 3));
858 }
859
860 static void dissect_manageability(proto_item *tlv_root,
861                                   proto_item *tlv_item,
862                                   tvbuff_t *tvb, int offset)
863 {
864   proto_tree_add_item(tlv_root, hf_p2p_attr_manageability_bitmap, tvb,
865                       offset + 3, 1, ENC_BIG_ENDIAN);
866   proto_tree_add_item(tlv_root, hf_p2p_attr_manageability_bitmap_mgmt, tvb,
867                       offset + 3, 1, ENC_BIG_ENDIAN);
868   proto_tree_add_item(tlv_root, hf_p2p_attr_manageability_bitmap_cross_connect,
869                       tvb, offset + 3, 1, ENC_BIG_ENDIAN);
870   proto_tree_add_item(tlv_root, hf_p2p_attr_manageability_bitmap_coex_opt, tvb,
871                       offset + 3, 1, ENC_BIG_ENDIAN);
872   proto_item_append_text(tlv_item, ": Bitmap field 0x%x",
873                          tvb_get_guint8(tvb, offset + 3));
874 }
875
876 static void dissect_minor_reason_code(proto_item *tlv_root,
877                                       proto_item *tlv_item,
878                                       tvbuff_t *tvb, int offset)
879 {
880   proto_tree_add_item(tlv_root, hf_p2p_attr_minor_reason_code, tvb,
881                       offset + 3, 1, ENC_BIG_ENDIAN);
882   proto_item_append_text(tlv_item, ": %u (%s)",
883                          tvb_get_guint8(tvb, offset + 3),
884                          val_to_str(tvb_get_guint8(tvb, offset + 3),
885                                     p2p_minor_reason_codes,
886                                     "Unknown Minor Reason Code (%u)"));
887 }
888
889 void dissect_wifi_p2p_ie(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb,
890                          int offset, gint size)
891 {
892   guint16 slen = 0;
893   guint8 stype = 0;
894   proto_item *tlv_root, *tlv_item;
895
896   while (size > 0) {
897     if (size < 3) {
898       expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR,
899                              "Packet too short for P2P IE");
900       break;
901     }
902
903     stype = tvb_get_guint8(tvb, offset);
904     slen = tvb_get_letohs(tvb, offset + 1);
905
906     tlv_item = proto_tree_add_text(tree, tvb, offset, 3 + slen, "%s",
907                                    val_to_str(stype, p2p_attr_types,
908                                               "Unknown attribute type (%u)"));
909     tlv_root = proto_item_add_subtree(tlv_item, ett_p2p_tlv);
910
911     proto_tree_add_item(tlv_root, hf_p2p_attr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
912     proto_tree_add_uint(tlv_root, hf_p2p_attr_len, tvb, offset + 1, 2,
913                         slen);
914
915     switch(stype) {
916     case P2P_ATTR_P2P_CAPABILITY:
917       dissect_wifi_p2p_capability(tlv_root, tlv_item, tvb, offset);
918       break;
919     case P2P_ATTR_P2P_DEVICE_ID:
920       dissect_device_id(tlv_root, tlv_item, tvb, offset);
921       break;
922     case P2P_ATTR_GROUP_OWNER_INTENT:
923       dissect_group_owner_intent(tlv_root, tlv_item, tvb, offset);
924       break;
925     case P2P_ATTR_STATUS:
926       dissect_status(tlv_root, tlv_item, tvb, offset);
927       break;
928     case P2P_ATTR_LISTEN_CHANNEL:
929       dissect_listen_channel(tlv_root, tlv_item, tvb, offset);
930       break;
931     case P2P_ATTR_OPERATING_CHANNEL:
932       dissect_operating_channel(tlv_root, tlv_item, tvb, offset);
933       break;
934     case P2P_ATTR_CHANNEL_LIST:
935       dissect_channel_list(tlv_root, tvb, offset, slen);
936       break;
937     case P2P_ATTR_P2P_DEVICE_INFO:
938       dissect_wifi_p2p_device_info(pinfo, tlv_root, tvb, offset, slen);
939       break;
940     case P2P_ATTR_CONFIGURATION_TIMEOUT:
941       dissect_configuration_timeout(tlv_root, tlv_item, tvb, offset);
942       break;
943     case P2P_ATTR_INTENDED_P2P_INTERFACE_ADDRESS:
944       dissect_intended_interface_addr(tlv_root, tlv_item, tvb, offset);
945       break;
946     case P2P_ATTR_EXTENDED_LISTEN_TIMING:
947       dissect_extended_listen_timing(tlv_root, tlv_item, tvb, offset);
948       break;
949     case P2P_ATTR_P2P_GROUP_ID:
950       dissect_wifi_p2p_group_id(tlv_root, tlv_item, tvb, offset, slen);
951       break;
952     case P2P_ATTR_P2P_GROUP_BSSID:
953       dissect_wifi_p2p_group_bssid(pinfo, tlv_root, tlv_item, tvb, offset, slen);
954       break;
955     case P2P_ATTR_NOTICE_OF_ABSENCE:
956       dissect_notice_of_absence(pinfo, tlv_root, tlv_item, tvb, offset, slen);
957       break;
958     case P2P_ATTR_P2P_GROUP_INFO:
959       dissect_wifi_p2p_group_info(pinfo, tlv_root, tlv_item, tvb, offset,
960                                   slen);
961       break;
962     case P2P_ATTR_INVITATION_FLAGS:
963       dissect_invitation_flags(tlv_root, tlv_item, tvb, offset);
964       break;
965     case P2P_ATTR_P2P_MANAGEABILITY:
966       dissect_manageability(tlv_root, tlv_item, tvb, offset);
967       break;
968     case P2P_ATTR_MINOR_REASON_CODE:
969       dissect_minor_reason_code(tlv_root, tlv_item, tvb, offset);
970       break;
971     }
972
973     offset += 3 + slen;
974     size -= 3 + slen;
975   }
976 }
977
978 int dissect_wifi_p2p_public_action(packet_info *pinfo, proto_tree *tree,
979                                    tvbuff_t *tvb, int offset)
980 {
981   guint8 subtype;
982   proto_tree_add_item(tree, hf_p2p_public_action_subtype, tvb, offset, 1,
983                       ENC_BIG_ENDIAN);
984   subtype = tvb_get_guint8(tvb, offset);
985   col_append_fstr(pinfo->cinfo, COL_INFO, ", P2P - %s",
986                   val_to_str(subtype, p2p_public_action_subtypes,
987                              "Unknown (%u)"));
988   offset++;
989   proto_tree_add_item(tree, hf_p2p_public_action_dialog_token, tvb, offset, 1,
990                       ENC_BIG_ENDIAN);
991   offset++;
992   /* Followed by variable length IEs dissected by packet-ieee80211.c */
993   return offset;
994 }
995
996 int dissect_wifi_p2p_action(proto_tree *tree, tvbuff_t *tvb, int offset)
997 {
998   proto_tree_add_item(tree, hf_p2p_action_subtype, tvb, offset, 1, ENC_BIG_ENDIAN);
999   offset++;
1000   proto_tree_add_item(tree, hf_p2p_action_dialog_token, tvb, offset, 1, ENC_BIG_ENDIAN);
1001   offset++;
1002   /* Followed by variable length IEs dissected by packet-ieee80211.c */
1003   return offset;
1004 }
1005
1006 void dissect_wifi_p2p_anqp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb,
1007                            int offset, gboolean request)
1008 {
1009   proto_item *item;
1010
1011   item = proto_tree_add_item(tree, hf_p2p_anqp_service_update_indicator, tvb,
1012                              offset, 2, ENC_LITTLE_ENDIAN);
1013   offset += 2;
1014
1015   while (tvb_length_remaining(tvb, offset) >= (request ? 4 : 5)) {
1016     guint16 len;
1017     proto_tree *tlv;
1018     guint8 type, id, sd_proto;
1019
1020     len = tvb_get_letohs(tvb, offset);
1021     if (len < 2) {
1022       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
1023                              "Too short Service TLV field");
1024       return;
1025     }
1026     if (len > tvb_length_remaining(tvb, offset + 2)) {
1027       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
1028                              "Too short frame for Service TLV field");
1029       return;
1030     }
1031
1032     type = tvb_get_guint8(tvb, offset + 2);
1033     id = tvb_get_guint8(tvb, offset + 3);
1034     item = proto_tree_add_text(tree, tvb, offset, 2 + len,
1035                                "Service TLV (Transaction ID: %u  Type: %s)",
1036                                id, val_to_str(type, p2p_service_protocol_types,
1037                                               "Unknown (%u)"));
1038     tlv = proto_item_add_subtree(item, ett_p2p_service_tlv);
1039
1040     proto_tree_add_item(tlv, hf_p2p_anqp_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1041     offset += 2;
1042     sd_proto = tvb_get_guint8(tvb, offset);
1043     proto_tree_add_item(tlv, hf_p2p_anqp_service_protocol_type, tvb,
1044                         offset, 1, ENC_BIG_ENDIAN);
1045     proto_tree_add_item(tlv, hf_p2p_anqp_service_transaction_id, tvb,
1046                         offset + 1, 1, ENC_BIG_ENDIAN);
1047     if (request) {
1048       proto_tree_add_item(tlv, hf_p2p_anqp_query_data, tvb,
1049                           offset + 2, len - 2, ENC_NA);
1050     } else {
1051       proto_tree_add_item(tlv, hf_p2p_anqp_status_code, tvb,
1052                           offset + 2, 1, ENC_BIG_ENDIAN);
1053       proto_tree_add_item(tlv, hf_p2p_anqp_response_data, tvb,
1054                           offset + 3, len - 3, ENC_NA);
1055       if (sd_proto == 4)
1056         dissect_wifi_display_ie(pinfo, tlv, tvb, offset + 3, len - 3);
1057     }
1058     offset += len;
1059   }
1060
1061   if (tvb_length_remaining(tvb, offset) > 0) {
1062     expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
1063                            "Unexpected padding in the end of P2P ANQP");
1064   }
1065 }
1066
1067 void
1068 proto_register_p2p(void)
1069 {
1070   static hf_register_info hf[] = {
1071     { &hf_p2p_attr_type,
1072       { "Attribute Type", "wifi_p2p.type",
1073         FT_UINT8, BASE_DEC, VALS(p2p_attr_types), 0x0, NULL, HFILL }},
1074     { &hf_p2p_attr_len,
1075       { "Attribute Length", "wifi_p2p.length",
1076         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1077
1078 #if 0
1079     { &hf_p2p_attr_capab,
1080       { "P2P Capability", "wifi_p2p.p2p_capability",
1081         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1082 #endif
1083     { &hf_p2p_attr_capab_device,
1084       { "Device Capability Bitmap",
1085         "wifi_p2p.p2p_capability.device_capability",
1086         FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1087     { &hf_p2p_attr_capab_device_service_discovery,
1088       { "Service Discovery",
1089         "wifi_p2p.p2p_capability.device_capability.service_discovery",
1090         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_SERVICE_DISCOVERY, NULL, HFILL
1091       }},
1092     { &hf_p2p_attr_capab_device_client_discoverability,
1093       { "P2P Client Discoverability",
1094         "wifi_p2p.p2p_capability.device_capability.client_discoverability",
1095         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_P2P_CLIENT_DISCOVERABILITY,
1096         NULL, HFILL
1097       }},
1098     { &hf_p2p_attr_capab_device_concurrent_operation,
1099       { "Concurrent Operation",
1100         "wifi_p2p.p2p_capability.device_capability.concurrent_operation",
1101         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_CONCURRENT_OPERATION, NULL,
1102         HFILL
1103       }},
1104     { &hf_p2p_attr_capab_device_infrastructure_managed,
1105       { "P2P Infrastructure Managed",
1106         "wifi_p2p.p2p_capability.device_capability.infrastructure_managed",
1107         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_P2P_INFRASTRUCTURE_MANAGED,
1108         NULL, HFILL
1109       }},
1110     { &hf_p2p_attr_capab_device_limit,
1111       { "P2P Device Limit",
1112         "wifi_p2p.p2p_capability.device_capability.device_limit",
1113         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_P2P_DEVICE_LIMIT, NULL, HFILL
1114       }},
1115     { &hf_p2p_attr_capab_invitation_procedure,
1116       { "P2P Invitation Procedure",
1117         "wifi_p2p.p2p_capability.device_capability.invitation_procedure",
1118         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_P2P_INVITATION_PROCEDURE, NULL,
1119         HFILL
1120       }},
1121     { &hf_p2p_attr_capab_group,
1122       { "Group Capability Bitmap", "wifi_p2p.p2p_capability.group_capability",
1123         FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1124     { &hf_p2p_attr_capab_group_owner,
1125       { "P2P Group Owner",
1126         "wifi_p2p.p2p_capability.group_capability.group_owner",
1127         FT_UINT8, BASE_HEX, NULL, P2P_GROUP_CAPAB_P2P_GROUP_OWNER, NULL, HFILL
1128       }},
1129     { &hf_p2p_attr_capab_group_persistent,
1130       { "Persistent P2P Group",
1131         "wifi_p2p.p2p_capability.group_capability.persistent_group",
1132         FT_UINT8, BASE_HEX, NULL, P2P_GROUP_CAPAB_PERSISTENT_P2P_GROUP, NULL,
1133         HFILL }},
1134     { &hf_p2p_attr_capab_group_limit,
1135       { "P2P Group Limit",
1136         "wifi_p2p.p2p_capability.group_capability.group_limit",
1137         FT_UINT8, BASE_HEX, NULL, P2P_GROUP_CAPAB_P2P_GROUP_LIMIT, NULL, HFILL
1138       }},
1139     { &hf_p2p_attr_capab_group_intra_bss_distribution,
1140       { "Intra-BSS Distribution",
1141         "wifi_p2p.p2p_capability.group_capability.intra_bss_distribution",
1142         FT_UINT8, BASE_HEX, NULL, P2P_GROUP_CAPAB_INTRA_BSS_DISTRIBUTION, NULL,
1143         HFILL }},
1144     { &hf_p2p_attr_capab_group_cross_connection,
1145       { "Cross Connection",
1146         "wifi_p2p.p2p_capability.group_capability.cross_connection",
1147         FT_UINT8, BASE_HEX, NULL, P2P_GROUP_CAPAB_CROSS_CONNECTION, NULL, HFILL
1148       }},
1149     { &hf_p2p_attr_capab_group_persistent_reconnect,
1150       { "Persistent Reconnect",
1151         "wifi_p2p.p2p_capability.group_capability.persistent_reconnect",
1152         FT_UINT8, BASE_HEX, NULL, P2P_GROUP_CAPAB_PERSISTENT_RECONNECT, NULL,
1153         HFILL }},
1154     { &hf_p2p_attr_capab_group_group_formation,
1155       { "Group Formation",
1156         "wifi_p2p.p2p_capability.group_capability.group_formation",
1157         FT_UINT8, BASE_HEX, NULL, P2P_GROUP_CAPAB_GROUP_FORMATION, NULL, HFILL
1158       }},
1159
1160     { &hf_p2p_attr_device_id,
1161       { "Device ID", "wifi_p2p.device_id",
1162         FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1163
1164     { &hf_p2p_attr_status,
1165       { "Status Code", "wifi_p2p.status",
1166         FT_UINT8, BASE_DEC, VALS(p2p_status_codes), 0x0, NULL, HFILL }},
1167
1168     { &hf_p2p_attr_go_intent,
1169       { "Group Owner Intent", "wifi_p2p.go_intent",
1170         FT_UINT8, BASE_DEC, NULL, 0x1e, NULL, HFILL }},
1171     { &hf_p2p_attr_go_intent_tie_breaker,
1172       { "Group Owner Intent Tie Breaker", "wifi_p2p.go_intent_tie_breaker",
1173         FT_UINT8, BASE_DEC, NULL, 0x01, NULL, HFILL }},
1174
1175 #if 0
1176     { &hf_p2p_attr_listen_channel,
1177       { "Listen Channel", "wifi_p2p.listen_channel",
1178         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1179 #endif
1180     { &hf_p2p_attr_listen_channel_country,
1181       { "Country String", "wifi_p2p.listen_channel.country_string",
1182         FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1183     { &hf_p2p_attr_listen_channel_oper_class,
1184       { "Operating Class", "wifi_p2p.listen_channel.operating_class",
1185         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1186     { &hf_p2p_attr_listen_channel_number,
1187       { "Channel Number", "wifi_p2p.listen_channel.channel_number",
1188         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1189
1190 #if 0
1191     { &hf_p2p_attr_operating_channel,
1192       { "Operating Channel", "wifi_p2p.operating_channel",
1193         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1194 #endif
1195     { &hf_p2p_attr_operating_channel_country,
1196       { "Country String", "wifi_p2p.operating_channel.country_string",
1197         FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1198     { &hf_p2p_attr_operating_channel_oper_class,
1199       { "Operating Class", "wifi_p2p.channel.operating_class",
1200         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1201     { &hf_p2p_attr_operating_channel_number,
1202       { "Channel Number", "wifi_p2p.channel.channel_number",
1203         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1204
1205 #if 0
1206     { &hf_p2p_attr_channel_list,
1207       { "Channel List", "wifi_p2p.channel_list",
1208         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1209 #endif
1210     { &hf_p2p_attr_channel_list_country,
1211       { "Country String", "wifi_p2p.channel_list.country_string",
1212         FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1213     { &hf_p2p_attr_channel_list_oper_class,
1214       { "Operating Class", "wifi_p2p.channel_list.operating_class",
1215         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1216     { &hf_p2p_attr_channel_list_num_chan,
1217       { "Number of Channels", "wifi_p2p.channel_list.num_chan",
1218         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1219     { &hf_p2p_attr_channel_list_chan,
1220       { "Channel List", "wifi_p2p.channel_list.channel_list",
1221         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1222 #if 0
1223     { &hf_p2p_attr_dev_info,
1224       { "Device Info", "wifi_p2p.dev_info",
1225         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1226 #endif
1227     { &hf_p2p_attr_dev_info_p2p_dev_addr,
1228       { "P2P Device address", "wifi_p2p.dev_info.p2p_dev_addr",
1229         FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1230     { &hf_p2p_attr_dev_info_pri_dev_type,
1231       { "Primary Device Type", "wifi_p2p.dev_info.pri_dev_type",
1232         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1233     { &hf_p2p_attr_dev_info_pri_dev_type_category,
1234       { "Primary Device Type: Category",
1235         "wifi_p2p.dev_info.pri_dev_type.category",
1236         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1237     { &hf_p2p_attr_dev_info_pri_dev_type_oui,
1238       { "Primary Device Type: OUI", "wifi_p2p.dev_info.pri_dev_type.oui",
1239         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1240     { &hf_p2p_attr_dev_info_pri_dev_type_subcategory,
1241       { "Primary Device Type: Subcategory",
1242         "wifi_p2p.dev_info.pri_dev_type.subcategory",
1243         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1244     { &hf_p2p_attr_dev_info_num_sec,
1245       { "Number of Secondary Device Types", "wifi_p2p.dev_info.num_sec",
1246         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1247     { &hf_p2p_attr_dev_info_sec_dev_type,
1248       { "Secondary Device Type", "wifi_p2p.dev_info.sec_dev_type",
1249         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1250     { &hf_p2p_attr_dev_info_dev_name_type,
1251       { "Device Name attribute type", "wifi_p2p.dev_info.dev_name_type",
1252         FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1253     { &hf_p2p_attr_dev_info_dev_name_len,
1254       { "Device Name attribute length", "wifi_p2p.dev_info.dev_name",
1255         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1256     { &hf_p2p_attr_dev_info_dev_name,
1257       { "Device Name", "wifi_p2p.dev_info.dev_name",
1258         FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1259     { &hf_p2p_attr_dev_info_config_methods,
1260       { "Config Methods", "wifi_p2p.dev_info.config_methods",
1261         FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
1262     { &hf_p2p_attr_dev_info_config_methods_usba,
1263       { "USBA (Flash Drive)", "wifi_p2p.dev_info.config_methods.usba",
1264         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_USBA, NULL, HFILL }},
1265     { &hf_p2p_attr_dev_info_config_methods_ethernet,
1266       { "Ethernet", "wifi_p2p.dev_info.config_methods.ethernet",
1267         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_ETHERNET, NULL, HFILL }},
1268     { &hf_p2p_attr_dev_info_config_methods_label,
1269       { "Label", "wifi_p2p.dev_info.config_methods.label",
1270         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_LABEL, NULL, HFILL }},
1271     { &hf_p2p_attr_dev_info_config_methods_display,
1272       { "Display", "wifi_p2p.dev_info.config_methods.display",
1273         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_DISPLAY, NULL, HFILL }},
1274     { &hf_p2p_attr_dev_info_config_methods_ext_nfc_token,
1275       { "External NFC Token", "wifi_p2p.dev_info.config_methods.ext_nfc_token",
1276         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_EXT_NFC_TOKEN, NULL, HFILL }},
1277     { &hf_p2p_attr_dev_info_config_methods_int_nfc_token,
1278       { "Integrated NFC Token",
1279         "wifi_p2p.dev_info.config_methods.int_nfc_token",
1280         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_INT_NFC_TOKEN, NULL, HFILL }},
1281     { &hf_p2p_attr_dev_info_config_methods_nfc_interface,
1282       { "NFC Interface", "wifi_p2p.dev_info.config_methods.nfc_interface",
1283         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_NFC_INTERFACE, NULL, HFILL }},
1284     { &hf_p2p_attr_dev_info_config_methods_pushbutton,
1285       { "PushButton", "wifi_p2p.dev_info.config_methods.pushbutton",
1286         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_PUSHBUTTON, NULL, HFILL }},
1287     { &hf_p2p_attr_dev_info_config_methods_keypad,
1288       { "Keypad", "wifi_p2p.dev_info.config_methods.keypad",
1289         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_KEYPAD, NULL, HFILL }},
1290     { &hf_p2p_attr_config_timeout_go,
1291       { "GO Configuration Timeout", "wifi_p2p.config_timeout.go",
1292         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1293     { &hf_p2p_attr_config_timeout_client,
1294       { "Client Configuration Timeout", "wifi_p2p.config_timeout.client",
1295         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1296     { &hf_p2p_attr_intended_interface_addr,
1297       { "P2P Interface Address", "wifi_p2p.intended_interface_addr",
1298         FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1299     { &hf_p2p_attr_extended_listen_timing_period,
1300       { "Availability Period", "wifi_p2p.extended_listen_timing.period",
1301         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1302     { &hf_p2p_attr_extended_listen_timing_interval,
1303       { "Availability Interval", "wifi_p2p.extended_listen_timing.interval",
1304         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1305     { &hf_p2p_attr_p2p_group_id_dev_addr,
1306       { "P2P Device address", "wifi_p2p.p2p_group_id.p2p_dev_addr",
1307         FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1308     { &hf_p2p_attr_p2p_group_id_ssid,
1309       { "SSID", "wifi_p2p.p2p_group_id.ssid",
1310         FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1311     { &hf_p2p_attr_p2p_group_bssid,
1312       { "BSSID", "wifi_p2p.p2p_group_bssid",
1313         FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1314
1315     { &hf_p2p_attr_noa_index,
1316       { "Index", "wifi_p2p.noa.index",
1317         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1318     { &hf_p2p_attr_noa_params,
1319       { "CTWindow and OppPS Parameters", "wifi_p2p.noa.params",
1320         FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1321     { &hf_p2p_attr_noa_params_opp_ps,
1322       { "OppPS", "wifi_p2p.noa.params.opp_ps",
1323         FT_UINT8, BASE_DEC, NULL, 0x80, NULL, HFILL }},
1324     { &hf_p2p_attr_noa_params_ctwindow,
1325       { "CTWindow", "wifi_p2p.noa.params.ctwindow",
1326         FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1327     { &hf_p2p_attr_noa_count_type,
1328       { "Count/Type", "wifi_p2p.noa.count_type",
1329         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1330     { &hf_p2p_attr_noa_duration,
1331       { "Duration", "wifi_p2p.noa.duration",
1332         FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1333     { &hf_p2p_attr_noa_interval,
1334       { "Interval", "wifi_p2p.noa.interval",
1335         FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1336     { &hf_p2p_attr_noa_start_time,
1337       { "Start Time", "wifi_p2p.noa.start_time",
1338         FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1339
1340 #if 0
1341     { &hf_p2p_attr_gi,
1342       { "Device Info", "wifi_p2p.group_info",
1343         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1344 #endif
1345     { &hf_p2p_attr_gi_length,
1346       { "P2P Client Info Descriptor Length", "wifi_p2p.group_info.length",
1347         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1348     { &hf_p2p_attr_gi_p2p_dev_addr,
1349       { "P2P Device address", "wifi_p2p.group_info.p2p_dev_addr",
1350         FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1351     { &hf_p2p_attr_gi_p2p_iface_addr,
1352       { "P2P Interface address", "wifi_p2p.group_info.p2p_interface_addr",
1353         FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1354     { &hf_p2p_attr_gi_dev_capab,
1355       { "Device Capability Bitmap", "wifi_p2p.group_info.device_capability",
1356         FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1357     { &hf_p2p_attr_gi_dev_capab_service_discovery,
1358       { "Service Discovery",
1359         "wifi_p2p.group_info.device_capability.service_discovery",
1360         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_SERVICE_DISCOVERY, NULL, HFILL
1361       }},
1362     { &hf_p2p_attr_gi_dev_capab_client_discoverability,
1363       { "P2P Client Discoverability",
1364         "wifi_p2p.group_info.device_capability.client_discoverability",
1365         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_P2P_CLIENT_DISCOVERABILITY,
1366         NULL, HFILL
1367       }},
1368     { &hf_p2p_attr_gi_dev_capab_concurrent_operation,
1369       { "Concurrent Operation",
1370         "wifi_p2p.group_info.device_capability.concurrent_operation",
1371         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_CONCURRENT_OPERATION, NULL,
1372         HFILL
1373       }},
1374     { &hf_p2p_attr_gi_dev_capab_infrastructure_managed,
1375       { "P2P Infrastructure Managed",
1376         "wifi_p2p.group_info.device_capability.infrastructure_managed",
1377         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_P2P_INFRASTRUCTURE_MANAGED,
1378         NULL, HFILL
1379       }},
1380     { &hf_p2p_attr_gi_dev_capab_limit,
1381       { "P2P Device Limit",
1382         "wifi_p2p.group_info.device_capability.device_limit",
1383         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_P2P_DEVICE_LIMIT, NULL, HFILL }},
1384 #if 0
1385     { &hf_p2p_attr_gi_dev_capab_invitation_procedure,
1386       { "P2P Invitation Procedure",
1387         "wifi_p2p.group_info.device_capability.invitation_procedure",
1388         FT_UINT8, BASE_HEX, NULL, P2P_DEV_CAPAB_P2P_INVITATION_PROCEDURE, NULL,
1389         HFILL }},
1390 #endif
1391     { &hf_p2p_attr_gi_pri_dev_type,
1392       { "Primary Device Type", "wifi_p2p.group_info.pri_dev_type",
1393         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1394     { &hf_p2p_attr_gi_pri_dev_type_category,
1395       { "Primary Device Type: Category",
1396         "wifi_p2p.group_info.pri_dev_type.category",
1397         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1398     { &hf_p2p_attr_gi_pri_dev_type_oui,
1399       { "Primary Device Type: OUI", "wifi_p2p.group_info.pri_dev_type.oui",
1400         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1401     { &hf_p2p_attr_gi_pri_dev_type_subcategory,
1402       { "Primary Device Type: Subcategory",
1403         "wifi_p2p.group_info.pri_dev_type.subcategory",
1404         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1405     { &hf_p2p_attr_gi_num_sec_dev_types,
1406       { "Number of Secondary Device Types", "wifi_p2p.group_info.num_sec",
1407         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1408     { &hf_p2p_attr_gi_sec_dev_type,
1409       { "Secondary Device Type", "wifi_p2p.group_info.sec_dev_type",
1410         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1411     { &hf_p2p_attr_gi_dev_name_type,
1412       { "Device Name attribute type", "wifi_p2p.group_info.dev_name_type",
1413         FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1414     { &hf_p2p_attr_gi_dev_name_len,
1415       { "Device Name attribute length", "wifi_p2p.group_info.dev_name",
1416         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1417     { &hf_p2p_attr_gi_dev_name,
1418       { "Device Name", "wifi_p2p.group_info.dev_name",
1419         FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1420     { &hf_p2p_attr_gi_config_methods,
1421       { "Config Methods", "wifi_p2p.group_info.config_methods",
1422         FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
1423 #if 0
1424     { &hf_p2p_attr_gi_config_methods_usba,
1425       { "USBA (Flash Drive)", "wifi_p2p.group_info.config_methods.usba",
1426         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_USBA, NULL, HFILL }},
1427 #endif
1428 #if 0
1429     { &hf_p2p_attr_gi_config_methods_ethernet,
1430       { "Ethernet", "wifi_p2p.group_info.config_methods.ethernet",
1431         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_ETHERNET, NULL, HFILL }},
1432 #endif
1433 #if 0
1434     { &hf_p2p_attr_gi_config_methods_label,
1435       { "Label", "wifi_p2p.group_info.config_methods.label",
1436         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_LABEL, NULL, HFILL }},
1437 #endif
1438 #if 0
1439     { &hf_p2p_attr_gi_config_methods_display,
1440       { "Display", "wifi_p2p.group_info.config_methods.display",
1441         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_DISPLAY, NULL, HFILL }},
1442 #endif
1443 #if 0
1444     { &hf_p2p_attr_gi_config_methods_ext_nfc_token,
1445       { "External NFC Token",
1446         "wifi_p2p.group_info.config_methods.ext_nfc_token",
1447         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_EXT_NFC_TOKEN, NULL, HFILL }},
1448 #endif
1449 #if 0
1450     { &hf_p2p_attr_gi_config_methods_int_nfc_token,
1451       { "Integrated NFC Token",
1452         "wifi_p2p.group_info.config_methods.int_nfc_token",
1453         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_INT_NFC_TOKEN, NULL, HFILL }},
1454 #endif
1455 #if 0
1456     { &hf_p2p_attr_gi_config_methods_nfc_interface,
1457       { "NFC Interface", "wifi_p2p.group_info.config_methods.nfc_interface",
1458         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_NFC_INTERFACE, NULL, HFILL }},
1459 #endif
1460 #if 0
1461     { &hf_p2p_attr_gi_config_methods_pushbutton,
1462       { "PushButton", "wifi_p2p.group_info.config_methods.pushbutton",
1463         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_PUSHBUTTON, NULL, HFILL }},
1464 #endif
1465 #if 0
1466     { &hf_p2p_attr_gi_config_methods_keypad,
1467       { "Keypad", "wifi_p2p.group_info.config_methods.keypad",
1468         FT_UINT16, BASE_HEX, NULL, WPS_CONF_METH_KEYPAD, NULL, HFILL }},
1469 #endif
1470
1471     { &hf_p2p_attr_invitation_flags,
1472       { "Invitation Flags", "wifi_p2p.invitation_flags",
1473         FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1474     { &hf_p2p_attr_invitation_flags_type,
1475       { "Invitation Type", "wifi_p2p.invitation_flags.type",
1476         FT_UINT8, BASE_HEX, VALS(invitation_types), 0x01, NULL, HFILL }},
1477
1478     { &hf_p2p_attr_manageability_bitmap,
1479       { "Manageability Bitmap field", "wifi_p2p.manageability.bitmap",
1480         FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1481     { &hf_p2p_attr_manageability_bitmap_mgmt,
1482       { "P2P Device Management", "wifi_p2p.manageability.bitmap.dev_mgmt",
1483         FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL }},
1484     { &hf_p2p_attr_manageability_bitmap_cross_connect,
1485       { "Cross Connection Permitted",
1486         "wifi_p2p.manageability.bitmap.cross_connect",
1487         FT_UINT8, BASE_HEX, NULL, 0x02, NULL, HFILL }},
1488     { &hf_p2p_attr_manageability_bitmap_coex_opt,
1489       { "Coexistence Optional", "wifi_p2p.manageability.bitmap.coex_opt",
1490         FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL }},
1491
1492     { &hf_p2p_attr_minor_reason_code,
1493       { "Minor Reason Code", "wifi_p2p.minor_reason_code",
1494         FT_UINT8, BASE_DEC, VALS(p2p_minor_reason_codes), 0x0, NULL, HFILL }},
1495
1496     { &hf_p2p_anqp_service_update_indicator,
1497       { "Service Update Indicator", "wifi_p2p.anqp.service_update_indicator",
1498         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1499     { &hf_p2p_anqp_length,
1500       { "Length", "wifi_p2p.anqp.length",
1501         FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1502     { &hf_p2p_anqp_service_protocol_type,
1503       { "Service Protocol Type", "wifi_p2p.anqp.service_protocol_type",
1504         FT_UINT8, BASE_DEC, VALS(p2p_service_protocol_types), 0x0, NULL,
1505         HFILL }},
1506     { &hf_p2p_anqp_service_transaction_id,
1507       { "Service Transaction ID", "wifi_p2p.anqp.service_transaction_id",
1508         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1509     { &hf_p2p_anqp_query_data,
1510       { "Query Data", "wifi_p2p.anqp.query_data",
1511         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1512     { &hf_p2p_anqp_status_code,
1513       { "Status Code", "wifi_p2p.anqp.status_code",
1514         FT_UINT8, BASE_DEC, VALS(p2p_sd_status_codes), 0x0,
1515         "Service Query Status Code", HFILL }},
1516     { &hf_p2p_anqp_response_data,
1517       { "Response Data", "wifi_p2p.anqp.response_data",
1518         FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1519
1520     { &hf_p2p_action_subtype,
1521       { "P2P Action Subtype", "wifi_p2p.action.subtype",
1522         FT_UINT8, BASE_DEC, VALS(p2p_action_subtypes), 0x0, NULL, HFILL }},
1523     { &hf_p2p_action_dialog_token,
1524       { "P2P Action Dialog Token", "wifi_p2p.action.dialog_token",
1525         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1526     { &hf_p2p_public_action_subtype,
1527       { "P2P Public Action Subtype", "wifi_p2p.public_action.subtype",
1528         FT_UINT8, BASE_DEC, VALS(p2p_public_action_subtypes), 0x0, NULL, HFILL
1529       }},
1530     { &hf_p2p_public_action_dialog_token,
1531       { "P2P Public Action Dialog Token",
1532         "wifi_p2p.public_action.dialog_token",
1533         FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}
1534   };
1535   static gint *ett[] = {
1536     &ett_p2p_tlv,
1537     &ett_p2p_service_tlv,
1538     &ett_p2p_client_descr
1539   };
1540
1541   proto_p2p = proto_register_protocol("Wi-Fi Peer-to-Peer", "Wi-Fi P2P",
1542                                       "wifi_p2p");
1543   proto_register_field_array(proto_p2p, hf, array_length(hf));
1544   proto_register_subtree_array(ett, array_length(ett));
1545 }
1546
1547 /*
1548  * Editor modelines
1549  *
1550  * Local Variables:
1551  * c-basic-offset: 2
1552  * tab-width: 8
1553  * indent-tabs-mode: nil
1554  * End:
1555  *
1556  * ex: set shiftwidth=2 tabstop=8 expandtab:
1557  * :indentSize=2:tabSize=8:noTabs=true:
1558  */