2 * @file traffic_selector_substructure.h
4 * @brief Interface of traffic_selector_substructure_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
24 #ifndef TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
25 #define TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
28 #include <encoding/payloads/payload.h>
29 #include <utils/host.h>
30 #include <config/traffic_selector.h>
33 * Length of a TRAFFIC SELECTOR SUBSTRUCTURE without start and end address.
37 #define TRAFFIC_SELECTOR_HEADER_LENGTH 8
39 typedef struct traffic_selector_substructure_t traffic_selector_substructure_t
;
42 * @brief Class representing an IKEv2 TRAFFIC SELECTOR.
44 * The TRAFFIC SELECTOR format is described in RFC section 3.13.1.
47 * - traffic_selector_substructure_create()
48 * - traffic_selector_substructure_create_from_traffic_selector()
52 struct traffic_selector_substructure_t
{
54 * The payload_t interface.
56 payload_t payload_interface
;
59 * @brief Get the type of Traffic selector.
61 * @param this calling traffic_selector_substructure_t object
62 * @return type of traffic selector
65 ts_type_t (*get_ts_type
) (traffic_selector_substructure_t
*this);
68 * @brief Set the type of Traffic selector.
70 * @param this calling traffic_selector_substructure_t object
71 * @param ts_type type of traffic selector
73 void (*set_ts_type
) (traffic_selector_substructure_t
*this,ts_type_t ts_type
);
76 * @brief Get the IP protocol ID of Traffic selector.
78 * @param this calling traffic_selector_substructure_t object
79 * @return type of traffic selector
82 u_int8_t (*get_protocol_id
) (traffic_selector_substructure_t
*this);
85 * @brief Set the IP protocol ID of Traffic selector
87 * @param this calling traffic_selector_substructure_t object
88 * @param protocol_id protocol ID of traffic selector
90 void (*set_protocol_id
) (traffic_selector_substructure_t
*this,u_int8_t protocol_id
);
93 * @brief Get the start port and address as host_t object.
95 * Returned host_t object has to get destroyed by the caller.
97 * @param this calling traffic_selector_substructure_t object
98 * @return start host as host_t object
101 host_t
*(*get_start_host
) (traffic_selector_substructure_t
*this);
104 * @brief Set the start port and address as host_t object.
106 * @param this calling traffic_selector_substructure_t object
107 * @param start_host start host as host_t object
109 void (*set_start_host
) (traffic_selector_substructure_t
*this,host_t
*start_host
);
112 * @brief Get the end port and address as host_t object.
114 * Returned host_t object has to get destroyed by the caller.
116 * @param this calling traffic_selector_substructure_t object
117 * @return end host as host_t object
120 host_t
*(*get_end_host
) (traffic_selector_substructure_t
*this);
123 * @brief Set the end port and address as host_t object.
125 * @param this calling traffic_selector_substructure_t object
126 * @param end_host end host as host_t object
128 void (*set_end_host
) (traffic_selector_substructure_t
*this,host_t
*end_host
);
131 * @brief Get a traffic_selector_t from this substructure.
133 * @warning traffic_selector_t must be destroyed after usage.
135 * @param this calling traffic_selector_substructure_t object
136 * @return contained traffic_selector_t
138 traffic_selector_t
*(*get_traffic_selector
) (traffic_selector_substructure_t
*this);
141 * @brief Destroys an traffic_selector_substructure_t object.
143 * @param this traffic_selector_substructure_t object to destroy
145 void (*destroy
) (traffic_selector_substructure_t
*this);
149 * @brief Creates an empty traffic_selector_substructure_t object.
151 * TS type is set to default TS_IPV4_ADDR_RANGE!
153 * @return traffic_selector_substructure_t object
157 traffic_selector_substructure_t
*traffic_selector_substructure_create(void);
160 * @brief Creates an initialized traffif selector substructure using
161 * the values from a traffic_selector_t.
163 * @param traffic_selector traffic_selector_t to use for initialization
164 * @return traffic_selector_substructure_t object
168 traffic_selector_substructure_t
*traffic_selector_substructure_create_from_traffic_selector(traffic_selector_t
*traffic_selector
);
171 #endif /* /TRAFFIC_SELECTOR_SUBSTRUCTURE_H_ */