aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/genetlink.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-12-05 09:37:56 -0500
committerDavid Howells <dhowells@warthog.cambridge.redhat.com>2006-12-05 09:37:56 -0500
commit4c1ac1b49122b805adfa4efc620592f68dccf5db (patch)
tree87557f4bc2fd4fe65b7570489c2f610c45c0adcd /include/net/genetlink.h
parentc4028958b6ecad064b1a6303a6a5906d4fe48d73 (diff)
parentd916faace3efc0bf19fe9a615a1ab8fa1a24cd93 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/infiniband/core/iwcm.c drivers/net/chelsio/cxgb2.c drivers/net/wireless/bcm43xx/bcm43xx_main.c drivers/net/wireless/prism54/islpci_eth.c drivers/usb/core/hub.h drivers/usb/input/hid-core.c net/core/netpoll.c Fix up merge failures with Linus's head and fix new compilation failures. Signed-Off-By: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/net/genetlink.h')
-rw-r--r--include/net/genetlink.h54
1 files changed, 47 insertions, 7 deletions
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index b619314218a6..adff4c898d50 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -53,6 +53,7 @@ struct genl_info
53 * @policy: attribute validation policy 53 * @policy: attribute validation policy
54 * @doit: standard command callback 54 * @doit: standard command callback
55 * @dumpit: callback for dumpers 55 * @dumpit: callback for dumpers
56 * @done: completion callback for dumps
56 * @ops_list: operations list 57 * @ops_list: operations list
57 */ 58 */
58struct genl_ops 59struct genl_ops
@@ -64,6 +65,7 @@ struct genl_ops
64 struct genl_info *info); 65 struct genl_info *info);
65 int (*dumpit)(struct sk_buff *skb, 66 int (*dumpit)(struct sk_buff *skb,
66 struct netlink_callback *cb); 67 struct netlink_callback *cb);
68 int (*done)(struct netlink_callback *cb);
67 struct list_head ops_list; 69 struct list_head ops_list;
68}; 70};
69 71
@@ -79,34 +81,51 @@ extern struct sock *genl_sock;
79 * @skb: socket buffer holding the message 81 * @skb: socket buffer holding the message
80 * @pid: netlink pid the message is addressed to 82 * @pid: netlink pid the message is addressed to
81 * @seq: sequence number (usually the one of the sender) 83 * @seq: sequence number (usually the one of the sender)
82 * @type: netlink message type 84 * @family: generic netlink family
83 * @hdrlen: length of the user specific header
84 * @flags netlink message flags 85 * @flags netlink message flags
85 * @cmd: generic netlink command 86 * @cmd: generic netlink command
86 * @version: version
87 * 87 *
88 * Returns pointer to user specific header 88 * Returns pointer to user specific header
89 */ 89 */
90static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, 90static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
91 int type, int hdrlen, int flags, 91 struct genl_family *family, int flags, u8 cmd)
92 u8 cmd, u8 version)
93{ 92{
94 struct nlmsghdr *nlh; 93 struct nlmsghdr *nlh;
95 struct genlmsghdr *hdr; 94 struct genlmsghdr *hdr;
96 95
97 nlh = nlmsg_put(skb, pid, seq, type, GENL_HDRLEN + hdrlen, flags); 96 nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN +
97 family->hdrsize, flags);
98 if (nlh == NULL) 98 if (nlh == NULL)
99 return NULL; 99 return NULL;
100 100
101 hdr = nlmsg_data(nlh); 101 hdr = nlmsg_data(nlh);
102 hdr->cmd = cmd; 102 hdr->cmd = cmd;
103 hdr->version = version; 103 hdr->version = family->version;
104 hdr->reserved = 0; 104 hdr->reserved = 0;
105 105
106 return (char *) hdr + GENL_HDRLEN; 106 return (char *) hdr + GENL_HDRLEN;
107} 107}
108 108
109/** 109/**
110 * genlmsg_put_reply - Add generic netlink header to a reply message
111 * @skb: socket buffer holding the message
112 * @info: receiver info
113 * @family: generic netlink family
114 * @flags: netlink message flags
115 * @cmd: generic netlink command
116 *
117 * Returns pointer to user specific header
118 */
119static inline void *genlmsg_put_reply(struct sk_buff *skb,
120 struct genl_info *info,
121 struct genl_family *family,
122 int flags, u8 cmd)
123{
124 return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
125 flags, cmd);
126}
127
128/**
110 * genlmsg_end - Finalize a generic netlink message 129 * genlmsg_end - Finalize a generic netlink message
111 * @skb: socket buffer the message is stored in 130 * @skb: socket buffer the message is stored in
112 * @hdr: user specific header 131 * @hdr: user specific header
@@ -150,6 +169,16 @@ static inline int genlmsg_unicast(struct sk_buff *skb, u32 pid)
150} 169}
151 170
152/** 171/**
172 * genlmsg_reply - reply to a request
173 * @skb: netlink message to be sent back
174 * @info: receiver information
175 */
176static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
177{
178 return genlmsg_unicast(skb, info->snd_pid);
179}
180
181/**
153 * gennlmsg_data - head of message payload 182 * gennlmsg_data - head of message payload
154 * @gnlh: genetlink messsage header 183 * @gnlh: genetlink messsage header
155 */ 184 */
@@ -187,4 +216,15 @@ static inline int genlmsg_total_size(int payload)
187 return NLMSG_ALIGN(genlmsg_msg_size(payload)); 216 return NLMSG_ALIGN(genlmsg_msg_size(payload));
188} 217}
189 218
219/**
220 * genlmsg_new - Allocate a new generic netlink message
221 * @payload: size of the message payload
222 * @flags: the type of memory to allocate.
223 */
224static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
225{
226 return nlmsg_new(genlmsg_total_size(payload), flags);
227}
228
229
190#endif /* __NET_GENERIC_NETLINK_H */ 230#endif /* __NET_GENERIC_NETLINK_H */