summaryrefslogtreecommitdiffstats
path: root/interfaces-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-12-06 00:53:52 +0000
committerTed Trask <ttrask01@yahoo.com>2012-12-06 00:53:52 +0000
commit50f946418c3fbd5fd32f5218b177920a065a53ac (patch)
treebb7f51df2dccf9b2842c7975c39e5a0e483851d3 /interfaces-model.lua
parentbf240e45183c7a1aff68a39b59b09638cae7e7e3 (diff)
downloadacf-alpine-baselayout-50f946418c3fbd5fd32f5218b177920a065a53ac.tar.bz2
acf-alpine-baselayout-50f946418c3fbd5fd32f5218b177920a065a53ac.tar.xz
Interfaces: Move iface structure to a separate file and use it in view to determine which options to display
The previous method meant that each option was defined in both the model and in the view. Now, everything is defined in the model, and the view just hides / shows as desired.
Diffstat (limited to 'interfaces-model.lua')
-rw-r--r--interfaces-model.lua71
1 files changed, 7 insertions, 64 deletions
diff --git a/interfaces-model.lua b/interfaces-model.lua
index 59e16ba..1e86b8c 100644
--- a/interfaces-model.lua
+++ b/interfaces-model.lua
@@ -14,67 +14,7 @@ local array
-- iface is a local table with cfes for the various parts of interface definitions
-- Depending on the address family and corresponding method, different options are valid
-local iface = {
- required = {
- comment = {type="longtext", label="Comments", seq=2},
- auto = {type="boolean", value=false, label="Auto bring-up", seq=3},
- name = {label="Interface Name", seq=1},
- family = {type="select", label="Address Family", option={"inet", "ipx", "inet6"}, seq=4},
- method = {type="select", label="Method", option={"loopback", "static", "manual", "dhcp", "bootp", "ppp", "wvdial", "dynamic", "v4tunnel"}, seq=5},
- ['pre-up'] = {type="longtext", label="'pre-up' actions", seq=100},
- up = {type="longtext", label="'up' actions", seq=101},
- down = {type="longtext", label="'down' actions", seq=102},
- ['post-down'] = {type="longtext", label="'post-down' actions", seq=103},
- },
- family_methods = {
- inet = {"loopback", "static", "manual", "dhcp", "bootp", "ppp", "wvdial"},
- ipx = {"static", "dynamic"},
- inet6 = {"loopback", "static", "manual", "v4tunnel"},
- },
- method_options = {
- inet = {
- static = {"address", "netmask", "broadcast", "network", "metric", "gateway", "pointopoint", "media", "hwaddress", "mtu"},
- dhcp = {"hostname", "leasehours", "leasetime", "vendor", "client", "hwaddress"},
- bootp = {"bootfile", "server", "hwaddr"},
- ppp = {"provider"},
- wvdial = {"provider"},
- },
- ipx = {
- static = {"frame", "netnum"},
- dynamic = {"frame"},
- },
- inet6 ={
- static = {"address", "netmask", "gateway", "media", "hwaddress", "mtu"},
- v4tunnel = {"address", "netmask", "endpoint", "local", "gateway", "ttl"},
- },
- },
- optional = {
- address = {label="Address", seq=6},
- netmask = {label="Netmask", seq=7},
- endpoint = {label="Endpoint address", seq=8},
- ['local'] = {label="Local address", seq=9},
- broadcast = {label="Broadcast address", seq=10},
- network = {label="Network address", seq=11},
- metric = {label="Routing metric", seq=12},
- gateway = {label="Default gateway", seq=13},
- pointopoint = {label="Point-to-point address", seq=14},
- media = {label="Medium type", seq=15},
- hostname = {label="Hostname", seq=16},
- leasehours = {label="Preferred lease time (hours)", seq=17},
- leasetime = {label="Preferred lease time (seconds)", seq=18},
- vendor = {label="Vendor class identifier", seq=19},
- client = {label="Client identifier", seq=20},
- hwaddress = {label="Hardware address", seq=21},
- mtu = {label="MTU size", seq=22},
- bootfile = {label="Boot file", seq=23},
- server = {label="Server address", seq=24},
- hwaddr = {label="Hardware address", seq=25},
- provider = {label="Provider name", seq=26},
- frame = {label="Ethernet frame type", seq=27},
- netnum = {label="Network number", seq=28},
- ttl = {label="TTL setting", seq=29},
- },
-}
+local iface = require("alpine-baselayout/interfaces-definitions")
-- Create an interface structure with all options
local get_blank_iface = function ()
@@ -297,15 +237,18 @@ end
get_iface_by_name = function(self, clientdata)
-- if the name is blank, then return a blank iface with error
+ local ret
unpack_interfaces()
local rc, idx = arrayindex(clientdata.name or "")
if rc == false then
- local ret = get_blank_iface()
+ ret = get_blank_iface()
ret.value.name.value = name
ret.value.name.errtxt = "Interface does not exist"
- return ret
+ else
+ ret = array[idx]
end
- return array[idx]
+ ret.value.name.readonly = true
+ return ret
end
get_iface = function(self, clientdata)