linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0
@ 2009-01-28 23:10 pat-lkml
  2009-01-28 23:11 ` pat-lkml
  0 siblings, 1 reply; 6+ messages in thread
From: pat-lkml @ 2009-01-28 23:10 UTC (permalink / raw)
  To: linux-wireless

Upstream has renamed nl_handle to nl_sock.  Update iw to the new names
and add #define for libnl-1.1.

Signed-off-by: Pat Erley <pat-lkml@erley.org>
---

In the future, should I keep pushing these sorts of patches, or should
we back them out and wait for a 'release' of libnl-2.0 and push them all
in then?

diff --git a/crda.c b/crda.c
index afc5df1..f2c471f 100644
--- a/crda.c
+++ b/crda.c
@@ -43,10 +43,11 @@ static inline int __genl_ctrl_alloc_cache(struct
nl_handle *h, struct nl_cache *
 }

 #define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache
+#define nl_sock nl_handle
 #endif /* CONFIG_LIBNL20 */

 struct nl80211_state {
-	struct nl_handle *nl_handle;
+	struct nl_sock *nl_sock;
 	struct nl_cache *nl_cache;
 	struct genl_family *nl80211;
 };
@@ -55,22 +56,22 @@ static int nl80211_init(struct nl80211_state *state)
 {
 	int err;

-	state->nl_handle = nl_socket_alloc();
-	if (!state->nl_handle) {
-		fprintf(stderr, "Failed to allocate netlink handle.\n");
+	state->nl_sock = nl_socket_alloc();
+	if (!state->nl_sock) {
+		fprintf(stderr, "Failed to allocate netlink sock.\n");
 		return -ENOMEM;
 	}

-	if (genl_connect(state->nl_handle)) {
+	if (genl_connect(state->nl_sock)) {
 		fprintf(stderr, "Failed to connect to generic netlink.\n");
 		err = -ENOLINK;
-		goto out_handle_destroy;
+		goto out_sock_destroy;
 	}

-	if (genl_ctrl_alloc_cache(state->nl_handle, &state->nl_cache)) {
+	if (genl_ctrl_alloc_cache(state->nl_sock, &state->nl_cache)) {
 		fprintf(stderr, "Failed to allocate generic netlink cache.\n");
 		err = -ENOMEM;
-		goto out_handle_destroy;
+		goto out_sock_destroy;
 	}

 	state->nl80211 = genl_ctrl_search_by_name(state->nl_cache, "nl80211");
@@ -84,8 +85,8 @@ static int nl80211_init(struct nl80211_state *state)

  out_cache_free:
 	nl_cache_free(state->nl_cache);
- out_handle_destroy:
-	nl_socket_free(state->nl_handle);
+ out_sock_destroy:
+	nl_socket_free(state->nl_sock);
 	return err;
 }

@@ -93,7 +94,7 @@ static void nl80211_cleanup(struct nl80211_state *state)
 {
 	genl_family_put(state->nl80211);
 	nl_cache_free(state->nl_cache);
-	nl_socket_free(state->nl_handle);
+	nl_socket_free(state->nl_sock);
 }

 static int reg_handler(struct nl_msg __attribute__((unused)) *msg,
@@ -294,7 +295,7 @@ int main(int argc, char **argv)
 	if (!cb)
 		goto cb_out;

-	r = nl_send_auto_complete(nlstate.nl_handle, msg);
+	r = nl_send_auto_complete(nlstate.nl_sock, msg);

 	if (r < 0) {
 		fprintf(stderr, "Failed to send regulatory request: %d\n", r);
@@ -306,7 +307,7 @@ int main(int argc, char **argv)
 	nl_cb_err(cb, NL_CB_CUSTOM, error_handler, NULL);

 	if (!finished) {
-		r = nl_wait_for_ack(nlstate.nl_handle);
+		r = nl_wait_for_ack(nlstate.nl_sock);
 		if (r < 0) {
 			fprintf(stderr, "Failed to set regulatory domain: "
 				"%d\n", r);

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

* [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0
@ 2009-01-28 23:11 pat-lkml
  2009-01-29  0:04 ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: pat-lkml @ 2009-01-28 23:11 UTC (permalink / raw)
  To: linux-wireless

Upstream has renamed nl_handle to nl_sock.  Update iw to the new names
and add #define for libnl-1.1.

Signed-off-by: Pat Erley <pat-lkml@erley.org>
---

Now with the iw patch instead of the crda patch, haha...

In the future, should I keep pushing these sorts of patches, or should
we back them out and wait for a 'release' of libnl-2.0 and push them all
in then?

diff --git a/genl.c b/genl.c
index e99ea9d..6091b97 100644
--- a/genl.c
+++ b/genl.c
@@ -64,7 +64,7 @@ static int family_handler(struct nl_msg *msg, void *arg)
 	return NL_SKIP;
 }

-int nl_get_multicast_id(struct nl_handle *handle, const char *family,
const char *group)
+int nl_get_multicast_id(struct nl_sock *sock, const char *family, const
char *group)
 {
 	struct nl_msg *msg;
 	struct nl_cb *cb;
@@ -84,7 +84,7 @@ int nl_get_multicast_id(struct nl_handle *handle,
const char *family, const char
 		goto out_fail_cb;
 	}

-	ctrlid = genl_ctrl_resolve(handle, "nlctrl");
+	ctrlid = genl_ctrl_resolve(sock, "nlctrl");

         genlmsg_put(msg, 0, 0, ctrlid, 0,
 		    0, CTRL_CMD_GETFAMILY, 0);
@@ -92,7 +92,7 @@ int nl_get_multicast_id(struct nl_handle *handle,
const char *family, const char
 	ret = -ENOBUFS;
 	NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, family);

-	ret = nl_send_auto_complete(handle, msg);
+	ret = nl_send_auto_complete(sock, msg);
 	if (ret < 0)
 		goto out;

@@ -103,7 +103,7 @@ int nl_get_multicast_id(struct nl_handle *handle,
const char *family, const char
 	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, family_handler, &grp);

 	while (ret > 0)
-		nl_recvmsgs(handle, cb);
+		nl_recvmsgs(sock, cb);

 	if (ret == 0)
 		ret = grp.id;
diff --git a/iw.c b/iw.c
index 117399c..f30da43 100644
--- a/iw.c
+++ b/iw.c
@@ -31,12 +31,12 @@ static inline struct nl_handle *nl_socket_alloc(void)
 	return nl_handle_alloc();
 }

-static inline void nl_socket_free(struct nl_handle *h)
+static inline void nl_socket_free(struct nl_sock *h)
 {
 	nl_handle_destroy(h);
 }

-static inline int __genl_ctrl_alloc_cache(struct nl_handle *h, struct
nl_cache **cache)
+static inline int __genl_ctrl_alloc_cache(struct nl_sock *h, struct
nl_cache **cache)
 {
 	struct nl_cache *tmp = genl_ctrl_alloc_cache(h);
 	if (!tmp)
@@ -53,19 +53,19 @@ static int nl80211_init(struct nl80211_state *state)
 {
 	int err;

-	state->nl_handle = nl_socket_alloc();
-	if (!state->nl_handle) {
-		fprintf(stderr, "Failed to allocate netlink handle.\n");
+	state->nl_sock = nl_socket_alloc();
+	if (!state->nl_sock) {
+		fprintf(stderr, "Failed to allocate netlink socket.\n");
 		return -ENOMEM;
 	}

-	if (genl_connect(state->nl_handle)) {
+	if (genl_connect(state->nl_sock)) {
 		fprintf(stderr, "Failed to connect to generic netlink.\n");
 		err = -ENOLINK;
 		goto out_handle_destroy;
 	}

-	if (genl_ctrl_alloc_cache(state->nl_handle, &state->nl_cache)) {
+	if (genl_ctrl_alloc_cache(state->nl_sock, &state->nl_cache)) {
 		fprintf(stderr, "Failed to allocate generic netlink cache.\n");
 		err = -ENOMEM;
 		goto out_handle_destroy;
@@ -83,7 +83,7 @@ static int nl80211_init(struct nl80211_state *state)
  out_cache_free:
 	nl_cache_free(state->nl_cache);
  out_handle_destroy:
-	nl_socket_free(state->nl_handle);
+	nl_socket_free(state->nl_sock);
 	return err;
 }

@@ -91,7 +91,7 @@ static void nl80211_cleanup(struct nl80211_state *state)
 {
 	genl_family_put(state->nl80211);
 	nl_cache_free(state->nl_cache);
-	nl_socket_free(state->nl_handle);
+	nl_socket_free(state->nl_sock);
 }

 __COMMAND(NULL, NULL, NULL, 0, 0, 0, CIB_NONE, NULL);
@@ -271,7 +271,7 @@ static int handle_cmd(struct nl80211_state *state,
 	if (err)
 		goto out;

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

@@ -282,7 +282,7 @@ static int handle_cmd(struct nl80211_state *state,
 	nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);

 	while (err > 0)
-		nl_recvmsgs(state->nl_handle, cb);
+		nl_recvmsgs(state->nl_sock, cb);
  out:
 	nl_cb_put(cb);
  out_free_msg:
@@ -331,11 +331,11 @@ static int listen_events(struct nl80211_state *state,
 		return -ENOMEM;
 	}

-	mcid = nl_get_multicast_id(state->nl_handle, "nl80211", "config");
+	mcid = nl_get_multicast_id(state->nl_sock, "nl80211", "config");
 	if (mcid < 0)
 		return mcid;

-	ret = nl_socket_add_membership(state->nl_handle, mcid);
+	ret = nl_socket_add_membership(state->nl_sock, mcid);
 	if (ret)
 		return ret;
 	
@@ -344,7 +344,7 @@ static int listen_events(struct nl80211_state *state,
 	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, print_event, NULL);

 	while (1)
-		nl_recvmsgs(state->nl_handle, cb);
+		nl_recvmsgs(state->nl_sock, cb);

 	nl_cb_put(cb);

diff --git a/iw.h b/iw.h
index 49788e0..7c2ab02 100644
--- a/iw.h
+++ b/iw.h
@@ -10,12 +10,12 @@

 #define ETH_ALEN 6

-struct nl80211_state {
-#ifdef CONFIG_LIBNL20
-	struct nl_sock *nl_handle;
-#else
-	struct nl_handle *nl_handle;
+#ifndef CONFIG_LIBNL20
+#  define nl_sock nl_handle
 #endif
+
+struct nl80211_state {
+	struct nl_sock *nl_sock;
 	struct nl_cache *nl_cache;
 	struct genl_family *nl80211;
 };
@@ -67,6 +67,6 @@ const char *iftype_name(enum nl80211_iftype iftype);
 int ieee80211_channel_to_frequency(int chan);
 int ieee80211_frequency_to_channel(int freq);

-int nl_get_multicast_id(struct nl_handle *handle, const char *family,
const char *group);
+int nl_get_multicast_id(struct nl_sock *sock, const char *family, const
char *group);

 #endif /* __IW_H */


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

* Re: [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0
  2009-01-28 23:10 pat-lkml
@ 2009-01-28 23:11 ` pat-lkml
  0 siblings, 0 replies; 6+ messages in thread
