All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH py80211 0/4] py80211: add support for scheduled scan
@ 2015-06-12 14:00 Luca Coelho
  2015-06-12 14:00 ` [PATCH py80211 1/4] py80211: scan: spin base scan classes off scan_request Luca Coelho
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Luca Coelho @ 2015-06-12 14:00 UTC (permalink / raw)
  To: aspriel; +Cc: linux-wireless

From: Luciano Coelho <luciano.coelho@intel.com>

Hi Arend,

Here's a small patchset that adds support for scheduled scans in
py80211.

I'm not sure this is the right approach, I added separate classes for
each command, so feel free to ask me to change it completely if you
want and I may or may not do it. :P

Cheers,
Luca.

Luciano Coelho (4):
  py80211: scan: spin base scan classes off scan_request
  py80211: scan: add sched_scan start class
  py80211: add sched_scan stop class
  py80211: scan: add matchsets support for scheduled scans

 lib/scan.py | 157 +++++++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 119 insertions(+), 38 deletions(-)

-- 
2.1.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH py80211 1/4] py80211: scan: spin base scan classes off scan_request
  2015-06-12 14:00 [PATCH py80211 0/4] py80211: add support for scheduled scan Luca Coelho
@ 2015-06-12 14:00 ` Luca Coelho
  2015-06-13 18:40   ` Arend van Spriel
  2015-06-12 14:00 ` [PATCH py80211 2/4] py80211: scan: add sched_scan start class Luca Coelho
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Luca Coelho @ 2015-06-12 14:00 UTC (permalink / raw)
  To: aspriel; +Cc: linux-wireless

From: Luciano Coelho <luciano.coelho@intel.com>

Most of the scan_request code can be reused for scheduled scan, so
spin the common part off the regular scan class.

Additionally, add one extra class that is able to send scan commands
(for sched_scan stop, for instance) without adding any scan
attributes.

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

diff --git a/lib/scan.py b/lib/scan.py
index 491c0b7..5ccae55 100644
--- a/lib/scan.py
+++ b/lib/scan.py
@@ -84,14 +84,65 @@ class bss_list(custom_handler):
 			traceback.print_tb(tb)
 		return nl.NL_SKIP
 
-class scan_request(custom_handler):
+class scan_cmd_base(custom_handler):
 	def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
-		self._ifidx = ifidx
 		self._access = access80211(level)
+                self._nl_cmd = None
+		self._ifidx = ifidx
+
+	def _wait_for_completion(self):
+		while self.scan_busy:
+			self._access._sock.recvmsgs(self._access._rx_cb)
+
+	def _prepare_cmd(self):
+                if self._nl_cmd == None:
+                        raise Exception("sub-class must set _nl_cmd")
+
+		flags = nlc.NLM_F_REQUEST | nlc.NLM_F_ACK
+		self._nl_msg = self._access.alloc_genlmsg(self._nl_cmd, flags)
+		nl.nla_put_u32(self._nl_msg._msg, nl80211.ATTR_IFINDEX, self._ifidx)
+
+        def _send_and_wait(self):
+		self.scan_busy = True
+		self._access.disable_seq_check()
+		mcid = self._access.subscribe_multicast('scan')
+		ret = self._access.send(self._nl_msg, self)
+		if ret < 0:
+			self.scan_busy = False
+			return ret
+
+		self._wait_for_completion()
+		self._access.drop_multicast(mcid)
+		return 0
+
+class scan_start_base(scan_cmd_base):
+        def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
+                super(scan_start_base, self).__init__(ifidx, level)
 		self._ssids = None
 		self._freqs = None
 		self._flags = 0
 		self._ies = None
