2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
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
11 http://www.apache.org/licenses/LICENSE-2.0
15 m0 = Map("network", translate("network"))
17 local netstat = luci.sys.net.deviceinfo()
19 m0.parse = function() end
21 s = m0:section(TypedSection, "interface", translate("status"))
22 s.template = "cbi/tblsection"
25 function s.filter(self, section)
26 return section ~= "loopback" and section
29 hwaddr = s:option(DummyValue, "_hwaddr")
30 function hwaddr.cfgvalue(self, section)
31 local ix = self.map:get(section, "ifname") or ""
32 return luci.fs.readfile("/sys/class/net/" .. ix .. "/address") or "n/a"
36 s:option(DummyValue, "ipaddr", translate("ipaddress"))
38 s:option(DummyValue, "netmask", translate("netmask"))
41 txrx = s:option(DummyValue, "_txrx")
43 function txrx.cfgvalue(self, section)
44 local ix = self.map:get(section, "ifname")
46 local rx = netstat and netstat[ix] and netstat[ix][1]
47 rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-"
49 local tx = netstat and netstat[ix] and netstat[ix][9]
50 tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-"
52 return string.format("%s / %s", tx, rx)
55 errors = s:option(DummyValue, "_err")
57 function errors.cfgvalue(self, section)
58 local ix = self.map:get(section, "ifname")
60 local rx = netstat and netstat[ix] and netstat[ix][3]
61 local tx = netstat and netstat[ix] and netstat[ix][11]
63 rx = rx and tostring(rx) or "-"
64 tx = tx and tostring(tx) or "-"
66 return string.format("%s / %s", tx, rx)
72 m = Map("network", "")
74 s = m:section(NamedSection, "lan", "interface", translate("m_n_local"))
75 s:option(Value, "ipaddr", translate("ipaddress"))
77 nm = s:option(Value, "netmask", translate("netmask"))
78 nm:value("255.255.255.0")
79 nm:value("255.255.0.0")
82 gw = s:option(Value, "gateway", translate("gateway") .. translate("cbi_optional"))
84 dns = s:option(Value, "dns", translate("dnsserver") .. translate("cbi_optional"))
88 s = m:section(NamedSection, "wan", "interface", translate("m_n_inet"))
89 p = s:option(ListValue, "proto", translate("protocol"))
90 p:value("none", "disabled")
91 p:value("static", translate("manual", "manual"))
92 p:value("dhcp", translate("automatic", "automatic"))
93 p:value("pppoe", "PPPoE")
94 p:value("pptp", "PPTP")
96 ip = s:option(Value, "ipaddr", translate("ipaddress"))
97 ip:depends("proto", "static")
99 nm = s:option(Value, "netmask", translate("netmask"))
100 nm:depends("proto", "static")
102 gw = s:option(Value, "gateway", translate("gateway"))
103 gw:depends("proto", "static")
106 dns = s:option(Value, "dns", translate("dnsserver"))
107 dns:depends("proto", "static")
110 usr = s:option(Value, "username", translate("username"))
111 usr:depends("proto", "pppoe")
112 usr:depends("proto", "pptp")
114 pwd = s:option(Value, "password", translate("password"))
115 pwd:depends("proto", "pppoe")
116 pwd:depends("proto", "pptp")
118 kea = s:option(Flag, "keepalive", translate("m_n_keepalive"))
119 kea:depends("proto", "pppoe")
120 kea:depends("proto", "pptp")
125 cod = s:option(Value, "demand", translate("m_n_dialondemand"), "s")
126 cod:depends("proto", "pppoe")
127 cod:depends("proto", "pptp")
130 srv = s:option(Value, "server", translate("m_n_pptp_server"))
131 srv:depends("proto", "pptp")