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 "payloads/encodings.h"
28 #include "payloads/payload.h"
32 * @brief A parser_t object which parses payloads of specific type
34 typedef struct parser_s parser_t
;
39 * @brief parses the next payload in the current context
41 * @warning caller is responsible for freeing allocated data_struct
43 * @param parser parser Object
44 * @param payload_type payload to parse
45 * @param[out] payload pointer where parsed payload was allocated
47 * - SUCCESSFUL if succeeded,
48 * - NOT_SUPPORTED if payload_type is not supported
49 * - OUT_OF_RES if out of ressources
50 * - PARSE_ERROR if corrupted data found
52 status_t (*parse_payload
) (parser_t
*this, payload_type_t payload_type
, payload_t
**payload
);
55 * @brief Destroys a parser object
57 * @param parser parser object
59 * - SUCCESSFUL in any case
61 status_t (*destroy
) (parser_t
*this);
65 * @brief Constructor to create a parser
67 * The parser uses a set of payload_infos to know how to
68 * parse different payloads.
70 * @param chunk chunk of data to parse in this session
71 * @return the parser, or NULL if failed
74 parser_t
*parser_create(chunk_t data
);