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>
34 * Class representing an IKEv1/IKEv2 proposal substructure.
36 struct proposal_substructure_t
{
39 * The payload_t interface.
41 payload_t payload_interface
;
44 * Sets the proposal number of current proposal.
46 * @param id proposal number to set
48 void (*set_proposal_number
) (proposal_substructure_t
*this,
49 u_int8_t proposal_number
);
51 * get proposal number of current proposal.
53 * @return proposal number of current proposal substructure.
55 u_int8_t (*get_proposal_number
) (proposal_substructure_t
*this);
58 * Sets the protocol id of current proposal.
60 * @param id protocol id to set
62 void (*set_protocol_id
) (proposal_substructure_t
*this,
63 u_int8_t protocol_id
);
66 * get protocol id of current proposal.
68 * @return protocol id of current proposal substructure.
70 u_int8_t (*get_protocol_id
) (proposal_substructure_t
*this);
73 * Sets the next_payload field of this substructure
75 * If this is the last proposal, next payload field is set to 0,
78 * @param is_last When TRUE, next payload field is set to 0, otherwise to 2
80 void (*set_is_last_proposal
) (proposal_substructure_t
*this, bool is_last
);
83 * Returns the currently set SPI of this proposal.
85 * @return chunk_t pointing to the value
87 chunk_t (*get_spi
) (proposal_substructure_t
*this);
90 * Sets the SPI of the current proposal.
92 * @warning SPI is getting copied
94 * @param spi chunk_t pointing to the value to set
96 void (*set_spi
) (proposal_substructure_t
*this, chunk_t spi
);
99 * Get proposals contained in a propsal_substructure_t.
101 * @param list list to add created proposals to
103 void (*get_proposals
) (proposal_substructure_t
*this, linked_list_t
*list
);
106 * Create an enumerator over transform substructures.
108 * @return enumerator over transform_substructure_t
110 enumerator_t
* (*create_substructure_enumerator
)(proposal_substructure_t
*this);
113 * Destroys an proposal_substructure_t object.
115 void (*destroy
) (proposal_substructure_t
*this);
119 * Creates an empty proposal_substructure_t object
121 * @param type PROPOSAL_SUBSTRUCTURE or PROPOSAL_SUBSTRUCTURE_V1
122 * @return proposal_substructure_t object
124 proposal_substructure_t
*proposal_substructure_create(payload_type_t type
);
127 * Creates a proposal_substructure_t from a proposal_t.
129 * @param type PROPOSAL_SUBSTRUCTURE or PROPOSAL_SUBSTRUCTURE_V1
130 * @param proposal proposal to build a substruct out of it
131 * @return proposal_substructure_t object
133 proposal_substructure_t
*proposal_substructure_create_from_proposal(
134 payload_type_t type
, proposal_t
*proposal
);
137 * Creates a proposal_substructure_t from a list of proposal_t (IKEv1 only).
139 * @param proposal proposal to build a substruct out of it
140 * @return IKEv1 proposal_substructure_t PROPOSAL_SUBSTRUCTURE_V1
142 proposal_substructure_t
*proposal_substructure_create_from_proposals(
143 linked_list_t
*proposals
);
145 #endif /** PROPOSAL_SUBSTRUCTURE_H_ @}*/