added .gitignore files to NM applet
[strongswan.git] / src / charon / sa / connect_manager.h
1 /*
2 * Copyright (C) 2007-2008 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup connect_manager connect_manager
18 * @{ @ingroup sa
19 */
20
21 #ifndef CONNECT_MANAGER_H_
22 #define CONNECT_MANAGER_H_
23
24 typedef struct connect_manager_t connect_manager_t;
25
26 #include <encoding/message.h>
27 #include <sa/ike_sa_id.h>
28 #include <utils/identification.h>
29
30 /**
31 * The connection manager is responsible for establishing a direct
32 * connection with another peer.
33 */
34 struct connect_manager_t {
35
36 /**
37 * Checks if a there is already a mediated connection registered
38 * between two peers.
39 *
40 * @param id my id
41 * @param peer_id the other peer's id
42 * @param mediated_sa the IKE_SA ID of the mediated connection
43 * @returns
44 * - TRUE, if there was already a mediated connection registered
45 * - FALSE, otherwise
46 */
47 bool (*check_and_register) (connect_manager_t *this,
48 identification_t *id, identification_t *peer_id, ike_sa_id_t *mediated_sa);
49
50 /**
51 * Checks if there are waiting connections with a specific peer.
52 * If so, reinitiate them.
53 *
54 * @param id my id
55 * @param peer_id the other peer's id
56 */
57 void (*check_and_initiate) (connect_manager_t *this, ike_sa_id_t *mediation_sa,
58 identification_t *id, identification_t *peer_id);
59
60 /**
61 * Creates a checklist and sets the initiator's data.
62 *
63 * @param initiator ID of the initiator
64 * @param responder ID of the responder
65 * @param connect_id the connect ID provided by the initiator
66 * @param key the initiator's key
67 * @param endpoints the initiator's endpoints
68 * @param is_initiator TRUE, if the caller of this method is the initiator
69 * FALSE, otherwise
70 * @returns SUCCESS
71 */
72 status_t (*set_initiator_data) (connect_manager_t *this,
73 identification_t *initiator, identification_t *responder,
74 chunk_t connect_id, chunk_t key, linked_list_t *endpoints, bool is_initiator);
75
76 /**
77 * Updates a checklist and sets the responder's data. The checklist's
78 * state is advanced to WAITING which means that checks will be sent.
79 *
80 * @param connect_id the connect ID
81 * @param chunk_t the responder's key
82 * @param endpoints the responder's endpoints
83 * @returns
84 * - NOT_FOUND, if the checklist has not been found
85 * - SUCCESS, otherwise
86 */
87 status_t (*set_responder_data) (connect_manager_t *this,
88 chunk_t connect_id, chunk_t key, linked_list_t *endpoints);
89
90 /**
91 * Stops checks for a checklist. Used after the responder received an IKE_SA_INIT
92 * request which contains a ME_CONNECTID payload.
93 *
94 * @param connect_id the connect ID
95 * @returns
96 * - NOT_FOUND, if the checklist has not been found
97 * - SUCCESS, otherwise
98 */
99 status_t (*stop_checks) (connect_manager_t *this, chunk_t connect_id);
100
101 /**
102 * Processes a connectivity check
103 *
104 * @param message the received message
105 */
106 void (*process_check) (connect_manager_t *this, message_t *message);
107
108 /**
109 * Destroys the manager with all data.
110 */
111 void (*destroy) (connect_manager_t *this);
112 };
113
114 /**
115 * Create a manager.
116 *
117 * @returns connect_manager_t object
118 */
119 connect_manager_t *connect_manager_create(void);
120
121 #endif /** CONNECT_MANAGER_H_ @}*/