+                self._nl_cmd = None
+
+        def _add_scan_attrs(self):
+		if self._ssids:
+			i = 0
+			nest = nl.nla_nest_start(self._nl_msg._msg, nl80211.ATTR_SCAN_SSIDS)
+			for ssid in self._ssids:
+				nl.nla_put(self._nl_msg._msg, i, ssid)
+				i += 1
+			nl.nla_nest_end(self._nl_msg._msg, nest)
+		if self._freqs:
+			i = 0
+			nest = nl.nla_nest_start(self._nl_msg._msg, nl80211.ATTR_SCAN_FREQUENCIES)
+			for freq in self._freqs:
+				nl.nla_put_u32(self._nl_msg._msg, i, freq)
+				i += 1
+			nl.nla_nest_end(self._nl_msg._msg, nest)
+		if self._flags != 0:
+			nl.nla_put_u32(self._nl_msg._msg, nl80211.ATTR_SCAN_FLAGS, self._flags)
+		if self._ies:
+			nl.nla_put(self._nl_msg._msg, nl80211.ATTR_IE, self._ies)
 
 	def add_ssids(self, ssids):
 		if self._ssids == None:
@@ -115,49 +166,20 @@ class scan_request(custom_handler):
 	def set_flags(self, flags):
 		self._flags = flags
 
-	def wait_for_scan_completion(self):
-		while self.scan_busy:
-			self._access._sock.recvmsgs(self._access._rx_cb)
-
-	def send(self):
-		flags = nlc.NLM_F_REQUEST | nlc.NLM_F_ACK
-		m = self._access.alloc_genlmsg(nl80211.CMD_TRIGGER_SCAN, flags)
-		nl.nla_put_u32(m._msg, nl80211.ATTR_IFINDEX, self._ifidx)
+        def send(self):
+                self._prepare_cmd()
+                self._add_scan_attrs()
+                self._send_and_wait()
 
-		if self._ssids:
-			i = 0
-			nest = nl.nla_nest_start(m._msg, nl80211.ATTR_SCAN_SSIDS)
-			for ssid in self._ssids:
-				nl.nla_put(m._msg, i, ssid)
-				i += 1
-			nl.nla_nest_end(m._msg, nest)
-		if self._freqs:
-			i = 0
-			nest = nl.nla_nest_start(m._msg, nl80211.ATTR_SCAN_FREQUENCIES)
-			for freq in self._freqs:
-				nl.nla_put_u32(m._msg, i, freq)
-				i += 1
-			nl.nla_nest_end(m._msg, nest)
-		if self._flags != 0:
-			nl.nla_put_u32(m._msg, nl80211.ATTR_SCAN_FLAGS, self._flags)
-		if self._ies:
-			nl.nla_put(m._msg, nl80211.ATTR_IE, self._ies)
-
-		self.scan_busy = True
-		self._access.disable_seq_check()
-		mcid = self._access.subscribe_multicast('scan')
-		ret = self._access.send(m, self)
-		if ret < 0:
-			self.scan_busy = False
-			return ret
-
-		self.wait_for_scan_completion()
-		self._access.drop_multicast(mcid)
-		return 0
+class scan_request(scan_start_base):
+	def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
+                super(scan_request, self).__init__(ifidx, level)
+                self._nl_cmd = nl80211.CMD_TRIGGER_SCAN
 
-	def handle(self, msg, arg):
+        def handle(self, msg, arg):
 		genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))
+
+                # A regular scan is complete when we get scan results
 		if genlh.cmd in [ nl80211.CMD_SCAN_ABORTED, nl80211.CMD_NEW_SCAN_RESULTS ]:
 			self.scan_busy = False
 		return nl.NL_SKIP
-
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH py80211 2/4] py80211: scan: add sched_scan start class
  2015-06-12 14:00 [PATCH py80211 0/4] py80211: add support for scheduled scan Luca Coelho
  2015-06-12 14:00 ` [PATCH py80211 1/4] py80211: scan: spin base scan classes off scan_request Luca Coelho
@ 2015-06-12 14:00 ` Luca Coelho
  2015-06-13 18:44   ` Arend van Spriel
  2015-06-12 14:00 ` [PATCH py80211 3/4] py80211: add sched_scan stop class Luca Coelho
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Luca Coelho @ 2015-06-12 14:00 UTC (permalink / raw)
  To: aspriel; +Cc: linux-wireless

