1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1998 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate #ifndef _ASN1_H_ 30*0Sstevel@tonic-gate #define _ASN1_H_ 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/types.h> 33*0Sstevel@tonic-gate #include "impl.h" 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate /***** GLOBAL CONSTANTS *****/ 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #define MAX_SUBID 0xFFFFFFFF 38*0Sstevel@tonic-gate /*SNMP imposes a restriction on the max. length */ 39*0Sstevel@tonic-gate /* of any OID value to 128 numbers in the sequence. */ 40*0Sstevel@tonic-gate #define MAX_OID_LEN 128 /* max subid's in an oid */ 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate #define ASN_BOOLEAN (0x01) 43*0Sstevel@tonic-gate #define ASN_INTEGER (0x02) 44*0Sstevel@tonic-gate #define ASN_BIT_STR (0x03) 45*0Sstevel@tonic-gate #define ASN_OCTET_STR (0x04) 46*0Sstevel@tonic-gate #define ASN_NULL (0x05) 47*0Sstevel@tonic-gate #define ASN_OBJECT_ID (0x06) 48*0Sstevel@tonic-gate #define ASN_SEQUENCE (0x10) 49*0Sstevel@tonic-gate #define ASN_SET (0x11) 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #define ASN_UNIVERSAL (0x00) 52*0Sstevel@tonic-gate #define ASN_APPLICATION (0x40) 53*0Sstevel@tonic-gate #define ASN_CONTEXT (0x80) 54*0Sstevel@tonic-gate #define ASN_PRIVATE (0xC0) 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate #define ASN_PRIMITIVE (0x00) 57*0Sstevel@tonic-gate #define ASN_CONSTRUCTOR (0x20) 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate #define ASN_LONG_LEN (0x80) 60*0Sstevel@tonic-gate #define ASN_EXTENSION_ID (0x1F) 61*0Sstevel@tonic-gate #define ASN_BIT8 (0x80) 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate #define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR) 64*0Sstevel@tonic-gate #define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID) 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate #define INTEGER ASN_INTEGER 68*0Sstevel@tonic-gate #define STRING ASN_OCTET_STR 69*0Sstevel@tonic-gate #define OBJID ASN_OBJECT_ID 70*0Sstevel@tonic-gate #define NULLOBJ ASN_NULL 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate /* defined types (from the SMI, RFC 1065) */ 73*0Sstevel@tonic-gate #define IPADDRESS (ASN_APPLICATION | 0) 74*0Sstevel@tonic-gate #define COUNTER (ASN_APPLICATION | 1) 75*0Sstevel@tonic-gate #define GAUGE (ASN_APPLICATION | 2) 76*0Sstevel@tonic-gate #define TIMETICKS (ASN_APPLICATION | 3) 77*0Sstevel@tonic-gate #define OPAQUE (ASN_APPLICATION | 4) 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate /***** GLOBAL FUNCTIONS *****/ 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate extern u_char *asn_parse_int(u_char *, uint32_t *, u_char *, int32_t *, uint32_t , char *); 83*0Sstevel@tonic-gate extern u_char *asn_parse_unsigned_int(u_char *, uint32_t *, u_char *, 84*0Sstevel@tonic-gate int32_t *, uint32_t, char *); 85*0Sstevel@tonic-gate extern u_char *asn_build_int(u_char *, uint32_t *, u_char, int32_t *, uint32_t, char *); 86*0Sstevel@tonic-gate extern u_char *asn_build_unsigned_int(u_char *, uint32_t *, u_char, 87*0Sstevel@tonic-gate int32_t *, uint32_t, char *); 88*0Sstevel@tonic-gate extern u_char *asn_parse_string(u_char *, uint32_t *, u_char *, u_char *, uint32_t *, char *); 89*0Sstevel@tonic-gate extern u_char *asn_build_string(u_char *, uint32_t *, u_char, u_char *, uint32_t, char *); 90*0Sstevel@tonic-gate extern u_char *asn_parse_header(u_char *, uint32_t *, u_char *, char *); 91*0Sstevel@tonic-gate extern u_char *asn_build_header(u_char *, uint32_t *, u_char, uint32_t, char *); 92*0Sstevel@tonic-gate extern u_char *asn_parse_length(u_char *, uint32_t *, char *); 93*0Sstevel@tonic-gate extern u_char *asn_build_length(u_char *, uint32_t *, uint32_t, char *); 94*0Sstevel@tonic-gate extern u_char *asn_parse_objid(u_char *, uint32_t *, u_char *, Subid *, int32_t *, char *); 95*0Sstevel@tonic-gate extern u_char *asn_build_objid(u_char *, uint32_t *, u_char, Subid *, int32_t, char *); 96*0Sstevel@tonic-gate extern u_char *asn_parse_null(u_char *, uint32_t *, u_char *, char *); 97*0Sstevel@tonic-gate extern u_char *asn_build_null(u_char *, uint32_t *, u_char, char *); 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate #endif 100