Add features support to tnccs plugins
[strongswan.git] / src / libcharon / tnc / tnccs / tnccs.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 #define USE_TNC
17
18 #include "tnccs.h"
19
20 #include <daemon.h>
21
22
23 ENUM(tnccs_type_names, TNCCS_UNKNOWN, TNCCS_2_0,
24 "unknown TNCCS",
25 "TNCCS 1.1",
26 "TNCCS SOH",
27 "TNCCS 2.0",
28 );
29
30 /**
31 * See header
32 */
33 bool tnccs_method_register(plugin_t *plugin, plugin_feature_t *feature,
34 bool reg, void *data)
35 {
36 if (reg)
37 {
38 if (feature->type == FEATURE_CUSTOM)
39 {
40 tnccs_type_t type = TNCCS_UNKNOWN;
41
42 if (streq(feature->arg.custom, "tnccs-2.0"))
43 {
44 type = TNCCS_2_0;
45 }
46 else if (streq(feature->arg.custom, "tnccs-1.1"))
47 {
48 type = TNCCS_1_1;
49 }
50 else if (streq(feature->arg.custom, "tnccs-dynamic"))
51 {
52 type = TNCCS_DYNAMIC;
53 }
54 else
55 {
56 return FALSE;
57 }
58 charon->tnccs->add_method(charon->tnccs, type,
59 (tnccs_constructor_t)data);
60 }
61 }
62 else
63 {
64 charon->tnccs->remove_method(charon->tnccs, (tnccs_constructor_t)data);
65 }
66 return TRUE;
67 }