- source code documentation improved
[strongswan.git] / Source / charon / generator.h
1 /**
2 * @file generator.h
3 *
4 * @brief Generic generator class used to generate IKEv2-header and payloads.
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 "encodings.h"
28
29 /**
30 * Generating is done in a data buffer.
31 * This is thehe start size of this buffer in Bytes.
32 */
33 #define GENERATOR_DATA_BUFFER_SIZE 3000
34
35 /**
36 * Number of bytes to increase the buffer, if it is to small.
37 */
38 #define GENERATOR_DATA_BUFFER_INCREASE_VALUE 1000
39
40 /**
41 *A generator_t object which generates payloads of specific type.
42 */
43 typedef struct generator_s generator_t;
44
45 struct generator_s {
46
47 /**
48 * @brief Generates a specific payload from given data struct.
49 *
50 * Remember: Header and substructures are also handled as payloads.
51 *
52 * @param generator generator_t object
53 * @param payload_type payload type to generate using the given data struct
54 * @param[in] data_struct data struct where the needed data for generating are stored
55 * @param[out] output pointer to a chunk_t where the data are generated to
56 * @return
57 * - SUCCESSFUL if succeeded
58 * - NOT_SUPPORTED if payload_type is not supported
59 * - OUT_OF_RES if out of ressources
60 */
61 status_t (*generate_payload) (generator_t *this,payload_type_t payload_type,void * data_struct, chunk_t *data);
62
63 /**
64 * @brief Destroys a generator_t object.
65 *
66 * @param generator generator_t object
67 *
68 * @return always success
69 */
70 status_t (*destroy) (generator_t *this);
71 };
72
73 /**
74 * Constructor to create a generator
75 *
76 * @param payload_infos pointer to the payload_info_t-array containing
77 * all the payload informations needed to
78 * automatic generate a specific payload
79 */
80 generator_t * generator_create(payload_info_t ** payload_infos);
81
82 #endif /*GENERATOR_H_*/