summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen-ichirou MATSUZAWA <chamaken@gmail.com>2015-09-11 16:57:37 +0900
committerTobias Klauser <tklauser@distanz.ch>2015-09-15 10:47:37 +0200
commit67728607d5144cd36d056c4289c7e53f9113329a (patch)
tree7d259435a6dbde4ca70bb083df9705527117795f
parent4669e7a1ac2112b0e9ba7c0b865fdedffbb86055 (diff)
netsniff-ng: nlmsg: update pull size
It would be better to use NLMSG_HDRLEN instead of sizeof(*hdr) and not to use NLMSG_PAYLOAD to get payload length, I think. Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--proto_nlmsg.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/proto_nlmsg.c b/proto_nlmsg.c
index 1dde5e1..76253ca 100644
--- a/proto_nlmsg.c
+++ b/proto_nlmsg.c
@@ -750,15 +750,15 @@ static void nlmsg_print(uint16_t family, struct nlmsghdr *hdr)
static void nlmsg(struct pkt_buff *pkt)
{
- struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, sizeof(*hdr));
+ struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, NLMSG_HDRLEN);
while (hdr) {
nlmsg_print(ntohs(pkt->sll->sll_protocol), hdr);
- if (!pkt_pull(pkt, NLMSG_PAYLOAD(hdr, 0)))
+ if (!pkt_pull(pkt, NLMSG_ALIGN(hdr->nlmsg_len) - NLMSG_HDRLEN))
break;
- hdr = (struct nlmsghdr *) pkt_pull(pkt, sizeof(*hdr));
+ hdr = (struct nlmsghdr *) pkt_pull(pkt, NLMSG_HDRLEN);
if (hdr && hdr->nlmsg_type != NLMSG_DONE &&
(hdr->nlmsg_flags & NLM_F_MULTI))
tprintf("\n");
@@ -767,7 +767,7 @@ static void nlmsg(struct pkt_buff *pkt)
static void nlmsg_less(struct pkt_buff *pkt)
{
- struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, sizeof(*hdr));
+ struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, NLMSG_HDRLEN);
uint16_t family = ntohs(pkt->sll->sll_protocol);
char type[32];