linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iw: Add send callback with optional debug handler
@ 2011-03-17  0:28 Sean Robinson
  2011-03-17  9:29 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Robinson @ 2011-03-17  0:28 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

libnl supports callbacks for send and recv.  This patch enables callbacks
for sent messages and uses the debug callback for the --debug option, as
the recv callbacks do.

Signed-off-by: Sean Robinson <seankrobinson@gmail.com>
---
 iw.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/iw.c b/iw.c
index 2593481..4c1fcbd 100644
--- a/iw.c
+++ b/iw.c
@@ -259,6 +259,7 @@ static int __handle_cmd(struct nl80211_state
*state, enum id_input idby,
 {
 	const struct cmd *cmd, *match = NULL, *sectcmd;
 	struct nl_cb *cb;
+	struct nl_cb *s_cb;
 	struct nl_msg *msg;
 	int devidx = 0;
 	int err, o_argc;
@@ -380,7 +381,8 @@ static int __handle_cmd(struct nl80211_state
*state, enum id_input idby,
 	}

 	cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
-	if (!cb) {
+	s_cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
+	if (!(cb && s_cb)) {
 		fprintf(stderr, "failed to allocate netlink callbacks\n");
 		err = 2;
 		goto out_free_msg;
@@ -404,6 +406,8 @@ static int __handle_cmd(struct nl80211_state
*state, enum id_input idby,
 	if (err)
 		goto out;

+	nl_socket_set_cb(state->nl_sock, s_cb);
+
 	err = nl_send_auto_complete(state->nl_sock, msg);
 	if (err < 0)
 		goto out;
--
1.7.4.1



-- 
Sean Robinson
WiFi Radar - http://wifi-radar.berlios.de
Python WiFi - http://pythonwifi.wikispot.org
pymnl - http://pymnl.wikispot.org

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

* Re: [PATCH] iw: Add send callback with optional debug handler
  2011-03-17  0:28 [PATCH] iw: Add send callback with optional debug handler Sean Robinson
@ 2011-03-17  9:29 ` Johannes Berg
  2011-03-17 15:06   ` Sean Robinson
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2011-03-17  9:29 UTC (permalink / raw)
  To: Sean Robinson; +Cc: linux-wireless

On Wed, 2011-03-16 at 17:28 -0700, Sean Robinson wrote:
> libnl supports callbacks for send and recv.  This patch enables callbacks
> for sent messages and uses the debug callback for the --debug option, as
> the recv callbacks do.

I can't apply this, the patch is corrupted.

>  	cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
> -	if (!cb) {
> +	s_cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
> +	if (!(cb && s_cb)) {

I think (!cb || !s_cb) would be easier to read.

johannes



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

* Re: [PATCH] iw: Add send callback with optional debug handler
  2011-03-17  9:29 ` Johannes Berg
@ 2011-03-17 15:06   ` Sean Robinson
  0 siblings, 0 replies; 3+ messages in thread
From: Sean Robinson @ 2011-03-17 15:06 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

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

  I have made the test syntax change you recommended and attached the
gzipped 'git format-patch'.

On Thu, Mar 17, 2011 at 2:29 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Wed, 2011-03-16 at 17:28 -0700, Sean Robinson wrote:
>> libnl supports callbacks for send and recv.  This patch enables callbacks
>> for sent messages and uses the debug callback for the --debug option, as
>> the recv callbacks do.
>
> I can't apply this, the patch is corrupted.
>
>>       cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
>> -     if (!cb) {
>> +     s_cb = nl_cb_alloc(iw_debug ? NL_CB_DEBUG : NL_CB_DEFAULT);
>> +     if (!(cb && s_cb)) {
>
> I think (!cb || !s_cb) would be easier to read.
>
> johannes
>
>
>



-- 
Sean Robinson
WiFi Radar - http://wifi-radar.berlios.de
Python WiFi - http://pythonwifi.wikispot.org
pymnl - http://pymnl.wikispot.org

[-- Attachment #2: 0001-Add-send-callbacks-with-optional-debug-handler.patch.gz --]
[-- Type: application/x-gzip, Size: 805 bytes --]

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

end of thread, other threads:[~2011-03-17 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17  0:28 [PATCH] iw: Add send callback with optional debug handler Sean Robinson
2011-03-17  9:29 ` Johannes Berg
2011-03-17 15:06   ` Sean Robinson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).