updated Doxyfile
[strongswan.git] / src / libstrongswan / asn1 / asn1_parser.h
1 /*
2 * Copyright (C) 2006 Martin Will
3 * Copyright (C) 2000-2008 Andreas Steffen
4 *
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * $Id$
18 */
19
20 /**
21 * @defgroup asn1_parser asn1_parser
22 * @{ @ingroup asn1
23 */
24
25 #ifndef ASN1_PARSER_H_
26 #define ASN1_PARSER_H_
27
28 #include <stdarg.h>
29
30 #include <library.h>
31
32 /**
33 * Definition of ASN.1 flags
34 */
35 #define ASN1_NONE 0x00
36 #define ASN1_DEF 0x01
37 #define ASN1_OPT 0x02
38 #define ASN1_LOOP 0x04
39 #define ASN1_END 0x08
40 #define ASN1_OBJ 0x10
41 #define ASN1_BODY 0x20
42 #define ASN1_RAW 0x40
43 #define ASN1_EXIT 0x80
44
45 typedef struct asn1Object_t asn1Object_t;
46
47 /**
48 * Syntax definition of an ASN.1 object
49 */
50 struct asn1Object_t{
51 u_int level;
52 const u_char *name;
53 asn1_t type;
54 u_char flags;
55 };
56
57 typedef struct asn1_parser_t asn1_parser_t;
58
59 /**
60 * Public interface of an ASN.1 parser
61 */
62 struct asn1_parser_t {
63
64 /**
65 * Parse the next ASN.1 object in the hierarchy and return it
66 *
67 * @param objectID current line in the object syntax definition
68 * @param object current object
69 * @return - FALSE if end of object syntax definition was reached
70 * or a parsing error occurred
71 * - TRUE otherwise
72 */
73 bool (*iterate)(asn1_parser_t *this, int *objectID, chunk_t *object);
74
75 /**
76 * Get the current parsing level
77 *
78 * @return current level
79 */
80 u_int (*get_level)(asn1_parser_t *this);
81
82 /**
83 * Set the top-most level
84 *
85 * @param level top-most level
86 */
87 void (*set_top_level)(asn1_parser_t *this, u_int level0);
88
89 /**
90 * Set implicit and private flags
91 *
92 * @param implicit top-most type of object is implicit
93 * @param private object data is private (use debug level 4)
94 */
95 void (*set_flags)(asn1_parser_t *this, bool implicit, bool private);
96
97 /**
98 * Show final parsing status
99 *
100 * @return TRUE if parsing was successful, FALSE otherwise
101 */
102 bool (*success)(asn1_parser_t *this);
103
104 /**
105 * Destroy the ASN.1 parser
106 */
107 void (*destroy)(asn1_parser_t *this);
108 };
109
110 /**
111 * Create an ASN.1 parser
112 *
113 * @param objects syntax definition of the ASN.1 object to be parsed
114 * @param blob ASN.1 coded binary blob
115 * @return ASN.1 context
116 */
117 asn1_parser_t* asn1_parser_create(asn1Object_t const *objects, chunk_t blob);
118
119 #endif /** ASN1_PARSER_H_ @}*/