Reputation: 15099
I'm trying to get the size of a chunk of data sent via NetLink (Linux Kernel).
I have tried with size = nlh->nlmsg_len - NLMSG_HDRLEN
, but that isn't returning the correct size.
What's the correct way to get the message's data size?
Upvotes: 0
Views: 742
Reputation: 10579
Why would you believe nlh->nlmsg_len - NLMSG_HDRLEN
is not returning the {message size without header} for the message you are looking at? If nlmsg_len contains, for example, the value 16 (that's what NLMSG_HDRLEN should be), then the payload of this message is empty. Your buffer may have more messages in it that want to be read.
As a side note, I recommend you use libmnl for Netlink message parsing and construction.
Upvotes: 2