2 * Copyright (C) 2010 Martin Willi
4 * Copyright (C) secunet Security Networks AG
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 #include "addrblock_plugin.h"
20 #include <plugins/plugin_feature.h>
22 #include "addrblock_validator.h"
23 #include "addrblock_narrow.h"
25 typedef struct private_addrblock_plugin_t private_addrblock_plugin_t
;
28 * private data of addrblock_plugin
30 struct private_addrblock_plugin_t
{
35 addrblock_plugin_t
public;
38 * Validator implementation instance.
40 addrblock_validator_t
*validator
;
43 * Listener to check TS list
45 addrblock_narrow_t
*narrower
;
48 METHOD(plugin_t
, get_name
, char*,
49 private_addrblock_plugin_t
*this)
57 static bool plugin_cb(private_addrblock_plugin_t
*this,
58 plugin_feature_t
*feature
, bool reg
, void *cb_data
)
62 lib
->credmgr
->add_validator(lib
->credmgr
, &this->validator
->validator
);
63 charon
->bus
->add_listener(charon
->bus
, &this->narrower
->listener
);
67 charon
->bus
->remove_listener(charon
->bus
, &this->narrower
->listener
);
68 lib
->credmgr
->remove_validator(lib
->credmgr
,
69 &this->validator
->validator
);
74 METHOD(plugin_t
, get_features
, int,
75 private_addrblock_plugin_t
*this, plugin_feature_t
*features
[])
77 static plugin_feature_t f
[] = {
78 PLUGIN_CALLBACK((plugin_feature_callback_t
)plugin_cb
, NULL
),
79 PLUGIN_PROVIDE(CUSTOM
, "addrblock"),
80 PLUGIN_SDEPEND(CERT_DECODE
, CERT_X509
),
86 METHOD(plugin_t
, destroy
, void,
87 private_addrblock_plugin_t
*this)
89 this->narrower
->destroy(this->narrower
);
90 this->validator
->destroy(this->validator
);
97 plugin_t
*addrblock_plugin_create()
99 private_addrblock_plugin_t
*this;
104 .get_name
= _get_name
,
105 .get_features
= _get_features
,
109 .validator
= addrblock_validator_create(),
110 .narrower
= addrblock_narrow_create(),
113 return &this->public.plugin
;