winsnmp.h 12 KB

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