From: pat-lkml @ 2009-01-28 23:11 UTC (permalink / raw)
  To: linux-wireless

Oops, this patch is the crda one I was about to send... teach me to pay
attention.

Pat Erley

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

* Re: [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0
  2009-01-28 23:11 [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0 pat-lkml
@ 2009-01-29  0:04 ` Johannes Berg
  2009-01-29  0:15   ` pat-lkml
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2009-01-29  0:04 UTC (permalink / raw)
  To: pat-lkml; +Cc: linux-wireless

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

On Wed, 2009-01-28 at 18:11 -0500, pat-lkml wrote:
> Upstream has renamed nl_handle to nl_sock.  Update iw to the new names
> and add #define for libnl-1.1.

I fixed this already, no?

And renaming nl_handle to nl_sock means that it won't work with older,
released libs, afaict.

johannes

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

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

* Re: [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0
  2009-01-29  0:04 ` Johannes Berg
@ 2009-01-29  0:15   ` pat-lkml
  2009-01-29  0:18     ` pat-lkml
  0 siblings, 1 reply; 6+ messages in thread
From: pat-lkml @ 2009-01-29  0:15 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

Johannes Berg wrote:
> On Wed, 2009-01-28 at 18:11 -0500, pat-lkml wrote:
>> Upstream has renamed nl_handle to nl_sock.  Update iw to the new names
>> and add #define for libnl-1.1.
> 
> I fixed this already, no?
> 
> And renaming nl_handle to nl_sock means that it won't work with older,
> released libs, afaict.
> 
> johannes
Unless my build chain is major league broken, it doesn't build for my
system without doing this.

Lots of these warnings:


In file included from info.c:11:
iw.h:70: warning: 'struct nl_handle' declared inside parameter list
iw.h:70: warning: its scope is only this definition or declaration,
which is probably not what you want

and this error/warning combo that finally fails:

CC   genl.o
In file included from genl.c:12:
iw.h:70: warning: 'struct nl_handle' declared inside parameter list
iw.h:70: warning: its scope is only this definition or declaration,
which is probably not what you want
genl.c:67: warning: 'struct nl_handle' declared inside parameter list
genl.c:68: error: conflicting types for 'nl_get_multicast_id'
iw.h:70: error: previous declaration of 'nl_get_multicast_id' was here
genl.c: In function 'nl_get_multicast_id':
genl.c:87: warning: passing argument 1 of 'genl_ctrl_resolve' from
incompatible pointer type
genl.c:95: warning: passing argument 1 of 'nl_send_auto_complete' from
incompatible pointer type
genl.c:106: warning: passing argument 1 of 'nl_recvmsgs' from
incompatible pointer type
make: *** [genl.o] Error 1

After this patch, it compiles cleanly.  I'll revert to libnl-1.1
quickly, but I believe that it will work fine with this patch as well.

Pat

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

* Re: [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0
  2009-01-29  0:15   ` pat-lkml
@ 2009-01-29  0:18     ` pat-lkml
  0 siblings, 0 replies; 6+ messages in thread
From: pat-lkml @ 2009-01-29  0:18 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

pat-lkml wrote:
> Johannes Berg wrote:
>> On Wed, 2009-01-28 at 18:11 -0500, pat-lkml wrote:
>>> Upstream has renamed nl_handle to nl_sock.  Update iw to the new names
>>> and add #define for libnl-1.1.
>> I fixed this already, no?
>>
>> And renaming nl_handle to nl_sock means that it won't work with older,
>> released libs, afaict.
>>
>> johannes
> Unless my build chain is major league broken, it doesn't build for my
> system without doing this.
> 
> Lots of these warnings:
> 
> 
> In file included from info.c:11:
> iw.h:70: warning: 'struct nl_handle' declared inside parameter list
> iw.h:70: warning: its scope is only this definition or declaration,
> which is probably not what you want
> 
> and this error/warning combo that finally fails:
> 
> CC   genl.o
> In file included from genl.c:12:
> iw.h:70: warning: 'struct nl_handle' declared inside parameter list
> iw.h:70: warning: its scope is only this definition or declaration,
> which is probably not what you want
> genl.c:67: warning: 'struct nl_handle' declared inside parameter list
> genl.c:68: error: conflicting types for 'nl_get_multicast_id'
> iw.h:70: error: previous declaration of 'nl_get_multicast_id' was here
> genl.c: In function 'nl_get_multicast_id':
> genl.c:87: warning: passing argument 1 of 'genl_ctrl_resolve' from
> incompatible pointer type
> genl.c:95: warning: passing argument 1 of 'nl_send_auto_complete' from
> incompatible pointer type
> genl.c:106: warning: passing argument 1 of 'nl_recvmsgs' from
> incompatible pointer type
> make: *** [genl.o] Error 1
> 
> After this patch, it compiles cleanly.  I'll revert to libnl-1.1
> quickly, but I believe that it will work fine with this patch as well.
> 
Yep, builds cleanly and works for me with libnl-1.1 as well.

Pat

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

end of thread, other threads:[~2009-01-29  0:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 23:11 [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0 pat-lkml
2009-01-29  0:04 ` Johannes Berg
2009-01-29  0:15   ` pat-lkml
2009-01-29  0:18     ` pat-lkml
  -- strict thread matches above, loose matches on Subject: below --
2009-01-28 23:10 pat-lkml
2009-01-28 23:11 ` pat-lkml

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