]> git.ipfire.org Git - people/ms/strongswan.git/blob - programs/charon/charon/encoding/payloads/id_payload.h
- import of strongswan-2.7.0
[people/ms/strongswan.git] / programs / charon / charon / encoding / payloads / id_payload.h
1 /**
2 * @file id_payload.h
3 *
4 * @brief Interface of id_payload_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 ID_PAYLOAD_H_
25 #define ID_PAYLOAD_H_
26
27 #include <types.h>
28 #include <utils/identification.h>
29 #include <encoding/payloads/payload.h>
30
31 /**
32 * Length of a id payload without the data in bytes.
33 *
34 * @ingroup payloads
35 */
36 #define ID_PAYLOAD_HEADER_LENGTH 8
37
38
39 typedef struct id_payload_t id_payload_t;
40
41 /**
42 * Object representing an IKEv2 ID payload.
43 *
44 * The ID payload format is described in RFC section 3.5.
45 *
46 * @b Constructors:
47 * - id_payload_create_from_identification()
48 * - id_payload_create()
49 *
50 * @ingroup payloads
51 */
52 struct id_payload_t {
53 /**
54 * The payload_t interface.
55 */
56 payload_t payload_interface;
57
58 /**
59 * @brief Set the ID type.
60 *
61 * @param this calling id_payload_t object
62 * @param type Type of ID
63 */
64 void (*set_id_type) (id_payload_t *this, id_type_t type);
65
66 /**
67 * @brief Get the ID type.
68 *
69 * @param this calling id_payload_t object
70 * @return type of the ID
71 */
72 id_type_t (*get_id_type) (id_payload_t *this);
73
74 /**
75 * @brief Set the ID data.
76 *
77 * Data are getting cloned.
78 *
79 * @param this calling id_payload_t object
80 * @param data ID data as chunk_t
81 */
82 void (*set_data) (id_payload_t *this, chunk_t data);
83
84 /**
85 * @brief Get the ID data.
86 *
87 * Returned data are a copy of the internal one
88 *
89 * @param this calling id_payload_t object
90 * @return ID data as chunk_t
91 */
92 chunk_t (*get_data_clone) (id_payload_t *this);
93
94 /**
95 * @brief Get the ID data.
96 *
97 * Returned data are NOT copied.
98 *
99 * @param this calling id_payload_t object
100 * @return ID data as chunk_t
101 */
102 chunk_t (*get_data) (id_payload_t *this);
103
104 /**
105 * @brief Creates an identification object of this id payload.
106 *
107 * Returned object has to get destroyed by the caller.
108 *
109 * @param this calling id_payload_t object
110 * @return identification_t object
111 */
112 identification_t *(*get_identification) (id_payload_t *this);
113
114 /**
115 * @brief Get the type of ID payload (IDi or IDr).
116 *
117 * @param this calling id_payload_t object
118 * @return
119 * - TRUE if this payload is of type IDi
120 * - FALSE if this payload is of type IDr
121 *
122 */
123 bool (*get_initiator) (id_payload_t *this);
124
125 /**
126 * @brief Set the type of ID payload (IDi or IDr).
127 *
128 * @param this calling id_payload_t object
129 * @param is_initiator
130 * - TRUE if this payload is of type IDi
131 * - FALSE if this payload is of type IDr
132 *
133 */
134 void (*set_initiator) (id_payload_t *this,bool is_initiator);
135
136 /**
137 * @brief Destroys an id_payload_t object.
138 *
139 * @param this id_payload_t object to destroy
140 */
141 void (*destroy) (id_payload_t *this);
142 };
143
144 /**
145 * @brief Creates an empty id_payload_t object.
146 *
147 * @param is_initiator
148 * - TRUE if this payload is of type IDi
149 * - FALSE if this payload is of type IDr
150 *
151 * @return id_payload_t object
152 *
153 * @ingroup payloads
154 */
155 id_payload_t *id_payload_create(bool is_initiator);
156
157 /**
158 * @brief Creates an id_payload_t from an existing identification_t object.
159 *
160 * @param is_initiator
161 * - TRUE if this payload is of type IDi
162 * - FALSE if this payload is of type IDr
163 * @param identification identification_t object
164 * @return id_payload_t object
165 *
166 * @ingroup payloads
167 */
168 id_payload_t *id_payload_create_from_identification(bool is_initiator,identification_t *identification);
169
170
171
172 #endif /* ID_PAYLOAD_H_ */