From Shaun Jackman:
[obnox/wireshark/wip.git] / epan / dissectors / format-oid.h
1 /* format-oid.h
2  * Declare routine for formatting OIDs
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Didier Jorand
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __FORMAT_OID_H__
26 #define __FORMAT_OID_H__
27
28 /*
29  * Oh, this is hellish.
30  *
31  * The CMU SNMP library defines an OID as a sequence of "u_int"s,
32  * unless EIGHTBIT_SUBIDS is defined, in which case it defines
33  * an OID as a sequence of "u_char"s.  None of its header files
34  * define EIGHTBIT_SUBIDS, and if a program defines it, that's
35  * not going to change the library to treat OIDs as sequences
36  * of "u_chars", so I'll assume that it'll be "u_int"s.
37  *
38  * The UCD SNMP library does the same, except it defines an OID
39  * as a sequence of "u_long"s, by default.
40  *
41  * "libsmi" defines it as a sequence of "unsigned int"s.
42  *
43  * I don't want to oblige all users of ASN.1 to include the SNMP
44  * library header files, so I'll assume none of the SNMP libraries
45  * will rudely surprise me by changing the definition; if they
46  * do, there will be compiler warnings, so we'll at least be able
47  * to catch it.
48  *
49  * This requires that, if you're going to use "asn1_subid_decode()",
50  * "asn1_oid_value_decode()", or "asn1_oid_decode()", you include
51  * "config.h", to get the right #defines defined, so that we properly
52  * typedef "subid_t".
53  */
54 #if defined(HAVE_NET_SNMP)
55 typedef gulong  subid_t;        /* Net-SNMP */
56 #else
57 typedef guint   subid_t;        /* CMU SNMP, UCD SNMP, libsmi, or nothing */
58 #endif
59
60 extern int oid_to_subid_buf(const guint8 *oid, gint oid_len, subid_t *buf, int buf_len);
61 extern gchar *format_oid(subid_t *oid, guint oid_length);
62 extern void new_format_oid(subid_t *oid, guint oid_length, 
63                            gchar **non_decoded, gchar **decoded);
64
65 #endif