name change
[obnox/wireshark/wip.git] / epan / asn1.h
1 /* asn1.h
2  * Definitions for ASN.1 BER dissection
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  *
9  * Based on "g_asn1.h" from:
10  *
11  * GXSNMP -- An snmp mangament application
12  * Copyright (C) 1998 Gregory McLean & Jochen Friedrich
13  * Beholder RMON ethernet network monitor,Copyright (C) 1993 DNPAP group
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28  *
29  */
30 #ifndef __ASN1_H__
31 #define __ASN1_H__
32
33 #define ASN1_UNI       0     /* Universal   */
34 #define ASN1_APL       1     /* Application */
35 #define ASN1_CTX       2     /* Context     */
36 #define ASN1_PRV       3     /* Private     */
37
38                              /* Tag                */
39 #define ASN1_EOC       0     /* End Of Contents    */
40 #define ASN1_BOL       1     /* Boolean            */
41 #define ASN1_INT       2     /* Integer            */
42 #define ASN1_BTS       3     /* Bit String         */
43 #define ASN1_OTS       4     /* Octet String       */
44 #define ASN1_NUL       5     /* Null               */
45 #define ASN1_OJI       6     /* Object Identifier  */
46 #define ASN1_OJD       7     /* Object Description */
47 #define ASN1_EXT       8     /* External           */
48 #define ASN1_REAL      9     /* Real               */
49 #define ASN1_ENUM      10    /* Enumerated         */
50 #define ASN1_SEQ       16    /* Sequence           */
51 #define ASN1_SET       17    /* Set                */
52 #define ASN1_NUMSTR    18    /* Numerical String   */
53 #define ASN1_PRNSTR    19    /* Printable String   */
54 #define ASN1_TEXSTR    20    /* Teletext String    */
55 #define ASN1_VIDSTR    21    /* Video String       */
56 #define ASN1_IA5STR    22    /* IA5 String         */
57 #define ASN1_UNITIM    23    /* Universal Time     */
58 #define ASN1_GENTIM    24    /* General Time       */
59 #define ASN1_GRASTR    25    /* Graphical String   */
60 #define ASN1_VISSTR    26    /* Visible String     */
61 #define ASN1_GENSTR    27    /* General String     */
62
63                              /* Primitive / Constructed */
64 #define ASN1_PRI     0       /* Primitive               */
65 #define ASN1_CON     1       /* Constructed             */
66
67
68 #define ASN1_ERR_NOERROR                0       /* no error */
69 #define ASN1_ERR_EOC_MISMATCH           1
70 #define ASN1_ERR_WRONG_TYPE             2       /* type not right */
71 #define ASN1_ERR_LENGTH_NOT_DEFINITE    3       /* length should be definite */
72 #define ASN1_ERR_LENGTH_MISMATCH        4
73 #define ASN1_ERR_WRONG_LENGTH_FOR_TYPE  5       /* length wrong for type */
74
75 typedef struct _ASN1_SCK ASN1_SCK;
76
77 struct _ASN1_SCK
78 {                           /* ASN1 socket                         */
79     tvbuff_t *tvb;          /* Tvbuff whence the data comes        */
80     int offset;             /* Current offset in tvbuff            */
81 };
82
83 #include <epan/dissectors/format-oid.h>
84
85 extern void asn1_open (ASN1_SCK *asn1, tvbuff_t *tvb, int offset);
86 extern void asn1_close (ASN1_SCK *asn1, int *offset);
87 extern int asn1_octet_decode (ASN1_SCK *asn1, guchar *ch);
88 extern int asn1_tag_decode (ASN1_SCK *asn1, guint *tag);
89 extern int asn1_id_decode (ASN1_SCK *asn1, guint *cls, guint *con, guint *tag);
90 extern int asn1_id_decode1 (ASN1_SCK *asn1, guint *tag);
91 extern int asn1_length_decode (ASN1_SCK *asn1, gboolean *def, guint *len);
92 extern int asn1_header_decode(ASN1_SCK *asn1, guint *cls, guint *con,
93                               guint *tag, gboolean *defp, guint *lenp);
94 extern int asn1_eoc (ASN1_SCK *asn1, int eoc);
95 extern int asn1_eoc_decode (ASN1_SCK *asn1, int eoc);
96 extern int asn1_null_decode (ASN1_SCK *asn1, int enc_len);
97 extern int asn1_bool_decode (ASN1_SCK *asn1, int enc_len, gboolean *boolean);
98 extern int asn1_int32_value_decode (ASN1_SCK *asn1, int enc_len,
99                                     gint32 *integer);
100 extern int asn1_int32_decode (ASN1_SCK *asn1, gint32 *integer, guint *nbytes);
101 extern int asn1_uint32_value_decode (ASN1_SCK *asn1, int enc_len,
102                                      guint32 *integer);
103 extern int asn1_uint32_decode (ASN1_SCK *asn1, guint32 *integer, guint *nbytes);
104 extern int asn1_bits_decode (ASN1_SCK *asn1, int enc_len, guchar **bits,
105                              guint *len, guchar *unused);
106 extern int asn1_string_value_decode (ASN1_SCK *asn1, int enc_len,
107                                      guchar **octets);
108 extern int asn1_string_decode (ASN1_SCK *asn1, guchar **octets, guint *str_len,
109                                guint *nbytes, guint expected_tag);
110 extern int asn1_octet_string_decode (ASN1_SCK *asn1, guchar **octets,
111                                      guint *str_len, guint *nbytes);
112 extern int asn1_subid_decode (ASN1_SCK *asn1, subid_t *subid);
113 extern int asn1_oid_value_decode (ASN1_SCK *asn1, int enc_len, subid_t **oid,
114                                   guint *len);
115 extern int asn1_oid_decode (ASN1_SCK *asn1, subid_t **oid, guint *len,
116                             guint *nbytes);
117 extern int asn1_sequence_decode (ASN1_SCK *asn1, guint *seq_len, guint *nbytes);
118
119 extern const char *asn1_err_to_str (int err);
120
121 #endif