]>
Commit | Line | Data |
---|---|---|
7da522ba JH |
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> | |
a527a426 | 28 | #include <utils/linked_list.h> |
03283349 | 29 | #include <config/traffic_selector.h> |
7da522ba JH |
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 | /** | |
c3dc864e | 44 | * @brief Class representing an IKEv2 TS payload. |
7da522ba | 45 | * |
8a491129 | 46 | * The TS payload format is described in RFC section 3.13. |
7da522ba | 47 | * |
c3dc864e MW |
48 | * @b Constructors: |
49 | * - ts_payload_create() | |
50 | * - ts_payload_create_from_traffic_selectors() | |
7da522ba | 51 | * |
c3dc864e | 52 | * @ingroup payloads |
7da522ba JH |
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 | |
7da522ba JH |
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 | |
7da522ba JH |
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); | |
03283349 MW |
105 | |
106 | /** | |
a527a426 | 107 | * @brief Get a list of nested traffic selectors as traffic_selector_t. |
03283349 | 108 | * |
a527a426 | 109 | * Resulting list and its traffic selectors must be destroyed after usage |
03283349 MW |
110 | * |
111 | * @param this calling ts_payload_t object | |
a527a426 | 112 | * @return list of traffic selectors |
03283349 | 113 | */ |
a527a426 | 114 | linked_list_t *(*get_traffic_selectors) (ts_payload_t *this); |
7da522ba JH |
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 | /** | |
03283349 | 125 | * @brief Creates an empty ts_payload_t object. |
7da522ba JH |
126 | * |
127 | * | |
128 | * @param is_initiator | |
129 | * - TRUE if this payload is of type TSi | |
130 | * - FALSE if this payload is of type TSr | |
c3dc864e | 131 | * @return ts_payload_t object |
7da522ba JH |
132 | * |
133 | * @ingroup payloads | |
134 | */ | |
135 | ts_payload_t *ts_payload_create(bool is_initiator); | |
136 | ||
03283349 | 137 | /** |
a527a426 | 138 | * @brief Creates ts_payload with a list of traffic_selector_t |
03283349 MW |
139 | * |
140 | * | |
141 | * @param is_initiator | |
19f78a6f MW |
142 | * - TRUE if this payload is of type TSi |
143 | * - FALSE if this payload is of type TSr | |
a527a426 | 144 | * @param traffic_selectors list of traffic selectors to include |
19f78a6f | 145 | * @return ts_payload_t object |
03283349 MW |
146 | * |
147 | * @ingroup payloads | |
148 | */ | |
a527a426 | 149 | ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator, linked_list_t *traffic_selectors); |
03283349 | 150 | |
7da522ba | 151 | |
16b9a73c | 152 | #endif /* TS_PAYLOAD_H_ */ |