3be2e2e13dc935e22e85d771d7650e6230012d3c
[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 IKEv1/IKEv2 Nonce payload.
42 */
43 struct nonce_payload_t {
44 /**
45 * The payload_t interface.
46 */
47 payload_t payload_interface;
48
49 /**
50 * Set the nonce value.
51 *
52 * @param nonce chunk containing the nonce, will be cloned
53 */
54 void (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
55
56 /**
57 * Get the nonce value.
58 *
59 * @return a chunk containing the cloned nonce
60 */
61 chunk_t (*get_nonce) (nonce_payload_t *this);
62
63 /**
64 * Destroys an nonce_payload_t object.
65 */
66 void (*destroy) (nonce_payload_t *this);
67 };
68
69 /**
70 * Creates an empty nonce_payload_t object
71 *
72 * @param type NONCE or NONCE_V1
73 * @return nonce_payload_t object
74 */
75 nonce_payload_t *nonce_payload_create(payload_type_t type);
76
77 #endif /** NONCE_PAYLOAD_H_ @}*/