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 IKEv1/IKEv2 proposal substructure.
42 struct proposal_substructure_t
{
45 * The payload_t interface.
47 payload_t payload_interface
;
50 * Sets the proposal number of current proposal.
52 * @param id proposal number to set
54 void (*set_proposal_number
) (proposal_substructure_t
*this,
55 u_int8_t proposal_number
);
57 * get proposal number of current proposal.
59 * @return proposal number of current proposal substructure.
61 u_int8_t (*get_proposal_number
) (proposal_substructure_t
*this);
64 * Sets the protocol id of current proposal.
66 * @param id protocol id to set
68 void (*set_protocol_id
) (proposal_substructure_t
*this,
69 u_int8_t protocol_id
);
72 * get protocol id of current proposal.
74 * @return protocol id of current proposal substructure.
76 u_int8_t (*get_protocol_id
) (proposal_substructure_t
*this);
79 * Sets the next_payload field of this substructure
81 * If this is the last proposal, next payload field is set to 0,
84 * @param is_last When TRUE, next payload field is set to 0, otherwise to 2
86 void (*set_is_last_proposal
) (proposal_substructure_t
*this, bool is_last
);
89 * Returns the currently set SPI of this proposal.
91 * @return chunk_t pointing to the value
93 chunk_t (*get_spi
) (proposal_substructure_t
*this);
96 * Sets the SPI of the current proposal.
98 * @warning SPI is getting copied
100 * @param spi chunk_t pointing to the value to set
102 void (*set_spi
) (proposal_substructure_t
*this, chunk_t spi
);
105 * Get a proposal_t from the propsal_substructure_t.
109 proposal_t
* (*get_proposal
) (proposal_substructure_t
*this);
112 * Create an enumerator over transform substructures.
114 * @return enumerator over transform_substructure_t
116 enumerator_t
* (*create_substructure_enumerator
)(proposal_substructure_t
*this);
119 * Destroys an proposal_substructure_t object.
121 void (*destroy
) (proposal_substructure_t
*this);
125 * Creates an empty proposal_substructure_t object
127 * @param type PROPOSAL_SUBSTRUCTURE or PROPOSAL_SUBSTRUCTURE_V1
128 * @return proposal_substructure_t object
130 proposal_substructure_t
*proposal_substructure_create(payload_type_t type
);
133 * Creates a proposal_substructure_t from a proposal_t.
135 * @param type PROPOSAL_SUBSTRUCTURE or PROPOSAL_SUBSTRUCTURE_V1
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 payload_type_t type
, proposal_t
*proposal
);
142 #endif /** PROPOSAL_SUBSTRUCTURE_H_ @}*/