network.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. local fs = require "nixio.fs"
  5. m = Map("network", translate("Interfaces"))
  6. m.pageaction = false
  7. m:section(SimpleSection).template = "admin_network/iface_overview"
  8. -- Show ATM bridge section if we have the capabilities
  9. if fs.access("/usr/sbin/br2684ctl") then
  10. atm = m:section(TypedSection, "atm-bridge", translate("ATM Bridges"),
  11. translate("ATM bridges expose encapsulated ethernet in AAL5 " ..
  12. "connections as virtual Linux network interfaces which can " ..
  13. "be used in conjunction with DHCP or PPP to dial into the " ..
  14. "provider network."))
  15. atm.addremove = true
  16. atm.anonymous = true
  17. atm.create = function(self, section)
  18. local sid = TypedSection.create(self, section)
  19. local max_unit = -1
  20. m.uci:foreach("network", "atm-bridge",
  21. function(s)
  22. local u = tonumber(s.unit)
  23. if u ~= nil and u > max_unit then
  24. max_unit = u
  25. end
  26. end)
  27. m.uci:set("network", sid, "unit", max_unit + 1)
  28. m.uci:set("network", sid, "atmdev", 0)
  29. m.uci:set("network", sid, "encaps", "llc")
  30. m.uci:set("network", sid, "payload", "bridged")
  31. m.uci:set("network", sid, "vci", 35)
  32. m.uci:set("network", sid, "vpi", 8)
  33. return sid
  34. end
  35. atm:tab("general", translate("General Setup"))
  36. atm:tab("advanced", translate("Advanced Settings"))
  37. vci = atm:taboption("general", Value, "vci", translate("ATM Virtual Channel Identifier (VCI)"))
  38. vpi = atm:taboption("general", Value, "vpi", translate("ATM Virtual Path Identifier (VPI)"))
  39. encaps = atm:taboption("general", ListValue, "encaps", translate("Encapsulation mode"))
  40. encaps:value("llc", translate("LLC"))
  41. encaps:value("vc", translate("VC-Mux"))
  42. atmdev = atm:taboption("advanced", Value, "atmdev", translate("ATM device number"))
  43. unit = atm:taboption("advanced", Value, "unit", translate("Bridge unit number"))
  44. payload = atm:taboption("advanced", ListValue, "payload", translate("Forwarding mode"))
  45. payload:value("bridged", translate("bridged"))
  46. payload:value("routed", translate("routed"))
  47. m.pageaction = true
  48. end
  49. local network = require "luci.model.network"
  50. if network:has_ipv6() then
  51. local s = m:section(NamedSection, "globals", "globals", translate("Global network options"))
  52. local o = s:option(Value, "ula_prefix", translate("IPv6 ULA-Prefix"))
  53. o.datatype = "ip6addr"
  54. o.rmempty = true
  55. m.pageaction = true
  56. end
  57. return m