谁有snmp对应的Delphi单元(最好是WSNMP32.dll的)或者完整一点的控件,谢谢!(100分)

  • 主题发起人 主题发起人 Lucker
  • 开始时间 开始时间
D6里就有
 
{******************************************************************}
{ }
{ Borland Delphi Runtime Library }
{ SNMP functions interface unit }
{ }
{ Portions created by Microsoft are }
{ Copyright (C) 1992-1999 Microsoft Corporation. }
{ All Rights Reserved. }
{ }
{ The original file is: snmp.h }
{ The original Pascal code is: Snmp.pas, released 05 Oct 2001. }
{ The initial developer of the Pascal code is Petr Vones }
{ (petr.v@mujmail.cz). }
{ }
{ Portions created by Petr Vones are }
{ Copyright (C) 2001 Petr Vones }
{ }
{ Obtained through: }
{ }
{ Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project }
{ JEDI home page, located at http://delphi-jedi.org }
{ }
{ The contents of this file are used with permission, subject to }
{ the Mozilla Public License Version 1.1 (the "License"); you may }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
{ implied. See the License for the specific language governing }
{ rights and limitations under the License. }
{ }
{******************************************************************}

unit Snmp;

{$ALIGN ON}
{$WEAKPACKAGEUNIT ON}
{$MINENUMSIZE 4}

interface

uses
Windows;

(*$HPPEMIT '#include <snmp.h>'*)

type
PAsnOctetString = ^TAsnOctetString;
TAsnOctetString = record
stream: PChar;
length: UINT;
dynamic_: Boolean;
end;
{$EXTERNALSYM TAsnOctetString}

PAsnObjectIdentifier = ^TAsnObjectIdentifier;
TAsnObjectIdentifier = record
idLength: UINT;
ids: PUINT;
end;
{$EXTERNALSYM TAsnObjectIdentifier}

TAsnInteger32 = LongInt;
{$EXTERNALSYM TAsnInteger32}
TAsnUnsigned32 = ULONG;
{$EXTERNALSYM TAsnUnsigned32}
TAsnCounter64 = ULARGE_INTEGER;
{$EXTERNALSYM TAsnCounter64}
TAsnCounter32 = TAsnUnsigned32;
{$EXTERNALSYM TAsnCounter32}
TAsnGauge32 = TAsnUnsigned32;
{$EXTERNALSYM TAsnGauge32}
TAsnTimeticks = TAsnUnsigned32;
{$EXTERNALSYM TAsnTimeticks}
TAsnBits = TAsnOctetString;
{$EXTERNALSYM TAsnBits}
TAsnSequence = TAsnOctetString;
{$EXTERNALSYM TAsnSequence}
TAsnImplicitSequence = TAsnOctetString;
{$EXTERNALSYM TAsnImplicitSequence}
TAsnIPAddress = TAsnOctetString;
{$EXTERNALSYM TAsnIPAddress}
TAsnNetworkAddress = TAsnOctetString;
{$EXTERNALSYM TAsnNetworkAddress}
TAsnDisplayString = TAsnOctetString;
{$EXTERNALSYM TAsnDisplayString}
TAsnOpaque = TAsnOctetString;
{$EXTERNALSYM TAsnOpaque}

PAsnAny = ^TAsnAny;
TAsnAny = record
asnType: Byte;
case Integer of
0: (number: TAsnInteger32); // ASN_INTEGER, ASN_INTEGER32
1: (unsigned32: TAsnUnsigned32); // ASN_UNSIGNED32
2: (counter64: TAsnCounter64); // ASN_COUNTER64
3: (string_: TAsnOctetString); // ASN_OCTETSTRING
4: (bits: TAsnBits); // ASN_BITS
5: (object_: TAsnObjectIdentifier); // ASN_OBJECTIDENTIFIER
6: (sequence: TAsnSequence); // ASN_SEQUENCE
7: (address: TAsnIPAddress); // ASN_IPADDRESS
8: (counter: TAsnCounter32); // ASN_COUNTER32
9: (gauge: TAsnGauge32); // ASN_GAUGE32
10: (ticks: TAsnTimeticks); // ASN_TIMETICKS
11: (arbitrary: TAsnOpaque); // ASN_OPAQUE
end;
{$EXTERNALSYM TAsnAny}

TAsnObjectName = TAsnObjectIdentifier;
{$EXTERNALSYM TAsnObjectName}
TAsnObjectSyntax = TAsnAny;
{$EXTERNALSYM TAsnObjectSyntax}

PSnmpVarBind = ^TSnmpVarBind;
TSnmpVarBind = record
name: TAsnObjectName;
value: TAsnObjectSyntax;
end;
{$EXTERNALSYM TSnmpVarBind}

PSnmpVarBindList = ^TSnmpVarBindList;
TSnmpVarBindList = record
list: PSnmpVarBind;
len: UINT;
end;
{$EXTERNALSYM TSnmpVarBindList}

const

{$IFNDEF _INC_WINSNMP}

{ ASN/BER Base Types }

ASN_UNIVERSAL = $00;
{$EXTERNALSYM ASN_UNIVERSAL}
ASN_APPLICATION = $40;
{$EXTERNALSYM ASN_APPLICATION}
ASN_CONTEXT = $80;
{$EXTERNALSYM ASN_CONTEXT}
ASN_PRIVATE = $C0;
{$EXTERNALSYM ASN_PRIVATE}

ASN_PRIMITIVE = $00;
{$EXTERNALSYM ASN_PRIMITIVE}
ASN_CONSTRUCTOR = $20;
{$EXTERNALSYM ASN_CONSTRUCTOR}

{ PDU Type Values }

SNMP_PDU_GET = (ASN_CONTEXT or ASN_CONSTRUCTOR or $0);
{$EXTERNALSYM SNMP_PDU_GET}
SNMP_PDU_GETNEXT = (ASN_CONTEXT or ASN_CONSTRUCTOR or $1);
{$EXTERNALSYM SNMP_PDU_GETNEXT}
SNMP_PDU_RESPONSE = (ASN_CONTEXT or ASN_CONSTRUCTOR or $2);
{$EXTERNALSYM SNMP_PDU_RESPONSE}
SNMP_PDU_SET = (ASN_CONTEXT or ASN_CONSTRUCTOR or $3);
{$EXTERNALSYM SNMP_PDU_SET}
SNMP_PDU_V1TRAP = (ASN_CONTEXT or ASN_CONSTRUCTOR or $4);
{$EXTERNALSYM SNMP_PDU_V1TRAP}
SNMP_PDU_GETBULK = (ASN_CONTEXT or ASN_CONSTRUCTOR or $5);
{$EXTERNALSYM SNMP_PDU_GETBULK}
SNMP_PDU_INFORM = (ASN_CONTEXT or ASN_CONSTRUCTOR or $6);
{$EXTERNALSYM SNMP_PDU_INFORM}
SNMP_PDU_TRAP = (ASN_CONTEXT or ASN_CONSTRUCTOR or $7);
{$EXTERNALSYM SNMP_PDU_TRAP}

{$ENDIF _INC_WINSNMP}

{ SNMP Simple Syntax Values }

ASN_INTEGER = (ASN_UNIVERSAL or ASN_PRIMITIVE or $02);
{$EXTERNALSYM ASN_INTEGER}
ASN_BITS = (ASN_UNIVERSAL or ASN_PRIMITIVE or $03);
{$EXTERNALSYM ASN_BITS}
ASN_OCTETSTRING = (ASN_UNIVERSAL or ASN_PRIMITIVE or $04);
{$EXTERNALSYM ASN_OCTETSTRING}
ASN_NULL = (ASN_UNIVERSAL or ASN_PRIMITIVE or $05);
{$EXTERNALSYM ASN_NULL}
ASN_OBJECTIDENTIFIER = (ASN_UNIVERSAL or ASN_PRIMITIVE or $06);
{$EXTERNALSYM ASN_OBJECTIDENTIFIER}
ASN_INTEGER32 = ASN_INTEGER;
{$EXTERNALSYM ASN_INTEGER32}

{ SNMP Constructor Syntax Values }

ASN_SEQUENCE = (ASN_UNIVERSAL or ASN_CONSTRUCTOR or $10);
{$EXTERNALSYM ASN_SEQUENCE}
ASN_SEQUENCEOF = ASN_SEQUENCE;
{$EXTERNALSYM ASN_SEQUENCEOF}

{ SNMP Application Syntax Values }

ASN_IPADDRESS = (ASN_APPLICATION or ASN_PRIMITIVE or $00);
{$EXTERNALSYM ASN_IPADDRESS}
ASN_COUNTER32 = (ASN_APPLICATION or ASN_PRIMITIVE or $01);
{$EXTERNALSYM ASN_COUNTER32}
ASN_GAUGE32 = (ASN_APPLICATION or ASN_PRIMITIVE or $02);
{$EXTERNALSYM ASN_GAUGE32}
ASN_TIMETICKS = (ASN_APPLICATION or ASN_PRIMITIVE or $03);
{$EXTERNALSYM ASN_TIMETICKS}
ASN_OPAQUE = (ASN_APPLICATION or ASN_PRIMITIVE or $04);
{$EXTERNALSYM ASN_OPAQUE}
ASN_COUNTER64 = (ASN_APPLICATION or ASN_PRIMITIVE or $06);
{$EXTERNALSYM ASN_COUNTER64}
ASN_UNSIGNED32 = (ASN_APPLICATION or ASN_PRIMITIVE or $07);
{$EXTERNALSYM ASN_UNSIGNED32}

{ SNMP Exception Conditions }

SNMP_EXCEPTION_NOSUCHOBJECT = (ASN_CONTEXT or ASN_PRIMITIVE or $00);
{$EXTERNALSYM SNMP_EXCEPTION_NOSUCHOBJECT}
SNMP_EXCEPTION_NOSUCHINSTANCE = (ASN_CONTEXT or ASN_PRIMITIVE or $01);
{$EXTERNALSYM SNMP_EXCEPTION_NOSUCHINSTANCE}
SNMP_EXCEPTION_ENDOFMIBVIEW = (ASN_CONTEXT or ASN_PRIMITIVE or $02);
{$EXTERNALSYM SNMP_EXCEPTION_ENDOFMIBVIEW}

{ SNMP Request Types (used in SnmpExtensionQueryEx) }

SNMP_EXTENSION_GET = SNMP_PDU_GET;
{$EXTERNALSYM SNMP_EXTENSION_GET}
SNMP_EXTENSION_GET_NEXT = SNMP_PDU_GETNEXT;
{$EXTERNALSYM SNMP_EXTENSION_GET_NEXT}
SNMP_EXTENSION_GET_BULK = SNMP_PDU_GETBULK;
{$EXTERNALSYM SNMP_EXTENSION_GET_BULK}
SNMP_EXTENSION_SET_TEST = (ASN_PRIVATE or ASN_CONSTRUCTOR or $0);
{$EXTERNALSYM SNMP_EXTENSION_SET_TEST}
SNMP_EXTENSION_SET_COMMIT = SNMP_PDU_SET;
{$EXTERNALSYM SNMP_EXTENSION_SET_COMMIT}
SNMP_EXTENSION_SET_UNDO = (ASN_PRIVATE or ASN_CONSTRUCTOR or $1);
{$EXTERNALSYM SNMP_EXTENSION_SET_UNDO}
SNMP_EXTENSION_SET_CLEANUP = (ASN_PRIVATE or ASN_CONSTRUCTOR or $2);
{$EXTERNALSYM SNMP_EXTENSION_SET_CLEANUP}

{ SNMP Error Codes }

SNMP_ERRORSTATUS_NOERROR = 0;
{$EXTERNALSYM SNMP_ERRORSTATUS_NOERROR}
SNMP_ERRORSTATUS_TOOBIG = 1;
{$EXTERNALSYM SNMP_ERRORSTATUS_TOOBIG}
SNMP_ERRORSTATUS_NOSUCHNAME = 2;
{$EXTERNALSYM SNMP_ERRORSTATUS_NOSUCHNAME}
SNMP_ERRORSTATUS_BADVALUE = 3;
{$EXTERNALSYM SNMP_ERRORSTATUS_BADVALUE}
SNMP_ERRORSTATUS_READONLY = 4;
{$EXTERNALSYM SNMP_ERRORSTATUS_READONLY}
SNMP_ERRORSTATUS_GENERR = 5;
{$EXTERNALSYM SNMP_ERRORSTATUS_GENERR}
SNMP_ERRORSTATUS_NOACCESS = 6;
{$EXTERNALSYM SNMP_ERRORSTATUS_NOACCESS}
SNMP_ERRORSTATUS_WRONGTYPE = 7;
{$EXTERNALSYM SNMP_ERRORSTATUS_WRONGTYPE}
SNMP_ERRORSTATUS_WRONGLENGTH = 8;
{$EXTERNALSYM SNMP_ERRORSTATUS_WRONGLENGTH}
SNMP_ERRORSTATUS_WRONGENCODING = 9;
{$EXTERNALSYM SNMP_ERRORSTATUS_WRONGENCODING}
SNMP_ERRORSTATUS_WRONGVALUE = 10;
{$EXTERNALSYM SNMP_ERRORSTATUS_WRONGVALUE}
SNMP_ERRORSTATUS_NOCREATION = 11;
{$EXTERNALSYM SNMP_ERRORSTATUS_NOCREATION}
SNMP_ERRORSTATUS_INCONSISTENTVALUE = 12;
{$EXTERNALSYM SNMP_ERRORSTATUS_INCONSISTENTVALUE}
SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE = 13;
{$EXTERNALSYM SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE}
SNMP_ERRORSTATUS_COMMITFAILED = 14;
{$EXTERNALSYM SNMP_ERRORSTATUS_COMMITFAILED}
SNMP_ERRORSTATUS_UNDOFAILED = 15;
{$EXTERNALSYM SNMP_ERRORSTATUS_UNDOFAILED}
SNMP_ERRORSTATUS_AUTHORIZATIONERROR = 16;
{$EXTERNALSYM SNMP_ERRORSTATUS_AUTHORIZATIONERROR}
SNMP_ERRORSTATUS_NOTWRITABLE = 17;
{$EXTERNALSYM SNMP_ERRORSTATUS_NOTWRITABLE}
SNMP_ERRORSTATUS_INCONSISTENTNAME = 18;
{$EXTERNALSYM SNMP_ERRORSTATUS_INCONSISTENTNAME}

{ SNMPv1 Trap Types }

SNMP_GENERICTRAP_COLDSTART = 0;
{$EXTERNALSYM SNMP_GENERICTRAP_COLDSTART}
SNMP_GENERICTRAP_WARMSTART = 1;
{$EXTERNALSYM SNMP_GENERICTRAP_WARMSTART}
SNMP_GENERICTRAP_LINKDOWN = 2;
{$EXTERNALSYM SNMP_GENERICTRAP_LINKDOWN}
SNMP_GENERICTRAP_LINKUP = 3;
{$EXTERNALSYM SNMP_GENERICTRAP_LINKUP}
SNMP_GENERICTRAP_AUTHFAILURE = 4;
{$EXTERNALSYM SNMP_GENERICTRAP_AUTHFAILURE}
SNMP_GENERICTRAP_EGPNEIGHLOSS = 5;
{$EXTERNALSYM SNMP_GENERICTRAP_EGPNEIGHLOSS}
SNMP_GENERICTRAP_ENTERSPECIFIC = 6;
{$EXTERNALSYM SNMP_GENERICTRAP_ENTERSPECIFIC}

{ SNMP Access Types }

SNMP_ACCESS_NONE = 0;
{$EXTERNALSYM SNMP_ACCESS_NONE}
SNMP_ACCESS_NOTIFY = 1;
{$EXTERNALSYM SNMP_ACCESS_NOTIFY}
SNMP_ACCESS_READ_ONLY = 2;
{$EXTERNALSYM SNMP_ACCESS_READ_ONLY}
SNMP_ACCESS_READ_WRITE = 3;
{$EXTERNALSYM SNMP_ACCESS_READ_WRITE}
SNMP_ACCESS_READ_CREATE = 4;
{$EXTERNALSYM SNMP_ACCESS_READ_CREATE}

{ SNMP API Return Code Definitions }

type
SNMPAPI = Integer;
{$EXTERNALSYM SNMPAPI}
const
SNMPAPI_NOERROR = True;
{$EXTERNALSYM SNMPAPI_NOERROR}
SNMPAPI_ERROR = False;
{$EXTERNALSYM SNMPAPI_ERROR}

{ SNMP Extension API Type Definitions }

type
TSnmpExtensionInit = function (dwUptimeReference: DWORD; var phSubagentTrapEvent: THandle;
var pFirstSupportedRegion: PAsnObjectIdentifier): Boolean; stdcall;

TSnmpExtensionInitEx = function (var pNextSupportedRegion: PAsnObjectIdentifier): Boolean; stdcall;

TSnmpExtensionMonitor = function (pAgentMgmtData: Pointer): Boolean; stdcall;

TSnmpExtensionQuery = function (bPduType: Byte; var pVarBindList: TSnmpVarBindList;
var pErrorStatus: TAsnInteger32; var pErrorIndex: TAsnInteger32): Boolean; stdcall;

TSnmpExtensionQueryEx = function (nRequestType: UINT; nTransactionId: UINT; var pVarBindList: PSnmpVarBindList;
var pContextInfo: PAsnOctetString; var pErrorStatus: TAsnInteger32; var pErrorIndex: TAsnInteger32): Boolean; stdcall;

TSnmpExtensionTrap = function (pEnterpriseOid: PAsnObjectIdentifier; var pGenericTrapId: TAsnInteger32;
var pSpecificTrapId: TAsnInteger32; var pTimeStamp: TAsnTimeticks; var pVarBindList: PSnmpVarBindList): Boolean; stdcall;

TSnmpExtensionClose = procedure; stdcall;

{ SNMP API Prototypes }

function SnmpUtilOidCpy(pOidDst: PAsnObjectIdentifier; pOidSrc: PAsnObjectIdentifier): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilOidCpy}
function SnmpUtilOidAppend(pOidDst: PAsnObjectIdentifier; pOidSrc: PAsnObjectIdentifier): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilOidAppend}
function SnmpUtilOidNCmp(pOid1, pOid2: PAsnObjectIdentifier; nSubIds: UINT): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilOidNCmp}
function SnmpUtilOidCmp(pOid1, pOid2: PAsnObjectIdentifier): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilOidCmp}
procedure SnmpUtilOidFree(pOid: TAsnObjectIdentifier); stdcall;
{$EXTERNALSYM SnmpUtilOidFree}
function SnmpUtilOctetsCmp(pOctets1, pOctets2: PAsnOctetString): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilOctetsCmp}
function SnmpUtilOctetsNCmp(pOctets1, pOctets2: PAsnOctetString; nChars: UINT): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilOctetsNCmp}
function SnmpUtilOctetsCpy(pOctetsDst, pOctetsSrc: PAsnOctetString): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilOctetsCpy}
procedure SnmpUtilOctetsFree(pOctets: PAsnOctetString); stdcall;
{$EXTERNALSYM SnmpUtilOctetsFree}
function SnmpUtilAsnAnyCpy(pAnyDst, pAnySrc: PAsnAny): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilAsnAnyCpy}
procedure SnmpUtilAsnAnyFree(pAny: PAsnAny); stdcall;
{$EXTERNALSYM SnmpUtilAsnAnyFree}
function SnmpUtilVarBindCpy(pVbDst: PSnmpVarBind; pVbSrc: PSnmpVarBind): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilVarBindCpy}
procedure SnmpUtilVarBindFree(pVb: PSnmpVarBind); stdcall;
{$EXTERNALSYM SnmpUtilVarBindFree}
function SnmpUtilVarBindListCpy(pVblDst: PSnmpVarBindList; pVblSrc: PSnmpVarBindList): SNMPAPI; stdcall;
{$EXTERNALSYM SnmpUtilVarBindListCpy}
procedure SnmpUtilVarBindListFree(pVbl: PSnmpVarBindList); stdcall;
{$EXTERNALSYM SnmpUtilVarBindListFree}
procedure SnmpUtilMemFree(pMem: Pointer); stdcall;
{$EXTERNALSYM SnmpUtilMemFree}
function SnmpUtilMemAlloc(nBytes: UINT): Pointer; stdcall;
{$EXTERNALSYM SnmpUtilMemAlloc}
function SnmpUtilMemReAlloc(pMem: Pointer; nBytes: UINT): Pointer; stdcall;
{$EXTERNALSYM SnmpUtilMemReAlloc}
function SnmpUtilOidToA(Oid: PAsnObjectIdentifier): PChar; stdcall;
{$EXTERNALSYM SnmpUtilOidToA}
function SnmpUtilIdsToA(Ids: PUINT; IdLength: UINT): PChar; stdcall;
{$EXTERNALSYM SnmpUtilIdsToA}
procedure SnmpUtilPrintOid(Oid: PAsnObjectIdentifier); stdcall;
{$EXTERNALSYM SnmpUtilPrintOid}
procedure SnmpUtilPrintAsnAny(pAny: PAsnAny); stdcall;
{$EXTERNALSYM SnmpUtilPrintAsnAny}
function SnmpSvcGetUptime: DWORD; stdcall;
{$EXTERNALSYM SnmpSvcGetUptime}
procedure SnmpSvcSetLogLevel(nLogLevel: Integer); stdcall;
{$EXTERNALSYM SnmpSvcSetLogLevel}
procedure SnmpSvcSetLogType(nLogType: Integer); stdcall;
{$EXTERNALSYM SnmpSvcSetLogType}

