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.

277 lines
8.8 KiB

  1. /*++
  2. Copyright (c) 1999, Microsoft Corporation
  3. Module Name:
  4. ipsamplerm.h
  5. Abstract:
  6. The file contains type definitions and declarations for SAMPLE, the
  7. sample ip protocol, used by the IP Router Manager.
  8. --*/
  9. #ifndef _IPSAMPLERM_H_
  10. #define _IPSAMPLERM_H_
  11. // useful for variable sized structs
  12. #undef ANY_SIZE
  13. #define ANY_SIZE 0
  14. //----------------------------------------------------------------------------
  15. // CONSTANT AND MACRO DECLARATIONS
  16. //----------------------------------------------------------------------------
  17. #define PROTO_IP_SAMPLE 200
  18. #define MS_IP_SAMPLE \
  19. PROTOCOL_ID(PROTO_TYPE_UCAST, PROTO_VENDOR_MS0, PROTO_IP_SAMPLE)
  20. #define SAMPLE_PROTOCOL_MULTICAST_GROUP ((DWORD)0x640000E0) // 224.0.0.100
  21. //----------------------------------------------------------------------------
  22. // constants identifying IPSAMPLE's MIB tables
  23. //----------------------------------------------------------------------------
  24. #define IPSAMPLE_GLOBAL_STATS_ID 0
  25. #define IPSAMPLE_GLOBAL_CONFIG_ID 1
  26. #define IPSAMPLE_IF_STATS_ID 2
  27. #define IPSAMPLE_IF_CONFIG_ID 3
  28. #define IPSAMPLE_IF_BINDING_ID 4
  29. //----------------------------------------------------------------------------
  30. // constants used for the field IPSAMPLE_GLOBAL_CONFIG::dwLoggingLevel
  31. //----------------------------------------------------------------------------
  32. #define IPSAMPLE_LOGGING_NONE 0
  33. #define IPSAMPLE_LOGGING_ERROR 1
  34. #define IPSAMPLE_LOGGING_WARN 2
  35. #define IPSAMPLE_LOGGING_INFO 3
  36. //----------------------------------------------------------------------------
  37. // constants used for the field IPSAMPLE_IF_CONFIG::ulMetric
  38. //----------------------------------------------------------------------------
  39. #define IPSAMPLE_METRIC_INFINITE 16
  40. //----------------------------------------------------------------------------
  41. // constants used to construct the field IPSAMPLE_IF_BINDING::dwState
  42. //----------------------------------------------------------------------------
  43. #define IPSAMPLE_STATE_ACTIVE 0x00000001
  44. #define IPSAMPLE_STATE_BOUND 0x00000002
  45. //----------------------------------------------------------------------------
  46. // STRUCTURE DEFINITIONS
  47. //----------------------------------------------------------------------------
  48. //----------------------------------------------------------------------------
  49. // struct: IPSAMPLE_GLOBAL_STATS
  50. //
  51. // This MIB entry stores global statistics for IPSAMPLE;
  52. // There is only one instance, so this entry has no index.
  53. //
  54. // This structure is read-only.
  55. //----------------------------------------------------------------------------
  56. typedef struct _IPSAMPLE_GLOBAL_STATS
  57. {
  58. ULONG ulNumInterfaces; // # interfaces added
  59. } IPSAMPLE_GLOBAL_STATS, *PIPSAMPLE_GLOBAL_STATS;
  60. //----------------------------------------------------------------------------
  61. // struct: IPSAMPLE_GLOBAL_CONFIG
  62. //
  63. // This MIB entry stores global configuration for IPSAMPLE
  64. // There is only one instance, so this entry has no index.
  65. //----------------------------------------------------------------------------
  66. typedef struct _IPSAMPLE_GLOBAL_CONFIG
  67. {
  68. DWORD dwLoggingLevel;
  69. } IPSAMPLE_GLOBAL_CONFIG, *PIPSAMPLE_GLOBAL_CONFIG;
  70. //----------------------------------------------------------------------------
  71. // struct: IPSAMPLE_IF_STATS
  72. //
  73. // This MIB entry stores per-interface statistics for IPSAMPLE.
  74. //
  75. // This structure is read-only.
  76. //----------------------------------------------------------------------------
  77. typedef struct _IPSAMPLE_IF_STATS
  78. {
  79. ULONG ulNumPackets; // # packets sent out this interface
  80. } IPSAMPLE_IF_STATS, *PIPSAMPLE_IF_STATS;
  81. //----------------------------------------------------------------------------
  82. // struct: IPSAMPLE_IF_CONFIG
  83. //
  84. // This MIB entry describes per-interface configuration.
  85. // All IP address fields must be in network order.
  86. //----------------------------------------------------------------------------
  87. typedef struct _IPSAMPLE_IF_CONFIG
  88. {
  89. ULONG ulMetric;
  90. } IPSAMPLE_IF_CONFIG, *PIPSAMPLE_IF_CONFIG;
  91. //----------------------------------------------------------------------------
  92. // struct: IPSAMPLE_IF_BINDING
  93. //
  94. // This MIB entry contains the table of IP addresses to which each
  95. // interface is bound. All IP addresses are in network order.
  96. //
  97. // THIS STRUCTURE IS VARIABLE LENGTH:
  98. //
  99. // The base structure contains of the field ulCount, which gives the
  100. // number of IP addresses to which the indexed interface is bound. The
  101. // IP addresses themselves follow the base structure, and are given as
  102. // IPSAMPLE_IP_ADDRESS structures.
  103. //
  104. // This MIB entry is read-only.
  105. //----------------------------------------------------------------------------
  106. typedef struct _IPSAMPLE_IF_BINDING
  107. {
  108. DWORD dwState;
  109. ULONG ulCount;
  110. } IPSAMPLE_IF_BINDING, *PIPSAMPLE_IF_BINDING;
  111. //----------------------------------------------------------------------------
  112. // struct: IPSAMPLE_IP_ADDRESS
  113. //
  114. // This structure is used for storing interface bindings. A series of
  115. // structures of this type follows the IPSAMPLE_IF_BINDING structure
  116. // (described above).
  117. //
  118. // Both fields are IP address fields in network-order.
  119. //----------------------------------------------------------------------------
  120. typedef struct _IPSAMPLE_IP_ADDRESS
  121. {
  122. DWORD dwAddress;
  123. DWORD dwMask;
  124. } IPSAMPLE_IP_ADDRESS, *PIPSAMPLE_IP_ADDRESS;
  125. //----------------------------------------------------------------------------
  126. // macros for manipulating the variable-length IPSAMPLE_IF_BINDING structure
  127. //
  128. // IPSAMPLE_IF_BINDING_SIZE computes the size of a binding structure.
  129. //
  130. // IPSAMPLE_IF_ADDRESS_TABLE computes the starting address in a binding
  131. // struct of the series of IPSAMPLE_IP_ADDRESS structures which are
  132. // the bindings for the interface in question.
  133. //
  134. // e.g.
  135. // PIPSAMPLE_IF_BINDING piibSource, piibDest;
  136. //
  137. // piibDest = malloc(IPSAMPLE_IF_BINDING_SIZE(piibSource));
  138. // memcpy(piibDest, piibSource, IPSAMPLE_IF_BINDING_SIZE(piibSource));
  139. //
  140. // e.g.
  141. // ULONG i;
  142. // PIPSAMPLE_IF_BINDING piib;
  143. // PIPSAMPLE_IP_ADDRESS *piia;
  144. //
  145. // piia = IPSAMPLE_IF_ADDRESS_TABLE(piib);
  146. // for (i = 0; i < piib->ulCount; i++)
  147. // {
  148. // printf("%s-", inet_ntoa(*(struct in_addr *)&piia->dwAddress));
  149. // printf("%s\n", inet_ntoa(*(struct in_addr *)&piia->dwMask));
  150. // }
  151. //----------------------------------------------------------------------------
  152. #define IPSAMPLE_IF_BINDING_SIZE(bind) \
  153. (sizeof(IPSAMPLE_IF_BINDING) + \
  154. (bind)->ulCount * sizeof(IPSAMPLE_IP_ADDRESS))
  155. #define IPSAMPLE_IF_ADDRESS_TABLE(bind) \
  156. ((PIPSAMPLE_IP_ADDRESS)((bind) + 1))
  157. //----------------------------------------------------------------------------
  158. // The following structures are used to query the MIB and get back a
  159. // response. The TypeID field is one of the IDs #defined above. The
  160. // IfIndex is used to reference an interface table entry . For sample
  161. // it corresponds to an ip address, and hence is a single DWORD for now.
  162. // In general the index could be a variable size array of DWORDs.
  163. //----------------------------------------------------------------------------
  164. //----------------------------------------------------------------------------
  165. // struct: IPSAMPLE_MIB_SET_INPUT_DATA
  166. //
  167. // This is passed as input data for MibSet.
  168. // Note that only global config and interface config can be set.
  169. //----------------------------------------------------------------------------
  170. typedef struct _IPSAMPLE_MIB_SET_INPUT_DATA
  171. {
  172. DWORD IMSID_TypeID;
  173. DWORD IMSID_IfIndex;
  174. DWORD IMSID_BufferSize;
  175. BYTE IMSID_Buffer[ANY_SIZE];
  176. } IPSAMPLE_MIB_SET_INPUT_DATA, *PIPSAMPLE_MIB_SET_INPUT_DATA;
  177. //----------------------------------------------------------------------------
  178. // struct: IPSAMPLE_MIB_GET_INPUT_DATA
  179. //
  180. // This is passed as input data for MibGet, MibGetFirst, MibGetNext. All
  181. // tables are readable. All IP addresses must be in network order.
  182. //----------------------------------------------------------------------------
  183. typedef struct _IPSAMPLE_MIB_GET_INPUT_DATA
  184. {
  185. DWORD IMGID_TypeID;
  186. DWORD IMGID_IfIndex;
  187. } IPSAMPLE_MIB_GET_INPUT_DATA, *PIPSAMPLE_MIB_GET_INPUT_DATA;
  188. //----------------------------------------------------------------------------
  189. // struct: IPSAMPLE_MIB_GET_OUTPUT_DATA
  190. //
  191. // This is written into the output data by MibGet, MibGetFirst, MibGetNext.
  192. //----------------------------------------------------------------------------
  193. typedef struct _IPSAMPLE_MIB_GET_OUTPUT_DATA
  194. {
  195. DWORD IMGOD_TypeID;
  196. DWORD IMGOD_IfIndex;
  197. BYTE IMGOD_Buffer[ANY_SIZE];
  198. } IPSAMPLE_MIB_GET_OUTPUT_DATA, *PIPSAMPLE_MIB_GET_OUTPUT_DATA;
  199. #endif // _IPSAMPLERM_H_