luci-app-coovachilli: switch to luci.ip route functions
[project/luci.git] / applications / luci-app-coovachilli / luasrc / model / cbi / coovachilli_network.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 local sys = require"luci.sys"
6 local ip  = require "luci.ip"
7
8 m = Map("coovachilli")
9
10 -- tun
11 s1 = m:section(TypedSection, "tun")
12 s1.anonymous = true
13
14 s1:option( Flag, "usetap" )
15 s1:option( Value, "tundev" ).optional = true
16 s1:option( Value, "txqlen" ).optional = true
17
18 net = s1:option( Value, "net" )
19 for _, route in ipairs(ip.routes({ family = 4, type = 1 })) do
20         if route.dest:prefix() > 0 and route.dest:prefix() < 32 then
21                 net:value( route.dest:string() )
22         end
23 end
24
25 s1:option( Value, "dynip" ).optional = true
26 s1:option( Value, "statip" ).optional = true
27
28 s1:option( Value, "dns1" ).optional = true
29 s1:option( Value, "dns2" ).optional = true
30 s1:option( Value, "domain" ).optional = true
31
32 s1:option( Value, "ipup" ).optional = true
33 s1:option( Value, "ipdown" ).optional = true
34
35 s1:option( Value, "conup" ).optional = true
36 s1:option( Value, "condown" ).optional = true
37
38
39 -- dhcp config
40 s2 = m:section(TypedSection, "dhcp")
41 s2.anonymous = true
42
43 dif = s2:option( Value, "dhcpif" )
44 for _, nif in ipairs(sys.net.devices()) do
45         if nif ~= "lo" then dif:value(nif) end
46 end
47
48 s2:option( Value, "dhcpmac" ).optional = true
49 s2:option( Value, "lease" ).optional = true
50 s2:option( Value, "dhcpstart" ).optional = true
51 s2:option( Value, "dhcpend" ).optional = true
52
53 s2:option( Flag, "eapolenable" )
54
55
56 return m