4 * @brief Generic parser class used to parse IKEv2-Header and Payload
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
27 #include "encodings.h"
30 typedef struct parser_context_s parser_context_t
;
32 struct parser_context_s
{
34 status_t (*destroy
) (parser_context_t
*this);
40 * @brief A parser_t object which parses payloads of specific type
42 typedef struct parser_s parser_t
;
47 * @brief parses a chunk and generates a usable data struct
49 * Remember: Header and substructures are also seen as payloads
51 * @param parser parser Object
52 * @param payload_type definition of payload including encoding_rule
53 * @param data chunk of data to parse
54 * @param[out] allocated structure with parsed data
56 * - SUCCESSFUL if succeeded,
57 * - NOT_SUPPORTED if payload_type is not supported
58 * - OUT_OF_RES if out of ressources
59 * - PARSE_ERROR if corrupted data found
61 parser_context_t
*(*create_context
) (parser_t
*this, chunk_t data
);
62 status_t (*parse_payload
) (parser_t
*this, parser_context_t
* context
, payload_type_t payload_type
, void **data_struct
);
65 * @brief Destroys a parser object
67 * @param parser parser object
69 * - SUCCESSFUL in any case
71 status_t (*destroy
) (parser_t
*this);
75 * Constructor to create a parser
78 parser_t
*parser_create(payload_info_t
**payload_infos
);