Add PT-TLS interface to strongSwan PDP
[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 * private data of tnc_pdp plugin
25 */
26 struct private_tnc_pdp_plugin_t {
27
28 /**
29 * implements plugin interface
30 */
31 tnc_pdp_plugin_t public;
32
33 /**
34 * Policy Decision Point object
35 */
36 tnc_pdp_t *pdp;
37
38 };
39
40 METHOD(plugin_t, get_name, char*,
41 private_tnc_pdp_plugin_t *this)
42 {
43 return "tnc-pdp";
44 }
45
46 /**
47 * Register listener
48 */
49 static bool plugin_cb(private_tnc_pdp_plugin_t *this,
50 plugin_feature_t *feature, bool reg, void *cb_data)
51 {
52 if (reg)
53 {
54 this->pdp = tnc_pdp_create();
55 }
56 else
57 {
58 DESTROY_IF(this->pdp);
59 }
60 return TRUE;
61 }
62
63 METHOD(plugin_t, get_features, int,
64 private_tnc_pdp_plugin_t *this, plugin_feature_t *features[])
65 {
66 static plugin_feature_t f[] = {
67 PLUGIN_CALLBACK((plugin_feature_callback_t)plugin_cb, NULL),
68 PLUGIN_PROVIDE(CUSTOM, "tnc-pdp"),
69 PLUGIN_DEPENDS(CUSTOM, "imv-manager"),
70 PLUGIN_DEPENDS(HASHER, HASH_MD5),
71 PLUGIN_DEPENDS(SIGNER, AUTH_HMAC_MD5_128),
72 PLUGIN_DEPENDS(NONCE_GEN),
73 };
74 *features = f;
75 return countof(f);
76 }
77
78 METHOD(plugin_t, destroy, void,
79 private_tnc_pdp_plugin_t *this)
80 {
81 free(this);
82 }
83
84 /*
85 * see header file
86 */
87 plugin_t *tnc_pdp_plugin_create()
88 {
89 private_tnc_pdp_plugin_t *this;
90
91 INIT(this,
92 .public = {
93 .plugin = {
94 .get_name = _get_name,
95 .get_features = _get_features,
96 .destroy = _destroy,
97 },
98 },
99 );
100
101 return &this->public.plugin;
102 }
103