aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-11-14 22:46:02 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:22:42 -0500
commit17c157c889f4b07258af6bfec9e4e9dcf3c00178 (patch)
treef17be049a40b5742ca7e67094d6a7063146568d5 /include
parent81878d27fdd297a33f3cfcf29483fe1abaf26dec (diff)
[GENL]: Add genlmsg_put_reply() to simplify building reply headers
By modyfing genlmsg_put() to take a genl_family and by adding genlmsg_put_reply() the process of constructing the netlink and generic netlink headers is simplified. Signed-off-by: Thomas Graf <tgraf@suug.ch> Acked-by: Paul Moore <paul.moore@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/genetlink.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 797c18b5041f..7fd131c9a8cc 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -79,34 +79,51 @@ extern struct sock *genl_sock;
79 * @skb: socket buffer holding the message 79 * @skb: socket buffer holding the message
80 * @pid: netlink pid the message is addressed to 80 * @pid: netlink pid the message is addressed to
81 * @seq: sequence number (usually the one of the sender) 81 * @seq: sequence number (usually the one of the sender)
82 * @type: netlink message type 82 * @family: generic netlink family
83 * @hdrlen: length of the user specific header
84 * @flags netlink message flags 83 * @flags netlink message flags
85 * @cmd: generic netlink command 84 * @cmd: generic netlink command
86 * @version: version
87 * 85 *
88 * Returns pointer to user specific header 86 * Returns pointer to user specific header
89 */ 87 */
90static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, 88static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
91 int type, int hdrlen, int flags, 89 struct genl_family *family, int flags, u8 cmd)
92 u8 cmd, u8 version)
93{ 90{
94 struct nlmsghdr *nlh; 91 struct nlmsghdr *nlh;
95 struct genlmsghdr *hdr; 92 struct genlmsghdr *hdr;
96 93
97 nlh = nlmsg_put(skb, pid, seq, type, GENL_HDRLEN + hdrlen, flags); 94 nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN +
95 family->hdrsize, flags);
98 if (nlh == NULL) 96 if (nlh == NULL)
99 return NULL; 97 return NULL;
100 98
101 hdr = nlmsg_data(nlh); 99 hdr = nlmsg_data(nlh);
102 hdr->cmd = cmd; 100 hdr->cmd = cmd;
103 hdr->version = version; 101 hdr->version = family->version;
104 hdr->reserved = 0; 102 hdr->reserved = 0;
105 103
106 return (char *) hdr + GENL_HDRLEN; 104 return (char *) hdr + GENL_HDRLEN;
107} 105}
108 106
109/** 107/**
108 * genlmsg_put_reply - Add generic netlink header to a reply message
109 * @skb: socket buffer holding the message
110 * @info: receiver info
111 * @family: generic netlink family
112 * @flags: netlink message flags
113 * @cmd: generic netlink command
114 *
115 * Returns pointer to user specific header
116 */
117static inline void *genlmsg_put_reply(struct sk_buff *skb,
118 struct genl_info *info,
119 struct genl_family *family,
120 int flags, u8 cmd)
121{
122 return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
123 flags, cmd);
124}
125
126/**
110 * genlmsg_end - Finalize a generic netlink message 127 * genlmsg_end - Finalize a generic netlink message
111 * @skb: socket buffer the message is stored in 128 * @skb: socket buffer the message is stored in
112 * @hdr: user specific header 129 * @hdr: user specific header