summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroopa <roopa@cumulusnetworks.com>2013-01-17 16:29:03 -0800
committerThomas Graf <tgraf@suug.ch>2013-01-18 14:41:58 +0100
commit99399ca9c07499cfeadf4a24a9b66006d3b48b40 (patch)
tree0de812b930eb5eaf881a67acb6ea9922476aeb16
parent6b4a2cb634701b72eba6c50220611d0787ec4601 (diff)
downloadlibnl-99399ca9c07499cfeadf4a24a9b66006d3b48b40.tar.gz
Add new rtnl_link_af_data_compare function to compare af_data
This patch adds a new api rtnl_linl_af_data_compare to compare link af_data Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
-rw-r--r--include/netlink/route/link/api.h3
-rw-r--r--lib/route/link/api.c32
2 files changed, 35 insertions, 0 deletions
diff --git a/include/netlink/route/link/api.h b/include/netlink/route/link/api.h
index 92a48f7..28f2464 100644
--- a/include/netlink/route/link/api.h
+++ b/include/netlink/route/link/api.h
@@ -142,6 +142,9 @@ extern void * rtnl_link_af_data(const struct rtnl_link *,
const struct rtnl_link_af_ops *);
extern int rtnl_link_af_register(struct rtnl_link_af_ops *);
extern int rtnl_link_af_unregister(struct rtnl_link_af_ops *);
+extern int rtnl_link_af_data_compare(struct rtnl_link *a,
+ struct rtnl_link *b,
+ int family);
#ifdef __cplusplus
}
diff --git a/lib/route/link/api.c b/lib/route/link/api.c
index a12eb09..9387bc5 100644
--- a/lib/route/link/api.c
+++ b/lib/route/link/api.c
@@ -350,6 +350,38 @@ errout:
return err;
}
+/**
+ * Compare af data for a link address family
+ * @arg a Link object a
+ * @arg b Link object b
+ * @arg family af data family
+ *
+ * This function will compare af_data between two links
+ * a and b of family given by arg family
+ *
+ * @return 0 if address family specific data matches or is not present
+ * or != 0 if it mismatches.
+ */
+int rtnl_link_af_data_compare(struct rtnl_link *a, struct rtnl_link *b,
+ int family)
+{
+ struct rtnl_link_af_ops *af_ops = rtnl_link_af_ops_lookup(family);
+
+ if (!af_ops)
+ return ~0;
+
+ if (!a->l_af_data[family] && !b->l_af_data[family])
+ return 0;
+
+ if (!a->l_af_data[family] || !b->l_af_data[family])
+ return ~0;
+
+ if (af_ops->ao_compare)
+ return af_ops->ao_compare(a, b, family, ~0, 0);
+
+ return 0;
+}
+
/** @} */
/** @} */