a45b0a14c7d562fc53a12d94c924bc0b5a54291a
[strongswan.git] / src / charon / encoding / payloads / id_payload.h
1 /*
2 * Copyright (C) 2007 Tobias Brunner
3 * Copyright (C) 2005-2006 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * $Id$
18 */
19
20 /**
21 * @defgroup id_payload id_payload
22 * @{ @ingroup payloads
23 */
24
25 #ifndef ID_PAYLOAD_H_
26 #define ID_PAYLOAD_H_
27
28 typedef struct id_payload_t id_payload_t;
29
30 #include <library.h>
31 #include <utils/identification.h>
32 #include <encoding/payloads/payload.h>
33
34 /**
35 * Length of a id payload without the data in bytes.
36 */
37 #define ID_PAYLOAD_HEADER_LENGTH 8
38
39 /**
40 * Object representing an IKEv2 ID payload.
41 *
42 * The ID payload format is described in RFC section 3.5.
43 */
44 struct id_payload_t {
45 /**
46 * The payload_t interface.
47 */
48 payload_t payload_interface;
49
50 /**
51 * Set the ID type.
52 *
53 * @param type Type of ID
54 */
55 void (*set_id_type) (id_payload_t *this, id_type_t type);
56
57 /**
58 * Get the ID type.
59 *
60 * @return type of the ID
61 */
62 id_type_t (*get_id_type) (id_payload_t *this);
63
64 /**
65 * Set the ID data.
66 *
67 * Data are getting cloned.
68 *
69 * @param data ID data as chunk_t
70 */
71 void (*set_data) (id_payload_t *this, chunk_t data);
72
73 /**
74 * Get the ID data.
75 *
76 * Returned data are a copy of the internal one
77 *
78 * @return ID data as chunk_t
79 */
80 chunk_t (*get_data_clone) (id_payload_t *this);
81
82 /**
83 * Get the ID data.
84 *
85 * Returned data are NOT copied.
86 *
87 * @return ID data as chunk_t
88 */
89 chunk_t (*get_data) (id_payload_t *this);
90
91 /**
92 * Creates an identification object of this id payload.
93 *
94 * Returned object has to get destroyed by the caller.
95 *
96 * @return identification_t object
97 */
98 identification_t *(*get_identification) (id_payload_t *this);
99
100 /**
101 * Destroys an id_payload_t object.
102 */
103 void (*destroy) (id_payload_t *this);
104 };
105
106 /**
107 * Creates an empty id_payload_t object.
108 *
109 * @param payload_type one of ID_INITIATOR, ID_RESPONDER
110 * @return id_payload_t object
111 */
112 id_payload_t *id_payload_create(payload_type_t payload_type);
113
114 /**
115 * Creates an id_payload_t from an existing identification_t object.
116 *
117 * @param payload_type one of ID_INITIATOR, ID_RESPONDER
118 * @param identification identification_t object
119 * @return id_payload_t object
120 */
121 id_payload_t *id_payload_create_from_identification(payload_type_t payload_type,
122 identification_t *identification);
123
124 #endif /* ID_PAYLOAD_H_ @} */