| 1 | {{{#!html |
| 2 | <div id="wikipage" class="trac-content"><p> |
| 3 | </p><div class="wiki-toc"> |
| 4 | <ol> |
| 5 | <li> |
| 6 | <a href="#AndroidWi-Fi">Android Wi-Fi</a> |
| 7 | <ol> |
| 8 | <li> |
| 9 | <a href="#Build-timeConfiguration">Build-time Configuration</a> |
| 10 | </li> |
| 11 | <li> |
| 12 | <a href="#AndroidFrameworkAPI">Android Framework API</a> |
| 13 | </li> |
| 14 | <li> |
| 15 | <a href="#Packages">Packages</a> |
| 16 | </li> |
| 17 | <li> |
| 18 | <a href="#FirmwareandKernelModuleloading">Firmware and Kernel Module loading</a> |
| 19 | </li> |
| 20 | <li> |
| 21 | <a href="#ClientMode">Client Mode</a> |
| 22 | <ol> |
| 23 | <li> |
| 24 | <a href="#Configuration">Configuration</a> |
| 25 | </li> |
| 26 | <li> |
| 27 | <a href="#Operation">Operation</a> |
| 28 | <ol> |
| 29 | <li> |
| 30 | <a href="#AndroidUI">Android UI</a> |
| 31 | </li> |
| 32 | <li> |
| 33 | <a href="#AndroidApplication">Android Application</a> |
| 34 | </li> |
| 35 | <li> |
| 36 | <a href="#command-line">command-line</a> |
| 37 | </li> |
| 38 | </ol> |
| 39 | </li> |
| 40 | </ol> |
| 41 | </li> |
| 42 | <li> |
| 43 | <a href="#AccessPointMode">Access Point Mode</a> |
| 44 | <ol> |
| 45 | <li> |
| 46 | <a href="#Configuration1">Configuration</a> |
| 47 | </li> |
| 48 | <li> |
| 49 | <a href="#Operation1">Operation</a> |
| 50 | <ol> |
| 51 | <li> |
| 52 | <a href="#AndroidUI1">Android UI</a> |
| 53 | </li> |
| 54 | <li> |
| 55 | <a href="#AndroidApplication1">Android Application</a> |
| 56 | </li> |
| 57 | <li> |
| 58 | <a href="#command-line1">command-line</a> |
| 59 | </li> |
| 60 | </ol> |
| 61 | </li> |
| 62 | </ol> |
| 63 | </li> |
| 64 | </ol> |
| 65 | </li> |
| 66 | </ol> |
| 67 | </div><p> |
| 68 | </p> |
| 69 | <p> |
| 70 | See also: |
| 71 | </p> |
| 72 | <ul><li><a class="wiki" href="/wiki/Android#bluetooth">Android Bluetooth</a> |
| 73 | </li><li><a class="wiki" href="/wiki/Android#nfc">Android NFC</a> |
| 74 | </li></ul><h1 id="AndroidWi-Fi">Android Wi-Fi</h1> |
| 75 | <p> |
| 76 | Android uses the standard <a class="ext-link" href="https://w1.fi/hostapd/"><span class="icon"></span>hostapd</a> and <a class="ext-link" href="http://w1.fi/wpa_supplicant/"><span class="icon"></span>wpa_supplicant</a> users-space daemons for Access Point and authentication management. These are fairly close forks of the upstream projects with some changes specifically for Android. Source for both is currently in the external/wpa_supplicent_8 directory. Currently this relates most closely to the version 2.1-devel branch. |
| 77 | </p> |
| 78 | <p> |
| 79 | The Android network daemon <tt>netd</tt> (source in /system/netd) manages the overall Linux based network configuration listening for commands over a socket interface. There is a Network Daemon Command shell application, <tt>ndc</tt> that can be used to send/receive commands via command-line. |
| 80 | </p> |
| 81 | <p> |
| 82 | The <tt>wifi</tt> legacy module in hardware/hardware_liblegacy/wifi.c implements the API defined in <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/hardware/libhardware_legacy/include/hardware_legacy/wifi.h"><span class="icon"></span>hardware/libhardware_legacy/include/hardware_legacy/wifi.h</a> |
| 83 | </p> |
| 84 | <p> |
| 85 | <span class="wikianchor" id="build-config"></span> |
| 86 | </p> |
| 87 | <h2 id="Build-timeConfiguration">Build-time Configuration</h2> |
| 88 | <p> |
| 89 | The BoardConfig.mk file for your build target defines the details of the configuration of <tt>hostapd</tt> and <tt>wpa_supplicant</tt> used in the build process. |
| 90 | </p> |
| 91 | <p> |
| 92 | The Gateworks Android BSP defines the following: |
| 93 | </p> |
| 94 | <pre class="wiki"># wireless device (used by various modules to include per-device support) |
| 95 | BOARD_WLAN_DEVICE := wl12xx_mac80211 |
| 96 | |
| 97 | # Supplicant |
| 98 | WPA_SUPPLICANT_VERSION := VER_0_8_X |
| 99 | BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_wl12xx |
| 100 | # skip populating rtl/conf files |
| 101 | SKIP_WPA_SUPPLICANT_RTL := y |
| 102 | SKIP_WPA_SUPPLICANT_CONF := y |
| 103 | |
| 104 | # AP |
| 105 | HOSTAPD_VERSION := VER_0_8_x |
| 106 | BOARD_HOSTAPD_DRIVER := NL80211 |
| 107 | BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_wl12xx |
| 108 | </pre><ul><li>the wl12xx configuration and library are fairly mac80211 compliant and thus should provide support for all mac80211 drivers we include |
| 109 | </li><li>the 'PRIVATE_LIB's are used when communicating with the driver and allow for easy customization |
| 110 | </li></ul><p> |
| 111 | Additional defines can be used for drivers that require specific kernel modules to be loaded or firmware to be loaded for various operation modes. The actual loading of the modules and firmware is done by <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/hardware/libhardware_legacy/wifi/wifi.c"><span class="icon"></span>wifi.c</a>: |
| 112 | </p> |
| 113 | <pre class="wiki"># kernel modules |
| 114 | WIFI_DRIVER_MODULE_PATH - full path of kernel module(s) |
| 115 | WIFI_DRIVER_MODULE_NAME - kernel module name (w/o the ko) |
| 116 | WIFI_DRIVER_MODULE_ARG - kernel module params |
| 117 | WIFI_DRIVER_P2P_MODULE_ARG |
| 118 | |
| 119 | # firmware |
| 120 | WIFI_FIRMWARE_LOADER - firmware loader |
| 121 | WIFI_DRIVER_FW_PATH_PARAM - params to pass to fw loader |
| 122 | WIFI_DRIVER_FW_PATH_AP - full path to AP firmware |
| 123 | WIFI_DRIVER_FW_PATH_STA - full path to STA firmware |
| 124 | WIFI_DRIVER_FW_PATH_P2P - full path to P2P firmware |
| 125 | </pre><ul><li>Note by default these are all blank or null meaning not used and the Gateworks BSP does not define these meaning it supports wireless devices that either need no module/firmware loading or that it is assumed that was done during init.sh |
| 126 | </li></ul><p> |
| 127 | <span class="wikianchor" id="framework"></span> |
| 128 | </p> |
| 129 | <h2 id="AndroidFrameworkAPI">Android Framework API</h2> |
| 130 | <p> |
| 131 | The Android framework talks to {{{netd}} via the <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/services/java/com/android/server/NetworkManagementService.java"><span class="icon"></span>NetworkManagementService class</a> |
| 132 | </p> |
| 133 | <p> |
| 134 | The <a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiManager.html"><span class="icon"></span>WifiManager</a> class provides the primary API for managing al aspects of Wi-Fi connectivity. To perform operations that pertain to network connectivity at an abstract level use <a class="ext-link" href="http://developer.android.com/reference/android/net/ConnectivityManager.html"><span class="icon"></span>ConnectivityManager</a> which answers queries about the state of network connectivity and notifies applications when network connectivity changes. |
| 135 | </p> |
| 136 | <p> |
| 137 | The <a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiConfiguration.html"><span class="icon"></span>WifiConfiguration</a> class reprsents a configured Wi-Fi network, including the security configuration. Android is not intended to provide a build that is suitable for all wireless devices and you may find that customization via the above is necessary. |
| 138 | </p> |
| 139 | <p> |
| 140 | <span class="wikianchor" id="packages"></span> |
| 141 | </p> |
| 142 | <h2 id="Packages">Packages</h2> |
| 143 | <p> |
| 144 | The Android modules/packages required for wireless are: |
| 145 | </p> |
| 146 | <ul><li>client mode: wpa_supplicant |
| 147 | </li><li>access point mode: hostapd hostapd_cli dnsmasq iptables |
| 148 | </li></ul><p> |
| 149 | <span class="wikianchor" id="kernel-modules"></span> |
| 150 | <span class="wikianchor" id="firmware"></span> |
| 151 | </p> |
| 152 | <h2 id="FirmwareandKernelModuleloading">Firmware and Kernel Module loading</h2> |
| 153 | <p> |
| 154 | The <tt>libhardware_legacy</tt> module provides an API used by the Android framework that facilitates kernel module loading, firmware loading, wpa_supplicant service management, and dhcp service management. The module is heavily configurable for specific wireless devices at build-time through: |
| 155 | </p> |
| 156 | <ul><li>BoardConfig.mk variables: |
| 157 | <pre class="wiki"># kernel Module |
| 158 | WIFI_DRIVER_MODULE_NAME |
| 159 | WIFI_DRIVER_MODULE_PATH |
| 160 | WIFI_DRIVER_MODULE_ARG |
| 161 | |
| 162 | # Firmware |
| 163 | WIFI_FIRMWARE_LOADER |
| 164 | WIFI_DRIVER_FW_PATH_STA |
| 165 | WIFI_DRIVER_FW_PATH_AP |
| 166 | WIFI_DRIVER_FW_PATH_P2P |
| 167 | WIFI_DRIVER_FW_PATH_PARAM |
| 168 | </pre></li><li>functions and their native JNI mappings via WifiNative class: |
| 169 | <ul><li>driver loading/unloading (used by android_net_wifi_WifiNative.cpp) |
| 170 | <ul><li>wifi_load_driver() / loadDriver |
| 171 | </li><li>wifi_unload_driver() / unloadDriver |
| 172 | </li><li>is_wifi_driver_loaded() / isDriverLoaded |
| 173 | </li></ul></li><li>supplicant (used by android_net_wifi_WifiNative.cpp) |
| 174 | <ul><li>wifi_start_supplicant() / startSupplicant |
| 175 | </li><li>wifi_stop_supplicant() / killSupplicant |
| 176 | </li><li>wifi_connect_to_supplicant() / connectToSupplicantNative |
| 177 | </li><li>wifi_close_supplicant_connection() / closeSupplicantConnectionNative |
| 178 | </li></ul></li><li>configuration (used by android_net_wifi_WifiNative.cpp) |
| 179 | <ul><li>wifi_wait_for_event() / waitForEventNative |
| 180 | </li><li>wifi_command() / doBoolenaCommandNative / doIntCommandNative / doStringCommandNative |
| 181 | </li></ul></li><li>DHCP |
| 182 | <ul><li>do_dhcp_request() |
| 183 | </li><li>get_dhcp_error_string() |
| 184 | </li></ul></li><li>firmware loading (used by SoftapController.cpp) |
| 185 | <ul><li>wifi_get_fw_path() |
| 186 | </li><li>wifi_change_fw_path() |
| 187 | </li></ul></li></ul></li><li>paths for the user-space daemons are stored in wifi.c |
| 188 | </li></ul><p> |
| 189 | <span class="wikianchor" id="sta"></span> |
| 190 | </p> |
| 191 | <h2 id="ClientMode">Client Mode</h2> |
| 192 | <p> |
| 193 | Android uses the standard <a class="ext-link" href="http://w1.fi/wpa_supplicant/"><span class="icon"></span>wpa_supplicant</a> users-space daemon for Access Point and authentication management on the client-side. |
| 194 | </p> |
| 195 | <h3 id="Configuration">Configuration</h3> |
| 196 | <p> |
| 197 | The <tt>wpa_supplicant.conf</tt> file is stored in /data/misc/wifi/wpa_supplicant.conf and used by the <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/wifi/java/android/net/wifi/WifiConfigStore.java"><span class="icon"></span>WifiConfigStore class</a> and the <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java"><span class="icon"></span>SettingsBackupAgent class</a> |
| 198 | </p> |
| 199 | <h3 id="Operation">Operation</h3> |
| 200 | <p> |
| 201 | The <tt>wpa_supplicant</tt> application runs as a backgaround daemon launched by the Android <tt>init</tt> process. It is communicated with via a socket. |
| 202 | </p> |
| 203 | <h4 id="AndroidUI">Android UI</h4> |
| 204 | <p> |
| 205 | You can use Wireless Networking Client support via the Settings App: Settings -> Wi-Fi. You must enable Wi-Fi and configure one or more Wi-Fi networks at which point the <a class="missing wiki">NetworkManagementService?</a> will handle the associations. |
| 206 | </p> |
| 207 | <h4 id="AndroidApplication">Android Application</h4> |
| 208 | <p> |
| 209 | An Application can use Wireless Client mode via the <a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiConfiguration.html"><span class="icon"></span>WifiConfiguration class</a> (representing a configured Wi-Fi network including security) and the <a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiManager.html"><span class="icon"></span>WifiManager class</a> functions: |
| 210 | </p> |
| 211 | <ul><li><a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiManager.html#setWifiEnabled(boolean)"><span class="icon"></span>setWifiEnabled()</a> - Enable or disable Wi-Fi |
| 212 | </li><li><a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiManager.html#getWifiState()"><span class="icon"></span>getWifiState()</a> - get wi-Fi enabled state |
| 213 | </li><li><a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiManager.html#isWifiEnabled()"><span class="icon"></span>isWifiEnabled()</a> - return whether Wi-Fi is enabled or disabled |
| 214 | </li><li><a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiManager.html#startScan()"><span class="icon"></span>startScan()</a> - request a scan for access points |
| 215 | </li><li><a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiManager.html#getScanResults()"><span class="icon"></span>getScanResults()</a> - returnteh results of the latest access point scan |
| 216 | </li></ul><h4 id="command-line">command-line</h4> |
| 217 | <p> |
| 218 | From a command-line perspective you can manually configure and launch <tt>wpa_supplicant</tt> if you wish: |
| 219 | </p> |
| 220 | <div class="code"><pre><span class="c"># restore default wpa_supplicant.conf and start wpa_supplicant service |
| 221 | </span>cp /system/etc/wifi/wpa_supplicant.conf /data/misc/wifi/wpa_supplicant |
| 222 | chmod 660 /data/misc/wifi/wpa_supplicant.conf |
| 223 | chwon system.wifi /data/misc/wifi/wpa_supplicant.conf |
| 224 | start wpa_supplicant |
| 225 | </pre></div><p> |
| 226 | <span class="wikianchor" id="ap"></span> |
| 227 | </p> |
| 228 | <h2 id="AccessPointMode">Access Point Mode</h2> |
| 229 | <p> |
| 230 | Android uses the <a class="ext-link" href="https://w1.fi/hostapd/"><span class="icon"></span>hostapd</a> users-space daemon for Access Point and authentication management on the AP side. For a DHCP server it uses the typical dnsmasq server. |
| 231 | </p> |
| 232 | <p> |
| 233 | The <tt>hostapd</tt> application provides the Access Point management and is managed by the <tt>netd</tt> SoftapController class which accepts the following commands: |
| 234 | </p> |
| 235 | <ul><li>startap - starts hostapd |
| 236 | </li><li>stopap - stops hostapd |
| 237 | </li><li>fwreload <STA|AP|P2P> - reload firmware for specified operating mode |
| 238 | </li><li>status - returns if AP is running or not |
| 239 | </li><li>set <wlan iface> <SSID <hidden|broadcast> <channel> <wpa2?-psk|open> <passphrase> - configure AP |
| 240 | </li></ul><p> |
| 241 | The <tt>dnsmasq</tt> application provides a DHCP server and is managed by the <tt>netd</tt> TetherController class which also manages <tt>iptables</tt>. |
| 242 | </p> |
| 243 | <p> |
| 244 | The <tt>netd</tt> TetherController class accepts the following commands: |
| 245 | </p> |
| 246 | <blockquote> |
| 247 | <p> |
| 248 | which accesps the following commands. |
| 249 | </p> |
| 250 | </blockquote> |
| 251 | <ul><li>tether stop - stop tethering |
| 252 | </li><li>tether start - start tethering |
| 253 | </li><li>tether status - report tether status |
| 254 | </li><li>tether interface add <iface> - add an interface to the tether |
| 255 | </li><li>tether interface remove <iface> - remove an interface from the tether |
| 256 | </li><li>tether interface list - list tethered interfaces |
| 257 | </li><li>tether dns set <dns1> <...> - add 1 or more dns forwarders |
| 258 | </li><li>tether dns list - list dns forwarders |
| 259 | </li></ul><p> |
| 260 | Network Address Translation (NAT) is provided by the <tt>netd</tt> NatController class which uses the <tt>iptables</tt> shell command and accepts the following commands: |
| 261 | </p> |
| 262 | <ul><li>nat enable <internal interface> <externalinterface> [<route-rules...>] - enable NAT |
| 263 | <ul><li>route-rules take the form of: <action> <addr> what will be used with the <tt>ip</tt> tool as: ip rule <action> from <addr> table |
| 264 | </li></ul></li><li>nat disable <internal interface> <externalinterface> - disable NAT |
| 265 | </li></ul><h3 id="Configuration1">Configuration</h3> |
| 266 | <p> |
| 267 | The <tt>hostapd.conf</tt> file is stored in /data/misc/wifi/hostapd.conf and used by the <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/system/netd/SoftapController.cpp"><span class="icon"></span>SoftapController class</a>. |
| 268 | </p> |
| 269 | <p> |
| 270 | The <tt>dnsmasq</tt> application is launched by <tt>netd</tt> with all configuration available on the cmdline. It will store lease information in /data/misc/dhcp/dnsmasq.leases |
| 271 | </p> |
| 272 | <p> |
| 273 | When configuration through the Android UI, the Settings application (Settings -> Wireless & Networks -> More... -> Tethering & portable hotspot -> Set up Wi-Fi hotspot) will store the SSID and Passkey settings in the /data/misc/wifi/softap.conf file which are used to dynamically create /data/misc/wifi/hostapd.conf. |
| 274 | </p> |
| 275 | <h3 id="Operation1">Operation</h3> |
| 276 | <p> |
| 277 | Unlike other system services that are started from Android's init process, <tt>hostapd</tt> is started on-demand by the Network Daemon <tt>netd</tt> via it's <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/system/netd/SoftapController.cpp"><span class="icon"></span>!SoftapController class</a> when it receives the <tt>softap startap</tt> command. |
| 278 | </p> |
| 279 | <p> |
| 280 | This command is sent to <tt>netd</tt> when the <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/services/java/com/android/server/NetworkManagementService.java"><span class="icon"></span>NetworkManagementService</a> <tt>startAccessPoint</tt> function is called. |
| 281 | </p> |
| 282 | <h4 id="AndroidUI1">Android UI</h4> |
| 283 | <p> |
| 284 | From an Android UI perspective, you can enable an Access Point (aka Hotspot) and NAT routing (aka Tethering) via the Settings Application: |
| 285 | </p> |
| 286 | <ol><li>Goto Settings -> Wireless & Networks -> More... -> Tethering & portable hotspot -> Set up Wi-Fi hotspot and specify your SSID and security settings |
| 287 | </li></ol><ol start="2"><li>Goto Settings -> Wireless & Networks -> More... -> Tethering & portable hotspot -> Portable Wi-Fi hotspot |
| 288 | </li></ol><p> |
| 289 | Note that enabling the Wi-Fi hotspot via the Settings GUI will not 'stick' and again be enabled on re-boot by design. |
| 290 | </p> |
| 291 | <h4 id="AndroidApplication1">Android Application</h4> |
| 292 | <p> |
| 293 | An application can use the <a class="ext-link" href="http://developer.android.com/reference/android/net/wifi/WifiManager.html"><span class="icon"></span>WifiManager class</a> to manage an Access Point: |
| 294 | </p> |
| 295 | <ul><li><a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/wifi/java/android/net/wifi/WifiManager.java#1102"><span class="icon"></span>setWifiApEnabled()</a> - start AP Mode |
| 296 | </li><li><a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/wifi/java/android/net/wifi/WifiManager.java#1120"><span class="icon"></span>getWifiApState()</a> - get Wi-Fi AP enabled state |
| 297 | </li><li><a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/wifi/java/android/net/wifi/WifiManager.java#1135"><span class="icon"></span>isWifiApEnabled()</a> - return whether Wi-Fi AP is enabled or disabled |
| 298 | </li><li><a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/wifi/java/android/net/wifi/WifiManager.java#1145"><span class="icon"></span>getWifiApConfiguration()</a> - get the Wi-Fi AP configuration |
| 299 | </li><li><a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/wifi/java/android/net/wifi/WifiManager.java#1159"><span class="icon"></span>setWifiApConfiguration()</a> - set the Wi-Fi AP configuration |
| 300 | </li></ul><p> |
| 301 | If your wireless device requires module or firmware loading, <tt>netd</tt> will do this as well by calling <tt>fwreload <STA|AP|P2P></tt> using the API defined in hardware/libhardware_legacy/include/wifi.h however note that the firmware load command and patches for each option are a build-time option using paths and arguments defined in BoardConfig.mk. By default these are all blank meaning no firmware or modules will be loaded. |
| 302 | </p> |
| 303 | <h4 id="command-line1">command-line</h4> |
| 304 | <p> |
| 305 | While you can manage <tt>hostapd</tt> and <tt>dnsmasq</tt> IP forwarding, and Network Address Translation manually it is likely much easier to use the API that the Network Daemon <tt>netd</tt> provides either through the Android java framework via the <a class="ext-link" href="http://androidxref.com/4.4.3_r1.1/xref/frameworks/base/services/java/com/android/server/NetworkManagementService.java"><span class="icon"></span>NetworkManagementService class</a> or via command-line with its command-line interface app <tt>netd</tt>. |
| 306 | </p> |
| 307 | <p> |
| 308 | For example, you can use <tt>netd</tt> to manage an Access Point with Linux NAT Routine (aka a 'Tethered Hotspot') using <tt>ncd</tt>: |
| 309 | </p> |
| 310 | <ol><li>configure Access Point: |
| 311 | <div class="code"><pre>ndc softap <span class="nb">set </span>wlan0 testssid broadcast 11 wpa-psk testpass <span class="c"># config hostapd |
| 312 | </span></pre></div><ul><li>the <tt>softap set</tt> command has the usage: <tt>sotfap set <iface> <SSID> <hidden|broadcast> <channel> <wpa-psk|wpa2-psk|open> <passphrase></tt> |
| 313 | <ul><li>/data/misc/wifi/hostapd.conf (which must be writable by netd) will be written to: |
| 314 | <pre class="wiki">interface=<iface> |
| 315 | driver=nl80211 |
| 316 | ctrl_interface=/data/misc/wifi/hostapd |
| 317 | ssid=testssid |
| 318 | channel=<channel> |
| 319 | ieee80211n=1 |
| 320 | hw_mode=g |
| 321 | </pre></li><li>for hidden an 'ignore_broadcast_ssid=1' will be added, for broadcast 'ignore_broadcast_ssid=0' |
| 322 | </li><li>for wpa-psk 'wpa=1, wpa_pairwise=TKIP CCMD, wpa_psk' entries will be added |
| 323 | </li><li>for wpa2-psk 'wpa=2, rsn_pairwise=CCMP, wpa_psk' entries will be added |
| 324 | </li></ul></li></ul></li></ol><ol start="2"><li>start the Access Point: |
| 325 | <div class="code"><pre>ndc softap startap <span class="c"># start hostapd |
| 326 | </span></pre></div><ul><li>Note that you can stop the Access Point at any time with <tt>ncd softap stopap</tt> |
| 327 | </li></ul></li></ol><ol start="3"><li>configure the wlan0 interface: |
| 328 | <div class="code"><pre>ndc interface setcfg wlan0 192.168.43.1 24 up |
| 329 | </pre></div></li></ol><ol start="4"><li>configure tethering |
| 330 | <div class="code"><pre>ndc tether interface add wlan0 <span class="c"># add wlan0 to tether |
| 331 | </span>ndc tether dns <span class="nb">set </span>8.8.4.4 8.8.8.8 <span class="c"># add DNS servers |
| 332 | </span>ndc ipfwd <span class="nb">enable</span> <span class="c"># enable IP forwarding |
| 333 | </span></pre></div></li></ol><ol start="5"><li>start tether of wlan0 with a specified DHCP pool (.10 to .99 in this case) (runs dnsmasq and configures NAT) |
| 334 | <div class="code"><pre>ndc tether start 192.168.43.10 192.168.43.99 |
| 335 | </pre></div></li></ol><ol start="6"><li>start Network Address Translation (NAT) |
| 336 | <div class="code"><pre>ndc nat <span class="nb">enable </span>wlan0 eth0 0 |
| 337 | </pre></div></li></ol><p> |
| 338 | Note that when using Access Point mode, you must not enable Wireless from the Settings Application as this puts the radio in Client mode. |
| 339 | </p> |
| 340 | }}} |