/*
 * tnmAsn1.h --
 *
 *	Definitions for the ASN.1/BER encoder/decoder for the SNMP
 *	protocol. This is only the subset of ASN.1/BER required by
 *	the SNMP protocol.
 *
 * Copyright (c) 1994-1996 Technical University of Braunschweig.
 * Copyright (c) 1996-1997 University of Twente. 
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#ifndef _TNMASN1
#define _TNMASN1

/*
 *----------------------------------------------------------------
 * Definition of ASN.1 data types used by SNMP.
 *----------------------------------------------------------------
 */

#define ASN1_UNIVERSAL		( 0x00 )
#define ASN1_APPLICATION	( 0x40 )
#define ASN1_CONTEXT		( 0x80 )
#define ASN1_PRIVATE		( 0xc0 )

#define ASN1_PRIMITIVE		( 0x00 )
#define ASN1_CONSTRUCTED	( 0x20 )

#define	ASN1_OTHER		( ASN1_UNIVERSAL | 0x00 )
#define ASN1_BOOLEAN		( ASN1_UNIVERSAL | 0x01 )
#define	ASN1_INTEGER		( ASN1_UNIVERSAL | 0x02 )
#define ASN1_BIT_STRING		( ASN1_UNIVERSAL | 0x03 )
#define	ASN1_OCTET_STRING	( ASN1_UNIVERSAL | 0x04 )
#define	ASN1_NULL		( ASN1_UNIVERSAL | 0x05 )
#define ASN1_OBJECT_IDENTIFIER	( ASN1_UNIVERSAL | 0x06 )
#define ASN1_SEQUENCE		( ASN1_UNIVERSAL | 0x10 )
#define	ASN1_SEQUENCE_OF	( ASN1_UNIVERSAL | 0x11 )

#define ASN1_IPADDRESS		( ASN1_APPLICATION | ASN1_PRIMITIVE | 0x00 )
#define ASN1_COUNTER32		( ASN1_APPLICATION | ASN1_PRIMITIVE | 0x01 )
#define ASN1_GAUGE32		( ASN1_APPLICATION | ASN1_PRIMITIVE | 0x02 )
#define ASN1_TIMETICKS		( ASN1_APPLICATION | ASN1_PRIMITIVE | 0x03 )
#define ASN1_OPAQUE		( ASN1_APPLICATION | ASN1_PRIMITIVE | 0x04 )
#define ASN1_NSAPADDRESS	( ASN1_APPLICATION | ASN1_PRIMITIVE | 0x05 )
#define ASN1_COUNTER64		( ASN1_APPLICATION | ASN1_PRIMITIVE | 0x06 )

/*
 *----------------------------------------------------------------
 * Exception codes used in SNMPv2 varbind lists (RFC 1905).
 *----------------------------------------------------------------
 */

#define ASN1_NO_SUCH_OBJECT	( ASN1_CONTEXT | ASN1_PRIMITIVE | 0x00 )
#define ASN1_NO_SUCH_INSTANCE	( ASN1_CONTEXT | ASN1_PRIMITIVE | 0x01 )
#define ASN1_END_OF_MIB_VIEW	( ASN1_CONTEXT | ASN1_PRIMITIVE | 0x02 )

/*
 *----------------------------------------------------------------
 * Non-aggregate types for MIB tree nodes that are not defined in
 * SMI or to distinguish from their SNMPv1 values. XXX
 *----------------------------------------------------------------
 */

#define	NetworkAddress		( 0x15 )

EXTERN TnmTable tnmSnmpTypeTable[];
EXTERN TnmTable tnmSnmpExceptionTable[];

/*
 *----------------------------------------------------------------
 * Functions that manipulate object identifier. THIS IS OLD CODE
 * AND SHOULD NOT BE USED ANYMORE.
 *----------------------------------------------------------------
 */

typedef u_int Tnm_Oid;

EXTERN char*
TnmOidToStr		_ANSI_ARGS_((Tnm_Oid *oid, int len));

EXTERN Tnm_Oid*
TnmStrToOid		_ANSI_ARGS_((char *str, int *len));

/*
 *----------------------------------------------------------------
 * This function return a static error string describing the last 
 * error which incurred in the BER encoder/decoder.
 *----------------------------------------------------------------
 */

EXTERN char*
TnmBerError		_ANSI_ARGS_((void));

/*
 *----------------------------------------------------------------
 * BER functions visible for other modules (encoding/decoding):
 *----------------------------------------------------------------
 */

EXTERN u_char*
TnmBerEncLength		_ANSI_ARGS_((u_char *packet, int *packetlen,
				     u_char *len_fld, int length));
EXTERN u_char*
TnmBerDecLength		_ANSI_ARGS_((u_char *packet, int *packetlen,
				     u_int *length));
EXTERN u_char*
TnmBerEncInt		_ANSI_ARGS_((u_char *packet, int *packetlen,
				     int tag, int value));
EXTERN u_char*
TnmBerDecInt		_ANSI_ARGS_((u_char *packet, int *packetlen,
				     int tag, int *value));
EXTERN u_char*
TnmBerEncCounter64	_ANSI_ARGS_((u_char *packet, int *packetlen,
				     double value));
EXTERN u_char*
TnmBerDecCounter64	_ANSI_ARGS_((u_char *packet, int *packetlen,
				     u_int *high, u_int *low));
EXTERN u_char*
TnmBerEncOID		_ANSI_ARGS_((u_char *packet, int *packetlen,
				     Tnm_Oid *oid, int oidlen));
EXTERN u_char*
TnmBerDecOID		_ANSI_ARGS_((u_char *packet, int *packetlen,
				     Tnm_Oid *oid, int *oidlen));
EXTERN u_char*
TnmBerEncOctetString	_ANSI_ARGS_((u_char *packet, int *packetlen,
				     int tag, char *octets, int len));
EXTERN u_char*
TnmBerDecOctetString	_ANSI_ARGS_((u_char *packet, int *packetlen,
				     int tag, char **octets, int *len));
EXTERN u_char*
TnmBerEncNull		_ANSI_ARGS_((u_char *packet, int *packetlen, int tag));

EXTERN u_char*
TnmBerDecNull		_ANSI_ARGS_((u_char *packet, int *packetlen, int tag));

#endif /* _TNMASN1 */
