Lines Matching refs:nh
120 static bool checkRtNetlinkLength(const struct nlmsghdr *nh, size_t size) { in checkRtNetlinkLength() argument
121 if (nh->nlmsg_len < NLMSG_LENGTH(size)) { in checkRtNetlinkLength()
122 SLOGE("Got a short %s message\n", rtMessageName(nh->nlmsg_type)); in checkRtNetlinkLength()
144 bool NetlinkEvent::parseIfInfoMessage(const struct nlmsghdr *nh) { in parseIfInfoMessage() argument
145 struct ifinfomsg *ifi = (struct ifinfomsg *) NLMSG_DATA(nh); in parseIfInfoMessage()
146 if (!checkRtNetlinkLength(nh, sizeof(*ifi))) in parseIfInfoMessage()
153 int len = IFLA_PAYLOAD(nh); in parseIfInfoMessage()
178 bool NetlinkEvent::parseIfAddrMessage(const struct nlmsghdr *nh) { in parseIfAddrMessage() argument
179 struct ifaddrmsg *ifaddr = (struct ifaddrmsg *) NLMSG_DATA(nh); in parseIfAddrMessage()
185 if (!checkRtNetlinkLength(nh, sizeof(*ifaddr))) in parseIfAddrMessage()
188 int type = nh->nlmsg_type; in parseIfAddrMessage()
201 int len = IFA_PAYLOAD(nh); in parseIfAddrMessage()
282 bool NetlinkEvent::parseUlogPacketMessage(const struct nlmsghdr *nh) { in parseUlogPacketMessage() argument
284 ulog_packet_msg_t *pm = (ulog_packet_msg_t *) NLMSG_DATA(nh); in parseUlogPacketMessage()
285 if (!checkRtNetlinkLength(nh, sizeof(*pm))) in parseUlogPacketMessage()
311 bool NetlinkEvent::parseNfPacketMessage(struct nlmsghdr *nh) { in parseNfPacketMessage() argument
316 struct nlattr* uid_attr = findNlAttr(nh, sizeof(struct genlmsghdr), NFULA_UID); in parseNfPacketMessage()
321 struct nlattr* payload = findNlAttr(nh, sizeof(struct genlmsghdr), NFULA_PAYLOAD); in parseNfPacketMessage()
347 bool NetlinkEvent::parseRtMessage(const struct nlmsghdr *nh) { in parseRtMessage() argument
348 uint8_t type = nh->nlmsg_type; in parseRtMessage()
356 struct rtmsg *rtm = (struct rtmsg *) NLMSG_DATA(nh); in parseRtMessage()
357 if (!checkRtNetlinkLength(nh, sizeof(*rtm))) in parseRtMessage()
381 size_t len = RTM_PAYLOAD(nh); in parseRtMessage()
439 bool NetlinkEvent::parseNdUserOptMessage(const struct nlmsghdr *nh) { in parseNdUserOptMessage() argument
440 struct nduseroptmsg *msg = (struct nduseroptmsg *) NLMSG_DATA(nh); in parseNdUserOptMessage()
441 if (!checkRtNetlinkLength(nh, sizeof(*msg))) in parseNdUserOptMessage()
445 int len = NLMSG_PAYLOAD(nh, sizeof(*msg)); in parseNdUserOptMessage()
561 struct nlmsghdr *nh; in parseBinaryNetlinkMessage() local
563 for (nh = (struct nlmsghdr *) buffer; in parseBinaryNetlinkMessage()
564 NLMSG_OK(nh, (unsigned) size) && (nh->nlmsg_type != NLMSG_DONE); in parseBinaryNetlinkMessage()
565 nh = NLMSG_NEXT(nh, size)) { in parseBinaryNetlinkMessage()
567 if (!rtMessageName(nh->nlmsg_type)) { in parseBinaryNetlinkMessage()
568 SLOGD("Unexpected netlink message type %d\n", nh->nlmsg_type); in parseBinaryNetlinkMessage()
572 if (nh->nlmsg_type == RTM_NEWLINK) { in parseBinaryNetlinkMessage()
573 if (parseIfInfoMessage(nh)) in parseBinaryNetlinkMessage()
576 } else if (nh->nlmsg_type == LOCAL_QLOG_NL_EVENT) { in parseBinaryNetlinkMessage()
577 if (parseUlogPacketMessage(nh)) in parseBinaryNetlinkMessage()
580 } else if (nh->nlmsg_type == RTM_NEWADDR || in parseBinaryNetlinkMessage()
581 nh->nlmsg_type == RTM_DELADDR) { in parseBinaryNetlinkMessage()
582 if (parseIfAddrMessage(nh)) in parseBinaryNetlinkMessage()
585 } else if (nh->nlmsg_type == RTM_NEWROUTE || in parseBinaryNetlinkMessage()
586 nh->nlmsg_type == RTM_DELROUTE) { in parseBinaryNetlinkMessage()
587 if (parseRtMessage(nh)) in parseBinaryNetlinkMessage()
590 } else if (nh->nlmsg_type == RTM_NEWNDUSEROPT) { in parseBinaryNetlinkMessage()
591 if (parseNdUserOptMessage(nh)) in parseBinaryNetlinkMessage()
594 } else if (nh->nlmsg_type == LOCAL_NFLOG_PACKET) { in parseBinaryNetlinkMessage()
595 if (parseNfPacketMessage(nh)) in parseBinaryNetlinkMessage()
699 nlattr* NetlinkEvent::findNlAttr(const nlmsghdr* nh, size_t hdrlen, uint16_t attr) { in findNlAttr() argument
700 if (nh == nullptr || NLMSG_HDRLEN + NLMSG_ALIGN(hdrlen) > SSIZE_MAX) { in findNlAttr()
706 ssize_t left = nh->nlmsg_len - NLA_START; in findNlAttr()
707 uint8_t* hdr = ((uint8_t*)nh) + NLA_START; in findNlAttr()