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