From: Luciano Coelho <luciano.coelho@intel.com>

Add a class to start scheduled scans.

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

diff --git a/lib/scan.py b/lib/scan.py
index 5ccae55..bfaf4da 100644
--- a/lib/scan.py
+++ b/lib/scan.py
@@ -123,6 +123,7 @@ class scan_start_base(scan_cmd_base):
 		self._flags = 0
 		self._ies = None
                 self._nl_cmd = None
+                self._interval = None
 
         def _add_scan_attrs(self):
 		if self._ssids:
@@ -144,6 +145,9 @@ class scan_start_base(scan_cmd_base):
 		if self._ies:
 			nl.nla_put(self._nl_msg._msg, nl80211.ATTR_IE, self._ies)
 
+                if self._interval != None:
+                        nl.nla_put_u32(self._nl_msg._msg, nl80211.ATTR_SCHED_SCAN_INTERVAL, self._interval)
+
 	def add_ssids(self, ssids):
 		if self._ssids == None:
 			self._ssids = ssids
@@ -183,3 +187,19 @@ class scan_request(scan_start_base):
 		if genlh.cmd in [ nl80211.CMD_SCAN_ABORTED, nl80211.CMD_NEW_SCAN_RESULTS ]:
 			self.scan_busy = False
 		return nl.NL_SKIP
+
+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
+
+	def set_interval(self, interval):
+		self._interval = interval
+
+        def handle(self, msg, arg):
+		genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))
+
+                # A schedule scan is complete immediately when it gets started
+                if genlh.cmd in [ nl80211.CMD_START_SCHED_SCAN ]:
+                        self.scan_busy = False
+		return nl.NL_SKIP
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH py80211 3/4] py80211: add sched_scan stop class
  2015-06-12 14:00 [PATCH py80211 0/4] py80211: add support for scheduled scan Luca Coelho
  2015-06-12 14:00 ` [PATCH py80211 1/4] py80211: scan: spin base scan classes off scan_request Luca Coelho
  2015-06-12 14:00 ` [PATCH py80211 2/4] py80211: scan: add sched_scan start class Luca Coelho
@ 2015-06-12 14:00 ` Luca Coelho
  2015-06-13 18:45   ` Arend van Spriel
  2015-06-12 14:00 ` [PATCH py80211 4/4] py80211: scan: add matchsets support for scheduled scans Luca Coelho
  2015-06-13  6:26 ` [PATCH py80211 0/4] py80211: add support for scheduled scan Arend van Spriel
  4 siblings, 1 reply; 12+ messages in thread
From: Luca Coelho @ 2015-06-12 14:00 UTC (permalink / raw)
  To: aspriel; +Cc: linux-wireless

From: Luciano Coelho <luciano.coelho@intel.com>

Add a class to stop scheduled scans.

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

diff --git a/lib/scan.py b/lib/scan.py
index bfaf4da..bfaf3d2 100644
--- a/lib/scan.py
+++ b/lib/scan.py
@@ -203,3 +203,18 @@ class sched_scan_start(scan_start_base):
                 if genlh.cmd in [ nl80211.CMD_START_SCHED_SCAN ]:
                         self.scan_busy = False
 		return nl.NL_SKIP
