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.

352 lines
17 KiB

  1. /*++
  2. Copyright(c) 1998,99 Microsoft Corporation
  3. Module Name:
  4. wlbsiocl.h
  5. Abstract:
  6. Windows Load Balancing Service (WLBS)
  7. IOCTL and remote control specifications
  8. Author:
  9. kyrilf
  10. Environment:
  11. Revision History:
  12. --*/
  13. #ifndef _Wlbsiocl_h_
  14. #define _Wlbsiocl_h_
  15. #ifdef KERNEL_MODE
  16. #include <ndis.h>
  17. #include <ntddndis.h>
  18. #include <devioctl.h>
  19. typedef BOOLEAN BOOL;
  20. #else
  21. #include <windows.h>
  22. #include <winioctl.h>
  23. #endif
  24. #include "wlbsparm.h"
  25. /* these are not strictly parameters, but this is a good place to put them, since this file is shared among user and kernel modes */
  26. /* Microsoft says that this value should be in the range 32768-65536 */
  27. #define CVY_DEVICE_TYPE 0xc0c0
  28. #define IOCTL_CVY_CLUSTER_ON CTL_CODE(CVY_DEVICE_TYPE, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  29. #define IOCTL_CVY_CLUSTER_OFF CTL_CODE(CVY_DEVICE_TYPE, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  30. #define IOCTL_CVY_PORT_ON CTL_CODE(CVY_DEVICE_TYPE, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  31. #define IOCTL_CVY_PORT_OFF CTL_CODE(CVY_DEVICE_TYPE, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  32. #define IOCTL_CVY_QUERY CTL_CODE(CVY_DEVICE_TYPE, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
  33. #define IOCTL_CVY_RELOAD CTL_CODE(CVY_DEVICE_TYPE, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  34. #define IOCTL_CVY_PORT_SET CTL_CODE(CVY_DEVICE_TYPE, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  35. #define IOCTL_CVY_PORT_DRAIN CTL_CODE(CVY_DEVICE_TYPE, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  36. #define IOCTL_CVY_CLUSTER_DRAIN CTL_CODE(CVY_DEVICE_TYPE, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
  37. #define IOCTL_CVY_CLUSTER_PLUG CTL_CODE(CVY_DEVICE_TYPE, 10, METHOD_BUFFERED, FILE_ANY_ACCESS) /* Internal only - passed from main.c to load.c when a start interrupts a drain. */
  38. #define IOCTL_CVY_CLUSTER_SUSPEND CTL_CODE(CVY_DEVICE_TYPE, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
  39. #define IOCTL_CVY_CLUSTER_RESUME CTL_CODE(CVY_DEVICE_TYPE, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  40. #define IOCTL_CVY_QUERY_STATE CTL_CODE(CVY_DEVICE_TYPE, 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
  41. #if defined (NLB_SESSION_SUPPORT)
  42. #define IOCTL_CVY_CONNECTION_NOTIFY CTL_CODE(CVY_DEVICE_TYPE, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)
  43. #endif
  44. #if defined (SBH)
  45. #define IOCTL_CVY_QUERY_PERF CTL_CODE(CVY_DEVICE_TYPE, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  46. #endif
  47. #define IOCTL_CVY_OK 0
  48. #define IOCTL_CVY_ALREADY 1
  49. #define IOCTL_CVY_BAD_PARAMS 2
  50. #define IOCTL_CVY_NOT_FOUND 3
  51. #define IOCTL_CVY_STOPPED 4
  52. #define IOCTL_CVY_CONVERGING 5
  53. #define IOCTL_CVY_SLAVE 6
  54. #define IOCTL_CVY_MASTER 7
  55. #define IOCTL_CVY_BAD_PASSWORD 8
  56. #define IOCTL_CVY_DRAINING 9
  57. #define IOCTL_CVY_DRAINING_STOPPED 10
  58. #define IOCTL_CVY_SUSPENDED 11
  59. #define IOCTL_CVY_DISCONNECTED 12
  60. #define IOCTL_REMOTE_CODE 0xb055c0de
  61. #define IOCTL_REMOTE_VR_PASSWORD L"b055c0de"
  62. #define IOCTL_REMOTE_VR_CODE 0x9CD8906E
  63. #define IOCTL_REMOTE_SEND_RETRIES 5
  64. #define IOCTL_REMOTE_RECV_DELAY 100
  65. #define IOCTL_REMOTE_RECV_RETRIES 20
  66. #define IOCTL_MASTER_HOST 0 /* MASTER_HOST host id */
  67. #define IOCTL_ALL_HOSTS 0xffffffff /* ALL_HOSTS host id */
  68. #define IOCTL_ALL_PORTS 0xffffffff /* Apply to all port rules. */
  69. #define IOCTL_ALL_VIPS 0x00000000 /* For virtual clusters, this is the ALL VIP specification for disable/enable/drain
  70. (including both specific VIP and "ALL VIP" port rules). */
  71. #define CVY_MAX_DEVNAME_LEN 48 /* The actual length of \device\guid is 46, but 48 was chosen for word alignment. */
  72. /* These flags indicate which options are being used/specified and/or additional information for the remote protocol. */
  73. /* For queries. */
  74. #define IOCTL_OPTIONS_QUERY_CLUSTER_MEMBER 0x00000001 /* The initiator is part of the cluster it is querying. */
  75. #define IOCTL_OPTIONS_QUERY_HOSTNAME 0x00000002 /* Return the hostname when a remote query is performed. */
  76. /* For port rule operations. */
  77. #define IOCTL_OPTIONS_PORTS_VIP_SPECIFIED 0x00000001 /* A VIP has been specified to check against. */
  78. /* For state queries. */
  79. #if defined (SBH)
  80. //
  81. // For IOCTL_CVY_QUERY_PERF
  82. //
  83. typedef struct
  84. {
  85. USHORT QueryState; // same as IOCTL_CVY_BUF::data.query.state
  86. USHORT HostId;
  87. ULONG HostMap;
  88. //
  89. // Heartbeat including ethernet header
  90. //
  91. UCHAR EthernetDstAddr[6];
  92. UCHAR EthernetSrcAddr[6];
  93. ULONG HeartbeatVersion;
  94. ULONG ClusterIp;
  95. ULONG DedicatedIp;
  96. USHORT master_id;
  97. USHORT state; /* my host's state */
  98. USHORT nrules; /* # active rules */
  99. ULONG UniqueCode; /* unique host code */
  100. ULONG pkt_count; // Count of packets handled since cvg'd
  101. // Updated only during convergence
  102. ULONG teaming; /* Includes BDA teaming configuration. */
  103. ULONG reserved2;
  104. ULONG rcode[CVY_MAX_RULES]; /* rule code */
  105. ULONGLONG cur_map[CVY_MAX_RULES]; /* my current load map for each port group */
  106. ULONGLONG new_map[CVY_MAX_RULES]; /* my new load map for each port group */
  107. /* if converging */
  108. ULONGLONG idle_map[CVY_MAX_RULES]; /* map of idle bins for each port group */
  109. ULONGLONG rdy_bins[CVY_MAX_RULES]; /* my rdy to send bins for each port group */
  110. ULONG load_amt[CVY_MAX_RULES]; /* my load amount for each port group */
  111. ULONG pg_rsvd1[CVY_MAX_RULES]; /* reserved */
  112. //
  113. // Load module
  114. //
  115. ULONG Convergence;
  116. ULONG nDescAllocated;
  117. ULONG nDescInUse;
  118. ULONG PacketCount;
  119. ULONGLONG AllIdleMap[CVY_MAX_RULES];
  120. ULONGLONG CurrentMap[CVY_MAX_RULES][CVY_MAX_HOSTS];
  121. ULONG DirtyClientWaiting;
  122. }CVY_DRIVER_PERF, *PCVY_DRIVER_PERF;
  123. #endif /* SBH */
  124. #pragma pack(1)
  125. typedef enum {
  126. NLB_CONN_UP = 0,
  127. NLB_CONN_DOWN,
  128. NLB_CONN_RESET
  129. } NLB_CONN_NOTIFICATION_OPERATION;
  130. #if defined (NLB_SESSION_SUPPORT)
  131. #define NLB_ERROR_SUCCESS 0x00000000
  132. #define NLB_ERROR_GENERIC_FAILURE 0x00000001
  133. #define NLB_ERROR_INVALID_PARAMETER 0x00000002
  134. #define NLB_ERROR_REQUEST_REFUSED 0x00000003
  135. #define NLB_ERROR_NOT_BOUND 0x00000004
  136. #define NLB_ERROR_NOT_FOUND 0x00000005
  137. /* IOCTL input buffer for connection notification from user space. */
  138. typedef struct {
  139. ULONG ReturnCode; /* The status of the operation upon return. */
  140. ULONG Version; /* The version number for checking between user and kernel space. */
  141. NLB_CONN_NOTIFICATION_OPERATION Operation; /* The operation to perform - UP/DOWN/RESET. */
  142. ULONG ClientIPAddress; /* The IP address of the client in network byte order. */
  143. ULONG ServerIPAddress; /* The IP address of the server in network byte order. */
  144. USHORT ClientPort; /* The client port number. */
  145. USHORT ServerPort; /* The server port number. */
  146. USHORT Protocol; /* The protocol of the packet in question. */
  147. USHORT Reserved; /* For byte alignment - reserved for later. */
  148. } IOCTL_CONN_NOTIFICATION, * PIOCTL_CONN_NOTIFICATION;
  149. #endif
  150. #define NLB_QUERY_STATE_SUCCESS 1500
  151. #define NLB_QUERY_STATE_FAILURE 1501
  152. /* These are the supported state query operations. */
  153. typedef enum {
  154. NLB_QUERY_REG_PARAMS = 0, /* Retrieve the registry parameters from the driver state. */
  155. NLB_QUERY_PORT_RULE_STATE, /* Retrieve the current port rule state. */
  156. NLB_QUERY_BDA_TEAM_STATE, /* Retrieve the current BDA teaming state. */
  157. NLB_QUERY_PACKET_STATISTICS, /* Retrieve the current packet handling statistics. */
  158. NLB_QUERY_PACKET_FILTER /* Retrieve packet filtering information. */
  159. } NLB_QUERY_STATE_OPERATION;
  160. /* These are the possible responses from the load packet filter
  161. state query, which returns accept/reject status for a given
  162. IP tuple and protocol, based on the current driver state. */
  163. typedef enum {
  164. NLB_REJECT_LOAD_MODULE_INACTIVE = 0, /* Packet rejected because the load module is inactive. */
  165. NLB_REJECT_CLUSTER_STOPPED, /* Packet rejected because NLB is stopped on this adapter. */
  166. NLB_REJECT_PORT_RULE_DISABLED, /* Packet rejected because the applicable port rule's filtering mode is disabled. */
  167. NLB_REJECT_CONNECTION_DIRTY, /* Packet rejected because the connection was marked dirty. */
  168. NLB_REJECT_OWNED_ELSEWHERE, /* Packet rejected because the packet is owned by another host. */
  169. NLB_REJECT_BDA_TEAMING_REFUSED, /* Packet rejected because BDA teaming refused to process it. */
  170. NLB_ACCEPT_UNCONDITIONAL_OWNERSHIP, /* Packet accepted because this host owns it unconditionally (optimized mode). */
  171. NLB_ACCEPT_FOUND_MATCHING_DESCRIPTOR, /* Packet accepted because we found a matching connection descriptor. */
  172. NLB_ACCEPT_PASSTHRU_MODE, /* Packet accepted because the cluster is in passthru mode. */
  173. NLB_ACCEPT_DIP_OR_BROADCAST, /* Packet accepted because its was sent to a bypassed address. */
  174. NLB_ACCEPT_REMOTE_CONTROL_REQUEST, /* Packet accepted because it is an NLB remote control packet. */
  175. NLB_ACCEPT_REMOTE_CONTROL_RESPONSE /* Packet accepted because it is an NLB remote control packet. */
  176. } NLB_QUERY_PACKET_FILTER_RESPONSE;
  177. /* This structure is used to query packet filtering information from the driver
  178. about a particular connection. Given a IP tuple (client IP, client port,
  179. server IP, server port) and a protocol, determine whether or not this host
  180. would accept the packet and why or why not. It is important that this is
  181. performed completely unobtrusively and has no side-effects on the actual
  182. operation of NLB and the load module. */
  183. typedef struct {
  184. ULONG ClientIPAddress; /* The IP address of the client in network byte order. */
  185. ULONG ServerIPAddress; /* The IP address of the server in network byte order. */
  186. USHORT ClientPort; /* The client port number. */
  187. USHORT ServerPort; /* The server port number. */
  188. USHORT Protocol; /* The protocol of the packet in question. */
  189. USHORT Reserved; /* For byte alignment - reserved for later. */
  190. struct {
  191. NLB_QUERY_PACKET_FILTER_RESPONSE Accept; /* The response - reason for accepting or rejecting the packet. */
  192. struct {
  193. USHORT Valid; /* Whether or not the driver has filled in the descriptor information. */
  194. USHORT Reserved; /* For byte alignment - reserved for later. */
  195. USHORT Alloc; /* Whether this descriptor is from the hash table or queue. */
  196. USHORT Dirty; /* Whether this connection is dirty or not. */
  197. ULONG FinCount; /* The number of FINs seen on this connection - TCP only. */
  198. } DescriptorInfo;
  199. struct {
  200. USHORT Valid; /* Whether or not the driver has filled in the hashing information. */
  201. USHORT Reserved; /* For byte alignment - reserved for later. */
  202. ULONG Bin; /* The "bucket" which this tuple mapped to - from 0 to 59. */
  203. ULONG ActiveConnections; /* The number of active connections on this "bucket". */
  204. ULONGLONG CurrentMap; /* The current "bucket" map for the applicable port rule. */
  205. ULONGLONG AllIdleMap; /* The all idle "bucket" map for the applicable port rule. */
  206. } HashInfo;
  207. } Results;
  208. } IOCTL_QUERY_STATE_PACKET_FILTER, * PIOCTL_QUERY_STATE_PACKET_FILTER;
  209. /* This structure is used by all query state IOCTLS to retrieve the specified
  210. state information from the driver, including load module state, port rule
  211. state, packet statistics and BDA teaming. */
  212. typedef struct {
  213. ULONG ReturnCode; /* The status of the operation upon return. */
  214. ULONG Version; /* The version number for checking between user and kernel space. */
  215. NLB_QUERY_STATE_OPERATION Operation; /* The operation to perform. */
  216. union {
  217. IOCTL_QUERY_STATE_PACKET_FILTER Filter; /* The input/output buffer for packet filter queries. */
  218. };
  219. } IOCTL_QUERY_STATE, * PIOCTL_QUERY_STATE;
  220. /* This structure is used by most of the existing IOCTL and remote control operations,
  221. including queries, cluster control and port rule control. */
  222. typedef union
  223. {
  224. ULONG ret_code;
  225. union {
  226. struct {
  227. USHORT state;
  228. USHORT host_id;
  229. ULONG host_map;
  230. } query;
  231. struct {
  232. ULONG load;
  233. ULONG num;
  234. } port;
  235. } data;
  236. } IOCTL_CVY_BUF, * PIOCTL_CVY_BUF;
  237. /* This structure is used by IOCTL and remote control operations to provide extended
  238. functionality beyond the legacy remote control protocol, which MUST remain backward
  239. compatible with NT 4.0 and Windows 2000. */
  240. typedef union {
  241. UCHAR reserved[256]; /* Bite the bullet and reserve 256 bytes to allow for future expansion. */
  242. union {
  243. struct
  244. {
  245. ULONG flags; /* These flags indicate which options fields have been specified. */
  246. WCHAR hostname[CVY_MAX_HOST_NAME + 1]; /* Host name filled in by NLB on remote control reply. */
  247. } query;
  248. struct
  249. {
  250. ULONG flags; /* These flags indicate which options fields have been specified. */
  251. ULONG virtual_ip_addr; /* For virtual clusters, the VIP, which can be 0x00000000, 0xffffffff or a specific VIP. */
  252. } port;
  253. struct
  254. {
  255. ULONG flags; /* These flags indicate which options fields have been specified. */
  256. IOCTL_QUERY_STATE query; /* This is the input/output buffer for querying driver state. */
  257. } state;
  258. #if defined (NLB_SESSION_SUPPORT)
  259. struct
  260. {
  261. ULONG flags; /* These flags indicate which options fields have been specified. */
  262. IOCTL_CONN_NOTIFICATION conn; /* The input/output buffer for connection notifications from upper-layer protocols. */
  263. } notify;
  264. #endif
  265. };
  266. } IOCTL_OPTIONS, * PIOCTL_OPTIONS;
  267. typedef struct {
  268. WCHAR device_name[CVY_MAX_DEVNAME_LEN]; /* Identifies the adapter. */
  269. IOCTL_CVY_BUF ctrl; /* The IOCTL information. */
  270. IOCTL_OPTIONS options; /* Optionally specified parameters. */
  271. } IOCTL_LOCAL_HDR, * PIOCTL_LOCAL_HDR;
  272. /* These macros define the remote control packets lengths based on Windows and NLB versions,
  273. so that error checking can be done upon the reception of a remote control packet. */
  274. #define NLB_MIN_RCTL_PACKET_LEN(ip_hdrp) ((sizeof(ULONG) * IP_GET_HLEN(ip_hdrp)) + sizeof(UDP_HDR) + sizeof(IOCTL_REMOTE_HDR) - sizeof(IOCTL_OPTIONS))
  275. #define NLB_NT40_RCTL_PACKET_LEN(ip_hdrp) ((sizeof(ULONG) * IP_GET_HLEN(ip_hdrp)) + sizeof(UDP_HDR) + sizeof(IOCTL_REMOTE_HDR) - sizeof(IOCTL_OPTIONS))
  276. #define NLB_WIN2K_RCTL_PACKET_LEN(ip_hdrp) ((sizeof(ULONG) * IP_GET_HLEN(ip_hdrp)) + sizeof(UDP_HDR) + sizeof(IOCTL_REMOTE_HDR) - sizeof(IOCTL_OPTIONS))
  277. #define NLB_WINXP_RCTL_PACKET_LEN(ip_hdrp) ((sizeof(ULONG) * IP_GET_HLEN(ip_hdrp)) + sizeof(UDP_HDR) + sizeof(IOCTL_REMOTE_HDR))
  278. #define NLB_MAX_RCTL_PACKET_LEN(ip_hdrp) ((sizeof(ULONG) * IP_GET_HLEN(ip_hdrp)) + sizeof(UDP_HDR) + sizeof(IOCTL_REMOTE_HDR))
  279. /* This structure is the UDP data for NLB remote control messages. */
  280. typedef struct {
  281. ULONG code; /* Distinguishes remote packets. */
  282. ULONG version; /* Software version. */
  283. ULONG host; /* Destination host (0 or cluster IP address for master). */
  284. ULONG cluster; /* Primary cluster IP address. */
  285. ULONG addr; /* Dedicated IP address on the way back, client IP address on the way in. */
  286. ULONG id; /* Message ID. */
  287. ULONG ioctrl; /* IOCTRL code. */
  288. IOCTL_CVY_BUF ctrl; /* Control buffer. */
  289. ULONG password; /* Encoded password. */
  290. IOCTL_OPTIONS options; /* Optionally specified parameters. */
  291. } IOCTL_REMOTE_HDR, * PIOCTL_REMOTE_HDR;
  292. #pragma pack()
  293. #endif /* _Wlbsiocl_h_ */