created tnc-pdp policy decision point plugin
[strongswan.git] / src / libcharon / plugins / tnc_pdp / tnc_pdp_plugin.c
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 * HSR 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
16 #include "tnc_pdp_plugin.h"
17 #include "tnc_pdp.h"
18
19 typedef struct private_tnc_pdp_plugin_t private_tnc_pdp_plugin_t;
20
21 /**
22 * Default RADIUS port, when not configured
23 */
24 #define RADIUS_PORT 1812
25
26 /**
27 * private data of tnc_pdp plugin
28 */
29 struct private_tnc_pdp_plugin_t {
30
31 /**
32 * implements plugin interface
33 */
34 tnc_pdp_plugin_t public;
35
36 /**
37 * Policy Decision Point object
38 */
39 tnc_pdp_t *pdp;
40
41 };
42
43 METHOD(plugin_t, get_name, char*,
44 private_tnc_pdp_plugin_t *this)
45 {
46 return "tnc-pdp";
47 }
48
49 METHOD(plugin_t, get_features, int,
50 private_tnc_pdp_plugin_t *this, plugin_feature_t *features[])
51 {
52 static plugin_feature_t f[] = {
53 PLUGIN_PROVIDE(CUSTOM, "tnc-pdp"),
54 PLUGIN_DEPENDS(CUSTOM, "imv-manager"),
55 };
56 *features = f;
57 return countof(f);
58 }
59
60 METHOD(plugin_t, destroy, void,
61 private_tnc_pdp_plugin_t *this)
62 {
63 DESTROY_IF(this->pdp);
64 free(this);
65 }
66
67 /*
68 * see header file
69 */
70 plugin_t *tnc_pdp_plugin_create()
71 {
72 private_tnc_pdp_plugin_t *this;
73 int port;
74
75 port = lib->settings->get_int(lib->settings,
76 "charon.plugins.tnc_pdp.radius_port", RADIUS_PORT);
77
78 INIT(this,
79 .public = {
80 .plugin = {
81 .get_name = _get_name,
82 .get_features = _get_features,
83 .destroy = _destroy,
84 },
85 },
86 .pdp = tnc_pdp_create(port),
87 );
88
89 return &this->public.plugin;
90 }
91