- moved linked_list_iterator_t to iterator_t, located in iterator.h
[strongswan.git] / Source / charon / encoding / payloads / sa_payload.h
1 /**
2 * @file sa_payload.h
3 *
4 * @brief Declaration of the class sa_payload_t.
5 *
6 * An object of this type represents an IKEv2 SA-Payload and contains proposal
7 * substructures.
8 *
9 */
10
11 /*
12 * Copyright (C) 2005 Jan Hutter, Martin Willi
13 * Hochschule fuer Technik Rapperswil
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
19 *
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * for more details.
24 */
25
26 #ifndef SA_PAYLOAD_H_
27 #define SA_PAYLOAD_H_
28
29 #include <types.h>
30 #include <encoding/payloads/payload.h>
31 #include <encoding/payloads/proposal_substructure.h>
32 #include <utils/linked_list.h>
33
34 /**
35 * Critical flag must not be set
36 */
37 #define SA_PAYLOAD_CRITICAL_FLAG FALSE;
38
39 /**
40 * SA_PAYLOAD length in bytes without any proposal substructure
41 */
42 #define SA_PAYLOAD_HEADER_LENGTH 4
43
44 typedef struct sa_payload_t sa_payload_t;
45
46 /**
47 * Object representing an IKEv2-SA Payload
48 *
49 * The SA Payload format is described in RFC section 3.3.
50 *
51 */
52 struct sa_payload_t {
53 /**
54 * implements payload_t interface
55 */
56 payload_t payload_interface;
57
58 /**
59 * @brief Creates an iterator of stored proposal_substructure_t objects.
60 *
61 * @warning The created iterator has to get destroyed by the caller!
62 *
63 * @warning When deleting an proposal using this iterator,
64 * the length of this transform substructure has to be refreshed
65 * by calling get_length()!
66 *
67 * @param this calling sa_payload_t object
68 * @param iterator the created iterator is stored at the pointed pointer
69 * @param[in] forward iterator direction (TRUE: front to end)
70 * @return
71 * - SUCCESS or
72 * - OUT_OF_RES if iterator could not be created
73 */
74 status_t (*create_proposal_substructure_iterator) (sa_payload_t *this,iterator_t **iterator, bool forward);
75
76 /**
77 * @brief Adds a proposal_substructure_t object to this object.
78 *
79 * @warning The added proposal_substructure_t object is
80 * getting destroyed in destroy function of sa_payload_t.
81 *
82 * @param this calling sa_payload_t object
83 * @param proposal proposal_substructure_t object to add
84 * @return - SUCCESS if succeeded
85 * - FAILED otherwise
86 */
87 status_t (*add_proposal_substructure) (sa_payload_t *this,proposal_substructure_t *proposal);
88
89 /**
90 * @brief Destroys an sa_payload_t object.
91 *
92 * @param this sa_payload_t object to destroy
93 * @return
94 * SUCCESS in any case
95 */
96 status_t (*destroy) (sa_payload_t *this);
97 };
98
99 /**
100 * @brief Creates an empty sa_payload_t object
101 *
102 * @return
103 * - created sa_payload_t object, or
104 * - NULL if failed
105 */
106
107 sa_payload_t *sa_payload_create();
108
109
110 #endif /*SA_PAYLOAD_H_*/