2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * @defgroup proposal_substructure proposal_substructure
19 * @{ @ingroup payloads
22 #ifndef PROPOSAL_SUBSTRUCTURE_H_
23 #define PROPOSAL_SUBSTRUCTURE_H_
25 typedef struct proposal_substructure_t proposal_substructure_t
;
28 #include <encoding/payloads/payload.h>
29 #include <encoding/payloads/transform_substructure.h>
30 #include <config/proposal.h>
31 #include <utils/linked_list.h>
32 #include <kernel/kernel_ipsec.h>
33 #include <sa/authenticators/authenticator.h>
36 * Class representing an IKEv1/IKEv2 proposal substructure.
38 struct proposal_substructure_t
{
41 * The payload_t interface.
43 payload_t payload_interface
;
46 * Sets the proposal number of current proposal.
48 * @param id proposal number to set
50 void (*set_proposal_number
) (proposal_substructure_t
*this,
51 u_int8_t proposal_number
);
53 * get proposal number of current proposal.
55 * @return proposal number of current proposal substructure.
57 u_int8_t (*get_proposal_number
) (proposal_substructure_t
*this);
60 * Sets the protocol id of current proposal.
62 * @param id protocol id to set
64 void (*set_protocol_id
) (proposal_substructure_t
*this,
65 u_int8_t protocol_id
);
68 * get protocol id of current proposal.
70 * @return protocol id of current proposal substructure.
72 u_int8_t (*get_protocol_id
) (proposal_substructure_t
*this);
75 * Sets the next_payload field of this substructure
77 * If this is the last proposal, next payload field is set to 0,
80 * @param is_last When TRUE, next payload field is set to 0, otherwise to 2
82 void (*set_is_last_proposal
) (proposal_substructure_t
*this, bool is_last
);
85 * Returns the currently set SPI of this proposal.
87 * @return chunk_t pointing to the value
89 chunk_t (*get_spi
) (proposal_substructure_t
*this);
92 * Sets the SPI of the current proposal.
94 * @warning SPI is getting copied
96 * @param spi chunk_t pointing to the value to set
98 void (*set_spi
) (proposal_substructure_t
*this, chunk_t spi
);
101 * Get proposals contained in a propsal_substructure_t.
103 * @param list list to add created proposals to
105 void (*get_proposals
) (proposal_substructure_t
*this, linked_list_t
*list
);
108 * Create an enumerator over transform substructures.
110 * @return enumerator over transform_substructure_t
112 enumerator_t
* (*create_substructure_enumerator
)(proposal_substructure_t
*this);
115 * Destroys an proposal_substructure_t object.
117 void (*destroy
) (proposal_substructure_t
*this);
121 * Creates an empty proposal_substructure_t object
123 * @param type PROPOSAL_SUBSTRUCTURE or PROPOSAL_SUBSTRUCTURE_V1
124 * @return proposal_substructure_t object
126 proposal_substructure_t
*proposal_substructure_create(payload_type_t type
);
129 * Creates an IKEv2 proposal_substructure_t from a proposal_t.
131 * @param proposal proposal to build a substruct out of it
132 * @return proposal_substructure_t PROPOSAL_SUBSTRUCTURE
134 proposal_substructure_t
*proposal_substructure_create_from_proposal_v2(
135 proposal_t
*proposal
);
137 * Creates an IKEv1 proposal_substructure_t from a proposal_t.
139 * @param proposal proposal to build a substruct out of it
140 * @param lifetime lifetime in seconds
141 * @param lifebytes lifebytes, in bytes
142 * @param auth authentication method to use, or AUTH_NONE
143 * @param mode IPsec encapsulation mode, TRANSPORT or TUNNEL
144 * @param udp TRUE to use UDP encapsulation
147 * @return proposal_substructure_t object PROPOSAL_SUBSTRUCTURE_V1
149 proposal_substructure_t
*proposal_substructure_create_from_proposal_v1(
150 proposal_t
*proposal
, u_int32_t lifetime
, u_int64_t lifebytes
,
151 auth_method_t auth
, ipsec_mode_t mode
, bool udp
);
154 * Creates an IKEv1 proposal_substructure_t from a list of proposal_t.
156 * @param proposals list of proposal_t to encode in a substructure
157 * @param lifetime lifetime in seconds
158 * @param lifebytes lifebytes, in bytes
159 * @param auth authentication method to use, or AUTH_NONE
160 * @param mode IPsec encapsulation mode, TRANSPORT or TUNNEL
161 * @param udp TRUE to use UDP encapsulation
162 * @return IKEv1 proposal_substructure_t PROPOSAL_SUBSTRUCTURE_V1
164 proposal_substructure_t
*proposal_substructure_create_from_proposals_v1(
165 linked_list_t
*proposals
, u_int32_t lifetime
, u_int64_t lifebytes
,
166 auth_method_t auth
, ipsec_mode_t mode
, bool udp
);
168 #endif /** PROPOSAL_SUBSTRUCTURE_H_ @}*/