Added member fields for reserved bits and bytes in all payloads
[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 * @param data AUTH data as chunk_t, gets cloned
66 */
67 void (*set_data) (auth_payload_t *this, chunk_t data);
68
69 /**
70 * Get the AUTH data.
71 *
72 * @return AUTH data as chunk_t, internal data
73 */
74 chunk_t (*get_data) (auth_payload_t *this);
75
76 /**
77 * Get the value of a reserved bit.
78 *
79 * @param nr number of the reserved bit, 0-6
80 * @return TRUE if bit was set, FALSE to clear
81 */
82 bool (*get_reserved_bit)(auth_payload_t *this, u_int nr);
83
84 /**
85 * Set one of the reserved bits.
86 *
87 * @param nr number of the reserved bit, 0-6
88 */
89 void (*set_reserved_bit)(auth_payload_t *this, u_int nr);
90
91 /**
92 * Destroys an auth_payload_t object.
93 */
94 void (*destroy) (auth_payload_t *this);
95 };
96
97 /**
98 * Creates an empty auth_payload_t object.
99 *
100 * @return auth_payload_t object
101 */
102 auth_payload_t *auth_payload_create(void);
103
104 #endif /** AUTH_PAYLOAD_H_ @}*/