252N/A/*
252N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
252N/A *
252N/A * U.S. Government Rights - Commercial software. Government users are subject
252N/A * to the Sun Microsystems, Inc. standard license agreement and applicable
252N/A * provisions of the FAR and its supplements.
252N/A *
252N/A *
252N/A * This distribution may include materials developed by third parties. Sun,
252N/A * Sun Microsystems, the Sun logo and Solaris are trademarks or registered
252N/A * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
252N/A *
252N/A */
252N/A
252N/A#if !defined(lint) && !defined(NOID)
252N/A#pragma ident "@(#)asn1.h 2.17 00/07/17 SMI"
252N/A#endif
252N/A
252N/A/*
252N/A** Sun considers its source code as an unpublished, proprietary trade
252N/A** secret, and it is available only under strict license provisions.
252N/A** This copyright notice is placed here only to protect Sun in the event
252N/A** the source is deemed a published work. Disassembly, decompilation,
252N/A** or other means of reducing the object code to human readable form is
252N/A** prohibited by the license agreement under which this code is provided
252N/A** to the user or company in possession of this copy.
252N/A**
252N/A** RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
252N/A** Government is subject to restrictions as set forth in subparagraph
252N/A** (c)(1)(ii) of the Rights in Technical Data and Computer Software
252N/A** clause at DFARS 52.227-7013 and in similar clauses in the FAR and
252N/A** NASA FAR Supplement.
252N/A*/
252N/A/****************************************************************************
252N/A * Copyright (c) 1986, 1988 Epilogue Technology Corporation
252N/A * All rights reserved.
252N/A *
252N/A * This is unpublished proprietary source code of Epilogue Technology
252N/A * Corporation.
252N/A *
252N/A * The copyright notice above does not evidence any actual or intended
252N/A * publication of such source code.
252N/A ****************************************************************************/
252N/A
252N/A/* $Header: /net/bigblock.east/files5/SMA_CVS/sun/agent/modules/seaExtensions/asn1.h,v 1.3 2003/08/12 21:14:53 rr144420 Exp $ */
252N/A/*
252N/A * $Log: asn1.h,v $
252N/A * Revision 1.3 2003/08/12 21:14:53 rr144420
252N/A * 4895376 - correct Sun copyright statements. Cannot use (c), and must use Copyright Copyright in makefiles
252N/A *
252N/A * Revision 1.2 2003/08/08 15:39:52 pcarroll
252N/A * 4895376 - The copyright statement in the demo* codes do not look right
252N/A *
252N/A * Revision 1.1 2003/07/28 17:59:15 dporter
252N/A * 4892877 - Need SMA Agent to implement sun extensions found in SEA sun.mib
252N/A *
252N/A *
252N/A * Rev 2.0 31 Mar 1990 15:11:26
252N/A * Release 2.00
252N/A *
252N/A * Rev 1.1 14 Dec 1989 16:01:16
252N/A * Added support for Borland Turbo C compiler
252N/A *
252N/A * Rev 1.0 12 Sep 1988 10:46:12
252N/A * Initial revision.
252N/A*/
252N/A
252N/A#if (!defined(asn1_inc))
252N/A#define asn1_inc
252N/A
252N/A/**********************************************************************
252N/A If necessary adjust the following to match the compiler being used.
252N/A **********************************************************************/
252N/Atypedef long INT_32_T;
252N/Atypedef unsigned long UINT_32_T;
252N/Atypedef short int INT_16_T;
252N/Atypedef unsigned short UINT_16_T;
252N/Atypedef unsigned char UINT_8_T;
252N/Atypedef unsigned char OCTET_T ;
252N/A /* SNMP ASN.1 tags and lengths can always fit into 16 bits... */
252N/Atypedef unsigned short ATVALUE_T; /* ASN.1 type values */
252N/Atypedef unsigned short ALENGTH_T; /* ASN.1 contents field lengths */
252N/A#define OCTETS_PER_INT32 (sizeof(INT_32_T)/sizeof(OCTET_T))
252N/A#define OCTETS_PER_INT16 (sizeof(INT_16_T)/sizeof(OCTET_T))
252N/A
252N/A/* Allow the components of an object identifer to be either 16 or 32-bits */
252N/A/* 16-bit is default, define OIDC_32 to switch to 32-bits. */
252N/A#if defined(OIDC_32)
252N/Atypedef unsigned long OIDC_T;
252N/A#else
252N/Atypedef unsigned short OIDC_T;
252N/A#endif /* OIDC_32 */
252N/A
252N/A/* ASN.1 FLAGS (form and class), adjusted for position within an octet */
252N/A#define A_IDCF_MASK 0xE0 /* Mask for ID CLASS and FORM bits */
252N/A#define A_IDC_MASK 0xC0 /* Mask for ID CLASS bits */
252N/A#define A_IDF_MASK 0x20 /* Mask for ID FORM bit */
252N/A#define A_FLAG_MASK 0xE0
252N/A#define A_UNIVERSAL 0x00
252N/A#define A_APPLICATION 0x40
252N/A#define A_CONTEXT 0x80
252N/A#define A_PRIVATE 0xC0
252N/A#define A_PRIMITIVE 0x00
252N/A#define A_CONSTRUCTOR 0x20
252N/A
252N/A#define A_DEFAULT_SCOPE A_CONTEXT
252N/A
252N/A/* ASN.1 basic types, all in UNIVERSAL scope */
252N/A#define A_NO_ID 0x00
252N/A#define A_BOOLEAN 0x01
252N/A#define A_INTEGER 0x02
252N/A#define A_BITSTRING 0x03
252N/A#define A_OCTETSTRING 0x04
252N/A#define A_NULL 0x05
252N/A#define A_OBJECTID 0x06
252N/A#define A_SEQUENCE 0x10
252N/A#define A_SET 0x11
252N/A
252N/A/* ASN.1 defined types, all based on OCTETSTRING */
252N/A#define A_NUMERICSTRING 0x12
252N/A#define A_PRINTABLESTRING 0x13
252N/A#define A_T61STRING 0x14
252N/A#define A_TELETEXSTRING A_T61STRING
252N/A#define A_VIDEOTEXSTRING 0x15
252N/A#define A_IA5STRING 0x16
252N/A#define A_GRAPHICSTRING 0x19
252N/A#define A_VISIBLESTRING 0x1A
252N/A#define A_GENERALSTRING 0x1B
252N/A
252N/A/* Other ASN.1 defined universal types */
252N/A#define A_GENERALIZEDTIME 0x18
252N/A#define A_UTCTIME 0x17
252N/A#define A_OBJECTDESCRIPTOR 0x07
252N/A
252N/A/****************************************************************************
252N/A
252N/ANAME: A_SizeOfLength
252N/A
252N/APURPOSE: Compute the number of octets needed to hold an ASN.1 length field.
252N/A
252N/APARAMETERS:
252N/A ALENGTH_T The proposed length
252N/A
252N/ARETURNS: ALENGTH_T The number of octets needed
252N/A
252N/ARESTRICTIONS:
252N/A
252N/ABUGS:
252N/A****************************************************************************/
252N/A#define A_SizeOfLength(S) ((ALENGTH_T)((S) <= 127 ? 1 : ((S) <= 255 ? 2 : 3)))
252N/A
252N/A/****************************************************************************
252N/A
252N/ANAME: A_SizeOfType
252N/A
252N/APURPOSE: Compute the number of octets needed to hold an ASN.1 type field
252N/A
252N/APARAMETERS:
252N/A ATVALUE_T The proposed type (without CLASS & FORM bits)
252N/A
252N/ARETURNS: unsigned int The number of octets needed
252N/A
252N/ARESTRICTIONS:
252N/A
252N/ABUGS:
252N/A****************************************************************************/
252N/A#define A_SizeOfType(V) ((unsigned int) ((V) <= 30 ? 1 : \
252N/A ((V) <= 127 ? 2 : ((V) <= 16383 ? 3 : 4))))
252N/A
252N/A
252N/A/****************************************************************************
252N/AA_SizeOfOctetString -- Return total size that an octet string would
252N/A occupy when ASN.1 encoded (tag and length fields
252N/A are NOT included)
252N/A
252N/AParameters:
252N/A ALENGTH_T The size of the string
252N/A
252N/AReturns: ALENGTH_T Number of octets the octet string would occupy if
252N/A in ASN.1 encoding, NOT including the type/length fields
252N/A of the outermost wrapper. Since these routines only
252N/A generate non-constructor encodings, the length is
252N/A exactly that given.
252N/A****************************************************************************/
252N/A#define A_SizeOfOctetString(L) ((ALENGTH_T)(L))
252N/A
252N/A
252N/A/****************************************************************************
252N/AOBJECT IDENTIFIER
252N/A****************************************************************************/
252N/A
252N/A/* The following structure is used to internally hold an object identifier */
252N/A/* Each component is limited in range from 0 to 64K-1. */
252N/A
252N/Atypedef struct OBJ_ID_S
252N/A {
252N/A int num_components; /* # of object id components */
252N/A /* Note: this is the number of */
252N/A /* components in the object id, */
252N/A /* which is one more than the # */
252N/A /* of subidentifiers in an */
252N/A /* encoded object id. */
252N/A OIDC_T *component_list;
252N/A } OBJ_ID_T;
252N/A
252N/A#endif /* asn1_inc */