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