+
+class sched_scan_stop(scan_cmd_base):
+	def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
+                super(sched_scan_stop, self).__init__(ifidx, level)
+                self._nl_cmd = nl80211.CMD_STOP_SCHED_SCAN
+
+        def send(self):
+                self._prepare_cmd()
+                self._send_and_wait()
+
+        def handle(self, msg, arg):
+		genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))
+                if genlh.cmd in [ nl80211.CMD_SCHED_SCAN_STOPPED ]:
+                        self.scan_busy = False
+		return nl.NL_SKIP
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH py80211 4/4] py80211: scan: add matchsets support for scheduled scans
  2015-06-12 14:00 [PATCH py80211 0/4] py80211: add support for scheduled scan Luca Coelho
                   ` (2 preceding siblings ...)
  2015-06-12 14:00 ` [PATCH py80211 3/4] py80211: add sched_scan stop class Luca Coelho
@ 2015-06-12 14:00 ` Luca Coelho
  2015-06-13 18:45   ` Arend van Spriel
  2015-06-13  6:26 ` [PATCH py80211 0/4] py80211: add support for scheduled scan Arend van Spriel
  4 siblings, 1 reply; 12+ messages in thread
From: Luca Coelho @ 2015-06-12 14:00 UTC (permalink / raw)
  To: aspriel; +Cc: linux-wireless

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(+)

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))
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH py80211 0/4] py80211: add support for scheduled scan
  2015-06-12 14:00 [PATCH py80211 0/4] py80211: add support for scheduled scan Luca Coelho
                   ` (3 preceding siblings ...)
  2015-06-12 14:00 ` [PATCH py80211 4/4] py80211: scan: add matchsets support for scheduled scans Luca Coelho
@ 2015-06-13  6:26 ` Arend van Spriel
  2015-06-16  7:33   ` Luca Coelho
  4 siblings, 1 reply; 12+ messages in thread
From: Arend van Spriel @ 2015-06-13  6:26 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless

On 12-06-15 16:00, Luca Coelho wrote:
> From: Luciano Coelho <luciano.coelho@intel.com>
> 
> Hi Arend,
> 
> Here's a small patchset that adds support for scheduled scans in
> py80211.

Thanks! One general remark. It seems you are using soft-tabs where I
stick to true tabs. Python is pretty anal about that so better stick to
true tabs.

> I'm not sure this is the right approach, I added separate classes for
> each command, so feel free to ask me to change it completely if you
> want and I may or may not do it. :P

Me neither, but it may be a bit too classy ;-) So I would prefer to have
a scheduled scan class with start and stop operation.

Good to see you are using '_' consistently for class private members and
functions. I need to clean it up in other files. I recently added Pyro
support allowing remote access to py80211 objects and it only exposes
public members and functions.

Thanks again,
Arend

> Cheers,
> Luca.
> 
> Luciano Coelho (4):
>   py80211: scan: spin base scan classes off scan_request
>   py80211: scan: add sched_scan start class
>   py80211: add sched_scan stop class
>   py80211: scan: add matchsets support for scheduled scans
> 
>  lib/scan.py | 157 +++++++++++++++++++++++++++++++++++++++++++++---------------
>  1 file changed, 119 insertions(+), 38 deletions(-)
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH py80211 1/4] py80211: scan: spin base scan classes off scan_request
  2015-06-12 14:00 ` [PATCH py80211 1/4] py80211: scan: spin base scan classes off scan_request Luca Coelho