{ SNMP Debugging Definitions }

const
SNMP_LOG_SILENT = $0;
{$EXTERNALSYM SNMP_LOG_SILENT}
SNMP_LOG_FATAL = $1;
{$EXTERNALSYM SNMP_LOG_FATAL}
SNMP_LOG_ERROR = $2;
{$EXTERNALSYM SNMP_LOG_ERROR}
SNMP_LOG_WARNING = $3;
{$EXTERNALSYM SNMP_LOG_WARNING}
SNMP_LOG_TRACE = $4;
{$EXTERNALSYM SNMP_LOG_TRACE}
SNMP_LOG_VERBOSE = $5;
{$EXTERNALSYM SNMP_LOG_VERBOSE}

SNMP_OUTPUT_TO_CONSOLE = $1;
{$EXTERNALSYM SNMP_OUTPUT_TO_CONSOLE}
SNMP_OUTPUT_TO_LOGFILE = $2;
{$EXTERNALSYM SNMP_OUTPUT_TO_LOGFILE}
SNMP_OUTPUT_TO_EVENTLOG = $4; // no longer supported
{$EXTERNALSYM SNMP_OUTPUT_TO_EVENTLOG}
SNMP_OUTPUT_TO_DEBUGGER = $8;
{$EXTERNALSYM SNMP_OUTPUT_TO_DEBUGGER}

