2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
14 module("luci.controller.admin.network", package.seeall)
18 local uci = require("luci.model.uci").cursor()
19 local i18n = luci.i18n.translate
21 local page = node("admin", "network")
22 page.target = alias("admin", "network", "network")
23 page.title = i18n("Network")
27 local page = node("admin", "network", "vlan")
28 page.target = cbi("admin_network/vlan")
29 page.title = i18n("Switch")
32 local page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), i18n("Wifi"), 15)
36 local page = entry({"admin", "network", "wireless_join"}, call("wifi_join"), nil, 16)
39 local page = entry({"admin", "network", "wireless_delete"}, call("wifi_delete"), nil, 16)
42 local page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), i18n("Interfaces"), 10)
46 local page = entry({"admin", "network", "add"}, cbi("admin_network/iface_add"), nil)
49 uci:foreach("network", "interface",
51 local ifc = section[".name"]
52 if ifc ~= "loopback" then
53 entry({"admin", "network", "network", ifc},
60 local page = node("admin", "network", "dhcp")
61 page.target = cbi("admin_network/dhcp")
67 {"admin", "network", "dhcp", "leases"},
68 cbi("admin_network/dhcpleases"),
72 local page = node("admin", "network", "hosts")
73 page.target = cbi("admin_network/hosts")
74 page.title = i18n("Hostnames")
77 local page = node("admin", "network", "routes")
78 page.target = cbi("admin_network/routes")
79 page.title = i18n("Static Routes")
85 local function param(x)
86 return luci.http.formvalue(x)
89 local function ptable(x)
91 return x and (type(x) ~= "table" and { x } or x) or {}
94 local dev = param("device")
95 local ssid = param("join")
98 local cancel = (param("cancel") or param("cbi.cancel")) and true or false
101 luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless_join?device=" .. dev))
103 local cbi = require "luci.cbi"
104 local tpl = require "luci.template"
105 local map = luci.cbi.load("admin_network/wifi_add")[1]
107 if map:parse() ~= cbi.FORM_DONE then
114 luci.template.render("admin_network/wifi_join")
118 function wifi_delete(network)
119 local uci = require "luci.model.uci".cursor()
120 local wlm = require "luci.model.wireless"
123 wlm:del_network(network)
126 luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))