Add Cisco Unity client support for Split-Include and Local-LAN
[strongswan.git] / src / libcharon / plugins / unity / unity_plugin.c
1 /*
2 * Copyright (C) 2012 Martin Willi
3 * Copyright (C) 2012 revosec AG
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 "unity_plugin.h"
17 #include "unity_handler.h"
18 #include "unity_narrow.h"
19
20 #include <daemon.h>
21 #include <hydra.h>
22
23 typedef struct private_unity_plugin_t private_unity_plugin_t;
24
25 /**
26 * private data of unity_plugin
27 */
28 struct private_unity_plugin_t {
29
30 /**
31 * public functions
32 */
33 unity_plugin_t public;
34
35 /**
36 * Handler for UNITY configuration attributes
37 */
38 unity_handler_t *handler;
39
40 /**
41 * Traffic selector narrower, for Unity Split-Includes
42 */
43 unity_narrow_t *narrower;
44 };
45
46 METHOD(plugin_t, get_name, char*,
47 private_unity_plugin_t *this)
48 {
49 return "unity";
50 }
51
52 METHOD(plugin_t, destroy, void,
53 private_unity_plugin_t *this)
54 {
55 charon->bus->remove_listener(charon->bus, &this->narrower->listener);
56 this->narrower->destroy(this->narrower);
57 hydra->attributes->remove_handler(hydra->attributes, &this->handler->handler);
58 this->handler->destroy(this->handler);
59 free(this);
60 }
61
62 /*
63 * see header file
64 */
65 plugin_t *unity_plugin_create()
66 {
67 private_unity_plugin_t *this;
68
69 INIT(this,
70 .public = {
71 .plugin = {
72 .get_name = _get_name,
73 .reload = (void*)return_false,
74 .destroy = _destroy,
75 },
76 },
77 .handler = unity_handler_create(),
78 );
79 hydra->attributes->add_handler(hydra->attributes, &this->handler->handler);
80
81 this->narrower = unity_narrow_create(this->handler),
82 charon->bus->add_listener(charon->bus, &this->narrower->listener);
83
84 return &this->public.plugin;
85 }