2 * Common data for ASN.1
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 ASN1_ENC_BER, /* X.690 - BER, CER, DER */
31 ASN1_ENC_PER, /* X.691 - PER */
32 ASN1_ENC_ECN, /* X.692 - ECN */
33 ASN1_ENC_XER /* X.693 - XER */
44 ASN1_PAR_IRR, /* irrelevant parameter */
52 typedef struct _asn1_par_def_t {
57 typedef struct _asn1_par_t {
65 struct _asn1_par_t *next;
68 typedef struct _asn1_stack_frame_t {
70 struct _asn1_par_t *par;
71 struct _asn1_stack_frame_t *next;
74 #define ASN1_CTX_SIGNATURE 0x41435458 /* "ACTX" */
76 typedef struct _asn1_ctx_t {
81 proto_item *created_item;
82 struct _asn1_stack_frame_t *stack;
87 gboolean data_value_descr_present;
88 gboolean direct_ref_present;
89 gboolean indirect_ref_present;
90 tvbuff_t *data_value_descriptor;
91 const char *direct_reference;
92 gint32 indirect_reference;
99 tvbuff_t *single_asn1_type;
100 tvbuff_t *octet_aligned;
104 int (*ber_callback)(gboolean imp_tag, tvbuff_t *tvb, int offset, struct _asn1_ctx_t* ,proto_tree *tree, int hf_index );
107 int (*type_cb)(tvbuff_t*, int, struct _asn1_ctx_t*, proto_tree*, int);
113 gboolean data_value_descr_present;
114 tvbuff_t *data_value_descriptor;
119 2 : presentation-context-id,
120 3 : context-negotiation,
124 gint32 presentation_context_id;
125 const char *abstract_syntax;
126 const char *transfer_syntax;
127 tvbuff_t *data_value;
130 int (*ber_callback)(gboolean imp_tag, tvbuff_t *tvb, int offset, struct _asn1_ctx_t* ,proto_tree *tree, int hf_index );
133 int (*type_cb)(tvbuff_t*, int, struct _asn1_ctx_t*, proto_tree*, int);
137 struct _rose_ctx_t *rose_ctx;
140 #define ROSE_CTX_SIGNATURE 0x524F5345 /* "ROSE" */
142 typedef struct _rose_ctx_t {
144 dissector_table_t arg_global_dissector_table;
145 dissector_table_t arg_local_dissector_table;
146 dissector_table_t res_global_dissector_table;
147 dissector_table_t res_local_dissector_table;
148 dissector_table_t err_global_dissector_table;
149 dissector_table_t err_local_dissector_table;
150 /* filling in description into tree, info column, any buffer */
152 gboolean fillin_info;
154 gsize fillin_buf_size;
155 struct { /* "dynamic" data */
165 -1 : none (optional in ReturnResult)
170 const char *code_global;
171 proto_item *code_item;
176 extern void asn1_ctx_init(asn1_ctx_t *actx, asn1_enc_e encoding, gboolean aligned, packet_info *pinfo);
177 extern gboolean asn1_ctx_check_signature(asn1_ctx_t *actx);
178 extern void asn1_ctx_clean_external(asn1_ctx_t *actx);
179 extern void asn1_ctx_clean_epdv(asn1_ctx_t *actx);
181 extern void asn1_stack_frame_push(asn1_ctx_t *actx, const gchar *name);
182 extern void asn1_stack_frame_pop(asn1_ctx_t *actx, const gchar *name);
183 extern void asn1_stack_frame_check(asn1_ctx_t *actx, const gchar *name, const asn1_par_def_t *par_def);
185 extern void asn1_param_push_boolean(asn1_ctx_t *actx, gboolean value);
186 extern void asn1_param_push_integer(asn1_ctx_t *actx, gint32 value);
187 extern gboolean asn1_param_get_boolean(asn1_ctx_t *actx, const gchar *name);
188 extern gint32 asn1_param_get_integer(asn1_ctx_t *actx, const gchar *name);
190 extern void rose_ctx_init(rose_ctx_t *rctx);
191 extern gboolean rose_ctx_check_signature(rose_ctx_t *rctx);
192 extern void rose_ctx_clean_data(rose_ctx_t *rctx);
194 extern asn1_ctx_t *get_asn1_ctx(void *ptr);
195 extern rose_ctx_t *get_rose_ctx(void *ptr);
197 extern double asn1_get_real(const guint8 *real_ptr, gint real_len);
200 #define ASN1_EXT_ROOT 0x01
201 #define ASN1_EXT_EXT 0x02
202 #define ASN1_OPT 0x04
203 #define ASN1_DFLT 0x08
205 #define ASN1_HAS_EXT(f) ((f)&(ASN1_EXT_ROOT|ASN1_EXT_EXT))
208 #endif /* __ASN1_H__ */