routes.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local wa = require "luci.tools.webadmin"
  4. local fs = require "nixio.fs"
  5. m = Map("network",
  6. translate("Routes"),
  7. translate("Routes specify over which interface and gateway a certain host or network " ..
  8. "can be reached."))
  9. s = m:section(TypedSection, "route", translate("Static IPv4 Routes"))
  10. s.addremove = true
  11. s.anonymous = true
  12. s.template = "cbi/tblsection"
  13. iface = s:option(ListValue, "interface", translate("Interface"))
  14. wa.cbi_add_networks(iface)
  15. t = s:option(Value, "target", translate("Target"), translate("Host-<abbr title=\"Internet Protocol Address\">IP</abbr> or Network"))
  16. t.datatype = "ip4addr"
  17. t.rmempty = false
  18. n = s:option(Value, "netmask", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Netmask"), translate("if target is a network"))
  19. n.placeholder = "255.255.255.255"
  20. n.datatype = "ip4addr"
  21. n.rmempty = true
  22. g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Gateway"))
  23. g.datatype = "ip4addr"
  24. g.rmempty = true
  25. metric = s:option(Value, "metric", translate("Metric"))
  26. metric.placeholder = 0
  27. metric.datatype = "range(0,255)"
  28. metric.rmempty = true
  29. mtu = s:option(Value, "mtu", translate("MTU"))
  30. mtu.placeholder = 1500
  31. mtu.datatype = "range(64,9000)"
  32. mtu.rmempty = true
  33. if fs.access("/proc/net/ipv6_route") then
  34. s = m:section(TypedSection, "route6", translate("Static IPv6 Routes"))
  35. s.addremove = true
  36. s.anonymous = true
  37. s.template = "cbi/tblsection"
  38. iface = s:option(ListValue, "interface", translate("Interface"))
  39. wa.cbi_add_networks(iface)
  40. t = s:option(Value, "target", translate("Target"), translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Address or Network (CIDR)"))
  41. t.datatype = "ip6addr"
  42. t.rmempty = false
  43. g = s:option(Value, "gateway", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Gateway"))
  44. g.datatype = "ip6addr"
  45. g.rmempty = true
  46. metric = s:option(Value, "metric", translate("Metric"))
  47. metric.placeholder = 0
  48. metric.datatype = "range(0,65535)" -- XXX: not sure
  49. metric.rmempty = true
  50. mtu = s:option(Value, "mtu", translate("MTU"))
  51. mtu.placeholder = 1500
  52. mtu.datatype = "range(64,9000)"
  53. mtu.rmempty = true
  54. end
  55. return m