- added
[strongswan.git] / Source / charon / parser.h
1 /**
2 * @file parser.h
3 *
4 * @brief Generic parser class used to parse IKEv2-Header and Payload
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 PARSER_H_
24 #define PARSER_H_
25
26 #include "types.h"
27 #include "encodings.h"
28
29
30
31 /**
32 * @brief A parser_t-object which parses payloads of specific type
33 */
34 typedef struct parser_s parser_t;
35
36 struct parser_s {
37
38 /**
39 * @brief Generates a specific payload from given data struct
40 *
41 * Remember: Header and substructures are also seen as payloads
42 *
43 * @param generator generator object
44 * @return SUCCESSFUL if succeeded,
45 * NOT_SUPPORTED if payload_type is not supported
46 * OUT_OF_RES if out of ressources
47 */
48 status_t (*parse_payload) (parser_t *this, payload_type_t payload_type, chunk_t *data, void *data_struct);
49
50 /**
51 * @brief Destroys a generator object
52 *
53 * @param generator generator object
54 * @return SUCCESSFUL if succeeded, FAILED otherwise
55 */
56 status_t (*destroy) (parser_t *this);
57 };
58
59 /**
60 * Constructor to create a parser
61 *
62 */
63 parser_t *parser_create(payload_info_t ** payload_infos);
64
65 #endif /*PARSER_H_*/