summaryrefslogtreecommitdiff
path: root/lib/netlink.c
diff options
context:
space:
mode:
authorJiri Benc <jbenc@redhat.com>2015-09-29 19:10:55 -0300
committerBen Pfaff <blp@nicira.com>2015-10-05 11:16:21 -0700
commit1b186808e4e2940c56e3d5738b1a3c727fa5d0ed (patch)
tree6c7cee85ca807b71034c434ec692c35de71aa8fa /lib/netlink.c
parent8c46162bb41c27c86523f59e6d0cbf91ea42b5d6 (diff)
downloadopenvswitch-1b186808e4e2940c56e3d5738b1a3c727fa5d0ed.tar.gz
netlink: helper functions for ipv6 address in netlink attrs
[cascardo: add NL_A_IPV6, used in next patch] Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/netlink.c')
-rw-r--r--lib/netlink.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/netlink.c b/lib/netlink.c
index 09723b24d..6bb353719 100644
--- a/lib/netlink.c
+++ b/lib/netlink.c
@@ -308,6 +308,15 @@ nl_msg_put_be64(struct ofpbuf *msg, uint16_t type, ovs_be64 value)
nl_msg_put_unspec(msg, type, &value, sizeof value);
}
+/* Appends a Netlink attribute of the given 'type' and the given IPv6
+ * address order 'value' to 'msg'. */
+void
+nl_msg_put_in6_addr(struct ofpbuf *msg, uint16_t type,
+ const struct in6_addr *value)
+{
+ nl_msg_put_unspec(msg, type, value, sizeof *value);
+}
+
/* Appends a Netlink attribute of the given 'type' and the given odp_port_t
* 'value' to 'msg'. */
void
@@ -603,6 +612,15 @@ nl_attr_get_be64(const struct nlattr *nla)
return get_32aligned_be64(x);
}
+/* Returns the IPv6 address value in 'nla''s payload.
+ *
+ * Asserts that 'nla''s payload is at least 16 bytes long. */
+struct in6_addr
+nl_attr_get_in6_addr(const struct nlattr *nla)
+{
+ return NL_ATTR_GET_AS(nla, struct in6_addr);
+}
+
/* Returns the 32-bit odp_port_t value in 'nla''s payload.
*
* Asserts that 'nla''s payload is at least 4 bytes long. */
@@ -643,6 +661,7 @@ min_attr_len(enum nl_attr_type type)
case NL_A_U64: return 8;
case NL_A_STRING: return 1;
case NL_A_FLAG: return 0;
+ case NL_A_IPV6: return 16;
case NL_A_NESTED: return 0;
case N_NL_ATTR_TYPES: default: OVS_NOT_REACHED();
}
@@ -661,6 +680,7 @@ max_attr_len(enum nl_attr_type type)
case NL_A_U64: return 8;
case NL_A_STRING: return SIZE_MAX;
case NL_A_FLAG: return SIZE_MAX;
+ case NL_A_IPV6: return 16;
case NL_A_NESTED: return SIZE_MAX;
case N_NL_ATTR_TYPES: default: OVS_NOT_REACHED();
}