diff mbox

[py80211,4/4] py80211: scan: add matchsets support for scheduled scans

Message ID 1434117644-3033-5-git-send-email-luca@coelho.fi (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show

Commit Message

Luca Coelho June 12, 2015, 2 p.m. UTC
From: Luciano Coelho <luciano.coelho@intel.com>

Modify the sched_scan_start class so that the caller can pass a list
of matches to be used in the scheduled scan request.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
 lib/scan.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Arend Van Spriel June 13, 2015, 6:45 p.m. UTC | #1
On 12-06-15 16:00, Luca Coelho wrote:
> From: Luciano Coelho <luciano.coelho@intel.com>
> 
> Modify the sched_scan_start class so that the caller can pass a list
> of matches to be used in the scheduled scan request.
> 
> Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>

Merged in master branch after indentation cleanup.

Regards,
Arend

> ---
>  lib/scan.py | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/lib/scan.py b/lib/scan.py
> index bfaf3d2..b55d148 100644
> --- a/lib/scan.py
> +++ b/lib/scan.py
> @@ -192,10 +192,34 @@ class sched_scan_start(scan_start_base):
>  	def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
>                  super(sched_scan_start, self).__init__(ifidx, level)
>                  self._nl_cmd = nl80211.CMD_START_SCHED_SCAN
> +                self._matches = None
>  
>  	def set_interval(self, interval):
>  		self._interval = interval
>  
> +        def add_matches(self, matches):
> +                self._matches = matches
> +
> +        def _add_matches_attrs(self):
> +		if self._matches:
> +			i = 0
> +
> +                        matchset = nl.nla_nest_start(self._nl_msg._msg, nl80211.ATTR_SCHED_SCAN_MATCH)
> +			for match in self._matches:
> +                                nest = nl.nla_nest_start(self._nl_msg._msg, i)
> +                                if 'ssid' in match:
> +                                        nl.nla_put(self._nl_msg._msg, nl80211.SCHED_SCAN_MATCH_ATTR_SSID, match['ssid'])
> +				i += 1
> +                                nl.nla_nest_end(self._nl_msg._msg, nest)
> +
> +                        nl.nla_nest_end(self._nl_msg._msg, matchset)
> +
> +        def send(self):
> +                self._prepare_cmd()
> +                self._add_scan_attrs()
> +                self._add_matches_attrs()
> +                self._send_and_wait()
> +
>          def handle(self, msg, arg):
>  		genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/scan.py b/lib/scan.py
index bfaf3d2..b55d148 100644
--- a/lib/scan.py
+++ b/lib/scan.py
@@ -192,10 +192,34 @@  class sched_scan_start(scan_start_base):
 	def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
                 super(sched_scan_start, self).__init__(ifidx, level)
                 self._nl_cmd = nl80211.CMD_START_SCHED_SCAN
+                self._matches = None
 
 	def set_interval(self, interval):
 		self._interval = interval
 
+        def add_matches(self, matches):
+                self._matches = matches
+
+        def _add_matches_attrs(self):
+		if self._matches:
+			i = 0
+
+                        matchset = nl.nla_nest_start(self._nl_msg._msg, nl80211.ATTR_SCHED_SCAN_MATCH)
+			for match in self._matches:
+                                nest = nl.nla_nest_start(self._nl_msg._msg, i)
+                                if 'ssid' in match:
+                                        nl.nla_put(self._nl_msg._msg, nl80211.SCHED_SCAN_MATCH_ATTR_SSID, match['ssid'])
+				i += 1
+                                nl.nla_nest_end(self._nl_msg._msg, nest)
+
+                        nl.nla_nest_end(self._nl_msg._msg, matchset)
+
+        def send(self):
+                self._prepare_cmd()
+                self._add_scan_attrs()
+                self._add_matches_attrs()
+                self._send_and_wait()
+
         def handle(self, msg, arg):
 		genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))