some improvements in signaling code
[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 #include <types.h>
29
30 /**
31 * printf() specifier to print a ike_sa_id.
32 */
33 #define IKE_SA_ID_PRINTF_SPEC 'J'
34
35 typedef struct ike_sa_id_t ike_sa_id_t;
36
37 /**
38 * @brief An object of type ike_sa_id_t is used to identify an IKE_SA.
39 *
40 * An IKE_SA is identified by its initiator and responder spi's.
41 * Additionaly it contains the role of the actual running IKEv2-Daemon
42 * for the specific IKE_SA (original initiator or responder).
43 *
44 * @b Constructors:
45 * - ike_sa_id_create()
46 *
47 * @ingroup sa
48 */
49 struct ike_sa_id_t {
50
51 /**
52 * @brief Set the SPI of the responder.
53 *
54 * This function is called when a request or reply of a IKE_SA_INIT is received.
55 *
56 * @param this calling object
57 * @param responder_spi SPI of responder to set
58 */
59 void (*set_responder_spi) (ike_sa_id_t *this, u_int64_t responder_spi);
60
61 /**
62 * @brief Set the SPI of the initiator.
63 *
64 * @param this calling object
65 * @param initiator_spi SPI to set
66 */
67 void (*set_initiator_spi) (ike_sa_id_t *this, u_int64_t initiator_spi);
68
69 /**
70 * @brief Get the initiator SPI.
71 *
72 * @param this calling object
73 * @return SPI of the initiator
74 */
75 u_int64_t (*get_initiator_spi) (ike_sa_id_t *this);
76
77 /**
78 * @brief Get the responder SPI.
79 *
80 * @param this calling object
81 * @return SPI of the responder
82 */
83 u_int64_t (*get_responder_spi) (ike_sa_id_t *this);
84
85 /**
86 * @brief Check if two ike_sa_id_t objects are equal.
87 *
88 * Two ike_sa_id_t objects are equal if both SPI values and the role matches.
89 *
90 * @param this calling object
91 * @param other ike_sa_id_t object to check if equal
92 * @return TRUE if given ike_sa_id_t are equal, FALSE otherwise
93 */
94 bool (*equals) (ike_sa_id_t *this, ike_sa_id_t *other);
95
96 /**
97 * @brief Replace all values of a given ike_sa_id_t object with values.
98 * from another ike_sa_id_t object.
99 *
100 * After calling this function, both objects are equal.
101 *
102 * @param this calling object
103 * @param other ike_sa_id_t object from which values will be taken
104 */
105 void (*replace_values) (ike_sa_id_t *this, ike_sa_id_t *other);
106
107 /**
108 * @brief Get the initiator flag.
109 *
110 * @param this calling object
111 * @return TRUE if we are the original initator
112 */
113 bool (*is_initiator) (ike_sa_id_t *this);
114
115 /**
116 * @brief Switche the original initiator flag.
117 *
118 * @param this calling object
119 * @return TRUE if we are the original initator after switch, FALSE otherwise
120 */
121 bool (*switch_initiator) (ike_sa_id_t *this);
122
123 /**
124 * @brief Clones a given ike_sa_id_t object.
125 *
126 * @param this calling object
127 * @return cloned ike_sa_id_t object
128 */
129 ike_sa_id_t *(*clone) (ike_sa_id_t *this);
130
131 /**
132 * @brief Destroys an ike_sa_id_t object.
133 *
134 * @param this calling object
135 */
136 void (*destroy) (ike_sa_id_t *this);
137 };
138
139 /**
140 * @brief Creates an ike_sa_id_t object with specific SPI's and defined role.
141 *
142 * @param initiator_spi initiators SPI
143 * @param responder_spi responders SPI
144 * @param is_initiaor TRUE if we are the original initiator
145 * @return ike_sa_id_t object
146 *
147 * @ingroup sa
148 */
149 ike_sa_id_t * ike_sa_id_create(u_int64_t initiator_spi, u_int64_t responder_spi, bool is_initiaor);
150
151 #endif /*IKE_SA_ID_H_*/