]> git.ipfire.org Git - thirdparty/strongswan.git/blob - programs/charon/charon/encoding/payloads/sa_payload.h
- import of strongswan-2.7.0
[thirdparty/strongswan.git] / programs / charon / charon / encoding / payloads / sa_payload.h
1 /**
2 * @file sa_payload.h
3 *
4 * @brief Interface of sa_payload_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef SA_PAYLOAD_H_
24 #define SA_PAYLOAD_H_
25
26 #include <types.h>
27 #include <encoding/payloads/payload.h>
28 #include <encoding/payloads/proposal_substructure.h>
29 #include <utils/linked_list.h>
30
31 /**
32 * SA_PAYLOAD length in bytes without any proposal substructure.
33 *
34 * @ingroup payloads
35 */
36 #define SA_PAYLOAD_HEADER_LENGTH 4
37
38 typedef struct sa_payload_t sa_payload_t;
39
40 /**
41 * @brief Class representing an IKEv2-SA Payload.
42 *
43 * The SA Payload format is described in RFC section 3.3.
44 *
45 * @b Constructors:
46 * - sa_payload_create()
47 * - sa_payload_create_from_ike_proposals()
48 * - sa_payload_create_from_proposal()
49 *
50 * @todo Add support of algorithms without specified keylength in get_proposals and get_ike_proposals.
51 *
52 * @ingroup payloads
53 */
54 struct sa_payload_t {
55 /**
56 * The payload_t interface.
57 */
58 payload_t payload_interface;
59
60 /**
61 * @brief Creates an iterator of stored proposal_substructure_t objects.
62 *
63 * @warning The created iterator has to get destroyed by the caller!
64 *
65 * @warning When deleting an proposal using this iterator,
66 * the length of this transform substructure has to be refreshed
67 * by calling get_length()!
68 *
69 * @param this calling sa_payload_t object
70 * @param[in] forward iterator direction (TRUE: front to end)
71 * @return created iterator_t object
72 */
73 iterator_t *(*create_proposal_substructure_iterator) (sa_payload_t *this, bool forward);
74
75 /**
76 * @brief Adds a proposal_substructure_t object to this object.
77 *
78 * @warning The added proposal_substructure_t object is
79 * getting destroyed in destroy function of sa_payload_t.
80 *
81 * @param this calling sa_payload_t object
82 * @param proposal proposal_substructure_t object to add
83 */
84 void (*add_proposal_substructure) (sa_payload_t *this,proposal_substructure_t *proposal);
85
86 /**
87 * @brief Gets the proposals in this payload as a list.
88 *
89 * @return a list containing proposal_t s
90 */
91 linked_list_t *(*get_proposals) (sa_payload_t *this);
92
93 /**
94 * @brief Add a child proposal (AH/ESP) to the payload.
95 *
96 * @param proposal child proposal to add to the payload
97 */
98 void (*add_proposal) (sa_payload_t *this, proposal_t *proposal);
99
100 /**
101 * @brief Destroys an sa_payload_t object.
102 *
103 * @param this sa_payload_t object to destroy
104 */
105 void (*destroy) (sa_payload_t *this);
106 };
107
108 /**
109 * @brief Creates an empty sa_payload_t object
110 *
111 * @return created sa_payload_t object
112 *
113 * @ingroup payloads
114 */
115 sa_payload_t *sa_payload_create();
116
117 /**
118 * @brief Creates a sa_payload_t object from a list of proposals.
119 *
120 * @param proposals list of proposals to build the payload from
121 * @return sa_payload_t object
122 *
123 * @ingroup payloads
124 */
125 sa_payload_t *sa_payload_create_from_proposal_list(linked_list_t *proposals);
126
127 /**
128 * @brief Creates a sa_payload_t object from a single proposal.
129 *
130 * This is only for convenience. Use sa_payload_create_from_proposal_list
131 * if you want to add more than one proposal.
132 *
133 * @param proposal proposal from which the payload should be built.
134 * @return sa_payload_t object
135 *
136 * @ingroup payloads
137 */
138 sa_payload_t *sa_payload_create_from_proposal(proposal_t *proposal);
139
140 #endif /*SA_PAYLOAD_H_*/