wireless.tex 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. The WiFi settings are configured in the file \texttt{/etc/config/wireless}
  2. (currently supported on Broadcom, Atheros and mac80211). When booting the router for the first time
  3. it should detect your card and create a sample configuration file. By default '\texttt{option network lan}' is
  4. commented. This prevents unsecured sharing of the network over the wireless interface.
  5. Each wireless driver has its own configuration script in \texttt{/lib/wifi/driver\_name.sh} which handles
  6. driver specific options and configurations. This script is also calling driver specific binaries like wlc for
  7. Broadcom, or hostapd and wpa\_supplicant for atheros.
  8. The reason for using such architecture, is that it abstracts the driver configuration.
  9. \paragraph{Generic Broadcom wireless config:}
  10. \begin{Verbatim}
  11. config wifi-device "wl0"
  12. option type "broadcom"
  13. option channel "5"
  14. config wifi-iface
  15. option device "wl0"
  16. # option network lan
  17. option mode "ap"
  18. option ssid "OpenWrt"
  19. option hidden "0"
  20. option encryption "none"
  21. \end{Verbatim}
  22. \paragraph{Generic Atheros wireless config:}
  23. \begin{Verbatim}
  24. config wifi-device "wifi0"
  25. option type "atheros"
  26. option channel "5"
  27. option agmode "11g"
  28. config wifi-iface
  29. option device "wifi0"
  30. # option network lan
  31. option mode "ap"
  32. option ssid "OpenWrt"
  33. option hidden "0"
  34. option encryption "none"
  35. \end{Verbatim}
  36. \paragraph{Generic mac80211 wireless config:}
  37. \begin{Verbatim}
  38. config wifi-device "wifi0"
  39. option type "mac80211"
  40. option channel "5"
  41. config wifi-iface
  42. option device "wlan0"
  43. # option network lan
  44. option mode "ap"
  45. option ssid "OpenWrt"
  46. option hidden "0"
  47. option encryption "none"
  48. \end{Verbatim}
  49. \paragraph{Generic multi-radio Atheros wireless config:}
  50. \begin{Verbatim}
  51. config wifi-device wifi0
  52. option type atheros
  53. option channel 1
  54. config wifi-iface
  55. option device wifi0
  56. # option network lan
  57. option mode ap
  58. option ssid OpenWrt_private
  59. option hidden 0
  60. option encryption none
  61. config wifi-device wifi1
  62. option type atheros
  63. option channel 11
  64. config wifi-iface
  65. option device wifi1
  66. # option network lan
  67. option mode ap
  68. option ssid OpenWrt_public
  69. option hidden 1
  70. option encryption none
  71. \end{Verbatim}
  72. There are two types of config sections in this file. The '\texttt{wifi-device}' refers to
  73. the physical wifi interface and '\texttt{wifi-iface}' configures a virtual interface on top
  74. of that (if supported by the driver).
  75. A full outline of the wireless configuration file with description of each field:
  76. \begin{Verbatim}
  77. config wifi-device wifi device name
  78. option type broadcom, atheros, mac80211
  79. option country us, uk, fr, de, etc.
  80. option channel 1-14
  81. option maxassoc 1-128 (broadcom only)
  82. option distance 1-n
  83. option agmode 11b, 11g, 11a, 11bg (atheros only)
  84. config wifi-iface
  85. option network the interface you want wifi to bridge with
  86. option device wifi0, wifi1, wifi2, wifiN
  87. option mode ap, sta, adhoc, monitor, or wds
  88. option ssid ssid name
  89. option bssid bssid address
  90. option encryption none, wep, psk, psk2, wpa, wpa2
  91. option key encryption key
  92. option key1 key 1
  93. option key2 key 2
  94. option key3 key 3
  95. option key4 key 4
  96. option server ip address
  97. option port port
  98. option hidden 0,1
  99. option isolate 0,1
  100. \end{Verbatim}
  101. \paragraph{Options for the \texttt{wifi-device}:}
  102. \begin{itemize}
  103. \item \texttt{type} \\
  104. The driver to use for this interface.
  105. \item \texttt{country} \\
  106. The country code used to determine the regulatory settings.
  107. \item \texttt{channel} \\
  108. The wifi channel (e.g. 1-14, depending on your country setting).
  109. \item \texttt{maxassoc} \\
  110. Optional: Maximum number of associated clients. This feature is supported only on the broadcom chipset.
  111. \item \texttt{distance} \\
  112. Optional: Distance between the ap and the furthest client in meters. This feature is supported only on the atheros chipset.
  113. \item \texttt{mode} \\
  114. The frequency band (\texttt{b}, \texttt{g}, \texttt{bg}, \texttt{a}). This feature is only supported on the atheros chipset.
  115. \end{itemize}
  116. \paragraph{Options for the \texttt{wifi-iface}:}
  117. \begin{itemize}
  118. \item \texttt{network} \\
  119. Selects the interface section from \texttt{/etc/config/network} to be
  120. used with this interface
  121. \item \texttt{device} \\
  122. Set the wifi device name.
  123. \item \texttt{mode} \\
  124. Operating mode:
  125. \begin{itemize}
  126. \item \texttt{ap} \\
  127. Access point mode
  128. \item \texttt{sta} \\
  129. Client mode
  130. \item \texttt{adhoc} \\
  131. Ad-Hoc mode
  132. \item \texttt{monitor} \\
  133. Monitor mode
  134. \item \texttt{wds} \\
  135. WDS point-to-point link
  136. \end{itemize}
  137. \item \texttt{ssid}
  138. Set the SSID to be used on the wifi device.
  139. \item \texttt{bssid}
  140. Set the BSSID address to be used for wds to set the mac address of the other wds unit.
  141. \item \texttt{encryption} \\
  142. Encryption setting. Accepts the following values:
  143. \begin{itemize}
  144. \item \texttt{none}
  145. \item \texttt{wep}
  146. \item \texttt{psk}, \texttt{psk2} \\
  147. WPA(2) Pre-shared Key
  148. \item \texttt{wpa}, \texttt{wpa2} \\
  149. WPA(2) RADIUS
  150. \end{itemize}
  151. \item \texttt{key, key1, key2, key3, key4} (wep, wpa and psk) \\
  152. WEP key, WPA key (PSK mode) or the RADIUS shared secret (WPA RADIUS mode)
  153. \item \texttt{server} (wpa) \\
  154. The RADIUS server ip address
  155. \item \texttt{port} (wpa) \\
  156. The RADIUS server port (defaults to 1812)
  157. \item \texttt{hidden} \\
  158. 0 broadcasts the ssid; 1 disables broadcasting of the ssid
  159. \item \texttt{isolate} \\
  160. Optional: Isolation is a mode usually set on hotspots that limits the clients to communicate only with the AP and not with other wireless clients.
  161. 0 disables ap isolation (default); 1 enables ap isolation.
  162. \end{itemize}
  163. \paragraph{Limitations:}
  164. There are certain limitations when combining modes.
  165. Only the following mode combinations are supported:
  166. \begin{itemize}
  167. \item \textbf{Broadcom}: \\
  168. \begin{itemize}
  169. \item 1x \texttt{sta}, 0-3x \texttt{ap}
  170. \item 1-4x \texttt{ap}
  171. \item 1x \texttt{adhoc}
  172. \item 1x \texttt{monitor}
  173. \end{itemize}
  174. WDS links can only be used in pure AP mode and cannot use WEP (except when sharing the
  175. settings with the master interface, which is done automatically).
  176. \item \textbf{Atheros}: \\
  177. \begin{itemize}
  178. \item 1x \texttt{sta}, 0-Nx \texttt{ap}
  179. \item 1-Nx \texttt{ap}
  180. \item 1x \texttt{adhoc}
  181. \end{itemize}
  182. N is the maximum number of VAPs that the module allows, it defaults to 4, but can be
  183. changed by loading the module with the maxvaps=N parameter.
  184. \end{itemize}
  185. \paragraph{Adding a new driver configuration}
  186. Since we currently only support two different wireless drivers : Broadcom and Atheros,
  187. you might be interested in adding support for another driver like Ralink RT2x00,
  188. Texas Instruments ACX100/111.
  189. The driver specific script should be placed in \texttt{/lib/wifi/<driver>.sh} and has to
  190. include several functions providing :
  191. \begin{itemize}
  192. \item detection of the driver presence
  193. \item enabling/disabling the wifi interface(s)
  194. \item configuration reading and setting
  195. \item third-party programs calling (nas, supplicant)
  196. \end{itemize}
  197. Each driver script should append the driver to a global DRIVERS variable :
  198. \begin{Verbatim}
  199. append DRIVERS "driver name"
  200. \end{Verbatim}
  201. \subparagraph{\texttt{scan\_<driver>}}
  202. This function will parse the \texttt{/etc/config/wireless} and make sure there
  203. are no configuration incompatibilities, like enabling hidden SSIDS with ad-hoc mode
  204. for instance. This can be more complex if your driver supports a lof of configuration
  205. options. It does not change the state of the interface.
  206. Example:
  207. \begin{Verbatim}
  208. scan_dummy() {
  209. local device="$1"
  210. config_get vifs "$device" vifs
  211. for vif in $vifs; do
  212. # check config consistency for wifi-iface sections
  213. done
  214. # check mode combination
  215. }
  216. \end{Verbatim}
  217. \subparagraph{\texttt{enable\_<driver>}}
  218. This function will bring up the wifi device and optionally create application specific
  219. configuration files, e.g. for the WPA authenticator or supplicant.
  220. Example:
  221. \begin{Verbatim}
  222. enable_dummy() {
  223. local device="$1"
  224. config_get vifs "$device" vifs
  225. for vif in $vifs; do
  226. # bring up virtual interface belonging to
  227. # the wifi-device "$device"
  228. done
  229. }
  230. \end{Verbatim}
  231. \subparagraph{\texttt{disable\_<driver>}}
  232. This function will bring down the wifi device and all its virtual interfaces (if supported).
  233. Example:
  234. \begin{Verbatim}
  235. disable_dummy() {
  236. local device="$1"
  237. # bring down virtual interfaces belonging to
  238. # "$device" regardless of whether they are
  239. # configured or not. Don't rely on the vifs
  240. # variable at this point
  241. }
  242. \end{Verbatim}
  243. \subparagraph{\texttt{detect\_<driver>}}
  244. This function looks for interfaces that are usable with the driver. Template config sections
  245. for new devices should be written to stdout. Must check for already existing config sections
  246. belonging to the interfaces before creating new templates.
  247. Example:
  248. \begin{Verbatim}
  249. detect_dummy() {
  250. [ wifi-device = "$(config_get dummydev type)" ] && return 0
  251. cat <<EOF
  252. config wifi-device dummydev
  253. option type dummy
  254. # REMOVE THIS LINE TO ENABLE WIFI:
  255. option disabled 1
  256. config wifi-iface
  257. option device dummydev
  258. option mode ap
  259. option ssid OpenWrt
  260. EOF
  261. }
  262. \end{Verbatim}