Adding a whack_attribute class which manages in-memory pools in pluto and is very...
[strongswan.git] / src / pluto / whack_attribute.h
1 /*
2 * Copyright (C) 2010 Tobias Brunner
3 * 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 /**
17 * @defgroup whack_attribute
18 * @{ @ingroup pluto
19 */
20
21 #ifndef WHACK_ATTRIBUTE_H_
22 #define WHACK_ATTRIBUTE_H_
23
24 #include <whack.h>
25 #include <attributes/attribute_provider.h>
26
27 typedef struct whack_attribute_t whack_attribute_t;
28
29 /**
30 * Whack attribute provider (basically an in-memory IP address pool)
31 */
32 struct whack_attribute_t {
33
34 /**
35 * Implements attribute provider interface
36 */
37 attribute_provider_t provider;
38
39 /**
40 * Add a virtual IP address pool.
41 *
42 * @param name name of the pool
43 * @param right "right" end of whack message
44 * @return TRUE, if the pool was successfully added
45 */
46 bool (*add_pool)(whack_attribute_t *this, const char *name,
47 const whack_end_t *right);
48
49 /**
50 * Remove a virtual IP address pool.
51 *
52 * @param name name of the pool
53 */
54 void (*del_pool)(whack_attribute_t *this, char *name);
55
56 /**
57 * Create an enumerator over installed pools.
58 *
59 * Enumerator enumerates over
60 * char *pool, u_int size, u_int offline, u_int online.
61 *
62 * @return enumerator
63 */
64 enumerator_t* (*create_pool_enumerator)(whack_attribute_t *this);
65
66 /**
67 * Create an enumerator over the leases of a pool.
68 *
69 * Enumerator enumerates over
70 * identification_t *id, host_t *address, bool online
71 *
72 * @param name name of the pool to enumerate
73 * @return enumerator, NULL if pool not found
74 */
75 enumerator_t* (*create_lease_enumerator)(whack_attribute_t *this,
76 char *name);
77 };
78
79 /**
80 * Global object to manage pools. Set between calls to
81 * whack_attribute_initialize() and whack_attribute_finalize().
82 */
83 extern whack_attribute_t *whack_attr;
84
85 /**
86 * Initialize the whack attribute provider
87 */
88 void whack_attribute_initialize();
89
90 /**
91 * Finalize the whack attribute provider
92 */
93 void whack_attribute_finalize();
94
95 #endif /** WHACK_ATTRIBUTE_H_ @}*/