Enable WiFi P2P link to Linux via wpa_supplicant

时间:2016-08-31 17:09:07

标签: c linux archlinux wifi-direct wpa-supplicant

I enable WiFi P2P connections to a Linux host via wpa_supplicant and a simple C program [1] calling the wpa_ctrl API [2]. After connect by a Nexus 7 Android tablet and then disconnect, the Linux host disappears from the tablet's list of P2P peers, and only reappears after rebooting the host. I have tried reissuing a p2p_ext_listen, restarting wpa_supplicant, and un/reloading the mwifiex_sdio driver with modprobe. I believe this is a bug outside my code, but if so, where?

[1] https://github.com/networkimprov/p2p-host/blob/master/main.c
Feel free to build & test on an x86 linux box :-)

[2] https://w1.fi/wpa_supplicant/devel/ctrl_iface_page.html

My Linux host:

  • wpa_supplicant 2.5 with -i p2p0 -D nl80211 -c /etc/wpa_supplicant/p2p0.conf
  • kernel 4.7.2 (mainline)
  • distro Arch Linux ARM
  • radio Marvell sd8787
  • cpu OMAP3

p2p0.conf:

ctrl_interface=/run/wpa_supplicant
ap_scan=1
device_name=mwifiex-p2p-device
device_type=1-0050F204-1
p2p_listen_reg_class=81
p2p_listen_channel=1
p2p_oper_reg_class=81
p2p_oper_channel=1
p2p_no_group_iface=1
p2p_go_intent=15

Program log (>>> flags msg to wpa_supplicant):

$ sudo p2p-host/p2phostd /run/wpa_supplicant/p2p0 75 1500 11111111
>>> P2P_EXT_LISTEN 75 1500
    OK
    <3>P2P-DEVICE-FOUND ae:22:0b:48:49:61 p2p_dev_addr=ae:22:0b:48:49:61 pri_dev_type=10-0050F204-5 name='Android_7326' config_methods=0x188 dev_capab=0x25 group_capab=0x0 new=1
    <3>P2P-PROV-DISC-SHOW-PIN ae:22:0b:48:49:61 72764473 p2p_dev_addr=ae:22:0b:48:49:61 pri_dev_type=10-0050F204-5 name='Android_7326' config_methods=0x188 dev_capab=0x25 group_capab=0x0
>>> P2P_CONNECT ae:22:0b:48:49:61 11111111 display go_intent=0
    OK
    <3>P2P-GO-NEG-SUCCESS role=client freq=2417 ht40=0 peer_dev=ae:22:0b:48:49:61 peer_iface=ae:22:0b:48:c9:61 wps_method=Display
    <3>CTRL-EVENT-SCAN-STARTED
    <3>CTRL-EVENT-BSS-ADDED 0 20:4e:7f:92:63:d6
    <3>CTRL-EVENT-SCAN-RESULTS
    <3>WPS-AP-AVAILABLE
    <3>CTRL-EVENT-SCAN-STARTED
    <3>CTRL-EVENT-BSS-ADDED 1 ae:22:0b:48:c9:61
    <3>CTRL-EVENT-SCAN-RESULTS
    <3>WPS-AP-AVAILABLE-AUTH
    <3>Trying to associate with ae:22:0b:48:c9:61 (SSID='DIRECT-Mw-Android_7326' freq=2417 MHz)
    <3>Associated with ae:22:0b:48:c9:61
    <3>CTRL-EVENT-EAP-STARTED EAP authentication started
    <3>CTRL-EVENT-EAP-STATUS status='started' parameter=''
    <3>CTRL-EVENT-EAP-PROPOSED-METHOD vendor=14122 method=1
    <3>CTRL-EVENT-EAP-STATUS status='accept proposed method' parameter='WSC'
    <3>CTRL-EVENT-EAP-METHOD EAP vendor 14122 method 1 (WSC) selected
    <3>WPS-CRED-RECEIVED
    <3>WPS-SUCCESS
    <3>P2P-GROUP-FORMATION-SUCCESS
    <3>CTRL-EVENT-EAP-STATUS status='completion' parameter='failure'
    <3>CTRL-EVENT-EAP-FAILURE EAP authentication failed
    <3>CTRL-EVENT-DISCONNECTED bssid=ae:22:0b:48:c9:61 reason=3 locally_generated=1
    <3>Trying to associate with ae:22:0b:48:c9:61 (SSID='DIRECT-Mw-Android_7326' freq=2417 MHz)
    <3>Associated with ae:22:0b:48:c9:61
    <3>WPA: Key negotiation completed with ae:22:0b:48:c9:61 [PTK=CCMP GTK=CCMP]
    <3>CTRL-EVENT-CONNECTED - Connection to ae:22:0b:48:c9:61 completed [id=0 id_str=]
    <3>P2P-GROUP-STARTED p2p0 client ssid="DIRECT-Mw-Android_7326" freq=2417 psk=... go_dev_addr=ae:22:0b:48:49:61 [PERSISTENT]
...disconnect after a short while...
    <3>CTRL-EVENT-BSS-REMOVED 0 20:4e:7f:92:63:d6
    <3>CTRL-EVENT-DISCONNECTED bssid=ae:22:0b:48:c9:61 reason=3
    <3>CTRL-EVENT-DISCONNECTED bssid=ae:22:0b:48:c9:61 reason=3 locally_generated=1
    <3>P2P-GROUP-REMOVED p2p0 client reason=GO_ENDING_SESSION
...Linux host disappears from P2P list...
^C
$ wget help

0 个答案:

没有答案