fixed cert_validator_t:validate interface
[strongswan.git] / src / libcharon / plugins / addrblock / addrblock_plugin.c
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
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
16 #include "addrblock_plugin.h"
17
18 #include <daemon.h>
19
20 #include "addrblock_validator.h"
21 #include "addrblock_narrow.h"
22
23 typedef struct private_addrblock_plugin_t private_addrblock_plugin_t;
24
25 /**
26 * private data of addrblock_plugin
27 */
28 struct private_addrblock_plugin_t {
29
30 /**
31 * public functions
32 */
33 addrblock_plugin_t public;
34
35 /**
36 * Validator implementation instance.
37 */
38 addrblock_validator_t *validator;
39
40 /**
41 * Listener to check TS list
42 */
43 addrblock_narrow_t *narrower;
44 };
45
46 METHOD(plugin_t, destroy, void,
47 private_addrblock_plugin_t *this)
48 {
49 charon->bus->remove_listener(charon->bus, &this->narrower->listener);
50 lib->credmgr->remove_validator(lib->credmgr, &this->validator->validator);
51 this->narrower->destroy(this->narrower);
52 this->validator->destroy(this->validator);
53 free(this);
54 }
55
56 /*
57 * see header file
58 */
59 plugin_t *addrblock_plugin_create()
60 {
61 private_addrblock_plugin_t *this;
62
63 INIT(this,
64 .public = {
65 .plugin = {
66 .destroy = _destroy,
67 },
68 },
69 .validator = addrblock_validator_create(),
70 .narrower = addrblock_narrow_create(),
71 );
72 lib->credmgr->add_validator(lib->credmgr, &this->validator->validator);
73 charon->bus->add_listener(charon->bus, &this->narrower->listener);
74
75 return &this->public.plugin;
76 }