From 860376a9abfb8b5d70062086660fd7e204a3317b Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 2 Oct 2003 06:13:29 +0000 Subject: From Samuel Qu, Michael Lum, and Jeff Morriss: TCAP support, and "asn_id_decode1()" variant of "asn_id_decode()". svn path=/trunk/; revision=8586 --- asn1.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 7 deletions(-) (limited to 'asn1.c') diff --git a/asn1.c b/asn1.c index 0d2c36e6aa..0b86c9ea30 100644 --- a/asn1.c +++ b/asn1.c @@ -1,7 +1,7 @@ /* asn1.c * Routines for ASN.1 BER dissection * - * $Id: asn1.c,v 1.21 2003/08/29 19:13:28 guy Exp $ + * $Id: asn1.c,v 1.22 2003/10/02 06:13:27 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -138,22 +138,21 @@ asn1_octet_decode(ASN1_SCK *asn1, guchar *ch) } /* - * NAME: asn1_tag_decode - * SYNOPSIS: int asn1_tag_decode + * NAME: asn1_tag_get + * SYNOPSIS: int asn1_tag_get * ( * ASN1_SCK *asn1, * guint *tag * ) - * DESCRIPTION: Decodes a tag. + * DESCRIPTION: Decodes a tag number, combining it with existing tag bits. * RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success) */ -int -asn1_tag_decode(ASN1_SCK *asn1, guint *tag) +static int +asn1_tag_get(ASN1_SCK *asn1, guint *tag) { int ret; guchar ch; - *tag = 0; do { ret = asn1_octet_decode (asn1, &ch); if (ret != ASN1_ERR_NOERROR) @@ -164,6 +163,23 @@ asn1_tag_decode(ASN1_SCK *asn1, guint *tag) return ASN1_ERR_NOERROR; } +/* + * NAME: asn1_tag_decode + * SYNOPSIS: int asn1_tag_decode + * ( + * ASN1_SCK *asn1, + * guint *tag + * ) + * DESCRIPTION: Decodes a tag number. + * RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success) + */ +int +asn1_tag_decode(ASN1_SCK *asn1, guint *tag) +{ + *tag = 0; + return asn1_tag_get(asn1, tag); +} + /* * NAME: asn1_id_decode * SYNOPSIS: int asn1_id_decode @@ -182,6 +198,7 @@ asn1_id_decode(ASN1_SCK *asn1, guint *cls, guint *con, guint *tag) int ret; guchar ch; + *tag = 0; ret = asn1_octet_decode (asn1, &ch); if (ret != ASN1_ERR_NOERROR) return ret; @@ -196,6 +213,39 @@ asn1_id_decode(ASN1_SCK *asn1, guint *cls, guint *con, guint *tag) return ASN1_ERR_NOERROR; } +/* + * NAME: asn1_id_decode1 + * SYNOPSIS: int asn1_id_decode1 + * ( + * ASN1_SCK *asn1, + * guint *tag + * ) + * DESCRIPTION: Decodes an identifier. + * Like asn1_id_decode() except that the Class and Constructor + * bits are returned in the tag. + * RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success) + */ +int +asn1_id_decode1(ASN1_SCK *asn1, guint *tag) +{ + int ret; + guchar ch; + + *tag = 0; + ret = asn1_octet_decode (asn1, &ch); + if (ret != ASN1_ERR_NOERROR) + return ret; + + *tag = ch; + if ((*tag & 0x1F) == 0x1F) { /* high-tag-number format */ + *tag = ch >> 5; /* leave just the Class and Constructor bits */ + ret = asn1_tag_get (asn1, tag); + if (ret != ASN1_ERR_NOERROR) + return ret; + } + return ASN1_ERR_NOERROR; +} + /* * NAME: asn1_length_decode * SYNOPSIS: int asn1_length_decode -- cgit v1.2.3