| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
oids.h
Go to the documentation of this file.
1/* oids.h
2 * Object IDentifier Support
3 *
4 * (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org>
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13#ifndef __OIDS_H__
14#define __OIDS_H__
15
16#include <epan/ftypes/ftypes.h>
17#include <epan/prefs.h>
18#include <epan/wmem_scopes.h>
19#include "ws_symbol_export.h"
20
21#ifdef __cplusplus
22 extern "C" {
23#endif /* __cplusplus */
24
28#define BER_TAG_ANY -1
29
30 struct _oid_bit_t {
31 unsigned offset;
32 int hfid;
33};
34
35 typedef struct _oid_bits_info_t {
36 unsigned num;
37 int ett;
38 struct _oid_bit_t* data;
39} oid_bits_info_t;
40
41 typedef enum _oid_key_type_t {
42 OID_KEY_TYPE_WRONG,
43 OID_KEY_TYPE_INTEGER,
44 OID_KEY_TYPE_OID,
45 OID_KEY_TYPE_STRING,
46 OID_KEY_TYPE_BYTES,
47 OID_KEY_TYPE_NSAP,
48 OID_KEY_TYPE_IPADDR,
49 OID_KEY_TYPE_IMPLIED_OID,
50 OID_KEY_TYPE_IMPLIED_STRING,
51 OID_KEY_TYPE_IMPLIED_BYTES,
52 OID_KEY_TYPE_ETHER,
53 OID_KEY_TYPE_DATE_AND_TIME
54} oid_key_type_t;
55
56 typedef struct _oid_value_type_t {
57 enum ftenum ft_type;
58 int display;
59 int8_t ber_class;
60 int32_t ber_tag;
61 int min_len;
62 int max_len;
63 oid_key_type_t keytype;
64 int keysize;
65} oid_value_type_t;
66
67 typedef enum _oid_kind_t {
68 OID_KIND_UNKNOWN = 0,
69 OID_KIND_NODE,
70 OID_KIND_SCALAR,
71 OID_KIND_TABLE,
72 OID_KIND_ROW,
73 OID_KIND_COLUMN,
74 OID_KIND_NOTIFICATION,
75 OID_KIND_GROUP,
76 OID_KIND_COMPLIANCE,
77 OID_KIND_CAPABILITIES
78} oid_kind_t;
79
80 typedef struct _oid_key_t {
81 char* name;
82 uint32_t num_subids;
83 oid_key_type_t key_type;
84 int hfid;
85 enum ftenum ft_type;
86 int display;
87 struct _oid_key_t* next;
88} oid_key_t;
89
90 typedef struct _oid_info_t {
91 uint32_t subid;
92 char* name;
93 oid_kind_t kind;
94 wmem_tree_t* children;
95 const oid_value_type_t* value_type;
96 int value_hfid;
97 oid_key_t* key;
98 oid_bits_info_t* bits;
99 struct _oid_info_t* parent;
100} oid_info_t;
101
103WS_DLL_PUBLIC void oids_init(const char* app_env_var_prefix);
104 extern void oid_pref_init(module_t *nameres);
105
107WS_DLL_PUBLIC void oids_cleanup(void);
108
109/*
110 * The objects returned by all these functions are all allocated with a
111 * packet lifetime and do not have to be freed.
112 * However, take into account that when the packet dissection
113 * completes, these buffers will be automatically reclaimed/freed.
114 * If you need the buffer to remain for a longer scope than packet lifetime
115 * you must copy the content to an wmem_file_scope() buffer.
116 */
117
118/*
119 * These functions convert through the various formats:
120 * string: is like "0.1.3.4.5.30" (not resolved)
121 * encoded: is BER encoded (as per X.690 section 8.19)
122 * subids: is an array of uint32_t
123 */
124
125/* return length of encoded buffer */
126WS_DLL_PUBLIC
127 unsigned oid_subid2encoded(wmem_allocator_t *scope, unsigned len, uint32_t* subids, uint8_t** encoded_p);
128WS_DLL_PUBLIC
129 unsigned oid_string2encoded(wmem_allocator_t *scope, const char *oid_str, uint8_t** encoded_p);
130
131/* return length of subid array */
132WS_DLL_PUBLIC
133 unsigned oid_encoded2subid(wmem_allocator_t *scope, const uint8_t *oid, int len, uint32_t** subids_p);
134WS_DLL_PUBLIC
135 unsigned oid_encoded2subid_sub(wmem_allocator_t *scope, const uint8_t *oid_bytes, int oid_len, uint32_t** subids_pi,
136 bool is_first);
137WS_DLL_PUBLIC
138 unsigned oid_string2subid(wmem_allocator_t *scope, const char *oid_str, uint32_t** subids_p);
139
140WS_DLL_PUBLIC char* oid_encoded2string(wmem_allocator_t *scope, const uint8_t* encoded, unsigned len);
141WS_DLL_PUBLIC char* rel_oid_encoded2string(wmem_allocator_t *scope, const uint8_t* encoded, unsigned len);
142WS_DLL_PUBLIC char* oid_subid2string(wmem_allocator_t *scope, uint32_t *subids, unsigned len);
143WS_DLL_PUBLIC char* rel_oid_subid2string(wmem_allocator_t *scope, uint32_t *subids, unsigned len, bool is_absolute);
144
145/* these return a formated string as human readable as possible */
146WS_DLL_PUBLIC char *oid_resolved(wmem_allocator_t *scope, unsigned len, uint32_t *subids);
147WS_DLL_PUBLIC char *oid_resolved_from_encoded(wmem_allocator_t *scope, const uint8_t *oid, int len);
148WS_DLL_PUBLIC char *rel_oid_resolved_from_encoded(wmem_allocator_t *scope, const uint8_t *oid, int len);
149WS_DLL_PUBLIC char *oid_resolved_from_string(wmem_allocator_t *scope, const char *oid_str);
150
151/* these yield two formated strings one resolved and one numeric */
152WS_DLL_PUBLIC void oid_both(wmem_allocator_t *scope, unsigned oid_len, uint32_t *subids, char** resolved_p, char** numeric_p);
153WS_DLL_PUBLIC void oid_both_from_encoded(wmem_allocator_t *scope, const uint8_t *oid, int oid_len, char** resolved_p, char** numeric_p);
154WS_DLL_PUBLIC void oid_both_from_string(wmem_allocator_t *scope, const char *oid_str, char** resolved_p, char** numeric_p);
155
156/*
157 * These return the info for the best match.
158 * *matched_p will be set to the number of nodes used by the returned oid
159 * *left_p will be set to the number of remaining unresolved subids
160 */
161WS_DLL_PUBLIC oid_info_t* oid_get(unsigned oid_len, uint32_t *subids, unsigned* matched_p, unsigned* left_p);
162WS_DLL_PUBLIC oid_info_t* oid_get_from_encoded(wmem_allocator_t *scope, const uint8_t *oid, int oid_len, uint32_t **subids, unsigned* matched, unsigned* left);
163WS_DLL_PUBLIC oid_info_t* oid_get_from_string(wmem_allocator_t *scope, const char *oid_str, uint32_t **subids, unsigned* matched, unsigned* left);
164
165/* these are used to add oids to the collection */
166WS_DLL_PUBLIC void oid_add(const char* name, unsigned oid_len, uint32_t *subids);
167WS_DLL_PUBLIC void oid_add_from_encoded(const char* name, const uint8_t *oid, int oid_len);
168WS_DLL_PUBLIC void oid_add_from_string(const char* name, const char *oid_str);
169
176WS_DLL_PUBLIC char *oid_get_default_mib_path(const char* app_env_var_prefix);
177
178/* macros for legacy oid functions */
179#define subid_t uint32_t
180
181
182
183#ifdef DEBUG_OIDS
184 extern char* oid_test_a2b(uint32_t num_subids, uint32_t* subids);
185 extern void add_oid_debug_subtree(oid_info_t* oid_info, proto_tree *tree);
186#else
187#define add_oid_debug_subtree(a,b) ((void)0)
188#endif
189
190#ifdef __cplusplus
191}
192#endif /* __cplusplus */
193
194#endif /* __OIDS_H__ */
195
196/*
197 * Editor modelines
198 *
199 * Local Variables:
200 * c-basic-offset: 4
201 * tab-width: 8
202 * indent-tabs-mode: nil
203 * End:
204 *
205 * ex: set shiftwidth=4 tabstop=8 expandtab:
206 * :indentSize=4:tabSize=8:noTabs=true:
207 */
ftypes.h
oids_init
WS_DLL_PUBLIC void oids_init(const char *app_env_var_prefix)
oid_get_default_mib_path
WS_DLL_PUBLIC char * oid_get_default_mib_path(const char *app_env_var_prefix)
oids_cleanup
WS_DLL_PUBLIC void oids_cleanup(void)
Definition oids.c:870
prefs.h
_oid_bit_t
Definition oids.h:30
_oid_bits_info_t
Definition oids.h:35
_oid_info_t
Definition oids.h:90
_oid_key_t
Definition oids.h:80
_oid_value_type_t
Definition oids.h:56
_proto_node
Definition proto.h:907
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
_wmem_tree_t
Internal representation of a wmem balanced tree.
Definition wmem_tree-int.h:81
pref_module
Definition prefs-int.h:27
wmem_scopes.h