Removed strayed code fragment
[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
18 /**
19 * @defgroup id_payload id_payload
20 * @{ @ingroup payloads
21 */
22
23 #ifndef ID_PAYLOAD_H_
24 #define ID_PAYLOAD_H_
25
26 typedef struct id_payload_t id_payload_t;
27
28 #include <library.h>
29 #include <utils/identification.h>
30 #include <encoding/payloads/payload.h>
31
32 /**
33 * Length of a id payload without the data in bytes.
34 */
35 #define ID_PAYLOAD_HEADER_LENGTH 8
36
37 /**
38 * Object representing an IKEv2 ID payload.
39 *
40 * The ID payload format is described in RFC section 3.5.
41 */
42 struct id_payload_t {
43 /**
44 * The payload_t interface.
45 */
46 payload_t payload_interface;
47
48 /**
49 * Set the ID type.
50 *
51 * @param type Type of ID
52 */
53 void (*set_id_type) (id_payload_t *this, id_type_t type);
54
55 /**
56 * Get the ID type.
57 *
58 * @return type of the ID
59 */
60 id_type_t (*get_id_type) (id_payload_t *this);
61
62 /**
63 * Set the ID data.
64 *
65 * Data are getting cloned.
66 *
67 * @param data ID data as chunk_t
68 */
69 void (*set_data) (id_payload_t *this, chunk_t data);
70
71 /**
72 * Get the ID data.
73 *
74 * Returned data are a copy of the internal one
75 *
76 * @return ID data as chunk_t
77 */
78 chunk_t (*get_data_clone) (id_payload_t *this);
79
80 /**
81 * Get the ID data.
82 *
83 * Returned data are NOT copied.
84 *
85 * @return ID data as chunk_t
86 */
87 chunk_t (*get_data) (id_payload_t *this);
88
89 /**
90 * Creates an identification object of this id payload.
91 *
92 * Returned object has to get destroyed by the caller.
93 *
94 * @return identification_t object
95 */
96 identification_t *(*get_identification) (id_payload_t *this);
97
98 /**
99 * Destroys an id_payload_t object.
100 */
101 void (*destroy) (id_payload_t *this);
102 };
103
104 /**
105 * Creates an empty id_payload_t object.
106 *
107 * @param payload_type one of ID_INITIATOR, ID_RESPONDER
108 * @return id_payload_t object
109 */
110 id_payload_t *id_payload_create(payload_type_t payload_type);
111
112 /**
113 * Creates an id_payload_t from an existing identification_t object.
114 *
115 * @param payload_type one of ID_INITIATOR, ID_RESPONDER
116 * @param identification identification_t object
117 * @return id_payload_t object
118 */
119 id_payload_t *id_payload_create_from_identification(payload_type_t payload_type,
120 identification_t *identification);
121
122 #endif /** ID_PAYLOAD_H_ @}*/