' ########################################################################################
' Microsoft Windows
' File: MgmtAPI.inc
' Contents: Definitions for SNMP Management API Development
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_MgmtAPI_PBI)
#DEFINE PBX_MgmtAPI_PBI
%EQUATE `MGMTAPI_INC = 1
'///////////////////////////////////////////////////////////////////////////////
'// //
'// Additional header files //
'// //
'///////////////////////////////////////////////////////////////////////////////
#INCLUDE ONCE "Legacy/System/Snmp.inc"
#INCLUDE ONCE "Legacy/Platform/WinSock.inc"
'///////////////////////////////////////////////////////////////////////////////
'// //
'// MGMT API error code definitions //
'// //
'///////////////////////////////////////////////////////////////////////////////
%EQUATE `SNMP_MGMTAPI_TIMEOUT = 40
%EQUATE `SNMP_MGMTAPI_SELECT_FDERRORS = 41
%EQUATE `SNMP_MGMTAPI_TRAP_ERRORS = 42
%EQUATE `SNMP_MGMTAPI_TRAP_DUPINIT = 43
%EQUATE `SNMP_MGMTAPI_NOTRAPS = 44
%EQUATE `SNMP_MGMTAPI_AGAIN = 45
%EQUATE `SNMP_MGMTAPI_INVALID_CTL = 46
%EQUATE `SNMP_MGMTAPI_INVALID_SESSION = 47
%EQUATE `SNMP_MGMTAPI_INVALID_BUFFER = 48
'///////////////////////////////////////////////////////////////////////////////
'// //
'// MGMT API control codes
'// //
'///////////////////////////////////////////////////////////////////////////////
%EQUATE `MGMCTL_SETAGENTPORT = &H01
'///////////////////////////////////////////////////////////////////////////////
'// //
'// MGMT API type definitions //
'// //
'///////////////////////////////////////////////////////////////////////////////
'typedef PVOID LPSNMP_MGR_SESSION;
'///////////////////////////////////////////////////////////////////////////////
'// //
'// MGMT API prototypes //
'// //
'///////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION SnmpMgrOpen LIB "mgmtapi.dll" ALIAS "SnmpMgrOpen" ( BYREF lpAgentAddress AS ASCIIZ , BYREF lpAgentCommunity AS ASCIIZ , BYVAL nTimeOut AS LONG , BYVAL nRetries AS LONG ) AS QUAD ' LPSNMP_MGR_SESSION
DECLARE FUNCTION SnmpMgrCtl LIB "mgmtapi.dll" ALIAS "SnmpMgrCtl" ( BYVAL session AS QUAD , BYVAL dwCtlCode AS QUAD , BYVAL lpvInBuffer AS QUAD , BYVAL cbInBuffer AS QUAD , BYREF lpvOUTBuffer AS ANY , BYVAL cbOUTBuffer AS QUAD , BYREF lpcbBytesReturned AS QUAD ) AS LONG
DECLARE FUNCTION SnmpMgrClose LIB "mgmtapi.dll" ALIAS "SnmpMgrClose" ( BYVAL session AS QUAD
 ) AS LONG
DECLARE FUNCTION SnmpMgrRequest LIB "mgmtapi.dll" ALIAS "SnmpMgrRequest" ( BYVAL session AS DWORD
 , BYVAL requestType AS BYTE
 , BYREF variableBindings AS SnmpVarBindList
 , BYREF errorStatus AS LONG
 , BYREF errorIndex AS LONG
 ) AS LONG ' SNMPAPI
DECLARE FUNCTION SnmpMgrStrToOid LIB "mgmtapi.dll" ALIAS "SnmpMgrStrToOid" ( BYREF string AS ASCIIZ , BYREF oid AS AsnObjectIdentifier ) AS LONG
' Note: The 2nd parameter should be BYREF ASCIIZ PTR, but it has been declared
' as DWORD because PowerBASIC doesn't allow byref pointer variables.
DECLARE FUNCTION SnmpMgrOidToStr LIB "mgmtapi.dll" ALIAS "SnmpMgrOidToStr" ( BYREF oid AS AsnObjectIdentifier , BYREF string AS QUAD ) AS LONG
DECLARE FUNCTION SnmpMgrTrapListen LIB "mgmtapi.dll" ALIAS "SnmpMgrTrapListen" ( BYREF phTrapAvailable AS QUAD
 ) AS LONG
DECLARE FUNCTION SnmpMgrGetTrap LIB "mgmtapi.dll" ALIAS "SnmpMgrGetTrap" ( BYREF enterprise AS AsnObjectIdentifier
 , BYREF IPAddress AS AsnOctetString
 , BYREF genericTrap AS LONG
 , BYREF specificTrap AS LONG
 , BYREF timeStamp AS DWORD
 , BYREF variableBindings AS SnmpVarBindList
 ) AS LONG
DECLARE FUNCTION SnmpMgrGetTrapEx LIB "mgmtapi.dll" ALIAS "SnmpMgrGetTrapEx" ( BYREF enterprise AS AsnObjectIdentifier
 , BYREF agentAddress AS AsnOctetString
 , BYREF sourceAddress AS AsnOctetString
 , BYREF genericTrap AS LONG
 , BYREF specificTrap AS LONG
 , BYREF community AS AsnOctetString
 , BYREF timeStamp AS DWORD
 , BYREF variableBindings AS SnmpVarBindList
 ) AS LONG
#ENDIF
