home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / win32 / Snmp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-08  |  16.6 KB  |  433 lines

  1. /*++
  2.  
  3. Copyright (C) 1992-1996 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     snmp.h
  8.  
  9. Abstract:
  10.  
  11.     Definitions for SNMP Extension Agent development.
  12.  
  13. --*/
  14.  
  15. #ifndef _INC_SNMP
  16. #define _INC_SNMP
  17.  
  18. ///////////////////////////////////////////////////////////////////////////////
  19. //                                                                           //
  20. // Additional header files                                                   //
  21. //                                                                           //
  22. ///////////////////////////////////////////////////////////////////////////////
  23.  
  24. #include <windows.h>
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30. ///////////////////////////////////////////////////////////////////////////////
  31. //                                                                           //
  32. // SNMP API return type definitions                                          //
  33. //                                                                           //
  34. ///////////////////////////////////////////////////////////////////////////////
  35.  
  36. #define SNMPAPI                         INT
  37. #define SNMP_FUNC_TYPE                  WINAPI
  38.  
  39. ///////////////////////////////////////////////////////////////////////////////
  40. //                                                                           //
  41. // SNMP API return code definitions                                          //
  42. //                                                                           //
  43. ///////////////////////////////////////////////////////////////////////////////
  44.  
  45. #define SNMPAPI_NOERROR                 TRUE
  46. #define SNMPAPI_ERROR                   FALSE
  47.  
  48. ///////////////////////////////////////////////////////////////////////////////
  49. //                                                                           //
  50. // SNMP API error code definitions                                           //
  51. //                                                                           //
  52. ///////////////////////////////////////////////////////////////////////////////
  53.  
  54. #define SNMP_MEM_ALLOC_ERROR            1
  55.  
  56. ///////////////////////////////////////////////////////////////////////////////
  57. //                                                                           //
  58. // BER API error code definitions                                            //
  59. //                                                                           //
  60. ///////////////////////////////////////////////////////////////////////////////
  61.  
  62. #define SNMP_BERAPI_INVALID_LENGTH      10
  63. #define SNMP_BERAPI_INVALID_TAG         11
  64. #define SNMP_BERAPI_OVERFLOW            12
  65. #define SNMP_BERAPI_SHORT_BUFFER        13
  66. #define SNMP_BERAPI_INVALID_OBJELEM     14
  67.  
  68. ///////////////////////////////////////////////////////////////////////////////
  69. //                                                                           //
  70. // PDU API error code definitions                                            //
  71. //                                                                           //
  72. ///////////////////////////////////////////////////////////////////////////////
  73.  
  74. #define SNMP_PDUAPI_UNRECOGNIZED_PDU    20
  75. #define SNMP_PDUAPI_INVALID_ES          21
  76. #define SNMP_PDUAPI_INVALID_GT          22
  77.  
  78. ///////////////////////////////////////////////////////////////////////////////
  79. //                                                                           //
  80. // AUTH API error code definitions                                           //
  81. //                                                                           //
  82. ///////////////////////////////////////////////////////////////////////////////
  83.  
  84. #define SNMP_AUTHAPI_INVALID_VERSION    30
  85. #define SNMP_AUTHAPI_INVALID_MSG_TYPE   31
  86. #define SNMP_AUTHAPI_TRIV_AUTH_FAILED   32
  87.  
  88. ///////////////////////////////////////////////////////////////////////////////
  89. //                                                                           //
  90. // SNMP PDU error status definitions                                         //
  91. //                                                                           //
  92. ///////////////////////////////////////////////////////////////////////////////
  93.  
  94. #define SNMP_ERRORSTATUS_NOERROR        0
  95. #define SNMP_ERRORSTATUS_TOOBIG         1
  96. #define SNMP_ERRORSTATUS_NOSUCHNAME     2
  97. #define SNMP_ERRORSTATUS_BADVALUE       3
  98. #define SNMP_ERRORSTATUS_READONLY       4
  99. #define SNMP_ERRORSTATUS_GENERR         5
  100.  
  101. ///////////////////////////////////////////////////////////////////////////////
  102. //                                                                           //
  103. // SNMP PDU generic trap definitions                                         //
  104. //                                                                           //
  105. ///////////////////////////////////////////////////////////////////////////////
  106.  
  107. #define SNMP_GENERICTRAP_COLDSTART      0
  108. #define SNMP_GENERICTRAP_WARMSTART      1
  109. #define SNMP_GENERICTRAP_LINKDOWN       2
  110. #define SNMP_GENERICTRAP_LINKUP         3
  111. #define SNMP_GENERICTRAP_AUTHFAILURE    4
  112. #define SNMP_GENERICTRAP_EGPNEIGHLOSS   5
  113. #define SNMP_GENERICTRAP_ENTERSPECIFIC  6
  114.  
  115. ///////////////////////////////////////////////////////////////////////////////
  116. //                                                                           //
  117. // BER encoding definitions                                                  //
  118. //                                                                           //
  119. ///////////////////////////////////////////////////////////////////////////////
  120.  
  121. #define ASN_UNIVERSAL                   0x00
  122. #define ASN_APPLICATION                 0x40
  123. #define ASN_CONTEXTSPECIFIC             0x80
  124. #define ASN_PRIVATE                     0xC0
  125.  
  126. #define ASN_PRIMATIVE                   0x00
  127. #define ASN_CONSTRUCTOR                 0x20
  128.  
  129. //
  130. // For BER tags with a number ranging from 0 to 30 (inclusive), the
  131. // identifier octets consists of a single octet encoded as follows:
  132. //
  133. //   7 6 5 4 3 2 1 0
  134. //  +---+-+---------+
  135. //  |Cls|P| Tag Num |
  136. //  +---+-+---------+
  137. //
  138. //  where
  139. //
  140. //      Cls - is the class of the tag
  141. //
  142. //          00 - universal
  143. //          01 - application
  144. //          10 - context-specific
  145. //          11 - private
  146. //
  147. //      P - indicates whether encoding is primitive
  148. //
  149. //           0 - primitive
  150. //           1 - constructed
  151. //
  152. //      Tag Num - is the number of the tag
  153. //
  154.  
  155. ///////////////////////////////////////////////////////////////////////////////
  156. //                                                                           //
  157. // ASN.1 simple types                                                        //
  158. //                                                                           //
  159. ///////////////////////////////////////////////////////////////////////////////
  160.  
  161. #define ASN_INTEGER                (ASN_UNIVERSAL|ASN_PRIMATIVE|0x02)
  162. #define ASN_OCTETSTRING            (ASN_UNIVERSAL|ASN_PRIMATIVE|0x04)
  163. #define ASN_NULL                   (ASN_UNIVERSAL|ASN_PRIMATIVE|0x05)
  164. #define ASN_OBJECTIDENTIFIER       (ASN_UNIVERSAL|ASN_PRIMATIVE|0x06)
  165.  
  166. ///////////////////////////////////////////////////////////////////////////////
  167. //                                                                           //
  168. // ASN.1 constructor types                                                   //
  169. //                                                                           //
  170. ///////////////////////////////////////////////////////////////////////////////
  171.  
  172. #define ASN_SEQUENCE               (ASN_UNIVERSAL|ASN_CONSTRUCTOR|0x10)
  173. #define ASN_SEQUENCEOF             ASN_SEQUENCE
  174.  
  175. ///////////////////////////////////////////////////////////////////////////////
  176. //                                                                           //
  177. // ASN.1 application specific primatives                                     //
  178. //                                                                           //
  179. ///////////////////////////////////////////////////////////////////////////////
  180.  
  181. #define ASN_RFC1155_IPADDRESS      (ASN_APPLICATION|ASN_PRIMATIVE|0x00)
  182. #define ASN_RFC1155_COUNTER        (ASN_APPLICATION|ASN_PRIMATIVE|0x01)
  183. #define ASN_RFC1155_GAUGE          (ASN_APPLICATION|ASN_PRIMATIVE|0x02)
  184. #define ASN_RFC1155_TIMETICKS      (ASN_APPLICATION|ASN_PRIMATIVE|0x03)
  185. #define ASN_RFC1155_OPAQUE         (ASN_APPLICATION|ASN_PRIMATIVE|0x04)
  186. #define ASN_RFC1213_DISPSTRING     ASN_OCTETSTRING
  187.  
  188. ///////////////////////////////////////////////////////////////////////////////
  189. //                                                                           //
  190. // ASN.1 application specific constructors                                   //
  191. //                                                                           //
  192. ///////////////////////////////////////////////////////////////////////////////
  193.  
  194. #define ASN_RFC1157_GETREQUEST     (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x00)
  195. #define ASN_RFC1157_GETNEXTREQUEST (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x01)
  196. #define ASN_RFC1157_GETRESPONSE    (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x02)
  197. #define ASN_RFC1157_SETREQUEST     (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x03)
  198. #define ASN_RFC1157_TRAP           (ASN_CONTEXTSPECIFIC|ASN_CONSTRUCTOR|0x04)
  199.  
  200. ///////////////////////////////////////////////////////////////////////////////
  201. //                                                                           //
  202. // SNMP ASN type definitions                                                 //
  203. //                                                                           //
  204. ///////////////////////////////////////////////////////////////////////////////
  205.  
  206. typedef struct {
  207.     BYTE * stream;              // pointer to octet stream
  208.     UINT   length;              // number of octets in stream
  209.     BOOL   dynamic;             // true if octets must be freed
  210. } AsnOctetString;
  211.  
  212. typedef struct {
  213.     UINT   idLength;            // number of integers in oid
  214.     UINT * ids;                 // pointer to integer stream
  215. } AsnObjectIdentifier;
  216.  
  217. typedef LONG                    AsnInteger;
  218. typedef DWORD                   AsnCounter;
  219. typedef DWORD                   AsnGauge;
  220. typedef DWORD                   AsnTimeticks;
  221.  
  222. typedef AsnOctetString          AsnSequence;
  223. typedef AsnOctetString          AsnImplicitSequence;
  224. typedef AsnOctetString          AsnIPAddress;
  225. typedef AsnOctetString          AsnDisplayString;
  226. typedef AsnOctetString          AsnOpaque;
  227.  
  228. typedef AsnObjectIdentifier     AsnObjectName;
  229. typedef AsnIPAddress            AsnNetworkAddress;
  230.  
  231. typedef struct {
  232.     BYTE asnType;
  233.     union {
  234.         AsnInteger              number;
  235.         AsnOctetString          string;
  236.         AsnObjectIdentifier     object;
  237.         AsnSequence             sequence;
  238.         AsnIPAddress            address;
  239.         AsnCounter              counter;
  240.         AsnGauge                gauge;
  241.         AsnTimeticks            ticks;
  242.         AsnOpaque               arbitrary;
  243.     } asnValue;
  244. } AsnAny;
  245.  
  246. typedef AsnAny                  AsnObjectSyntax;
  247.  
  248. ///////////////////////////////////////////////////////////////////////////////
  249. //                                                                           //
  250. // SNMP API type definitions                                                 //
  251. //                                                                           //
  252. ///////////////////////////////////////////////////////////////////////////////
  253.  
  254. typedef struct vb {
  255.     AsnObjectName    name;      // variable's object identifer
  256.     AsnObjectSyntax  value;     // variable's value (in asn terms)
  257. } RFC1157VarBind;
  258.  
  259. typedef struct {
  260.     RFC1157VarBind * list;      // array of variable bindings
  261.     UINT             len;       // number of bindings in array
  262. } RFC1157VarBindList;
  263.  
  264. ///////////////////////////////////////////////////////////////////////////////
  265. //                                                                           //
  266. // SNMP API prototypes                                                       //
  267. //                                                                           //
  268. ///////////////////////////////////////////////////////////////////////////////
  269.  
  270. SNMPAPI
  271. SNMP_FUNC_TYPE
  272. SnmpUtilOidCpy(
  273.     OUT AsnObjectIdentifier *DstObjId,
  274.     IN  AsnObjectIdentifier *SrcObjId
  275.     );
  276.  
  277. SNMPAPI
  278. SNMP_FUNC_TYPE
  279. SnmpUtilOidAppend(
  280.     IN OUT AsnObjectIdentifier *DstObjId,
  281.     IN     AsnObjectIdentifier *SrcObjId
  282.     );
  283.  
  284. SNMPAPI
  285. SNMP_FUNC_TYPE
  286. SnmpUtilOidNCmp(
  287.     IN AsnObjectIdentifier *ObjIdA,
  288.     IN AsnObjectIdentifier *ObjIdB,
  289.     IN UINT                 Len
  290.     );
  291.  
  292. SNMPAPI
  293. SNMP_FUNC_TYPE
  294. SnmpUtilOidCmp(
  295.     IN AsnObjectIdentifier *ObjIdA,
  296.     IN AsnObjectIdentifier *ObjIdB
  297.     );
  298.  
  299. VOID
  300. SNMP_FUNC_TYPE
  301. SnmpUtilOidFree(
  302.     IN OUT AsnObjectIdentifier *ObjId
  303.     );
  304.  
  305. SNMPAPI
  306. SNMP_FUNC_TYPE
  307. SnmpUtilVarBindListCpy(
  308.     OUT RFC1157VarBindList *DstVarBindList,
  309.     IN  RFC1157VarBindList *SrcVarBindList
  310.     );
  311.  
  312. SNMPAPI
  313. SNMP_FUNC_TYPE
  314. SnmpUtilVarBindCpy(
  315.     OUT RFC1157VarBind *DstVarBind,
  316.     IN  RFC1157VarBind *SrcVarBind
  317.     );
  318.  
  319. VOID
  320. SNMP_FUNC_TYPE
  321. SnmpUtilVarBindListFree(
  322.     IN OUT RFC1157VarBindList *VarBindList
  323.     );
  324.  
  325. VOID
  326. SNMP_FUNC_TYPE
  327. SnmpUtilVarBindFree(
  328.     IN OUT RFC1157VarBind *VarBind
  329.     );
  330.  
  331. VOID
  332. SNMP_FUNC_TYPE
  333. SnmpUtilPrintAsnAny(
  334.     IN AsnAny *Any
  335.     );
  336.  
  337. VOID
  338. SNMP_FUNC_TYPE
  339. SnmpUtilMemFree(
  340.     IN OUT LPVOID Addr
  341.     );
  342.  
  343. LPVOID
  344. SNMP_FUNC_TYPE
  345. SnmpUtilMemAlloc(
  346.     IN UINT Size
  347.     );
  348.  
  349. LPVOID
  350. SNMP_FUNC_TYPE
  351. SnmpUtilMemReAlloc(
  352.     IN LPVOID Addr,
  353.     IN UINT   NewSize
  354.     );
  355.  
  356. ///////////////////////////////////////////////////////////////////////////////
  357. //                                                                           //
  358. // SNMP debugging definitions                                                //
  359. //                                                                           //
  360. ///////////////////////////////////////////////////////////////////////////////
  361.  
  362. #define SNMP_LOG_SILENT             0x0
  363. #define SNMP_LOG_FATAL              0x1
  364. #define SNMP_LOG_ERROR              0x2
  365. #define SNMP_LOG_WARNING            0x3
  366. #define SNMP_LOG_TRACE              0x4
  367. #define SNMP_LOG_VERBOSE            0x5
  368.  
  369. ///////////////////////////////////////////////////////////////////////////////
  370. //                                                                           //
  371. // SNMP debugging prototypes                                                 //
  372. //                                                                           //
  373. ///////////////////////////////////////////////////////////////////////////////
  374.  
  375. VOID
  376. SNMP_FUNC_TYPE
  377. SnmpUtilDbgPrint(
  378.     IN INT nLogLevel,               // see log levels above...
  379.     IN LPSTR szFormat,
  380.     IN ...
  381.     );
  382.  
  383. #if DBG
  384. #define SNMPDBG(_x_)                SnmpUtilDbgPrint _x_
  385. #else
  386. #define SNMPDBG(_x_)
  387. #endif
  388.  
  389. ///////////////////////////////////////////////////////////////////////////////
  390. //                                                                           //
  391. // Miscellaneous definitions                                                 //
  392. //                                                                           //
  393. ///////////////////////////////////////////////////////////////////////////////
  394.  
  395. #define SNMP_MAX_OID_LEN            0x7f00 // max number of elements in oid
  396.  
  397. ///////////////////////////////////////////////////////////////////////////////
  398. //                                                                           //
  399. // Support for old definitions (support disabled via SNMPSTRICT)             //
  400. //                                                                           //
  401. ///////////////////////////////////////////////////////////////////////////////
  402.  
  403. #ifndef SNMPSTRICT
  404.  
  405. #define SNMP_oidcpy                 SnmpUtilOidCpy
  406. #define SNMP_oidappend              SnmpUtilOidAppend
  407. #define SNMP_oidncmp                SnmpUtilOidNCmp
  408. #define SNMP_oidcmp                 SnmpUtilOidCmp
  409. #define SNMP_oidfree                SnmpUtilOidFree
  410.  
  411. #define SNMP_CopyVarBindList        SnmpUtilVarBindListCpy
  412. #define SNMP_FreeVarBindList        SnmpUtilVarBindListFree
  413. #define SNMP_CopyVarBind            SnmpUtilVarBindCpy
  414. #define SNMP_FreeVarBind            SnmpUtilVarBindFree
  415.  
  416. #define SNMP_printany               SnmpUtilPrintAsnAny
  417.  
  418. #define SNMP_free                   SnmpUtilMemFree
  419. #define SNMP_malloc                 SnmpUtilMemAlloc
  420. #define SNMP_realloc                SnmpUtilMemReAlloc
  421.  
  422. #define SNMP_DBG_free               SnmpUtilMemFree
  423. #define SNMP_DBG_malloc             SnmpUtilMemAlloc
  424. #define SNMP_DBG_realloc            SnmpUtilMemReAlloc
  425.  
  426. #endif // SNMPSTRICT
  427.  
  428. #ifdef __cplusplus
  429. }
  430. #endif
  431.  
  432. #endif // _INC_SNMP
  433.