Skip to contentSkip to conversation

iw: rename nl_handle to nl_sock for libnl-2.0

PATCH In review pat-lkml 2 participants 4 messages Jan 28, 2009 – Jan 29, 2009

lore
Share & tools
lore

pat-lkml

author
#0 lore raw

PATCH 1/1 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.

---

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?

genl.c +0 -1
index e99ea9d..6091b97 100644
@@ -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;

iw.c +1 -2
index 117399c..f30da43 100644
@@ -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);

iw.h +5 -6
index 49788e0..7c2ab02 100644
@@ -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 */

#1 lore raw
Quoted 2 lines · pat-lkml

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

author
#2 lore raw
Quoted 10 lines · Johannes Berg
Quoted 2 lines · pat-lkml

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

author
#3 lore raw
Quoted 40 lines · pat-lkml
Quoted 9 lines · Johannes Berg
Quoted 2 lines · pat-lkml

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

Quoted 3 lines

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