* luci/app/coovachilli: replace all chillispot names with coovachilli
[project/luci.git] / applications / luci-coovachilli / luasrc / model / cbi / coovachilli_network.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15
16 require("luci.sys")
17 require("luci.ip")
18
19 m = Map("coovachilli")
20
21 -- tun
22 s1 = m:section(TypedSection, "tun")
23 s1.anonymous = true
24
25 s1:option( Flag, "usetap" )
26 s1:option( Value, "tundev" ).optional = true
27 s1:option( Value, "txqlen" ).optional = true
28
29 net = s1:option( Value, "net" )
30 for _, route in ipairs(luci.sys.net.routes()) do
31         if route.Iface ~= "lo" and route.Mask ~= "FFFFFFFF" then
32                 local netmask = luci.ip.IPv4(route.Mask)
33                 if netmask then
34                         local netaddr = luci.ip.IPv4(route.Destination, netmask)
35                         if netaddr then
36                                 net:value( netaddr:string() )
37                         end
38                 end
39         end
40 end
41
42 s1:option( Value, "dynip" ).optional = true
43 s1:option( Value, "statip" ).optional = true
44
45 s1:option( Value, "dns1" ).optional = true
46 s1:option( Value, "dns2" ).optional = true
47 s1:option( Value, "domain" ).optional = true
48
49 s1:option( Value, "ipup" ).optional = true
50 s1:option( Value, "ipdown" ).optional = true
51
52 s1:option( Value, "conup" ).optional = true
53 s1:option( Value, "condown" ).optional = true
54
55
56 -- dhcp config
57 s2 = m:section(TypedSection, "dhcp")
58 s2.anonymous = true
59
60 dif = s2:option( Value, "dhcpif" )
61 for _, nif in ipairs(luci.sys.net.devices()) do
62         if nif ~= "lo" then dif:value(nif) end
63 end
64
65 s2:option( Value, "dhcpmac" ).optional = true
66 s2:option( Value, "lease" ).optional = true
67 s2:option( Value, "dhcpstart" ).optional = true
68 s2:option( Value, "dhcpend" ).optional = true
69
70
71 return m