{ SNMP Debugging Prototypes }

procedure SnmpUtilDbgPrint(nLogLevel: Integer; szFormat: PChar); stdcall;
{$EXTERNALSYM SnmpUtilDbgPrint}

{ Miscellaneous definitions }

const
DEFINE_NULLOID: TAsnObjectIdentifier = (idLength: 0; ids: nil);
{$EXTERNALSYM DEFINE_NULLOID}
DEFINE_NULLOCTETS: TAsnOctetString = (stream: nil; length: 0; dynamic_: False);
{$EXTERNALSYM DEFINE_NULLOCTETS}

DEFAULT_SNMP_PORT_UDP = 161;
{$EXTERNALSYM DEFAULT_SNMP_PORT_UDP}
DEFAULT_SNMP_PORT_IPX = 36879;
{$EXTERNALSYM DEFAULT_SNMP_PORT_IPX}
DEFAULT_SNMPTRAP_PORT_UDP = 162;
{$EXTERNALSYM DEFAULT_SNMPTRAP_PORT_UDP}
DEFAULT_SNMPTRAP_PORT_IPX = 36880;
{$EXTERNALSYM DEFAULT_SNMPTRAP_PORT_IPX}
SNMP_MAX_OID_LEN = 128;
{$EXTERNALSYM SNMP_MAX_OID_LEN}

