- creation of ts payloads using ts
[strongswan.git] / Source / charon / encoding / payloads / traffic_selector_substructure.h
1 /**
2 * @file traffic_selector_substructure.h
3 *
4 * @brief Interface of traffic_selector_substructure_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 TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
25 #define TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
26
27 #include <types.h>
28 #include <encoding/payloads/payload.h>
29 #include <network/host.h>
30 #include <config/traffic_selector.h>
31
32 /**
33 * Length of a TRAFFIC SELECTOR SUBSTRUCTURE without start and end address.
34 *
35 * @ingroup payloads
36 */
37 #define TRAFFIC_SELECTOR_HEADER_LENGTH 8
38
39 typedef struct traffic_selector_substructure_t traffic_selector_substructure_t;
40
41 /**
42 * Object representing an IKEv2 TRAFFIC SELECTOR.
43 *
44 * The TRAFFIC SELECTOR format is described in draft section 3.13.1.
45 *
46 * @ingroup payloads
47 *
48 */
49 struct traffic_selector_substructure_t {
50 /**
51 * The payload_t interface.
52 */
53 payload_t payload_interface;
54
55 /**
56 * @brief Get the type of Traffic selector.
57 *
58 * @param this calling traffic_selector_substructure_t object
59 * @return type of traffic selector
60 *
61 */
62 ts_type_t (*get_ts_type) (traffic_selector_substructure_t *this);
63
64 /**
65 * @brief Set the type of Traffic selector.
66 *
67 * @param this calling traffic_selector_substructure_t object
68 * @param ts_type type of traffic selector
69 */
70 void (*set_ts_type) (traffic_selector_substructure_t *this,ts_type_t ts_type);
71
72 /**
73 * @brief Get the IP protocol ID of Traffic selector.
74 *
75 * @param this calling traffic_selector_substructure_t object
76 * @return type of traffic selector
77 *
78 */
79 u_int8_t (*get_protocol_id) (traffic_selector_substructure_t *this);
80
81 /**
82 * @brief Set the IP protocol ID of Traffic selector
83 *
84 * @param this calling traffic_selector_substructure_t object
85 * @param protocol_id protocol ID of traffic selector
86 */
87 void (*set_protocol_id) (traffic_selector_substructure_t *this,u_int8_t protocol_id);
88
89 /**
90 * @brief Get the start port and address as host_t object.
91 *
92 * Returned host_t object has to get destroyed by the caller.
93 *
94 * @param this calling traffic_selector_substructure_t object
95 * @return start host as host_t object
96 *
97 */
98 host_t *(*get_start_host) (traffic_selector_substructure_t *this);
99
100 /**
101 * @brief Set the start port and address as host_t object.
102 *
103 * @param this calling traffic_selector_substructure_t object
104 * @param start_host start host as host_t object
105 */
106 void (*set_start_host) (traffic_selector_substructure_t *this,host_t *start_host);
107
108 /**
109 * @brief Get the end port and address as host_t object.
110 *
111 * Returned host_t object has to get destroyed by the caller.
112 *
113 * @param this calling traffic_selector_substructure_t object
114 * @return end host as host_t object
115 *
116 */
117 host_t *(*get_end_host) (traffic_selector_substructure_t *this);
118
119 /**
120 * @brief Set the end port and address as host_t object.
121 *
122 * @param this calling traffic_selector_substructure_t object
123 * @param end_host end host as host_t object
124 */
125 void (*set_end_host) (traffic_selector_substructure_t *this,host_t *end_host);
126
127 /**
128 * @brief Get a traffic_selector_t from this substructure.
129 *
130 * @warning traffic_selector_t must be destroyed after usage.
131 *
132 * @param this calling traffic_selector_substructure_t object
133 * @return contained traffic_selector_t
134 */
135 traffic_selector_t *(*get_traffic_selector) (traffic_selector_substructure_t *this);
136
137 /**
138 * @brief Destroys an traffic_selector_substructure_t object.
139 *
140 * @param this traffic_selector_substructure_t object to destroy
141 */
142 void (*destroy) (traffic_selector_substructure_t *this);
143 };
144
145 /**
146 * @brief Creates an empty traffic_selector_substructure_t object.
147 *
148 * TS type is set to default TS_IPV4_ADDR_RANGE!
149 *
150 * @return created traffic_selector_substructure_t object
151 *
152 * @ingroup payloads
153 */
154 traffic_selector_substructure_t *traffic_selector_substructure_create();
155
156 /**
157 * @brief Creates an initialized traffif selector substructure using
158 * the values from a traffic_selector_t.
159 *
160 * @param traffic_selector traffic_selector_t to use for initialization
161 * @return created traffic_selector_substructure_t object
162 *
163 * @ingroup payloads
164 */
165 traffic_selector_substructure_t *traffic_selector_substructure_create_from_traffic_selector(traffic_selector_t *traffic_selector);
166
167
168 #endif //TRAFFIC_SELECTOR_SUBSTRUCTURE_H_