plugin-feature: Add feature for DNSSEC-enabled resolvers
authorTobias Brunner <tobias@strongswan.org>
Fri, 7 Jun 2013 16:11:46 +0000 (18:11 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 11 Jun 2013 09:18:18 +0000 (11:18 +0200)
src/libstrongswan/plugins/plugin_feature.c
src/libstrongswan/plugins/plugin_feature.h

index 1ee726a..8a1958b 100644 (file)
@@ -50,6 +50,7 @@ ENUM(plugin_feature_names, FEATURE_NONE, FEATURE_CUSTOM,
        "XAUTH_CLIENT",
        "DATABASE",
        "FETCHER",
+       "RESOLVER",
        "CUSTOM",
 );
 
@@ -67,6 +68,7 @@ u_int32_t plugin_feature_hash(plugin_feature_t *feature)
                case FEATURE_NONCE_GEN:
                case FEATURE_DATABASE:
                case FEATURE_FETCHER:
+               case FEATURE_RESOLVER:
                        /* put these special cases in their (type-specific) buckets */
                        data = chunk_empty;
                        break;
@@ -133,6 +135,7 @@ bool plugin_feature_matches(plugin_feature_t *a, plugin_feature_t *b)
                        case FEATURE_RNG:
                                return a->arg.rng_quality <= b->arg.rng_quality;
                        case FEATURE_NONCE_GEN:
+                       case FEATURE_RESOLVER:
                                return TRUE;
                        case FEATURE_PRIVKEY:
                        case FEATURE_PRIVKEY_GEN:
@@ -186,6 +189,7 @@ bool plugin_feature_equals(plugin_feature_t *a, plugin_feature_t *b)
                        case FEATURE_PRF:
                        case FEATURE_DH:
                        case FEATURE_NONCE_GEN:
+                       case FEATURE_RESOLVER:
                        case FEATURE_PRIVKEY:
                        case FEATURE_PRIVKEY_GEN:
                        case FEATURE_PUBKEY:
@@ -285,6 +289,7 @@ char* plugin_feature_get_string(plugin_feature_t *feature)
                        }
                        break;
                case FEATURE_NONCE_GEN:
+               case FEATURE_RESOLVER:
                        if (asprintf(&str, "%N", plugin_feature_names, feature->type) > 0)
                        {
                                return str;
@@ -462,6 +467,9 @@ bool plugin_feature_load(plugin_t *plugin, plugin_feature_t *feature,
                        lib->fetcher->add_fetcher(lib->fetcher, reg->arg.reg.f,
                                                                          feature->arg.fetcher);
                        break;
+               case FEATURE_RESOLVER:
+                       lib->resolver->add_resolver(lib->resolver, reg->arg.reg.f);
+                       break;
                default:
                        break;
        }
@@ -534,6 +542,9 @@ bool plugin_feature_unload(plugin_t *plugin, plugin_feature_t *feature,
                case FEATURE_FETCHER:
                        lib->fetcher->remove_fetcher(lib->fetcher, reg->arg.reg.f);
                        break;
+               case FEATURE_RESOLVER:
+                       lib->resolver->remove_resolver(lib->resolver, reg->arg.reg.f);
+                       break;
                default:
                        break;
        }
index 0f29bf6..00deb38 100644 (file)
@@ -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 } }