Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-per.h
1/* packet-per.h
2 * Routines for dissection of ASN.1 Aligned PER
3 * 2003 Ronnie Sahlberg
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <[email protected]>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12#ifndef __PACKET_PER_H__
13#define __PACKET_PER_H__
14
15#include <epan/asn1.h>
16#include "ws_symbol_export.h"
17
18typedef unsigned (*per_type_fn)(tvbuff_t*, uint32_t offset, asn1_ctx_t*, proto_tree*, int);
19
20/* in all functions here, offset is uint32_t and is
21 byteposition<<3 + bitposition
22*/
23
24/* value for value and size constraints */
25#define NO_BOUND -1
26
27
28/* values for extensions */
29#define ASN1_NO_EXTENSIONS 0
30#define ASN1_EXTENSION_ROOT ASN1_EXT_ROOT
31#define ASN1_NOT_EXTENSION_ROOT ASN1_EXT_EXT
32
33/* value for optional */
34#define ASN1_NOT_OPTIONAL 0
35#define ASN1_OPTIONAL ASN1_OPT
36
37typedef struct _per_choice_t {
38 int value;
39 const int *p_id;
40 int extension;
41 per_type_fn func;
43
44typedef struct _per_sequence_t {
45 const int *p_id;
46 int extension;
47 int optional;
48 per_type_fn func;
50
51WS_DLL_PUBLIC void dissect_per_not_decoded_yet(proto_tree* tree, packet_info* pinfo, tvbuff_t *tvb, const char* reason);
52
53WS_DLL_PUBLIC uint32_t dissect_per_null(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
54
55WS_DLL_PUBLIC uint32_t dissect_per_GeneralString(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index);
56
57WS_DLL_PUBLIC uint32_t dissect_per_sequence_of(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *parent_tree, int hf_index, int ett_index, const per_sequence_t *seq);
58
59WS_DLL_PUBLIC uint32_t dissect_per_IA5String(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, tvbuff_t **value_tvb);
60
61WS_DLL_PUBLIC uint32_t dissect_per_NumericString(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, tvbuff_t **value_tvb);
62
63WS_DLL_PUBLIC uint32_t dissect_per_PrintableString(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, tvbuff_t **value_tvb);
64
65WS_DLL_PUBLIC uint32_t dissect_per_VisibleString(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, tvbuff_t **value_tvb);
66
67WS_DLL_PUBLIC uint32_t dissect_per_BMPString(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension);
68
69WS_DLL_PUBLIC uint32_t dissect_per_UTF8String(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension);
70
71extern uint32_t dissect_per_object_descriptor(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, tvbuff_t **value_tvb);
72
73WS_DLL_PUBLIC uint32_t dissect_per_constrained_sequence_of(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *parent_tree, int hf_index, int ett_index, const per_sequence_t *seq, int min_len, int max_len, bool has_extension);
74
75WS_DLL_PUBLIC uint32_t dissect_per_constrained_set_of(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *parent_tree, int hf_index, int ett_index, const per_sequence_t *seq, int min_len, int max_len, bool has_extension);
76
77WS_DLL_PUBLIC uint32_t dissect_per_set_of(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *parent_tree, int hf_index, int ett_index, const per_sequence_t *seq);
78
79WS_DLL_PUBLIC uint32_t dissect_per_object_identifier(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, tvbuff_t **value_tvb);
80WS_DLL_PUBLIC uint32_t dissect_per_object_identifier_str(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, const char **value_stringx);
81
82WS_DLL_PUBLIC uint32_t dissect_per_relative_oid(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, tvbuff_t **value_tvb);
83WS_DLL_PUBLIC uint32_t dissect_per_relative_oid_str(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, const char **value_stringx);
84
85WS_DLL_PUBLIC uint32_t dissect_per_boolean(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, bool *bool_val);
86
87WS_DLL_PUBLIC uint32_t dissect_per_integer(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int32_t *value);
88WS_DLL_PUBLIC uint32_t dissect_per_integer64b(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int64_t *value);
89WS_DLL_PUBLIC uint32_t dissect_per_constrained_integer(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, uint32_t min, uint32_t max, uint32_t *value, bool has_extension);
90WS_DLL_PUBLIC uint32_t dissect_per_constrained_integer_64b(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, uint64_t min, uint64_t max, uint64_t *value, bool has_extension);
91
92WS_DLL_PUBLIC uint32_t dissect_per_real(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, double *value);
93
94/*
95 * @brief Dissects a PER choice
96 *
97 * @attention
98 * The return value of value (which can be mapped to a variable via VAL_PTR
99 * in a conformance file) is the tag number. Tag numbers are non-negative
100 * integers (X.680 8.2), but here value can be -1 if no alternative was
101 * selected. This is not necessarily an error if the choice was OPTIONAL.
102 * (The function does not have a way to distinguish between a CHOICE which
103 * is OPTIONAL and one which is not, and so treats all as optional.)
104 *
105 * This is *not* the same usage as dissect_ber_choice, which returns the
106 * ordinal number of the branch taken.
107 *
108 * @note
109 * Since the value can be -1 to indicate that the CHOICE was not present,
110 * it is safest to check that it is not so:
111 * ```c
112 * if (value != -1) {
113 * char* identifier = val_to_str_const(value, proto_ChoiceType_vals, "Unknown");
114 * }
115 * ```
116 * It is possible, albeit unlikely, that a ChoiceType may have a tag number
117 * greater than INT32_MAX. If the ChoiceType has a tag number of UINT32_MAX
118 * then the value is ambiguous.
119 */
120WS_DLL_PUBLIC uint32_t dissect_per_choice(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int ett_index, const per_choice_t *choice, int *value);
121
122WS_DLL_PUBLIC uint32_t dissect_per_sequence(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *parent_tree, int hf_index, int ett_index, const per_sequence_t *sequence);
123WS_DLL_PUBLIC uint32_t dissect_per_sequence_eag(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, const per_sequence_t *sequence);
124
125WS_DLL_PUBLIC uint32_t dissect_per_octet_string(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, tvbuff_t **value_tvb);
126WS_DLL_PUBLIC uint32_t dissect_per_octet_string_containing_pdu_new(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, dissector_t type_cb);
127
128WS_DLL_PUBLIC uint32_t dissect_per_bit_string(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, int * const *named_bits, int num_named_bits, tvbuff_t **value_tvb, int *len);
129
130WS_DLL_PUBLIC uint32_t dissect_per_bit_string_containing_pdu_new(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, dissector_t type_cb);
131
132WS_DLL_PUBLIC uint32_t dissect_per_restricted_character_string(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, bool has_extension, const char *alphabet, int alphabet_length, tvbuff_t **value_tvb);
133
134WS_DLL_PUBLIC uint32_t dissect_per_enumerated(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, uint32_t root_num, uint32_t *value, bool has_extension, uint32_t ext_num, const uint32_t *value_map);
135
136WS_DLL_PUBLIC uint32_t dissect_per_open_type(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, per_type_fn type_cb);
137WS_DLL_PUBLIC uint32_t dissect_per_open_type_pdu_new(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, dissector_t type_cb);
138
139WS_DLL_PUBLIC uint32_t dissect_per_external_type(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, per_type_fn type_cb);
140
141WS_DLL_PUBLIC uint32_t dissect_per_size_constrained_type(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, per_type_fn type_cb, const char *name, int min_len, int max_len, bool has_extension);
142extern bool get_size_constraint_from_stack(asn1_ctx_t *actx, const char *name, int *pmin_len, int *pmax_len, bool *phas_extension);
143
144extern uint32_t dissect_per_length_determinant(tvbuff_t *tvb, uint32_t offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index, uint32_t *length, bool *is_fragmented);
145
146WS_DLL_PUBLIC unsigned call_per_oid_callback(const char *oid, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned offset, asn1_ctx_t *actx, int hf_index);
147WS_DLL_PUBLIC void add_per_encoded_label(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree);
148
149/* PUBLIC_HEADER: This is used by custom dissectors and should be in the "install" target */
150WS_DLL_PUBLIC void register_per_oid_dissector(const char *oid, dissector_t dissector, int proto, const char *name);
151
152#endif /* __PACKET_PER_H__ */
Definition asn1.h:66
Definition packet_info.h:43
Definition packet-per.h:37
Definition packet-per.h:44
Definition proto.h:907
Definition tvbuff-int.h:36