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