netlink: New function nl_msg_put_unspec_zero().
authorBen Pfaff <blp@nicira.com>
Mon, 7 Oct 2013 21:11:40 +0000 (14:11 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 11 Nov 2013 21:35:06 +0000 (13:35 -0800)
An upcoming commit adds a user.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/netlink.c
lib/netlink.h

index 50444ab..8cf5261 100644 (file)
@@ -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
index afe2277..7c4dbe9 100644 (file)
@@ -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);