4 * @brief Interface of ts_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
28 #include <utils/linked_list.h>
29 #include <config/traffic_selector.h>
30 #include <encoding/payloads/payload.h>
31 #include <encoding/payloads/traffic_selector_substructure.h>
34 * Length of a TS payload without the Traffic selectors.
38 #define TS_PAYLOAD_HEADER_LENGTH 8
41 typedef struct ts_payload_t ts_payload_t
;
44 * @brief Class representing an IKEv2 TS payload.
46 * The TS payload format is described in RFC section 3.13.
49 * - ts_payload_create()
50 * - ts_payload_create_from_traffic_selectors()
56 * The payload_t interface.
58 payload_t payload_interface
;
61 * @brief Get the type of TSpayload (TSi or TSr).
63 * @param this calling id_payload_t object
65 * - TRUE if this payload is of type TSi
66 * - FALSE if this payload is of type TSr
68 bool (*get_initiator
) (ts_payload_t
*this);
71 * @brief Set the type of TS payload (TSi or TSr).
73 * @param this calling id_payload_t object
75 * - TRUE if this payload is of type TSi
76 * - FALSE if this payload is of type TSr
78 void (*set_initiator
) (ts_payload_t
*this,bool is_initiator
);
81 * @brief Adds a traffic_selector_substructure_t object to this object.
83 * @warning The added traffic_selector_substructure_t object is
84 * getting destroyed in destroy function of ts_payload_t.
86 * @param this calling ts_payload_t object
87 * @param traffic_selector traffic_selector_substructure_t object to add
89 void (*add_traffic_selector_substructure
) (ts_payload_t
*this,traffic_selector_substructure_t
*traffic_selector
);
92 * @brief Creates an iterator of stored traffic_selector_substructure_t objects.
94 * @warning The created iterator has to get destroyed by the caller!
96 * @warning When removing an traffic_selector_substructure_t object
97 * using this iterator, the length of this payload
98 * has to get refreshed by calling payload_t.get_length!
100 * @param this calling ts_payload_t object
101 * @param[in] forward iterator direction (TRUE: front to end)
102 * @return created iterator_t object
104 iterator_t
*(*create_traffic_selector_substructure_iterator
) (ts_payload_t
*this, bool forward
);
107 * @brief Get a list of nested traffic selectors as traffic_selector_t.
109 * Resulting list and its traffic selectors must be destroyed after usage
111 * @param this calling ts_payload_t object
112 * @return list of traffic selectors
114 linked_list_t
*(*get_traffic_selectors
) (ts_payload_t
*this);
117 * @brief Destroys an ts_payload_t object.
119 * @param this ts_payload_t object to destroy
121 void (*destroy
) (ts_payload_t
*this);
125 * @brief Creates an empty ts_payload_t object.
128 * @param is_initiator
129 * - TRUE if this payload is of type TSi
130 * - FALSE if this payload is of type TSr
131 * @return ts_payload_t object
135 ts_payload_t
*ts_payload_create(bool is_initiator
);
138 * @brief Creates ts_payload with a list of traffic_selector_t
141 * @param is_initiator
142 * - TRUE if this payload is of type TSi
143 * - FALSE if this payload is of type TSr
144 * @param traffic_selectors list of traffic selectors to include
145 * @return ts_payload_t object
149 ts_payload_t
*ts_payload_create_from_traffic_selectors(bool is_initiator
, linked_list_t
*traffic_selectors
);
152 #endif /* TS_PAYLOAD_H_ */