e9212202e2000b0c82d068f17d5b362c94ef9358
[strongswan.git] / src / libcharon / encoding / payloads / nonce_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 nonce_payload nonce_payload
19 * @{ @ingroup payloads
20 */
21
22 #ifndef NONCE_PAYLOAD_H_
23 #define NONCE_PAYLOAD_H_
24
25 typedef struct nonce_payload_t nonce_payload_t;
26
27 #include <library.h>
28 #include <encoding/payloads/payload.h>
29
30 /**
31 * Nonce size in bytes for nonces sending to other peer.
32 */
33 #define NONCE_SIZE 32
34
35 /**
36 * Length of a nonce payload without a nonce in bytes.
37 */
38 #define NONCE_PAYLOAD_HEADER_LENGTH 4
39
40 /**
41 * Object representing an IKEv2 Nonce payload.
42 *
43 * The Nonce payload format is described in RFC section 3.3.
44 */
45 struct nonce_payload_t {
46 /**
47 * The payload_t interface.
48 */
49 payload_t payload_interface;
50
51 /**
52 * Set the nonce value.
53 *
54 * @param nonce chunk containing the nonce, will be cloned
55 */
56 void (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
57
58 /**
59 * Get the nonce value.
60 *
61 * @return a chunk containing the cloned nonce
62 */
63 chunk_t (*get_nonce) (nonce_payload_t *this);
64
65 /**
66 * Destroys an nonce_payload_t object.
67 */
68 void (*destroy) (nonce_payload_t *this);
69 };
70
71 /**
72 * Creates an empty nonce_payload_t object
73 *
74 * @return nonce_payload_t object
75 */
76 nonce_payload_t *nonce_payload_create(void);
77
78 #endif /** NONCE_PAYLOAD_H_ @}*/