- implemented sa_config
[strongswan.git] / Source / 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 * Critical flag must not be set.
33 *
34 * @ingroup payloads
35 */
36 #define SA_PAYLOAD_CRITICAL_FLAG FALSE;
37
38 /**
39 * SA_PAYLOAD length in bytes without any proposal substructure.
40 *
41 * @ingroup payloads
42 */
43 #define SA_PAYLOAD_HEADER_LENGTH 4
44
45 typedef struct sa_payload_t sa_payload_t;
46
47 /**
48 * Class representing an IKEv2-SA Payload.
49 *
50 * The SA Payload format is described in RFC section 3.3.
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 Destroys an sa_payload_t object.
88 *
89 * @param this sa_payload_t object to destroy
90 */
91 void (*destroy) (sa_payload_t *this);
92 };
93
94 /**
95 * @brief Creates an empty sa_payload_t object
96 *
97 * @return created sa_payload_t object
98 *
99 * @ingroup payloads
100 */
101 sa_payload_t *sa_payload_create();
102
103
104 #endif /*SA_PAYLOAD_H_*/