diff options
author | Ben Pfaff <blp@nicira.com> | 2013-10-07 14:11:40 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-11-11 13:35:06 -0800 |
commit | 637abcbee958ae92d12231703b5357786e4ec9f1 (patch) | |
tree | f44eab9e46075b22cfe49946f78c732f498932de | |
parent | 8be9fec67a4ab8a9054222674755c0e791d61d8e (diff) | |
download | openvswitch-637abcbee958ae92d12231703b5357786e4ec9f1.tar.gz |
netlink: New function nl_msg_put_unspec_zero().
An upcoming commit adds a user.
Signed-off-by: Ben Pfaff <blp@nicira.com>
-rw-r--r-- | lib/netlink.c | 12 | ||||
-rw-r--r-- | lib/netlink.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/netlink.c b/lib/netlink.c index 50444abd9..8cf526117 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -220,6 +220,18 @@ nl_msg_put_unspec_uninit(struct ofpbuf *msg, uint16_t type, size_t size) return nla + 1; } +/* Appends a Netlink attribute of the given 'type' and room for 'size' bytes of + * data as its payload, plus Netlink padding if needed, to the tail end of + * 'msg', reallocating and copying its data if necessary. Returns a pointer to + * the first byte of data in the attribute, which is zeroed. */ +void * +nl_msg_put_unspec_zero(struct ofpbuf *msg, uint16_t type, size_t size) +{ + void *data = nl_msg_put_unspec_uninit(msg, type, size); + memset(data, 0, size); + return data; +} + /* Appends a Netlink attribute of the given 'type' and the 'size' bytes of * 'data' as its payload, to the tail end of 'msg', reallocating and copying * its data if necessary. Returns a pointer to the first byte of data in the diff --git a/lib/netlink.h b/lib/netlink.h index afe2277ec..7c4dbe91e 100644 --- a/lib/netlink.h +++ b/lib/netlink.h @@ -59,6 +59,7 @@ void *nl_msg_push_uninit(struct ofpbuf *, size_t); /* Appending attributes. */ void *nl_msg_put_unspec_uninit(struct ofpbuf *, uint16_t type, size_t); +void *nl_msg_put_unspec_zero(struct ofpbuf *, uint16_t type, size_t); void nl_msg_put_unspec(struct ofpbuf *, uint16_t type, const void *, size_t); void nl_msg_put_flag(struct ofpbuf *, uint16_t type); void nl_msg_put_u8(struct ofpbuf *, uint16_t type, uint8_t value); |