Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
asn1.h
Go to the documentation of this file.
1
13#ifndef __ASN1_H__
14#define __ASN1_H__
15
16#include "ws_symbol_export.h"
17
18typedef enum {
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 */
24} asn1_enc_e;
25
26typedef enum {
27 CB_ASN1_ENC,
28 CB_NEW_DISSECTOR,
29 CB_DISSECTOR_HANDLE
30} asn1_cb_variant;
31
32typedef enum {
33 ASN1_PAR_IRR, /* irrelevant parameter */
34 /* value */
35 ASN1_PAR_BOOLEAN,
36 ASN1_PAR_INTEGER,
37 /* type */
38 ASN1_PAR_TYPE
39} asn1_par_type;
40
41typedef struct _asn1_par_def_t {
42 const char *name;
43 asn1_par_type ptype;
45
46typedef struct _asn1_par_t {
47 const char *name;
48 asn1_par_type ptype;
49 union {
50 bool v_boolean;
51 int32_t v_integer;
52 void *v_type;
53 } value;
54 struct _asn1_par_t *next;
56
57typedef struct _asn1_stack_frame_t {
58 const char *name;
59 struct _asn1_par_t *par;
60 struct _asn1_stack_frame_t *next;
62
63#define ASN1_CTX_SIGNATURE 0x41435458 /* "ACTX" */
64
65typedef struct _asn1_ctx_t {
66 uint32_t signature;
67 asn1_enc_e encoding;
68 bool aligned;
69 packet_info *pinfo;
70 proto_item *created_item;
71 struct _asn1_stack_frame_t *stack;
72 void *value_ptr;
73 void *private_data;
74 struct {
75 int hf_index;
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;
82 int encoding;
83 /*
84 0 : single-ASN1-type,
85 1 : octet-aligned,
86 2 : arbitrary
87 */
88 tvbuff_t *single_asn1_type;
89 tvbuff_t *octet_aligned;
90 tvbuff_t *arbitrary;
91 union {
92 struct {
93 int (*ber_callback)(bool imp_tag, tvbuff_t *tvb, int offset, struct _asn1_ctx_t* ,proto_tree *tree, int hf_index );
94 } ber;
95 struct {
96 int (*type_cb)(tvbuff_t*, int, struct _asn1_ctx_t*, proto_tree*, int);
97 } per;
98 } u;
99 } external;
100 struct {
101 proto_tree *tree;
102 proto_tree *top_tree;
103 void* tree_ctx;
104 } subtree;
105 struct {
106 int hf_index;
107 bool data_value_descr_present;
108 tvbuff_t *data_value_descriptor;
109 int identification;
110 /*
111 0 : syntaxes,
112 1 : syntax,
113 2 : presentation-context-id,
114 3 : context-negotiation,
115 4 : transfer-syntax,
116 5 : fixed
117 */
118 int32_t presentation_context_id;
119 const char *abstract_syntax;
120 const char *transfer_syntax;
121 tvbuff_t *data_value;
122 union {
123 struct {
124 int (*ber_callback)(bool imp_tag, tvbuff_t *tvb, int offset, struct _asn1_ctx_t* ,proto_tree *tree, int hf_index );
125 } ber;
126 struct {
127 int (*type_cb)(tvbuff_t*, int, struct _asn1_ctx_t*, proto_tree*, int);
128 } per;
129 } u;
130 } embedded_pdv;
131 struct _rose_ctx_t *rose_ctx;
132} asn1_ctx_t;
133
134#define ROSE_CTX_SIGNATURE 0x524F5345 /* "ROSE" */
135
136typedef struct _rose_ctx_t {
137 uint32_t signature;
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 */
145 int apdu_depth;
146 bool fillin_info;
147 char *fillin_ptr;
148 size_t fillin_buf_size;
149 struct { /* "dynamic" data */
150 int pdu;
151 /*
152 1 : invoke,
153 2 : returnResult,
154 3 : returnError,
155 4 : reject
156 */
157 int code;
158 /*
159 -1 : none (optional in ReturnResult)
160 0 : local,
161 1 : global
162 */
163 int32_t code_local;
164 const char *code_global;
165 proto_item *code_item;
166 } d;
167 void *private_data;
168} rose_ctx_t;
169
170WS_DLL_PUBLIC void asn1_ctx_init(asn1_ctx_t *actx, asn1_enc_e encoding, bool aligned, packet_info *pinfo);
171extern bool asn1_ctx_check_signature(asn1_ctx_t *actx);
172extern void asn1_ctx_clean_external(asn1_ctx_t *actx);
173extern void asn1_ctx_clean_epdv(asn1_ctx_t *actx);
174
175extern void asn1_stack_frame_push(asn1_ctx_t *actx, const char *name);
176extern void asn1_stack_frame_pop(asn1_ctx_t *actx, const char *name);
177extern void asn1_stack_frame_check(asn1_ctx_t *actx, const char *name, const asn1_par_def_t *par_def);
178
179extern void asn1_param_push_boolean(asn1_ctx_t *actx, bool value);
180extern void asn1_param_push_integer(asn1_ctx_t *actx, int32_t value);
181extern bool asn1_param_get_boolean(asn1_ctx_t *actx, const char *name);
182extern int32_t asn1_param_get_integer(asn1_ctx_t *actx, const char *name);
183
184WS_DLL_PUBLIC void rose_ctx_init(rose_ctx_t *rctx);
185extern bool rose_ctx_check_signature(rose_ctx_t *rctx);
186WS_DLL_PUBLIC void rose_ctx_clean_data(rose_ctx_t *rctx);
187
188WS_DLL_PUBLIC asn1_ctx_t *get_asn1_ctx(void *ptr);
189WS_DLL_PUBLIC rose_ctx_t *get_rose_ctx(void *ptr);
190
191extern double asn1_get_real(const uint8_t *real_ptr, int len);
192
193/* flags */
194#define ASN1_EXT_ROOT 0x01
195#define ASN1_EXT_EXT 0x02
196#define ASN1_OPT 0x04
197#define ASN1_DFLT 0x08
198
199#define ASN1_HAS_EXT(f) ((f)&(ASN1_EXT_ROOT|ASN1_EXT_EXT))
200
201
202#endif /* __ASN1_H__ */
double asn1_get_real(const uint8_t *real_ptr, int len)
Definition asn1.c:187
Definition asn1.h:65
Definition asn1.h:41
Definition asn1.h:46
Definition asn1.h:57
Definition packet_info.h:43
Definition proto.h:903
Definition asn1.h:136
Definition packet.c:86
Definition tvbuff-int.h:35