hostapd no funciona desde adb shell

Tengo un LG G3 con 5.1.1 y puedo habilitar con éxito el punto de acceso Wi-Fi portátil a través del menú Configuración. Puedo ver mi SSID Wi-Fi portátil en otro dispositivo Android cuando está habilitado a través del menú Configuración.

Además, puedo confirmar que hostapd se está ejecutando con un archivo de configuración generado automáticamente.

root@d851:/ # ps | grep hostapd
wifi      6841  302   10892  1280  c026dd60 b6ed98b4 S /system/bin/hostapd
root@d851:/ # cat /proc/6841/cmdline
/system/bin/hostapd -e /data/misc/wifi/entropy.bin /data/misc/wifi/hostapd.conf

Mi problema surge cuando intento ejecutar hostapd manualmente a través de adb shell utilizando exactamente los mismos argumentos que hostapd generado a través del menú Configuración. Estoy deshabilitando Wi-Fi manualmente a través del menú de configuración y emitiendo el siguiente comando. Parece que hostapd se inicializa correctamente, pero otros dispositivos nunca ven el SSID de Wi-Fi.

root@d851:/ # /system/bin/hostapd -ddd -e /data/misc/wifi/entropy.bin /data/misc/wifi/hostapd.conf

Lo siguiente fue capturado de logcat cuando se emitió el comando anterior.

