attribute_manager supports attribute_handler's to handle configuration attributes...
[strongswan.git] / src / charon / plugins / resolv_conf / resolv_conf_plugin.c
1 /*
2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * $Id$
16 */
17
18 #include "resolv_conf_plugin.h"
19 #include "resolv_conf_handler.h"
20
21 #include <daemon.h>
22
23 typedef struct private_resolv_conf_plugin_t private_resolv_conf_plugin_t;
24
25 /**
26 * private data of resolv_conf plugin
27 */
28 struct private_resolv_conf_plugin_t {
29
30 /**
31 * implements plugin interface
32 */
33 resolv_conf_plugin_t public;
34
35 /**
36 * The registerd DNS attribute handler
37 */
38 resolv_conf_handler_t *handler;
39 };
40
41 /**
42 * Implementation of plugin_t.destroy
43 */
44 static void destroy(private_resolv_conf_plugin_t *this)
45 {
46 charon->attributes->remove_handler(charon->attributes,
47 &this->handler->handler);
48 this->handler->destroy(this->handler);
49 free(this);
50 }
51
52 /*
53 * see header file
54 */
55 plugin_t *plugin_create()
56 {
57 private_resolv_conf_plugin_t *this = malloc_thing(private_resolv_conf_plugin_t);
58
59 this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
60
61 this->handler = resolv_conf_handler_create();
62 charon->attributes->add_handler(charon->attributes, &this->handler->handler);
63
64 return &this->public.plugin;
65 }
66