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
17 * @defgroup connect_manager connect_manager
21 #ifndef CONNECT_MANAGER_H_
22 #define CONNECT_MANAGER_H_
24 typedef struct connect_manager_t connect_manager_t
;
26 #include <encoding/message.h>
27 #include <sa/ike_sa_id.h>
28 #include <utils/identification.h>
31 * The connection manager is responsible for establishing a direct
32 * connection with another peer.
34 struct connect_manager_t
{
37 * Checks if a there is already a mediated connection registered
41 * @param peer_id the other peer's id
42 * @param mediated_sa the IKE_SA ID of the mediated connection
44 * - TRUE, if a mediated connection is registered
47 bool (*check_and_register
) (connect_manager_t
*this, identification_t
*id
,
48 identification_t
*peer_id
,
49 ike_sa_id_t
*mediated_sa
);
52 * Checks if there are waiting connections with a specific peer.
53 * If so, reinitiate them.
56 * @param peer_id the other peer's id
58 void (*check_and_initiate
) (connect_manager_t
*this,
59 ike_sa_id_t
*mediation_sa
, identification_t
*id
,
60 identification_t
*peer_id
);
63 * Creates a checklist and sets the initiator's data.
65 * @param initiator ID of the initiator
66 * @param responder ID of the responder
67 * @param connect_id the connect ID provided by the initiator
68 * @param key the initiator's key
69 * @param endpoints the initiator's endpoints
70 * @param is_initiator TRUE, if the caller of this method is the initiator
73 status_t (*set_initiator_data
) (connect_manager_t
*this,
74 identification_t
*initiator
,
75 identification_t
*responder
,
76 chunk_t connect_id
, chunk_t key
,
77 linked_list_t
*endpoints
,
81 * Updates a checklist and sets the responder's data. The checklist's
82 * state is advanced to WAITING which means that checks will be sent.
84 * @param connect_id the connect ID
85 * @param chunk_t the responder's key
86 * @param endpoints the responder's endpoints
88 * - NOT_FOUND, if the checklist has not been found
89 * - SUCCESS, otherwise
91 status_t (*set_responder_data
) (connect_manager_t
*this,
92 chunk_t connect_id
, chunk_t key
,
93 linked_list_t
*endpoints
);
96 * Stops checks for a checklist. Called after the responder received an
97 * IKE_SA_INIT 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_ @}*/