Skip to content

Commit

Permalink
feat(nl80211): add support passive scan
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <[email protected]>
  • Loading branch information
zhaojh329 committed Jul 17, 2024
1 parent 59d12e5 commit 9511dc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions examples/netlink/nl80211_scan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local nl = require 'eco.nl'

local ifname = 'wlan0'

-- If no ssids is passed, a passive scan is performed
local ok, err = nl80211.scan('trigger', { ifname = ifname, ssids = { '', 'test1', 'test2' }, freqs = { 2412, 2417 } })
if not ok then
print(err)
Expand Down
15 changes: 6 additions & 9 deletions nl80211.lua
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,13 @@ local function nl80211_scan(sock, msg, action, cmd, params)

if action == 'trigger' then
local ssids = params.ssids

if type(ssids) ~= 'table' or #ssids == 0 then
ssids = { '' }
end

msg:put_attr_nest_start(nl80211.ATTR_SCAN_SSIDS)
for i, ssid in ipairs(ssids) do
msg:put_attr_str(i, ssid)
if type(ssids) == 'table' and #ssids > 0 then
msg:put_attr_nest_start(nl80211.ATTR_SCAN_SSIDS)
for i, ssid in ipairs(ssids) do
msg:put_attr_str(i, ssid)
end
msg:put_attr_nest_end()
end
msg:put_attr_nest_end()

local freqs = params.freqs
if type(freqs) == 'table' and #freqs > 0 then
Expand Down

0 comments on commit 9511dc3

Please sign in to comment.