proto_ahcp.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local map, section, net = ...
  4. local device, apn, service, pincode, username, password
  5. local ipv6, maxwait, defaultroute, metric, peerdns, dns,
  6. keepalive_failure, keepalive_interval, demand
  7. mca = s:taboption("ahcp", Value, "multicast_address", translate("Multicast address"))
  8. mca.optional = true
  9. mca.placeholder = "ff02::cca6:c0f9:e182:5359"
  10. mca.datatype = "ip6addr"
  11. mca:depends("proto", "ahcp")
  12. port = s:taboption("ahcp", Value, "port", translate("Port"))
  13. port.optional = true
  14. port.placeholder = 5359
  15. port.datatype = "port"
  16. port:depends("proto", "ahcp")
  17. fam = s:taboption("ahcp", ListValue, "_family", translate("Protocol family"))
  18. fam:value("", translate("IPv4 and IPv6"))
  19. fam:value("ipv4", translate("IPv4 only"))
  20. fam:value("ipv6", translate("IPv6 only"))
  21. fam:depends("proto", "ahcp")
  22. function fam.cfgvalue(self, section)
  23. local v4 = m.uci:get_bool("network", section, "ipv4_only")
  24. local v6 = m.uci:get_bool("network", section, "ipv6_only")
  25. if v4 then
  26. return "ipv4"
  27. elseif v6 then
  28. return "ipv6"
  29. end
  30. return ""
  31. end
  32. function fam.write(self, section, value)
  33. if value == "ipv4" then
  34. m.uci:set("network", section, "ipv4_only", "true")
  35. m.uci:delete("network", section, "ipv6_only")
  36. elseif value == "ipv6" then
  37. m.uci:set("network", section, "ipv6_only", "true")
  38. m.uci:delete("network", section, "ipv4_only")
  39. end
  40. end
  41. function fam.remove(self, section)
  42. m.uci:delete("network", section, "ipv4_only")
  43. m.uci:delete("network", section, "ipv6_only")
  44. end
  45. nodns = s:taboption("ahcp", Flag, "no_dns", translate("Disable DNS setup"))
  46. nodns.optional = true
  47. nodns.enabled = "true"
  48. nodns.disabled = "false"
  49. nodns.default = nodns.disabled
  50. nodns:depends("proto", "ahcp")
  51. ltime = s:taboption("ahcp", Value, "lease_time", translate("Lease validity time"))
  52. ltime.optional = true
  53. ltime.placeholder = 3666
  54. ltime.datatype = "uinteger"
  55. ltime:depends("proto", "ahcp")