updated Doxyfile
[strongswan.git] / src / charon / encoding / payloads / eap_payload.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * $Id$
17 */
18
19 /**
20 * @defgroup eap_payload eap_payload
21 * @{ @ingroup payloads
22 */
23
24 #ifndef EAP_PAYLOAD_H_
25 #define EAP_PAYLOAD_H_
26
27 typedef struct eap_payload_t eap_payload_t;
28
29 #include <library.h>
30 #include <encoding/payloads/payload.h>
31 #include <sa/authenticators/eap/eap_method.h>
32
33 /**
34 * Length of a EAP payload without the EAP Message in bytes.
35 */
36 #define EAP_PAYLOAD_HEADER_LENGTH 4
37
38 /**
39 * Class representing an IKEv2 EAP payload.
40 *
41 * The EAP payload format is described in RFC section 3.16.
42 */
43 struct eap_payload_t {
44
45 /**
46 * The payload_t interface.
47 */
48 payload_t payload_interface;
49
50 /**
51 * Set the contained EAP data.
52 *
53 * This contains the FULL EAP message starting with "code".
54 * Chunk gets cloned.
55 *
56 * @param message EAP data
57 */
58 void (*set_data) (eap_payload_t *this, chunk_t data);
59
60 /**
61 * Get the contained EAP data.
62 *
63 * This contains the FULL EAP message starting with "code".
64 *
65 * @return EAP data (pointer to internal data)
66 */
67 chunk_t (*get_data) (eap_payload_t *this);
68
69 /**
70 * Get the EAP code.
71 *
72 * @return EAP message as chunk_t
73 */
74 eap_code_t (*get_code) (eap_payload_t *this);
75
76 /**
77 * Get the EAP identifier.
78 *
79 * @return unique identifier
80 */
81 u_int8_t (*get_identifier) (eap_payload_t *this);
82
83 /**
84 * Get the EAP method type.
85 *
86 * @param vendor pointer receiving vendor identifier
87 * @return EAP method type, vendor specific if vendor != 0
88 */
89 eap_type_t (*get_type) (eap_payload_t *this, u_int32_t *vendor);
90
91 /**
92 * Destroys an eap_payload_t object.
93 */
94 void (*destroy) (eap_payload_t *this);
95 };
96
97 /**
98 * Creates an empty eap_payload_t object.
99 *
100 * @return eap_payload_t object
101 */
102 eap_payload_t *eap_payload_create(void);
103
104 /**
105 * Creates an eap_payload_t object with data.
106 *
107 * @return eap_payload_t object
108 */
109 eap_payload_t *eap_payload_create_data(chunk_t data);
110
111 /**
112 * Creates an eap_payload_t object with a code.
113 *
114 * Could should be either EAP_SUCCESS/EAP_FAILURE, use
115 * constructor above otherwise.
116 *
117 * @param code EAP status code
118 * @param identifier EAP identifier to use in payload
119 * @return eap_payload_t object
120 */
121 eap_payload_t *eap_payload_create_code(eap_code_t code, u_int8_t identifier);
122
123 /**
124 * Creates an eap_payload_t EAP_RESPONSE containing an EAP_NAK.
125 *
126 * @param identifier EAP identifier to use in payload
127 * @return eap_payload_t object
128 */
129 eap_payload_t *eap_payload_create_nak(u_int8_t identifier);
130
131 #endif /** EAP_PAYLOAD_H_ @}*/