aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/netlink.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-12-18 15:22:35 (GMT)
committerJouni Malinen <j@w1.fi>2009-12-18 15:22:35 (GMT)
commitf37cf89ccb4f9c8a74ba8979f60bf3979f44d87e (patch)
tree2d0857f693fca23ef8793c8bd8066aaf49da594b /src/drivers/netlink.c
parent08063178fb48e2ee2f46b345326890ac295e2cfa (diff)
downloadhostap-f37cf89ccb4f9c8a74ba8979f60bf3979f44d87e.zip
hostap-f37cf89ccb4f9c8a74ba8979f60bf3979f44d87e.tar.gz
hostap-f37cf89ccb4f9c8a74ba8979f60bf3979f44d87e.tar.bz2
netlink: Use NLMSG_OK and NLMSG_NEXT macros
Diffstat (limited to 'src/drivers/netlink.c')
-rw-r--r--src/drivers/netlink.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/drivers/netlink.c b/src/drivers/netlink.c
index 5e61183..a788e0b 100644
--- a/src/drivers/netlink.c
+++ b/src/drivers/netlink.c
@@ -48,17 +48,10 @@ try_again:
}
h = (struct nlmsghdr *) buf;
- while (left >= (int) sizeof(*h)) {
- int len, plen;
-
- len = h->nlmsg_len;
- plen = len - sizeof(*h);
- if (len > left || plen < 0) {
- wpa_printf(MSG_DEBUG, "netlnk: Malformed message: "
- "len=%d left=%d plen=%d",
- len, left, plen);
- break;
- }
+ while (NLMSG_OK(h, left)) {
+ int plen;
+
+ plen = h->nlmsg_len - sizeof(*h);
switch (h->nlmsg_type) {
case RTM_NEWLINK:
@@ -73,9 +66,7 @@ try_again:
break;
}
- len = NLMSG_ALIGN(len);
- left -= len;
- h = (struct nlmsghdr *) ((char *) h + len);
+ h = NLMSG_NEXT(h, left);
}
if (left > 0) {