Merge branch 'ikev1-clean' into ikev1-master
[strongswan.git] / src / libcharon / encoding / payloads / transform_substructure.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
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>.
10 *
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
14 * for more details.
15 */
16
17 /**
18 * @defgroup transform_substructure transform_substructure
19 * @{ @ingroup payloads
20 */
21
22 #ifndef TRANSFORM_SUBSTRUCTURE_H_
23 #define TRANSFORM_SUBSTRUCTURE_H_
24
25 typedef struct transform_substructure_t transform_substructure_t;
26
27 #include <library.h>
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>
36
37 /**
38 * IKEv1 Value for a transform payload.
39 */
40 #define TRANSFORM_TYPE_VALUE 3
41
42 /**
43 * Class representing an IKEv1/IKEv2 transform substructure.
44 */
45 struct transform_substructure_t {
46
47 /**
48 * The payload_t interface.
49 */
50 payload_t payload_interface;
51
52 /**
53 * Adds a transform_attribute_t object to this object.
54 *
55 * @param proposal transform_attribute_t object to add
56 */
57 void (*add_transform_attribute) (transform_substructure_t *this,
58 transform_attribute_t *attribute);
59
60 /**
61 * Sets the next_payload field of this substructure
62 *
63 * If this is the last transform, next payload field is set to 0,
64 * otherwise to 3
65 *
66 * @param is_last When TRUE, next payload field is set to 0, otherwise to 3
67 */
68 void (*set_is_last_transform) (transform_substructure_t *this, bool is_last);
69
70 /**
71 * Get transform type (IKEv2) or the transform number (IKEv1).
72 *
73 * @return Transform type of current transform substructure.
74 */
75 u_int8_t (*get_transform_type_or_number) (transform_substructure_t *this);
76
77 /**
78 * Get transform id of the current transform.
79 *
80 * @return Transform id of current transform substructure.
81 */
82 u_int16_t (*get_transform_id) (transform_substructure_t *this);
83
84 /**
85 * Create an enumerator over transform attributes.
86 *
87 * @return enumerator over transform_attribute_t*
88 */
89 enumerator_t* (*create_attribute_enumerator)(transform_substructure_t *this);
90
91 /**
92 * Destroys an transform_substructure_t object.
93 */
94 void (*destroy) (transform_substructure_t *this);
95 };
96
97 /**
98 * Creates an empty transform_substructure_t object.
99 *
100 * @param type TRANSFORM_SUBSTRUCTURE or TRANSFORM_SUBSTRUCTURE_V1
101 * @return created transform_substructure_t object
102 */
103 transform_substructure_t *transform_substructure_create(payload_type_t type);
104
105 /**
106 * Creates an empty transform_substructure_t object.
107 *
108 * @param type TRANSFORM_SUBSTRUCTURE or TRANSFORM_SUBSTRUCTURE_V1
109 * @param type_or_number Type (IKEv2) or number (IKEv1) of transform
110 * @param id transform id specifc for the transform type
111 * @return transform_substructure_t object
112 */
113 transform_substructure_t *transform_substructure_create_type(payload_type_t type,
114 u_int8_t type_or_number, u_int16_t id);
115
116 #endif /** TRANSFORM_SUBSTRUCTURE_H_ @}*/