diff options
author | Thomas Graf <tgraf@suug.ch> | 2005-06-19 01:50:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-06-19 01:50:12 -0400 |
commit | f88a10d65620d97b6d0a7e352a3493c1b7e7409b (patch) | |
tree | 8d38311e479d5deb11cfab2c052c83c8b1321132 /include | |
parent | e52c1f17e4ea8e61bd26eb25f1a184202693c2b9 (diff) |
[NETLINK]: New message building macros
NLMSG_PUT_ANSWER(skb, nlcb, type, length)
Start a new netlink message as answer to a request,
returns the message header.
NLMSG_END(skb, nlh)
End a netlink message, fixes total message length,
returns skb->len.
NLMSG_CANCEL(skb, nlh)
Cancel the building process and trim whole message
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netlink.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/include/linux/netlink.h b/include/linux/netlink.h index b2738ac8bc99..8d1cb419a930 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h | |||
@@ -171,8 +171,21 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | #define NLMSG_PUT(skb, pid, seq, type, len) \ | 173 | #define NLMSG_PUT(skb, pid, seq, type, len) \ |
174 | ({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) goto nlmsg_failure; \ | 174 | ({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) \ |
175 | __nlmsg_put(skb, pid, seq, type, len); }) | 175 | goto nlmsg_failure; \ |
176 | __nlmsg_put(skb, pid, seq, type, len); }) | ||
177 | |||
178 | #define NLMSG_PUT_ANSWER(skb, cb, type, len) \ | ||
179 | NLMSG_PUT(skb, NETLINK_CB((cb)->skb).pid, \ | ||
180 | (cb)->nlh->nlmsg_seq, type, len) | ||
181 | |||
182 | #define NLMSG_END(skb, nlh) \ | ||
183 | ({ (nlh)->nlmsg_len = (skb)->tail - (unsigned char *) (nlh); \ | ||
184 | (skb)->len; }) | ||
185 | |||
186 | #define NLMSG_CANCEL(skb, nlh) \ | ||
187 | ({ skb_trim(skb, (unsigned char *) (nlh) - (skb)->data); \ | ||
188 | -1; }) | ||
176 | 189 | ||
177 | extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, | 190 | extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, |
178 | struct nlmsghdr *nlh, | 191 | struct nlmsghdr *nlh, |