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
24 #ifndef _ID_PAYLOAD_H_
25 #define _ID_PAYLOAD_H_
28 #include <encoding/payloads/payload.h>
31 * Length of a id payload without the data in bytes.
35 #define ID_PAYLOAD_HEADER_LENGTH 8
38 typedef enum id_type_t id_type_t
;
41 * ID Types of a ID payload.
47 * ID data is a single four (4) octet IPv4 address.
52 * ID data is a fully-qualified domain name string.
53 * An example of a ID_FQDN is, "example.com".
54 * The string MUST not contain any terminators (e.g., NULL, CR, etc.).
59 * ID data is a fully-qualified RFC822 email address string, An example of
60 * a ID_RFC822_ADDR is, "jsmith@example.com". The string MUST
61 * not contain any terminators.
66 * ID data is a single sixteen (16) octet IPv6 address.
71 * ID data is the binary DER encoding of an ASN.1 X.500 Distinguished Name
77 * ID data is the binary DER encoding of an ASN.1 X.500 GeneralName
83 * ID data is an opaque octet stream which may be used to pass vendor-
84 * specific information necessary to do certain proprietary
85 * types of identification.
90 extern mapping_t id_type_m
[];
93 typedef struct id_payload_t id_payload_t
;
96 * Object representing an IKEv2 ID payload.
98 * The ID payload format is described in draft section 3.5.
103 struct id_payload_t
{
105 * The payload_t interface.
107 payload_t payload_interface
;
110 * @brief Set the ID type.
113 * @param this calling id_payload_t object
114 * @param type Type of ID
116 void (*set_id_type
) (id_payload_t
*this, id_type_t type
);
119 * @brief Get the ID type.
121 * @param this calling id_payload_t object
122 * @return type of the ID
124 id_type_t (*get_id_type
) (id_payload_t
*this);
127 * @brief Set the ID data.
129 * Data are getting cloned.
131 * @param this calling id_payload_t object
132 * @param data ID data as chunk_t
134 void (*set_data
) (id_payload_t
*this, chunk_t data
);
137 * @brief Get the ID data.
139 * Returned data are a copy of the internal one
141 * @param this calling id_payload_t object
142 * @return ID data as chunk_t
144 chunk_t (*get_data
) (id_payload_t
*this);
147 * @brief Get the type of ID payload (IDi or IDr).
149 * @param this calling id_payload_t object
151 * - TRUE if this payload is of type IDi
152 * - FALSE if this payload is of type IDr
155 bool (*get_initiator
) (id_payload_t
*this);
158 * @brief Set the type of ID payload (IDi or IDr).
160 * @param this calling id_payload_t object
161 * @param is_initiator
162 * - TRUE if this payload is of type IDi
163 * - FALSE if this payload is of type IDr
166 void (*set_initiator
) (id_payload_t
*this,bool is_initiator
);
169 * @brief Destroys an id_payload_t object.
171 * @param this id_payload_t object to destroy
173 void (*destroy
) (id_payload_t
*this);
177 * @brief Creates an empty id_payload_t object.
179 * As default a ID payload of type IDi is created.
181 * @param is_initiator
182 * - TRUE if this payload is of type IDi
183 * - FALSE if this payload is of type IDr
185 * @return created id_payload_t object
189 id_payload_t
*id_payload_create(bool is_initiator
);
192 #endif //_ID_PAYLOAD_H_