Get rid of some unused variables, as per Josef Korelus.
[obnox/wireshark/wip.git] / packet-ber.h
1 /* packet-ber.h
2  * Helpers for ASN.1/BER dissection
3  * Ronnie Sahlberg (C) 2004
4  *
5  * $Id: packet-ber.h,v 1.5 2004/03/26 00:21:53 guy Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifndef __PACKET_BER_H__
27 #define __PACKET_BER_H__
28
29 typedef int (*ber_callback)(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset);
30
31 #define BER_CLASS_UNI   0
32 #define BER_CLASS_APP   1
33 #define BER_CLASS_CON   2
34 #define BER_CLASS_PRI   3
35
36
37 #define BER_UNI_TAG_EOC                      0  /* 'end-of-content' */
38 #define BER_UNI_TAG_BOOLEAN                  1
39 #define BER_UNI_TAG_INTEGER                  2
40 #define BER_UNI_TAG_BITSTRING                3
41 #define BER_UNI_TAG_OCTETSTRING              4
42 #define BER_UNI_TAG_NULL                     5
43 #define BER_UNI_TAG_OID                      6  /* OBJECT IDENTIFIER */
44 #define BER_UNI_TAG_ObjectDescriptor         7
45 #define BER_UNI_TAG_REAL                     9
46 #define BER_UNI_TAG_ENUMERATED              10
47 #define BER_UNI_TAG_EMBEDDED_PDV            11
48 #define BER_UNI_TAG_UTF8String              12
49 #define BER_UNI_TAG_RELATIVE_OID            13
50 #define BER_UNI_TAG_SEQUENCE                16  /* SEQUENCE, SEQUENCE OF */
51 #define BER_UNI_TAG_SET                     17  /* SET, SET OF */
52 #define BER_UNI_TAG_NumericString           18
53 #define BER_UNI_TAG_PrintableString         19
54 #define BER_UNI_TAG_TeletextString          20  /* TeletextString, T61String */
55 #define BER_UNI_TAG_VideotexString          21
56 #define BER_UNI_TAG_IA5String               22
57 #define BER_UNI_TAG_UCTTime                 23
58 #define BER_UNI_TAG_GeneralizedTime         24
59 #define BER_UNI_TAG_GraphicString           25
60 #define BER_UNI_TAG_VisibleString           26  /* VisibleString, ISO64String */
61 #define BER_UNI_TAG_GeneralString           27
62 #define BER_UNI_TAG_UniversalString         28
63 #define BER_UNI_TAG_CHARACTERSTRING         29
64 #define BER_UNI_TAG_BMPString               30
65
66 /* this function dissects the identifier octer of the BER TLV.
67  * We only handle TAGs (and LENGTHs) that fit inside 32 bit integers.
68  */
69 extern int get_ber_identifier(tvbuff_t *tvb, int offset, guint8 *class, gboolean *pc, guint32 *tag);
70 extern int dissect_ber_identifier(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint8 *class, gboolean *pc, guint32 *tag);
71
72 /* this function dissects the identifier octer of the BER TLV.
73  * We only handle (TAGs and) LENGTHs that fit inside 32 bit integers.
74  */
75 extern int get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind);
76 extern int dissect_ber_length(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind);
77
78 extern int dissect_ber_octet_string(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **out_tvb);
79 extern int dissect_ber_octet_string_wcb(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, ber_callback func);
80
81 extern int dissect_ber_integer(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, guint32 *value);
82
83
84 extern int dissect_ber_boolean(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id);
85
86
87 #define BER_FLAGS_OPTIONAL      0x00000001
88 #define BER_FLAGS_IMPLTAG       0x00000002
89 #define BER_FLAGS_NOOWNTAG      0x00000004
90 #define BER_FLAGS_NOTCHKTAG     0x00000008
91 typedef struct _ber_sequence {
92         guint8  class;
93         guint32 tag;
94         guint32 flags;
95         ber_callback    func;
96 } ber_sequence;
97
98 /* this function dissects a BER sequence 
99  */
100 extern int dissect_ber_sequence(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, ber_sequence *seq, gint hf_id, gint ett_id);
101
102
103 typedef struct _ber_choice {
104         guint32 value;
105         guint8  class;
106         guint32 tag;
107         guint32 flags;
108         ber_callback    func;
109 } ber_choice;
110
111
112 /* this function dissects a BER choice 
113  */
114 extern int dissect_ber_choice(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_choice *ch, gint hf_id, gint ett_id);
115
116
117 /* this function dissects a BER strings
118  */
119 extern int dissect_ber_restricted_string(gboolean implicit_tag, guint32 type, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **out_tvb);
120 extern int dissect_ber_GeneralString(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, char *name_string, guint name_len);
121
122
123 /* this function dissects a BER Object Identifier
124  */
125 extern int dissect_ber_object_identifier(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, char *value_string);
126
127 /* this function dissects a BER sequence of
128  */
129 extern int dissect_ber_sequence_of(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, ber_sequence *seq, gint hf_id, gint ett_id);
130
131 extern int dissect_ber_set_of(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, ber_sequence *seq, gint hf_id, gint ett_id);
132
133
134 extern int dissect_ber_generalized_time(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id);
135
136 typedef struct _asn_namedbit {
137         guint32 bit;
138         int *p_id;
139         gint32 gb0;  /* the 1st bit of "bit group", -1 = the 1st bit of current byte */
140         gint32 gb1;  /* last bit of "bit group", -1 = last bit of current byte */
141         gchar *tstr;  /* true string */
142         gchar *fstr;  /* false string */
143 } asn_namedbit;
144 /* this function dissects a BER BIT-STRING
145  */
146 extern int dissect_ber_bitstring(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, asn_namedbit *named_bits, gint hf_id, gint ett_id, tvbuff_t **out_tvb);
147 extern int dissect_ber_bitstring32(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, int **bit_fields, gint hf_id, gint ett_id, tvbuff_t **out_tvb);
148
149
150 extern proto_item *ber_last_created_item;
151 extern proto_item *get_ber_last_created_item(void);
152
153 #endif  /* __PACKET_BER_H__ */