@ 2015-06-13 18:40   ` Arend van Spriel
  0 siblings, 0 replies; 12+ messages in thread
From: Arend van Spriel @ 2015-06-13 18:40 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless

On 12-06-15 16:00, Luca Coelho wrote:
> From: Luciano Coelho <luciano.coelho@intel.com>
> 
> Most of the scan_request code can be reused for scheduled scan, so
> spin the common part off the regular scan class.
> 
> Additionally, add one extra class that is able to send scan commands
> (for sched_scan stop, for instance) without adding any scan
> attributes.
> 
> Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>

Added to the master branch with following modifications:

    [aspriel@gmail.com: fixed indentation]
    [aspriel@gmail.com: remove redundant initialization]

> ---
>  lib/scan.py | 106 ++++++++++++++++++++++++++++++++++++------------------------
>  1 file changed, 64 insertions(+), 42 deletions(-)
> 
> diff --git a/lib/scan.py b/lib/scan.py
> index 491c0b7..5ccae55 100644
> --- a/lib/scan.py
> +++ b/lib/scan.py
> @@ -84,14 +84,65 @@ class bss_list(custom_handler):
>  			traceback.print_tb(tb)
>  		return nl.NL_SKIP
>  
> -class scan_request(custom_handler):
> +class scan_cmd_base(custom_handler):
>  	def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
> -		self._ifidx = ifidx
>  		self._access = access80211(level)
> +                self._nl_cmd = None
> +		self._ifidx = ifidx
> +
> +	def _wait_for_completion(self):
> +		while self.scan_busy:
> +			self._access._sock.recvmsgs(self._access._rx_cb)
> +
> +	def _prepare_cmd(self):
> +                if self._nl_cmd == None:
> +                        raise Exception("sub-class must set _nl_cmd")
> +
> +		flags = nlc.NLM_F_REQUEST | nlc.NLM_F_ACK
> +		self._nl_msg = self._access.alloc_genlmsg(self._nl_cmd, flags)
> +		nl.nla_put_u32(self._nl_msg._msg, nl80211.ATTR_IFINDEX, self._ifidx)
> +
> +        def _send_and_wait(self):
> +		self.scan_busy = True
> +		self._access.disable_seq_check()
> +		mcid = self._access.subscribe_multicast('scan')
> +		ret = self._access.send(self._nl_msg, self)
> +		if ret < 0:
> +			self.scan_busy = False
> +			return ret
> +
> +		self._wait_for_completion()
> +		self._access.drop_multicast(mcid)
> +		return 0
> +
> +class scan_start_base(scan_cmd_base):
> +        def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
> +                super(scan_start_base, self).__init__(ifidx, level)
>  		self._ssids = None
>  		self._freqs = None
>  		self._flags = 0
>  		self._ies = None
> +                self._nl_cmd = None

This initialization of _nl_cmd is redundant and thus removed.

> +
> +        def _add_scan_attrs(self):
> +		if self._ssids:
> +			i = 0
> +			nest = nl.nla_nest_start(self._nl_msg._msg, nl80211.ATTR_SCAN_SSIDS)
> +			for ssid in self._ssids:
> +				nl.nla_put(self._nl_msg._msg, i, ssid)
> +				i += 1
> +			nl.nla_nest_end(self._nl_msg._msg, nest)
> +		if self._freqs:
> +			i = 0
> +			nest = nl.nla_nest_start(self._nl_msg._msg, nl80211.ATTR_SCAN_FREQUENCIES)
> +			for freq in self._freqs:
> +				nl.nla_put_u32(self._nl_msg._msg, i, freq)
> +				i += 1
> +			nl.nla_nest_end(self._nl_msg._msg, nest)
> +		if self._flags != 0:
> +			nl.nla_put_u32(self._nl_msg._msg, nl80211.ATTR_SCAN_FLAGS, self._flags)
> +		if self._ies:
> +			nl.nla_put(self._nl_msg._msg, nl80211.ATTR_IE, self._ies)
>  
>  	def add_ssids(self, ssids):
>  		if self._ssids == None:
> @@ -115,49 +166,20 @@ class scan_request(custom_handler):
>  	def set_flags(self, flags):
>  		self._flags = flags
>  
> -	def wait_for_scan_completion(self):
> -		while self.scan_busy:
> -			self._access._sock.recvmsgs(self._access._rx_cb)
> -
> -	def send(self):
> -		flags = nlc.NLM_F_REQUEST | nlc.NLM_F_ACK
> -		m = self._access.alloc_genlmsg(nl80211.CMD_TRIGGER_SCAN, flags)
> -		nl.nla_put_u32(m._msg, nl80211.ATTR_IFINDEX, self._ifidx)
> +        def send(self):
> +                self._prepare_cmd()
> +                self._add_scan_attrs()
> +                self._send_and_wait()
>  
> -		if self._ssids:
> -			i = 0
> -			nest = nl.nla_nest_start(m._msg, nl80211.ATTR_SCAN_SSIDS)
> -			for ssid in self._ssids:
> -				nl.nla_put(m._msg, i, ssid)
> -				i += 1
> -			nl.nla_nest_end(m._msg, nest)
> -		if self._freqs:
> -			i = 0
> -			nest = nl.nla_nest_start(m._msg, nl80211.ATTR_SCAN_FREQUENCIES)
> -			for freq in self._freqs:
> -				nl.nla_put_u32(m._msg, i, freq)
> -				i += 1
> -			nl.nla_nest_end(m._msg, nest)
> -		if self._flags != 0:
> -			nl.nla_put_u32(m._msg, nl80211.ATTR_SCAN_FLAGS, self._flags)
> -		if self._ies:
> -			nl.nla_put(m._msg, nl80211.ATTR_IE, self._ies)
> -
> -		self.scan_busy = True
> -		self._access.disable_seq_check()
> -		mcid = self._access.subscribe_multicast('scan')
> -		ret = self._access.send(m, self)
> -		if ret < 0:
> -			self.scan_busy = False
> -			return ret
> -
> -		self.wait_for_scan_completion()
> -		self._access.drop_multicast(mcid)
> -		return 0
> +class scan_request(scan_start_base):
> +	def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
> +                super(scan_request, self).__init__(ifidx, level)
> +                self._nl_cmd = nl80211.CMD_TRIGGER_SCAN
>  
> -	def handle(self, msg, arg):
> +        def handle(self, msg, arg):
>  		genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))
> +
> +                # A regular scan is complete when we get scan results
>  		if genlh.cmd in [ nl80211.CMD_SCAN_ABORTED, nl80211.CMD_NEW_SCAN_RESULTS ]:
>  			self.scan_busy = False
>  		return nl.NL_SKIP
> -
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH py80211 2/4] py80211: scan: add sched_scan start class
  2015-06-12 14:00 ` [PATCH py80211 2/4] py80211: scan: add sched_scan start class Luca Coelho
