2
0

proto.lua 785 B

123456789101112131415161718192021222324252627282930313233343536
  1. -- Copyright 2012 Jo-Philipp Wich <jow@openwrt.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. module("luci.tools.proto", package.seeall)
  4. function opt_macaddr(s, ifc, ...)
  5. local v = luci.cbi.Value
  6. local o = s:taboption("advanced", v, "macaddr", ...)
  7. o.placeholder = ifc and ifc:mac()
  8. o.datatype = "macaddr"
  9. function o.cfgvalue(self, section)
  10. local w = ifc and ifc:get_wifinet()
  11. if w then
  12. return w:get("macaddr")
  13. else
  14. return v.cfgvalue(self, section)
  15. end
  16. end
  17. function o.write(self, section, value)
  18. local w = ifc and ifc:get_wifinet()
  19. if w then
  20. w:set("macaddr", value)
  21. elseif value then
  22. v.write(self, section, value)
  23. else
  24. v.remove(self, section)
  25. end
  26. end
  27. function o.remove(self, section)
  28. self:write(section, nil)
  29. end
  30. end