4 * @brief Interface of id_payload_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
28 #include <utils/identification.h>
29 #include <encoding/payloads/payload.h>
32 * Length of a id payload without the data in bytes.
36 #define ID_PAYLOAD_HEADER_LENGTH 8
39 typedef struct id_payload_t id_payload_t
;
42 * Object representing an IKEv2 ID payload.
44 * The ID payload format is described in RFC section 3.5.
47 * - id_payload_create_from_identification()
48 * - id_payload_create()
54 * The payload_t interface.
56 payload_t payload_interface
;
59 * @brief Set the ID type.
61 * @param this calling id_payload_t object
62 * @param type Type of ID
64 void (*set_id_type
) (id_payload_t
*this, id_type_t type
);
67 * @brief Get the ID type.
69 * @param this calling id_payload_t object
70 * @return type of the ID
72 id_type_t (*get_id_type
) (id_payload_t
*this);
75 * @brief Set the ID data.
77 * Data are getting cloned.
79 * @param this calling id_payload_t object
80 * @param data ID data as chunk_t
82 void (*set_data
) (id_payload_t
*this, chunk_t data
);
85 * @brief Get the ID data.
87 * Returned data are a copy of the internal one
89 * @param this calling id_payload_t object
90 * @return ID data as chunk_t
92 chunk_t (*get_data_clone
) (id_payload_t
*this);
95 * @brief Get the ID data.
97 * Returned data are NOT copied.
99 * @param this calling id_payload_t object
100 * @return ID data as chunk_t
102 chunk_t (*get_data
) (id_payload_t
*this);
105 * @brief Creates an identification object of this id payload.
107 * Returned object has to get destroyed by the caller.
109 * @param this calling id_payload_t object
110 * @return identification_t object
112 identification_t
*(*get_identification
) (id_payload_t
*this);
115 * @brief Get the type of ID payload (IDi or IDr).
117 * @param this calling id_payload_t object
119 * - TRUE if this payload is of type IDi
120 * - FALSE if this payload is of type IDr
123 bool (*get_initiator
) (id_payload_t
*this);
126 * @brief Set the type of ID payload (IDi or IDr).
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
134 void (*set_initiator
) (id_payload_t
*this,bool is_initiator
);
137 * @brief Destroys an id_payload_t object.
139 * @param this id_payload_t object to destroy
141 void (*destroy
) (id_payload_t
*this);
145 * @brief Creates an empty id_payload_t object.
147 * @param is_initiator
148 * - TRUE if this payload is of type IDi
149 * - FALSE if this payload is of type IDr
151 * @return id_payload_t object
155 id_payload_t
*id_payload_create(bool is_initiator
);
158 * @brief Creates an id_payload_t from an existing identification_t object.
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
168 id_payload_t
*id_payload_create_from_identification(bool is_initiator
,identification_t
*identification
);
172 #endif /* ID_PAYLOAD_H_ */