{ API Error Code Definitions }

SNMP_MEM_ALLOC_ERROR = 1;
{$EXTERNALSYM SNMP_MEM_ALLOC_ERROR}
SNMP_BERAPI_INVALID_LENGTH = 10;
{$EXTERNALSYM SNMP_BERAPI_INVALID_LENGTH}
SNMP_BERAPI_INVALID_TAG = 11;
{$EXTERNALSYM SNMP_BERAPI_INVALID_TAG}
SNMP_BERAPI_OVERFLOW = 12;
{$EXTERNALSYM SNMP_BERAPI_OVERFLOW}
SNMP_BERAPI_SHORT_BUFFER = 13;
{$EXTERNALSYM SNMP_BERAPI_SHORT_BUFFER}
SNMP_BERAPI_INVALID_OBJELEM = 14;
{$EXTERNALSYM SNMP_BERAPI_INVALID_OBJELEM}
SNMP_PDUAPI_UNRECOGNIZED_PDU = 20;
{$EXTERNALSYM SNMP_PDUAPI_UNRECOGNIZED_PDU}
SNMP_PDUAPI_INVALID_ES = 21;
{$EXTERNALSYM SNMP_PDUAPI_INVALID_ES}
SNMP_PDUAPI_INVALID_GT = 22;
{$EXTERNALSYM SNMP_PDUAPI_INVALID_GT}
SNMP_AUTHAPI_INVALID_VERSION = 30;
{$EXTERNALSYM SNMP_AUTHAPI_INVALID_VERSION}
SNMP_AUTHAPI_INVALID_MSG_TYPE = 31;
{$EXTERNALSYM SNMP_AUTHAPI_INVALID_MSG_TYPE}
SNMP_AUTHAPI_TRIV_AUTH_FAILED = 32;
{$EXTERNALSYM SNMP_AUTHAPI_TRIV_AUTH_FAILED}

{ Support for old definitions (support disabled via SNMPSTRICT) }

{$IFNDEF SNMPSTRICT}

function SNMP_oidcpy(pOidDst: PAsnObjectIdentifier; pOidSrc: PAsnObjectIdentifier): SNMPAPI; stdcall;
{$EXTERNALSYM SNMP_oidcpy}
function SNMP_oidappend(pOidDst: PAsnObjectIdentifier; pOidSrc: PAsnObjectIdentifier): SNMPAPI; stdcall;
{$EXTERNALSYM SNMP_oidappend}
function SNMP_oidncmp(pOid1, pOid2: PAsnObjectIdentifier; nSubIds: UINT): SNMPAPI; stdcall;
{$EXTERNALSYM SNMP_oidncmp}
function SNMP_oidcmp(pOid1, pOid2: PAsnObjectIdentifier): SNMPAPI; stdcall;
{$EXTERNALSYM SNMP_oidcmp}
procedure SNMP_oidfree(pOid: TAsnObjectIdentifier); stdcall;
{$EXTERNALSYM SNMP_oidfree}

function SNMP_CopyVarBind(pVbDst: PSnmpVarBind; pVbSrc: PSnmpVarBind): SNMPAPI; stdcall;
{$EXTERNALSYM SNMP_CopyVarBind}
procedure SNMP_FreeVarBind(pVb: PSnmpVarBind); stdcall;
{$EXTERNALSYM SNMP_FreeVarBind}
function SNMP_CopyVarBindList(pVblDst: PSnmpVarBindList; pVblSrc: PSnmpVarBindList): SNMPAPI; stdcall;
{$EXTERNALSYM SNMP_CopyVarBindList}
procedure SNMP_FreeVarBindList(pVbl: PSnmpVarBindList); stdcall;
{$EXTERNALSYM SNMP_FreeVarBindList}

procedure SNMP_printany(pAny: PAsnAny); stdcall;
{$EXTERNALSYM SNMP_printany}

procedure SNMP_free(pMem: Pointer); stdcall;
{$EXTERNALSYM SNMP_free}
function SNMP_malloc(nBytes: UINT): Pointer; stdcall;
{$EXTERNALSYM SNMP_malloc}
function SNMP_realloc(pMem: Pointer; nBytes: UINT): Pointer; stdcall;
{$EXTERNALSYM SNMP_realloc}

procedure SNMP_DBG_free(pMem: Pointer); stdcall;
{$EXTERNALSYM SNMP_DBG_free}
function SNMP_DBG_malloc(nBytes: UINT): Pointer; stdcall;
{$EXTERNALSYM SNMP_DBG_malloc}
function SNMP_DBG_realloc(pMem: Pointer; nBytes: UINT): Pointer; stdcall;
{$EXTERNALSYM SNMP_DBG_realloc}

const
ASN_RFC1155_IPADDRESS = ASN_IPADDRESS;
{$EXTERNALSYM ASN_RFC1155_IPADDRESS}
ASN_RFC1155_COUNTER = ASN_COUNTER32;
{$EXTERNALSYM ASN_RFC1155_COUNTER}
ASN_RFC1155_GAUGE = ASN_GAUGE32;
{$EXTERNALSYM ASN_RFC1155_GAUGE}
ASN_RFC1155_TIMETICKS = ASN_TIMETICKS;
{$EXTERNALSYM ASN_RFC1155_TIMETICKS}
ASN_RFC1155_OPAQUE = ASN_OPAQUE;
{$EXTERNALSYM ASN_RFC1155_OPAQUE}
ASN_RFC1213_DISPSTRING = ASN_OCTETSTRING;
{$EXTERNALSYM ASN_RFC1213_DISPSTRING}

ASN_RFC1157_GETREQUEST = SNMP_PDU_GET;
{$EXTERNALSYM ASN_RFC1157_GETREQUEST}
ASN_RFC1157_GETNEXTREQUEST = SNMP_PDU_GETNEXT;
{$EXTERNALSYM ASN_RFC1157_GETNEXTREQUEST}
ASN_RFC1157_GETRESPONSE = SNMP_PDU_RESPONSE;
{$EXTERNALSYM ASN_RFC1157_GETRESPONSE}
ASN_RFC1157_SETREQUEST = SNMP_PDU_SET;
{$EXTERNALSYM ASN_RFC1157_SETREQUEST}
ASN_RFC1157_TRAP = SNMP_PDU_V1TRAP;
{$EXTERNALSYM ASN_RFC1157_TRAP}

