3 * Common data for ASN.1
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include "ws_symbol_export.h"
19 ASN1_ENC_BER
, /* X.690 - BER, CER, DER */
20 ASN1_ENC_PER
, /* X.691 - PER */
21 ASN1_ENC_ECN
, /* X.692 - ECN */
22 ASN1_ENC_XER
, /* X.693 - XER */
23 ASN1_ENC_OER
/* X.696 - OER */
33 ASN1_PAR_IRR
, /* irrelevant parameter */
41 typedef struct _asn1_par_def_t
{
46 typedef struct _asn1_par_t
{
54 struct _asn1_par_t
*next
;
57 typedef struct _asn1_stack_frame_t
{
59 struct _asn1_par_t
*par
;
60 struct _asn1_stack_frame_t
*next
;
63 #define ASN1_CTX_SIGNATURE 0x41435458 /* "ACTX" */
65 typedef struct _asn1_ctx_t
{
70 proto_item
*created_item
;
71 struct _asn1_stack_frame_t
*stack
;
76 bool data_value_descr_present
;
77 bool direct_ref_present
;
78 bool indirect_ref_present
;
79 tvbuff_t
*data_value_descriptor
;
80 const char *direct_reference
;
81 int32_t indirect_reference
;
88 tvbuff_t
*single_asn1_type
;
89 tvbuff_t
*octet_aligned
;
93 int (*ber_callback
)(bool imp_tag
, tvbuff_t
*tvb
, int offset
, struct _asn1_ctx_t
* ,proto_tree
*tree
, int hf_index
);
96 int (*type_cb
)(tvbuff_t
*, int, struct _asn1_ctx_t
*, proto_tree
*, int);
102 proto_tree
*top_tree
;
107 bool data_value_descr_present
;
108 tvbuff_t
*data_value_descriptor
;
113 2 : presentation-context-id,
114 3 : context-negotiation,
118 int32_t presentation_context_id
;
119 const char *abstract_syntax
;
120 const char *transfer_syntax
;
121 tvbuff_t
*data_value
;
124 int (*ber_callback
)(bool imp_tag
, tvbuff_t
*tvb
, int offset
, struct _asn1_ctx_t
* ,proto_tree
*tree
, int hf_index
);
127 int (*type_cb
)(tvbuff_t
*, int, struct _asn1_ctx_t
*, proto_tree
*, int);
131 struct _rose_ctx_t
*rose_ctx
;
134 #define ROSE_CTX_SIGNATURE 0x524F5345 /* "ROSE" */
136 typedef struct _rose_ctx_t
{
138 dissector_table_t arg_global_dissector_table
;
139 dissector_table_t arg_local_dissector_table
;
140 dissector_table_t res_global_dissector_table
;
141 dissector_table_t res_local_dissector_table
;
142 dissector_table_t err_global_dissector_table
;
143 dissector_table_t err_local_dissector_table
;
144 /* filling in description into tree, info column, any buffer */
148 size_t fillin_buf_size
;
149 struct { /* "dynamic" data */
159 -1 : none (optional in ReturnResult)
164 const char *code_global
;
165 proto_item
*code_item
;
170 WS_DLL_PUBLIC
void asn1_ctx_init(asn1_ctx_t
*actx
, asn1_enc_e encoding
, bool aligned
, packet_info
*pinfo
);
171 extern bool asn1_ctx_check_signature(asn1_ctx_t
*actx
);
172 extern void asn1_ctx_clean_external(asn1_ctx_t
*actx
);
173 extern void asn1_ctx_clean_epdv(asn1_ctx_t
*actx
);
175 extern void asn1_stack_frame_push(asn1_ctx_t
*actx
, const char *name
);
176 extern void asn1_stack_frame_pop(asn1_ctx_t
*actx
, const char *name
);
177 extern void asn1_stack_frame_check(asn1_ctx_t
*actx
, const char *name
, const asn1_par_def_t
*par_def
);
179 extern void asn1_param_push_boolean(asn1_ctx_t
*actx
, bool value
);
180 extern void asn1_param_push_integer(asn1_ctx_t
*actx
, int32_t value
);
181 extern bool asn1_param_get_boolean(asn1_ctx_t
*actx
, const char *name
);
182 extern int32_t asn1_param_get_integer(asn1_ctx_t
*actx
, const char *name
);
184 WS_DLL_PUBLIC
void rose_ctx_init(rose_ctx_t
*rctx
);
185 extern bool rose_ctx_check_signature(rose_ctx_t
*rctx
);
186 WS_DLL_PUBLIC
void rose_ctx_clean_data(rose_ctx_t
*rctx
);
188 WS_DLL_PUBLIC asn1_ctx_t
*get_asn1_ctx(void *ptr
);
189 WS_DLL_PUBLIC rose_ctx_t
*get_rose_ctx(void *ptr
);
191 extern double asn1_get_real(const uint8_t *real_ptr
, int len
);
194 #define ASN1_EXT_ROOT 0x01
195 #define ASN1_EXT_EXT 0x02
196 #define ASN1_OPT 0x04
197 #define ASN1_DFLT 0x08
199 #define ASN1_HAS_EXT(f) ((f)&(ASN1_EXT_ROOT|ASN1_EXT_EXT))
202 #endif /* __ASN1_H__ */