summaryrefslogtreecommitdiff
path: root/src/charon/sa/connect_manager.h
blob: 2f3e9109bee4bd48be0d44f8ffe66e3352f65ce6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
 * @file connect_manager.h
 * 
 * @brief Interface of connect_manager_t.
 * 
 */

/*
 * Copyright (C) 2007 Tobias Brunner
 * Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

#ifndef CONNECT_MANAGER_H_
#define CONNECT_MANAGER_H_

typedef struct connect_manager_t connect_manager_t;

#include <encoding/message.h>
#include <config/child_cfg.h>
#include <sa/ike_sa_id.h>
#include <utils/identification.h>

/**
 * @brief The connection manager is responsible for establishing a direct
 * connection with another peer.
 * 
 * @b Constructors:
 * - connect_manager_create()
 * 
 * @ingroup sa
 */
struct connect_manager_t {
	
	/**
	 * @brief Checks if a there is already a mediated connection registered
	 * between two peers.
	 * 
	 * @param this 				the manager object
	 * @param id				my id
	 * @param peer_id			the other peer's id
	 * @param mediated_sa		the IKE_SA ID of the mediated connection
	 * @param child				the CHILD_SA config of the mediated connection 
	 * @returns 				
	 * 							- TRUE, if there was already a mediated connection registered
	 * 							- FALSE, otherwise
	 */
	bool (*check_and_register) (connect_manager_t *this,
			identification_t *id, identification_t *peer_id,
			ike_sa_id_t *mediated_sa, child_cfg_t *child);
	
	/**
	 * @brief Checks if there are waiting connections with a specific peer.
	 * If so, reinitiate them.
	 * 
	 * @param this 				the manager object
	 * @param id				my id
	 * @param peer_id			the other peer's id
	 */
	void (*check_and_initiate) (connect_manager_t *this, ike_sa_id_t *mediation_sa,
			identification_t *id, identification_t *peer_id);
	
	/**
	 * @brief Creates a checklist and sets the initiator's data.
	 * 
	 * @param this 				the manager object
	 * @param initiator			ID of the initiator
	 * @param responder			ID of the responder
	 * @param session_id		the session ID provided by the initiator
	 * @param key				the initiator's key
	 * @param endpoints			the initiator's endpoints
	 * @param is_initiator		TRUE, if the caller of this method is the initiator
	 * 							FALSE, otherwise
	 * @returns
	 * 							SUCCESS
	 */
	status_t (*set_initiator_data) (connect_manager_t *this,
		identification_t *initiator, identification_t *responder,
		chunk_t session_id, chunk_t key, linked_list_t *endpoints, bool is_initiator);
	
	/**
	 * @brief Updates a checklist and sets the responder's data. The checklist's
	 * state is advanced to WAITING which means that checks will be sent.
	 * 
	 * @param this 				the manager object
	 * @param session_id		the session ID
	 * @param chunk_t			the responder's key
	 * @param endpoints			the responder's endpoints 
	 * @returns 				
	 * 							- NOT_FOUND, if the checklist has not been found
	 * 							- SUCCESS, otherwise
	 */
	status_t (*set_responder_data) (connect_manager_t *this,
		chunk_t session_id, chunk_t key, linked_list_t *endpoints);
	
	
	/**
	 * @brief Processes a connectivity check
	 * 
	 * @param this				the manager object
	 * @param message			the received message
	 */
	void (*process_check) (connect_manager_t *this, message_t *message);
	
	/**
	 * @brief Destroys the manager with all data.
	 * 
	 * @param this				 the manager object
	 */
	void (*destroy) (connect_manager_t *this);
};

/**
 * @brief Create a manager.
 * 
 * @returns 	connect_manager_t object
 * 
 * @ingroup sa
 */
connect_manager_t *connect_manager_create(void);

#endif /*CONNECT_MANAGER_H_*/