proto_pppoe.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 username, password, ac, service
  5. local ipv6, defaultroute, metric, peerdns, dns,
  6. keepalive_failure, keepalive_interval, demand, mtu
  7. username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
  8. password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
  9. password.password = true
  10. ac = section:taboption("general", Value, "ac",
  11. translate("Access Concentrator"),
  12. translate("Leave empty to autodetect"))
  13. ac.placeholder = translate("auto")
  14. service = section:taboption("general", Value, "service",
  15. translate("Service Name"),
  16. translate("Leave empty to autodetect"))
  17. service.placeholder = translate("auto")
  18. if luci.model.network:has_ipv6() then
  19. ipv6 = section:taboption("advanced", Flag, "ipv6",
  20. translate("Enable IPv6 negotiation on the PPP link"))
  21. ipv6.default = ipv6.disabled
  22. end
  23. defaultroute = section:taboption("advanced", Flag, "defaultroute",
  24. translate("Use default gateway"),
  25. translate("If unchecked, no default route is configured"))
  26. defaultroute.default = defaultroute.enabled
  27. metric = section:taboption("advanced", Value, "metric",
  28. translate("Use gateway metric"))
  29. metric.placeholder = "0"
  30. metric.datatype = "uinteger"
  31. metric:depends("defaultroute", defaultroute.enabled)
  32. peerdns = section:taboption("advanced", Flag, "peerdns",
  33. translate("Use DNS servers advertised by peer"),
  34. translate("If unchecked, the advertised DNS server addresses are ignored"))
  35. peerdns.default = peerdns.enabled
  36. dns = section:taboption("advanced", DynamicList, "dns",
  37. translate("Use custom DNS servers"))
  38. dns:depends("peerdns", "")
  39. dns.datatype = "ipaddr"
  40. dns.cast = "string"
  41. keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
  42. translate("LCP echo failure threshold"),
  43. translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
  44. function keepalive_failure.cfgvalue(self, section)
  45. local v = m:get(section, "keepalive")
  46. if v and #v > 0 then
  47. return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
  48. end
  49. end
  50. keepalive_failure.placeholder = "0"
  51. keepalive_failure.datatype = "uinteger"
  52. keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
  53. translate("LCP echo interval"),
  54. translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
  55. function keepalive_interval.cfgvalue(self, section)
  56. local v = m:get(section, "keepalive")
  57. if v and #v > 0 then
  58. return tonumber(v:match("^%d+[ ,]+(%d+)"))
  59. end
  60. end
  61. function keepalive_interval.write(self, section, value)
  62. local f = tonumber(keepalive_failure:formvalue(section)) or 0
  63. local i = tonumber(value) or 5
  64. if i < 1 then i = 1 end
  65. if f > 0 then
  66. m:set(section, "keepalive", "%d %d" %{ f, i })
  67. else
  68. m:del(section, "keepalive")
  69. end
  70. end
  71. keepalive_interval.remove = keepalive_interval.write
  72. keepalive_failure.write = keepalive_interval.write
  73. keepalive_failure.remove = keepalive_interval.write
  74. keepalive_interval.placeholder = "5"
  75. keepalive_interval.datatype = "min(1)"
  76. demand = section:taboption("advanced", Value, "demand",
  77. translate("Inactivity timeout"),
  78. translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
  79. demand.placeholder = "0"
  80. demand.datatype = "uinteger"
  81. mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
  82. mtu.placeholder = "1500"
  83. mtu.datatype = "max(9200)"