From: Balbir Singh Date: Sun, 1 Oct 2006 06:28:51 +0000 (-0700) Subject: [PATCH] Add genetlink utilities for payload length calculation X-Git-Tag: v2.6.19-rc1~538 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17db952cd16cecc76937b138c685ae3d198ab17c;p=platform%2Fupstream%2Fkernel-adaptation-pc.git [PATCH] Add genetlink utilities for payload length calculation Add two utility helper functions genlmsg_msg_size() and genlmsg_total_size(). These functions are derived from their netlink counterparts. Signed-off-by: Balbir Singh Cc: Jamal Hadi Cc: Shailabh Nagar Cc: Thomas Graf Cc: "David S. Miller" Cc: Jay Lan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/net/genetlink.h b/include/net/genetlink.h index 4a38d85..b619314 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h @@ -169,4 +169,22 @@ static inline int genlmsg_len(const struct genlmsghdr *gnlh) return (nlh->nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN); } +/** + * genlmsg_msg_size - length of genetlink message not including padding + * @payload: length of message payload + */ +static inline int genlmsg_msg_size(int payload) +{ + return GENL_HDRLEN + payload; +} + +/** + * genlmsg_total_size - length of genetlink message including padding + * @payload: length of message payload + */ +static inline int genlmsg_total_size(int payload) +{ + return NLMSG_ALIGN(genlmsg_msg_size(payload)); +} + #endif /* __NET_GENERIC_NETLINK_H */