home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / snmp.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  24KB  |  654 lines

  1. /*++
  2.  
  3. Copyright 1992 - 1998 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     snmp.h
  8.  
  9. Abstract:
  10.  
  11.     Definitions for SNMP 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 Type Definitions                                                     //
  33. //                                                                           //
  34. ///////////////////////////////////////////////////////////////////////////////
  35.  
  36. #pragma pack(4)
  37.  
  38. typedef struct {
  39.     BYTE * stream;     
  40.     UINT   length;     
  41.     BOOL   dynamic;    
  42. } AsnOctetString;
  43.  
  44. typedef struct {
  45.     UINT   idLength;   
  46.     UINT * ids;        
  47. } AsnObjectIdentifier;
  48.  
  49. typedef LONG                    AsnInteger32;
  50. typedef ULONG                   AsnUnsigned32;
  51. typedef ULARGE_INTEGER          AsnCounter64;
  52. typedef AsnUnsigned32           AsnCounter32;
  53. typedef AsnUnsigned32           AsnGauge32;
  54. typedef AsnUnsigned32           AsnTimeticks;
  55. typedef AsnOctetString          AsnBits;
  56. typedef AsnOctetString          AsnSequence;
  57. typedef AsnOctetString          AsnImplicitSequence;
  58. typedef AsnOctetString          AsnIPAddress;
  59. typedef AsnOctetString          AsnNetworkAddress;
  60. typedef AsnOctetString          AsnDisplayString;
  61. typedef AsnOctetString          AsnOpaque;
  62.  
  63. typedef struct {
  64.     BYTE asnType;
  65.     union {                     
  66.         AsnInteger32            number;     // ASN_INTEGER
  67.                                             // ASN_INTEGER32
  68.         AsnUnsigned32           unsigned32; // ASN_UNSIGNED32
  69.         AsnCounter64            counter64;  // ASN_COUNTER64
  70.         AsnOctetString          string;     // ASN_OCTETSTRING
  71.         AsnBits                 bits;       // ASN_BITS
  72.         AsnObjectIdentifier     object;     // ASN_OBJECTIDENTIFIER
  73.         AsnSequence             sequence;   // ASN_SEQUENCE
  74.         AsnIPAddress            address;    // ASN_IPADDRESS
  75.         AsnCounter32            counter;    // ASN_COUNTER32
  76.         AsnGauge32              gauge;      // ASN_GAUGE32
  77.         AsnTimeticks            ticks;      // ASN_TIMETICKS
  78.         AsnOpaque               arbitrary;  // ASN_OPAQUE
  79.     } asnValue;
  80. } AsnAny;
  81.  
  82. typedef AsnObjectIdentifier     AsnObjectName;
  83. typedef AsnAny                  AsnObjectSyntax;
  84.  
  85. typedef struct {
  86.     AsnObjectName    name;     
  87.     AsnObjectSyntax  value;    
  88. } SnmpVarBind;
  89.  
  90. typedef struct {
  91.     SnmpVarBind * list;     
  92.     UINT          len;      
  93. } SnmpVarBindList;
  94.  
  95. #pragma pack()
  96.  
  97. #ifndef _INC_WINSNMP
  98.  
  99. ///////////////////////////////////////////////////////////////////////////////
  100. //                                                                           //
  101. // ASN/BER Base Types                                                        //
  102. //                                                                           //
  103. ///////////////////////////////////////////////////////////////////////////////
  104.                                         
  105. #define ASN_UNIVERSAL                   0x00
  106. #define ASN_APPLICATION                 0x40
  107. #define ASN_CONTEXT                     0x80
  108. #define ASN_PRIVATE                     0xC0
  109.  
  110. #define ASN_PRIMITIVE                   0x00
  111. #define ASN_CONSTRUCTOR                 0x20
  112.  
  113. ///////////////////////////////////////////////////////////////////////////////
  114. //                                                                           //
  115. // PDU Type Values                                                           //
  116. //                                                                           //
  117. ///////////////////////////////////////////////////////////////////////////////
  118.  
  119. #define SNMP_PDU_GET                (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
  120. #define SNMP_PDU_GETNEXT            (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
  121. #define SNMP_PDU_RESPONSE           (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
  122. #define SNMP_PDU_SET                (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
  123. #define SNMP_PDU_V1TRAP             (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) 
  124. #define SNMP_PDU_GETBULK            (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
  125. #define SNMP_PDU_INFORM             (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
  126. #define SNMP_PDU_TRAP               (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
  127.  
  128. #endif // _INC_WINSNMP
  129.  
  130. ///////////////////////////////////////////////////////////////////////////////
  131. //                                                                           //
  132. // SNMP Simple Syntax Values                                                 //
  133. //                                                                           //
  134. ///////////////////////////////////////////////////////////////////////////////
  135.  
  136. #define ASN_INTEGER                 (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x02)
  137. #define ASN_BITS                    (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
  138. #define ASN_OCTETSTRING             (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04)
  139. #define ASN_NULL                    (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x05)
  140. #define ASN_OBJECTIDENTIFIER        (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x06)
  141. #define ASN_INTEGER32               ASN_INTEGER
  142.  
  143. ///////////////////////////////////////////////////////////////////////////////
  144. //                                                                           //
  145. // SNMP Constructor Syntax Values                                            //
  146. //                                                                           //
  147. ///////////////////////////////////////////////////////////////////////////////
  148.                                 
  149. #define ASN_SEQUENCE                (ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10)
  150. #define ASN_SEQUENCEOF              ASN_SEQUENCE
  151.  
  152. ///////////////////////////////////////////////////////////////////////////////
  153. //                                                                           //
  154. // SNMP Application Syntax Values                                            //
  155. //                                                                           //
  156. ///////////////////////////////////////////////////////////////////////////////
  157.  
  158. #define ASN_IPADDRESS               (ASN_APPLICATION | ASN_PRIMITIVE | 0x00)
  159. #define ASN_COUNTER32               (ASN_APPLICATION | ASN_PRIMITIVE | 0x01)
  160. #define ASN_GAUGE32                 (ASN_APPLICATION | ASN_PRIMITIVE | 0x02)
  161. #define ASN_TIMETICKS               (ASN_APPLICATION | ASN_PRIMITIVE | 0x03)
  162. #define ASN_OPAQUE                  (ASN_APPLICATION | ASN_PRIMITIVE | 0x04)
  163. #define ASN_COUNTER64               (ASN_APPLICATION | ASN_PRIMITIVE | 0x06)
  164. #define ASN_UNSIGNED32              (ASN_APPLICATION | ASN_PRIMITIVE | 0x07)
  165.  
  166. ///////////////////////////////////////////////////////////////////////////////
  167. //                                                                           //
  168. // SNMP Exception Conditions                                                 //
  169. //                                                                           //
  170. ///////////////////////////////////////////////////////////////////////////////
  171.                                         
  172. #define SNMP_EXCEPTION_NOSUCHOBJECT     (ASN_CONTEXT | ASN_PRIMITIVE | 0x00)
  173. #define SNMP_EXCEPTION_NOSUCHINSTANCE   (ASN_CONTEXT | ASN_PRIMITIVE | 0x01)
  174. #define SNMP_EXCEPTION_ENDOFMIBVIEW     (ASN_CONTEXT | ASN_PRIMITIVE | 0x02)
  175.  
  176. ///////////////////////////////////////////////////////////////////////////////
  177. //                                                                           //
  178. // SNMP Request Types (used in SnmpExtensionQueryEx)                         //
  179. //                                                                           //
  180. ///////////////////////////////////////////////////////////////////////////////
  181.                                     
  182. #define SNMP_EXTENSION_GET          SNMP_PDU_GET     
  183. #define SNMP_EXTENSION_GET_NEXT     SNMP_PDU_GETNEXT
  184. #define SNMP_EXTENSION_GET_BULK     SNMP_PDU_GETBULK
  185. #define SNMP_EXTENSION_SET_TEST     (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x0)
  186. #define SNMP_EXTENSION_SET_COMMIT   SNMP_PDU_SET
  187. #define SNMP_EXTENSION_SET_UNDO     (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x1)
  188. #define SNMP_EXTENSION_SET_CLEANUP  (ASN_PRIVATE | ASN_CONSTRUCTOR | 0x2)
  189.  
  190. ///////////////////////////////////////////////////////////////////////////////
  191. //                                                                           //
  192. // SNMP Error Codes                                                          //
  193. //                                                                           //
  194. ///////////////////////////////////////////////////////////////////////////////
  195.  
  196. #define SNMP_ERRORSTATUS_NOERROR                0
  197. #define SNMP_ERRORSTATUS_TOOBIG                 1
  198. #define SNMP_ERRORSTATUS_NOSUCHNAME             2
  199. #define SNMP_ERRORSTATUS_BADVALUE               3
  200. #define SNMP_ERRORSTATUS_READONLY               4
  201. #define SNMP_ERRORSTATUS_GENERR                 5
  202. #define SNMP_ERRORSTATUS_NOACCESS               6
  203. #define SNMP_ERRORSTATUS_WRONGTYPE              7
  204. #define SNMP_ERRORSTATUS_WRONGLENGTH            8
  205. #define SNMP_ERRORSTATUS_WRONGENCODING          9
  206. #define SNMP_ERRORSTATUS_WRONGVALUE             10
  207. #define SNMP_ERRORSTATUS_NOCREATION             11
  208. #define SNMP_ERRORSTATUS_INCONSISTENTVALUE      12
  209. #define SNMP_ERRORSTATUS_RESOURCEUNAVAILABLE    13
  210. #define SNMP_ERRORSTATUS_COMMITFAILED           14
  211. #define SNMP_ERRORSTATUS_UNDOFAILED             15
  212. #define SNMP_ERRORSTATUS_AUTHORIZATIONERROR     16
  213. #define SNMP_ERRORSTATUS_NOTWRITABLE            17
  214. #define SNMP_ERRORSTATUS_INCONSISTENTNAME       18
  215.  
  216. ///////////////////////////////////////////////////////////////////////////////
  217. //                                                                           //
  218. // SNMPv1 Trap Types                                                         //
  219. //                                                                           //
  220. ///////////////////////////////////////////////////////////////////////////////
  221.  
  222. #define SNMP_GENERICTRAP_COLDSTART              0    
  223. #define SNMP_GENERICTRAP_WARMSTART              1
  224. #define SNMP_GENERICTRAP_LINKDOWN               2
  225. #define SNMP_GENERICTRAP_LINKUP                 3
  226. #define SNMP_GENERICTRAP_AUTHFAILURE            4
  227. #define SNMP_GENERICTRAP_EGPNEIGHLOSS           5
  228. #define SNMP_GENERICTRAP_ENTERSPECIFIC          6
  229.  
  230. ///////////////////////////////////////////////////////////////////////////////
  231. //                                                                           //
  232. // SNMP Access Types                                                         //
  233. //                                                                           //
  234. ///////////////////////////////////////////////////////////////////////////////
  235.  
  236. #define SNMP_ACCESS_NONE                        0
  237. #define SNMP_ACCESS_NOTIFY                      1
  238. #define SNMP_ACCESS_READ_ONLY                   2
  239. #define SNMP_ACCESS_READ_WRITE                  3
  240. #define SNMP_ACCESS_READ_CREATE                 4
  241.  
  242. ///////////////////////////////////////////////////////////////////////////////
  243. //                                                                           //
  244. // SNMP API Return Code Definitions                                          //
  245. //                                                                           //
  246. ///////////////////////////////////////////////////////////////////////////////
  247.  
  248. #define SNMPAPI                                 INT
  249. #define SNMP_FUNC_TYPE                          WINAPI
  250.  
  251. #define SNMPAPI_NOERROR                         TRUE
  252. #define SNMPAPI_ERROR                           FALSE
  253.  
  254. ///////////////////////////////////////////////////////////////////////////////
  255. //                                                                           //
  256. // SNMP Extension API Prototypes                                             //
  257. //                                                                           //
  258. ///////////////////////////////////////////////////////////////////////////////
  259.  
  260. BOOL 
  261. SNMP_FUNC_TYPE
  262. SnmpExtensionInit(
  263.     DWORD                 dwUptimeReference,    
  264.     HANDLE *              phSubagentTrapEvent,  
  265.     AsnObjectIdentifier * pFirstSupportedRegion 
  266.     );
  267.  
  268. BOOL 
  269. SNMP_FUNC_TYPE
  270. SnmpExtensionInitEx(
  271.     AsnObjectIdentifier * pNextSupportedRegion
  272.     );
  273.  
  274. BOOL
  275. SNMP_FUNC_TYPE
  276. SnmpExtensionQuery(
  277.     BYTE              bPduType,    
  278.     SnmpVarBindList * pVarBindList,
  279.     AsnInteger32 *    pErrorStatus, 
  280.     AsnInteger32 *    pErrorIndex  
  281.     );
  282.  
  283. BOOL
  284. SNMP_FUNC_TYPE
  285. SnmpExtensionQueryEx(
  286.     UINT              nRequestType,   
  287.     UINT              nTransactionId,
  288.     SnmpVarBindList * pVarBindList,
  289.     AsnOctetString *  pContextInfo,
  290.     AsnInteger32 *    pErrorStatus,
  291.     AsnInteger32 *    pErrorIndex
  292.     );
  293.  
  294. BOOL 
  295. SNMP_FUNC_TYPE
  296. SnmpExtensionTrap(
  297.     AsnObjectIdentifier * pEnterpriseOid,  
  298.     AsnInteger32 *        pGenericTrapId,  
  299.     AsnInteger32 *        pSpecificTrapId, 
  300.     AsnTimeticks *        pTimeStamp,      
  301.     SnmpVarBindList *     pVarBindList
  302.     );
  303.  
  304. VOID
  305. SNMP_FUNC_TYPE
  306. SnmpExtensionClose(
  307.     );
  308.  
  309. ///////////////////////////////////////////////////////////////////////////////
  310. //                                                                           //
  311. // SNMP Extension API Type Definitions                                       //
  312. //                                                                           //
  313. ///////////////////////////////////////////////////////////////////////////////
  314.  
  315. typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONINIT)(
  316.     DWORD                 dwUpTimeReference,
  317.     HANDLE *              phSubagentTrapEvent,
  318.     AsnObjectIdentifier * pFirstSupportedRegion
  319.     );
  320.  
  321. typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONINITEX)(
  322.     AsnObjectIdentifier * pNextSupportedRegion
  323.     );
  324.  
  325. typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONQUERY)(
  326.     BYTE              bPduType,
  327.     SnmpVarBindList * pVarBindList,
  328.     AsnInteger32 *    pErrorStatus,
  329.     AsnInteger32 *    pErrorIndex
  330.     );
  331.  
  332. typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONQUERYEX)(
  333.     UINT              nRequestType,   
  334.     UINT              nTransactionId,
  335.     SnmpVarBindList * pVarBindList,
  336.     AsnOctetString *  pContextInfo,
  337.     AsnInteger32 *    pErrorStatus,
  338.     AsnInteger32 *    pErrorIndex
  339.     );
  340.  
  341. typedef BOOL (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONTRAP)(
  342.     AsnObjectIdentifier * pEnterpriseOid,
  343.     AsnInteger32 *        pGenericTrapId,
  344.     AsnInteger32 *        pSpecificTrapId,
  345.     AsnTimeticks *        pTimeStamp,
  346.     SnmpVarBindList *     pVarBindList
  347.     );
  348.  
  349. typedef VOID (SNMP_FUNC_TYPE * PFNSNMPEXTENSIONCLOSE)(
  350.     );
  351.  
  352. ///////////////////////////////////////////////////////////////////////////////
  353. //                                                                           //
  354. // SNMP API Prototypes                                                       //
  355. //                                                                           //
  356. ///////////////////////////////////////////////////////////////////////////////
  357.  
  358. SNMPAPI
  359. SNMP_FUNC_TYPE
  360. SnmpUtilOidCpy(
  361.     AsnObjectIdentifier * pOidDst,
  362.     AsnObjectIdentifier * pOidSrc
  363.     );
  364.  
  365. SNMPAPI
  366. SNMP_FUNC_TYPE
  367. SnmpUtilOidAppend(
  368.     AsnObjectIdentifier * pOidDst,
  369.     AsnObjectIdentifier * pOidSrc
  370.     );
  371.  
  372. SNMPAPI
  373. SNMP_FUNC_TYPE
  374. SnmpUtilOidNCmp(
  375.     AsnObjectIdentifier * pOid1,
  376.     AsnObjectIdentifier * pOid2,
  377.     UINT                  nSubIds
  378.     );
  379.  
  380. SNMPAPI
  381. SNMP_FUNC_TYPE
  382. SnmpUtilOidCmp(
  383.     AsnObjectIdentifier * pOid1,
  384.     AsnObjectIdentifier * pOid2
  385.     );
  386.  
  387. VOID
  388. SNMP_FUNC_TYPE
  389. SnmpUtilOidFree(
  390.     AsnObjectIdentifier * pOid
  391.     );
  392.  
  393. SNMPAPI
  394. SNMP_FUNC_TYPE
  395. SnmpUtilOctetsCmp(
  396.     AsnOctetString * pOctets1,
  397.     AsnOctetString * pOctets2
  398.     );
  399.  
  400. SNMPAPI
  401. SNMP_FUNC_TYPE
  402. SnmpUtilOctetsNCmp(
  403.     AsnOctetString * pOctets1,
  404.     AsnOctetString * pOctets2,
  405.     UINT             nChars
  406.     );
  407.  
  408. SNMPAPI
  409. SNMP_FUNC_TYPE
  410. SnmpUtilOctetsCpy(
  411.     AsnOctetString * pOctetsDst,
  412.     AsnOctetString * pOctetsSrc
  413.     );
  414.  
  415. VOID
  416. SNMP_FUNC_TYPE
  417. SnmpUtilOctetsFree(
  418.     AsnOctetString * pOctets
  419.     );
  420.  
  421. SNMPAPI
  422. SNMP_FUNC_TYPE
  423. SnmpUtilAsnAnyCpy(
  424.     AsnAny * pAnyDst,
  425.     AsnAny * pAnySrc
  426.     );
  427.  
  428. VOID
  429. SNMP_FUNC_TYPE
  430. SnmpUtilAsnAnyFree(
  431.     AsnAny * pAny
  432.     );
  433.  
  434. SNMPAPI
  435. SNMP_FUNC_TYPE
  436. SnmpUtilVarBindCpy(
  437.     SnmpVarBind * pVbDst,
  438.     SnmpVarBind * pVbSrc
  439.     );
  440.  
  441. VOID
  442. SNMP_FUNC_TYPE
  443. SnmpUtilVarBindFree(
  444.     SnmpVarBind * pVb
  445.     );
  446.  
  447. SNMPAPI
  448. SNMP_FUNC_TYPE
  449. SnmpUtilVarBindListCpy(
  450.     SnmpVarBindList * pVblDst,
  451.     SnmpVarBindList * pVblSrc
  452.     );
  453.  
  454. VOID
  455. SNMP_FUNC_TYPE
  456. SnmpUtilVarBindListFree(
  457.     SnmpVarBindList * pVbl
  458.     );
  459.  
  460. VOID
  461. SNMP_FUNC_TYPE
  462. SnmpUtilMemFree(
  463.     LPVOID pMem
  464.     );
  465.  
  466. LPVOID
  467. SNMP_FUNC_TYPE
  468. SnmpUtilMemAlloc(
  469.     UINT nBytes
  470.     );
  471.  
  472. LPVOID
  473. SNMP_FUNC_TYPE
  474. SnmpUtilMemReAlloc(
  475.     LPVOID pMem,
  476.     UINT   nBytes
  477.     );
  478.  
  479. LPSTR
  480. SNMP_FUNC_TYPE
  481. SnmpUtilOidToA(
  482.     IN AsnObjectIdentifier *Oid
  483.     );
  484.  
  485. LPSTR 
  486. SNMP_FUNC_TYPE
  487. SnmpUtilIdsToA(
  488.     IN UINT *Ids,
  489.     IN UINT IdLength
  490.     );
  491.  
  492. VOID 
  493. SNMP_FUNC_TYPE
  494. SnmpUtilPrintOid(
  495.     IN AsnObjectIdentifier *Oid 
  496.     );
  497.  
  498. VOID
  499. SNMP_FUNC_TYPE
  500. SnmpUtilPrintAsnAny(
  501.     AsnAny * pAny
  502.     );
  503.  
  504. DWORD
  505. SNMP_FUNC_TYPE 
  506. SnmpSvcGetUptime(
  507.     );
  508.  
  509. VOID
  510. SNMP_FUNC_TYPE
  511. SnmpSvcSetLogLevel(
  512.     INT nLogLevel
  513.     );
  514.  
  515. VOID
  516. SNMP_FUNC_TYPE
  517. SnmpSvcSetLogType(
  518.     INT nLogType
  519.     );
  520.  
  521. ///////////////////////////////////////////////////////////////////////////////
  522. //                                                                           //
  523. // SNMP Debugging Definitions                                                //
  524. //                                                                           //
  525. ///////////////////////////////////////////////////////////////////////////////
  526.  
  527. #define SNMP_LOG_SILENT                 0x0
  528. #define SNMP_LOG_FATAL                  0x1
  529. #define SNMP_LOG_ERROR                  0x2
  530. #define SNMP_LOG_WARNING                0x3
  531. #define SNMP_LOG_TRACE                  0x4
  532. #define SNMP_LOG_VERBOSE                0x5
  533.  
  534. #define SNMP_OUTPUT_TO_CONSOLE          0x1
  535. #define SNMP_OUTPUT_TO_LOGFILE          0x2
  536. #define SNMP_OUTPUT_TO_EVENTLOG         0x4  // no longer supported
  537. #define SNMP_OUTPUT_TO_DEBUGGER         0x8
  538.  
  539. ///////////////////////////////////////////////////////////////////////////////
  540. //                                                                           //
  541. // SNMP Debugging Prototypes                                                 //
  542. //                                                                           //
  543. ///////////////////////////////////////////////////////////////////////////////
  544.  
  545. VOID
  546. SNMP_FUNC_TYPE
  547. SnmpUtilDbgPrint(
  548.     IN INT nLogLevel,   // see log levels above...
  549.     IN LPSTR szFormat,
  550.     IN ...
  551.     );
  552.  
  553. #if DBG
  554. #define SNMPDBG(_x_)                    SnmpUtilDbgPrint _x_
  555. #else
  556. #define SNMPDBG(_x_)
  557. #endif
  558.  
  559. ///////////////////////////////////////////////////////////////////////////////
  560. //                                                                           //
  561. // Miscellaneous definitions                                                 //
  562. //                                                                           //
  563. ///////////////////////////////////////////////////////////////////////////////
  564.  
  565. #define DEFINE_SIZEOF(Array)        (sizeof(Array)/sizeof((Array)[0]))
  566. #define DEFINE_OID(SubIdArray)      {DEFINE_SIZEOF(SubIdArray),(SubIdArray)}
  567. #define DEFINE_NULLOID()            {0,NULL} 
  568. #define DEFINE_NULLOCTETS()         {NULL,0,FALSE}
  569.  
  570. #define DEFAULT_SNMP_PORT_UDP       161
  571. #define DEFAULT_SNMP_PORT_IPX       36879
  572. #define DEFAULT_SNMPTRAP_PORT_UDP   162
  573. #define DEFAULT_SNMPTRAP_PORT_IPX   36880
  574.  
  575. #define SNMP_MAX_OID_LEN            128
  576.  
  577. ///////////////////////////////////////////////////////////////////////////////
  578. //                                                                           //
  579. // API Error Code Definitions                                                //
  580. //                                                                           //
  581. ///////////////////////////////////////////////////////////////////////////////
  582.                                         
  583. #define SNMP_MEM_ALLOC_ERROR            1
  584. #define SNMP_BERAPI_INVALID_LENGTH      10
  585. #define SNMP_BERAPI_INVALID_TAG         11
  586. #define SNMP_BERAPI_OVERFLOW            12
  587. #define SNMP_BERAPI_SHORT_BUFFER        13
  588. #define SNMP_BERAPI_INVALID_OBJELEM     14
  589. #define SNMP_PDUAPI_UNRECOGNIZED_PDU    20
  590. #define SNMP_PDUAPI_INVALID_ES          21
  591. #define SNMP_PDUAPI_INVALID_GT          22
  592. #define SNMP_AUTHAPI_INVALID_VERSION    30
  593. #define SNMP_AUTHAPI_INVALID_MSG_TYPE   31
  594. #define SNMP_AUTHAPI_TRIV_AUTH_FAILED   32
  595.  
  596. ///////////////////////////////////////////////////////////////////////////////
  597. //                                                                           //
  598. // Support for old definitions (support disabled via SNMPSTRICT)             //
  599. //                                                                           //
  600. ///////////////////////////////////////////////////////////////////////////////
  601.  
  602. #ifndef SNMPSTRICT
  603.  
  604. #define SNMP_oidcpy                     SnmpUtilOidCpy
  605. #define SNMP_oidappend                  SnmpUtilOidAppend
  606. #define SNMP_oidncmp                    SnmpUtilOidNCmp
  607. #define SNMP_oidcmp                     SnmpUtilOidCmp
  608. #define SNMP_oidfree                    SnmpUtilOidFree
  609.  
  610. #define SNMP_CopyVarBindList            SnmpUtilVarBindListCpy
  611. #define SNMP_FreeVarBindList            SnmpUtilVarBindListFree
  612. #define SNMP_CopyVarBind                SnmpUtilVarBindCpy
  613. #define SNMP_FreeVarBind                SnmpUtilVarBindFree
  614.  
  615. #define SNMP_printany                   SnmpUtilPrintAsnAny
  616.  
  617. #define SNMP_free                       SnmpUtilMemFree
  618. #define SNMP_malloc                     SnmpUtilMemAlloc
  619. #define SNMP_realloc                    SnmpUtilMemReAlloc
  620.  
  621. #define SNMP_DBG_free                   SnmpUtilMemFree
  622. #define SNMP_DBG_malloc                 SnmpUtilMemAlloc
  623. #define SNMP_DBG_realloc                SnmpUtilMemReAlloc
  624.  
  625. #define ASN_RFC1155_IPADDRESS           ASN_IPADDRESS
  626. #define ASN_RFC1155_COUNTER             ASN_COUNTER32
  627. #define ASN_RFC1155_GAUGE               ASN_GAUGE32
  628. #define ASN_RFC1155_TIMETICKS           ASN_TIMETICKS
  629. #define ASN_RFC1155_OPAQUE              ASN_OPAQUE
  630. #define ASN_RFC1213_DISPSTRING          ASN_OCTETSTRING
  631.  
  632. #define ASN_RFC1157_GETREQUEST          SNMP_PDU_GET     
  633. #define ASN_RFC1157_GETNEXTREQUEST      SNMP_PDU_GETNEXT 
  634. #define ASN_RFC1157_GETRESPONSE         SNMP_PDU_RESPONSE
  635. #define ASN_RFC1157_SETREQUEST          SNMP_PDU_SET     
  636. #define ASN_RFC1157_TRAP                SNMP_PDU_V1TRAP  
  637.  
  638. #define ASN_CONTEXTSPECIFIC             ASN_CONTEXT
  639. #define ASN_PRIMATIVE                   ASN_PRIMITIVE
  640.  
  641. #define RFC1157VarBindList              SnmpVarBindList
  642. #define RFC1157VarBind                  SnmpVarBind
  643. #define AsnInteger                      AsnInteger32      
  644. #define AsnCounter                      AsnCounter32      
  645. #define AsnGauge                        AsnGauge32        
  646.  
  647. #endif // SNMPSTRICT
  648.  
  649. #ifdef __cplusplus
  650. }
  651. #endif
  652.  
  653. #endif // _INC_SNMP
  654.