Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.0 KiB

  1. /*++ BUILD Version: 001 // Increment this if a change has global effects
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name :
  4. mib.h
  5. Abstract:
  6. Generic Macros and Functions for SNMP Extension Agent for
  7. gathering statistics information for Internet Services on NT.
  8. Author:
  9. Murali R. Krishnan ( MuraliK ) 22-Feb-1995
  10. Environment:
  11. User Mode -- Win32
  12. Project:
  13. SMTP Server SNMP MIB DLL
  14. Revision History:
  15. --*/
  16. # ifndef _MIB_H_
  17. # define _MIB_H_
  18. #include <windows.h>
  19. #include <snmp.h>
  20. #include <lm.h>
  21. #include <inetinfo.h>
  22. //
  23. // MIB function actions.
  24. //
  25. #define MIB_GET ( ASN_RFC1157_GETREQUEST)
  26. #define MIB_SET ( ASN_RFC1157_SETREQUEST)
  27. #define MIB_GETNEXT ( ASN_RFC1157_GETNEXTREQUEST)
  28. #define MIB_GETFIRST ( ASN_PRIVATE | ASN_CONSTRUCTOR | 0x0 )
  29. //
  30. // MIB Variable access privileges.
  31. //
  32. #define MIB_ACCESS_READ 0
  33. #define MIB_ACCESS_WRITE 1
  34. #define MIB_ACCESS_READWRITE 2
  35. #define MIB_NOACCESS 3
  36. typedef UINT ( * LPMIBFUNC)(
  37. RFC1157VarBind * pRfcVarBind,
  38. UINT Action,
  39. struct _MIB_ENTRY * pMibeCurrent,
  40. struct _MIB_ENTRIES* pMibEntries,
  41. LPVOID pStatistics
  42. );
  43. typedef struct _MIB_ENTRY {
  44. AsnObjectIdentifier asnOid; // OID for mib variable
  45. LONG lFieldOffset; // filed offset
  46. UINT uiAccess; // type of accesss( R, W, R/W, None)
  47. LPMIBFUNC pMibFunc; // ptr to function managing this var.
  48. BYTE bType; // Type( integer, counter, gauage).
  49. } MIB_ENTRY, FAR * LPMIB_ENTRY;
  50. typedef struct _MIB_ENTRIES {
  51. AsnObjectIdentifier * pOidPrefix; // Oid with prefix for MIB ENTRIES
  52. int cMibEntries; // count of MIB_ENTRIES in the array
  53. LPMIB_ENTRY prgMibEntry; // ptr to array of MIB_ENTRIES
  54. } MIB_ENTRIES, FAR * LPMIB_ENTRIES;
  55. //
  56. // GET_OID_LENGTH( oid) gets the length of the oid.
  57. //
  58. # define GET_OID_LENGTH( oid) ((oid).idLength)
  59. //
  60. // Macro to determine number of sub-oid's in an array of UINTs.
  61. //
  62. #define OID_SIZEOF( uiArray ) ( sizeof( uiArray) / sizeof(UINT) )
  63. //
  64. // OID_FROM_UINT_ARRAY(): Macro to define OID from an Array of UINTs
  65. //
  66. # define OID_FROM_UINT_ARRAY( uiArray) { OID_SIZEOF( uiArray), uiArray }
  67. //
  68. // Macros for creating MIB Entries ( as specified in struct _MIB_ENTRY above)
  69. // MIB_ENTRY_HEADER: creates a generic MIB_ENTRY for a MIB group header.
  70. // MIB_ENTRY_ITEM: creates a generic MIB_ENTRY for a MIB variable.
  71. // MIB_COUNTER: creates a counter type MIB_ENTRY
  72. // MIB_INTEGER: creates an integer type MIB_ENTRY
  73. //
  74. # define MIB_ENTRY_HEADER( oid) \
  75. { oid, \
  76. -1, \
  77. MIB_NOACCESS, \
  78. NULL, \
  79. ASN_RFC1155_OPAQUE, \
  80. }
  81. # define MIB_ENTRY_ITEM( oid, offset, access, type, func) \
  82. { oid, \
  83. offset, \
  84. access, \
  85. ( func), \
  86. ( type), \
  87. }
  88. # define MIB_COUNTER( oid, field, func) \
  89. MIB_ENTRY_ITEM( oid, field, MIB_ACCESS_READ, ASN_RFC1155_COUNTER, func)
  90. # define MIB_INTEGER( oid, field, func) \
  91. MIB_ENTRY_ITEM( oid, field, MIB_ACCESS_READ, ASN_INTEGER, func)
  92. UINT
  93. ResolveVarBinding(
  94. IN OUT RFC1157VarBind * pRfcVarBinding,
  95. IN BYTE pduAction,
  96. IN LPVOID pStatistics,
  97. IN LPMIB_ENTRIES pMibEntries
  98. );
  99. UINT
  100. MibStatisticsWorker(
  101. IN OUT RFC1157VarBind * pRfcVarBinding,
  102. IN UINT pduAction,
  103. IN struct _MIB_ENTRY * pMibeCurrent,
  104. IN struct _MIB_ENTRIES * pMibEntries,
  105. IN LPVOID pStatistics
  106. );
  107. # endif // _MIB_H_