cleaning up
[strongswan.git] / src / charon / encoding / generator.h
1 /**
2 * @file generator.h
3 *
4 * @brief Interface of generator_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24 #ifndef GENERATOR_H_
25 #define GENERATOR_H_
26
27 typedef struct generator_t generator_t;
28
29 #include <library.h>
30 #include <encoding/payloads/encodings.h>
31 #include <encoding/payloads/payload.h>
32
33 /**
34 * Generating is done in a data buffer.
35 * This is thehe start size of this buffer in bytes.
36 *
37 * @ingroup enconding
38 */
39 #define GENERATOR_DATA_BUFFER_SIZE 500
40
41 /**
42 * Number of bytes to increase the buffer, if it is to small.
43 *
44 * @ingroup enconding
45 */
46 #define GENERATOR_DATA_BUFFER_INCREASE_VALUE 500
47
48
49 /**
50 * @brief A generator_t class used to generate IKEv2 payloads.
51 *
52 * After creation, multiple payloads can be generated with the generate_payload
53 * method. The generated bytes are appended. After all payloads are added,
54 * the write_to_chunk method writes out all generated data since
55 * the creation of the generator. After that, the generator must be destroyed.
56 * The generater uses a set of encoding rules, which it can get from
57 * the supplied payload. With this rules, the generater can generate
58 * the payload and all substructures automatically.
59 *
60 * @b Constructor:
61 * - generator_create()
62 *
63 * @ingroup encoding
64 */
65 struct generator_t {
66
67 /**
68 * @brief Generates a specific payload from given payload object.
69 *
70 * Remember: Header and substructures are also handled as payloads.
71 *
72 * @param this generator_t object
73 * @param[in] payload interface payload_t implementing object
74 */
75 void (*generate_payload) (generator_t *this,payload_t *payload);
76
77 /**
78 * @brief Writes all generated data of the generator to a chunk.
79 *
80 * @param this generator_t object
81 * @param[out] data chunk to write the data to
82 */
83 void (*write_to_chunk) (generator_t *this,chunk_t *data);
84
85 /**
86 * @brief Destroys a generator_t object.
87 *
88 * @param this generator_t object
89 */
90 void (*destroy) (generator_t *this);
91 };
92
93 /**
94 * @brief Constructor to create a generator.
95 *
96 * @return generator_t object.
97 *
98 * @ingroup encoding
99 */
100 generator_t *generator_create(void);
101
102 #endif /*GENERATOR_H_*/