Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef _INC_WINSNMP
      7 #define _INC_WINSNMP
      8 
      9 #ifndef _INC_WINDOWS
     10 #include <windows.h>
     11 #define _INC_WINDOWS
     12 #endif
     13 
     14 #include <limits.h>
     15 
     16 #ifdef __cplusplus
     17 extern "C" {
     18 #endif
     19 
     20   typedef HANDLE HSNMP_SESSION,*LPHSNMP_SESSION;
     21   typedef HANDLE HSNMP_ENTITY,*LPHSNMP_ENTITY;
     22   typedef HANDLE HSNMP_CONTEXT,*LPHSNMP_CONTEXT;
     23   typedef HANDLE HSNMP_PDU,*LPHSNMP_PDU;
     24   typedef HANDLE HSNMP_VBL,*LPHSNMP_VBL;
     25   typedef unsigned char smiBYTE,*smiLPBYTE;
     26 
     27 #if ULONG_MAX==4294967295U
     28   typedef signed __LONG32 smiINT,*smiLPINT;
     29   typedef smiINT smiINT32,*smiLPINT32;
     30   typedef unsigned __LONG32 smiUINT32,*smiLPUINT32;
     31 #elif UINT_MAX==4294967295U
     32   typedef int smiINT,*smiLPINT;
     33   typedef smiINT smiINT32,*smiLPINT32;
     34   typedef unsigned int smiUINT32,*smiLPUINT32;
     35 #else
     36 #error Can not define smiINT and smiUINT
     37 #endif
     38 
     39   typedef struct {
     40     smiUINT32 len;
     41     smiLPBYTE ptr;
     42   } smiOCTETS,*smiLPOCTETS;
     43 
     44   typedef const smiOCTETS *smiLPCOCTETS;
     45   typedef smiOCTETS smiBITS,*smiLPBITS;
     46 
     47   typedef struct {
     48     smiUINT32 len;
     49     smiLPUINT32 ptr;
     50   } smiOID,*smiLPOID;
     51 
     52   typedef const smiOID *smiLPCOID;
     53   typedef smiOCTETS smiIPADDR,*smiLPIPADDR;
     54   typedef smiUINT32 smiCNTR32,*smiLPCNTR32;
     55   typedef smiUINT32 smiGAUGE32,*smiLPGAUGE32;
     56   typedef smiUINT32 smiTIMETICKS,*smiLPTIMETICKS;
     57   typedef smiOCTETS smiOPAQUE,*smiLPOPAQUE;
     58   typedef smiOCTETS smiNSAPADDR,*smiLPNSAPADDR;
     59 
     60   typedef struct {
     61     smiUINT32 hipart;
     62     smiUINT32 lopart;
     63   } smiCNTR64,*smiLPCNTR64;
     64 
     65 #define ASN_UNIVERSAL (0x00)
     66 #define ASN_APPLICATION (0x40)
     67 #define ASN_CONTEXT (0x80)
     68 #define ASN_PRIVATE (0xC0)
     69 #define ASN_PRIMITIVE (0x00)
     70 #define ASN_CONSTRUCTOR (0x20)
     71 
     72 #define SNMP_SYNTAX_SEQUENCE (ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10)
     73 #define SNMP_SYNTAX_INT (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x02)
     74 #define SNMP_SYNTAX_BITS (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
     75 #define SNMP_SYNTAX_OCTETS (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04)
     76 #define SNMP_SYNTAX_NULL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x05)
     77 #define SNMP_SYNTAX_OID (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x06)
     78 #define SNMP_SYNTAX_INT32 SNMP_SYNTAX_INT
     79 #define SNMP_SYNTAX_IPADDR (ASN_APPLICATION | ASN_PRIMITIVE | 0x00)
     80 #define SNMP_SYNTAX_CNTR32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x01)
     81 #define SNMP_SYNTAX_GAUGE32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x02)
     82 #define SNMP_SYNTAX_TIMETICKS (ASN_APPLICATION | ASN_PRIMITIVE | 0x03)
     83 #define SNMP_SYNTAX_OPAQUE (ASN_APPLICATION | ASN_PRIMITIVE | 0x04)
     84 #define SNMP_SYNTAX_NSAPADDR (ASN_APPLICATION | ASN_PRIMITIVE | 0x05)
     85 #define SNMP_SYNTAX_CNTR64 (ASN_APPLICATION | ASN_PRIMITIVE | 0x06)
     86 #define SNMP_SYNTAX_UINT32 (ASN_APPLICATION | ASN_PRIMITIVE | 0x07)
     87 #define SNMP_SYNTAX_UNSIGNED32 SNMP_SYNTAX_GAUGE32
     88 #define SNMP_SYNTAX_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x00)
     89 #define SNMP_SYNTAX_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x01)
     90 #define SNMP_SYNTAX_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x02)
     91 
     92   typedef struct {
     93     smiUINT32 syntax;
     94     union {
     95       smiINT sNumber;
     96       smiUINT32 uNumber;
     97       smiCNTR64 hNumber;
     98       smiOCTETS string;
     99       smiOID oid;
    100       smiBYTE empty;
    101     } value;
    102   } smiVALUE,*smiLPVALUE;
    103   typedef const smiVALUE *smiLPCVALUE;
    104 
    105 #define MAXOBJIDSIZE 128
    106 #define MAXOBJIDSTRSIZE 1408
    107 
    108 #define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
    109 #define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
    110 #define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
    111 #define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
    112 
    113 #define SNMP_PDU_V1TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
    114 #define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
    115 #define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
    116 #define SNMP_PDU_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
    117 
    118 #define SNMP_TRAP_COLDSTART 0
    119 #define SNMP_TRAP_WARMSTART 1
    120 #define SNMP_TRAP_LINKDOWN 2
    121 #define SNMP_TRAP_LINKUP 3
    122 #define SNMP_TRAP_AUTHFAIL 4
    123 #define SNMP_TRAP_EGPNEIGHBORLOSS 5
    124 #define SNMP_TRAP_ENTERPRISESPECIFIC 6
    125 
    126 #define SNMP_ERROR_NOERROR 0
    127 #define SNMP_ERROR_TOOBIG 1
    128 #define SNMP_ERROR_NOSUCHNAME 2
    129 #define SNMP_ERROR_BADVALUE 3
    130 #define SNMP_ERROR_READONLY 4
    131 #define SNMP_ERROR_GENERR 5
    132 
    133 #define SNMP_ERROR_NOACCESS 6
    134 #define SNMP_ERROR_WRONGTYPE 7
    135 #define SNMP_ERROR_WRONGLENGTH 8
    136 #define SNMP_ERROR_WRONGENCODING 9
    137 #define SNMP_ERROR_WRONGVALUE 10
    138 #define SNMP_ERROR_NOCREATION 11
    139 #define SNMP_ERROR_INCONSISTENTVALUE 12
    140 #define SNMP_ERROR_RESOURCEUNAVAILABLE 13
    141 #define SNMP_ERROR_COMMITFAILED 14
    142 #define SNMP_ERROR_UNDOFAILED 15
    143 #define SNMP_ERROR_AUTHORIZATIONERROR 16
    144 #define SNMP_ERROR_NOTWRITABLE 17
    145 #define SNMP_ERROR_INCONSISTENTNAME 18
    146 
    147 #define SNMPAPI_TRANSLATED 0
    148 #define SNMPAPI_UNTRANSLATED_V1 1
    149 #define SNMPAPI_UNTRANSLATED_V2 2
    150 
    151 #define SNMPAPI_NO_SUPPORT 0
    152 #define SNMPAPI_V1_SUPPORT 1
    153 #define SNMPAPI_V2_SUPPORT 2
    154 #define SNMPAPI_M2M_SUPPORT 3
    155 
    156 #define SNMPAPI_OFF 0
    157 #define SNMPAPI_ON 1
    158 
    159   typedef smiUINT32 SNMPAPI_STATUS;
    160 #define SNMPAPI_FAILURE 0
    161 #define SNMPAPI_SUCCESS 1
    162 
    163 #define SNMPAPI_ALLOC_ERROR 2
    164 #define SNMPAPI_CONTEXT_INVALID 3
    165 #define SNMPAPI_CONTEXT_UNKNOWN 4
    166 #define SNMPAPI_ENTITY_INVALID 5
    167 #define SNMPAPI_ENTITY_UNKNOWN 6
    168 #define SNMPAPI_INDEX_INVALID 7
    169 #define SNMPAPI_NOOP 8
    170 #define SNMPAPI_OID_INVALID 9
    171 #define SNMPAPI_OPERATION_INVALID 10
    172 #define SNMPAPI_OUTPUT_TRUNCATED 11
    173 #define SNMPAPI_PDU_INVALID 12
    174 #define SNMPAPI_SESSION_INVALID 13
    175 #define SNMPAPI_SYNTAX_INVALID 14
    176 #define SNMPAPI_VBL_INVALID 15
    177 #define SNMPAPI_MODE_INVALID 16
    178 #define SNMPAPI_SIZE_INVALID 17
    179 #define SNMPAPI_NOT_INITIALIZED 18
    180 #define SNMPAPI_MESSAGE_INVALID 19
    181 #define SNMPAPI_HWND_INVALID 20
    182 #define SNMPAPI_OTHER_ERROR 99
    183 
    184 #define SNMPAPI_TL_NOT_INITIALIZED 100
    185 #define SNMPAPI_TL_NOT_SUPPORTED 101
    186 #define SNMPAPI_TL_NOT_AVAILABLE 102
    187 #define SNMPAPI_TL_RESOURCE_ERROR 103
    188 #define SNMPAPI_TL_UNDELIVERABLE 104
    189 #define SNMPAPI_TL_SRC_INVALID 105
    190 #define SNMPAPI_TL_INVALID_PARAM 106
    191 #define SNMPAPI_TL_IN_USE 107
    192 #define SNMPAPI_TL_TIMEOUT 108
    193 #define SNMPAPI_TL_PDU_TOO_BIG 109
    194 #define SNMPAPI_TL_OTHER 199
    195 
    196 #ifndef IN
    197 #define IN
    198 #endif
    199 
    200 #ifndef OUT
    201 #define OUT
    202 #endif
    203 
    204 #define SNMPAPI_CALL WINAPI
    205 
    206 #define MAXVENDORINFO 32
    207   typedef struct {
    208     char vendorName[MAXVENDORINFO*2];
    209     char vendorContact[MAXVENDORINFO*2];
    210     char vendorVersionId[MAXVENDORINFO];
    211     char vendorVersionDate[MAXVENDORINFO];
    212     smiUINT32 vendorEnterprise;
    213   } smiVENDORINFO,*smiLPVENDORINFO;
    214 
    215   typedef SNMPAPI_STATUS (CALLBACK *SNMPAPI_CALLBACK)(HSNMP_SESSION hSession,HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam,LPVOID lpClientData);
    216 
    217   SNMPAPI_STATUS WINAPI SnmpGetTranslateMode(smiLPUINT32 nTranslateMode);
    218   SNMPAPI_STATUS WINAPI SnmpSetTranslateMode(smiUINT32 nTranslateMode);
    219   SNMPAPI_STATUS WINAPI SnmpGetRetransmitMode(smiLPUINT32 nRetransmitMode);
    220   SNMPAPI_STATUS WINAPI SnmpSetRetransmitMode(smiUINT32 nRetransmitMode);
    221   SNMPAPI_STATUS WINAPI SnmpGetTimeout(HSNMP_ENTITY hEntity,smiLPTIMETICKS nPolicyTimeout,smiLPTIMETICKS nActualTimeout);
    222   SNMPAPI_STATUS WINAPI SnmpSetTimeout(HSNMP_ENTITY hEntity,smiTIMETICKS nPolicyTimeout);
    223   SNMPAPI_STATUS WINAPI SnmpGetRetry(HSNMP_ENTITY hEntity,smiLPUINT32 nPolicyRetry,smiLPUINT32 nActualRetry);
    224   SNMPAPI_STATUS WINAPI SnmpSetRetry(HSNMP_ENTITY hEntity,smiUINT32 nPolicyRetry);
    225   SNMPAPI_STATUS WINAPI SnmpGetVendorInfo(smiLPVENDORINFO vendorInfo);
    226   SNMPAPI_STATUS WINAPI SnmpStartup(smiLPUINT32 nMajorVersion,smiLPUINT32 nMinorVersion,smiLPUINT32 nLevel,smiLPUINT32 nTranslateMode,smiLPUINT32 nRetransmitMode);
    227   SNMPAPI_STATUS WINAPI SnmpCleanup(void);
    228   HSNMP_SESSION WINAPI SnmpOpen(HWND hWnd,UINT wMsg);
    229   SNMPAPI_STATUS WINAPI SnmpClose(HSNMP_SESSION session);
    230   SNMPAPI_STATUS WINAPI SnmpSendMsg(HSNMP_SESSION session,HSNMP_ENTITY srcEntity,HSNMP_ENTITY dstEntity,HSNMP_CONTEXT context,HSNMP_PDU PDU);
    231   SNMPAPI_STATUS WINAPI SnmpRecvMsg(HSNMP_SESSION session,LPHSNMP_ENTITY srcEntity,LPHSNMP_ENTITY dstEntity,LPHSNMP_CONTEXT context,LPHSNMP_PDU PDU);
    232   SNMPAPI_STATUS WINAPI SnmpRegister(HSNMP_SESSION session,HSNMP_ENTITY srcEntity,HSNMP_ENTITY dstEntity,HSNMP_CONTEXT context,smiLPCOID notification,smiUINT32 state);
    233   HSNMP_SESSION WINAPI SnmpCreateSession(HWND hWnd,UINT wMsg,SNMPAPI_CALLBACK fCallBack,LPVOID lpClientData);
    234   SNMPAPI_STATUS WINAPI SnmpListen(HSNMP_ENTITY hEntity,SNMPAPI_STATUS lStatus);
    235   SNMPAPI_STATUS WINAPI SnmpCancelMsg(HSNMP_SESSION session,smiINT32 reqId);
    236   SNMPAPI_STATUS WINAPI SnmpStartupEx(smiLPUINT32 nMajorVersion,smiLPUINT32 nMinorVersion,smiLPUINT32 nLevel,smiLPUINT32 nTranslateMode,smiLPUINT32 nRetransmitMode);
    237 
    238   typedef SNMPAPI_STATUS (WINAPI *PFNSNMPSTARTUPEX)(smiLPUINT32,smiLPUINT32,smiLPUINT32,smiLPUINT32,smiLPUINT32);
    239 
    240   SNMPAPI_STATUS WINAPI SnmpCleanupEx(void);
    241 
    242   typedef SNMPAPI_STATUS (WINAPI *PFNSNMPCLEANUPEX)(void);
    243 
    244   HSNMP_ENTITY WINAPI SnmpStrToEntity(HSNMP_SESSION session,LPCSTR string);
    245   SNMPAPI_STATUS WINAPI SnmpEntityToStr(HSNMP_ENTITY entity,smiUINT32 size,LPSTR string);
    246   SNMPAPI_STATUS WINAPI SnmpFreeEntity(HSNMP_ENTITY entity);
    247   HSNMP_CONTEXT WINAPI SnmpStrToContext(HSNMP_SESSION session,smiLPCOCTETS string);
    248   SNMPAPI_STATUS WINAPI SnmpContextToStr(HSNMP_CONTEXT context,smiLPOCTETS string);
    249   SNMPAPI_STATUS WINAPI SnmpFreeContext(HSNMP_CONTEXT context);
    250   SNMPAPI_STATUS WINAPI SnmpSetPort(HSNMP_ENTITY hEntity,UINT nPort);
    251   HSNMP_PDU WINAPI SnmpCreatePdu(HSNMP_SESSION session,smiINT PDU_type,smiINT32 request_id,smiINT error_status,smiINT error_index,HSNMP_VBL varbindlist);
    252   SNMPAPI_STATUS WINAPI SnmpGetPduData(HSNMP_PDU PDU,smiLPINT PDU_type,smiLPINT32 request_id,smiLPINT error_status,smiLPINT error_index,LPHSNMP_VBL varbindlist);
    253   SNMPAPI_STATUS WINAPI SnmpSetPduData(HSNMP_PDU PDU,const smiINT *PDU_type,const smiINT32 *request_id,const smiINT *non_repeaters,const smiINT *max_repetitions,const HSNMP_VBL *varbindlist);
    254   HSNMP_PDU WINAPI SnmpDuplicatePdu(HSNMP_SESSION session,HSNMP_PDU PDU);
    255   SNMPAPI_STATUS WINAPI SnmpFreePdu(HSNMP_PDU PDU);
    256   HSNMP_VBL WINAPI SnmpCreateVbl(HSNMP_SESSION session,smiLPCOID name,smiLPCVALUE value);
    257   HSNMP_VBL WINAPI SnmpDuplicateVbl(HSNMP_SESSION session,HSNMP_VBL vbl);
    258   SNMPAPI_STATUS WINAPI SnmpFreeVbl(HSNMP_VBL vbl);
    259   SNMPAPI_STATUS WINAPI SnmpCountVbl(HSNMP_VBL vbl);
    260   SNMPAPI_STATUS WINAPI SnmpGetVb(HSNMP_VBL vbl,smiUINT32 index,smiLPOID name,smiLPVALUE value);
    261   SNMPAPI_STATUS WINAPI SnmpSetVb(HSNMP_VBL vbl,smiUINT32 index,smiLPCOID name,smiLPCVALUE value);
    262   SNMPAPI_STATUS WINAPI SnmpDeleteVb(HSNMP_VBL vbl,smiUINT32 index);
    263   SNMPAPI_STATUS WINAPI SnmpGetLastError(HSNMP_SESSION session);
    264   SNMPAPI_STATUS WINAPI SnmpStrToOid(LPCSTR string,smiLPOID dstOID);
    265   SNMPAPI_STATUS WINAPI SnmpOidToStr(smiLPCOID srcOID,smiUINT32 size,LPSTR string);
    266   SNMPAPI_STATUS WINAPI SnmpOidCopy(smiLPCOID srcOID,smiLPOID dstOID);
    267   SNMPAPI_STATUS WINAPI SnmpOidCompare(smiLPCOID xOID,smiLPCOID yOID,smiUINT32 maxlen,smiLPINT result);
    268   SNMPAPI_STATUS WINAPI SnmpEncodeMsg(HSNMP_SESSION session,HSNMP_ENTITY srcEntity,HSNMP_ENTITY dstEntity,HSNMP_CONTEXT context,HSNMP_PDU pdu,smiLPOCTETS msgBufDesc);
    269   SNMPAPI_STATUS WINAPI SnmpDecodeMsg(HSNMP_SESSION session,LPHSNMP_ENTITY srcEntity,LPHSNMP_ENTITY dstEntity,LPHSNMP_CONTEXT context,LPHSNMP_PDU pdu,smiLPCOCTETS msgBufDesc);
    270   SNMPAPI_STATUS WINAPI SnmpFreeDescriptor(smiUINT32 syntax,smiLPOPAQUE descriptor);
    271 
    272 #ifdef __cplusplus
    273 }
    274 #endif
    275 
    276 #endif
    277