You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
891 B

  1. #!/usr/bin/lua
  2. local uci = require 'uci'.cursor()
  3. local ubus = require('ubus').connect()
  4. local neighbor_reports = {}
  5. local function hasKey(tab, key)
  6. for k, _ in pairs(tab) do
  7. if k == key then return true end
  8. end
  9. return false
  10. end
  11. uci:foreach('static-neighbor-report', 'neighbor', function (config)
  12. if hasKey(config, "disabled") and config.disabled ~= '0' then
  13. return
  14. end
  15. local bssid = ''
  16. local ssid = ''
  17. local neighbor_report = config['neighbor_report']
  18. if hasKey(config, 'bssid') then bssid = config.bssid end
  19. if hasKey(config, 'ssid') then ssid = config.ssid end
  20. for iface in config.iface:gmatch("%S+") do
  21. if not hasKey(neighbor_reports, iface) then
  22. neighbor_reports[iface] = {}
  23. end
  24. table.insert(neighbor_reports[iface], {bssid, ssid, neighbor_report})
  25. end
  26. end)
  27. for k, v in pairs(neighbor_reports) do
  28. ubus:call('hostapd.' .. k, 'rrm_nr_set', {list=v})
  29. end