2009-01-28 23:11:12

by Pat Erley

[permalink] [raw]
Subject: [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0

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 <[email protected]>
---

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 */



2009-01-29 00:05:25

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0

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


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2009-01-29 00:15:30

by Pat Erley

[permalink] [raw]
Subject: Re: [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0

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

2009-01-29 00:18:57

by Pat Erley

[permalink] [raw]
Subject: Re: [PATCH] iw: rename nl_handle to nl_sock for libnl-2.0

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