@ 2015-06-13 18:44   ` Arend van Spriel
  0 siblings, 0 replies; 12+ messages in thread
From: Arend van Spriel @ 2015-06-13 18:44 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless



On 12-06-15 16:00, Luca Coelho wrote:
> From: Luciano Coelho <luciano.coelho@intel.com>
> 
> Add a class to start scheduled scans.
> 
> Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>

Merged in the master branch with following modification:

    [aspriel@gmail.com: fixed indentation]
    [aspriel@gmail.com: only use interval member in sched_scan_start]

Regards,
Arend

> ---
>  lib/scan.py | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/lib/scan.py b/lib/scan.py
> index 5ccae55..bfaf4da 100644
> --- a/lib/scan.py
> +++ b/lib/scan.py
> @@ -123,6 +123,7 @@ class scan_start_base(scan_cmd_base):
>  		self._flags = 0
>  		self._ies = None
>                  self._nl_cmd = None
> +                self._interval = None

Deal with interval in sched_scan_start class by overriding _add_scan_attrs.

>          def _add_scan_attrs(self):
>  		if self._ssids:
> @@ -144,6 +145,9 @@ class scan_start_base(scan_cmd_base):
>  		if self._ies:
>  			nl.nla_put(self._nl_msg._msg, nl80211.ATTR_IE, self._ies)
>  
> +                if self._interval != None:
> +                        nl.nla_put_u32(self._nl_msg._msg, nl80211.ATTR_SCHED_SCAN_INTERVAL, self._interval)
> +
>  	def add_ssids(self, ssids):
>  		if self._ssids == None:
>  			self._ssids = ssids
> @@ -183,3 +187,19 @@ class scan_request(scan_start_base):
>  		if genlh.cmd in [ nl80211.CMD_SCAN_ABORTED, nl80211.CMD_NEW_SCAN_RESULTS ]:
>  			self.scan_busy = False
>  		return nl.NL_SKIP
> +
> +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
> +
> +	def set_interval(self, interval):
> +		self._interval = interval
> +
> +        def handle(self, msg, arg):
> +		genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))
> +
> +                # A schedule scan is complete immediately when it gets started
> +                if genlh.cmd in [ nl80211.CMD_START_SCHED_SCAN ]:
> +                        self.scan_busy = False
> +		return nl.NL_SKIP
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH py80211 3/4] py80211: add sched_scan stop class
  2015-06-12 14:00 ` [PATCH py80211 3/4] py80211: add sched_scan stop class Luca Coelho
