[PATCH 1/2] utils: add nl_get_capabilities() function

Thomas Haller thaller at redhat.com
Thu Feb 20 12:12:29 EST 2014


Signed-off-by: Thomas Haller <thaller at redhat.com>
---
 include/netlink/utils.h |  8 ++++++++
 lib/utils.c             | 22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/include/netlink/utils.h b/include/netlink/utils.h
index 502341a..3c1c460 100644
--- a/include/netlink/utils.h
+++ b/include/netlink/utils.h
@@ -79,6 +79,14 @@ extern void	nl_new_line(struct nl_dump_params *);
 extern void	nl_dump(struct nl_dump_params *, const char *, ...);
 extern void	nl_dump_line(struct nl_dump_params *, const char *, ...);
 
+enum {
+	NL_CAPABILITY_NONE,
+
+	__NL_CAPABILITY_MAX
+#define NL_CAPABILITY_MAX                               (__NL_CAPABILITY_MAX - 1)
+};
+const int *nl_get_capabilities (void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/utils.c b/lib/utils.c
index 1267e87..3235f60 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1111,6 +1111,28 @@ void dump_from_ops(struct nl_object *obj, struct nl_dump_params *params)
 		obj->ce_ops->oo_dump[type](obj, params);
 }
 
+/**
+ * Returns a list of capabilities that this version of libnl
+ * supports. The capabilities are integer constants with
+ * name NL_CAPABILITY_*.
+ *
+ * This allows users to check at runtime whether the loaded
+ * libnl library supports a predefined set of capabilities.
+ * This is useful so that applications can workaround known issues of
+ * libnl that are fixed in newer library versions, without having a
+ * hard dependency on the new version.
+ *
+ * The array is terminated with 0 (NL_CAPABILITY_NONE) and the
+ * capabilities are sorted ascending.
+ **/
+const int *nl_get_capabilities ()
+{
+	static const int caps[] = {
+		NL_CAPABILITY_NONE
+	};
+	return caps;
+}
+
 /** @endcond */
 
 /** @} */
-- 
1.8.5.3




More information about the libnl mailing list