2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
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>.
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
18 * @defgroup generator generator
19 * @{ @ingroup encoding
25 typedef struct generator_t generator_t
;
28 #include <encoding/payloads/encodings.h>
29 #include <encoding/payloads/payload.h>
32 * Generating is done in a data buffer.
33 * This is the start size of this buffer in bytes.
35 #define GENERATOR_DATA_BUFFER_SIZE 500
38 * Number of bytes to increase the buffer, if it is too small.
40 #define GENERATOR_DATA_BUFFER_INCREASE_VALUE 500
44 * A generator_t class used to generate IKEv2 payloads.
46 * After creation, multiple payloads can be generated with the generate_payload
47 * method. The generated bytes are appended. After all payloads are added,
48 * the write_to_chunk method writes out all generated data since
49 * the creation of the generator. After that, the generator must be destroyed.
50 * The generater uses a set of encoding rules, which it can get from
51 * the supplied payload. With this rules, the generater can generate
52 * the payload and all substructures automatically.
57 * Generates a specific payload from given payload object.
59 * Remember: Header and substructures are also handled as payloads.
61 * @param payload interface payload_t implementing object
63 void (*generate_payload
) (generator_t
*this,payload_t
*payload
);
66 * Writes all generated data of the generator to a chunk.
68 * @param data chunk to write the data to
70 void (*write_to_chunk
) (generator_t
*this,chunk_t
*data
);
73 * Destroys a generator_t object.
75 void (*destroy
) (generator_t
*this);
79 * Constructor to create a generator.
81 * @return generator_t object.
83 generator_t
*generator_create(void);
85 #endif /** GENERATOR_H_ @}*/