summaryrefslogtreecommitdiff
path: root/src/charon/config/policies/policy_store.h
blob: cd8870953137bd7b9f0dd102f3a075cf66075897 (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
119
/**
 * @file policy_store.h
 * 
 * @brief Interface policy_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 POLICY_STORE_H_
#define POLICY_STORE_H_

typedef struct policy_store_t policy_store_t;

#include <library.h>
#include <config/policies/policy.h>
#include <utils/linked_list.h>


/**
 * @brief The interface for a store of policy_t's.
 *
 * The store uses reference counting to manage their lifetime. Call
 * destroy() for a policy which is returned from the store after usage.
 *
 * @b Constructors:
 * - stroke_create()
 * 
 * @ingroup config
 */
struct policy_store_t {

	/**
	 * @brief Returns a policy identified by two IDs and a set of traffic selectors.
	 *
	 * other_id must be fully qualified. my_id may be %any, as the
	 * other peer may not include an IDr Request.
	 *
	 * @param this			calling object
	 * @param my_id			own ID of the policy
	 * @param other_id		others ID of the policy
	 * @param my_ts			traffic selectors requested for local host
	 * @param other_ts		traffic selectors requested for remote host
	 * @param my_host		host to use for wilcards in TS compare
	 * @param other_host	host to use for wildcards in TS compare
	 * @return
	 *						- matching policy_t, if found
	 *						- NULL otherwise
	 */
	policy_t *(*get_policy) (policy_store_t *this, 
							 identification_t *my_id, identification_t *other_id,
							 linked_list_t *my_ts, linked_list_t *other_ts,
							 host_t *my_host, host_t* other_host);

	/**
	 * @brief Returns a policy identified by a connection name.
	 *
	 * @param this		calling object
	 * @param name		name of the policy
	 * @return
	 *					- matching policy_t, if found
	 *					- NULL otherwise
	 */
	policy_t *(*get_policy_by_name) (policy_store_t *this, char *name);

	/**
	 * @brief Add a policy to the list.
	 *
	 * The policy is owned by the store after the call. Do
	 * not modify nor free.
	 *
	 * @param this		calling object
	 * @param policy	policy to add
	 */
	void (*add_policy) (policy_store_t *this, policy_t *policy);

	/**
	 * @brief Delete a policy from the store.
	 *
	 * Remove a policy from the store identified by its name.
	 *
	 * @param this		calling object
	 * @param policy	policy to add
	 * @return
	 *					- SUCCESS, or
	 *					- NOT_FOUND
	 */
	status_t (*delete_policy) (policy_store_t *this, char *name);
	
	/**
	 * @brief Get an iterator for the stored policies.
	 *
	 * @param this				calling object
	 * @return					iterator over all stored policies
	 */
	iterator_t* (*create_iterator) (policy_store_t *this);
	
	/**
	 * @brief Destroys a policy_store_t object.
	 *
	 * @param this 					calling object
	 */
	void (*destroy) (policy_store_t *this);
};

#endif /*POLICY_STORE_H_*/