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>
30 #include <config/init_config.h>
31 #include <config/sa_config.h>
34 * Critical flag must not be set.
38 #define SA_PAYLOAD_CRITICAL_FLAG FALSE;
41 * SA_PAYLOAD length in bytes without any proposal substructure.
45 #define SA_PAYLOAD_HEADER_LENGTH 4
47 typedef struct sa_payload_t sa_payload_t
;
50 * Class representing an IKEv2-SA Payload.
52 * The SA Payload format is described in RFC section 3.3.
58 * The payload_t interface.
60 payload_t payload_interface
;
63 * @brief Creates an iterator of stored proposal_substructure_t objects.
65 * @warning The created iterator has to get destroyed by the caller!
67 * @warning When deleting an proposal using this iterator,
68 * the length of this transform substructure has to be refreshed
69 * by calling get_length()!
71 * @param this calling sa_payload_t object
72 * @param[in] forward iterator direction (TRUE: front to end)
73 * @return created iterator_t object
75 iterator_t
*(*create_proposal_substructure_iterator
) (sa_payload_t
*this, bool forward
);
78 * @brief Adds a proposal_substructure_t object to this object.
80 * @warning The added proposal_substructure_t object is
81 * getting destroyed in destroy function of sa_payload_t.
83 * @param this calling sa_payload_t object
84 * @param proposal proposal_substructure_t object to add
86 void (*add_proposal_substructure
) (sa_payload_t
*this,proposal_substructure_t
*proposal
);
89 * Creates an array of ike_proposal_t's in this SA payload.
91 * An IKE proposal consist of transform of type ENCRYPTION_ALGORITHM,
92 * PSEUDO_RANDOM_FUNCTION, INTEGRITY_ALGORITHM and DIFFIE_HELLMAN_GROUP
94 * @param proposals the pointer to the first entry of ike_proposal_t's is set
95 * @param proposal_count the number of found proposals is written at this location
97 * - SUCCESS if an IKE proposal could be found
98 * - NOT_FOUND if no IKE proposal could be found
99 * - FAILED if a proposal does not contain all needed transforms
102 status_t (*get_ike_proposals
) (sa_payload_t
*this, ike_proposal_t
**proposals
, size_t *proposal_count
);
105 * Creates an array of child_proposal_t's in this SA payload.
107 * @param proposals the pointer to the first entry of child_proposal_t's is set
108 * @param proposal_count the number of found proposals is written at this location
110 * - SUCCESS if child proposals could be found
111 * - NOT_FOUND if no child proposal could be found
112 * - FAILED if a proposal does not contain all needed transforms
114 status_t (*get_child_proposals
) (sa_payload_t
*this, child_proposal_t
**proposals
, size_t *proposal_count
);
117 * @brief Destroys an sa_payload_t object.
119 * @param this sa_payload_t object to destroy
121 void (*destroy
) (sa_payload_t
*this);
125 * @brief Creates an empty sa_payload_t object
127 * @return created sa_payload_t object
131 sa_payload_t
*sa_payload_create();
134 * @brief Creates a sa_payload_t object from array of ike_proposal_t's.
136 * @return created sa_payload_t object
137 * @param proposals pointer to first proposal in array of type ike_proposal_t
138 * @param proposal_count number of ike_proposal_t's in array
142 sa_payload_t
*sa_payload_create_from_ike_proposals(ike_proposal_t
*proposals
, size_t proposal_count
);
145 * @brief Creates a sa_payload_t object from array of child_proposal_t's.
147 * @warning for proposals where AH and ESP is not set, an empty proposal is created.
150 * @return created sa_payload_t object
151 * @param proposals pointer to first proposal in array of type child_proposal_t
152 * @param proposal_count number of child_proposal_t's in array
156 sa_payload_t
*sa_payload_create_from_child_proposals(child_proposal_t
*proposals
, size_t proposal_count
);
158 #endif /*SA_PAYLOAD_H_*/