2 * Routines for dissection of ASN.1 Aligned PER
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 __PACKET_PER_H__
27 #define __PACKET_PER_H__
29 #include "ws_symbol_export.h"
31 #define PER_NOT_DECODED_YET(x) \
32 proto_tree_add_text(tree, tvb, 0, 0, "something unknown here [%s]",x); \
33 col_append_fstr(actx->pinfo->cinfo, COL_INFO, "[UNKNOWN PER: %s]", x); \
34 tvb_get_guint8(tvb, 9999);
36 typedef int (*per_type_fn
)(tvbuff_t
*, int, asn1_ctx_t
*, proto_tree
*, int);
38 /* in all functions here, offset is guint32 and is
39 byteposition<<3 + bitposition
42 /* value for value and size constraints */
46 /* values for extensions */
47 #define ASN1_NO_EXTENSIONS 0
48 #define ASN1_EXTENSION_ROOT ASN1_EXT_ROOT
49 #define ASN1_NOT_EXTENSION_ROOT ASN1_EXT_EXT
51 /* value for optional */
52 #define ASN1_NOT_OPTIONAL 0
53 #define ASN1_OPTIONAL ASN1_OPT
55 typedef struct _per_choice_t
{
62 typedef struct _per_sequence_t
{
69 WS_DLL_PUBLIC guint32
dissect_per_null(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
);
71 WS_DLL_PUBLIC guint32
dissect_per_GeneralString(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
);
73 WS_DLL_PUBLIC guint32
dissect_per_sequence_of(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*parent_tree
, int hf_index
, gint ett_index
, const per_sequence_t
*seq
);
75 WS_DLL_PUBLIC guint32
dissect_per_IA5String(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
);
77 WS_DLL_PUBLIC guint32
dissect_per_NumericString(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
);
79 WS_DLL_PUBLIC guint32
dissect_per_PrintableString(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
);
81 WS_DLL_PUBLIC guint32
dissect_per_VisibleString(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
);
83 WS_DLL_PUBLIC guint32
dissect_per_BMPString(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
);
85 extern guint32
dissect_per_UTF8String(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
);
87 extern guint32
dissect_per_object_descriptor(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, tvbuff_t
**value_tvb
);
89 WS_DLL_PUBLIC guint32
dissect_per_constrained_sequence_of(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*parent_tree
, int hf_index
, gint ett_index
, const per_sequence_t
*seq
, int min_len
, int max_len
, gboolean has_extension
);
91 WS_DLL_PUBLIC guint32
dissect_per_constrained_set_of(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*parent_tree
, int hf_index
, gint ett_index
, const per_sequence_t
*seq
, int min_len
, int max_len
, gboolean has_extension
);
93 WS_DLL_PUBLIC guint32
dissect_per_set_of(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*parent_tree
, int hf_index
, gint ett_index
, const per_sequence_t
*seq
);
95 WS_DLL_PUBLIC guint32
dissect_per_object_identifier(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, tvbuff_t
**value_tvb
);
96 WS_DLL_PUBLIC guint32
dissect_per_object_identifier_str(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, const char **value_stringx
);
98 WS_DLL_PUBLIC guint32
dissect_per_relative_oid(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, tvbuff_t
**value_tvb
);
99 WS_DLL_PUBLIC guint32
dissect_per_relative_oid_str(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, const char **value_stringx
);
101 WS_DLL_PUBLIC guint32
dissect_per_boolean(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, gboolean
*bool_val
);
103 WS_DLL_PUBLIC guint32
dissect_per_integer(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, gint32
*value
);
105 WS_DLL_PUBLIC guint32
dissect_per_constrained_integer(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, guint32 min
, guint32 max
, guint32
*value
, gboolean has_extension
);
107 WS_DLL_PUBLIC guint32
dissect_per_constrained_integer_64b(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, guint64 min
, guint64 max
, guint64
*value
, gboolean has_extension
);
109 WS_DLL_PUBLIC guint32
dissect_per_real(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, double *value
);
111 WS_DLL_PUBLIC guint32
dissect_per_choice(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, gint ett_index
, const per_choice_t
*choice
, gint
*value
);
113 WS_DLL_PUBLIC guint32
dissect_per_sequence(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*parent_tree
, int hf_index
, gint ett_index
, const per_sequence_t
*sequence
);
114 WS_DLL_PUBLIC guint32
dissect_per_sequence_eag(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, const per_sequence_t
*sequence
);
116 WS_DLL_PUBLIC guint32
dissect_per_octet_string(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
, tvbuff_t
**value_tvb
);
117 WS_DLL_PUBLIC guint32
dissect_per_octet_string_containing_pdu(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
, dissector_t type_cb
);
118 WS_DLL_PUBLIC guint32
dissect_per_octet_string_containing_pdu_new(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
, new_dissector_t type_cb
);
120 WS_DLL_PUBLIC guint32
dissect_per_bit_string(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
, tvbuff_t
**value_tvb
);
121 WS_DLL_PUBLIC guint32
dissect_per_bit_string_containing_pdu(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
, dissector_t type_cb
);
122 WS_DLL_PUBLIC guint32
dissect_per_bit_string_containing_pdu_new(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
, new_dissector_t type_cb
);
124 WS_DLL_PUBLIC guint32
dissect_per_restricted_character_string(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, int min_len
, int max_len
, gboolean has_extension
, const char *alphabet
, int alphabet_length
, tvbuff_t
**value_tvb
);
126 WS_DLL_PUBLIC guint32
dissect_per_enumerated(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, guint32 root_num
, guint32
*value
, gboolean has_extension
, guint32 ext_num
, guint32
*value_map
);
128 WS_DLL_PUBLIC guint32
dissect_per_open_type(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, per_type_fn type_cb
);
129 WS_DLL_PUBLIC guint32
dissect_per_open_type_pdu(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, dissector_t type_cb
);
130 WS_DLL_PUBLIC guint32
dissect_per_open_type_pdu_new(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, new_dissector_t type_cb
);
132 WS_DLL_PUBLIC guint32
dissect_per_external_type(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, per_type_fn type_cb
);
134 extern guint32
dissect_per_size_constrained_type(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx
, proto_tree
*tree
, int hf_index
, per_type_fn type_cb
, const gchar
*name
, int min_len
, int max_len
, gboolean has_extension
);
135 extern gboolean
get_size_constraint_from_stack(asn1_ctx_t
*actx
, const gchar
*name
, int *pmin_len
, int *pmax_len
, gboolean
*phas_extension
);
137 extern guint32
dissect_per_length_determinant(tvbuff_t
*tvb
, guint32 offset
, asn1_ctx_t
*actx _U_
, proto_tree
*tree
, int hf_index
, guint32
*length
);
139 #endif /* __PACKET_PER_H__ */