- show connection templates in status & statusall
[strongswan.git] / src / charon / config / connections / connection_store.h
1 /**
2 * @file connection_store.h
3 *
4 * @brief Interface connection_store_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2006 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef CONNECTION_STORE_H_
24 #define CONNECTION_STORE_H_
25
26 #include <types.h>
27 #include <config/connections/connection.h>
28 #include <utils/logger.h>
29
30
31 typedef struct connection_store_t connection_store_t;
32
33 /**
34 * @brief The interface for a store of connection_t's.
35 *
36 * @b Constructors:
37 * - stroke_create()
38 *
39 * @ingroup config
40 */
41 struct connection_store_t {
42
43 /**
44 * @brief Returns a connection definition identified by two IDs.
45 *
46 * This call is useful to get a connection which is identified by IDs
47 * rather than addresses, e.g. for connection setup on user request.
48 * The returned connection gets created/cloned and therefore must
49 * be destroyed after usage.
50 *
51 * @param this calling object
52 * @param my_id own ID of connection
53 * @param other_id others ID of connection
54 * @return
55 * - connection_t, if found
56 * - NULL otherwise
57 */
58 connection_t *(*get_connection_by_ids) (connection_store_t *this, identification_t *my_id, identification_t *other_id);
59
60 /**
61 * @brief Returns a connection definition identified by two hosts.
62 *
63 * This call is usefull to get a connection identified by addresses.
64 * It may be used after kernel request for traffic protection.
65 * The returned connection gets created/cloned and therefore must
66 * be destroyed after usage.
67 *
68 * @param this calling object
69 * @param my_id own address of connection
70 * @param other_id others address of connection
71 * @return
72 * - connection_t, if found
73 * - NULL otherwise
74 */
75 connection_t *(*get_connection_by_hosts) (connection_store_t *this, host_t *my_host, host_t *other_host);
76
77 /**
78 * @brief Returns a connection identified by its name.
79 *
80 * This call is usefull to get a connection identified its
81 * name, as on an connection setup.
82 *
83 * @param this calling object
84 * @param name name of the connection to get
85 * @return
86 * - connection_t, if found
87 * - NULL otherwise
88 */
89 connection_t *(*get_connection_by_name) (connection_store_t *this, char *name);
90
91 /**
92 * @brief Add a connection to the store.
93 *
94 * After a successful call, the connection is owned by the store and may
95 * not be manipulated nor destroyed.
96 *
97 * @param this calling object
98 * @param connection connection to add
99 * @return
100 * - SUCCESS, or
101 * - FAILED
102 */
103 status_t (*add_connection) (connection_store_t *this, connection_t *connection);
104
105 /**
106 * @brief Log the connections stored in the store.
107 *
108 * Depending on the implementation of the store, the store
109 * logs various information to the specified logger.
110 * If logger is NULL, the internal logger is used, if name is
111 * NULL, all connections are logged
112 *
113 * @param this calling object
114 * @param logger logger to use for the log, or NULL
115 * @param name name of the connection, or NULL
116 * @return
117 * - SUCCESS, or
118 * - FAILED
119 */
120 void (*log_connections) (connection_store_t *this, logger_t *logger, char *name);
121
122 /**
123 * @brief Destroys a connection_store_t object.
124 *
125 * @param this calling object
126 */
127 void (*destroy) (connection_store_t *this);
128 };
129
130 #endif /* CONNECTION_STORE_H_ */