Propagate to the Q.933 dissector Anders Broman's change to the Q.931
[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.2 2004/03/04 07:07:00 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   0x00
32 #define BER_CLASS_APP   0x01
33 #define BER_CLASS_CON   0x02
34 #define BER_CLASS_PRI   0x03
35
36
37 #define BER_UNI_TAG_BOOLEAN     0x01
38 #define BER_UNI_TAG_INTEGER     0x02
39 #define BER_UNI_TAG_BITSTRING   0x03
40 #define BER_UNI_TAG_OCTETSTRING 0x04
41 #define BER_UNI_TAG_SEQUENCE    0x10
42 #define BER_UNI_TAG_GENTIME     0x18
43 #define BER_UNI_TAG_GENSTR      0x1b
44
45 /* this function dissects the identifier octer of the BER TLV.
46  * We only handle TAGs (and LENGTHs) that fit inside 32 bit integers.
47  */
48 extern int dissect_ber_identifier(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint8 *class, gboolean *pc, guint32 *tag);
49
50 /* this function dissects the identifier octer of the BER TLV.
51  * We only handle (TAGs and) LENGTHs that fit inside 32 bit integers.
52  */
53 extern int dissect_ber_length(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32 *length);
54
55 /* func is NULL normally but
56  * if the octet string contains an ber encode struct we provide func as the 
57  * dissector for that struct
58  */
59 extern int dissect_ber_octet_string(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, ber_callback func);
60
61 extern int dissect_ber_integer(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, guint32 *value);
62
63
64 extern int dissect_ber_boolean(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id);
65
66
67 #define BER_FLAGS_OPTIONAL      0x00000001
68 typedef struct _ber_sequence {
69         guint8  class;
70         guint32 tag;
71         guint32 flags;
72         ber_callback    func;
73 } ber_sequence;
74
75 /* this function dissects a BER sequence 
76  */
77 extern int dissect_ber_sequence(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, ber_sequence *seq, gint hf_id, gint ett_id);
78
79
80 typedef struct _ber_choice {
81         guint8  class;
82         guint32 tag;
83         ber_callback    func;
84 } ber_choice;
85
86
87 /* this function dissects a BER choice 
88  */
89 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);
90
91
92 /* this function dissects a BER GeneralString
93  */
94 extern int dissect_ber_GeneralString(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, char *name_string, int name_len);
95
96
97 /* this function dissects a BER sequence of
98  */
99 extern int dissect_ber_sequence_of(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, ber_callback func, gint hf_id, gint ett_id);
100
101
102 extern int dissect_ber_generalized_time(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id);
103
104 /* this function dissects a BER BIT-STRING
105  */
106 extern int dissect_ber_bitstring(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, gint hf_id, gint ett_id, unsigned char *bitstring, int bitstring_len, proto_item **it, proto_tree **tr);
107
108
109 extern proto_item *ber_last_created_item;
110
111 #endif  /* __PACKET_BER_H__ */