summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/plugin_feature.h
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:26 +0200
committerYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:26 +0200
commit6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349 (patch)
tree009fc492961e13860d2a4bc2de8caf2bbe2975e7 /src/libstrongswan/plugins/plugin_feature.h
parentc83921a2b566aa9d55d8ccc7258f04fca6292ee6 (diff)
downloadvyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.tar.gz
vyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.zip
Imported Upstream version 5.1.0
Diffstat (limited to 'src/libstrongswan/plugins/plugin_feature.h')
-rw-r--r--src/libstrongswan/plugins/plugin_feature.h40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/libstrongswan/plugins/plugin_feature.h b/src/libstrongswan/plugins/plugin_feature.h
index 7667fff3e..ea23f766c 100644
--- a/src/libstrongswan/plugins/plugin_feature.h
+++ b/src/libstrongswan/plugins/plugin_feature.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012-2013 Tobias Brunner
* Hochschule fuer Technik Rapperswil
*
* Copyright (C) 2011 Martin Willi
@@ -150,6 +150,8 @@ struct plugin_feature_t {
FEATURE_DATABASE,
/** fetcher_t */
FEATURE_FETCHER,
+ /** resolver_t */
+ FEATURE_RESOLVER,
/** custom feature, described with a string */
FEATURE_CUSTOM,
} type;
@@ -294,6 +296,7 @@ struct plugin_feature_t {
#define _PLUGIN_FEATURE_EAP_PEER(kind, type) __PLUGIN_FEATURE(kind, EAP_PEER, .eap = type)
#define _PLUGIN_FEATURE_DATABASE(kind, type) __PLUGIN_FEATURE(kind, DATABASE, .database = type)
#define _PLUGIN_FEATURE_FETCHER(kind, type) __PLUGIN_FEATURE(kind, FETCHER, .fetcher = type)
+#define _PLUGIN_FEATURE_RESOLVER(kind, ...) __PLUGIN_FEATURE(kind, RESOLVER, .custom = NULL)
#define _PLUGIN_FEATURE_CUSTOM(kind, name) __PLUGIN_FEATURE(kind, CUSTOM, .custom = name)
#define _PLUGIN_FEATURE_XAUTH_SERVER(kind, name) __PLUGIN_FEATURE(kind, XAUTH_SERVER, .xauth = name)
#define _PLUGIN_FEATURE_XAUTH_PEER(kind, name) __PLUGIN_FEATURE(kind, XAUTH_PEER, .xauth = name)
@@ -317,6 +320,7 @@ struct plugin_feature_t {
#define _PLUGIN_FEATURE_REGISTER_CONTAINER_ENCODE(type, f, final)__PLUGIN_FEATURE_REGISTER_BUILDER(type, f, final)
#define _PLUGIN_FEATURE_REGISTER_DATABASE(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
#define _PLUGIN_FEATURE_REGISTER_FETCHER(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
+#define _PLUGIN_FEATURE_REGISTER_RESOLVER(type, f) __PLUGIN_FEATURE_REGISTER(type, f)
#define _PLUGIN_FEATURE_CALLBACK(_cb, _data) (plugin_feature_t){ FEATURE_CALLBACK, FEATURE_NONE, .arg.cb = { .f = _cb, .data = _data } }
@@ -326,6 +330,27 @@ struct plugin_feature_t {
extern enum_name_t *plugin_feature_names;
/**
+ * Add a set of plugin features to the given array, which must have enough space
+ * to store the added features.
+ *
+ * @param features the array of plugin features to extend
+ * @param to_add the features to add
+ * @param count number of features to add
+ * @param pos current position in the features array, gets advanced
+ */
+static inline void plugin_features_add(plugin_feature_t *features,
+ plugin_feature_t *to_add,
+ int count, int *pos)
+{
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ features[(*pos)++] = to_add[i];
+ }
+}
+
+/**
* Calculates a hash value for the given feature.
*
* Since this is intended to be used with the plugin_features_matches function
@@ -340,6 +365,10 @@ u_int32_t plugin_feature_hash(plugin_feature_t *feature);
/**
* Check if feature a matches to feature b.
*
+ * This is no check for equality. For instance, for FEATURE_RNG a matches b if
+ * a's strength is at least the strength of b. Or for FEATURE_SQL if a is
+ * DB_ANY it will match b if it is of the same type.
+ *
* @param a feature to check
* @param b feature to match against
* @return TRUE if a matches b
@@ -347,6 +376,15 @@ u_int32_t plugin_feature_hash(plugin_feature_t *feature);
bool plugin_feature_matches(plugin_feature_t *a, plugin_feature_t *b);
/**
+ * Check if feature a equals feature b.
+ *
+ * @param a feature
+ * @param b feature to compare
+ * @return TRUE if a equals b
+ */
+bool plugin_feature_equals(plugin_feature_t *a, plugin_feature_t *b);
+
+/**
* Get a string describing feature.
*
* @param feature feature to describe