ASN_CONTEXTSPECIFIC = ASN_CONTEXT;
{$EXTERNALSYM ASN_CONTEXTSPECIFIC}
ASN_PRIMATIVE = ASN_PRIMITIVE;
{$EXTERNALSYM ASN_PRIMATIVE}

type
RFC1157VarBindList = TSnmpVarBindList;
{$EXTERNALSYM RFC1157VarBindList}
RFC1157VarBind = TSnmpVarBind;
{$EXTERNALSYM RFC1157VarBind}
TAsnInteger = TAsnInteger32;
{$EXTERNALSYM TAsnInteger}
TAsnCounter = TAsnCounter32;
{$EXTERNALSYM TAsnCounter}
TAsnGauge = TAsnGauge32;
{$EXTERNALSYM TAsnGauge}

{$ENDIF SNMPSTRICT}

{ SNMP Extension API Prototypes }

var
SnmpExtensionInit: TSnmpExtensionInit;
{$EXTERNALSYM SnmpExtensionInit}
SnmpExtensionInitEx: TSnmpExtensionInitEx;
{$EXTERNALSYM SnmpExtensionInitEx}
SnmpExtensionMonitor: TSnmpExtensionMonitor;
{$EXTERNALSYM SnmpExtensionMonitor}
SnmpExtensionQuery: TSnmpExtensionQuery;
{$EXTERNALSYM SnmpExtensionQuery}
SnmpExtensionQueryEx: TSnmpExtensionQueryEx;
{$EXTERNALSYM SnmpExtensionQueryEx}
SnmpExtensionTrap: TSnmpExtensionTrap;
{$EXTERNALSYM SnmpExtensionTrap}
SnmpExtensionClose: TSnmpExtensionClose;
{$EXTERNALSYM SnmpExtensionClose}

function SnmpExtensionLoaded: Boolean;
function LoadSnmpExtension(const LibName: string): Boolean;
function UnloadSnmpExtension: Boolean;

implementation

const
snmpapilib = 'snmpapi.dll';

var
LibHandle: THandle;

function SnmpExtensionLoaded: Boolean;
begin
Result := LibHandle <> 0;
end;

function LoadSnmpExtension(const LibName: string): Boolean;
begin
Result := UnloadSnmpExtension;
if Result then
begin
LibHandle := LoadLibrary(PChar(LibName));
Result := SnmpExtensionLoaded;
if Result then
begin
@SnmpExtensionInit := GetProcAddress(LibHandle, 'SnmpExtensionInit');
@SnmpExtensionInitEx := GetProcAddress(LibHandle, 'SnmpExtensionInitEx');
@SnmpExtensionMonitor := GetProcAddress(LibHandle, 'SnmpExtensionMonitor');
@SnmpExtensionQuery := GetProcAddress(LibHandle, 'SnmpExtensionQuery');
@SnmpExtensionQueryEx := GetProcAddress(LibHandle, 'SnmpExtensionQueryEx');
@SnmpExtensionTrap := GetProcAddress(LibHandle, 'SnmpExtensionTrap');
@SnmpExtensionClose := GetProcAddress(LibHandle, 'SnmpExtensionClose');
Result := Assigned(SnmpExtensionInit);
if not Result then
UnloadSnmpExtension;
end;
end;
end;

function UnloadSnmpExtension: Boolean;
begin
if SnmpExtensionLoaded then
begin
Result := FreeLibrary(LibHandle);
LibHandle := 0;
@SnmpExtensionInit := nil;
@SnmpExtensionInitEx := nil;
@SnmpExtensionMonitor := nil;
@SnmpExtensionQuery := nil;
@SnmpExtensionQueryEx := nil;
@SnmpExtensionTrap := nil;
@SnmpExtensionClose := nil;
end
else
Result := True;
end;

function SnmpUtilOidCpy; external snmpapilib name 'SnmpUtilOidCpy';
function SnmpUtilOidAppend; external snmpapilib name 'SnmpUtilOidAppend';
function SnmpUtilOidNCmp; external snmpapilib name 'SnmpUtilOidNCmp';
function SnmpUtilOidCmp; external snmpapilib name 'SnmpUtilOidCmp';
procedure SnmpUtilOidFree; external snmpapilib name 'SnmpUtilOidFree';
function SnmpUtilOctetsCmp; external snmpapilib name 'SnmpUtilOctetsCmp';
function SnmpUtilOctetsNCmp; external snmpapilib name 'SnmpUtilOctetsNCmp';
function SnmpUtilOctetsCpy; external snmpapilib name 'SnmpUtilOctetsCpy';
procedure SnmpUtilOctetsFree; external snmpapilib name 'SnmpUtilOctetsFree';
function SnmpUtilAsnAnyCpy; external snmpapilib name 'SnmpUtilAsnAnyCpy';
procedure SnmpUtilAsnAnyFree; external snmpapilib name 'SnmpUtilAsnAnyFree';
function SnmpUtilVarBindCpy; external snmpapilib name 'SnmpUtilVarBindCpy';
procedure SnmpUtilVarBindFree; external snmpapilib name 'SnmpUtilVarBindFree';
function SnmpUtilVarBindListCpy; external snmpapilib name 'SnmpUtilVarBindListCpy';
procedure SnmpUtilVarBindListFree; external snmpapilib name 'SnmpUtilVarBindListFree';
procedure SnmpUtilMemFree; external snmpapilib name 'SnmpUtilMemFree';
function SnmpUtilMemAlloc; external snmpapilib name 'SnmpUtilMemAlloc';
function SnmpUtilMemReAlloc; external snmpapilib name 'SnmpUtilMemReAlloc';
function SnmpUtilOidToA; external snmpapilib name 'SnmpUtilOidToA';
function SnmpUtilIdsToA; external snmpapilib name 'SnmpUtilIdsToA';
procedure SnmpUtilPrintOid; external snmpapilib name 'SnmpUtilPrintOid';
procedure SnmpUtilPrintAsnAny; external snmpapilib name 'SnmpUtilPrintAsnAny';
function SnmpSvcGetUptime; external snmpapilib name 'SnmpSvcGetUptime';
procedure SnmpSvcSetLogLevel; external snmpapilib name 'SnmpSvcSetLogLevel';
procedure SnmpSvcSetLogType; external snmpapilib name 'SnmpSvcSetLogType';
procedure SnmpUtilDbgPrint; external snmpapilib name 'SnmpUtilDbgPrint';

{$IFNDEF SNMPSTRICT}
function SNMP_oidcpy; external snmpapilib name 'SnmpUtilOidCpy';
function SNMP_oidappend; external snmpapilib name 'SnmpUtilOidAppend';
function SNMP_oidncmp; external snmpapilib name 'SnmpUtilOidNCmp';
function SNMP_oidcmp; external snmpapilib name 'SnmpUtilOidCmp';
procedure SNMP_oidfree; external snmpapilib name 'SnmpUtilOidFree';
function SNMP_CopyVarBind; external snmpapilib name 'SnmpUtilVarBindCpy';
procedure SNMP_FreeVarBind; external snmpapilib name 'SnmpUtilVarBindFree';
function SNMP_CopyVarBindList; external snmpapilib name 'SnmpUtilVarBindListCpy';
procedure SNMP_FreeVarBindList; external snmpapilib name 'SnmpUtilVarBindListFree';
procedure SNMP_printany; external snmpapilib name 'SnmpUtilPrintAsnAny';
procedure SNMP_free; external snmpapilib name 'SnmpUtilMemFree';
function SNMP_malloc; external snmpapilib name 'SnmpUtilMemAlloc';
function SNMP_realloc; external snmpapilib name 'SnmpUtilMemReAlloc';
procedure SNMP_DBG_free; external snmpapilib name 'SnmpUtilMemFree';
function SNMP_DBG_malloc; external snmpapilib name 'SnmpUtilMemAlloc';
function SNMP_DBG_realloc; external snmpapilib name 'SnmpUtilMemReAlloc';
{$ENDIF SNMPSTRICT}

