]> git.ipfire.org Git - thirdparty/strongswan.git/blob - Source/charon/encoding/payloads/nonce_payload.h
- moved packet and socket in new network-package
[thirdparty/strongswan.git] / Source / charon / encoding / payloads / nonce_payload.h
1 /**
2 * @file nonce_payload.h
3 *
4 * @brief Declaration of the class nonce_payload_t.
5 *
6 * An object of this type represents an IKEv2 Nonce-Payload.
7 *
8 */
9
10 /*
11 * Copyright (C) 2005 Jan Hutter, Martin Willi
12 * Hochschule fuer Technik Rapperswil
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 */
24
25 #ifndef NONCE_PAYLOAD_H_
26 #define NONCE_PAYLOAD_H_
27
28 #include <types.h>
29 #include <encoding/payloads/payload.h>
30
31 /**
32 * length of a nonce payload without a nonce in int
33 */
34 #define NONCE_PAYLOAD_HEADER_LENGTH 4
35
36 /**
37 * Object representing an IKEv2 Nonce payload
38 *
39 * The Nonce payload format is described in draft section 3.3.
40 *
41 */
42 typedef struct nonce_payload_s nonce_payload_t;
43
44 struct nonce_payload_s {
45 /**
46 * implements payload_t interface
47 */
48 payload_t payload_interface;
49
50 /**
51 * @brief Set the nonce value.
52 *
53 * The nonce must have length between 16 and 256 bytes
54 *
55 * @param this calling nonce_payload_t object
56 * @param nonce chunk containing the nonce, will be cloned
57 * @return
58 * - SUCCESS or
59 * - INVALID_ARG, if nonce has an invalid size
60 */
61 status_t (*set_nonce) (nonce_payload_t *this, chunk_t nonce);
62
63 /**
64 * @brief Get the nonce value.
65 *
66 * @param this calling nonce_payload_t object
67 * @param[out] nonce chunk where nonce data is located (cloned)
68 * @return SUCCESS in any case
69 */
70 status_t (*get_nonce) (nonce_payload_t *this, chunk_t *nonce);
71
72 /**
73 * @brief Destroys an nonce_payload_t object.
74 *
75 * @param this nonce_payload_t object to destroy
76 * @return
77 * SUCCESS in any case
78 */
79 status_t (*destroy) (nonce_payload_t *this);
80 };
81
82 /**
83 * @brief Creates an empty nonce_payload_t object
84 *
85 * @return
86 * - created nonce_payload_t object, or
87 * - NULL if failed
88 */
89
90 nonce_payload_t *nonce_payload_create();
91
92
93 #endif /*NONCE_PAYLOAD_H_*/