4 * @brief Interface of sa_payload_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
27 #include <encoding/payloads/payload.h>
28 #include <encoding/payloads/proposal_substructure.h>
29 #include <utils/linked_list.h>
32 * SA_PAYLOAD length in bytes without any proposal substructure.
36 #define SA_PAYLOAD_HEADER_LENGTH 4
38 typedef struct sa_payload_t sa_payload_t
;
41 * @brief Class representing an IKEv2-SA Payload.
43 * The SA Payload format is described in RFC section 3.3.
46 * - sa_payload_create()
47 * - sa_payload_create_from_ike_proposals()
48 * - sa_payload_create_from_proposal()
50 * @todo Add support of algorithms without specified keylength in get_proposals and get_ike_proposals.
56 * The payload_t interface.
58 payload_t payload_interface
;
61 * @brief Creates an iterator of stored proposal_substructure_t objects.
63 * @warning The created iterator has to get destroyed by the caller!
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()!
69 * @param this calling sa_payload_t object
70 * @param[in] forward iterator direction (TRUE: front to end)
71 * @return created iterator_t object
73 iterator_t
*(*create_proposal_substructure_iterator
) (sa_payload_t
*this, bool forward
);
76 * @brief Adds a proposal_substructure_t object to this object.
78 * @warning The added proposal_substructure_t object is
79 * getting destroyed in destroy function of sa_payload_t.
81 * @param this calling sa_payload_t object
82 * @param proposal proposal_substructure_t object to add
84 void (*add_proposal_substructure
) (sa_payload_t
*this,proposal_substructure_t
*proposal
);
87 * @brief Gets the proposals in this payload as a list.
89 * @return a list containing proposal_t s
91 linked_list_t
*(*get_proposals
) (sa_payload_t
*this);
94 * @brief Add a child proposal (AH/ESP) to the payload.
96 * @param proposal child proposal to add to the payload
98 void (*add_proposal
) (sa_payload_t
*this, proposal_t
*proposal
);
101 * @brief Destroys an sa_payload_t object.
103 * @param this sa_payload_t object to destroy
105 void (*destroy
) (sa_payload_t
*this);
109 * @brief Creates an empty sa_payload_t object
111 * @return created sa_payload_t object
115 sa_payload_t
*sa_payload_create(void);
118 * @brief Creates a sa_payload_t object from a list of proposals.
120 * @param proposals list of proposals to build the payload from
121 * @return sa_payload_t object
125 sa_payload_t
*sa_payload_create_from_proposal_list(linked_list_t
*proposals
);
128 * @brief Creates a sa_payload_t object from a single proposal.
130 * This is only for convenience. Use sa_payload_create_from_proposal_list
131 * if you want to add more than one proposal.
133 * @param proposal proposal from which the payload should be built.
134 * @return sa_payload_t object
138 sa_payload_t
*sa_payload_create_from_proposal(proposal_t
*proposal
);
140 #endif /*SA_PAYLOAD_H_*/