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