Annotation of embedaddon/strongswan/src/libcharon/encoding/parser.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2005-2006 Martin Willi
3: * Copyright (C) 2005 Jan Hutter
4: * HSR Hochschule fuer Technik Rapperswil
5: *
6: * This program is free software; you can redistribute it and/or modify it
7: * under the terms of the GNU General Public License as published by the
8: * Free Software Foundation; either version 2 of the License, or (at your
9: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * for more details.
15: */
16:
17: /**
18: * @defgroup parser parser
19: * @{ @ingroup encoding
20: */
21:
22: #ifndef PARSER_H_
23: #define PARSER_H_
24:
25: typedef struct parser_t parser_t;
26:
27: #include <library.h>
28: #include <encoding/payloads/encodings.h>
29: #include <encoding/payloads/payload.h>
30:
31: /**
32: * A parser_t class to parse IKE payloads.
33: *
34: * A parser is used for parsing one chunk of data. Multiple
35: * payloads can be parsed out of the chunk using parse_payload.
36: * The parser remains the state until destroyed.
37: */
38: struct parser_t {
39:
40: /**
41: * Parses the next payload.
42: *
43: * @warning Caller is responsible for freeing allocated payload.
44: *
45: * Rules for parsing are described in the payload definition.
46: *
47: * @param payload_type payload type to parse
48: * @param payload pointer where parsed payload was allocated
49: * @return
50: * - SUCCESSFUL if succeeded,
51: * - PARSE_ERROR if corrupted/invalid data found
52: */
53: status_t (*parse_payload) (parser_t *this, payload_type_t payload_type,
54: payload_t **payload);
55:
56: /**
57: * Gets the remaining byte count which is not currently parsed.
58: */
59: int (*get_remaining_byte_count) (parser_t *this);
60:
61: /**
62: * Resets the current parser context.
63: */
64: void (*reset_context) (parser_t *this);
65:
66: /**
67: * Set the major IKE version.
68: *
69: * @param major_version the major IKE version
70: */
71: void (*set_major_version) (parser_t *this, uint8_t major_version);
72:
73: /**
74: * Destroys a parser_t object.
75: */
76: void (*destroy) (parser_t *this);
77: };
78:
79: /**
80: * Constructor to create a parser_t object.
81: *
82: * @param data chunk of data to parse with this parser_t object
83: * @return parser_t object
84: */
85: parser_t *parser_create(chunk_t data);
86:
87: #endif /** PARSER_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>