]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Fix compilation with libnl 1.1 and 2.0
authorJouni Malinen <j@w1.fi>
Tue, 6 Jan 2015 16:27:06 +0000 (18:27 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 6 Jan 2015 16:30:20 +0000 (18:30 +0200)
Unfortunately, libnl 3.0 has changed the API in a way that is not
backwards compatible by renaming nlmsg_len() to nlmsg_datalen() without
leaving the older nlmsg_len() defined. As such, there does not seem to
be any clean way of using this function without breaking the build with
some libnl versions. For now, replace this call with direct calculation
of the data length since it can be done with a simple one-liner that
compiles with all libnl versions.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/drivers/driver_nl80211.c

index efcfd36f980bfc0f64f122a5a6d0edfb2517f1dd..a3a23794dbd1d0cc26cb48cd1c3978078f49b4e1 100644 (file)
@@ -290,7 +290,13 @@ static void nl80211_nlmsg_clear(struct nl_msg *msg)
        if (msg) {
                struct nlmsghdr *hdr = nlmsg_hdr(msg);
                void *data = nlmsg_data(hdr);
-               int len = nlmsg_datalen(hdr);
+               /*
+                * This would use nlmsg_datalen() or the older nlmsg_len() if
+                * only libnl were to maintain a stable API.. Neither will work
+                * with all released versions, so just calculate the length
+                * here.
+                */
+               int len = hdr->nlmsg_len - NLMSG_HDRLEN;
 
                os_memset(data, 0, len);
        }