]> git.ipfire.org Git - thirdparty/strongswan.git/blame - programs/charon/charon/encoding/generator.h
- import of strongswan-2.7.0
[thirdparty/strongswan.git] / programs / charon / charon / encoding / generator.h
CommitLineData
b82c0cab
JH
1/**
2 * @file generator.h
c3dc6f1a 3 *
27e43205 4 * @brief Interface of generator_t.
c3dc6f1a 5 *
b82c0cab
JH
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
021c2322 26#include <types.h>
4a962238
MW
27#include <encoding/payloads/encodings.h>
28#include <encoding/payloads/payload.h>
b82c0cab 29
9e4e6e9d 30/**
c7748338 31 * Generating is done in a data buffer.
0f30f568 32 * This is thehe start size of this buffer in bytes.
c3dc864e
MW
33 *
34 * @ingroup enconding
9e4e6e9d 35 */
b643c81c 36#define GENERATOR_DATA_BUFFER_SIZE 500
9e4e6e9d 37
762ce218 38/**
c7748338 39 * Number of bytes to increase the buffer, if it is to small.
c3dc864e
MW
40 *
41 * @ingroup enconding
762ce218 42 */
b643c81c 43#define GENERATOR_DATA_BUFFER_INCREASE_VALUE 500
762ce218 44
c3dc864e 45
95c61cb9
JH
46typedef struct generator_t generator_t;
47
b82c0cab 48/**
c3dc864e
MW
49 * @brief A generator_t class used to generate IKEv2 payloads.
50 *
51 * After creation, multiple payloads can be generated with the generate_payload
52 * method. The generated bytes are appended. After all payloads are added,
53 * the write_to_chunk method writes out all generated data since
54 * the creation of the generator. After that, the generator must be destroyed.
55 * The generater uses a set of encoding rules, which it can get from
56 * the supplied payload. With this rules, the generater can generate
57 * the payload and all substructures automatically.
58 *
59 * @b Constructor:
60 * - generator_create()
27e43205
JH
61 *
62 * @ingroup encoding
b82c0cab 63 */
95c61cb9 64struct generator_t {
110dc83a
JH
65
66 /**
1e8bb886 67 * @brief Generates a specific payload from given payload object.
c3dc6f1a 68 *
c08ffafe 69 * Remember: Header and substructures are also handled as payloads.
c3dc6f1a 70 *
1e8bb886
JH
71 * @param this generator_t object
72 * @param[in] payload interface payload_t implementing object
b82c0cab 73 */
0f30f568 74 void (*generate_payload) (generator_t *this,payload_t *payload);
110dc83a
JH
75
76 /**
c3dc864e 77 * @brief Writes all generated data of the generator to a chunk.
110dc83a
JH
78 *
79 * @param this generator_t object
c3dc864e 80 * @param[out] data chunk to write the data to
110dc83a 81 */
0f30f568 82 void (*write_to_chunk) (generator_t *this,chunk_t *data);
b82c0cab
JH
83
84 /**
c08ffafe 85 * @brief Destroys a generator_t object.
c3dc6f1a 86 *
c3dc864e 87 * @param this generator_t object
b82c0cab 88 */
0f30f568 89 void (*destroy) (generator_t *this);
b82c0cab
JH
90};
91
9e4e6e9d 92/**
c3dc864e 93 * @brief Constructor to create a generator.
0f30f568 94 *
c3dc864e 95 * @return generator_t object.
27e43205
JH
96 *
97 * @ingroup encoding
9e4e6e9d 98 */
c3dc864e 99generator_t *generator_create();
b82c0cab
JH
100
101#endif /*GENERATOR_H_*/