@ 2015-06-13 18:45   ` Arend van Spriel
  0 siblings, 0 replies; 12+ messages in thread
From: Arend van Spriel @ 2015-06-13 18:45 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless



On 12-06-15 16:00, Luca Coelho wrote:
> From: Luciano Coelho <luciano.coelho@intel.com>
> 
> Add a class to stop scheduled scans.
> 
> Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>

Merged in master branch after indentation cleanup.

Regards,
Arend

> ---
>  lib/scan.py | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/lib/scan.py b/lib/scan.py
> index bfaf4da..bfaf3d2 100644
> --- a/lib/scan.py
> +++ b/lib/scan.py
> @@ -203,3 +203,18 @@ class sched_scan_start(scan_start_base):
>                  if genlh.cmd in [ nl80211.CMD_START_SCHED_SCAN ]:
>                          self.scan_busy = False
>  		return nl.NL_SKIP
> +
> +class sched_scan_stop(scan_cmd_base):
> +	def __init__(self, ifidx, level=nl.NL_CB_DEFAULT):
> +                super(sched_scan_stop, self).__init__(ifidx, level)
> +                self._nl_cmd = nl80211.CMD_STOP_SCHED_SCAN
> +
> +        def send(self):
> +                self._prepare_cmd()
> +                self._send_and_wait()
> +
> +        def handle(self, msg, arg):
> +		genlh = genl.genlmsg_hdr(nl.nlmsg_hdr(msg))
> +                if genlh.cmd in [ nl80211.CMD_SCHED_SCAN_STOPPED ]:
> +                        self.scan_busy = False
> +		return nl.NL_SKIP
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH py80211 4/4] py80211: scan: add matchsets support for scheduled scans
  2015-06-12 14:00 ` [PATCH py80211 4/4] py80211: scan: add matchsets support for scheduled scans Luca Coelho
@ 2015-06-13 18:45   ` Arend van Spriel
  0 siblings, 0 replies; 12+ messages in thread
From: Arend van Spriel @ 2015-06-13 18:45 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless



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))
>  
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH py80211 0/4] py80211: add support for scheduled scan
  2015-06-13  6:26 ` [PATCH py80211 0/4] py80211: add support for scheduled scan Arend van Spriel
@ 2015-06-16  7:33   ` Luca Coelho
  2015-06-21 21:29     ` Arend van Spriel
  0 siblings, 1 reply; 12+ messages in thread
From: Luca Coelho @ 2015-06-16  7:33 UTC (permalink / raw)
  To: Arend van Spriel; +Cc: linux-wireless

Hi Arend,

On Sat, 2015-06-13 at 08:26 +0200, Arend van Spriel wrote:
> On 12-06-15 16:00, Luca Coelho wrote:
> > Here's a small patchset that adds support for scheduled scans in
> > py80211.
> 
> Thanks! One general remark. It seems you are using soft-tabs where I
> stick to true tabs. Python is pretty anal about that so better stick to
> true tabs.

Uh, sorry about this.  I just used what emacs does by default in
python-mode and didn't give this much thought.  I'll make sure my future
patches conform to pythonist tab analities. :)


