aboutsummaryrefslogtreecommitdiffstats
path: root/asn1.h
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-12-10 09:49:29 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-12-10 09:49:29 +0000
commit0a61c9874f382e26f07c887374aa1ba94885e354 (patch)
treee300df163d0a52bcba7f8d4824e87fd72acb4900 /asn1.h
parentccfc5372cbbe15febb5c5adfd3f05be56b2c48e3 (diff)
Make the SNMP dissector use the ASN.1 code, rather than the SNMP library
code, to dissect SNMP PDUs; use the SNMP library code only to translate OIDs into strings. Put into the ASN.1 code an annoying hack to cope with the fact that UCD SNMP makes an OID out of "u_long"s whilst CMU SNMP makes it out of "u_int"s - have the ASN.1 code make it out of "subid_t"s, and typedef "subid_t" appropriately depending on the SNMP library you have. Eventually, we should be able to use "libsmi" instead of a full-blown SNMP library, and thus possibly work around various aggravations with the SNMP libraries. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1280 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'asn1.h')
-rw-r--r--asn1.h40
1 files changed, 36 insertions, 4 deletions
diff --git a/asn1.h b/asn1.h
index 8881452210..c68522702b 100644
--- a/asn1.h
+++ b/asn1.h
@@ -1,7 +1,7 @@
/* asn1.h
* Definitions for ASN.1 BER dissection
*
- * $Id: asn1.h,v 1.1 1999/12/05 07:47:46 guy Exp $
+ * $Id: asn1.h,v 1.2 1999/12/10 09:49:29 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -62,6 +62,38 @@
#define ASN1_PRI 0 /* Primitive */
#define ASN1_CON 1 /* Constructed */
+/*
+ * Oh, this is hellish.
+ *
+ * The CMU SNMP library defines an OID as a sequence of "u_int"s,
+ * unless EIGHTBIT_SUBIDS is defined, in which case it defines
+ * an OID as a sequence of "u_char"s. None of its header files
+ * define EIGHTBIT_SUBIDS, and if a program defines it, that's
+ * not going to change the library to treat OIDs as sequences
+ * of "u_chars", so I'll assume that it'll be "u_int"s.
+ *
+ * The UCD SNMP library does the same, except it defines an OID
+ * as a sequence of "u_long"s, by default.
+ *
+ * "libsmi" defines it as a sequence of "unsigned int"s.
+ *
+ * I don't want to oblige all users of ASN.1 to include the SNMP
+ * library header files, so I'll assume none of the SNMP libraries
+ * will rudely surprise me by changing the definition; if they
+ * do, there will be compiler warnings, so we'll at least be able
+ * to catch it.
+ *
+ * This requires that, if you're going to use "asn1_subid_decode()",
+ * "asn1_oid_value_decode()", or "asn1_oid_decode()", you include
+ * "config.h", to get the right #defines defined, so that we properly
+ * typedef "subid_t".
+ */
+#if defined(HAVE_UCD_SNMP_SNMP_H)
+typedef u_long subid_t; /* UCD SNMP */
+#else
+typedef u_int subid_t; /* CMU SNMP, libsmi, or nothing */
+#endif
+
#define ASN1_ERR_NOERROR 0 /* no error */
#define ASN1_ERR_EMPTY 1 /* ran out of data */
#define ASN1_ERR_EOC_MISMATCH 2
@@ -101,9 +133,9 @@ int asn1_octet_string_value_decode (ASN1_SCK *asn1, int enc_len,
guchar **octets);
int asn1_octet_string_decode (ASN1_SCK *asn1, guchar **octets, guint *str_len,
guint *nbytes);
-int asn1_subid_decode (ASN1_SCK *asn1, guint32 *subid);
-int asn1_oid_value_decode (ASN1_SCK *asn1, int enc_len, guint32 **oid,
+int asn1_subid_decode (ASN1_SCK *asn1, subid_t *subid);
+int asn1_oid_value_decode (ASN1_SCK *asn1, int enc_len, subid_t **oid,
guint *len);
-int asn1_oid_decode ( ASN1_SCK *asn1, guint32 **oid, guint *len, guint *nbytes);
+int asn1_oid_decode ( ASN1_SCK *asn1, subid_t **oid, guint *len, guint *nbytes);
int asn1_sequence_decode ( ASN1_SCK *asn1, guint *seq_len, guint *nbytes);
#endif