HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / asn1.h
blobb6d46bfbd2c05f727f205e870bea581a05a906ea
1 /* asn1.h
2 * Common data for ASN.1
3 * 2007 Anders Broman
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #ifndef __ASN1_H__
27 #define __ASN1_H__
29 #include "ws_symbol_export.h"
31 typedef enum {
32 ASN1_ENC_BER, /* X.690 - BER, CER, DER */
33 ASN1_ENC_PER, /* X.691 - PER */
34 ASN1_ENC_ECN, /* X.692 - ECN */
35 ASN1_ENC_XER /* X.693 - XER */
36 } asn1_enc_e;
38 typedef enum {
39 CB_ASN1_ENC,
40 CB_DISSECTOR,
41 CB_NEW_DISSECTOR,
42 CB_DISSECTOR_HANDLE
43 } asn1_cb_variant;
45 typedef enum {
46 ASN1_PAR_IRR, /* irrelevant parameter */
47 /* value */
48 ASN1_PAR_BOOLEAN,
49 ASN1_PAR_INTEGER,
50 /* type */
51 ASN1_PAR_TYPE
52 } asn1_par_type;
54 typedef struct _asn1_par_def_t {
55 const gchar *name;
56 asn1_par_type ptype;
57 } asn1_par_def_t;
59 typedef struct _asn1_par_t {
60 const gchar *name;
61 asn1_par_type ptype;
62 union {
63 gboolean v_boolean;
64 gint32 v_integer;
65 void *v_type;
66 } value;
67 struct _asn1_par_t *next;
68 } asn1_par_t;
70 typedef struct _asn1_stack_frame_t {
71 const gchar *name;
72 struct _asn1_par_t *par;
73 struct _asn1_stack_frame_t *next;
74 } asn1_stack_frame_t;
76 #define ASN1_CTX_SIGNATURE 0x41435458 /* "ACTX" */
78 typedef struct _asn1_ctx_t {
79 guint32 signature;
80 asn1_enc_e encoding;
81 gboolean aligned;
82 packet_info *pinfo;
83 proto_item *created_item;
84 struct _asn1_stack_frame_t *stack;
85 void *value_ptr;
86 void *private_data;
87 struct {
88 int hf_index;
89 gboolean data_value_descr_present;
90 gboolean direct_ref_present;
91 gboolean indirect_ref_present;
92 tvbuff_t *data_value_descriptor;
93 const char *direct_reference;
94 gint32 indirect_reference;
95 gint encoding;
96 /*
97 0 : single-ASN1-type,
98 1 : octet-aligned,
99 2 : arbitrary
101 tvbuff_t *single_asn1_type;
102 tvbuff_t *octet_aligned;
103 tvbuff_t *arbitrary;
104 union {
105 struct {
106 int (*ber_callback)(gboolean imp_tag, tvbuff_t *tvb, int offset, struct _asn1_ctx_t* ,proto_tree *tree, int hf_index );
107 } ber;
108 struct {
109 int (*type_cb)(tvbuff_t*, int, struct _asn1_ctx_t*, proto_tree*, int);
110 } per;
111 } u;
112 } external;
113 struct {
114 proto_tree *tree;
115 proto_tree *top_tree;
116 void* tree_ctx;
117 } subtree;
118 struct {
119 int hf_index;
120 gboolean data_value_descr_present;
121 tvbuff_t *data_value_descriptor;
122 gint identification;
124 0 : syntaxes,
125 1 : syntax,
126 2 : presentation-context-id,
127 3 : context-negotiation,
128 4 : transfer-syntax,
129 5 : fixed
131 gint32 presentation_context_id;
132 const char *abstract_syntax;
133 const char *transfer_syntax;
134 tvbuff_t *data_value;
135 union {
136 struct {
137 int (*ber_callback)(gboolean imp_tag, tvbuff_t *tvb, int offset, struct _asn1_ctx_t* ,proto_tree *tree, int hf_index );
138 } ber;
139 struct {
140 int (*type_cb)(tvbuff_t*, int, struct _asn1_ctx_t*, proto_tree*, int);
141 } per;
142 } u;
143 } embedded_pdv;
144 struct _rose_ctx_t *rose_ctx;
145 } asn1_ctx_t;
147 #define ROSE_CTX_SIGNATURE 0x524F5345 /* "ROSE" */
149 typedef struct _rose_ctx_t {
150 guint32 signature;
151 dissector_table_t arg_global_dissector_table;
152 dissector_table_t arg_local_dissector_table;
153 dissector_table_t res_global_dissector_table;
154 dissector_table_t res_local_dissector_table;
155 dissector_table_t err_global_dissector_table;
156 dissector_table_t err_local_dissector_table;
157 /* filling in description into tree, info column, any buffer */
158 int apdu_depth;
159 gboolean fillin_info;
160 gchar *fillin_ptr;
161 gsize fillin_buf_size;
162 struct { /* "dynamic" data */
163 gint pdu;
165 1 : invoke,
166 2 : returnResult,
167 3 : returnError,
168 4 : reject
170 gint code;
172 -1 : none (optional in ReturnResult)
173 0 : local,
174 1 : global
176 gint32 code_local;
177 const char *code_global;
178 proto_item *code_item;
179 } d;
180 void *private_data;
181 } rose_ctx_t;
183 WS_DLL_PUBLIC void asn1_ctx_init(asn1_ctx_t *actx, asn1_enc_e encoding, gboolean aligned, packet_info *pinfo);
184 extern gboolean asn1_ctx_check_signature(asn1_ctx_t *actx);
185 extern void asn1_ctx_clean_external(asn1_ctx_t *actx);
186 extern void asn1_ctx_clean_epdv(asn1_ctx_t *actx);
188 extern void asn1_stack_frame_push(asn1_ctx_t *actx, const gchar *name);
189 extern void asn1_stack_frame_pop(asn1_ctx_t *actx, const gchar *name);
190 extern void asn1_stack_frame_check(asn1_ctx_t *actx, const gchar *name, const asn1_par_def_t *par_def);
192 extern void asn1_param_push_boolean(asn1_ctx_t *actx, gboolean value);
193 extern void asn1_param_push_integer(asn1_ctx_t *actx, gint32 value);
194 extern gboolean asn1_param_get_boolean(asn1_ctx_t *actx, const gchar *name);
195 extern gint32 asn1_param_get_integer(asn1_ctx_t *actx, const gchar *name);
197 WS_DLL_PUBLIC void rose_ctx_init(rose_ctx_t *rctx);
198 extern gboolean rose_ctx_check_signature(rose_ctx_t *rctx);
199 WS_DLL_PUBLIC void rose_ctx_clean_data(rose_ctx_t *rctx);
201 WS_DLL_PUBLIC asn1_ctx_t *get_asn1_ctx(void *ptr);
202 WS_DLL_PUBLIC rose_ctx_t *get_rose_ctx(void *ptr);
204 extern double asn1_get_real(const guint8 *real_ptr, gint real_len);
206 /* flags */
207 #define ASN1_EXT_ROOT 0x01
208 #define ASN1_EXT_EXT 0x02
209 #define ASN1_OPT 0x04
210 #define ASN1_DFLT 0x08
212 #define ASN1_HAS_EXT(f) ((f)&(ASN1_EXT_ROOT|ASN1_EXT_EXT))
215 #endif /* __ASN1_H__ */