📄 asn1.h
字号:
/*_############################################################################ _## _## asn1.h _## _## SNMP++v3.2.20 _## ----------------------------------------------- _## Copyright (c) 2001-2006 Jochen Katz, Frank Fock _## _## This software is based on SNMP++2.6 from Hewlett Packard: _## _## Copyright (c) 1996 _## Hewlett-Packard Company _## _## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. _## Permission to use, copy, modify, distribute and/or sell this software _## and/or its documentation is hereby granted without fee. User agrees _## to display the above copyright notice and this license notice in all _## copies of the software and any documentation of the software. User _## agrees to assume all liability for the use of the software; _## Hewlett-Packard and Jochen Katz make no representations about the _## suitability of this software for any purpose. It is provided _## "AS-IS" without warranty of any kind, either express or implied. User _## hereby grants a royalty-free license to any and all derivatives based _## upon this software code base. _## _## Stuttgart, Germany, Sun Jan 15 23:12:08 CET 2006 _## _##########################################################################*/// $Id: asn1.h,v 1.7 2004/03/28 21:47:15 katz Exp $#ifndef _ASN1#define _ASN1#ifdef WIN32#ifndef __unix#include <winsock.h>#endif#endif#include "snmp_pp/target.h"#ifdef SNMP_PP_NAMESPACEnamespace Snmp_pp {#endif#define MAXLENGTH_BUFFER SNMP_MSG_LENGTH#ifndef EIGHTBIT_SUBIDStypedef unsigned long oid;#define MAX_SUBID 0xFFFFFFFF#elsetypedef unsigned char oid;#define MAX_SUBID 0xFF#endif#define MAX_OID_LEN 128 /* max subid's in an oid */// asn.1 values#define ASN_BOOLEAN (0x01)#ifndef ASN_INTEGER#define ASN_INTEGER (0x02)#endif#define ASN_BIT_STR (0x03)#define ASN_OCTET_STR (0x04)#ifndef ASN_NULL#define ASN_NULL (0x05)#endif#define ASN_OBJECT_ID (0x06)#ifndef ASN_SEQUENCE#define ASN_SEQUENCE (0x10)#endif#define ASN_SET (0x11)#ifndef ASN_UNIVERSAL#define ASN_UNIVERSAL (0x00)#endif#ifndef ASN_APPLICATION#define ASN_APPLICATION (0x40)#endif#ifndef ASN_CONTEXT#define ASN_CONTEXT (0x80)#endif#ifndef ASN_PRIVATE#define ASN_PRIVATE (0xC0)#endif#ifndef ASN_PRIMITIVE#define ASN_PRIMITIVE (0x00)#endif#ifndef ASN_CONSTRUCTOR#define ASN_CONSTRUCTOR (0x20)#endif#define ASN_LONG_LEN (0x80)#define ASN_EXTENSION_ID (0x1F)#define ASN_BIT8 (0x80)#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)#define ASN_MAX_NAME_LEN 128#define SNMP_VERSION_1 0#define SNMP_VERSION_2C 1#define SNMP_VERSION_2STERN 2#define SNMP_VERSION_3 3// defined types (from the SMI, RFC 1065)#define SMI_IPADDRESS (ASN_APPLICATION | 0)#define SMI_COUNTER (ASN_APPLICATION | 1)#define SMI_GAUGE (ASN_APPLICATION | 2)#define SMI_TIMETICKS (ASN_APPLICATION | 3)#define SMI_OPAQUE (ASN_APPLICATION | 4)#define SMI_NSAP (ASN_APPLICATION | 5)#define SMI_COUNTER64 (ASN_APPLICATION | 6)#define SMI_UINTEGER (ASN_APPLICATION | 7)#define GET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)#define GETNEXT_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)#define GET_RSP_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)#define SET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)#define GETBULK_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)#define INFORM_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)#define TRP2_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)#define REPORT_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)#define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)#define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)#define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)#define SNMP_MSG_LENGTH MAX_SNMP_PACKET#ifdef _DEBUG#define ASNERROR( string) debugprintf(3, "ASN parse error (%s)\n", string )#else#define ASNERROR( string)#endiftypedef struct sockaddr_in ipaddr;// pdustruct snmp_pdu { int command; // pdu type unsigned long reqid; // Request id#ifdef _SNMPv3 unsigned long msgid; unsigned long maxsize_scopedpdu;#endif unsigned long errstat; // Error status unsigned long errindex; // Error index // Trap information oid *enterprise; // System OID int enterprise_length; ipaddr agent_addr; // address of object generating trap int trap_type; // trap type int specific_type; // specific type unsigned long time; // Uptime // vb list struct variable_list *variables;};// vb liststruct variable_list { struct variable_list *next_variable; // NULL for last variable oid *name; // Object identifier of variable int name_length; // number of subid's in name unsigned char type; // ASN type of variable union { // value of variable long *integer; unsigned char *string; oid *objid; unsigned char *bitstring; struct counter64 *counter64; } val; int val_len;};struct counter64 { unsigned long high; unsigned long low;};// prototypes for encoding routinesDLLOPT unsigned char *asn_parse_int( unsigned char *data, int *datalength, unsigned char *type, long int *intp, int intsize);DLLOPT unsigned char *asn_parse_unsigned_int( unsigned char *data, int *datalength, unsigned char *type, unsigned long *intp, int intsize);DLLOPT unsigned char *asn_build_int(unsigned char *data, int *datalength, const unsigned char type, const long *intp, int intsize);DLLOPT unsigned char *asn_build_unsigned_int( unsigned char *data, int *datalength, unsigned char type, unsigned long *intp, int intsize);DLLOPT unsigned char *asn_parse_string( unsigned char *data, int *datalength, unsigned char *type, unsigned char *string, int *strlength);DLLOPT unsigned char *asn_build_string( unsigned char *data, int *datalength, const unsigned char type, const unsigned char *string, const int strlength);DLLOPT unsigned char *asn_parse_header( unsigned char *data, int *datalength, unsigned char *type);DLLOPT unsigned char *asn_build_header( unsigned char *data, int *datalength, unsigned char type, int length);DLLOPT unsigned char *asn_build_sequence( unsigned char *data, int *datalength, unsigned char type,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -