From 67728607d5144cd36d056c4289c7e53f9113329a Mon Sep 17 00:00:00 2001 From: Ken-ichirou MATSUZAWA Date: Fri, 11 Sep 2015 16:57:37 +0900 Subject: 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 Signed-off-by: Tobias Klauser --- proto_nlmsg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'proto_nlmsg.c') 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]; -- cgit v1.2.3-54-g00ecf