D/hostapd ( 7885): Add randomness: count=1 entropy=0
D/hostapd ( 7885): random pool - hexdump(len=128): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=8): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random pool - hexdump(len=128): [REMOVED]
D/hostapd ( 7885): random: Added entropy from /data/misc/wifi/entropy.bin (own_pool_ready=2)
D/hostapd ( 7885): random: Trying to read entropy from /dev/random
D/hostapd ( 7885): Get randomness: len=20 entropy=1
D/hostapd ( 7885): random from os_get_random - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): mixed random - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random: Updated entropy file /data/misc/wifi/entropy.bin (own_pool_ready=2)
E/hostapd ( 7885): Configuration file: /data/misc/wifi/hostapd.conf
D/hostapd ( 7885): rfkill: initial event: idx=0 type=2 op=0 soft=1 hard=0
D/hostapd ( 7885): rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0
D/hostapd ( 7885): rfkill: initial event: idx=2 type=1 op=0 soft=0 hard=0
D/hostapd ( 7885): nl80211: Supported cipher 00-0f-ac:1
D/hostapd ( 7885): nl80211: Supported cipher 00-0f-ac:5
D/hostapd ( 7885): nl80211: Supported cipher 00-0f-ac:2
D/hostapd ( 7885): nl80211: Supported cipher 00-0f-ac:4
D/hostapd ( 7885): nl80211: Supported cipher 00-0f-ac:6
D/hostapd ( 7885): nl80211: Using driver-based off-channel TX
D/hostapd ( 7885): nl80211: TDLS supported
D/hostapd ( 7885): nl80211: Supported key managment offloads 0x0
D/hostapd ( 7885): nl80211: Supported key derivation offloads 0x0
D/hostapd ( 7885): nl80211: Use separate P2P group interface (driver advertised support)
D/hostapd ( 7885): nl80211: Enable multi-channel concurrent (driver advertised support)
D/hostapd ( 7885): nl80211: Disable use_monitor with device_ap_sme since no monitor mode support detected
D/hostapd ( 7885): nl80211: interface wlan0 in phy phy0
D/hostapd ( 7885): nl80211: Set mode ifindex 23 iftype 3 (AP)
D/hostapd ( 7885): nl80211: Setup AP(wlan0) - device_ap_sme=1 use_monitor=0
D/hostapd ( 7885): nl80211: Subscribe to mgmt frames with AP handle 0xb643e0a0 (device SME)
D/hostapd ( 7885): nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0xb643e0a0 match=
D/hostapd ( 7885): nl80211: Enable Probe Request reporting nl_preq=0xb643e0d0
D/hostapd ( 7885): nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0xb643e0d0 match=
D/hostapd ( 7885): nl80211: Add own interface ifindex 23
D/hostapd ( 7885): nl80211: if_indices[16]: 23
D/hostapd ( 7885): Unknown/unsupported wowlan trigger 'any'
D/hostapd ( 7885): phy: phy0
D/hostapd ( 7885): BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
D/hostapd ( 7885): nl80211: Regulatory information - country=00
D/hostapd ( 7885): nl80211: 2402-2472 @ 40 MHz 20 mBm
D/hostapd ( 7885): nl80211: 2457-2482 @ 40 MHz 20 mBm (no IR)
D/hostapd ( 7885): nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)
D/hostapd ( 7885): nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR)
D/hostapd ( 7885): nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR)
D/hostapd ( 7885): nl80211: 57240-63720 @ 2160 MHz 0 mBm
D/hostapd ( 7885): nl80211: Added 802.11b mode based on 802.11g information
D/hostapd ( 7885): Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=36 freq=5180 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=40 freq=5200 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=44 freq=5220 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=48 freq=5240 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=144 freq=5720 MHz max_tx_power=0 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=149 freq=5745 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=153 freq=5765 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=157 freq=5785 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=161 freq=5805 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=2 chan=165 freq=5825 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=20 dBm
D/hostapd ( 7885): Completing interface initialization
D/hostapd ( 7885): Mode: IEEE 802.11g  Channel: 6  Frequency: 2437 MHz
D/hostapd ( 7885): DFS 0 channels required radar detection
D/hostapd ( 7885): nl80211: Set freq 2437 (ht_enabled=1, vht_enabled=0, bandwidth=20 MHz, cf1=2437 MHz, cf2=0 MHz)
D/hostapd ( 7885): RATE[0] rate=10 flags=0x1
D/hostapd ( 7885): RATE[1] rate=20 flags=0x1
D/hostapd ( 7885): RATE[2] rate=55 flags=0x1
D/hostapd ( 7885): RATE[3] rate=110 flags=0x1
D/hostapd ( 7885): RATE[4] rate=60 flags=0x0
D/hostapd ( 7885): RATE[5] rate=90 flags=0x0
D/hostapd ( 7885): RATE[6] rate=120 flags=0x0
D/hostapd ( 7885): RATE[7] rate=180 flags=0x0
D/hostapd ( 7885): RATE[8] rate=240 flags=0x0
D/hostapd ( 7885): RATE[9] rate=360 flags=0x0
D/hostapd ( 7885): RATE[10] rate=480 flags=0x0
D/hostapd ( 7885): RATE[11] rate=540 flags=0x0
D/hostapd ( 7885): hostapd_setup_bss(hapd=0xb6456600 (wlan0), first=1)
D/hostapd ( 7885): wlan0: Flushing old station entries
D/hostapd ( 7885): nl80211: flush -> DEL_STATION wlan0 (all)
D/hostapd ( 7885): wlan0: Deauthenticate all stations
D/hostapd ( 7885): nl80211: sta_remove -> DEL_STATION wlan0 ff:ff:ff:ff:ff:ff --> 0 (Success)
D/hostapd ( 7885): wpa_driver_nl80211_set_key: ifindex=23 (wlan0) alg=0 addr=0x0 key_idx=0 set_tx=0 seq_len=0 key_len=0
D/hostapd ( 7885): wpa_driver_nl80211_set_key: ifindex=23 (wlan0) alg=0 addr=0x0 key_idx=1 set_tx=0 seq_len=0 key_len=0
D/hostapd ( 7885): wpa_driver_nl80211_set_key: ifindex=23 (wlan0) alg=0 addr=0x0 key_idx=2 set_tx=0 seq_len=0 key_len=0
D/hostapd ( 7885): wpa_driver_nl80211_set_key: ifindex=23 (wlan0) alg=0 addr=0x0 key_idx=3 set_tx=0 seq_len=0 key_len=0
E/hostapd ( 7885): Using interface wlan0 with hwaddr 00:90:4c:c5:12:38 and ssid "Redskins"
D/hostapd ( 7885): wpa_driver_set_ap_wps_p2p_ie: Entry
D/hostapd ( 7885): random: Got 20/20 bytes from /dev/random
D/hostapd ( 7885): Get randomness: len=20 entropy=0
D/hostapd ( 7885): random from os_get_random - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): mixed random - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random: Updated entropy file /data/misc/wifi/entropy.bin (own_pool_ready=2)
D/hostapd ( 7885): Get randomness: len=32 entropy=0
D/hostapd ( 7885): random from os_get_random - hexdump(len=32): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): mixed random - hexdump(len=32): [REMOVED]
D/hostapd ( 7885): GMK - hexdump(len=32): [REMOVED]
D/hostapd ( 7885): Get randomness: len=32 entropy=0
D/hostapd ( 7885): random from os_get_random - hexdump(len=32): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): mixed random - hexdump(len=32): [REMOVED]
D/hostapd ( 7885): Key Counter - hexdump(len=32): [REMOVED]
D/hostapd ( 7885): WPA: Delay group state machine start until Beacon frames have been configured
D/hostapd ( 7885): nl80211: Set beacon (beacon_set=0)
D/hostapd ( 7885): nl80211: Beacon head - hexdump(len=59): 80 00 00 00 ff ff ff ff ff ff 00 90 4c c5 12 38 00 90 4c c5 12 38 00 00 00 00 00 00 00 00 00 00 ...
D/hostapd ( 7885): nl80211: Beacon tail - hexdump(len=109): 2a 01 04 32 04 30 48 60 6c 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 0c 00 2d ...
D/hostapd ( 7885): nl80211: ifindex=23
D/hostapd ( 7885): nl80211: beacon_int=100
D/hostapd ( 7885): nl80211: dtim_period=2
D/hostapd ( 7885): nl80211: ssid - hexdump(len=8): 52 65 64 73 6b 69 6e 73
D/hostapd ( 7885): nl80211: hidden SSID not in use
D/hostapd ( 7885): nl80211: privacy=1
D/hostapd ( 7885): nl80211: auth_algs=0x3
D/hostapd ( 7885): nl80211: wpa_version=0x2
D/hostapd ( 7885): nl80211: key_mgmt_suites=0x2
D/hostapd ( 7885): nl80211: pairwise_ciphers=0x18
D/hostapd ( 7885): nl80211: group_cipher=0x10
D/hostapd ( 7885): WPA: Start group state machine to set initial keys
D/hostapd ( 7885): WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
D/hostapd ( 7885): Get randomness: len=16 entropy=0
D/hostapd ( 7885): random from os_get_random - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): random_mix_pool - hexdump(len=20): [REMOVED]
D/hostapd ( 7885): random from internal pool - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): mixed random - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): GTK - hexdump(len=16): [REMOVED]
D/hostapd ( 7885): WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
D/hostapd ( 7885): wpa_driver_nl80211_set_key: ifindex=23 (wlan0) alg=3 addr=0xb6f9988a key_idx=1 set_tx=1 seq_len=0 key_len=16
D/hostapd ( 7885): nl80211: KEY_DATA - hexdump(len=16): [REMOVED]
D/hostapd ( 7885):    broadcast key
D/hostapd ( 7885): nl80211: Set wlan0 operstate 0->1 (UP)
D/hostapd ( 7885): netlink: Operstate: ifindex=23 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
D/hostapd ( 7885): Failed to set TX queue parameters for queue 0.
D/hostapd ( 7885): Failed to set TX queue parameters for queue 1.
D/hostapd ( 7885): Failed to set TX queue parameters for queue 2.
D/hostapd ( 7885): Failed to set TX queue parameters for queue 3.
I/hostapd ( 7885): wlan0: interface state UNINITIALIZED->ENABLED
I/hostapd ( 7885): wlan0: AP-ENABLED 
D/hostapd ( 7885): wlan0: Setup of interface done.
D/hostapd ( 7885): ctrl_iface not configured!
D/hostapd ( 7885): RTM_NEWLINK: ifi_index=23 ifname=wlan0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])

¿Por qué ejecutar hostapd con exactamente el mismo archivo de configuración a través de adb shell no crea una red Wi-Fi visible para otros dispositivos? SELinux está en modo permisivo, así que lo he descartado. ¿Qué me estoy perdiendo posiblemente? ¿Hay alguna otra pieza de configuración que sea necesaria para habilitar el punto de acceso Wi-Fi portátil desde adb shell?

Cualquier ayuda es muy apreciada.

también mire el proceso wpa_supplicant

Respuestas (1)

En realidad, hay otro paso antes de ejecutar la línea de comando al ejecutar hostapd con el archivo conf, que es cargar el firmware. Y esto es exactamente por qué hay esta impresión:

D/hostapd (7885): ¡ctrl_iface no configurado!

El firmware cargado probará una interfaz en /data/misc/wifi/hostapd y este es el socket de dominio Unix para el cual el cliente hostapd puede comunicarse con el kernel.

Agregue algunas impresiones de depuración en SoftAPController.cpp y verá la imagen completa.

Entonces, ¿cómo se carga el firmware antes de ejecutar hostapd?
La carga de firmware es específica del proveedor, está a cargo de HAL. Para dispositivos Qualcomm: android.stackexchange.com/a/219548/218526