updated Doxyfile
[strongswan.git] / src / charon / encoding / payloads / sa_payload.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 * $Id$
17 */
18
19 /**
20 * @defgroup sa_payload sa_payload
21 * @{ @ingroup payloads
22 */
23
24 #ifndef SA_PAYLOAD_H_
25 #define SA_PAYLOAD_H_
26
27 typedef struct sa_payload_t sa_payload_t;
28
29 #include <library.h>
30 #include <encoding/payloads/payload.h>
31 #include <encoding/payloads/proposal_substructure.h>
32 #include <utils/linked_list.h>
33
34 /**
35 * SA_PAYLOAD length in bytes without any proposal substructure.
36 */
37 #define SA_PAYLOAD_HEADER_LENGTH 4
38
39 /**
40 * Class representing an IKEv2-SA Payload.
41 *
42 * The SA Payload format is described in RFC section 3.3.
43 */
44 struct sa_payload_t {
45 /**
46 * The payload_t interface.
47 */
48 payload_t payload_interface;
49
50 /**
51 * Creates an iterator of stored proposal_substructure_t objects.
52 *
53 * When deleting an proposal using this iterator,
54 * the length of this transform substructure has to be refreshed
55 * by calling get_length()!
56 *
57 * @param forward iterator direction (TRUE: front to end)
58 * @return created iterator_t object
59 */
60 iterator_t *(*create_proposal_substructure_iterator) (sa_payload_t *this,
61 bool forward);
62
63 /**
64 * Adds a proposal_substructure_t object to this object.
65 *
66 * @param proposal proposal_substructure_t object to add
67 */
68 void (*add_proposal_substructure) (sa_payload_t *this,
69 proposal_substructure_t *proposal);
70
71 /**
72 * Gets the proposals in this payload as a list.
73 *
74 * @return a list containing proposal_t s
75 */
76 linked_list_t *(*get_proposals) (sa_payload_t *this);
77
78 /**
79 * Add a child proposal (AH/ESP) to the payload.
80 *
81 * @param proposal child proposal to add to the payload
82 */
83 void (*add_proposal) (sa_payload_t *this, proposal_t *proposal);
84
85 /**
86 * Destroys an sa_payload_t object.
87 */
88 void (*destroy) (sa_payload_t *this);
89 };
90
91 /**
92 * Creates an empty sa_payload_t object
93 *
94 * @return created sa_payload_t object
95 */
96 sa_payload_t *sa_payload_create(void);
97
98 /**
99 * Creates a sa_payload_t object from a list of proposals.
100 *
101 * @param proposals list of proposals to build the payload from
102 * @return sa_payload_t object
103 */
104 sa_payload_t *sa_payload_create_from_proposal_list(linked_list_t *proposals);
105
106 /**
107 * Creates a sa_payload_t object from a single proposal.
108 *
109 * This is only for convenience. Use sa_payload_create_from_proposal_list
110 * if you want to add more than one proposal.
111 *
112 * @param proposal proposal from which the payload should be built.
113 * @return sa_payload_t object
114 */
115 sa_payload_t *sa_payload_create_from_proposal(proposal_t *proposal);
116
117 #endif /** SA_PAYLOAD_H_ @}*/