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", "dhcpleases")
61 page.target = cbi("admin_network/dhcpleases")
62 page.title = i18n("DHCP Leases")
65 local page = node("admin", "network", "hosts")
66 page.target = cbi("admin_network/hosts")
67 page.title = i18n("Hostnames")
70 local page = node("admin", "network", "routes")
71 page.target = cbi("admin_network/routes")
72 page.title = i18n("Static Routes")
78 local function param(x)
79 return luci.http.formvalue(x)
82 local function ptable(x)
84 return x and (type(x) ~= "table" and { x } or x) or {}
87 local dev = param("device")
88 local ssid = param("join")
91 local cancel = (param("cancel") or param("cbi.cancel")) and true or false
94 luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless_join?device=" .. dev))
96 local cbi = require "luci.cbi"
97 local tpl = require "luci.template"
98 local map = luci.cbi.load("admin_network/wifi_add")[1]
100 if map:parse() ~= cbi.FORM_DONE then
107 luci.template.render("admin_network/wifi_join")
111 function wifi_delete(network)
112 local uci = require "luci.model.uci".cursor()
113 local wlm = require "luci.model.wireless"
116 wlm:del_network(network)
119 luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))