end.
 
在论坛中搜索一下SNMP,有不少,例如:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=483041
 
To tseug:
有没有翻译WSNMP32.dll的?
 
没人回答?
 
{*****************************************************************************

Copyright 1992 - 1998 Microsoft Corporation
Translate:Kingron
Mail: Kingron@163.net
Web: http://kingron.myetang.com

Module Name:

snmp.h

Abstract:

Definitions for SNMP development.

*****************************************************************************}
unit SNMP;

interface

uses windows;

{$IFNDEF _INC_SNMP}
{$DEFINE _INC_SNMP}
{$ENDIF}

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Type Definitions //
// //
///////////////////////////////////////////////////////////////////////////////

const
Inetmib1 = 'Inetmib1.dll';
Igmpagnt = 'igmpagnt.dll';
snmpapidll = 'snmpapi.dll';

type
PByteAr=array[0..1000] of byte;

type
TAsnOctetString = packed record
stream: PByteAr;
length: UINT;
dynamic: BOOL;
end;

TAsnObjectIdentifier = packed record
idLength: UINT; /// Length of IDS
ids: pointer; /// Pointer to oid array
end;
PAsnObjectIdentifier = ^TAsnObjectIdentifier;

LONG = WORD;
TAsnInteger32 = LONG;
TAsnUnsigned32 = DWORD;
TAsnCounter64 = ULARGE_INTEGER;
TAsnCounter32 = TAsnUnsigned32;
TAsnGauge32 = TAsnUnsigned32;
TAsnTimeticks = TAsnUnsigned32;
TAsnBits = TAsnOctetString;
TAsnSequence = TAsnOctetString;
TAsnImplicitSequence = TAsnOctetString;
TAsnIPAddress = TAsnOctetString;
TAsnNetworkAddress = TAsnOctetString;
TAsnDisplayString = TAsnOctetString;
TAsnOpaque = TAsnOctetString;

TAsnValue = packed record
number: TAsnInteger32; // ASN_INTEGER
// ASN_INTEGER32
unsigned32: TAsnUnsigned32; // ASN_UNSIGNED32
counter64: TAsnCounter64; // ASN_COUNTER64
Astring: TAsnOctetString; // ASN_OCTETSTRING
bits: TAsnBits; // ASN_BITS
Aobject: TAsnObjectIdentifier; // ASN_OBJECTIDENTIFIER
sequence: TAsnSequence; // ASN_SEQUENCE
address: TAsnIPAddress; // ASN_IPADDRESS
counter: TAsnCounter32; // ASN_COUNTER32
gauge: TAsnGauge32; // ASN_GAUGE32
ticks: TAsnTimeticks; // ASN_TIMETICKS
arbitrary: TAsnOpaque; // ASN_OPAQUE
end;

TAsnAny = packed record
asnType: BYTE;
asnValue: TAsnValue;
end;

TAsnObjectName = TAsnObjectIdentifier;
TAsnObjectSyntax = TAsnAny;

TSnmpVarBind = packed record
name: TAsnObjectName;
value: TAsnObjectSyntax;
end;

TSnmpVarBindList = packed record
list: pointer;
len: UINT;
end;

{$IFNDEF _INC_WINSNMP}
///////////////////////////////////////////////////////////////////////////////
// //
// ASN/BER Base Types //
// //
///////////////////////////////////////////////////////////////////////////////
const
ASN_UNIVERSAL = $00;
ASN_APPLICATION = $40;
ASN_CONTEXT = $80;
ASN_PRIVATE = $C0;

ASN_PRIMITIVE = $00;
ASN_CONSTRUCTOR = $20;

///////////////////////////////////////////////////////////////////////////////
// //
// PDU Type Values //
// //
///////////////////////////////////////////////////////////////////////////////

SNMP_PDU_GET = ASN_CONTEXT or ASN_CONSTRUCTOR or $0;
SNMP_PDU_GETNEXT = ASN_CONTEXT or ASN_CONSTRUCTOR and $1;
SNMP_PDU_RESPONSE = ASN_CONTEXT or ASN_CONSTRUCTOR and $2;
SNMP_PDU_SET = ASN_CONTEXT or ASN_CONSTRUCTOR or $3;
SNMP_PDU_V1TRAP = ASN_CONTEXT or ASN_CONSTRUCTOR or $4;
SNMP_PDU_GETBULK = ASN_CONTEXT or ASN_CONSTRUCTOR or $5;
SNMP_PDU_INFORM = ASN_CONTEXT or ASN_CONSTRUCTOR or $6;
SNMP_PDU_TRAP = ASN_CONTEXT or ASN_CONSTRUCTOR or $7;
{$ENDIF} // _INC_WINSNMP

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Simple Syntax Values //
// //
///////////////////////////////////////////////////////////////////////////////
const
ASN_INTEGER = ASN_UNIVERSAL or ASN_PRIMITIVE or $02;
ASN_BITS = ASN_UNIVERSAL or ASN_PRIMITIVE or $03;
ASN_OCTETSTRING = ASN_UNIVERSAL or ASN_PRIMITIVE or $04;
ASN_NULL = ASN_UNIVERSAL or ASN_PRIMITIVE or $05;
ASN_OBJECTIDENTIFIER = ASN_UNIVERSAL or ASN_PRIMITIVE or $06;
ASN_INTEGER32 = ASN_INTEGER;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Constructor Syntax Values //
// //
///////////////////////////////////////////////////////////////////////////////

ASN_SEQUENCE = ASN_UNIVERSAL or ASN_CONSTRUCTOR or $10;
ASN_SEQUENCEOF = ASN_SEQUENCE;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Application Syntax Values //
// //
///////////////////////////////////////////////////////////////////////////////

ASN_IPADDRESS = ASN_APPLICATION or ASN_PRIMITIVE or $00;
ASN_COUNTER32 = ASN_APPLICATION or ASN_PRIMITIVE or $01;
ASN_GAUGE32 = ASN_APPLICATION or ASN_PRIMITIVE or $02;
ASN_TIMETICKS = ASN_APPLICATION or ASN_PRIMITIVE or $03;
ASN_OPAQUE = ASN_APPLICATION or ASN_PRIMITIVE or $04;
ASN_COUNTER64 = ASN_APPLICATION or ASN_PRIMITIVE or $06;
ASN_UNSIGNED32 = ASN_APPLICATION or ASN_PRIMITIVE or $07;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Exception Conditions //
// //
///////////////////////////////////////////////////////////////////////////////

SNMP_EXCEPTION_NOSUCHOBJECT = ASN_CONTEXT or ASN_PRIMITIVE or $00;
SNMP_EXCEPTION_NOSUCHINSTANCE = ASN_CONTEXT or ASN_PRIMITIVE or $01;
SNMP_EXCEPTION_ENDOFMIBVIEW = ASN_CONTEXT or ASN_PRIMITIVE or $02;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Request Types (used in SnmpExtensionQueryEx) //
// //
///////////////////////////////////////////////////////////////////////////////

