2 * Copyright (C) 2007-2008 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
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>.
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
19 * @defgroup connect_manager connect_manager
23 #ifndef CONNECT_MANAGER_H_
24 #define CONNECT_MANAGER_H_
26 typedef struct connect_manager_t connect_manager_t
;
28 #include <encoding/message.h>
29 #include <config/child_cfg.h>
30 #include <sa/ike_sa_id.h>
31 #include <utils/identification.h>
34 * The connection manager is responsible for establishing a direct
35 * connection with another peer.
37 struct connect_manager_t
{
40 * Checks if a there is already a mediated connection registered
44 * @param peer_id the other peer's id
45 * @param mediated_sa the IKE_SA ID of the mediated connection
46 * @param child the CHILD_SA config of the mediated connection
48 * - TRUE, if there was already a mediated connection registered
51 bool (*check_and_register
) (connect_manager_t
*this,
52 identification_t
*id
, identification_t
*peer_id
,
53 ike_sa_id_t
*mediated_sa
, child_cfg_t
*child
);
56 * Checks if there are waiting connections with a specific peer.
57 * If so, reinitiate them.
60 * @param peer_id the other peer's id
62 void (*check_and_initiate
) (connect_manager_t
*this, ike_sa_id_t
*mediation_sa
,
63 identification_t
*id
, identification_t
*peer_id
);
66 * Creates a checklist and sets the initiator's data.
68 * @param initiator ID of the initiator
69 * @param responder ID of the responder
70 * @param connect_id the connect ID provided by the initiator
71 * @param key the initiator's key
72 * @param endpoints the initiator's endpoints
73 * @param is_initiator TRUE, if the caller of this method is the initiator
77 status_t (*set_initiator_data
) (connect_manager_t
*this,
78 identification_t
*initiator
, identification_t
*responder
,
79 chunk_t connect_id
, chunk_t key
, linked_list_t
*endpoints
, bool is_initiator
);
82 * Updates a checklist and sets the responder's data. The checklist's
83 * state is advanced to WAITING which means that checks will be sent.
85 * @param connect_id the connect ID
86 * @param chunk_t the responder's key
87 * @param endpoints the responder's endpoints
89 * - NOT_FOUND, if the checklist has not been found
90 * - SUCCESS, otherwise
92 status_t (*set_responder_data
) (connect_manager_t
*this,
93 chunk_t connect_id
, chunk_t key
, linked_list_t
*endpoints
);
96 * Stops checks for a checklist. Used after the responder received an IKE_SA_INIT
97 * request which contains a ME_CONNECTID payload.
99 * @param connect_id the connect ID
101 * - NOT_FOUND, if the checklist has not been found
102 * - SUCCESS, otherwise
104 status_t (*stop_checks
) (connect_manager_t
*this, chunk_t connect_id
);
107 * Processes a connectivity check
109 * @param message the received message
111 void (*process_check
) (connect_manager_t
*this, message_t
*message
);
114 * Destroys the manager with all data.
116 void (*destroy
) (connect_manager_t
*this);
122 * @returns connect_manager_t object
124 connect_manager_t
*connect_manager_create(void);
126 #endif /*CONNECT_MANAGER_H_ @} */