2004-02-20 10:04:10 +00:00
|
|
|
/* packet-ber.h
|
|
|
|
* Helpers for ASN.1/BER dissection
|
|
|
|
* Ronnie Sahlberg (C) 2004
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2004-02-20 10:04:10 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2004-03-04 07:07:57 +00:00
|
|
|
#ifndef __PACKET_BER_H__
|
|
|
|
#define __PACKET_BER_H__
|
|
|
|
|
2004-05-17 20:03:36 +00:00
|
|
|
#define BER_NOT_DECODED_YET(x) \
|
2004-05-14 23:38:39 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, 0, "something unknown here [%s]",x); \
|
|
|
|
fprintf(stderr,"Not decoded yet in packet : %d [%s]\n", pinfo->fd->num,x); \
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)){ \
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, "[UNKNOWN BER: %s]", x); \
|
|
|
|
} \
|
|
|
|
tvb_get_guint8(tvb, 9999);
|
|
|
|
|
2004-02-20 10:04:10 +00:00
|
|
|
typedef int (*ber_callback)(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset);
|
|
|
|
|
2004-03-25 09:18:03 +00:00
|
|
|
#define BER_CLASS_UNI 0
|
|
|
|
#define BER_CLASS_APP 1
|
|
|
|
#define BER_CLASS_CON 2
|
|
|
|
#define BER_CLASS_PRI 3
|
2004-07-20 10:45:11 +00:00
|
|
|
#define BER_CLASS_ANY 99 /* dont check class nor tag */
|
2004-03-25 09:18:03 +00:00
|
|
|
|
2004-03-26 00:21:53 +00:00
|
|
|
#define BER_UNI_TAG_EOC 0 /* 'end-of-content' */
|
|
|
|
#define BER_UNI_TAG_BOOLEAN 1
|
|
|
|
#define BER_UNI_TAG_INTEGER 2
|
|
|
|
#define BER_UNI_TAG_BITSTRING 3
|
|
|
|
#define BER_UNI_TAG_OCTETSTRING 4
|
|
|
|
#define BER_UNI_TAG_NULL 5
|
|
|
|
#define BER_UNI_TAG_OID 6 /* OBJECT IDENTIFIER */
|
|
|
|
#define BER_UNI_TAG_ObjectDescriptor 7
|
|
|
|
#define BER_UNI_TAG_REAL 9
|
|
|
|
#define BER_UNI_TAG_ENUMERATED 10
|
|
|
|
#define BER_UNI_TAG_EMBEDDED_PDV 11
|
|
|
|
#define BER_UNI_TAG_UTF8String 12
|
|
|
|
#define BER_UNI_TAG_RELATIVE_OID 13
|
|
|
|
#define BER_UNI_TAG_SEQUENCE 16 /* SEQUENCE, SEQUENCE OF */
|
|
|
|
#define BER_UNI_TAG_SET 17 /* SET, SET OF */
|
2004-03-25 23:57:10 +00:00
|
|
|
#define BER_UNI_TAG_NumericString 18
|
|
|
|
#define BER_UNI_TAG_PrintableString 19
|
2004-12-13 11:59:48 +00:00
|
|
|
#define BER_UNI_TAG_TeletexString 20 /* TeletextString, T61String */
|
2004-03-25 23:57:10 +00:00
|
|
|
#define BER_UNI_TAG_VideotexString 21
|
|
|
|
#define BER_UNI_TAG_IA5String 22
|
2004-06-05 09:59:45 +00:00
|
|
|
#define BER_UNI_TAG_UTCTime 23
|
2004-03-26 00:21:53 +00:00
|
|
|
#define BER_UNI_TAG_GeneralizedTime 24
|
2004-03-25 23:57:10 +00:00
|
|
|
#define BER_UNI_TAG_GraphicString 25
|
|
|
|
#define BER_UNI_TAG_VisibleString 26 /* VisibleString, ISO64String */
|
2004-03-26 00:21:53 +00:00
|
|
|
#define BER_UNI_TAG_GeneralString 27
|
2004-03-25 23:57:10 +00:00
|
|
|
#define BER_UNI_TAG_UniversalString 28
|
|
|
|
#define BER_UNI_TAG_CHARACTERSTRING 29
|
|
|
|
#define BER_UNI_TAG_BMPString 30
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
/* this function dissects the identifier octer of the BER TLV.
|
|
|
|
* We only handle TAGs (and LENGTHs) that fit inside 32 bit integers.
|
|
|
|
*/
|
2004-12-13 08:15:34 +00:00
|
|
|
extern int get_ber_identifier(tvbuff_t *tvb, int offset, gint8 *class, gboolean *pc, gint32 *tag);
|
|
|
|
extern int dissect_ber_identifier(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint8 *class, gboolean *pc, gint32 *tag);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
/* this function dissects the identifier octer of the BER TLV.
|
|
|
|
* We only handle (TAGs and) LENGTHs that fit inside 32 bit integers.
|
|
|
|
*/
|
2004-03-25 09:18:03 +00:00
|
|
|
extern int get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind);
|
|
|
|
extern int dissect_ber_length(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
2004-03-25 09:18:03 +00:00
|
|
|
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);
|
|
|
|
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);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
2004-12-12 01:14:03 +00:00
|
|
|
extern int dissect_ber_integer(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, guint32 *value);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
|
2004-03-04 07:07:57 +00:00
|
|
|
extern int dissect_ber_boolean(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define BER_FLAGS_OPTIONAL 0x00000001
|
2004-03-25 09:18:03 +00:00
|
|
|
#define BER_FLAGS_IMPLTAG 0x00000002
|
2004-03-26 00:21:53 +00:00
|
|
|
#define BER_FLAGS_NOOWNTAG 0x00000004
|
|
|
|
#define BER_FLAGS_NOTCHKTAG 0x00000008
|
2004-12-13 08:15:34 +00:00
|
|
|
typedef struct _ber_sequence_t {
|
|
|
|
gint8 class;
|
|
|
|
gint32 tag;
|
2004-02-20 10:04:10 +00:00
|
|
|
guint32 flags;
|
|
|
|
ber_callback func;
|
2004-12-13 08:15:34 +00:00
|
|
|
} ber_sequence_t;
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
/* this function dissects a BER sequence
|
|
|
|
*/
|
2004-12-13 08:15:34 +00:00
|
|
|
extern int dissect_ber_sequence(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, gint hf_id, gint ett_id);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
|
2004-12-13 08:15:34 +00:00
|
|
|
typedef struct _ber_choice_t {
|
2004-03-25 09:18:03 +00:00
|
|
|
guint32 value;
|
2004-12-13 08:15:34 +00:00
|
|
|
gint8 class;
|
|
|
|
gint32 tag;
|
2004-03-25 09:18:03 +00:00
|
|
|
guint32 flags;
|
2004-02-20 10:04:10 +00:00
|
|
|
ber_callback func;
|
2004-12-13 08:15:34 +00:00
|
|
|
} ber_choice_t;
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* this function dissects a BER choice
|
|
|
|
*/
|
2004-12-13 08:15:34 +00:00
|
|
|
extern int dissect_ber_choice(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_choice_t *ch, gint hf_id, gint ett_id);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
|
2004-03-25 09:18:03 +00:00
|
|
|
/* this function dissects a BER strings
|
2004-02-20 10:04:10 +00:00
|
|
|
*/
|
2004-12-13 08:15:34 +00:00
|
|
|
extern int dissect_ber_restricted_string(gboolean implicit_tag, gint32 type, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, tvbuff_t **out_tvb);
|
2004-03-25 09:18:03 +00:00
|
|
|
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);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
|
2004-03-25 09:18:03 +00:00
|
|
|
/* this function dissects a BER Object Identifier
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
2004-02-20 10:04:10 +00:00
|
|
|
/* this function dissects a BER sequence of
|
|
|
|
*/
|
2004-12-13 08:15:34 +00:00
|
|
|
extern int dissect_ber_sequence_of(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, gint hf_id, gint ett_id);
|
2004-03-25 09:18:03 +00:00
|
|
|
|
2004-12-13 08:15:34 +00:00
|
|
|
extern int dissect_ber_set_of(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const ber_sequence_t *seq, gint hf_id, gint ett_id);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
|
2004-12-12 22:47:24 +00:00
|
|
|
extern int dissect_ber_GeneralizedTime(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
2004-03-25 09:18:03 +00:00
|
|
|
typedef struct _asn_namedbit {
|
|
|
|
guint32 bit;
|
|
|
|
int *p_id;
|
|
|
|
gint32 gb0; /* the 1st bit of "bit group", -1 = the 1st bit of current byte */
|
|
|
|
gint32 gb1; /* last bit of "bit group", -1 = last bit of current byte */
|
|
|
|
gchar *tstr; /* true string */
|
|
|
|
gchar *fstr; /* false string */
|
|
|
|
} asn_namedbit;
|
2004-02-20 10:04:10 +00:00
|
|
|
/* this function dissects a BER BIT-STRING
|
|
|
|
*/
|
2004-10-08 21:14:33 +00:00
|
|
|
extern int dissect_ber_bitstring(gboolean implicit_tag, packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const asn_namedbit *named_bits, gint hf_id, gint ett_id, tvbuff_t **out_tvb);
|
2004-03-25 09:18:03 +00:00
|
|
|
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);
|
2004-02-20 10:04:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern proto_item *ber_last_created_item;
|
2004-03-25 23:57:10 +00:00
|
|
|
extern proto_item *get_ber_last_created_item(void);
|
2004-03-04 07:07:57 +00:00
|
|
|
|
2004-07-21 11:13:03 +00:00
|
|
|
int call_ber_oid_callback(char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
|
2004-07-23 07:08:14 +00:00
|
|
|
void register_ber_oid_dissector(char *oid, dissector_t dissector, int proto, char *name);
|
2004-10-27 19:59:44 +00:00
|
|
|
void register_ber_oid_name(char *oid, char *name);
|
2004-07-29 09:52:14 +00:00
|
|
|
void dissect_ber_oid_NULL_callback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
2004-11-09 06:49:35 +00:00
|
|
|
char * get_ber_oid_name(char *str);
|
2004-07-20 09:11:40 +00:00
|
|
|
|
2004-03-26 00:21:53 +00:00
|
|
|
#endif /* __PACKET_BER_H__ */
|