summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarkus Trapp <trapp@sn-0000373>2017-02-14 15:33:04 (GMT)
committerThomas Haller <thaller@redhat.com>2017-05-03 10:50:37 (GMT)
commitb9a5a832330fd8cb28bddcc84840f445ad5da3c4 (patch)
tree67446a0dfef57c60b2976fb368e07d294aa5f446 /lib
parent8aca21de41f8875b94e122e5b4d704feb3b30bf5 (diff)
downloadlibnl-b9a5a832330fd8cb28bddcc84840f445ad5da3c4.zip
libnl-b9a5a832330fd8cb28bddcc84840f445ad5da3c4.tar.gz
libnl-b9a5a832330fd8cb28bddcc84840f445ad5da3c4.tar.bz2
route/link: add accessor API for IPv6 flags
Add functions to access the IPv6 specific flags of a link object. Also the functions for IPv6 link flags translation are now exported, similar to the non IPv6 specific translation functions. https://github.com/thom311/libnl/pull/136
Diffstat (limited to 'lib')
-rw-r--r--lib/route/link/inet6.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c
index 3d2668c..e638d06 100644
--- a/lib/route/link/inet6.c
+++ b/lib/route/link/inet6.c
@@ -248,12 +248,17 @@ static const struct trans_tbl inet6_flags[] = {
__ADD(IF_READY, ready),
};
-static char *inet6_flags2str(int flags, char *buf, size_t len)
+char *rtnl_link_inet6_flags2str(int flags, char *buf, size_t len)
{
return __flags2str(flags, buf, len, inet6_flags,
ARRAY_SIZE(inet6_flags));
}
+int rtnl_link_inet6_str2flags(const char *name)
+{
+ return __str2flags(name, inet6_flags, ARRAY_SIZE(inet6_flags));
+}
+
static const struct trans_tbl inet6_devconf[] = {
__ADD(DEVCONF_FORWARDING, forwarding),
__ADD(DEVCONF_HOPLIMIT, hoplimit),
@@ -322,7 +327,7 @@ static void inet6_dump_details(struct rtnl_link *link,
nl_size2str(i6->i6_cacheinfo.max_reasm_len, buf, sizeof(buf)));
nl_dump(p, " <%s>\n",
- inet6_flags2str(i6->i6_flags, buf, sizeof(buf)));
+ rtnl_link_inet6_flags2str(i6->i6_flags, buf, sizeof(buf)));
nl_dump_line(p, " create-stamp %.2fs reachable-time %s",
@@ -535,6 +540,48 @@ static struct rtnl_link_af_ops inet6_ops = {
};
/**
+ * Return IPv6 specific flags
+ * @arg link Link object
+ * @arg out_flags Flags on success
+ *
+ * Returns the link's IPv6 flags.
+ *
+ * @return 0 on success
+ * @return -NLE_NOATTR configuration setting not available
+ */
+int rtnl_link_inet6_get_flags(struct rtnl_link *link, uint32_t* out_flags)
+{
+ struct inet6_data *id = NULL;
+
+ if (!(id = rtnl_link_af_data(link, &inet6_ops)))
+ return -NLE_NOATTR;
+
+ *out_flags = id->i6_flags;
+ return 0;
+}
+
+/**
+ * Set IPv6 specific flags
+ * @arg link Link object
+ * @arg flags Flags to set
+ *
+ * Sets the link's IPv6 specific flags. Overwrites currently set flags.
+ *
+ * @return 0 on success
+ * @return -NLE_NOMEM could not allocate inet6 data
+ */
+int rtnl_link_inet6_set_flags(struct rtnl_link *link, uint32_t flags)
+{
+ struct inet6_data *id;
+
+ if (!(id = rtnl_link_af_alloc(link, &inet6_ops)))
+ return -NLE_NOMEM;
+
+ id->i6_flags = flags;
+ return 0;
+}
+
+/**
* Get IPv6 tokenized interface identifier
* @arg link Link object
* @arg token Tokenized interface identifier on success