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 <network/host.h>
32 * Length of a TRAFFIC SELECTOR SUBSTRUCTURE without start and end address.
36 #define TRAFFIC_SELECTOR_HEADER_LENGTH 8
39 typedef enum ts_type_t ts_type_t
;
42 * Traffic selector Types.
48 * A range of IPv4 addresses, represented by two four (4) octet
49 * values. The first value is the beginning IPv4 address
50 * (inclusive) and the second value is the ending IPv4 address
51 * (inclusive). All addresses falling between the two specified
52 * addresses are considered to be within the list.
54 TS_IPV4_ADDR_RANGE
= 7,
56 * A range of IPv6 addresses, represented by two sixteen (16)
57 * octet values. The first value is the beginning IPv6 address
58 * (inclusive) and the second value is the ending IPv6 address
59 * (inclusive). All addresses falling between the two specified
60 * addresses are considered to be within the list.
62 TS_IPV6_ADDR_RANGE
= 8
65 extern mapping_t ts_type_m
[];
67 typedef struct traffic_selector_substructure_t traffic_selector_substructure_t
;
70 * Object representing an IKEv2 TRAFFIC SELECTOR.
72 * The TRAFFIC SELECTOR format is described in draft section 3.13.1.
77 struct traffic_selector_substructure_t
{
79 * The payload_t interface.
81 payload_t payload_interface
;
84 * @brief Get the type of Traffic selector.
86 * @param this calling traffic_selector_substructure_t object
87 * @return type of traffic selector
90 ts_type_t (*get_ts_type
) (traffic_selector_substructure_t
*this);
93 * @brief Set the type of Traffic selector.
95 * @param this calling traffic_selector_substructure_t object
96 * @param ts_type type of traffic selector
98 void (*set_ts_type
) (traffic_selector_substructure_t
*this,ts_type_t ts_type
);
101 * @brief Get the IP protocol ID of Traffic selector.
103 * @param this calling traffic_selector_substructure_t object
104 * @return type of traffic selector
107 u_int8_t (*get_protocol_id
) (traffic_selector_substructure_t
*this);
110 * @brief Set the IP protocol ID of Traffic selector
112 * @param this calling traffic_selector_substructure_t object
113 * @param protocol_id protocol ID of traffic selector
115 void (*set_protocol_id
) (traffic_selector_substructure_t
*this,u_int8_t protocol_id
);
118 * @brief Get the start port and address as host_t object.
120 * Returned host_t object has to get destroyed by the caller.
122 * @param this calling traffic_selector_substructure_t object
123 * @return start host as host_t object
126 host_t
*(*get_start_host
) (traffic_selector_substructure_t
*this);
129 * @brief Set the start port and address as host_t object.
131 * @param this calling traffic_selector_substructure_t object
132 * @param start_host start host as host_t object
134 void (*set_start_host
) (traffic_selector_substructure_t
*this,host_t
*start_host
);
137 * @brief Get the end port and address as host_t object.
139 * Returned host_t object has to get destroyed by the caller.
141 * @param this calling traffic_selector_substructure_t object
142 * @return end host as host_t object
145 host_t
*(*get_end_host
) (traffic_selector_substructure_t
*this);
148 * @brief Set the end port and address as host_t object.
150 * @param this calling traffic_selector_substructure_t object
151 * @param end_host end host as host_t object
153 void (*set_end_host
) (traffic_selector_substructure_t
*this,host_t
*end_host
);
156 * @brief Destroys an traffic_selector_substructure_t object.
158 * @param this traffic_selector_substructure_t object to destroy
160 void (*destroy
) (traffic_selector_substructure_t
*this);
164 * @brief Creates an empty traffic_selector_substructure_t object.
166 * TS type is set to default TS_IPV4_ADDR_RANGE!
168 * @return created traffic_selector_substructure_t object
172 traffic_selector_substructure_t
*traffic_selector_substructure_create();
175 #endif //TRAFFIC_SELECTOR_SUBSTRUCTURE_H_