<%# LuCI - Lua Configuration Interface Copyright 2010 Kentarou Mastuyama -%> <%- local uci = require "luci.model.uci".cursor() local web = require "luci.tools.webadmin" function get_wifi_iface(option, val) local info = {} uci:foreach("wireless", "wifi-iface", function(s) if s[option] == val then info = s end end) return info end function get_network_tbl(val1, val2, gw) local tbl = {} local lan = {} local radio = {} local adhoc = {} local ap = {} local meshcruzer = {} local system = {} local mask = "255.255.255.0" local hostname = "RMR-"..val1 local lanip = "192.168."..val1..".1" local wlanip = "10.0.1."..val1 local apip = "192.168."..val2..".1" radio.radio0_mode = translate("a_w_adhoc") radio.radio1_mode = translate("a_w_adhoc") radio.radio2_mode = translate("a_w_ap") radio.radio2_essid = "RMR"..val2.."-AP" local ra ra = get_wifi_iface("device", "RADIO_0") if ra.encryption ~= "none" and ra.encryption ~= "wep" then radio.radio0_enc = "none" else radio.radio0_enc = ra.encryption end ra = get_wifi_iface("device", "RADIO_1") if ra.encryption ~= "none" and ra.encryption ~= "wep" then radio.radio1_enc = "none" else radio.radio1_enc = ra.encryption end ra = get_wifi_iface("device", "RADIO_2") radio.radio2_enc = ra.encryption or "none" -- eth1 lan.ipaddr = lanip lan.netmask = mask -- wlan0, wlan1 adhoc.ipaddr = wlanip adhoc.netmask = mask -- wlan2 ap.ipaddr = apip ap.netmask = mask -- meshcruzer meshcruzer.node_name = hostname meshcruzer.ipaddr = wlanip meshcruzer.subnet = "10.0.1.0/24" if gw == "on" then meshcruzer.gateway = translate("enable") else meshcruzer.gateway = translate("disable") end meshcruzer.interface = "wlan0 wlan1" -- system system.hostname = hostname tbl.lan = lan tbl.radio = radio tbl.adhoc = adhoc tbl.ap = ap tbl.meshcruzer = meshcruzer tbl.system = system return tbl end -%> <%+header%>

<%:nwasst_title Network Settings Assistance%>

<%:nwasst_desc This page helps you to setup bridge interface on this router.%>
<% if state == "save" then %>

<%:easy_setup_success Success to setup the network interfaces. This changes will apply after reboot.%>
<%:jump2reboot Jump to Reboot page%>

<% elseif state == "start" then %> <% local tbl = get_network_tbl(val1, val2, gateway) %>

<%:easy_setup_confirm Following settings will apply to your router. Press Apply button if you ok. %>

<%:wifi%>

RADIO_0

<%=tbl.radio.radio0_mode%>
<%=tbl.radio.radio0_enc%>

RADIO_1

<%=tbl.radio.radio1_mode%>
<%=tbl.radio.radio1_enc%>

RADIO_2

<%=tbl.radio.radio2_mode%>
<%=tbl.radio.radio2_enc%>
<%=tbl.radio.radio2_essid%>
<%:interface%>

<%=web.iface_get_network("eth1")%>

<%=tbl.lan.ipaddr%>
<%=tbl.lan.netmask%>

<% local iw = get_wifi_iface("ifname", "wlan0") %>

<%=iw.network%>

<%=tbl.adhoc.ipaddr%>
<%=tbl.adhoc.netmask%>

<% iw = get_wifi_iface("ifname", "wlan1") %>

<%=iw.network%>

<%=tbl.adhoc.ipaddr%>
<%=tbl.adhoc.netmask%>

<% iw = get_wifi_iface("ifname", "wlan2") %>

<%=iw.network%>

<%=tbl.ap.ipaddr%>
<%=tbl.ap.netmask%>
MeshCruzer
<%=tbl.meshcruzer.node_name%>
<%=tbl.meshcruzer.ipaddr%>
<%=tbl.meshcruzer.subnet%>
<%=tbl.meshcruzer.gateway%>
<%=tbl.meshcruzer.interface%>
<%:system%>
<%=tbl.system.hostname%>
" />
<% else %> <% if errmes and #errmes > 0 then %>
<%:easy_setup_error ERROR%> : <%=errmes%>

<% end %>
<% end %>
<%+footer%>