Moving charon to libcharon.
[strongswan.git] / src / libcharon / encoding / payloads / auth_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
17 /**
18 * @defgroup auth_payload auth_payload
19 * @{ @ingroup payloads
20 */
21
22 #ifndef AUTH_PAYLOAD_H_
23 #define AUTH_PAYLOAD_H_
24
25 typedef struct auth_payload_t auth_payload_t;
26
27 #include <library.h>
28 #include <encoding/payloads/payload.h>
29 #include <sa/authenticators/authenticator.h>
30
31 /**
32 * Length of a auth payload without the auth data in bytes.
33 */
34 #define AUTH_PAYLOAD_HEADER_LENGTH 8
35
36 /**
37 * Class representing an IKEv2 AUTH payload.
38 *
39 * The AUTH payload format is described in RFC section 3.8.
40 */
41 struct auth_payload_t {
42
43 /**
44 * The payload_t interface.
45 */
46 payload_t payload_interface;
47
48 /**
49 * Set the AUTH method.
50 *
51 * @param method auth_method_t to use
52 */
53 void (*set_auth_method) (auth_payload_t *this, auth_method_t method);
54
55 /**
56 * Get the AUTH method.
57 *
58 * @return auth_method_t used
59 */
60 auth_method_t (*get_auth_method) (auth_payload_t *this);
61
62 /**
63 * Set the AUTH data.
64 *
65 * Data gets cloned.
66 *
67 * @param data AUTH data as chunk_t
68 */
69 void (*set_data) (auth_payload_t *this, chunk_t data);
70
71 /**
72 * Get the AUTH data.
73 *
74 * Returned data are a copy of the internal one.
75 *
76 * @return AUTH data as chunk_t
77 */
78 chunk_t (*get_data_clone) (auth_payload_t *this);
79
80 /**
81 * Get the AUTH data.
82 *
83 * Returned data are NOT copied
84 *
85 * @return AUTH data as chunk_t
86 */
87 chunk_t (*get_data) (auth_payload_t *this);
88
89 /**
90 * Destroys an auth_payload_t object.
91 */
92 void (*destroy) (auth_payload_t *this);
93 };
94
95 /**
96 * Creates an empty auth_payload_t object.
97 *
98 * @return auth_payload_t object
99 */
100 auth_payload_t *auth_payload_create(void);
101
102 #endif /** AUTH_PAYLOAD_H_ @}*/