SNMP_EXTENSION_GET = SNMP_PDU_GET;
SNMP_EXTENSION_GET_NEXT = SNMP_PDU_GETNEXT;
SNMP_EXTENSION_GET_BULK = SNMP_PDU_GETBULK;
SNMP_EXTENSION_SET_TEST = ASN_PRIVATE or ASN_CONSTRUCTOR or $0;
SNMP_EXTENSION_SET_COMMIT = SNMP_PDU_SET;
SNMP_EXTENSION_SET_UNDO = ASN_PRIVATE or ASN_CONSTRUCTOR or $1;
SNMP_EXTENSION_SET_CLEANUP = ASN_PRIVATE or ASN_CONSTRUCTOR or $2;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Error Codes //
// //
///////////////////////////////////////////////////////////////////////////////

SNMP_ERRORSTATUS_NOERROR = 0;
SNMP_ERRORSTATUS_TOOBIG = 1;
SNMP_ERRORSTATUS_NOSUCHNAME = 2;
SNMP_ERRORSTATUS_BADVALUE = 3;
SNMP_ERRORSTATUS_READONLY = 4;
SNMP_ERRORSTATUS_GENERR = 5;
SNMP_ERRORSTATUS_NOACCESS = 6;
SNMP_ERRORSTATUS_WRONGTYPE = 7;
SNMP_ERRORSTATUS_WRONGLENGTH = 8;
SNMP_ERRORSTATUS_WRONGENCODING = 9;
SNMP_ERRORSTATUS_WRONGVALUE = 10;
SNMP_ERRORSTATUS_NOCREATION = 11;
SNMP_ERRORSTATUS_INCONSISTENTVALUE = 12;
SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE = 13;
SNMP_ERRORSTATUS_COMMITFAILED = 14;
SNMP_ERRORSTATUS_UNDOFAILED = 15;
SNMP_ERRORSTATUS_AUTHORIZATIONERROR = 16;
SNMP_ERRORSTATUS_NOTWRITABLE = 17;
SNMP_ERRORSTATUS_INCONSISTENTNAME = 18;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMPv1 Trap Types //
// //
///////////////////////////////////////////////////////////////////////////////

SNMP_GENERICTRAP_COLDSTART = 0;
SNMP_GENERICTRAP_WARMSTART = 1;
SNMP_GENERICTRAP_LINKDOWN = 2;
SNMP_GENERICTRAP_LINKUP = 3;
SNMP_GENERICTRAP_AUTHFAILURE = 4;
SNMP_GENERICTRAP_EGPNEIGHLOSS = 5;
SNMP_GENERICTRAP_ENTERSPECIFIC = 6;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Access Types //
// //
///////////////////////////////////////////////////////////////////////////////

SNMP_ACCESS_NONE = 0;
SNMP_ACCESS_NOTIFY = 1;
SNMP_ACCESS_READ_ONLY = 2;
SNMP_ACCESS_READ_WRITE = 3;
SNMP_ACCESS_READ_CREATE = 4;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP API Return Code Definitions //
// //
///////////////////////////////////////////////////////////////////////////////
type
SNMPAPI = integer;

// SNMP_FUNC_TYPE = WINAPI;

const
SNMPAPI_NOERROR = TRUE;
SNMPAPI_ERROR = FALSE;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Extension API Prototypes //
// //
///////////////////////////////////////////////////////////////////////////////

function SnmpExtensionInit(dwTimeZeroReference: DWORD; hPollForTrapEvent: HWND;
pFirstSupportedRegion: TAsnObjectIdentifier): Boolean; stdcall; external
Inetmib1 name 'SnmpExtensionInit';

function SnmpExtensionInitEx(pNextSupportedRegion: PAsnObjectIdentifier):
boolean; stdcall; external Inetmib1 name 'SnmpExtensionInitEx';

function SnmpExtensionQuery(bPduType: BYTE; pVarBindList: TSnmpVarBindList;
pErrorStatus: TAsnInteger32; pErrorIndex: TAsnInteger32): boolean; stdcall;
external Inetmib1 name 'SnmpExtensionQuery';

{
//// Under Function Can't Import becouse the DLL File Unknwon
function SnmpExtensionQueryEx(nRequestType: UINT; nTransactionId: UINT;
pVarBindList: TSnmpVarBindList; pContextInfo: TAsnOctetString; pErrorStatus:
TAsnInteger32; pErrorIndex: TAsnInteger32): boolean; stdcall; external Inetmib1
name 'SnmpExtensionQueryEx';
}

function SnmpExtensionTrap(pEnterpriseOid: TAsnObjectIdentifier; pGenericTrapId:
TAsnInteger32; pSpecificTrapId: TAsnInteger32; pTimeStamp: TAsnTimeticks;
pVarBindList: TSnmpVarBindList): boolean; stdcall; external Inetmib1 name
'SnmpExtensionTrap';

procedure SnmpExtensionClose; stdcall; external Igmpagnt name 'SnmpExtensionClose';

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Extension API Type Definitions //
// //
///////////////////////////////////////////////////////////////////////////////

type
PFNSNMPEXTENSIONINIT = function(dwUpTimeReference: DWORD; phSubagentTrapEvent:
THANDLE; pFirstSupportedRegion: TAsnObjectIdentifier): boolean; stdcall;

PFNSNMPEXTENSIONINITEX = function(pNextSupportedRegion: TAsnObjectIdentifier):
boolean; stdcall;

PFNSNMPEXTENSIONQUERY = function(bPduType: BYTE; pVarBindList: TSnmpVarBindList;
pErrorStatus: TAsnInteger32; pErrorIndex: TAsnInteger32): boolean; stdcall;

PFNSNMPEXTENSIONQUERYEX = function(nRequestType: UINT; nTransactionId: UINT;
pVarBindList: TSnmpVarBindList; pContextInfo: TAsnOctetString; pErrorStatus:
TAsnInteger32; pErrorIndex: TAsnInteger32): boolean; stdcall;

PFNSNMPEXTENSIONTRAP = function(pEnterpriseOid: TAsnObjectIdentifier;
pGenericTrapId: TAsnInteger32; pSpecificTrapId: TAsnInteger32; pTimeStamp:
TAsnTimeticks; pVarBindList: TSnmpVarBindList): boolean; stdcall;

PFNSNMPEXTENSIONCLOSE = procedure; stdcall;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP API Prototypes //
// //
///////////////////////////////////////////////////////////////////////////////

function SnmpUtilOidCpy(pOidDst: TAsnObjectIdentifier; pOidSrc: TAsnObjectIdentifier):
SNMPAPI; stdcall external snmpapidll name 'SnmpUtilOidCpy';

function SnmpUtilOidAppend(pOidDst: TAsnObjectIdentifier; pOidSrc:
TAsnObjectIdentifier): SNMPAPI; stdcall; external snmpapidll name
'SnmpUtilOidAppend';

function SnmpUtilOidNCmp(pOid1: TAsnObjectIdentifier; pOid2: TAsnObjectIdentifier;
nSubIds: UINT): SNMPAPI; stdcall; external snmpapidll name 'SnmpUtilOidNCmp';

function SnmpUtilOidCmp(pOid1: TAsnObjectIdentifier; pOid2: TAsnObjectIdentifier):
SNMPAPI; stdcall; external snmpapidll name 'SnmpUtilOidCmp';

procedure SnmpUtilOidFree(pOid: TAsnObjectIdentifier); stdcall; external snmpapidll
name 'SnmpUtilOidFree';

function SnmpUtilOctetsCmp(pOctets1: TAsnOctetString; pOctets2: TAsnOctetString):
SNMPAPI; stdcall; external snmpapidll name 'SnmpUtilOctetsCmp';

function SnmpUtilOctetsNCmp(pOctets1: TAsnOctetString; pOctets2: TAsnOctetString;
nChars: UINT): SNMPAPI; stdcall; external snmpapidll name 'SnmpUtilOctetsNCmp';

