Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] cfg80211: issue netlink notification when scan starts
@ 2009-06-16 17:56 Johannes Berg
  2009-06-16 19:22 ` Dan Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2009-06-16 17:56 UTC (permalink / raw)
  To: John Linville; +Cc: Marcel Holtmann, linux-wireless

To ease multiple apps working together smoothly,
send a notification when a scan is started.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/wireless/nl80211.c |   39 ++++++++++++++++++++++++++++++---------
 net/wireless/nl80211.h |    2 ++
 net/wireless/scan.c    |    3 ++-
 3 files changed, 34 insertions(+), 10 deletions(-)

--- wireless-testing.orig/net/wireless/nl80211.c	2009-06-16 18:49:13.000000000 +0200
+++ wireless-testing/net/wireless/nl80211.c	2009-06-16 18:51:27.000000000 +0200
@@ -2773,6 +2773,9 @@ static int nl80211_trigger_scan(struct s
 	drv->scan_req = request;
 	err = drv->ops->scan(&drv->wiphy, dev, request);
 
+	if (!err)
+		nl80211_send_scan_start(drv, dev);
+
  out_free:
 	if (err) {
 		drv->scan_req = NULL;
@@ -3599,11 +3602,11 @@ static int nl80211_add_scan_req(struct s
 	return -ENOBUFS;
 }
 
-static int nl80211_send_scan_donemsg(struct sk_buff *msg,
-				     struct cfg80211_registered_device *rdev,
-				     struct net_device *netdev,
-				     u32 pid, u32 seq, int flags,
-				     u32 cmd)
+static int nl80211_send_scan_msg(struct sk_buff *msg,
+				 struct cfg80211_registered_device *rdev,
+				 struct net_device *netdev,
+				 u32 pid, u32 seq, int flags,
+				 u32 cmd)
 {
 	void *hdr;
 
@@ -3624,6 +3627,24 @@ static int nl80211_send_scan_donemsg(str
 	return -EMSGSIZE;
 }
 
+void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
+			     struct net_device *netdev)
+{
+	struct sk_buff *msg;
+
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (!msg)
+		return;
+
+	if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
+				  NL80211_CMD_TRIGGER_SCAN) < 0) {
+		nlmsg_free(msg);
+		return;
+	}
+
+	genlmsg_multicast(msg, 0, nl80211_scan_mcgrp.id, GFP_KERNEL);
+}
+
 void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
 			    struct net_device *netdev)
 {
@@ -3633,8 +3654,8 @@ void nl80211_send_scan_done(struct cfg80
 	if (!msg)
 		return;
 
-	if (nl80211_send_scan_donemsg(msg, rdev, netdev, 0, 0, 0,
-				      NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
+	if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
+				  NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
 		nlmsg_free(msg);
 		return;
 	}
@@ -3651,8 +3672,8 @@ void nl80211_send_scan_aborted(struct cf
 	if (!msg)
 		return;
 
-	if (nl80211_send_scan_donemsg(msg, rdev, netdev, 0, 0, 0,
-				      NL80211_CMD_SCAN_ABORTED) < 0) {
+	if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
+				  NL80211_CMD_SCAN_ABORTED) < 0) {
 		nlmsg_free(msg);
 		return;
 	}
--- wireless-testing.orig/net/wireless/nl80211.h	2009-06-16 18:50:32.000000000 +0200
+++ wireless-testing/net/wireless/nl80211.h	2009-06-16 18:50:53.000000000 +0200
@@ -6,6 +6,8 @@
 extern int nl80211_init(void);
 extern void nl80211_exit(void);
 extern void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev);
+extern void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
+				    struct net_device *netdev);
 extern void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
 				   struct net_device *netdev);
 extern void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
--- wireless-testing.orig/net/wireless/scan.c	2009-06-16 18:52:00.000000000 +0200
+++ wireless-testing/net/wireless/scan.c	2009-06-16 18:52:13.000000000 +0200
@@ -648,7 +648,8 @@ int cfg80211_wext_siwscan(struct net_dev
 	if (err) {
 		rdev->scan_req = NULL;
 		kfree(creq);
-	}
+	} else
+		nl80211_send_scan_start(rdev, dev);
  out:
 	cfg80211_put_dev(rdev);
 	return err;



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

* Re: [PATCH] cfg80211: issue netlink notification when scan starts
  2009-06-16 17:56 [PATCH] cfg80211: issue netlink notification when scan starts Johannes Berg
@ 2009-06-16 19:22 ` Dan Williams
  2009-06-16 19:28   ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Williams @ 2009-06-16 19:22 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John Linville, Marcel Holtmann, linux-wireless

On Tue, 2009-06-16 at 19:56 +0200, Johannes Berg wrote:
> To ease multiple apps working together smoothly,
> send a notification when a scan is started.

Yay.  I like this.  As long as we can guarantee that it will always be
followed by a scan-done message of course.

Dan

> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> ---
>  net/wireless/nl80211.c |   39 ++++++++++++++++++++++++++++++---------
>  net/wireless/nl80211.h |    2 ++
>  net/wireless/scan.c    |    3 ++-
>  3 files changed, 34 insertions(+), 10 deletions(-)
> 
> --- wireless-testing.orig/net/wireless/nl80211.c	2009-06-16 18:49:13.000000000 +0200
> +++ wireless-testing/net/wireless/nl80211.c	2009-06-16 18:51:27.000000000 +0200
> @@ -2773,6 +2773,9 @@ static int nl80211_trigger_scan(struct s
>  	drv->scan_req = request;
>  	err = drv->ops->scan(&drv->wiphy, dev, request);
>  
> +	if (!err)
> +		nl80211_send_scan_start(drv, dev);
> +
>   out_free:
>  	if (err) {
>  		drv->scan_req = NULL;
> @@ -3599,11 +3602,11 @@ static int nl80211_add_scan_req(struct s
>  	return -ENOBUFS;
>  }
>  
> -static int nl80211_send_scan_donemsg(struct sk_buff *msg,
> -				     struct cfg80211_registered_device *rdev,
> -				     struct net_device *netdev,
> -				     u32 pid, u32 seq, int flags,
> -				     u32 cmd)
> +static int nl80211_send_scan_msg(struct sk_buff *msg,
> +				 struct cfg80211_registered_device *rdev,
> +				 struct net_device *netdev,
> +				 u32 pid, u32 seq, int flags,
> +				 u32 cmd)
>  {
>  	void *hdr;
>  
> @@ -3624,6 +3627,24 @@ static int nl80211_send_scan_donemsg(str
>  	return -EMSGSIZE;
>  }
>  
> +void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
> +			     struct net_device *netdev)
> +{
> +	struct sk_buff *msg;
> +
> +	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
> +	if (!msg)
> +		return;
> +
> +	if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
> +				  NL80211_CMD_TRIGGER_SCAN) < 0) {
> +		nlmsg_free(msg);
> +		return;
> +	}
> +
> +	genlmsg_multicast(msg, 0, nl80211_scan_mcgrp.id, GFP_KERNEL);
> +}
> +
>  void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
>  			    struct net_device *netdev)
>  {
> @@ -3633,8 +3654,8 @@ void nl80211_send_scan_done(struct cfg80
>  	if (!msg)
>  		return;
>  
> -	if (nl80211_send_scan_donemsg(msg, rdev, netdev, 0, 0, 0,
> -				      NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
> +	if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
> +				  NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
>  		nlmsg_free(msg);
>  		return;
>  	}
> @@ -3651,8 +3672,8 @@ void nl80211_send_scan_aborted(struct cf
>  	if (!msg)
>  		return;
>  
> -	if (nl80211_send_scan_donemsg(msg, rdev, netdev, 0, 0, 0,
> -				      NL80211_CMD_SCAN_ABORTED) < 0) {
> +	if (nl80211_send_scan_msg(msg, rdev, netdev, 0, 0, 0,
> +				  NL80211_CMD_SCAN_ABORTED) < 0) {
>  		nlmsg_free(msg);
>  		return;
>  	}
> --- wireless-testing.orig/net/wireless/nl80211.h	2009-06-16 18:50:32.000000000 +0200
> +++ wireless-testing/net/wireless/nl80211.h	2009-06-16 18:50:53.000000000 +0200
> @@ -6,6 +6,8 @@
>  extern int nl80211_init(void);
>  extern void nl80211_exit(void);
>  extern void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev);
> +extern void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
> +				    struct net_device *netdev);
>  extern void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
>  				   struct net_device *netdev);
>  extern void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
> --- wireless-testing.orig/net/wireless/scan.c	2009-06-16 18:52:00.000000000 +0200
> +++ wireless-testing/net/wireless/scan.c	2009-06-16 18:52:13.000000000 +0200
> @@ -648,7 +648,8 @@ int cfg80211_wext_siwscan(struct net_dev
>  	if (err) {
>  		rdev->scan_req = NULL;
>  		kfree(creq);
> -	}
> +	} else
> +		nl80211_send_scan_start(rdev, dev);
>   out:
>  	cfg80211_put_dev(rdev);
>  	return err;
> 
> 
> --
> 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


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

* Re: [PATCH] cfg80211: issue netlink notification when scan starts
  2009-06-16 19:22 ` Dan Williams
@ 2009-06-16 19:28   ` Johannes Berg
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2009-06-16 19:28 UTC (permalink / raw)
  To: Dan Williams; +Cc: John Linville, Marcel Holtmann, linux-wireless

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

On Tue, 2009-06-16 at 15:22 -0400, Dan Williams wrote:
> On Tue, 2009-06-16 at 19:56 +0200, Johannes Berg wrote:
> > To ease multiple apps working together smoothly,
> > send a notification when a scan is started.
> 
> Yay.  I like this.  As long as we can guarantee that it will always be
> followed by a scan-done message of course.

Yes, it will. Unless allocation fails or something stupid like that.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

end of thread, other threads:[~2009-06-16 19:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-16 17:56 [PATCH] cfg80211: issue netlink notification when scan starts Johannes Berg
2009-06-16 19:22 ` Dan Williams
2009-06-16 19:28   ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox