nl80211: Fix compilation with libnl 1.1 and 2.0

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>
This commit is contained in:
Jouni Malinen 2015-01-06 18:27:06 +02:00
parent c975e1c1da
commit d58ade2121

View 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);
}