Leaked source code of windows server 2003
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.

646 lines
23 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: wlbsconfig.h
  4. //
  5. // Module: Network Load Balancing
  6. //
  7. // Description: Internal APIs for cluster configuration. Thes APIs are internal
  8. // to WLBS team only, and no plan backward compatability.
  9. //
  10. // Copyright (C) Microsoft Corporation. All rights reserved.
  11. //
  12. // Author: fengsun Created 3/2/00
  13. //
  14. //+----------------------------------------------------------------------------
  15. #ifndef _WLBSCONFIG_H
  16. #define _WLBSCONFIG_H
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "wlbsctrl.h"
  21. /* Maximum lengths of parameter strings. */
  22. #define WLBS_MAX_VIRTUAL_NIC 256
  23. #define WLBS_MAX_CLUSTER_NIC 256
  24. #define WLBS_MAX_NETWORK_ADDR 17
  25. #define WLBS_MAX_CL_IP_ADDR 17
  26. #define WLBS_MAX_CL_NET_MASK 17
  27. #define WLBS_MAX_DED_IP_ADDR 17
  28. #define WLBS_MAX_DED_NET_MASK 17
  29. #define WLBS_MAX_NETWORK_ADDR 17
  30. #define WLBS_MAX_LICENSE_KEY 20
  31. #define WLBS_MAX_DOMAIN_NAME 100
  32. #define WLBS_MAX_BDA_TEAM_ID 40
  33. /* Port group rule - used in registry parameters.
  34. NOTE! do not access value marked with I. These are for internal use only. */
  35. #pragma pack(1)
  36. typedef struct
  37. {
  38. DWORD start_port, /* Starting port number. */
  39. end_port; /* Ending port number. */
  40. #ifdef WLBSAPI_INTERNAL_ONLY
  41. DWORD code; /* I: Unique rule code. */
  42. #else
  43. DWORD Private1; // Do not change these field directly
  44. #endif
  45. DWORD mode; /* Filtering mode. */
  46. DWORD protocol; /* WLBS_TCP, WLBS_UDP or WLBS_TCP_UDP */
  47. #ifdef WLBSAPI_INTERNAL_ONLY
  48. DWORD valid; /* I: For rule management in user mode. */
  49. #else
  50. DWORD Private2; // Do not change these field directly
  51. #endif
  52. union
  53. {
  54. struct
  55. {
  56. DWORD priority; /* Mastership priority: 1..32 or 0 for
  57. not-specified. */
  58. } single; /* Data for single server mode. */
  59. struct
  60. {
  61. WORD equal_load; /* TRUE - Even load distribution. */
  62. WORD affinity; /* WLBS_AFFINITY_... */
  63. DWORD load; /* Percentage of load to handle
  64. locally 0..100. */
  65. } multi; /* Data for multi-server mode. */
  66. } mode_data; /* Data for appropriate port group mode. */
  67. }
  68. WLBS_OLD_PORT_RULE, * PWLBS_OLD_PORT_RULE;
  69. /* Structure to hold the bi-directional affinity registry settings. */
  70. typedef struct _CVY_BDA {
  71. WCHAR team_id[WLBS_MAX_BDA_TEAM_ID + 1]; /* The team ID - MUST be a GUID. */
  72. ULONG active; /* On write, this flag determines whether to create BDATeaming key - BDA on/off switch. */
  73. ULONG master; /* Boolean indication of master status. */
  74. ULONG reverse_hash; /* Sets direction of hashing - forward (normal) or reverse. */
  75. } WLBS_BDA, PWLBS_BDA;
  76. typedef struct
  77. {
  78. TCHAR virtual_ip_addr [WLBS_MAX_CL_IP_ADDR + 1]; /* Virtual IP Address */
  79. DWORD start_port, /* Starting port number. */
  80. end_port; /* Ending port number. */
  81. #ifdef WLBSAPI_INTERNAL_ONLY
  82. DWORD code; /* I: Unique rule code. */
  83. #else
  84. DWORD Private1; // Do not change these field directly
  85. #endif
  86. DWORD mode; /* Filtering mode. */
  87. DWORD protocol; /* WLBS_TCP, WLBS_UDP or WLBS_TCP_UDP */
  88. #ifdef WLBSAPI_INTERNAL_ONLY
  89. DWORD valid; /* I: For rule management in user mode. */
  90. #else
  91. DWORD Private2; // Do not change these field directly
  92. #endif
  93. union
  94. {
  95. struct
  96. {
  97. DWORD priority; /* Mastership priority: 1..32 or 0 for
  98. not-specified. */
  99. } single; /* Data for single server mode. */
  100. struct
  101. {
  102. WORD equal_load; /* TRUE - Even load distribution. */
  103. WORD affinity; /* WLBS_AFFINITY_... */
  104. DWORD load; /* Percentage of load to handle
  105. locally 0..100. */
  106. } multi; /* Data for multi-server mode. */
  107. } mode_data; /* Data for appropriate port group mode. */
  108. }
  109. WLBS_PORT_RULE, * PWLBS_PORT_RULE;
  110. #pragma pack()
  111. #ifdef __cplusplus
  112. typedef struct __declspec(dllexport)
  113. #else
  114. typedef struct
  115. #endif
  116. {
  117. /* public - can be modified by clients of this API */
  118. DWORD host_priority; /* Host priority ID. */
  119. DWORD alive_period; /* Period for sending "I am alive" messages
  120. in milliseconds. */
  121. DWORD alive_tolerance; /* How many "I am alive" messages can be
  122. missed from other servers before assuming
  123. that the host is dead. */
  124. DWORD num_actions; /* Number of actions per allocation. */
  125. DWORD num_packets; /* number of packets per allocation. */
  126. DWORD num_send_msgs; /* Number of heartbeats per allocation. */
  127. DWORD install_date; /* Install time stamp, used to create a unique code for the host. */
  128. DWORD rct_port; /* Remote control UDP port. */
  129. DWORD rct_enabled; /* TRUE - remote control enabled. */
  130. DWORD cluster_mode; /* TRUE - join cluster on boot. */
  131. DWORD dscr_per_alloc; /* Number of connection tracking
  132. descriptor per allocation. */
  133. DWORD max_dscr_allocs; /* Maximum number of connection tracking
  134. descriptor allocations. */
  135. DWORD mcast_support; /* TRUE - multicast mode,
  136. FALSE - unicast mode */
  137. DWORD mask_src_mac; /* TRUE - Mangle source MAC address to
  138. prevent switch learning. FALSE -
  139. cluster is on a hub, optimizes switch
  140. performance by re-enabling learning. */
  141. TCHAR cl_mac_addr [WLBS_MAX_NETWORK_ADDR + 1];
  142. /* Cluster MAC address. */
  143. TCHAR cl_ip_addr [WLBS_MAX_CL_IP_ADDR + 1];
  144. /* Cluster IP address. */
  145. TCHAR cl_net_mask [WLBS_MAX_CL_NET_MASK + 1];
  146. /* Netmask for cluster IP. */
  147. TCHAR ded_ip_addr [WLBS_MAX_DED_IP_ADDR + 1];
  148. /* Dedicated IP address or "" for none. */
  149. TCHAR ded_net_mask [WLBS_MAX_DED_NET_MASK + 1];
  150. /* Netmask for dedicated IP address
  151. or "" for none */
  152. TCHAR domain_name [WLBS_MAX_DOMAIN_NAME + 1];
  153. /* FQDN of the cluster. */
  154. //
  155. // IGMP support
  156. //
  157. BOOL fIGMPSupport; // whether to send IGMP join periodically
  158. WCHAR szMCastIpAddress[WLBS_MAX_CL_IP_ADDR + 1]; // multicast IP
  159. BOOL fIpToMCastIp; // whether to generate multicast IP from cluster IP
  160. WLBS_BDA bda_teaming;
  161. #ifdef __cplusplus
  162. #ifndef WLBSAPI_INTERNAL_ONLY
  163. //
  164. // private - should be treated as opaque
  165. //
  166. // Do not change these field directly
  167. //
  168. private:
  169. #endif
  170. #endif
  171. /* obtained from the registry */
  172. DWORD i_parms_ver; /* I: Parameter structure version. */
  173. DWORD i_verify_date; /* I: Encoded install time stamp. */
  174. DWORD i_rmt_password; /* I: Remote maintenance password. */
  175. DWORD i_rct_password; /* I: Remote control password (use
  176. WlbsSetRemotePassword to set this
  177. value). */
  178. DWORD i_num_rules; /* I: # active port group rules (changed
  179. through WlbsAddPortRule and
  180. WlbsDelPortRule routines). */
  181. DWORD i_cleanup_delay; /* I: Dirty connection cleanup delay in
  182. milliseconds, 0 - delay. */
  183. DWORD i_scale_client; /* I: Legacy parameter. */
  184. DWORD i_mcast_spoof; /* I: TRUE - Provide ARP resolution in
  185. multicast mode. FALSE - clients
  186. will rely on static ARP entries. */
  187. DWORD i_convert_mac; /* I: TRUE - automatically generate MAC
  188. address based on cluster IP
  189. address in UI. */
  190. DWORD i_ip_chg_delay; /* I: Delay in milliseconds to block
  191. outgoing ARPs while IP address
  192. change is in process. */
  193. DWORD i_nbt_support; /* I: TRUE - NBT cluster name support
  194. enabled. */
  195. DWORD i_netmon_alive; /* I: TRUE - pass heartbeat messages
  196. to the protocols (netmon). */
  197. DWORD i_effective_version; /* I: Effective version of NLB */
  198. /* strings */
  199. TCHAR i_virtual_nic_name [WLBS_MAX_VIRTUAL_NIC + 1];
  200. /* I: Virtual NIC name or GUID. */
  201. // TCHAR cluster_nic_name [WLBS_MAX_CLUSTER_NIC + 1];
  202. /* I: Cluster NIC name or GUID. */
  203. TCHAR i_license_key [WLBS_MAX_LICENSE_KEY + 1];
  204. /* I: Legacy parameter. */
  205. WLBS_PORT_RULE i_port_rules [WLBS_MAX_RULES];
  206. /* I: Port rules (changed
  207. through WlbsAddPortRule and
  208. WlbsDelPortRule routines). */
  209. /* computed */
  210. DWORD i_max_hosts; /* Legacy parameter. */
  211. DWORD i_max_rules; /* Legacy parameter. */
  212. // DWORD i_expiration; /* Legacy parameter. */
  213. // DWORD i_ft_rules_enabled; /* Legacy parameter. */
  214. // DWORD version; /* Legacy parameter. */
  215. DWORD i_dwReserved;
  216. }
  217. WLBS_REG_PARAMS, * PWLBS_REG_PARAMS;
  218. /* API commands for WlbsFormatMessage */
  219. typedef enum
  220. {
  221. CmdWlbsAddPortRule,
  222. CmdWlbsAddressToName,
  223. CmdWlbsAddressToString,
  224. CmdWlbsAdjust,
  225. CmdWlbsCommitChanges,
  226. CmdWlbsDeletePortRule,
  227. CmdWlbsDestinationSet,
  228. CmdWlbsDisable,
  229. CmdWlbsDrain,
  230. CmdWlbsDrainStop,
  231. CmdWlbsEnable,
  232. CmdWlbsFormatMessage,
  233. CmdWlbsGetEffectiveVersion,
  234. CmdWlbsGetNumPortRules,
  235. CmdWlbsEnumPortRules,
  236. CmdWlbsGetPortRule,
  237. CmdWlbsInit,
  238. CmdWlbsPasswordSet,
  239. CmdWlbsPortSet,
  240. CmdWlbsQuery,
  241. CmdWlbsReadReg,
  242. CmdWlbsResolve,
  243. CmdWlbsResume,
  244. CmdWlbsSetDefaults,
  245. CmdWlbsSetRemotePassword,
  246. CmdWlbsStart,
  247. CmdWlbsStop,
  248. CmdWlbsSuspend,
  249. CmdWlbsTimeoutSet,
  250. CmdWlbsWriteReg
  251. }
  252. WLBS_COMMAND;
  253. extern BOOL WINAPI WlbsFormatMessage
  254. (
  255. DWORD error, /* IN - WLBS_... or WSA... return value. */
  256. WLBS_COMMAND command, /* IN - Which routine returned the value. */
  257. BOOL cluster, /* IN - TRUE - command was issued on entire
  258. cluster, FALSE - single host. */
  259. WCHAR* messagep, /* IN - Pointer to user-allocated buffer. */
  260. PDWORD lenp /* IN - Buffer size.
  261. OUT - The required buffer size if the current
  262. size is insufficient */
  263. );
  264. /*
  265. Return character string describing specified WLBS API return code. Note that
  266. message will depend on the command which returned the code and if it was
  267. issued in cluster-wide or single-host mode.
  268. returns:
  269. TRUE => Message formatted successfully.
  270. FALSE => Bad error code (lenp will contain 0 on exit) or buffer is not
  271. big enough to contain entire string (lenp will contain required
  272. buffer size on exit).
  273. */
  274. /* Support routines: */
  275. extern DWORD WINAPI WlbsResolve
  276. (
  277. const WCHAR* address /* IN - Internet host name or IP address in
  278. dotted notation. */
  279. );
  280. /*
  281. Resolve Internet host name to its IP address. This routine can also be
  282. used to convert a string containing an IP address in dotted notation to a
  283. value that can be passed to cluster control routines.
  284. returns:
  285. 0 => failed to resolve host name.
  286. <address> => IP address corresponding to the specified address.
  287. This value can be used in subsequent calls to
  288. cluster control routines.
  289. */
  290. extern BOOL WINAPI WlbsAddressToString
  291. (
  292. DWORD address, /* IN - IP address. */
  293. WCHAR* buf, /* OUT - Character buffer for resulting
  294. string. */
  295. PDWORD lenp /* IN - Buffer size in characters.
  296. OUT - Characters written or required buffer
  297. size. */
  298. );
  299. /*
  300. Convert IP address to a string in dotted notation.
  301. returns:
  302. TRUE => Successfully converted. lenp contains number of
  303. character written.
  304. FALSE => Buffer too small. lenp contains required buffer size
  305. including terminating NULL character.
  306. */
  307. extern BOOL WINAPI WlbsAddressToName
  308. (
  309. DWORD address, /* IN - IP address. */
  310. WCHAR* buf, /* OUT - Character buffer for resulting
  311. string. */
  312. PDWORD lenp /* IN - Buffer size in characters.
  313. OUT - Characters written or required buffer
  314. size. */
  315. );
  316. /*
  317. Resolve IP address to Internet host name.
  318. returns:
  319. TRUE => Successfully converted. lenp contains number of
  320. character written.
  321. FALSE => Buffer too small. lenp contains required buffer size
  322. including terminating NULL character.
  323. */
  324. /******************************************************************************
  325. Cluster host configuration routines. Note that in current implementation,
  326. cluster and host parameters need to be set to WLBS_LOCAL_CLUSTER and
  327. WLBS_LOCAL_HOST.
  328. ******************************************************************************/
  329. extern DWORD WINAPI WlbsReadReg
  330. (
  331. DWORD cluster, /* IN - WLBS_LOCAL_CLUSTER */
  332. PWLBS_REG_PARAMS reg_data /* OUT - Registry parameters */
  333. );
  334. /*
  335. Read WLBS registry data.
  336. returns:
  337. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  338. control operations.
  339. WLBS_BAD_PARAMS => reg_data is NULL
  340. WLBS_REG_ERROR => Error reading from the registry
  341. Local:
  342. WLBS_OK => Registry parameters successfully read.
  343. Remote:
  344. WLBS_LOCAL_ONLY => This call is implemented for local only operation.
  345. */
  346. extern DWORD WINAPI WlbsWriteReg
  347. (
  348. DWORD cluster, /* IN - WLBS_LOCAL_CLUSTER */
  349. const PWLBS_REG_PARAMS reg_data /* IN - Registry parameters. */
  350. );
  351. /*
  352. Write WLBS registry data.
  353. returns:
  354. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  355. control operations.
  356. WLBS_BAD_PARAMS => Registry parameter structure is invalid.
  357. WLBS_REG_ERROR => Error accessing the registry.
  358. Local:
  359. WLBS_OK => Registry parameters successfully written.
  360. Remote:
  361. WLBS_LOCAL_ONLY => This call is implemented for local only operation.
  362. */
  363. extern DWORD WINAPI WlbsCommitChanges
  364. (
  365. DWORD cluster /* IN - WLBS_LOCAL_CLUSTER */
  366. );
  367. /*
  368. Write WLBS registry data.
  369. returns:
  370. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  371. control operations.
  372. Local:
  373. WLBS_OK => Changes have been successfully applied.
  374. WLBS_BAD_PARAMS => Registry parameters were not accepted by the driver.
  375. Reload was not performed
  376. WLBS_REBOOT => Reboot required in order for config changes to
  377. take effect.
  378. WLBS_IO_ERROR => Error while writing to the driver.
  379. WLBS_REG_ERROR => Error while trying to write MAC address changes to the
  380. registry
  381. Remote:
  382. WLBS_LOCAL_ONLY => This call is implemented for local only operation.
  383. */
  384. extern DWORD WINAPI WlbsSetDefaults
  385. (
  386. PWLBS_REG_PARAMS reg_data /* OUT - Default values */
  387. );
  388. /*
  389. Fills in the reg_data structure with default values
  390. returns:
  391. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  392. control operations.
  393. WLBS_BAD_PARAMS => Invalid structure
  394. Local:
  395. WLBS_OK => Structure was filled in with the default values.
  396. Remote:
  397. WLBS_LOCAL_ONLY => This call is implemented for local only operation.
  398. */
  399. /******************************************************************************
  400. Registry parameter manipulation routines. Note that these routines operate
  401. WLBS_REG_PARAMS structure filled out by calling WlbsReadReg. Some parameters
  402. can be manipulated directly. Please make sure to use manipulation routines
  403. for the ones that they are provided for.
  404. ******************************************************************************/
  405. extern DWORD WINAPI WlbsGetEffectiveVersion
  406. (
  407. const PWLBS_REG_PARAMS reg_data /* IN - Registry parameters. */
  408. );
  409. /*
  410. Returns the effective version of cluster
  411. returns:
  412. CVY_VERSION_FULL => There is atleast one port rule that has a specific
  413. vip associated with it
  414. CVY_VERSION_LOWEST_CLIENT_FULL => All port rules have the "All vip" associated with them
  415. */
  416. extern DWORD WINAPI WlbsGetNumPortRules
  417. (
  418. const PWLBS_REG_PARAMS reg_data /* IN - Registry parameters. */
  419. );
  420. /*
  421. Returns number of port rules currently in the parameter structure.
  422. returns:
  423. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  424. control operations.
  425. WLBS_BAD_PARAMS => Registry parameter structure is invalid.
  426. 1...WLBS_MAX_RULES
  427. */
  428. extern DWORD WINAPI WlbsEnumPortRules
  429. (
  430. const PWLBS_REG_PARAMS reg_data, /* IN - Registry parameters. */
  431. PWLBS_PORT_RULE rules, /* OUT - Array of port rules. */
  432. PDWORD num_rules /* IN - Size of rules array.
  433. OUT - Number of rules retrieved. Note that
  434. this value can be larger than the size
  435. of the response array. In this case
  436. only the first few rules that fit
  437. in the array are returned. */
  438. );
  439. /*
  440. Enumerate all port rules in the list of port rules in parameter structure.
  441. returns:
  442. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  443. control operations.
  444. WLBS_BAD_PARAMS => Registry parameter structure is invalid.
  445. WLBS_TRUNCATED => All port rules did not fit into specified array.
  446. WLBS_OK => Rule has been successfully retrieved.
  447. */
  448. extern DWORD WINAPI WlbsGetPortRule
  449. (
  450. const PWLBS_REG_PARAMS reg_data, /* IN - Registry parameters. */
  451. DWORD vip, /* IN - Virtual IP Address of the port rule to retreive */
  452. DWORD port, /* IN - Port, which rule to retrieve. */
  453. PWLBS_PORT_RULE rule /* OUT - Port rule. */
  454. );
  455. /*
  456. Retrieve port rule containing specified port from the list of port rules
  457. in parameter structure.
  458. returns:
  459. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  460. control operations.
  461. WLBS_BAD_PARAMS => Registry parameter structure is invalid.
  462. WLBS_OK => Rule has been successfully retrieved.
  463. WLBS_NOT_FOUND => Port not found among port rules.
  464. */
  465. extern DWORD WINAPI WlbsAddPortRule
  466. (
  467. PWLBS_REG_PARAMS reg_data, /* IN - Registry parameters. */
  468. const PWLBS_PORT_RULE rule /* IN - Port rule to add. */
  469. );
  470. /*
  471. Add port to list of port rules in parameter structure.
  472. returns:
  473. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  474. control operations.
  475. WLBS_BAD_PARAMS => Registry parameter structure is invalid.
  476. WLBS_OK => Rule has been successfully added.
  477. WLBS_PORT_OVERLAP => Port rule overlaps with existing port rule.
  478. WLBS_BAD_PORT_PARAMS=> Invalid port rule parameters.
  479. WLBS_MAX_PORT_RULES => Maximum number of port rules already reached.
  480. */
  481. extern DWORD WINAPI WlbsDeletePortRule
  482. (
  483. PWLBS_REG_PARAMS reg_data, /* IN - Registry parameters. */
  484. DWORD vip, /* IN - Virtual IP Address of the port rule to retreive */
  485. DWORD port /* IN - Port, which rule to delete. */
  486. );
  487. /*
  488. Remove port rule containing specified port from the list of port rules
  489. in parameter structure.
  490. returns:
  491. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  492. control operations.
  493. WLBS_BAD_PARAMS => Registry parameter structure is invalid.
  494. WLBS_NOT_FOUND => Port not found among port rules.
  495. WLBS_OK => Rule has been successfully deleted.
  496. */
  497. extern DWORD WINAPI WlbsSetRemotePassword
  498. (
  499. PWLBS_REG_PARAMS reg_data, /* IN - Registry parameters. */
  500. const WCHAR* password /* IN - Password or NULL for no password. */
  501. );
  502. /*
  503. Set remote password code to encrypted value of the specified password.
  504. returns:
  505. WLBS_INIT_ERROR => Error initializing control module. Cannot perform
  506. control operations.
  507. WLBS_BAD_PARAMS => Registry parameter structure is invalid.
  508. WLBS_OK => Password has been successfully set.
  509. */
  510. DWORD WINAPI WlbsNotifyConfigChange(DWORD cluster);
  511. #ifdef __cplusplus
  512. } /* extern "C" */
  513. #endif
  514. #endif _WLBSCONFIG_H