]>
Commit | Line | Data |
---|---|---|
53f7a5f8 | 1 | /* |
1726795f | 2 | * Copyright (C) 2012 Tobias Brunner |
c71d53ba MW |
3 | * Copyright (C) 2005-2006 Martin Willi |
4 | * Copyright (C) 2005 Jan Hutter | |
19ef2aec TB |
5 | * |
6 | * Copyright (C) secunet Security Networks AG | |
53f7a5f8 JH |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2 of the License, or (at your | |
11 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | * for more details. | |
17 | */ | |
18 | ||
552cc11b MW |
19 | /** |
20 | * @defgroup ike_sa_id ike_sa_id | |
21 | * @{ @ingroup sa | |
22 | */ | |
53f7a5f8 | 23 | |
16b9a73c MW |
24 | #ifndef IKE_SA_ID_H_ |
25 | #define IKE_SA_ID_H_ | |
f7cf9f61 | 26 | |
382b4817 MW |
27 | typedef struct ike_sa_id_t ike_sa_id_t; |
28 | ||
db7ef624 | 29 | #include <library.h> |
53f7a5f8 | 30 | |
53f7a5f8 | 31 | /** |
552cc11b | 32 | * An object of type ike_sa_id_t is used to identify an IKE_SA. |
c3dc6f1a | 33 | * |
1726795f TB |
34 | * An IKE_SA is identified by its initiator and responder SPIs. |
35 | * Additionally, it contains the major IKE version of the IKE_SA and, for IKEv2, | |
36 | * the role of the daemon (original initiator or responder). | |
53f7a5f8 | 37 | */ |
5796aa16 | 38 | struct ike_sa_id_t { |
53f7a5f8 | 39 | |
1726795f TB |
40 | /** |
41 | * Get the major IKE version of this IKE_SA. | |
42 | * | |
43 | * @return IKE version | |
44 | */ | |
b12c53ce | 45 | uint8_t (*get_ike_version) (ike_sa_id_t *this); |
1726795f | 46 | |
53f7a5f8 | 47 | /** |
552cc11b | 48 | * Set the SPI of the responder. |
c3dc6f1a | 49 | * |
53f7a5f8 | 50 | * This function is called when a request or reply of a IKE_SA_INIT is received. |
c3dc6f1a | 51 | * |
f3bb1bd0 | 52 | * @param responder_spi SPI of responder to set |
53f7a5f8 | 53 | */ |
b12c53ce | 54 | void (*set_responder_spi) (ike_sa_id_t *this, uint64_t responder_spi); |
c3dc6f1a | 55 | |
472217f1 | 56 | /** |
552cc11b | 57 | * Set the SPI of the initiator. |
c3dc6f1a | 58 | * |
f3bb1bd0 | 59 | * @param initiator_spi SPI to set |
472217f1 | 60 | */ |
b12c53ce | 61 | void (*set_initiator_spi) (ike_sa_id_t *this, uint64_t initiator_spi); |
53f7a5f8 JH |
62 | |
63 | /** | |
552cc11b | 64 | * Get the initiator SPI. |
c3dc6f1a | 65 | * |
f3bb1bd0 | 66 | * @return SPI of the initiator |
53f7a5f8 | 67 | */ |
b12c53ce | 68 | uint64_t (*get_initiator_spi) (ike_sa_id_t *this); |
53f7a5f8 JH |
69 | |
70 | /** | |
552cc11b | 71 | * Get the responder SPI. |
c3dc6f1a | 72 | * |
f3bb1bd0 | 73 | * @return SPI of the responder |
53f7a5f8 | 74 | */ |
b12c53ce | 75 | uint64_t (*get_responder_spi) (ike_sa_id_t *this); |
c3dc6f1a | 76 | |
53f7a5f8 | 77 | /** |
552cc11b | 78 | * Check if two ike_sa_id_t objects are equal. |
7daf5226 | 79 | * |
1726795f TB |
80 | * Two ike_sa_id_t objects are equal if version and both SPI values match. |
81 | * The role is not compared. | |
c3dc6f1a | 82 | * |
f3bb1bd0 | 83 | * @param other ike_sa_id_t object to check if equal |
1726795f TB |
84 | * @return TRUE if given ike_sa_id_t are equal, |
85 | * FALSE otherwise | |
53f7a5f8 | 86 | */ |
d048df5c | 87 | bool (*equals) (ike_sa_id_t *this, ike_sa_id_t *other); |
c3dc6f1a | 88 | |
2598643a | 89 | /** |
0ceb2888 | 90 | * Replace all values of a given ike_sa_id_t object with values |
d048df5c | 91 | * from another ike_sa_id_t object. |
7daf5226 | 92 | * |
f7cf9f61 | 93 | * After calling this function, both objects are equal. |
c3dc6f1a | 94 | * |
f3bb1bd0 | 95 | * @param other ike_sa_id_t object from which values will be taken |
8491b298 | 96 | */ |
d048df5c | 97 | void (*replace_values) (ike_sa_id_t *this, ike_sa_id_t *other); |
c3dc6f1a | 98 | |
472217f1 | 99 | /** |
552cc11b | 100 | * Get the initiator flag. |
c3dc6f1a | 101 | * |
9c67f5ff | 102 | * @return TRUE if we are the original initiator |
7b3d1389 MW |
103 | */ |
104 | bool (*is_initiator) (ike_sa_id_t *this); | |
105 | ||
106 | /** | |
1726795f | 107 | * Switch the original initiator flag. |
7daf5226 | 108 | * |
1726795f | 109 | * @return new value if initiator flag. |
472217f1 | 110 | */ |
7b3d1389 | 111 | bool (*switch_initiator) (ike_sa_id_t *this); |
c3dc6f1a | 112 | |
8491b298 | 113 | /** |
552cc11b | 114 | * Clones a given ike_sa_id_t object. |
c3dc6f1a | 115 | * |
f3bb1bd0 | 116 | * @return cloned ike_sa_id_t object |
2598643a | 117 | */ |
d048df5c | 118 | ike_sa_id_t *(*clone) (ike_sa_id_t *this); |
53f7a5f8 JH |
119 | |
120 | /** | |
552cc11b | 121 | * Destroys an ike_sa_id_t object. |
53f7a5f8 | 122 | */ |
d048df5c | 123 | void (*destroy) (ike_sa_id_t *this); |
53f7a5f8 JH |
124 | }; |
125 | ||
126 | /** | |
1726795f | 127 | * Creates an ike_sa_id_t object. |
c3dc6f1a | 128 | * |
1726795f | 129 | * @param ike_version major IKE version |
f7cf9f61 JH |
130 | * @param initiator_spi initiators SPI |
131 | * @param responder_spi responders SPI | |
b3ab7a48 | 132 | * @param is_initiator TRUE if we are the original initiator |
f7cf9f61 | 133 | * @return ike_sa_id_t object |
53f7a5f8 | 134 | */ |
b12c53ce | 135 | ike_sa_id_t * ike_sa_id_create(uint8_t ike_version, uint64_t initiator_spi, |
b3ab7a48 | 136 | uint64_t responder_spi, bool is_initiator); |
53f7a5f8 | 137 | |
1490ff4d | 138 | #endif /** IKE_SA_ID_H_ @}*/ |