]> git.ipfire.org Git - people/ms/strongswan.git/blob - programs/charon/charon/encoding/payloads/ts_payload.h
- renamed get_block_size of hasher
[people/ms/strongswan.git] / programs / charon / charon / encoding / payloads / ts_payload.h
1 /**
2 * @file ts_payload.h
3 *
4 * @brief Interface of ts_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
24 #ifndef TS_PAYLOAD_H_
25 #define TS_PAYLOAD_H_
26
27 #include <types.h>
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>
32
33 /**
34 * Length of a TS payload without the Traffic selectors.
35 *
36 * @ingroup payloads
37 */
38 #define TS_PAYLOAD_HEADER_LENGTH 8
39
40
41 typedef struct ts_payload_t ts_payload_t;
42
43 /**
44 * @brief Class representing an IKEv2 TS payload.
45 *
46 * The TS payload format is described in RFC section 3.13.
47 *
48 * @b Constructors:
49 * - ts_payload_create()
50 * - ts_payload_create_from_traffic_selectors()
51 *
52 * @ingroup payloads
53 */
54 struct ts_payload_t {
55 /**
56 * The payload_t interface.
57 */
58 payload_t payload_interface;
59
60 /**
61 * @brief Get the type of TSpayload (TSi or TSr).
62 *
63 * @param this calling id_payload_t object
64 * @return
65 * - TRUE if this payload is of type TSi
66 * - FALSE if this payload is of type TSr
67 */
68 bool (*get_initiator) (ts_payload_t *this);
69
70 /**
71 * @brief Set the type of TS payload (TSi or TSr).
72 *
73 * @param this calling id_payload_t object
74 * @param is_initiator
75 * - TRUE if this payload is of type TSi
76 * - FALSE if this payload is of type TSr
77 */
78 void (*set_initiator) (ts_payload_t *this,bool is_initiator);
79
80 /**
81 * @brief Adds a traffic_selector_substructure_t object to this object.
82 *
83 * @warning The added traffic_selector_substructure_t object is
84 * getting destroyed in destroy function of ts_payload_t.
85 *
86 * @param this calling ts_payload_t object
87 * @param traffic_selector traffic_selector_substructure_t object to add
88 */
89 void (*add_traffic_selector_substructure) (ts_payload_t *this,traffic_selector_substructure_t *traffic_selector);
90
91 /**
92 * @brief Creates an iterator of stored traffic_selector_substructure_t objects.
93 *
94 * @warning The created iterator has to get destroyed by the caller!
95 *
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!
99 *
100 * @param this calling ts_payload_t object
101 * @param[in] forward iterator direction (TRUE: front to end)
102 * @return created iterator_t object
103 */
104 iterator_t *(*create_traffic_selector_substructure_iterator) (ts_payload_t *this, bool forward);
105
106 /**
107 * @brief Get a list of nested traffic selectors as traffic_selector_t.
108 *
109 * Resulting list and its traffic selectors must be destroyed after usage
110 *
111 * @param this calling ts_payload_t object
112 * @return list of traffic selectors
113 */
114 linked_list_t *(*get_traffic_selectors) (ts_payload_t *this);
115
116 /**
117 * @brief Destroys an ts_payload_t object.
118 *
119 * @param this ts_payload_t object to destroy
120 */
121 void (*destroy) (ts_payload_t *this);
122 };
123
124 /**
125 * @brief Creates an empty ts_payload_t object.
126 *
127 *
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
132 *
133 * @ingroup payloads
134 */
135 ts_payload_t *ts_payload_create(bool is_initiator);
136
137 /**
138 * @brief Creates ts_payload with a list of traffic_selector_t
139 *
140 *
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
146 *
147 * @ingroup payloads
148 */
149 ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator, linked_list_t *traffic_selectors);
150
151
152 #endif /* TS_PAYLOAD_H_ */