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>
35 * Length of the proposal substructure header (without spi).
37 #define PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH 8
40 * Class representing an IKEv2-PROPOSAL SUBSTRUCTURE.
42 * The PROPOSAL SUBSTRUCTURE format is described in RFC section 3.3.1.
44 struct proposal_substructure_t
{
47 * The payload_t interface.
49 payload_t payload_interface
;
52 * Sets the proposal number of current proposal.
54 * @param id proposal number to set
56 void (*set_proposal_number
) (proposal_substructure_t
*this,
57 u_int8_t proposal_number
);
59 * get proposal number of current proposal.
61 * @return proposal number of current proposal substructure.
63 u_int8_t (*get_proposal_number
) (proposal_substructure_t
*this);
66 * Sets the protocol id of current proposal.
68 * @param id protocol id to set
70 void (*set_protocol_id
) (proposal_substructure_t
*this,
71 u_int8_t protocol_id
);
74 * get protocol id of current proposal.
76 * @return protocol id of current proposal substructure.
78 u_int8_t (*get_protocol_id
) (proposal_substructure_t
*this);
81 * Sets the next_payload field of this substructure
83 * If this is the last proposal, next payload field is set to 0,
86 * @param is_last When TRUE, next payload field is set to 0, otherwise to 2
88 void (*set_is_last_proposal
) (proposal_substructure_t
*this, bool is_last
);
91 * Returns the currently set SPI of this proposal.
93 * @return chunk_t pointing to the value
95 chunk_t (*get_spi
) (proposal_substructure_t
*this);
98 * Sets the SPI of the current proposal.
100 * @warning SPI is getting copied
102 * @param spi chunk_t pointing to the value to set
104 void (*set_spi
) (proposal_substructure_t
*this, chunk_t spi
);
107 * Get a proposal_t from the propsal_substructure_t.
111 proposal_t
* (*get_proposal
) (proposal_substructure_t
*this);
114 * Create an enumerator over transform substructures.
116 * @return enumerator over transform_substructure_t
118 enumerator_t
* (*create_substructure_enumerator
)(proposal_substructure_t
*this);
121 * Destroys an proposal_substructure_t object.
123 void (*destroy
) (proposal_substructure_t
*this);
127 * Creates an empty proposal_substructure_t object
129 * @return proposal_substructure_t object
131 proposal_substructure_t
*proposal_substructure_create(void);
134 * Creates a proposal_substructure_t from a proposal_t.
136 * @param proposal proposal to build a substruct out of it
137 * @return proposal_substructure_t object
139 proposal_substructure_t
*proposal_substructure_create_from_proposal(
140 proposal_t
*proposal
);
142 #endif /** PROPOSAL_SUBSTRUCTURE_H_ @}*/