hosts.lua 738 B

12345678910111213141516171819202122232425262728
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Copyright 2010-2015 Jo-Philipp Wich <jow@openwrt.org>
  3. -- Licensed to the public under the Apache License 2.0.
  4. local ipc = require "luci.ip"
  5. m = Map("dhcp", translate("Hostnames"))
  6. s = m:section(TypedSection, "domain", translate("Host entries"))
  7. s.addremove = true
  8. s.anonymous = true
  9. s.template = "cbi/tblsection"
  10. hn = s:option(Value, "name", translate("Hostname"))
  11. hn.datatype = "hostname"
  12. hn.rmempty = true
  13. ip = s:option(Value, "ip", translate("IP address"))
  14. ip.datatype = "ipaddr"
  15. ip.rmempty = true
  16. ipc.neighbors({ }, function(n)
  17. if n.mac and n.dest and not n.dest:is6linklocal() then
  18. ip:value(n.dest:string(), "%s (%s)" %{ n.dest:string(), n.mac })
  19. end
  20. end)
  21. return m