README-P2P revision 281806
1252190Srpaulowpa_supplicant and Wi-Fi P2P
2252190Srpaulo============================
3252190Srpaulo
4252190SrpauloThis document describes how the Wi-Fi P2P implementation in
5252190Srpaulowpa_supplicant can be configured and how an external component on the
6252190Srpauloclient (e.g., management GUI) is used to enable WPS enrollment and
7252190Srpauloregistrar registration.
8252190Srpaulo
9252190Srpaulo
10252190SrpauloIntroduction to Wi-Fi P2P
11252190Srpaulo-------------------------
12252190Srpaulo
13252190SrpauloTODO
14252190Srpaulo
15252190SrpauloMore information about Wi-Fi P2P is available from Wi-Fi Alliance:
16252190Srpaulohttp://www.wi-fi.org/Wi-Fi_Direct.php
17252190Srpaulo
18252190Srpaulo
19252190Srpaulowpa_supplicant implementation
20252190Srpaulo-----------------------------
21252190Srpaulo
22252190SrpauloTODO
23252190Srpaulo
24252190Srpaulo
25252190Srpaulowpa_supplicant configuration
26252190Srpaulo----------------------------
27252190Srpaulo
28252190SrpauloWi-Fi P2P is an optional component that needs to be enabled in the
29252190Srpaulowpa_supplicant build configuration (.config). Here is an example
30252190Srpauloconfiguration that includes Wi-Fi P2P support and Linux nl80211
31252190Srpaulo-based driver interface:
32252190Srpaulo
33252190SrpauloCONFIG_DRIVER_NL80211=y
34252190SrpauloCONFIG_CTRL_IFACE=y
35252190SrpauloCONFIG_P2P=y
36252190SrpauloCONFIG_AP=y
37252190SrpauloCONFIG_WPS=y
38252190Srpaulo
39252190Srpaulo
40252190SrpauloIn run-time configuration file (wpa_supplicant.conf), some parameters
41252190Srpaulofor P2P may be set. In order to make the devices easier to recognize,
42252190Srpaulodevice_name and device_type should be specified. For example,
43252190Srpaulosomething like this should be included:
44252190Srpaulo
45252190Srpauloctrl_interface=/var/run/wpa_supplicant
46252190Srpaulodevice_name=My P2P Device
47252190Srpaulodevice_type=1-0050F204-1
48252190Srpaulo
49252190Srpaulo
50252190Srpaulowpa_cli
51252190Srpaulo-------
52252190Srpaulo
53252190SrpauloActual Wi-Fi P2P operations are requested during runtime. These can be
54252190Srpaulodone for example using wpa_cli (which is described below) or a GUI
55252190Srpaulolike wpa_gui-qt4.
56252190Srpaulo
57252190Srpaulo
58252190Srpaulowpa_cli starts in interactive mode if no command string is included on
59252190Srpaulothe command line. By default, it will select the first network interface
60252190Srpaulothat it can find (and that wpa_supplicant controls). If more than one
61252190Srpaulointerface is in use, it may be necessary to select one of the explicitly
62252190Srpauloby adding -i argument on the command line (e.g., 'wpa_cli -i wlan1').
63252190Srpaulo
64252190SrpauloMost of the P2P operations are done on the main interface (e.g., the
65252190Srpaulointerface that is automatically added when the driver is loaded, e.g.,
66252190Srpaulowlan0). When using a separate virtual interface for group operations
67252190Srpaulo(e.g., wlan1), the control interface for that group interface may need
68252190Srpauloto be used for some operations (mainly WPS activation in GO). This may
69252190Srpaulochange in the future so that all the needed operations could be done
70252190Srpauloover the main control interface.
71252190Srpaulo
72252190SrpauloDevice Discovery
73252190Srpaulo
74252190Srpaulop2p_find [timeout in seconds] [type=<social|progressive>] \
75281806Srpaulo	[dev_id=<addr>] [dev_type=<device type>] \
76281806Srpaulo	[delay=<search delay in ms>] [seek=<service name>] [freq=<MHz>]
77252190Srpaulo
78252190SrpauloThe default behavior is to run a single full scan in the beginning and
79252190Srpaulothen scan only social channels. type=social will scan only social
80252190Srpaulochannels, i.e., it skips the initial full scan. type=progressive is
81252190Srpaulolike the default behavior, but it will scan through all the channels
82252190Srpauloprogressively one channel at the time in the Search state rounds. This
83252190Srpaulowill help in finding new groups or groups missed during the initial
84281806Srpaulofull scan. When the type parameter is not included (i.e., full scan), the
85281806Srpaulooptional freq parameter can be used to override the first scan to use only
86281806Srpaulothe specified channel after which only social channels are scanned.
87252190Srpaulo
88252190SrpauloThe optional dev_id option can be used to specify a single P2P peer to
89252190Srpaulosearch for. The optional delay parameter can be used to request an extra
90252190Srpaulodelay to be used between search iterations (e.g., to free up radio
91252190Srpauloresources for concurrent operations).
92252190Srpaulo
93281806SrpauloThe optional dev_type option can be used to specify a single device type
94281806Srpaulo(primary or secondary) to search for, e.g.,
95281806Srpaulo"p2p_find dev_type=1-0050F204-1".
96281806Srpaulo
97281806Srpaulo
98281806SrpauloWith one or more seek arguments, the command sends Probe Request frames
99281806Srpaulofor a P2PS service. For example,
100281806Srpaulop2p_find 5 dev_id=11:22:33:44:55:66 seek=alt.example.chat seek=alt.example.video
101281806Srpaulo
102281806SrpauloParameters description:
103281806Srpaulo    Timeout - Optional ASCII base-10-encoded u16. If missing, request will not
104281806Srpaulo	time out and must be canceled manually
105281806Srpaulo    dev_id - Optional to request responses from a single known remote device
106281806Srpaulo    Service Name - Mandatory UTF-8 string for ASP seeks
107281806Srpaulo	Service name must match the remote service being advertised exactly
108281806Srpaulo	(no prefix matching).
109281806Srpaulo	Service name may be empty, in which case all ASP services will be
110281806Srpaulo	returned, and may be filtered with p2p_serv_disc_req settings, and
111281806Srpaulo	p2p_serv_asp_resp results.
112281806Srpaulo	Multiple service names may be requested, but if it exceeds internal
113281806Srpaulo	limit, it will automatically revert to requesting all ASP services.
114281806Srpaulo
115252190Srpaulop2p_listen [timeout in seconds]
116252190Srpaulo
117252190SrpauloStart Listen-only state (become discoverable without searching for
118252190Srpauloother devices). Optional parameter can be used to specify the duration
119252190Srpaulofor the Listen operation in seconds. This command may not be of that
120252190Srpaulomuch use during normal operations and is mainly designed for
121252190Srpaulotesting. It can also be used to keep the device discoverable without
122252190Srpaulohaving to maintain a group.
123252190Srpaulo
124252190Srpaulop2p_stop_find
125252190Srpaulo
126252190SrpauloStop ongoing P2P device discovery or other operation (connect, listen
127252190Srpaulomode).
128252190Srpaulo
129252190Srpaulop2p_flush
130252190Srpaulo
131252190SrpauloFlush P2P peer table and state.
132252190Srpaulo
133252190SrpauloGroup Formation
134252190Srpaulo
135252190Srpaulop2p_prov_disc <peer device address> <display|keypad|pbc> [join|auto]
136252190Srpaulo
137252190SrpauloSend P2P provision discovery request to the specified peer. The
138252190Srpauloparameters for this command are the P2P device address of the peer and
139252190Srpaulothe desired configuration method. For example, "p2p_prov_disc
140252190Srpaulo02:01:02:03:04:05 display" would request the peer to display a PIN for
141252190Srpaulous and "p2p_prov_disc 02:01:02:03:04:05 keypad" would request the peer
142252190Srpauloto enter a PIN that we display.
143252190Srpaulo
144252190SrpauloThe optional "join" parameter can be used to indicate that this command
145252190Srpaulois requesting an already running GO to prepare for a new client. This is
146252190Srpaulomainly used with "display" to request it to display a PIN. The "auto"
147252190Srpauloparameter can be used to request wpa_supplicant to automatically figure
148252190Srpauloout whether the peer device is operating as a GO and if so, use
149252190Srpaulojoin-a-group style PD instead of GO Negotiation style PD.
150252190Srpaulo
151281806Srpaulop2p_connect <peer device address> <pbc|pin|PIN#|p2ps> [display|keypad|p2ps]
152252190Srpaulo	[persistent|persistent=<network id>] [join|auth]
153281806Srpaulo	[go_intent=<0..15>] [freq=<in MHz>] [ht40] [vht] [provdisc] [auto]
154252190Srpaulo
155252190SrpauloStart P2P group formation with a discovered P2P peer. This includes
156252190Srpaulooptional group owner negotiation, group interface setup, provisioning,
157252190Srpauloand establishing data connection.
158252190Srpaulo
159252190SrpauloThe <pbc|pin|PIN#> parameter specifies the WPS provisioning
160252190Srpaulomethod. "pbc" string starts pushbutton method, "pin" string start PIN
161252190Srpaulomethod using an automatically generated PIN (which will be returned as
162252190Srpaulothe command return code), PIN# means that a pre-selected PIN can be
163252190Srpauloused (e.g., 12345670). [display|keypad] is used with PIN method
164252190Srpauloto specify which PIN is used (display=dynamically generated random PIN
165252190Srpaulofrom local display, keypad=PIN entered from peer display). "persistent"
166252190Srpauloparameter can be used to request a persistent group to be formed. The
167252190Srpaulo"persistent=<network id>" alternative can be used to pre-populate
168252190SrpauloSSID/passphrase configuration based on a previously used persistent
169252190Srpaulogroup where this device was the GO. The previously used parameters will
170252190Srpaulothen be used if the local end becomes the GO in GO Negotiation (which
171252190Srpaulocan be forced with go_intent=15).
172252190Srpaulo
173252190Srpaulo"join" indicates that this is a command to join an existing group as a
174252190Srpauloclient. It skips the GO Negotiation part. This will send a Provision
175252190SrpauloDiscovery Request message to the target GO before associating for WPS
176252190Srpauloprovisioning.
177252190Srpaulo
178252190Srpaulo"auth" indicates that the WPS parameters are authorized for the peer
179252190Srpaulodevice without actually starting GO Negotiation (i.e., the peer is
180252190Srpauloexpected to initiate GO Negotiation). This is mainly for testing
181252190Srpaulopurposes.
182252190Srpaulo
183252190Srpaulo"go_intent" can be used to override the default GO Intent for this GO
184252190SrpauloNegotiation.
185252190Srpaulo
186252190Srpaulo"freq" can be used to set a forced operating channel (e.g., freq=2412
187252190Srpauloto select 2.4 GHz channel 1).
188252190Srpaulo
189252190Srpaulo"provdisc" can be used to request a Provision Discovery exchange to be
190252190Srpauloused prior to starting GO Negotiation as a workaround with some deployed
191252190SrpauloP2P implementations that require this to allow the user to accept the
192252190Srpauloconnection.
193252190Srpaulo
194281806Srpaulo"auto" can be used to request wpa_supplicant to automatically figure
195281806Srpauloout whether the peer device is operating as a GO and if so, use
196281806Srpaulojoin-a-group operation rather than GO Negotiation.
197252190Srpaulo
198281806SrpauloP2PS attribute changes to p2p_connect command:
199281806Srpaulo
200281806SrpauloP2PS supports two WPS provisioning methods namely PIN method and P2PS default.
201281806SrpauloThe remaining paramters hold same role as in legacy P2P. In case of P2PS default
202281806Srpauloconfig method "p2ps" keyword is added in p2p_connect command.
203281806Srpaulo
204281806SrpauloFor example:
205281806Srpaulop2p_connect 02:0a:f5:85:11:00 12345670 p2ps persistent join
206281806Srpaulo	(WPS Method = P2PS default)
207281806Srpaulo
208281806Srpaulop2p_connect 02:0a:f5:85:11:00 45629034 keypad persistent
209281806Srpaulo	(WPS Method = PIN)
210281806Srpaulo
211281806Srpaulop2p_asp_provision <peer MAC address> <adv_id=peer adv id>
212281806Srpaulo	<adv_mac=peer MAC address> [role=2|4|1] <session=session id>
213281806Srpaulo	<session_mac=initiator mac address>
214281806Srpaulo	[info='service info'] <method=Default|keypad|Display>
215281806Srpaulo
216281806SrpauloThis command starts provision discovery with the P2PS enabled peer device.
217281806Srpaulo
218281806SrpauloFor example,
219281806Srpaulop2p_asp_provision 00:11:22:33:44:55 adv_id=4d6fc7 adv_mac=00:55:44:33:22:11 role=1 session=12ab34 session_mac=00:11:22:33:44:55 info='name=john' method=1000
220281806Srpaulo
221281806SrpauloParameter description:
222281806Srpaulo    MAC address - Mandatory
223281806Srpaulo    adv_id - Mandatory remote Advertising ID of service connection is being
224281806Srpaulo	established for
225281806Srpaulo    adv_mac - Mandatory MAC address that owns/registered the service
226281806Srpaulo    role - Optional
227281806Srpaulo	2 (group client only) or 4 (group owner only)
228281806Srpaulo	if not present (or 1) role is negotiated by the two peers.
229281806Srpaulo    session - Mandatory Session ID of the first session to be established
230281806Srpaulo    session_mac - Mandatory MAC address that owns/initiated the session
231281806Srpaulo    method - Optional method to request for provisioning (1000 - P2PS Default,
232281806Srpaulo	100 - Keypad(PIN), 8 - Display(PIN))
233281806Srpaulo    info - Optional UTF-8 string. Hint for service to indicate possible usage
234281806Srpaulo	parameters - Escape single quote & backslash:
235281806Srpaulo	with a backslash 0x27 == ' == \', and 0x5c == \ == \\
236281806Srpaulo
237281806Srpaulop2p_asp_provision_resp <peer mac address> <adv_id= local adv id>
238281806Srpaulo	<adv_mac=local MAC address> <role=1|2|4> <status=0>
239281806Srpaulo	<session=session id> <session_mac=peer MAC address>
240281806Srpaulo
241281806SrpauloThis command sends a provision discovery response from responder side.
242281806Srpaulo
243281806SrpauloFor example,
244281806Srpaulop2p_asp_provision_resp 00:55:44:33:22:11 adv_id=4d6fc7 adv_mac=00:55:44:33:22:11 role=1 status=0 session=12ab34 session_mac=00:11:22:33:44:55
245281806Srpaulo
246281806SrpauloParameters definition:
247281806Srpaulo    MAC address - Mandatory
248281806Srpaulo    adv_id - Mandatory local Advertising ID of service connection is being
249281806Srpaulo	established for
250281806Srpaulo    adv_mac - Mandatory MAC address that owns/registered the service
251281806Srpaulo    role -  Optional 2 (group client only) or 4 (group owner only)
252281806Srpaulo	if not present (or 1) role is negotiated by the two peers.
253281806Srpaulo    status - Mandatory Acceptance/Rejection code of Provisioning
254281806Srpaulo    session - Mandatory Session ID of the first session to be established
255281806Srpaulo    session_mac - Mandatory MAC address that owns/initiated the session
256281806Srpaulo
257281806Srpaulop2p_group_add [persistent|persistent=<network id>] [freq=<freq in MHz>]
258281806Srpaulo	[ht40] [vht]
259281806Srpaulo
260252190SrpauloSet up a P2P group owner manually (i.e., without group owner
261252190Srpaulonegotiation with a specific peer). This is also known as autonomous
262252190SrpauloGO. Optional persistent=<network id> can be used to specify restart of
263252190Srpauloa persistent group. Optional freq=<freq in MHz> can be used to force
264252190Srpaulothe GO to be started on a specific frequency. Special freq=2 or freq=5
265252190Srpaulooptions can be used to request the best 2.4 GHz or 5 GHz band channel
266252190Srpauloto be selected automatically.
267252190Srpaulo
268252190Srpaulop2p_reject <peer device address>
269252190Srpaulo
270252190SrpauloReject connection attempt from a peer (specified with a device
271252190Srpauloaddress). This is a mechanism to reject a pending GO Negotiation with
272252190Srpauloa peer and request to automatically block any further connection or
273252190Srpaulodiscovery of the peer.
274252190Srpaulo
275252190Srpaulop2p_group_remove <group interface>
276252190Srpaulo
277252190SrpauloTerminate a P2P group. If a new virtual network interface was used for
278252190Srpaulothe group, it will also be removed. The network interface name of the
279252190Srpaulogroup interface is used as a parameter for this command.
280252190Srpaulo
281252190Srpaulop2p_cancel
282252190Srpaulo
283252190SrpauloCancel an ongoing P2P group formation and joining-a-group related
284252190Srpaulooperation. This operations unauthorizes the specific peer device (if any
285252190Srpaulohad been authorized to start group formation), stops P2P find (if in
286252190Srpauloprogress), stops pending operations for join-a-group, and removes the
287252190SrpauloP2P group interface (if one was used) that is in the WPS provisioning
288252190Srpaulostep. If the WPS provisioning step has been completed, the group is not
289252190Srpauloterminated.
290252190Srpaulo
291281806Srpaulop2p_remove_client <peer's P2P Device Address|iface=<interface address>>
292281806Srpaulo
293281806SrpauloThis command can be used to remove the specified client from all groups
294281806Srpaulo(operating and persistent) from the local GO. Note that the peer device
295281806Srpaulocan rejoin the group if it is in possession of a valid key. See p2p_set
296281806Srpauloper_sta_psk command below for more details on how the peer can be
297281806Srpauloremoved securely.
298281806Srpaulo
299252190SrpauloService Discovery
300252190Srpaulo
301281806Srpaulop2p_service_add asp <auto accept> <adv id> <status 0/1> <Config Methods>
302281806Srpaulo	<Service name> [Service Information] [Response Info]
303281806Srpaulo
304281806SrpauloThis command can be used to search for a P2PS service which includes
305281806SrpauloPlay, Send, Display, and Print service. The parameters for this command
306281806Srpauloare "asp" to identify the command as P2PS one, auto accept value,
307281806Srpauloadvertisement id which uniquely identifies the service requests, state
308281806Srpauloof the service whether the service is available or not, config methods
309281806Srpaulowhich can be either P2PS method or PIN method, service name followed by
310281806Srpaulotwo optional parameters service information, and response info.
311281806Srpaulo
312281806SrpauloFor example,
313281806Srpaulop2p_service_add asp 1 4d6fc7 0 1108 alt.example.chat svc_info='name=john' rsp_info='enter PIN 1234'
314281806Srpaulo
315281806SrpauloParameters definition:
316281806Srpaulo    asp - Mandatory for ASP service registration
317281806Srpaulo    auto accept - Mandatory ASCII hex-encoded boolean (0 == no auto-accept,
318281806Srpaulo	1 == auto-accept ANY role, 2 == auto-accept CLIENT role,
319281806Srpaulo	4 == auto-accept GO role)
320281806Srpaulo    Advertisement ID - Mandatory non-zero ASCII hex-encoded u32
321281806Srpaulo	(Must be unique/not yet exist in svc db)
322281806Srpaulo    State - Mandatory ASCII hex-encoded u8 (0 -- Svc not available,
323281806Srpaulo	1 -- Svc available, 2-0xff  Application defined)
324281806Srpaulo    Config Methods - Mandatory ASCII hex-encoded u16 (bitmask of WSC config
325281806Srpaulo	methods)
326281806Srpaulo    Service Name - Mandatory UTF-8 string
327281806Srpaulo    Service Information - Optional UTF-8 string
328281806Srpaulo	Escape single quote & backslash with a backslash:
329281806Srpaulo	0x27 == ' == \', and 0x5c == \ == \\
330281806Srpaulo    Session response information -  Optional (used only if auto accept is TRUE)
331281806Srpaulo	UTF-8 string
332281806Srpaulo	Escape single quote & backslash with a backslash:
333281806Srpaulo	0x27 == ' == \', and 0x5c == \ == \\
334281806Srpaulo
335281806Srpaulop2p_service_rep asp <auto accept> <adv id> <status 0/1> <Config Methods>
336281806Srpaulo	<Service name> [Service Information] [Response Info]
337281806Srpaulo
338281806SrpauloThis command can be used to replace the existing service request
339281806Srpauloattributes from the initiator side. The replacement is only allowed if
340281806Srpaulothe advertisement id issued in the command matches with any one entry in
341281806Srpaulothe list of existing SD queries. If advertisement id doesn't match the
342281806Srpaulocommand returns a failure.
343281806Srpaulo
344281806SrpauloFor example,
345281806Srpaulop2p_service_rep asp 1 4d6fc7 1 1108 alt.example.chat svc_info='name=john' rsp_info='enter PIN 1234'
346281806Srpaulo
347281806SrpauloParameters definition:
348281806Srpaulo    asp - Mandatory for ASP service registration
349281806Srpaulo    auto accept - Mandatory ASCII hex-encoded boolean (1 == true, 0 == false)
350281806Srpaulo    Advertisement ID - Mandatory non-zero ASCII hex-encoded u32
351281806Srpaulo	(Must already exist in svc db)
352281806Srpaulo    State - Mandatory ASCII hex-encoded u8 (can be used to indicate svc
353281806Srpaulo	available or not available for instance)
354281806Srpaulo    Config Methods - Mandatory ASCII hex-encoded u16 (bitmask of WSC config
355281806Srpaulo	methods)
356281806Srpaulo    Service Name - Mandatory UTF-8 string (Must match existing string in svc db)
357281806Srpaulo    Service Information - Optional UTF-8 string
358281806Srpaulo	Escape single quote & backslash with a backslash:
359281806Srpaulo	0x27 == ' == \', and 0x5c == \ == \\
360281806Srpaulo    Session response information -  Optional (used only if auto accept is TRUE)
361281806Srpaulo	UTF-8 string
362281806Srpaulo	Escape single quote & backslash with a backslash:
363281806Srpaulo	0x27 == ' == \', and 0x5c == \ == \\
364281806Srpaulo
365252190Srpaulop2p_serv_disc_req
366252190Srpaulo
367252190SrpauloSchedule a P2P service discovery request. The parameters for this
368252190Srpaulocommand are the device address of the peer device (or 00:00:00:00:00:00
369252190Srpaulofor wildcard query that is sent to every discovered P2P peer that
370252190Srpaulosupports service discovery) and P2P Service Query TLV(s) as hexdump. For
371252190Srpauloexample,
372252190Srpaulo
373252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 02000001
374252190Srpaulo
375252190Srpauloschedules a request for listing all available services of all service
376252190Srpaulodiscovery protocols and requests this to be sent to all discovered
377252190Srpaulopeers (note: this can result in long response frames). The pending
378252190Srpaulorequests are sent during device discovery (see p2p_find).
379252190Srpaulo
380281806SrpauloThere can be multiple pending peer device specific queries (each will be
381281806Srpaulosent in sequence whenever the peer is found).
382252190Srpaulo
383252190SrpauloThis command returns an identifier for the pending query (e.g.,
384252190Srpaulo"1f77628") that can be used to cancel the request. Directed requests
385252190Srpaulowill be automatically removed when the specified peer has replied to
386252190Srpauloit.
387252190Srpaulo
388281806SrpauloService Query TLV has following format:
389281806SrpauloLength (2 octets, little endian) - length of following data
390281806SrpauloService Protocol Type (1 octet) - see the table below
391281806SrpauloService Transaction ID (1 octet) - nonzero identifier for the TLV
392281806SrpauloQuery Data (Length - 2 octets of data) - service protocol specific data
393281806Srpaulo
394281806SrpauloService Protocol Types:
395281806Srpaulo0 = All service protocols
396281806Srpaulo1 = Bonjour
397281806Srpaulo2 = UPnP
398281806Srpaulo3 = WS-Discovery
399281806Srpaulo4 = Wi-Fi Display
400281806Srpaulo
401252190SrpauloFor UPnP, an alternative command format can be used to specify a
402252190Srpaulosingle query TLV (i.e., a service discovery for a specific UPnP
403252190Srpauloservice):
404252190Srpaulo
405252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 upnp <version hex> <ST: from M-SEARCH>
406252190Srpaulo
407252190SrpauloFor example:
408252190Srpaulo
409252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 upnp 10 urn:schemas-upnp-org:device:InternetGatewayDevice:1
410252190Srpaulo
411252190SrpauloAdditional examples for queries:
412252190Srpaulo
413252190Srpaulo# list of all Bonjour services
414252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 02000101
415252190Srpaulo
416252190Srpaulo# list of all UPnP services
417252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 02000201
418252190Srpaulo
419252190Srpaulo# list of all WS-Discovery services
420252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 02000301
421252190Srpaulo
422252190Srpaulo# list of all Bonjour and UPnP services
423252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 0200010102000202
424252190Srpaulo
425252190Srpaulo# Apple File Sharing over TCP
426252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 130001010b5f6166706f766572746370c00c000c01
427252190Srpaulo
428252190Srpaulo# Bonjour SSTH (supported service type hash)
429252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 05000101000000
430252190Srpaulo
431252190Srpaulo# UPnP examples
432252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 upnp 10 ssdp:all
433252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 upnp 10 upnp:rootdevice
434252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 upnp 10 urn:schemas-upnp-org:service:ContentDirectory:2
435252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 upnp 10 uuid:6859dede-8574-59ab-9332-123456789012
436252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 upnp 10 urn:schemas-upnp-org:device:InternetGatewayDevice:1
437252190Srpaulo
438252190Srpaulo# Wi-Fi Display examples
439252190Srpaulo# format: wifi-display <list of roles> <list of subelements>
440252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 wifi-display [source] 2,3,4,5
441252190Srpaulop2p_serv_disc_req 02:01:02:03:04:05 wifi-display [pri-sink] 3
442252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 wifi-display [sec-source] 2
443252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 wifi-display [source+sink] 2,3,4,5
444252190Srpaulop2p_serv_disc_req 00:00:00:00:00:00 wifi-display [source][pri-sink] 2,3,4,5
445252190Srpaulo
446281806Srpaulop2p_serv_disc_req <Unicast|Broadcast mac address> asp <Transaction ID>
447281806Srpaulo	<Service Name> [Service Information]
448281806Srpaulo
449281806SrpauloThe command can be used for service discovery for P2PS enabled devices.
450281806Srpaulo
451281806SrpauloFor example: p2p_serv_disc_req 00:00:00:00:00:00 asp a1 alt.example 'john'
452281806Srpaulo
453281806SrpauloParameters definition:
454281806Srpaulo    MAC address - Mandatory Existing
455281806Srpaulo    asp - Mandatory for ASP queries
456281806Srpaulo    Transaction ID - Mandatory non-zero ASCII hex-encoded u8 for GAS
457281806Srpaulo    Service Name Prefix - Mandatory UTF-8 string.
458281806Srpaulo	Will match from beginning of remote Service Name
459281806Srpaulo    Service Information Substring - Optional UTF-8 string
460281806Srpaulo	If Service Information Substring is not included, all services matching
461281806Srpaulo	Service Name Prefix will be returned.
462281806Srpaulo	If Service Information Substring is included, both the Substring and the
463281806Srpaulo	Service Name Prefix must match for service to be returned.
464281806Srpaulo	If remote service has no Service Information, all Substring searches
465281806Srpaulo	will fail.
466281806Srpaulo
467252190Srpaulop2p_serv_disc_cancel_req <query identifier>
468252190Srpaulo
469252190SrpauloCancel a pending P2P service discovery request. This command takes a
470252190Srpaulosingle parameter: identifier for the pending query (the value returned
471252190Srpauloby p2p_serv_disc_req, e.g., "p2p_serv_disc_cancel_req 1f77628".
472252190Srpaulo
473252190Srpaulop2p_serv_disc_resp
474252190Srpaulo
475252190SrpauloReply to a service discovery query. This command takes following
476252190Srpauloparameters: frequency in MHz, destination address, dialog token,
477252190Srpauloresponse TLV(s). The first three parameters are copied from the
478252190Srpaulorequest event. For example, "p2p_serv_disc_resp 2437 02:40:61:c2:f3:b7
479252190Srpaulo1 0300000101". This command is used only if external program is used
480252190Srpauloto process the request (see p2p_serv_disc_external).
481252190Srpaulo
482252190Srpaulop2p_service_update
483252190Srpaulo
484252190SrpauloIndicate that local services have changed. This is used to increment
485252190Srpaulothe P2P service indicator value so that peers know when previously
486252190Srpaulocached information may have changed. This is only needed when external
487252190Srpauloservice discovery processing is enabled since the commands to
488252190Srpaulopre-configure services for internal processing will increment the
489252190Srpauloindicator automatically.
490252190Srpaulo
491252190Srpaulop2p_serv_disc_external <0|1>
492252190Srpaulo
493252190SrpauloConfigure external processing of P2P service requests: 0 (default) =
494252190Srpaulono external processing of requests (i.e., internal code will process
495252190Srpauloeach request based on pre-configured services), 1 = external
496252190Srpauloprocessing of requests (external program is responsible for replying
497252190Srpauloto service discovery requests with p2p_serv_disc_resp). Please note
498252190Srpaulothat there is quite strict limit on how quickly the response needs to
499252190Srpaulobe transmitted, so use of the internal processing is strongly
500252190Srpaulorecommended.
501252190Srpaulo
502252190Srpaulop2p_service_add bonjour <query hexdump> <RDATA hexdump>
503252190Srpaulo
504252190SrpauloAdd a local Bonjour service for internal SD query processing.
505252190Srpaulo
506252190SrpauloExamples:
507252190Srpaulo
508252190Srpaulo# AFP Over TCP (PTR)
509252190Srpaulop2p_service_add bonjour 0b5f6166706f766572746370c00c000c01 074578616d706c65c027
510252190Srpaulo# AFP Over TCP (TXT) (RDATA=null)
511252190Srpaulop2p_service_add bonjour 076578616d706c650b5f6166706f766572746370c00c001001 00
512252190Srpaulo
513252190Srpaulo# IP Printing over TCP (PTR) (RDATA=MyPrinter._ipp._tcp.local.)
514252190Srpaulop2p_service_add bonjour 045f697070c00c000c01 094d795072696e746572c027
515252190Srpaulo# IP Printing over TCP (TXT) (RDATA=txtvers=1,pdl=application/postscript)
516252190Srpaulop2p_service_add bonjour 096d797072696e746572045f697070c00c001001 09747874766572733d311a70646c3d6170706c69636174696f6e2f706f7374736372797074
517252190Srpaulo
518252190Srpaulo# Supported Service Type Hash (SSTH)
519252190Srpaulop2p_service_add bonjour 000000 <32-byte bitfield as hexdump>
520252190Srpaulo(note: see P2P spec Annex E.4 for information on how to construct the bitfield)
521252190Srpaulo
522252190Srpaulop2p_service_del bonjour <query hexdump>
523252190Srpaulo
524252190SrpauloRemove a local Bonjour service from internal SD query processing.
525252190Srpaulo
526252190Srpaulop2p_service_add upnp <version hex> <service>
527252190Srpaulo
528252190SrpauloAdd a local UPnP service for internal SD query processing.
529252190Srpaulo
530252190SrpauloExamples:
531252190Srpaulo
532252190Srpaulop2p_service_add upnp 10 uuid:6859dede-8574-59ab-9332-123456789012::upnp:rootdevice
533252190Srpaulop2p_service_add upnp 10 uuid:5566d33e-9774-09ab-4822-333456785632::upnp:rootdevice
534252190Srpaulop2p_service_add upnp 10 uuid:1122de4e-8574-59ab-9322-333456789044::urn:schemas-upnp-org:service:ContentDirectory:2
535252190Srpaulop2p_service_add upnp 10 uuid:5566d33e-9774-09ab-4822-333456785632::urn:schemas-upnp-org:service:ContentDirectory:2
536252190Srpaulop2p_service_add upnp 10 uuid:6859dede-8574-59ab-9332-123456789012::urn:schemas-upnp-org:device:InternetGatewayDevice:1
537252190Srpaulo
538252190Srpaulop2p_service_del upnp <version hex> <service>
539252190Srpaulo
540252190SrpauloRemove a local UPnP service from internal SD query processing.
541252190Srpaulo
542281806Srpaulop2p_service_del asp <adv id>
543281806Srpaulo
544281806SrpauloRemoves the local asp service from internal SD query list.
545281806SrpauloFor example: p2p_service_del asp 4d6fc7
546281806Srpaulo
547252190Srpaulop2p_service_flush
548252190Srpaulo
549252190SrpauloRemove all local services from internal SD query processing.
550252190Srpaulo
551252190SrpauloInvitation
552252190Srpaulo
553252190Srpaulop2p_invite [persistent=<network id>|group=<group ifname>] [peer=address]
554281806Srpaulo	[go_dev_addr=address] [freq=<freq in MHz>] [ht40] [vht]
555281806Srpaulo	[pref=<MHz>]
556252190Srpaulo
557252190SrpauloInvite a peer to join a group (e.g., group=wlan1) or to reinvoke a
558252190Srpaulopersistent group (e.g., persistent=4). If the peer device is the GO of
559252190Srpaulothe persistent group, the peer parameter is not needed. Otherwise it is
560252190Srpauloused to specify which device to invite. go_dev_addr parameter can be
561252190Srpauloused to override the GO device address for Invitation Request should
562252190Srpauloit be not known for some reason (this should not be needed in most
563252190Srpaulocases). When reinvoking a persistent group, the GO device can specify
564281806Srpaulothe frequency for the group with the freq parameter. When reinvoking a
565281806Srpaulopersistent group, the P2P client device can use freq parameter to force
566281806Srpauloa specific operating channel (or invitation failure if GO rejects that)
567281806Srpauloor pref parameter to request a specific channel (while allowing GO to
568281806Srpauloselect to use another channel, if needed).
569252190Srpaulo
570252190SrpauloGroup Operations
571252190Srpaulo
572252190Srpaulo(These are used on the group interface.)
573252190Srpaulo
574252190Srpaulowps_pin <any|address> <PIN>
575252190Srpaulo
576252190SrpauloStart WPS PIN method. This allows a single WPS Enrollee to connect to
577252190Srpaulothe AP/GO. This is used on the GO when a P2P client joins an existing
578252190Srpaulogroup. The second parameter is the address of the Enrollee or a string
579252190Srpaulo"any" to allow any station to use the entered PIN (which will restrict
580252190Srpaulothe PIN for one-time-use). PIN is the Enrollee PIN read either from a
581252190Srpaulolabel or display on the P2P Client/WPS Enrollee.
582252190Srpaulo
583252190Srpaulowps_pbc
584252190Srpaulo
585252190SrpauloStart WPS PBC method (i.e., push the button). This allows a single WPS
586252190SrpauloEnrollee to connect to the AP/GO. This is used on the GO when a P2P
587252190Srpauloclient joins an existing group.
588252190Srpaulo
589252190Srpaulop2p_get_passphrase
590252190Srpaulo
591252190SrpauloGet the passphrase for a group (only available when acting as a GO).
592252190Srpaulo
593252190Srpaulop2p_presence_req [<duration> <interval>] [<duration> <interval>]
594252190Srpaulo
595252190SrpauloSend a P2P Presence Request to the GO (this is only available when
596252190Srpauloacting as a P2P client). If no duration/interval pairs are given, the
597252190Srpaulorequest indicates that this client has no special needs for GO
598281806Srpaulopresence. The first parameter pair gives the preferred duration and
599252190Srpaulointerval values in microseconds. If the second pair is included, that
600281806Srpauloindicates which value would be acceptable. This command returns OK
601281806Srpauloimmediately and the response from the GO is indicated in a
602281806SrpauloP2P-PRESENCE-RESPONSE event message.
603252190Srpaulo
604252190SrpauloParameters
605252190Srpaulo
606252190Srpaulop2p_ext_listen [<period> <interval>]
607252190Srpaulo
608252190SrpauloConfigure Extended Listen Timing. If the parameters are omitted, this
609252190Srpaulofeature is disabled. If the parameters are included, Listen State will
610252190Srpaulobe entered every interval msec for at least period msec. Both values
611252190Srpaulohave acceptable range of 1-65535 (with interval obviously having to be
612252190Srpaulolarger than or equal to duration). If the P2P module is not idle at
613252190Srpaulothe time the Extended Listen Timing timeout occurs, the Listen State
614252190Srpaulooperation will be skipped.
615252190Srpaulo
616252190SrpauloThe configured values will also be advertised to other P2P Devices. The
617252190Srpauloreceived values are available in the p2p_peer command output:
618252190Srpaulo
619252190Srpauloext_listen_period=100 ext_listen_interval=5000
620252190Srpaulo
621252190Srpaulop2p_set <field> <value>
622252190Srpaulo
623252190SrpauloChange dynamic P2P parameters
624252190Srpaulo
625252190Srpaulop2p_set discoverability <0/1>
626252190Srpaulo
627252190SrpauloDisable/enable advertisement of client discoverability. This is
628252190Srpauloenabled by default and this parameter is mainly used to allow testing
629252190Srpauloof device discoverability.
630252190Srpaulo
631252190Srpaulop2p_set managed <0/1>
632252190Srpaulo
633252190SrpauloDisable/enable managed P2P Device operations. This is disabled by
634252190Srpaulodefault.
635252190Srpaulo
636252190Srpaulop2p_set listen_channel <1/6/11>
637252190Srpaulo
638252190SrpauloSet P2P Listen channel. This is mainly meant for testing purposes and
639252190Srpaulochanging the Listen channel during normal operations can result in
640252190Srpauloprotocol failures.
641252190Srpaulo
642252190Srpaulop2p_set ssid_postfix <postfix>
643252190Srpaulo
644252190SrpauloSet postfix string to be added to the automatically generated P2P SSID
645252190Srpaulo(DIRECT-<two random characters>). For example, postfix of "-testing"
646252190Srpaulocould result in the SSID becoming DIRECT-ab-testing.
647252190Srpaulo
648281806Srpaulop2p_set per_sta_psk <0/1>
649281806Srpaulo
650281806SrpauloDisabled(default)/enables use of per-client PSK in the P2P groups. This
651281806Srpaulocan be used to request GO to assign a unique PSK for each client during
652281806SrpauloWPS provisioning. When enabled, this allow clients to be removed from
653281806Srpaulothe group securily with p2p_remove_client command since that client's
654281806SrpauloPSK is removed at the same time to prevent it from connecting back using
655281806Srpaulothe old PSK. When per-client PSK is not used, the client can still be
656281806Srpaulodisconnected, but it will be able to re-join the group since the PSK it
657281806Srpaulolearned previously is still valid. It should be noted that the default
658281806Srpaulopassphrase on the GO that is normally used to allow legacy stations to
659281806Srpauloconnect through manual configuration does not change here, so if that is
660281806Srpauloshared, devices with knowledge of that passphrase can still connect.
661281806Srpaulo
662252190Srpauloset <field> <value>
663252190Srpaulo
664252190SrpauloSet global configuration parameters which may also affect P2P
665252190Srpaulooperations. The format on these parameters is same as is used in
666252190Srpaulowpa_supplicant.conf. Only the parameters listen here should be
667252190Srpaulochanged. Modifying other parameters may result in incorrect behavior
668252190Srpaulosince not all existing users of the parameters are updated.
669252190Srpaulo
670252190Srpauloset uuid <UUID>
671252190Srpaulo
672252190SrpauloSet WPS UUID (by default, this is generated based on the MAC address).
673252190Srpaulo
674252190Srpauloset device_name <device name>
675252190Srpaulo
676252190SrpauloSet WPS Device Name (also included in some P2P messages).
677252190Srpaulo
678252190Srpauloset manufacturer <manufacturer>
679252190Srpaulo
680252190SrpauloSet WPS Manufacturer.
681252190Srpaulo
682252190Srpauloset model_name <model name>
683252190Srpaulo
684252190SrpauloSet WPS Model Name.
685252190Srpaulo
686252190Srpauloset model_number <model number>
687252190Srpaulo
688252190SrpauloSet WPS Model Number.
689252190Srpaulo
690252190Srpauloset serial_number <serial number>
691252190Srpaulo
692252190SrpauloSet WPS Serial Number.
693252190Srpaulo
694252190Srpauloset device_type <device type>
695252190Srpaulo
696252190SrpauloSet WPS Device Type.
697252190Srpaulo
698252190Srpauloset os_version <OS version>
699252190Srpaulo
700252190SrpauloSet WPS OS Version.
701252190Srpaulo
702252190Srpauloset config_methods <config methods>
703252190Srpaulo
704252190SrpauloSet WPS Configuration Methods.
705252190Srpaulo
706252190Srpauloset sec_device_type <device type>
707252190Srpaulo
708252190SrpauloAdd a new Secondary Device Type.
709252190Srpaulo
710252190Srpauloset p2p_go_intent <GO intent>
711252190Srpaulo
712252190SrpauloSet the default P2P GO Intent. Note: This value can be overridden in
713252190Srpaulop2p_connect command and as such, there should be no need to change the
714252190Srpaulodefault value here during normal operations.
715252190Srpaulo
716252190Srpauloset p2p_ssid_postfix <P2P SSID postfix>
717252190Srpaulo
718252190SrpauloSet P2P SSID postfix.
719252190Srpaulo
720252190Srpauloset persistent_reconnect <0/1>
721252190Srpaulo
722252190SrpauloDisable/enabled persistent reconnect for reinvocation of persistent
723252190Srpaulogroups. If enabled, invitations to reinvoke a persistent group will be
724252190Srpauloaccepted without separate authorization (e.g., user interaction).
725252190Srpaulo
726252190Srpauloset country <two character country code>
727252190Srpaulo
728252190SrpauloSet country code (this is included in some P2P messages).
729252190Srpaulo
730281806Srpauloset p2p_search_delay <delay>
731281806Srpaulo
732281806SrpauloSet p2p_search_delay which adds extra delay in milliseconds between
733281806Srpauloconcurrent search iterations to make p2p_find friendlier to concurrent
734281806Srpaulooperations by avoiding it from taking 100% of radio resources. The
735281806Srpaulodefault value is 500 ms.
736281806Srpaulo
737252190SrpauloStatus
738252190Srpaulo
739252190Srpaulop2p_peers [discovered]
740252190Srpaulo
741252190SrpauloList P2P Device Addresses of all the P2P peers we know. The optional
742252190Srpaulo"discovered" parameter filters out the peers that we have not fully
743252190Srpaulodiscovered, i.e., which we have only seen in a received Probe Request
744252190Srpauloframe.
745252190Srpaulo
746252190Srpaulop2p_peer <P2P Device Address>
747252190Srpaulo
748252190SrpauloFetch information about a known P2P peer.
749252190Srpaulo
750252190SrpauloGroup Status
751252190Srpaulo
752252190Srpaulo(These are used on the group interface.)
753252190Srpaulo
754252190Srpaulostatus
755252190Srpaulo
756252190SrpauloShow status information (connection state, role, use encryption
757252190Srpauloparameters, IP address, etc.).
758252190Srpaulo
759252190Srpaulosta
760252190Srpaulo
761252190SrpauloShow information about an associated station (when acting in AP/GO role).
762252190Srpaulo
763252190Srpauloall_sta
764252190Srpaulo
765252190SrpauloLists the currently associated stations.
766252190Srpaulo
767252190SrpauloConfiguration data
768252190Srpaulo
769252190Srpaulolist_networks
770252190Srpaulo
771252190SrpauloLists the configured networks, including stored information for
772252190Srpaulopersistent groups. The identifier in this list is used with
773252190Srpaulop2p_group_add and p2p_invite to indicate which persistent group is to
774252190Srpaulobe reinvoked.
775252190Srpaulo
776252190Srpauloremove_network <network id>
777252190Srpaulo
778252190SrpauloRemove a network entry from configuration. 
779252190Srpaulo
780252190Srpaulo
781281806SrpauloP2PS Events/Responses:
782281806Srpaulo
783281806SrpauloP2PS-PROV-START: This events gets triggered when provisioning is issued for
784281806Srpauloeither seeker or advertiser.
785281806Srpaulo
786281806SrpauloFor example,
787281806SrpauloP2PS-PROV-START 00:55:44:33:22:11 adv_id=111 adv_mac=00:55:44:33:22:11 conncap=1 session=1234567 session_mac=00:11:22:33:44:55 info='xxxx'
788281806Srpaulo
789281806SrpauloParameters definition:
790281806Srpaulo    MAC address - always
791281806Srpaulo    adv_id - always ASCII hex-encoded u32
792281806Srpaulo    adv_mac - always MAC address that owns/registered the service
793281806Srpaulo    conncap - always mask of 0x01 (new), 0x02 (group client), 0x04 (group owner)
794281806Srpaulo	bits
795281806Srpaulo    session - always Session ID of the first session to be established
796281806Srpaulo    session_mac - always MAC address that owns/initiated the session
797281806Srpaulo    info - if available, UTF-8 string
798281806Srpaulo	Escaped single quote & backslash with a backslash:
799281806Srpaulo	\' == 0x27 == ', and \\ == 0x5c == \
800281806Srpaulo
801281806SrpauloP2PS-PROV-DONE: When provisioning is completed then this event gets triggered.
802281806Srpaulo
803281806SrpauloFor example,
804281806SrpauloP2PS-PROV-DONE 00:11:22:33:44:55 status=0 adv_id=111 adv_mac=00:55:44:33:22:11 conncap=1 session=1234567 session_mac=00:11:22:33:44:55 [dev_passwd_id=8 | go=p2p-wlan0-0 | join=11:22:33:44:55:66 | persist=0]
805281806Srpaulo
806281806SrpauloParameters definition:
807281806Srpaulo    MAC address - always main device address of peer. May be different from MAC
808281806Srpaulo	ultimately connected to.
809281806Srpaulo    status - always ascii hex-encoded u8 (0 == success, 12 == deferred success)
810281806Srpaulo    adv_id - always ascii hex-encoded u32
811281806Srpaulo    adv_mac - always MAC address that owns/registered the service
812281806Srpaulo    conncap - always One of: 1 (new), 2 (group client), 4 (group owner) bits
813281806Srpaulo    session - always Session ID of the first session to be established
814281806Srpaulo    session_mac - always MAC address that owns/initiated the session
815281806Srpaulo    dev_passwd_id - only if conncap value == 1 (New GO negotiation)
816281806Srpaulo	8 - "p2ps" password must be passed in p2p_connect command
817281806Srpaulo	1 - "display" password must be passed in p2p_connect command
818281806Srpaulo	5 - "keypad" password must be passed in p2p_connect command
819281806Srpaulo    join only - if conncap value == 2 (Client Only). Display password and "join"
820281806Srpaulo	must be passed in p2p_connect and address must be the MAC specified
821281806Srpaulo    go only - if conncap value == 4 (GO Only). Interface name must be set with a
822281806Srpaulo	password
823281806Srpaulo    persist - only if previous persistent group existed between peers and shall
824281806Srpaulo	be re-used. Group is restarted by sending "p2p_group_add persistent=0"
825281806Srpaulo	where value is taken from P2P-PROV-DONE
826281806Srpaulo
827281806SrpauloExtended Events/Response
828281806Srpaulo
829281806SrpauloP2P-DEVICE-FOUND 00:11:22:33:44:55 p2p_dev_addr=00:11:22:33:44:55 pri_dev_type=0-00000000-0 name='' config_methods=0x108 dev_capab=0x21 group_capab=0x0 adv_id=111 asp_svc=alt.example.chat
830281806Srpaulo
831281806SrpauloParameters definition:
832281806Srpaulo    adv_id - if ASP ASCII hex-encoded u32. If it is reporting the
833281806Srpaulo	"wildcard service", this value will be 0
834281806Srpaulo    asp_svc - if ASP this is the service string. If it is reporting the
835281806Srpaulo	"wildcard service", this value will be org.wi-fi.wfds
836281806Srpaulo
837281806Srpaulo
838252190Srpaulowpa_cli action script
839252190Srpaulo---------------------
840252190Srpaulo
841252190SrpauloSee examples/p2p-action.sh
842252190Srpaulo
843252190SrpauloTODO: describe DHCP/DNS setup
844252190SrpauloTODO: cross-connection
845