../svn-commit.tmp
[strongswan.git] / Source / 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 Jan Hutter, 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
24 #ifndef IKE_SA_ID_H_
25 #define IKE_SA_ID_H_
26
27 #include "types.h"
28
29 typedef struct ike_sa_id_t ike_sa_id_t;
30
31 /**
32 * @brief This class is used to identify an IKE_SA.
33 *
34 * An IKE_SA is identified by its initiator and responder spi's.
35 * Additionaly it contains the role of the actual running IKEv2-Daemon
36 * for the specific IKE_SA.
37 *
38 * @ingroup sa
39 */
40 struct ike_sa_id_t {
41
42 /**
43 * @brief Sets the SPI of the responder.
44 *
45 * This function is called when a request or reply of a IKE_SA_INIT is received.
46 *
47 * @param this ike_sa_id_t object
48 * @param responder_spi SPI of responder to set
49 */
50 void (*set_responder_spi) (ike_sa_id_t *this, u_int64_t responder_spi);
51
52 /**
53 * @brief Sets the SPI of the initiator.
54 *
55 *
56 * @param this ike_sa_id_t object
57 * @param initiator_spi SPI to set
58 */
59 void (*set_initiator_spi) (ike_sa_id_t *this, u_int64_t initiator_spi);
60
61 /**
62 * @brief Returns the initiator spi.
63 *
64 * @param this ike_sa_id_t object
65 * @return spi of the initiator
66 */
67 u_int64_t (*get_initiator_spi) (ike_sa_id_t *this);
68
69 /**
70 * @brief Returns the responder spi.
71 *
72 * @param this ike_sa_id_t object
73 * @return spi of the responder
74 */
75 u_int64_t (*get_responder_spi) (ike_sa_id_t *this);
76
77 /**
78 * @brief Check if two ike_sa_ids are equal.
79 *
80 * @param this ike_sa_id_t object
81 * @param other ike_sa_id object to check if equal
82 * @return TRUE if given ike_sa_ids are equal, FALSE otherwise
83 */
84 bool (*equals) (ike_sa_id_t *this, ike_sa_id_t *other);
85
86 /**
87 * @brief Replace the values of a given ike_sa_id_t object with values.
88 * from another ike_sa_id_t object.
89 *
90 * @param this ike_sa_id_t object
91 * @param other ike_sa_id_t object which values will be taken
92 */
93 void (*replace_values) (ike_sa_id_t *this, ike_sa_id_t *other);
94
95 /**
96 * @brief gets the initiator flag.
97 *
98 * @param this ike_sa_id_t object
99 * @return TRUE if we are the original initator
100 */
101 bool (*is_initiator) (ike_sa_id_t *this);
102
103 /**
104 * @brief switches the initiator flag.
105 *
106 * @param this ike_sa_id_t object
107 * @return TRUE if we are the original initator after switch
108 */
109 bool (*switch_initiator) (ike_sa_id_t *this);
110
111 /**
112 * @brief Clones a given ike_sa_id_t object.
113 *
114 * @param this ike_sa_id_t object
115 * @return cloned ike_sa_id
116 */
117 ike_sa_id_t *(*clone) (ike_sa_id_t *this);
118
119 /**
120 * @brief Destroys a ike_sa_id_tobject.
121 *
122 * @param this ike_sa_id_t object
123 */
124 void (*destroy) (ike_sa_id_t *this);
125 };
126
127 /**
128 * @brief Creates an ike_sa_id_t object with specific spi's and defined role
129 *
130 * @warning The initiator SPI and role is not changeable after initiating a ike_sa_id object
131 *
132 * @param initiator_spi initiators spi
133 * @param responder_spi responders spi
134 * @param is_initiator TRUE if we are the original initiator
135 * @return created ike_sa_id_t object
136 *
137 * @ingroup sa
138 */
139 ike_sa_id_t * ike_sa_id_create(u_int64_t initiator_spi, u_int64_t responder_spi, bool is_initiaor);
140
141 #endif /*IKE_SA_ID_H_*/