some cleanups
[strongswan.git] / src / charon / sa / ike_sa_id.h
1 /**
2 * @file ike_sa_id.h
3 *
4 * @brief Interface of ike_sa_id_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24
25 #ifndef IKE_SA_ID_H_
26 #define IKE_SA_ID_H_
27
28 typedef struct ike_sa_id_t ike_sa_id_t;
29
30 #include <library.h>
31
32
33 /**
34 * @brief An object of type ike_sa_id_t is used to identify an IKE_SA.
35 *
36 * An IKE_SA is identified by its initiator and responder spi's.
37 * Additionaly it contains the role of the actual running IKEv2-Daemon
38 * for the specific IKE_SA (original initiator or responder).
39 *
40 * @b Constructors:
41 * - ike_sa_id_create()
42 *
43 * @ingroup sa
44 */
45 struct ike_sa_id_t {
46
47 /**
48 * @brief Set the SPI of the responder.
49 *
50 * This function is called when a request or reply of a IKE_SA_INIT is received.
51 *
52 * @param this calling object
53 * @param responder_spi SPI of responder to set
54 */
55 void (*set_responder_spi) (ike_sa_id_t *this, u_int64_t responder_spi);
56
57 /**
58 * @brief Set the SPI of the initiator.
59 *
60 * @param this calling object
61 * @param initiator_spi SPI to set
62 */
63 void (*set_initiator_spi) (ike_sa_id_t *this, u_int64_t initiator_spi);
64
65 /**
66 * @brief Get the initiator SPI.
67 *
68 * @param this calling object
69 * @return SPI of the initiator
70 */
71 u_int64_t (*get_initiator_spi) (ike_sa_id_t *this);
72
73 /**
74 * @brief Get the responder SPI.
75 *
76 * @param this calling object
77 * @return SPI of the responder
78 */
79 u_int64_t (*get_responder_spi) (ike_sa_id_t *this);
80
81 /**
82 * @brief Check if two ike_sa_id_t objects are equal.
83 *
84 * Two ike_sa_id_t objects are equal if both SPI values and the role matches.
85 *
86 * @param this calling object
87 * @param other ike_sa_id_t object to check if equal
88 * @return TRUE if given ike_sa_id_t are equal, FALSE otherwise
89 */
90 bool (*equals) (ike_sa_id_t *this, ike_sa_id_t *other);
91
92 /**
93 * @brief Replace all values of a given ike_sa_id_t object with values.
94 * from another ike_sa_id_t object.
95 *
96 * After calling this function, both objects are equal.
97 *
98 * @param this calling object
99 * @param other ike_sa_id_t object from which values will be taken
100 */
101 void (*replace_values) (ike_sa_id_t *this, ike_sa_id_t *other);
102
103 /**
104 * @brief Get the initiator flag.
105 *
106 * @param this calling object
107 * @return TRUE if we are the original initator
108 */
109 bool (*is_initiator) (ike_sa_id_t *this);
110
111 /**
112 * @brief Switche the original initiator flag.
113 *
114 * @param this calling object
115 * @return TRUE if we are the original initator after switch, FALSE otherwise
116 */
117 bool (*switch_initiator) (ike_sa_id_t *this);
118
119 /**
120 * @brief Clones a given ike_sa_id_t object.
121 *
122 * @param this calling object
123 * @return cloned ike_sa_id_t object
124 */
125 ike_sa_id_t *(*clone) (ike_sa_id_t *this);
126
127 /**
128 * @brief Destroys an ike_sa_id_t object.
129 *
130 * @param this calling object
131 */
132 void (*destroy) (ike_sa_id_t *this);
133 };
134
135 /**
136 * @brief Creates an ike_sa_id_t object with specific SPI's and defined role.
137 *
138 * @param initiator_spi initiators SPI
139 * @param responder_spi responders SPI
140 * @param is_initiaor TRUE if we are the original initiator
141 * @return ike_sa_id_t object
142 *
143 * @ingroup sa
144 */
145 ike_sa_id_t * ike_sa_id_create(u_int64_t initiator_spi, u_int64_t responder_spi, bool is_initiaor);
146
147 #endif /*IKE_SA_ID_H_*/