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