Functions
wifi.h File Reference

Go to the source code of this file.

Functions

int do_dhcp_request (int *ipaddr, int *gateway, int *mask, int *dns1, int *dns2, int *server, int *lease)
 do_dhcp_request() issues a dhcp request and returns the acquired information. More...
 
int ensure_entropy_file_exists ()
 
const char * get_dhcp_error_string ()
 Return the error string of the last do_dhcp_request(). More...
 
int is_wifi_driver_loaded ()
 Check if the Wi-Fi driver is loaded. More...
 
int wifi_change_fw_path (const char *fwpath)
 Change the path to firmware for the wlan driver. More...
 
void wifi_close_supplicant_connection ()
 Close connection supplicant. More...
 
int wifi_command (const char *command, char *reply, size_t *reply_len)
 wifi_command() issues a command to the Wi-Fi driver. More...
 
int wifi_connect_to_supplicant ()
 Open a connection to supplicant. More...
 
const char * wifi_get_fw_path (int fw_type)
 
int wifi_load_driver ()
 Load the Wi-Fi driver. More...
 
int wifi_start_p2p_supplicant ()
 Start supplicant for p2p operation. More...
 
int wifi_start_supplicant ()
 Start supplicant. More...
 
int wifi_stop_supplicant ()
 Stop supplicant. More...
 
int wifi_unload_driver ()
 Unload the Wi-Fi driver. More...
 
int wifi_wait_for_event (char *buf, size_t len)
 wifi_wait_for_event() performs a blocking call to get a Wi-Fi event and returns a string representing a Wi-Fi event when it occurs. More...
 

Function Documentation

int do_dhcp_request ( int *  ipaddr,
int *  gateway,
int *  mask,
int *  dns1,
int *  dns2,
int *  server,
int *  lease 
)

do_dhcp_request() issues a dhcp request and returns the acquired information.

All IPV4 addresses/mask are in network byte order.

Parameters
ipaddrreturn the assigned IPV4 address
gatewayreturn the gateway being used
maskreturn the IPV4 mask
dns1return the IPV4 address of a DNS server
dns2return the IPV4 address of a DNS server
serverreturn the IPV4 address of DHCP server
leasereturn the length of lease in seconds.
Returns
0 if successful, < 0 if error.
int ensure_entropy_file_exists ( )
const char* get_dhcp_error_string ( )

Return the error string of the last do_dhcp_request().

int is_wifi_driver_loaded ( )

Check if the Wi-Fi driver is loaded.

Returns
0 on success, < 0 on failure.
int wifi_change_fw_path ( const char *  fwpath)

Change the path to firmware for the wlan driver.

void wifi_close_supplicant_connection ( )

Close connection supplicant.

Returns
0 on success, < 0 on failure.
int wifi_command ( const char *  command,
char *  reply,
size_t *  reply_len 
)

wifi_command() issues a command to the Wi-Fi driver.

Android extends the standard commands listed at /link http://hostap.epitest.fi/wpa_supplicant/devel/ctrl_iface_page.html to include support for sending commands to the driver:

Command / Command summary Form of Response Processing
DRIVER START
  Turn on Wi-Fi Hardware
OK if successful OK ? true : false
DRIVER STOP
  Turn off Wi-Fi hardware
OK if successful OK ? true : false
DRIVER RSSI
  Return received signal strength indicator in -db for current AP
<ssid> Rssi xx %*s %*s d", &rssi
DRIVER LINKSPEED
  Return link speed in MBPS
LinkSpeed xx %*s d", &linkspd
DRIVER MACADDR
  Return mac address of the station
Macaddr = xx.xx.xx.xx.xx.xx "%*s = %s", &macadr
DRIVER SCAN-ACTIVE
  Set scan type to active
"OK" if successful "OK" ? true : false
DRIVER SCAN-PASSIVE
  Set scan type to passive
"OK" if successful "OK" ? true : false

See libs/android_runtime/android_net_wifi_Wifi.cpp for more information describing how these and other commands are invoked.

Parameters
commandis the string command
replyis a buffer to receive a reply string
reply_lenon entry, this is the maximum length of the reply buffer. On exit, the number of bytes in the reply buffer.
Returns
0 if successful, < 0 if an error.
int wifi_connect_to_supplicant ( )

Open a connection to supplicant.

Returns
0 on success, < 0 on failure.
const char* wifi_get_fw_path ( int  fw_type)
int wifi_load_driver ( )

Load the Wi-Fi driver.

Returns
0 on success, < 0 on failure.
int wifi_start_p2p_supplicant ( )

Start supplicant for p2p operation.

Returns
0 on success, < 0 on failure.
int wifi_start_supplicant ( )

Start supplicant.

Returns
0 on success, < 0 on failure.
int wifi_stop_supplicant ( )

Stop supplicant.

Returns
0 on success, < 0 on failure.
int wifi_unload_driver ( )

Unload the Wi-Fi driver.

Returns
0 on success, < 0 on failure.
int wifi_wait_for_event ( char *  buf,
size_t  len 
)

wifi_wait_for_event() performs a blocking call to get a Wi-Fi event and returns a string representing a Wi-Fi event when it occurs.

Parameters
bufis the buffer that receives the event
lenis the maximum length of the buffer
Returns
number of bytes in buffer, 0 if no event (for instance, no connection), and less than 0 if there is an error.