8b911a57b8b9ed79f4cb8a2fd72b60b4f2ca1983
[strongswan.git] / Source / charon / ike_sa_id.h
1 /**
2 * @file ike_sa_id.h
3 *
4 * @brief Class for identification of an IKE_SA
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 /**
30 * @brief This class is used to identify an IKE_SA.
31 *
32 * An IKE_SA is identified by its initiator and responder spi's.
33 * Additionaly it contains the role of the actual running IKEv2-Daemon
34 * for the specific IKE_SA.
35 */
36 typedef struct ike_sa_id_s ike_sa_id_t;
37
38 struct ike_sa_id_s {
39
40 /**
41 * @brief Sets the SPI of the responder.
42 *
43 * This function is called when a request or reply of a IKE_SA_INIT is received.
44 *
45 * @param this ike_sa_id_t-object
46 * @param responder_spi SPI of responder to set
47 * @return SUCCESSFUL if succeeded, FAILED otherwise
48 */
49 status_t (*set_responder_spi) (ike_sa_id_t *this, spi_t responder_spi);
50
51 /**
52 * @brief Returns TRUE if the initiator spi is set (not zero)
53 *
54 * @param this ike_sa_id_t-object
55 * @return TRUE if the initiator spi is set, FALSE otherwise
56 */
57 bool (*initiator_spi_is_set) (ike_sa_id_t *this);
58
59 /**
60 * @brief Returns TRUE if the responder spi is set (not zero)
61 *
62 * @param this ike_sa_id_t-object
63 * @return TRUE if the responder spi is set, FALSE otherwise
64 */
65 bool (*responder_spi_is_set) (ike_sa_id_t *this);
66
67 /**
68 * @brief Check if two ike_sa_ids are equal
69 *
70 * @param this ike_sa_id_t-object
71 * @param other ike_sa_id object to check if equal
72 * @param are_equal is set to TRUE, if given ike_sa_ids are equal, FALSE otherwise
73 * @return SUCCESSFUL if succeeded, FAILED otherwise
74 */
75 status_t (*equals) (ike_sa_id_t *this,ike_sa_id_t *other, bool *are_equal);
76
77 /**
78 * @brief Replace the values of a given ike_sa_id_t-object with values
79 * from another ike_sa_id_t-Object
80 *
81 * @param this ike_sa_id_t-object
82 * @param other ike_sa_id_t object which values will be taken
83 * @return SUCCESSFUL if succeeded, FAILED otherwise
84 */
85 status_t (*replace_values) (ike_sa_id_t *this,ike_sa_id_t *other);
86
87 /**
88 * @brief Clones a given ike_sa_id_t-object
89 *
90 * @param this ike_sa_id_t-object
91 * @param clone_of_this ike_sa_id_t-object which will be created
92 * @return SUCCESSFUL if succeeded, FAILED otherwise
93 */
94 status_t (*clone) (ike_sa_id_t *this,ike_sa_id_t **clone_of_this);
95
96 /**
97 * @brief Destroys a ike_sa_id_tobject
98 *
99 * @param this ike_sa_id_t-object
100 * @return SUCCESSFUL if succeeded, FAILED otherwise
101 */
102 status_t (*destroy) (ike_sa_id_t *this);
103 };
104
105 /**
106 * Creates an ike_sa_id_t-object with specific spi's and defined role
107 *
108 * @warning The initiator SPI and role is not changeable after initiating a ike_sa_id-object
109 */
110 ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi,ike_sa_role_t role);
111
112 #endif /*IKE_SA_ID_H_*/