2 * Copyright (C) 2005-2009 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * HSR 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 * A generator_t class used to generate IKEv2 payloads.
34 * After creation, multiple payloads can be generated with the generate_payload
35 * method. The generated bytes are appended. After all payloads are added,
36 * the write_to_chunk method writes out all generated data since
37 * the creation of the generator.
38 * The generator uses a set of encoding rules, which it can get from
39 * the supplied payload. With this rules, the generator can generate
40 * the payload and all substructures automatically.
45 * Generates a specific payload from given payload object.
47 * @param payload interface payload_t implementing object
49 void (*generate_payload
) (generator_t
*this,payload_t
*payload
);
52 * Return a chunk for the currently generated data.
54 * The returned length pointer must be filled in with the length of
55 * the generated chunk (in network order).
57 * @param lenpos receives a pointer to fill in length value
58 * @param return chunk to internal buffer.
60 chunk_t (*get_chunk
) (generator_t
*this, uint32_t **lenpos
);
63 * Destroys a generator_t object.
65 void (*destroy
) (generator_t
*this);
69 * Constructor to create a generator.
71 * @return generator_t object.
73 generator_t
*generator_create(void);
76 * Constructor to create a generator that does not log any debug messages > 1.
78 * @return generator_t object.
80 generator_t
*generator_create_no_dbg(void);
83 #endif /** GENERATOR_H_ @}*/