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