2 * Object IDentifier Support
6 * (c) 2007, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #define BER_TAG_ANY -1
37 typedef struct _oid_bits_info_t {
40 struct _oid_bit_t* data;
43 typedef enum _oid_key_type_t {
51 OID_KEY_TYPE_IMPLIED_OID,
52 OID_KEY_TYPE_IMPLIED_STRING,
53 OID_KEY_TYPE_IMPLIED_BYTES
56 typedef struct _oid_value_type_t {
63 oid_key_type_t keytype;
67 typedef enum _oid_kind_t {
74 OID_KIND_NOTIFICATION,
80 typedef struct _oid_key_t {
83 oid_key_type_t key_type;
87 struct _oid_key_t* next;
90 typedef struct _oid_info_t {
94 void* children; /* an emem_tree_t* */
95 const oid_value_type_t* value_type;
98 oid_bits_info_t* bits;
99 struct _oid_info_t* parent;
102 /* init funcion called from epan.h */
103 extern void oids_init(void);
106 * The objects returned by all these functions are all allocated with a
107 * packet lifetime and does not have have to be freed.
108 * However, take into account that when the packet dissection
109 * completes, these buffers will be automatically reclaimed/freed.
110 * If you need the buffer to remain for a longer scope than packet lifetime
111 * you must copy the content to an se_alloc() buffer.
115 * These functions convert through the various formats:
116 * string: is like "0.1.3.4.5.30" (not resolved)
117 * encoded: is BER encoded (as per X.690 section 8.19)
118 * subids: is an array of guint32s
121 /* return length of encoded buffer */
122 guint oid_subid2encoded(guint len, guint32* subids, guint8** encoded_p);
123 guint oid_string2encoded(const gchar *oid_str, guint8** encoded_p);
125 /* return length of subid array */
126 guint oid_encoded2subid(const guint8 *oid, gint len, guint32** subids_p);
127 guint oid_string2subid(const gchar *oid_str, guint32** subids_p);
129 extern const gchar* oid_encoded2string(const guint8* encoded, guint len);
130 extern const gchar* oid_subid2string(guint32 *subids, guint len);
132 /* these return a formated string as human readable as posible */
133 extern const gchar *oid_resolved(guint len, guint32 *subids);
134 extern const gchar *oid_resolved_from_encoded(const guint8 *oid, gint len);
135 extern const gchar *oid_resolved_from_string(const gchar *oid_str);
137 /* these yield two formated strings one resolved and one numeric */
138 extern void oid_both(guint oid_len, guint32 *subids, char** resolved_p, char** numeric_p);
139 extern void oid_both_from_encoded(const guint8 *oid, gint oid_len, char** resolved_p, char** numeric_p);
140 extern void oid_both_from_string(const gchar *oid_str, char** resolved_p, char** numeric_p);
143 * These return the info for the best match.
144 * *matched_p will be set to the number of nodes used by the returned oid
145 * *left_p will be set to the number of remaining unresolved subids
147 extern oid_info_t* oid_get(guint oid_len, guint32 *subids, guint* matched_p, guint* left_p);
148 extern oid_info_t* oid_get_from_encoded(const guint8 *oid, gint oid_len, guint32 **subids, guint* matched, guint* left);
149 extern oid_info_t* oid_get_from_string(const gchar *oid_str, guint32 **subids, guint* matched, guint* left);
151 /* these are used to add oids to the collection */
152 extern void oid_add(const char* name, guint oid_len, guint32 *subids);
153 extern void oid_add_from_encoded(const char* name, const guint8 *oid, gint oid_len);
154 extern void oid_add_from_string(const char* name, const gchar *oid_str);
157 /* macros for legacy oid functions */
158 #define oid_resolv_cleanup() ((void)0)
159 #define subid_t guint32
164 extern char* oid_test_a2b(guint32 num_subids, guint32* subids);
165 extern void add_oid_debug_subtree(oid_info_t* oid_info, proto_tree *tree);
167 #define add_oid_debug_subtree(a,b) ((void)0)