> > I'm not sure this is the right approach, I added separate classes for
> > each command, so feel free to ask me to change it completely if you
> > want and I may or may not do it. :P
> 
> Me neither, but it may be a bit too classy ;-) So I would prefer to have
> a scheduled scan class with start and stop operation.

Yeah, I thought so too... In any case, I saw that you applied the classy
version.  Shall I rework this and send new patches or shall we leave it
as it is?


> Good to see you are using '_' consistently for class private members and
> functions. I need to clean it up in other files. I recently added Pyro
> support allowing remote access to py80211 objects and it only exposes
> public members and functions.

Yeah, I like the idea of being strict about private versus public
visibility.

There was a small mistake in one of the changes you made.  I'm going to
send a fix for it in a second.

Thanks for your help!

--
Luca.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH py80211 0/4] py80211: add support for scheduled scan
  2015-06-16  7:33   ` Luca Coelho
@ 2015-06-21 21:29     ` Arend van Spriel
  0 siblings, 0 replies; 12+ messages in thread
From: Arend van Spriel @ 2015-06-21 21:29 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless



On 16-06-15 09:33, Luca Coelho wrote:
> Hi Arend,
> 
> On Sat, 2015-06-13 at 08:26 +0200, Arend van Spriel wrote:
>> On 12-06-15 16:00, Luca Coelho wrote:
>>> Here's a small patchset that adds support for scheduled scans in
>>> py80211.
>>
>> Thanks! One general remark. It seems you are using soft-tabs where I
>> stick to true tabs. Python is pretty anal about that so better stick to
>> true tabs.
> 
> Uh, sorry about this.  I just used what emacs does by default in
> python-mode and didn't give this much thought.  I'll make sure my future
> patches conform to pythonist tab analities. :)

No problem. I am wondering if this is common to python projects.

>>> I'm not sure this is the right approach, I added separate classes for
>>> each command, so feel free to ask me to change it completely if you
>>> want and I may or may not do it. :P
>>
>> Me neither, but it may be a bit too classy ;-) So I would prefer to have
>> a scheduled scan class with start and stop operation.
> 
> Yeah, I thought so too... In any case, I saw that you applied the classy
> version.  Shall I rework this and send new patches or shall we leave it
> as it is?

I did not have too strong opinion about it to bounce it back at you.
Let's leave it for now.

Regards,
Arend

>> Good to see you are using '_' consistently for class private members and
>> functions. I need to clean it up in other files. I recently added Pyro
>> support allowing remote access to py80211 objects and it only exposes
>> public members and functions.
> 
> Yeah, I like the idea of being strict about private versus public
> visibility.
> 
> There was a small mistake in one of the changes you made.  I'm going to
> send a fix for it in a second.
> 
> Thanks for your help!
> 
> --
> Luca.
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-06-21 21:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 14:00 [PATCH py80211 0/4] py80211: add support for scheduled scan Luca Coelho
2015-06-12 14:00 ` [PATCH py80211 1/4] py80211: scan: spin base scan classes off scan_request Luca Coelho
2015-06-13 18:40   ` Arend van Spriel
2015-06-12 14:00 ` [PATCH py80211 2/4] py80211: scan: add sched_scan start class Luca Coelho
2015-06-13 18:44   ` Arend van Spriel
2015-06-12 14:00 ` [PATCH py80211 3/4] py80211: add sched_scan stop class Luca Coelho
2015-06-13 18:45   ` Arend van Spriel
2015-06-12 14:00 ` [PATCH py80211 4/4] py80211: scan: add matchsets support for scheduled scans Luca Coelho
2015-06-13 18:45   ` Arend van Spriel
2015-06-13  6:26 ` [PATCH py80211 0/4] py80211: add support for scheduled scan Arend van Spriel
2015-06-16  7:33   ` Luca Coelho
2015-06-21 21:29     ` Arend van Spriel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.