updated Doxyfile
[strongswan.git] / src / charon / encoding / payloads / traffic_selector_substructure.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * $Id$
17 */
18
19 /**
20 * @defgroup traffic_selector_substructure traffic_selector_substructure
21 * @{ @ingroup payloads
22 */
23
24 #ifndef TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
25 #define TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
26
27 typedef struct traffic_selector_substructure_t traffic_selector_substructure_t;
28
29 #include <library.h>
30 #include <encoding/payloads/payload.h>
31 #include <utils/host.h>
32 #include <config/traffic_selector.h>
33
34 /**
35 * Length of a TRAFFIC SELECTOR SUBSTRUCTURE without start and end address.
36 */
37 #define TRAFFIC_SELECTOR_HEADER_LENGTH 8
38
39 /**
40 * Class representing an IKEv2 TRAFFIC SELECTOR.
41 *
42 * The TRAFFIC SELECTOR format is described in RFC section 3.13.1.
43 */
44 struct traffic_selector_substructure_t {
45 /**
46 * The payload_t interface.
47 */
48 payload_t payload_interface;
49
50 /**
51 * Get the type of Traffic selector.
52 *
53 * @return type of traffic selector
54 *
55 */
56 ts_type_t (*get_ts_type) (traffic_selector_substructure_t *this);
57
58 /**
59 * Set the type of Traffic selector.
60 *
61 * @param ts_type type of traffic selector
62 */
63 void (*set_ts_type) (traffic_selector_substructure_t *this,
64 ts_type_t ts_type);
65
66 /**
67 * Get the IP protocol ID of Traffic selector.
68 *
69 * @return type of traffic selector
70 *
71 */
72 u_int8_t (*get_protocol_id) (traffic_selector_substructure_t *this);
73
74 /**
75 * Set the IP protocol ID of Traffic selector
76 *
77 * @param protocol_id protocol ID of traffic selector
78 */
79 void (*set_protocol_id) (traffic_selector_substructure_t *this,
80 u_int8_t protocol_id);
81
82 /**
83 * Get the start port and address as host_t object.
84 *
85 * Returned host_t object has to get destroyed by the caller.
86 *
87 * @return start host as host_t object
88 *
89 */
90 host_t *(*get_start_host) (traffic_selector_substructure_t *this);
91
92 /**
93 * Set the start port and address as host_t object.
94 *
95 * @param start_host start host as host_t object
96 */
97 void (*set_start_host) (traffic_selector_substructure_t *this,
98 host_t *start_host);
99
100 /**
101 * Get the end port and address as host_t object.
102 *
103 * Returned host_t object has to get destroyed by the caller.
104 *
105 * @return end host as host_t object
106 *
107 */
108 host_t *(*get_end_host) (traffic_selector_substructure_t *this);
109
110 /**
111 * Set the end port and address as host_t object.
112 *
113 * @param end_host end host as host_t object
114 */
115 void (*set_end_host) (traffic_selector_substructure_t *this,
116 host_t *end_host);
117
118 /**
119 * Get a traffic_selector_t from this substructure.
120 *
121 * @warning traffic_selector_t must be destroyed after usage.
122 *
123 * @return contained traffic_selector_t
124 */
125 traffic_selector_t *(*get_traffic_selector) (
126 traffic_selector_substructure_t *this);
127
128 /**
129 * Destroys an traffic_selector_substructure_t object.
130 */
131 void (*destroy) (traffic_selector_substructure_t *this);
132 };
133
134 /**
135 * Creates an empty traffic_selector_substructure_t object.
136 *
137 * TS type is set to default TS_IPV4_ADDR_RANGE!
138 *
139 * @return traffic_selector_substructure_t object
140 */
141 traffic_selector_substructure_t *traffic_selector_substructure_create(void);
142
143 /**
144 * Creates an initialized traffif selector substructure using
145 * the values from a traffic_selector_t.
146 *
147 * @param traffic_selector traffic_selector_t to use for initialization
148 * @return traffic_selector_substructure_t object
149 */
150 traffic_selector_substructure_t *traffic_selector_substructure_create_from_traffic_selector(
151 traffic_selector_t *traffic_selector);
152
153 #endif /** TRAFFIC_SELECTOR_SUBSTRUCTURE_H_ @}*/