- Add support for hostap driver

- Retrieve channels from all available wireless interfaces
 - Add channel "auto" to channel list

Thanks Vasilis Tsiligiannis
This commit is contained in:
Jo-Philipp Wich 2009-05-21 21:33:24 +00:00
parent b2994995af
commit 7590cd25f4
3 changed files with 58 additions and 13 deletions

View file

@ -691,13 +691,14 @@ function wifi.channels(iface)
local fd = io.popen(cmd) local fd = io.popen(cmd)
if fd then if fd then
local ln, c, f local ln, c, f
repeat while true do
ln = fd:read("*l") or "" ln = fd:read("*l")
if not ln then break end
c, f = ln:match("Channel (%d+) : (%d+%.%d+) GHz") c, f = ln:match("Channel (%d+) : (%d+%.%d+) GHz")
if c and f then if c and f then
cns[tonumber(c)] = tonumber(f) cns[tonumber(c)] = tonumber(f)
end end
until not ( #ln > 0 ) end
fd:close() fd:close()
end end

View file

@ -94,6 +94,7 @@ config variable
option datatype uint option datatype uint
list depends type=atheros list depends type=atheros
list depends type=broadcom list depends type=broadcom
list depends type=prism2
config variable config variable
option name 'rxantenna' option name 'rxantenna'
@ -102,6 +103,7 @@ config variable
option datatype uint option datatype uint
list depends type=atheros list depends type=atheros
list depends type=broadcom list depends type=broadcom
list depends type=prism2
config variable config variable
option name 'distance' option name 'distance'
@ -254,13 +256,13 @@ config variable
config variable config variable
option name 'frag' option name 'frag'
option section 'wireless.wifi-iface' option section 'wireless.wifi-iface'
option title 'Fragmentation Threshold (mac80211, atheros)' option title 'Fragmentation Threshold (mac80211, atheros, prism2)'
option datatype uint option datatype uint
config variable config variable
option name 'rts' option name 'rts'
option section 'wireless.wifi-iface' option section 'wireless.wifi-iface'
option title 'RTS/CTS Threshold (mac80211, atheros)' option title 'RTS/CTS Threshold (mac80211, atheros, prism2)'
option datatype uint option datatype uint
config variable config variable
@ -287,7 +289,7 @@ config variable
config variable config variable
option name 'hidden' option name 'hidden'
option section 'wireless.wifi-iface' option section 'wireless.wifi-iface'
option title 'Hide ESSID (atheros, broadcom)' option title 'Hide ESSID (atheros, broadcom, prism2)'
option datatype boolean option datatype boolean
list depends 'mode=ap' list depends 'mode=ap'
list depends 'mode=adhoc' list depends 'mode=adhoc'
@ -327,7 +329,7 @@ config variable
config variable config variable
option name 'macpolicy' option name 'macpolicy'
option section 'wireless.wifi-iface' option section 'wireless.wifi-iface'
option title 'MAC-Address Filter (atheros)' option title 'MAC-Address Filter (atheros, prism2)'
option type enum option type enum
config enum config enum
@ -343,7 +345,7 @@ config enum
config variable config variable
option name 'maclist' option name 'maclist'
option section 'wireless.wifi-iface' option section 'wireless.wifi-iface'
option title 'MAC-List (atheros)' option title 'MAC-List (atheros, prism2)'
list depends 'macpolicy=allow' list depends 'macpolicy=allow'
list depends 'macpolicy=deny' list depends 'macpolicy=deny'
option type lazylist option type lazylist
@ -352,7 +354,7 @@ config variable
config variable config variable
option name 'rate' option name 'rate'
option section 'wireless.wifi-iface' option section 'wireless.wifi-iface'
option title 'Transmission Rate (atheros)' option title 'Transmission Rate (atheros, prism2)'
config variable config variable
option name 'mcast_rate' option name 'mcast_rate'

View file

@ -39,22 +39,24 @@ local hwtype = m:get(arg[1], "type")
local nsantenna = m:get(arg[1], "antenna") local nsantenna = m:get(arg[1], "antenna")
ch = s:option(Value, "channel", translate("a_w_channel")) ch = s:option(Value, "channel", translate("a_w_channel"))
ch:value("auto", translate("wifi_auto"))
for c, f in luci.util.kspairs(luci.sys.wifi.channels()) do for c, f in luci.util.kspairs(luci.sys.wifi.channels()) do
ch:value(c, "%i (%.3f GHz)" %{ c, f }) ch:value(c, "%i (%.3f GHz)" %{ c, f })
end end
s:option(Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
------------------- MAC80211 Device ------------------ ------------------- MAC80211 Device ------------------
if hwtype == "mac80211" then if hwtype == "mac80211" then
s:option(Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
end end
------------------- Madwifi Device ------------------ ------------------- Madwifi Device ------------------
if hwtype == "atheros" then if hwtype == "atheros" then
s:option(Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
mode = s:option(ListValue, "mode", translate("mode")) mode = s:option(ListValue, "mode", translate("mode"))
mode:value("", translate("wifi_auto")) mode:value("", translate("wifi_auto"))
mode:value("11b", "802.11b") mode:value("11b", "802.11b")
@ -91,6 +93,8 @@ end
------------------- Broadcom Device ------------------ ------------------- Broadcom Device ------------------
if hwtype == "broadcom" then if hwtype == "broadcom" then
s:option(Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
mp = s:option(ListValue, "macfilter", translate("wifi_macpolicy")) mp = s:option(ListValue, "macfilter", translate("wifi_macpolicy"))
mp.optional = true mp.optional = true
mp:value("") mp:value("")
@ -113,6 +117,16 @@ if hwtype == "broadcom" then
end end
--------------------- HostAP Device ---------------------
if hwtype == "prism2" then
s:option(Value, "txpower", translate("a_w_txpwr"), "att units").rmempty = true
s:option(Value, "txantenna", translate("wifi_txantenna")).optional = true
s:option(Value, "rxantenna", translate("wifi_rxantenna")).optional = true
end
----------------------- Interface ----------------------- ----------------------- Interface -----------------------
s = m:section(TypedSection, "wifi-iface", translate("interfaces")) s = m:section(TypedSection, "wifi-iface", translate("interfaces"))
@ -262,6 +276,34 @@ if hwtype == "broadcom" then
end end
----------------------- HostAP Interface ---------------------
if hwtype == "prism2" then
mode:value("wds", translate("a_w_wds"))
mode:value("monitor", translate("a_w_monitor"))
hidden = s:option(Flag, "hidden", translate("wifi_hidden"))
hidden:depends({mode="ap"})
hidden:depends({mode="adhoc"})
hidden:depends({mode="wds"})
hidden.optional = true
bssid:depends({mode="sta"})
mp = s:option(ListValue, "macpolicy", translate("wifi_macpolicy"))
mp.optional = true
mp:value("")
mp:value("deny", translate("wifi_whitelist"))
mp:value("allow", translate("wifi_blacklist"))
ml = s:option(DynamicList, "maclist", translate("wifi_maclist"))
ml:depends({macpolicy="allow"})
ml:depends({macpolicy="deny"})
s:option(Value, "rate", translate("wifi_rate")).optional = true
s:option(Value, "frag", translate("wifi_frag")).optional = true
s:option(Value, "rts", translate("wifi_rts")).optional = true
end
------------------- WiFI-Encryption ------------------- ------------------- WiFI-Encryption -------------------
@ -277,7 +319,7 @@ encr:depends({mode="mesh"})
encr:value("none", "No Encryption") encr:value("none", "No Encryption")
encr:value("wep", "WEP") encr:value("wep", "WEP")
if hwtype == "atheros" or hwtype == "mac80211" then if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
local supplicant = luci.fs.mtime("/usr/sbin/wpa_supplicant") local supplicant = luci.fs.mtime("/usr/sbin/wpa_supplicant")
local hostapd = luci.fs.mtime("/usr/sbin/hostapd") local hostapd = luci.fs.mtime("/usr/sbin/hostapd")
@ -332,7 +374,7 @@ key:depends("encryption", "psk2")
key:depends({mode="ap", encryption="wpa2"}) key:depends({mode="ap", encryption="wpa2"})
key.rmempty = true key.rmempty = true
if hwtype == "atheros" or hwtype == "mac80211" then if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
nasid = s:option(Value, "nasid", translate("a_w_nasid")) nasid = s:option(Value, "nasid", translate("a_w_nasid"))
nasid:depends({mode="ap", encryption="wpa"}) nasid:depends({mode="ap", encryption="wpa"})
nasid:depends({mode="ap", encryption="wpa2"}) nasid:depends({mode="ap", encryption="wpa2"})