summaryrefslogtreecommitdiff
path: root/src/charon/config/connections/connection_store.h
blob: 70f209d3ba3cc34ef3a1d4bf9e30f6d0915bbc01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
 * @file connection_store.h
 *
 * @brief Interface connection_store_t.
 *
 */

/*
 * Copyright (C) 2006 Martin Willi
 * Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

#ifndef CONNECTION_STORE_H_
#define CONNECTION_STORE_H_

typedef struct connection_store_t connection_store_t;

#include <library.h>
#include <config/connections/connection.h>
#include <utils/iterator.h>

/**
 * @brief The interface for a store of connection_t's.
 *
 * @b Constructors:
 *	- stroke_create()
 *
 * @ingroup config
 */
struct connection_store_t {

	/**
	 * @brief Returns a connection definition identified by two hosts.
	 * 
	 * This call is usefull to get a connection identified by addresses.
	 * It may be used after kernel request for traffic protection.
	 * The returned connection gets created/cloned and therefore must
	 * be destroyed after usage.
	 *
	 * @param this				calling object
	 * @param my_id				own address of connection
	 * @param other_id			others address of connection
	 * @return		
	 * 							- connection_t, if found
	 * 							- NULL otherwise
	 */
	connection_t *(*get_connection_by_hosts)(connection_store_t *this, 
											 host_t *my_host, host_t *other_host);
	
	/**
	 * @brief Returns a connection identified by its name.
	 *
	 * This call is usefull to get a connection identified its
	 * name, as on an connection setup.
	 *
	 * @param this				calling object
	 * @param name				name of the connection to get
	 * @return		
	 * 							- connection_t, if found
	 * 							- NULL otherwise
	 */
	connection_t *(*get_connection_by_name) (connection_store_t *this, char *name);
	
	/**
	 * @brief Add a connection to the store.
	 *
	 * After a successful call, the connection is owned by the store and may
	 * not be manipulated nor destroyed.
	 *
	 * @param this				calling object
	 * @param connection		connection to add
	 * @return
	 * 							- SUCCESS, or
	 * 							- FAILED
	 */
	status_t (*add_connection) (connection_store_t *this, connection_t *connection);
	
	/**
	 * @brief Delete a connection from the store.
	 *
	 * Remove a connection from the connection store, identified
	 * by the connections name.
	 *
	 * @param this				calling object
	 * @param name				name of the connection to delete
	 * @return
	 * 							- SUCCESS, or
	 * 							- NOT_FOUND
	 */
	status_t (*delete_connection) (connection_store_t *this, char *name);
	
	/**
	 * @brief Get an iterator for the stored connections.
	 *
	 * @param this				calling object
	 * @return					iterator over all stored connections
	 */
	iterator_t* (*create_iterator) (connection_store_t *this);
	
	/**
	 * @brief Destroys a connection_store_t object.
	 *
	 * @param this 					calling object
	 */
	void (*destroy) (connection_store_t *this);
};

#endif /* CONNECTION_STORE_H_ */