]>
Commit | Line | Data |
---|---|---|
b82c0cab JH |
1 | /** |
2 | * @file generator.h | |
c3dc6f1a | 3 | * |
c7748338 | 4 | * @brief Generic generator class used to generate IKEv2-header and payloads. |
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 JH |
31 | * Generating is done in a data buffer. |
32 | * This is thehe start size of this buffer in Bytes. | |
9e4e6e9d | 33 | */ |
b643c81c | 34 | #define GENERATOR_DATA_BUFFER_SIZE 500 |
9e4e6e9d | 35 | |
762ce218 | 36 | /** |
c7748338 | 37 | * Number of bytes to increase the buffer, if it is to small. |
762ce218 | 38 | */ |
b643c81c | 39 | #define GENERATOR_DATA_BUFFER_INCREASE_VALUE 500 |
762ce218 | 40 | |
b82c0cab | 41 | /** |
c08ffafe | 42 | *A generator_t object which generates payloads of specific type. |
b82c0cab JH |
43 | */ |
44 | typedef struct generator_s generator_t; | |
45 | ||
c3dc6f1a | 46 | struct generator_s { |
110dc83a JH |
47 | |
48 | /** | |
1e8bb886 | 49 | * @brief Generates a specific payload from given payload object. |
c3dc6f1a | 50 | * |
c08ffafe | 51 | * Remember: Header and substructures are also handled as payloads. |
c3dc6f1a | 52 | * |
1e8bb886 JH |
53 | * @param this generator_t object |
54 | * @param[in] payload interface payload_t implementing object | |
c08ffafe JH |
55 | * @return |
56 | * - SUCCESSFUL if succeeded | |
c08ffafe | 57 | * - OUT_OF_RES if out of ressources |
b82c0cab | 58 | */ |
1e8bb886 | 59 | status_t (*generate_payload) (generator_t *this,payload_t *payload); |
110dc83a JH |
60 | |
61 | /** | |
1e8bb886 | 62 | * Writes all generated data of current generator context to a chunk |
110dc83a JH |
63 | * |
64 | * @param this generator_t object | |
110dc83a JH |
65 | * * @param[out] data chunk to write the data to |
66 | * @return | |
67 | * @return | |
68 | * - SUCCESSFUL if succeeded | |
69 | * - OUT_OF_RES otherwise | |
70 | */ | |
1e8bb886 | 71 | status_t (*write_to_chunk) (generator_t *this,chunk_t *data); |
b82c0cab JH |
72 | |
73 | /** | |
c08ffafe | 74 | * @brief Destroys a generator_t object. |
c3dc6f1a | 75 | * |
110dc83a | 76 | * @param this generator_t object |
c08ffafe JH |
77 | * |
78 | * @return always success | |
b82c0cab JH |
79 | */ |
80 | status_t (*destroy) (generator_t *this); | |
81 | }; | |
82 | ||
9e4e6e9d JH |
83 | /** |
84 | * Constructor to create a generator | |
c3dc6f1a | 85 | * |
9e4e6e9d | 86 | */ |
c0211a29 | 87 | generator_t * generator_create(); |
b82c0cab JH |
88 | |
89 | #endif /*GENERATOR_H_*/ |