proto_pppoa.lua 3.8 KB

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