2007-08-19 23:00:47 +00:00
|
|
|
/* oids.h
|
2007-08-26 21:37:11 +00:00
|
|
|
* Object IDentifier Support
|
2007-08-15 19:52:44 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-08-05 21:03:46 +00:00
|
|
|
* (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org>
|
2007-08-15 19:52:44 +00:00
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __OIDS_H__
|
|
|
|
#define __OIDS_H__
|
|
|
|
|
2007-12-04 18:43:40 +00:00
|
|
|
#define BER_TAG_ANY -1
|
2007-08-19 23:00:47 +00:00
|
|
|
|
2007-08-15 19:52:44 +00:00
|
|
|
struct _oid_bit_t {
|
|
|
|
guint offset;
|
|
|
|
int hfid;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _oid_bits_info_t {
|
|
|
|
guint num;
|
|
|
|
gint ett;
|
|
|
|
struct _oid_bit_t* data;
|
|
|
|
} oid_bits_info_t;
|
|
|
|
|
2007-08-22 22:56:36 +00:00
|
|
|
typedef enum _oid_key_type_t {
|
|
|
|
OID_KEY_TYPE_WRONG,
|
|
|
|
OID_KEY_TYPE_INTEGER,
|
2007-09-13 16:49:51 +00:00
|
|
|
OID_KEY_TYPE_OID,
|
2007-08-22 22:56:36 +00:00
|
|
|
OID_KEY_TYPE_STRING,
|
|
|
|
OID_KEY_TYPE_BYTES,
|
|
|
|
OID_KEY_TYPE_NSAP,
|
2007-09-13 16:49:51 +00:00
|
|
|
OID_KEY_TYPE_IPADDR,
|
|
|
|
OID_KEY_TYPE_IMPLIED_OID,
|
|
|
|
OID_KEY_TYPE_IMPLIED_STRING,
|
2008-11-10 20:25:38 +00:00
|
|
|
OID_KEY_TYPE_IMPLIED_BYTES,
|
2008-12-02 08:11:23 +00:00
|
|
|
OID_KEY_TYPE_ETHER
|
2007-08-22 22:56:36 +00:00
|
|
|
} oid_key_type_t;
|
|
|
|
|
2007-08-19 23:00:47 +00:00
|
|
|
typedef struct _oid_value_type_t {
|
|
|
|
enum ftenum ft_type;
|
|
|
|
int display;
|
|
|
|
gint8 ber_class;
|
|
|
|
gint32 ber_tag;
|
2007-12-04 18:43:40 +00:00
|
|
|
int min_len;
|
2007-08-19 23:00:47 +00:00
|
|
|
int max_len;
|
2007-08-22 22:56:36 +00:00
|
|
|
oid_key_type_t keytype;
|
|
|
|
int keysize;
|
2007-12-04 18:43:40 +00:00
|
|
|
} oid_value_type_t;
|
2007-08-19 23:00:47 +00:00
|
|
|
|
2007-08-22 22:56:36 +00:00
|
|
|
typedef enum _oid_kind_t {
|
|
|
|
OID_KIND_UNKNOWN = 0,
|
|
|
|
OID_KIND_NODE,
|
|
|
|
OID_KIND_SCALAR,
|
|
|
|
OID_KIND_TABLE,
|
|
|
|
OID_KIND_ROW,
|
|
|
|
OID_KIND_COLUMN,
|
|
|
|
OID_KIND_NOTIFICATION,
|
|
|
|
OID_KIND_GROUP,
|
|
|
|
OID_KIND_COMPLIANCE,
|
|
|
|
OID_KIND_CAPABILITIES
|
|
|
|
} oid_kind_t;
|
|
|
|
|
|
|
|
typedef struct _oid_key_t {
|
|
|
|
char* name;
|
|
|
|
guint32 num_subids;
|
|
|
|
oid_key_type_t key_type;
|
|
|
|
int hfid;
|
|
|
|
enum ftenum ft_type;
|
|
|
|
int display;
|
|
|
|
struct _oid_key_t* next;
|
|
|
|
} oid_key_t;
|
|
|
|
|
2007-08-15 19:52:44 +00:00
|
|
|
typedef struct _oid_info_t {
|
|
|
|
guint32 subid;
|
|
|
|
char* name;
|
2007-08-22 22:56:36 +00:00
|
|
|
oid_kind_t kind;
|
2007-08-15 19:52:44 +00:00
|
|
|
void* children; /* an emem_tree_t* */
|
2007-08-19 23:00:47 +00:00
|
|
|
const oid_value_type_t* value_type;
|
2007-08-15 19:52:44 +00:00
|
|
|
int value_hfid;
|
2007-08-22 22:56:36 +00:00
|
|
|
oid_key_t* key;
|
2007-08-15 19:52:44 +00:00
|
|
|
oid_bits_info_t* bits;
|
|
|
|
struct _oid_info_t* parent;
|
|
|
|
} oid_info_t;
|
|
|
|
|
|
|
|
/* init funcion called from epan.h */
|
2007-08-25 01:14:24 +00:00
|
|
|
extern void oids_init(void);
|
2007-08-15 19:52:44 +00:00
|
|
|
|
|
|
|
/*
|
2007-12-04 18:43:40 +00:00
|
|
|
* The objects returned by all these functions are all allocated with a
|
|
|
|
* packet lifetime and does not have have to be freed.
|
2007-08-15 19:52:44 +00:00
|
|
|
* However, take into account that when the packet dissection
|
|
|
|
* completes, these buffers will be automatically reclaimed/freed.
|
|
|
|
* If you need the buffer to remain for a longer scope than packet lifetime
|
|
|
|
* you must copy the content to an se_alloc() buffer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These functions convert through the various formats:
|
|
|
|
* string: is like "0.1.3.4.5.30" (not resolved)
|
|
|
|
* encoded: is BER encoded (as per X.690 section 8.19)
|
|
|
|
* subids: is an array of guint32s
|
|
|
|
*/
|
|
|
|
|
2007-10-16 23:42:33 +00:00
|
|
|
/* return length of encoded buffer */
|
2007-08-15 19:52:44 +00:00
|
|
|
guint oid_subid2encoded(guint len, guint32* subids, guint8** encoded_p);
|
|
|
|
guint oid_string2encoded(const gchar *oid_str, guint8** encoded_p);
|
|
|
|
|
2007-10-16 23:42:33 +00:00
|
|
|
/* return length of subid array */
|
2007-08-15 19:52:44 +00:00
|
|
|
guint oid_encoded2subid(const guint8 *oid, gint len, guint32** subids_p);
|
|
|
|
guint oid_string2subid(const gchar *oid_str, guint32** subids_p);
|
|
|
|
|
|
|
|
extern const gchar* oid_encoded2string(const guint8* encoded, guint len);
|
|
|
|
extern const gchar* oid_subid2string(guint32 *subids, guint len);
|
|
|
|
|
|
|
|
/* these return a formated string as human readable as posible */
|
|
|
|
extern const gchar *oid_resolved(guint len, guint32 *subids);
|
|
|
|
extern const gchar *oid_resolved_from_encoded(const guint8 *oid, gint len);
|
|
|
|
extern const gchar *oid_resolved_from_string(const gchar *oid_str);
|
|
|
|
|
|
|
|
/* these yield two formated strings one resolved and one numeric */
|
2007-08-25 17:29:55 +00:00
|
|
|
extern void oid_both(guint oid_len, guint32 *subids, char** resolved_p, char** numeric_p);
|
|
|
|
extern void oid_both_from_encoded(const guint8 *oid, gint oid_len, char** resolved_p, char** numeric_p);
|
|
|
|
extern void oid_both_from_string(const gchar *oid_str, char** resolved_p, char** numeric_p);
|
2007-08-15 19:52:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These return the info for the best match.
|
|
|
|
* *matched_p will be set to the number of nodes used by the returned oid
|
2007-12-04 18:43:40 +00:00
|
|
|
* *left_p will be set to the number of remaining unresolved subids
|
2007-08-15 19:52:44 +00:00
|
|
|
*/
|
|
|
|
extern oid_info_t* oid_get(guint oid_len, guint32 *subids, guint* matched_p, guint* left_p);
|
2007-08-21 21:32:00 +00:00
|
|
|
extern oid_info_t* oid_get_from_encoded(const guint8 *oid, gint oid_len, guint32 **subids, guint* matched, guint* left);
|
|
|
|
extern oid_info_t* oid_get_from_string(const gchar *oid_str, guint32 **subids, guint* matched, guint* left);
|
2007-08-15 19:52:44 +00:00
|
|
|
|
|
|
|
/* these are used to add oids to the collection */
|
2007-08-25 01:14:24 +00:00
|
|
|
extern void oid_add(const char* name, guint oid_len, guint32 *subids);
|
|
|
|
extern void oid_add_from_encoded(const char* name, const guint8 *oid, gint oid_len);
|
|
|
|
extern void oid_add_from_string(const char* name, const gchar *oid_str);
|
2007-08-15 19:52:44 +00:00
|
|
|
|
2007-12-04 18:43:40 +00:00
|
|
|
/**
|
|
|
|
* Fetch the default MIB/PIB path
|
|
|
|
*
|
|
|
|
* @return A string containing the default MIB/PIB path. It must be
|
|
|
|
* g_free()d by the caller.
|
|
|
|
*/
|
2007-12-04 19:39:09 +00:00
|
|
|
extern gchar *oid_get_default_mib_path(void);
|
2007-12-04 18:43:40 +00:00
|
|
|
|
2007-08-25 01:14:24 +00:00
|
|
|
/* macros for legacy oid functions */
|
|
|
|
#define oid_resolv_cleanup() ((void)0)
|
|
|
|
#define subid_t guint32
|
|
|
|
|
2007-08-27 17:05:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_OIDS
|
|
|
|
extern char* oid_test_a2b(guint32 num_subids, guint32* subids);
|
|
|
|
extern void add_oid_debug_subtree(oid_info_t* oid_info, proto_tree *tree);
|
2007-12-04 18:43:40 +00:00
|
|
|
#else
|
2007-08-27 17:05:11 +00:00
|
|
|
#define add_oid_debug_subtree(a,b) ((void)0)
|
|
|
|
#endif
|
|
|
|
|
2007-08-24 12:15:49 +00:00
|
|
|
#endif
|