2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 * Load the Wi-Fi driver.
27 * @return 0 on success, < 0 on failure.
29 int wifi_load_driver();
32 * Unload the Wi-Fi driver.
34 * @return 0 on success, < 0 on failure.
36 int wifi_unload_driver();
39 * Check if the Wi-Fi driver is loaded.
41 * @return 0 on success, < 0 on failure.
43 int is_wifi_driver_loaded();
49 * @return 0 on success, < 0 on failure.
51 int wifi_start_supplicant(int p2pSupported);
56 * @return 0 on success, < 0 on failure.
58 int wifi_stop_supplicant();
61 * Open a connection to supplicant on interface
63 * @return 0 on success, < 0 on failure.
65 int wifi_connect_to_supplicant(const char *ifname);
68 * Close connection to supplicant on interface
70 * @return 0 on success, < 0 on failure.
72 void wifi_close_supplicant_connection(const char *ifname);
75 * wifi_wait_for_event() performs a blocking call to
76 * get a Wi-Fi event and returns a string representing
77 * a Wi-Fi event when it occurs.
79 * @param iface is the interface on which event is received
80 * @param buf is the buffer that receives the event
81 * @param len is the maximum length of the buffer
83 * @returns number of bytes in buffer, 0 if no
84 * event (for instance, no connection), and less than 0
85 * if there is an error.
87 int wifi_wait_for_event(const char *iface, char *buf, size_t len);
90 * wifi_command() issues a command to the Wi-Fi driver.
92 * Android extends the standard commands listed at
93 * /link http://hostap.epitest.fi/wpa_supplicant/devel/ctrl_iface_page.html
94 * to include support for sending commands to the driver:
96 * See wifi/java/android/net/wifi/WifiNative.java for the details of
97 * driver commands that are supported
99 * @param iface is the interface on which command is sent
100 * @param command is the string command
101 * @param reply is a buffer to receive a reply string
102 * @param reply_len on entry, this is the maximum length of
103 * the reply buffer. On exit, the number of
104 * bytes in the reply buffer.
106 * @return 0 if successful, < 0 if an error.
108 int wifi_command(const char *iface, const char *command, char *reply, size_t *reply_len);
111 * do_dhcp_request() issues a dhcp request and returns the acquired
114 * All IPV4 addresses/mask are in network byte order.
116 * @param ipaddr return the assigned IPV4 address
117 * @param gateway return the gateway being used
118 * @param mask return the IPV4 mask
119 * @param dns1 return the IPV4 address of a DNS server
120 * @param dns2 return the IPV4 address of a DNS server
121 * @param server return the IPV4 address of DHCP server
122 * @param lease return the length of lease in seconds.
124 * @return 0 if successful, < 0 if error.
126 int do_dhcp_request(int *ipaddr, int *gateway, int *mask,
127 int *dns1, int *dns2, int *server, int *lease);
130 * Return the error string of the last do_dhcp_request().
132 const char *get_dhcp_error_string();
135 * Return the path to requested firmware
137 #define WIFI_GET_FW_PATH_STA 0
138 #define WIFI_GET_FW_PATH_AP 1
139 #define WIFI_GET_FW_PATH_P2P 2
140 const char *wifi_get_fw_path(int fw_type);
143 * Change the path to firmware for the wlan driver
145 int wifi_change_fw_path(const char *fwpath);
148 * Check and create if necessary initial entropy file
150 #define WIFI_ENTROPY_FILE "/data/misc/wifi/entropy.bin"
151 int ensure_entropy_file_exists();