aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/config/init_config.h
blob: f63df61cf698a71a246c0d579c7197587319516a (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/**
 * @file init_config.h
 * 
 * @brief Interface of init_config_t.
 *  
 */

/*
 * Copyright (C) 2005 Jan Hutter, Martin Willi
 * 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 _INIT_CONFIG_H_
#define _INIT_CONFIG_H_

#include <types.h>
#include <network/host.h>
#include <utils/linked_list.h>
#include <config/proposal.h>
#include <transforms/crypters/crypter.h>
#include <transforms/prfs/prf.h>
#include <transforms/signers/signer.h>
#include <transforms/diffie_hellman.h>



typedef struct init_config_t init_config_t;

/**
 * @brief Represents a configuration class holding all needed informations for IKE_SA_INIT phase.
 * 
 * @b Constructors:
 *  - init_config_create()
 * 
 * @ingroup config
 */
struct init_config_t { 

	/**
	 * @brief Get my host information as host_t object.
	 * 
	 * Object is NOT getting cloned.
	 * 
	 * @param this	calling object
	 * @return		host information as host_t object
	 */
	host_t *(*get_my_host) (init_config_t *this);

	/**
	 * @brief Get other host information as host_t object.
	 * 
	 * Object is NOT getting cloned.
	 * 
	 * @param this	calling object
	 * @return		host information as host_t object
	 */
	host_t *(*get_other_host) (init_config_t *this);
	
	/**
	 * @brief Get my host information as host_t object.
	 * 
	 * Object is getting cloned and has to get destroyed by caller.
	 * 
	 * @param this	calling object
	 * @return		host information as host_t object
	 */
	host_t *(*get_my_host_clone) (init_config_t *this);

	/**
	 * @brief Get other host information as host_t object.
	 * 
	 * @warning Object is getting cloned and has to get destroyed by caller.
	 * 
	 * @param this	calling object
	 * @return		host information as host_t object
	 */
	host_t *(*get_other_host_clone) (init_config_t *this);
	
	/**
	 * @brief Returns a list of all supported proposals.
	 * 
	 * Returned list is still owned by init_config and MUST NOT
	 * modified or destroyed.
	 * 
	 * @param this				calling object
	 * @return 					list containing all the proposals
	 */
	linked_list_t *(*get_proposals) (init_config_t *this);
	
	/**
	 * @brief Adds a proposal to the list..
	 * 
	 * The first added proposal has the highest priority, the last
	 * added the lowest.
	 * 
	 * @param this				calling object
	 * @param priority			priority of adding proposal
	 * @param proposal			proposal to add
	 */
	void (*add_proposal) (init_config_t *this, proposal_t *proposal);
	
	/**
	 * @brief Select a proposed from suggested proposals.
	 * 
	 * Returned proposal must be destroyed after usage.
	 * 
	 * @param this					calling object
	 * @param proposals				list of proposals to select from
	 * @return						selected proposal, or NULL if none matches.
	 */
	proposal_t *(*select_proposal) (init_config_t *this, linked_list_t *proposals);
	
	/**
	 * @brief Get the DH group to use for connection initialization.
	 * 
	 * @param this					calling object
	 * @return						dh group to use for initialization
	 */
	diffie_hellman_group_t (*get_dh_group) (init_config_t *this);
	
	/**
	 * @brief Check if a suggested dh group is acceptable.
	 * 
	 * If we guess a wrong DH group for IKE_SA_INIT, the other
	 * peer will send us a offer. But is this acceptable for us?
	 * 
	 * @param this					calling object
	 * @return						dh group to use for initialization
	 */
	bool (*check_dh_group) (init_config_t *this, diffie_hellman_group_t dh_group);
	
	/**
	 * @brief Destroys a init_config_t object.
	 * 
	 * @param this	calling object
	 */
	void (*destroy) (init_config_t *this);
};

/**
 * @brief Creates a init_config_t object.
 * 
 * @return init_config_t object.
 * 
 * @ingroup config
 */
init_config_t * init_config_create(char *my_ip, char *other_ip, u_int16_t my_port, u_int16_t other_port);

#endif //_INIT_CONFIG_H_