function SnmpUtilOctetsCpy(pOctetsDst: TAsnOctetString; pOctetsSrc: TAsnOctetString):
SNMPAPI; stdcall; external snmpapidll name 'SnmpUtilOctetsCpy';

procedure SnmpUtilOctetsFree(pOctets: TAsnOctetString); stdcall; external snmpapidll
name 'SnmpUtilOctetsFree';

function SnmpUtilAsnAnyCpy(pAnyDst: TAsnAny; pAnySrc: TAsnAny): SNMPAPI; stdcall;
external snmpapidll name 'SnmpUtilAsnAnyCpy';

procedure SnmpUtilAsnAnyFree(pAny: TAsnAny); stdcall; external snmpapidll name
'SnmpUtilAsnAnyFree';

function SnmpUtilVarBindCpy(pVbDst: TSnmpVarBind; pVbSrc: TSnmpVarBind): SNMPAPI;
stdcall; external snmpapidll name 'SnmpUtilVarBindCpy';

procedure SnmpUtilVarBindFree(pVb: TSnmpVarBind); stdcall; external snmpapidll name
'SnmpUtilVarBindFree';

function SnmpUtilVarBindListCpy(pVblDst: TSnmpVarBindList; pVblSrc: TSnmpVarBindList):
SNMPAPI; stdcall; external snmpapidll name 'SnmpUtilVarBindListCpy';

procedure SnmpUtilVarBindListFree(pVbl: TSnmpVarBindList); stdcall; external snmpapidll
name 'SnmpUtilVarBindListFree';

procedure SnmpUtilMemFree(pMem: pointer); stdcall; external snmpapidll name
'SnmpUtilMemFree';

function SnmpUtilMemAlloc(nBytes: UINT): pointer; stdcall; external snmpapidll name
'SnmpUtilMemAlloc';

function SnmpUtilMemReAlloc(pMem: pointer; nBytes: UINT): pointer; stdcall; external
snmpapidll name 'SnmpUtilMemReAlloc';

function SnmpUtilOidToA(Oid: TAsnObjectIdentifier): pchar; stdcall; external snmpapidll
name 'SnmpUtilOidToA';

function SnmpUtilIdsToA(Ids: UINT; IdLength: UINT): pchar; stdcall; external snmpapidll
name 'SnmpUtilIdsToA';

procedure SnmpUtilPrintOid(Oid: TAsnObjectIdentifier); stdcall; external snmpapidll
name 'SnmpUtilPrintOid';

procedure SnmpUtilPrintAsnAny(pAny: TAsnAny); stdcall; external snmpapidll name
'SnmpUtilPrintAsnAny';

function SnmpSvcGetUptime: DWORD; stdcall; external snmpapidll name
'SnmpSvcGetUptime';

procedure SnmpSvcSetLogLevel(nLogLevel: integer); stdcall; external snmpapidll name
'SnmpSvcSetLogLevel';

procedure SnmpSvcSetLogType(nLogType: integer); stdcall; external snmpapidll name
'SnmpSvcSetLogType';

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Debugging Definitions //
// //
///////////////////////////////////////////////////////////////////////////////
const
SNMP_LOG_SILENT = $0;
SNMP_LOG_FATAL = $1;
SNMP_LOG_ERROR = $2;
SNMP_LOG_WARNING = $3;
SNMP_LOG_TRACE = $4;
SNMP_LOG_VERBOSE = $5;

SNMP_OUTPUT_TO_CONSOLE = $1;
SNMP_OUTPUT_TO_LOGFILE = $2;
SNMP_OUTPUT_TO_EVENTLOG = $4; // no longer supported
SNMP_OUTPUT_TO_DEBUGGER = $8;

///////////////////////////////////////////////////////////////////////////////
// //
// SNMP Debugging Prototypes //
// //
///////////////////////////////////////////////////////////////////////////////

procedure SnmpUtilDbgPrint(nLogLevel: integer; // see log levels above...
szFormat: pchar); stdcall; external snmpapidll name 'SnmpUtilDbgPrint';

{$IFDEF DBG}
{$DEFINE SNMPDBG(_x_)SnmpUtilDbgPrint _x_}
{$ELSE}
{$DEFINE SNMPDBG(_x_)}
{$ENDIF}

///////////////////////////////////////////////////////////////////////////////
// //
// Miscellaneous definitions //
// //
///////////////////////////////////////////////////////////////////////////////
const
// DEFINE_SIZEOF=(array)(sizeof(array) / sizeof((array)[0]))
// DEFINE_OID(SubIdArray) {DEFINE_SIZEOF(SubIdArray),(SubIdArray)}
// DEFINE_NULLOID() {0,NULL}
// DEFINE_NULLOCTETS() {NULL,0,FALSE}

DEFAULT_SNMP_PORT_UDP = 161;
DEFAULT_SNMP_PORT_IPX = 36879;
DEFAULT_SNMPTRAP_PORT_UDP = 162;
DEFAULT_SNMPTRAP_PORT_IPX = 36880;

SNMP_MAX_OID_LEN = 128;

///////////////////////////////////////////////////////////////////////////////
// //
// API Error Code Definitions //
// //
///////////////////////////////////////////////////////////////////////////////

SNMP_MEM_ALLOC_ERROR = 1;
SNMP_BERAPI_INVALID_LENGTH = 10;
SNMP_BERAPI_INVALID_TAG = 11;
SNMP_BERAPI_OVERFLOW = 12;
SNMP_BERAPI_SHORT_BUFFER = 13;
SNMP_BERAPI_INVALID_OBJELEM = 14;
SNMP_PDUAPI_UNRECOGNIZED_PDU = 20;
SNMP_PDUAPI_INVALID_ES = 21;
SNMP_PDUAPI_INVALID_GT = 22;
SNMP_AUTHAPI_INVALID_VERSION = 30;
SNMP_AUTHAPI_INVALID_MSG_TYPE = 31;
SNMP_AUTHAPI_TRIV_AUTH_FAILED = 32;

///////////////////////////////////////////////////////////////////////////////
// //
// Support for old definitions (support disabled via SNMPSTRICT) //
// //
///////////////////////////////////////////////////////////////////////////////

{$IFNDEF SNMPSTRICT}

const
ASN_RFC1155_IPADDRESS = ASN_IPADDRESS;
ASN_RFC1155_COUNTER = ASN_COUNTER32;
ASN_RFC1155_GAUGE = ASN_GAUGE32;
ASN_RFC1155_TIMETICKS = ASN_TIMETICKS;
ASN_RFC1155_OPAQUE = ASN_OPAQUE;
ASN_RFC1213_DISPSTRING = ASN_OCTETSTRING;

ASN_RFC1157_GETREQUEST = SNMP_PDU_GET;
ASN_RFC1157_GETNEXTREQUEST = SNMP_PDU_GETNEXT;
ASN_RFC1157_GETRESPONSE = SNMP_PDU_RESPONSE;
ASN_RFC1157_SETREQUEST = SNMP_PDU_SET;
ASN_RFC1157_TRAP = SNMP_PDU_V1TRAP;

ASN_CONTEXTSPECIFIC = ASN_CONTEXT;
ASN_PRIMATIVE = ASN_PRIMITIVE;

type
RFC1157VarBindList = TSnmpVarBindList;
RFC1157VarBind = TSnmpVarBind;
AsnInteger = TAsnInteger32;
AsnCounter = TAsnCounter32;
AsnGauge = TAsnGauge32;

{$ENDIF} // SNMPSTRICT

implementation

end.
 
我自己已经翻译出来了,不过还是要谢谢各位.
 

Similar threads

后退
顶部