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 transform_substructure transform_substructure
19 * @{ @ingroup payloads
22 #ifndef TRANSFORM_SUBSTRUCTURE_H_
23 #define TRANSFORM_SUBSTRUCTURE_H_
25 typedef struct transform_substructure_t transform_substructure_t
;
28 #include <encoding/payloads/payload.h>
29 #include <encoding/payloads/transform_attribute.h>
30 #include <utils/linked_list.h>
31 #include <crypto/diffie_hellman.h>
32 #include <crypto/signers/signer.h>
33 #include <crypto/prfs/prf.h>
34 #include <crypto/crypters/crypter.h>
35 #include <config/proposal.h>
38 * IKEv1 Value for a transform payload.
40 #define TRANSFORM_TYPE_VALUE 3
43 * Length of the transform substructure header in bytes.
45 #define TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH 8
48 * Class representing an IKEv2- TRANSFORM SUBSTRUCTURE.
50 * The TRANSFORM SUBSTRUCTURE format is described in RFC section 3.3.2.
52 struct transform_substructure_t
{
55 * The payload_t interface.
57 payload_t payload_interface
;
60 * Adds a transform_attribute_t object to this object.
62 * @param proposal transform_attribute_t object to add
64 void (*add_transform_attribute
) (transform_substructure_t
*this,
65 transform_attribute_t
*attribute
);
68 * Sets the next_payload field of this substructure
70 * If this is the last transform, next payload field is set to 0,
73 * @param is_last When TRUE, next payload field is set to 0, otherwise to 3
75 void (*set_is_last_transform
) (transform_substructure_t
*this, bool is_last
);
78 * get transform type of the current transform.
80 * @return Transform type of current transform substructure.
82 u_int8_t (*get_transform_type
) (transform_substructure_t
*this);
85 * Get transform id of the current transform.
87 * @return Transform id of current transform substructure.
89 u_int16_t (*get_transform_id
) (transform_substructure_t
*this);
92 * Get transform id of the current transform.
94 * @param key_length The key length is written to this location
96 * - SUCCESS if a key length attribute is contained
97 * - FAILED if no key length attribute is part of this
98 * transform or key length uses more then 16 bit!
100 status_t (*get_key_length
) (transform_substructure_t
*this,
101 u_int16_t
*key_length
);
104 * Destroys an transform_substructure_t object.
106 void (*destroy
) (transform_substructure_t
*this);
110 * Creates an empty transform_substructure_t object.
112 * @return created transform_substructure_t object
114 transform_substructure_t
*transform_substructure_create(void);
117 * Creates an empty transform_substructure_t object.
119 * @param type type of transform to create
120 * @param id transform id specifc for the transform type
121 * @param key_length key length for key length attribute, 0 to omit
122 * @return transform_substructure_t object
124 transform_substructure_t
*transform_substructure_create_type(
125 transform_type_t type
, u_int16_t id
, u_int16_t key_length
);
127 #endif /** TRANSFORM_SUBSTRUCTURE_H_ @}*/