summaryrefslogtreecommitdiffstats
path: root/modules/cookies
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2019-03-14 13:09:48 +0100
committerTomas Krizek <tomas.krizek@nic.cz>2019-04-17 18:44:29 +0200
commit176b1c282a54b2547b5795238120e842fcaeb6bd (patch)
tree984a4d1a1b9f347ee6daf344d8dd2a1d13ee0d74 /modules/cookies
parentMerge branch 'dnstap-turris' into 'master' (diff)
downloadknot-resolver-176b1c282a54b2547b5795238120e842fcaeb6bd.tar.xz
knot-resolver-176b1c282a54b2547b5795238120e842fcaeb6bd.zip
module API+ABI: remove one level of indirection
... for layers and props. This breaks C module API+ABI. It seemed weird to repeatedly call a function that returns a pointer to a structure in which we find the function we want to actually call. We've never used changing these functions AFAIK, and the target functions could easily be written to change their behavior instead (i.e. move the indirection *inside* the function). When breaking this, I also removed these two (_layers and _props) from the dynamic symbols (to be) exported from the C modules. They always pointed to memory belonging inside the module, and they seem quite sensible to be set up by the _init symbol instead.
Diffstat (limited to 'modules/cookies')
-rw-r--r--modules/cookies/cookies.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/modules/cookies/cookies.c b/modules/cookies/cookies.c
index 6a1db4f2..c7a350c3 100644
--- a/modules/cookies/cookies.c
+++ b/modules/cookies/cookies.c
@@ -47,6 +47,22 @@ static char *cookies_config(void *env, struct kr_module *module,
KR_EXPORT
int cookies_init(struct kr_module *module)
{
+ /* The function answer_finalize() in resolver is called before any
+ * .finish callback. Therefore this layer does not use it. */
+ static kr_layer_api_t layer = {
+ .begin = &check_request,
+ .consume = &check_response
+ };
+ /* Store module reference */
+ layer.data = module;
+ module->layer = &layer;
+
+ static const struct kr_prop props[] = {
+ { &cookies_config, "config", "Empty value to return current configuration.", },
+ { NULL, NULL, NULL }
+ };
+ module->props = props;
+
struct engine *engine = module->data;
struct kr_cookie_ctx *cookie_ctx = &engine->resolver.cookie_ctx;
@@ -72,29 +88,4 @@ int cookies_deinit(struct kr_module *module)
return kr_ok();
}
-KR_EXPORT
-const kr_layer_api_t *cookies_layer(struct kr_module *module)
-{
- /* The function answer_finalize() in resolver is called before any
- * .finish callback. Therefore this layer does not use it. */
-
- static kr_layer_api_t _layer = {
- .begin = &check_request,
- .consume = &check_response
- };
- /* Store module reference */
- _layer.data = module;
- return &_layer;
-}
-
-KR_EXPORT
-struct kr_prop *cookies_props(void)
-{
- static struct kr_prop prop_list[] = {
- { &cookies_config, "config", "Empty value to return current configuration.", },
- { NULL, NULL, NULL }
- };
- return prop_list;
-}
-
KR_MODULE_EXPORT(cookies)