From d58ade2121a542165f9b28b3dd8aedf9e4bd7ddb Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 6 Jan 2015 18:27:06 +0200 Subject: [PATCH] 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 --- src/drivers/driver_nl80211.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index efcfd36f9..a3a23794d 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -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); }