diff --git a/include/netpacket/netlink.h b/include/netpacket/netlink.h index 24a57efb6e..69553be4aa 100644 --- a/include/netpacket/netlink.h +++ b/include/netpacket/netlink.h @@ -136,6 +136,9 @@ ((n) -= NLMSG_ALIGN((hdr)->nlmsg_len), \ (FAR struct nlmsghdr*) \ (((FAR char*)(hdr)) + NLMSG_ALIGN((hdr)->nlmsg_len))) +#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len <= (len)) #define NLMSG_PAYLOAD(hdr, len) \ ((hdr)->nlmsg_len - NLMSG_SPACE((len)))