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.

2091 lines
38 KiB

  1. /*
  2. * Filename: NLB_Common.cpp
  3. * Description:
  4. * Author: shouse, 04.10.01
  5. */
  6. #include <stdio.h>
  7. #include <objbase.h>
  8. #include "NLB_Common.h"
  9. #include "winsock2.h"
  10. #include "wlbsutil.h"
  11. /*************************************************
  12. * Class: NLB_Name *
  13. *************************************************/
  14. /*
  15. * Method:
  16. * Description:
  17. * Author: Created by shouse, 4.26.01
  18. * Notes:
  19. */
  20. NLB_Name::NLB_Name () {
  21. Name[0] = L'\0';
  22. }
  23. /*
  24. * Method:
  25. * Description:
  26. * Author: Created by shouse, 4.26.01
  27. * Notes:
  28. */
  29. NLB_Name::~NLB_Name () {
  30. }
  31. /*
  32. * Method:
  33. * Description:
  34. * Author: Created by shouse, 4.26.01
  35. * Notes:
  36. */
  37. bool NLB_Name::IsValid () {
  38. return (Name[0] != L'\0');
  39. }
  40. /*
  41. * Method:
  42. * Description:
  43. * Author: Created by shouse, 4.26.01
  44. * Notes:
  45. */
  46. void NLB_Name::Clear () {
  47. Name[0] = L'\0';
  48. }
  49. /*
  50. * Method:
  51. * Description:
  52. * Author: Created by shouse, 4.26.01
  53. * Notes:
  54. */
  55. bool NLB_Name::GetName (PWCHAR pName, ULONG length) {
  56. NLB_ASSERT(pName);
  57. wcsncpy(pName, Name, length - 1);
  58. pName[length - 1] = L'\0';
  59. return IsValid();
  60. }
  61. /*
  62. * Method:
  63. * Description:
  64. * Author: Created by shouse, 4.26.01
  65. * Notes:
  66. */
  67. bool NLB_Name::SetName (PWCHAR pName) {
  68. NLB_ASSERT(pName);
  69. if (wcslen(pName) > NLB_MAX_NAME) return false;
  70. if (wcschr(pName, L' ')) return false;
  71. wcscpy(Name, pName);
  72. return true;
  73. }
  74. /*************************************************
  75. * Class: NLB_Label *
  76. *************************************************/
  77. /*
  78. * Method:
  79. * Description:
  80. * Author: Created by shouse, 4.26.01
  81. * Notes:
  82. */
  83. NLB_Label::NLB_Label () {
  84. Text[0] = L'\0';
  85. }
  86. /*
  87. * Method:
  88. * Description:
  89. * Author: Created by shouse, 4.26.01
  90. * Notes:
  91. */
  92. NLB_Label::~NLB_Label () {
  93. }
  94. /*
  95. * Method:
  96. * Description:
  97. * Author: Created by shouse, 4.26.01
  98. * Notes:
  99. */
  100. bool NLB_Label::IsValid () {
  101. return (Text[0] != L'\0');
  102. }
  103. /*
  104. * Method:
  105. * Description:
  106. * Author: Created by shouse, 4.26.01
  107. * Notes:
  108. */
  109. void NLB_Label::Clear () {
  110. Text[0] = L'\0';
  111. }
  112. /*
  113. * Method:
  114. * Description:
  115. * Author: Created by shouse, 4.26.01
  116. * Notes:
  117. */
  118. bool NLB_Label::GetText (PWCHAR pText, ULONG length) {
  119. NLB_ASSERT(pText);
  120. wcsncpy(pText, Text, length - 1);
  121. pText[length - 1] = L'\0';
  122. return IsValid();
  123. }
  124. /*
  125. * Method:
  126. * Description:
  127. * Author: Created by shouse, 4.26.01
  128. * Notes:
  129. */
  130. bool NLB_Label::SetText (PWCHAR pText) {
  131. NLB_ASSERT(pText);
  132. if (wcslen(pText) > NLB_MAX_LABEL) return false;
  133. wcscpy(Text, pText);
  134. return true;
  135. }
  136. /*************************************************
  137. * Class: NLB_Adapter *
  138. *************************************************/
  139. /*
  140. * Method:
  141. * Description:
  142. * Author: Created by shouse, 4.26.01
  143. * Notes:
  144. */
  145. NLB_Adapter & NLB_Adapter::operator= (const NLB_Adapter & adapter) {
  146. IdentifiedBy = adapter.IdentifiedBy;
  147. wcscpy(Identifier, adapter.Identifier);
  148. return *this;
  149. }
  150. /*
  151. * Method:
  152. * Description:
  153. * Author: Created by shouse, 4.26.01
  154. * Notes:
  155. */
  156. NLB_Adapter::NLB_Adapter () {
  157. IdentifiedBy = Invalid;
  158. Identifier[0] = L'\0';
  159. }
  160. /*
  161. * Method:
  162. * Description:
  163. * Author: Created by shouse, 4.26.01
  164. * Notes:
  165. */
  166. NLB_Adapter::~NLB_Adapter () {
  167. }
  168. /*
  169. * Method:
  170. * Description:
  171. * Author: Created by shouse, 4.26.01
  172. * Notes:
  173. */
  174. bool NLB_Adapter::IsValid () {
  175. return ((IdentifiedBy != Invalid) && (Identifier[0] != L'\0'));
  176. }
  177. /*
  178. * Method:
  179. * Description:
  180. * Author: Created by shouse, 4.26.01
  181. * Notes:
  182. */
  183. void NLB_Adapter::Clear () {
  184. IdentifiedBy = Invalid;
  185. Identifier[0] = L'\0';
  186. }
  187. /*
  188. * Method:
  189. * Description:
  190. * Author: Created by shouse, 4.26.01
  191. * Notes:
  192. */
  193. bool NLB_Adapter::GetName (PWCHAR pName, ULONG length) {
  194. NLB_ASSERT(pName);
  195. if (IdentifiedBy == ByName) {
  196. wcsncpy(pName, Identifier, length - 1);
  197. pName[length - 1] = L'\0';
  198. return IsValid();
  199. }
  200. return false;
  201. }
  202. /*
  203. * Method:
  204. * Description:
  205. * Author: Created by shouse, 4.26.01
  206. * Notes:
  207. */
  208. bool NLB_Adapter::GetGUID (PWCHAR pGUID, ULONG length) {
  209. NLB_ASSERT(pGUID);
  210. if (IdentifiedBy == ByGUID) {
  211. wcsncpy(pGUID, Identifier, length - 1);
  212. pGUID[length - 1] = L'\0';
  213. return IsValid();
  214. }
  215. return false;
  216. }
  217. /*
  218. * Method:
  219. * Description:
  220. * Author: Created by shouse, 4.26.01
  221. * Notes:
  222. */
  223. bool NLB_Adapter::SetName (PWCHAR pName) {
  224. NLB_ASSERT(pName);
  225. if (wcslen(pName) > NLB_MAX_ADAPTER_IDENTIFIER) return false;
  226. wcscpy(Identifier, pName);
  227. IdentifiedBy = ByName;
  228. return true;
  229. }
  230. /*
  231. * Method:
  232. * Description:
  233. * Author: Created by shouse, 4.26.01
  234. * Notes:
  235. */
  236. bool NLB_Adapter::SetGUID (PWCHAR pGUID) {
  237. WCHAR wszString[NLB_MAX_ADAPTER_IDENTIFIER + 1];
  238. GUID UUID;
  239. HRESULT hr = S_OK;
  240. NLB_ASSERT(pGUID);
  241. if (wcslen(pGUID) > NLB_MAX_ADAPTER_IDENTIFIER) return false;
  242. if (pGUID[0] != L'{')
  243. wsprintf(wszString, L"{%ls}", pGUID);
  244. else
  245. wsprintf(wszString, L"%ls", pGUID);
  246. hr = CLSIDFromString(wszString, &UUID);
  247. if (hr != NOERROR) return false;
  248. wcscpy(Identifier, wszString);
  249. IdentifiedBy = ByGUID;
  250. return true;
  251. }
  252. /*************************************************
  253. * Class: NLB_IPAddress *
  254. *************************************************/
  255. /*
  256. * Method:
  257. * Description:
  258. * Author: Created by shouse, 4.26.01
  259. * Notes:
  260. */
  261. bool NLB_IPAddress::operator== (NLB_IPAddress & address) {
  262. if (!IsValid() || !address.IsValid())
  263. return false;
  264. if (lstrcmpi(IPAddress, address.IPAddress))
  265. return false;
  266. return true;
  267. }
  268. /*
  269. * Method:
  270. * Description:
  271. * Author: Created by shouse, 4.26.01
  272. * Notes:
  273. */
  274. NLB_IPAddress & NLB_IPAddress::operator= (const NLB_IPAddress & address) {
  275. Type = address.Type;
  276. wcscpy(IPAddress, address.IPAddress);
  277. wcscpy(SubnetMask, address.SubnetMask);
  278. Adapter = address.Adapter;
  279. return *this;
  280. }
  281. /*
  282. * Method:
  283. * Description:
  284. * Author: Created by shouse, 4.26.01
  285. * Notes:
  286. */
  287. NLB_IPAddress::NLB_IPAddress () {
  288. Type = Invalid;
  289. IPAddress[0] = L'\0';
  290. SubnetMask[0] = L'\0';
  291. }
  292. /*
  293. * Method:
  294. * Description:
  295. * Author: Created by shouse, 4.26.01
  296. * Notes:
  297. */
  298. NLB_IPAddress::NLB_IPAddress (NLB_IPAddressType eType) {
  299. SetIPAddressType(eType);
  300. IPAddress[0] = L'\0';
  301. SubnetMask[0] = L'\0';
  302. }
  303. /*
  304. * Method:
  305. * Description:
  306. * Author: Created by shouse, 4.26.01
  307. * Notes:
  308. */
  309. NLB_IPAddress::~NLB_IPAddress () {
  310. }
  311. /*
  312. * Method:
  313. * Description:
  314. * Author: Created by shouse, 4.26.01
  315. * Notes:
  316. */
  317. bool NLB_IPAddress::IsValid () {
  318. if (Type == Invalid)
  319. return false;
  320. if (Type == IGMP)
  321. return (IsValidMulticastIPAddress(IPAddress) == TRUE);
  322. if (!IsValidIPAddressSubnetMaskPair(IPAddress, SubnetMask))
  323. return false;
  324. if (!IsContiguousSubnetMask(SubnetMask))
  325. return false;
  326. return true;
  327. }
  328. /*
  329. * Method:
  330. * Description:
  331. * Author: Created by shouse, 4.26.01
  332. * Notes:
  333. */
  334. void NLB_IPAddress::Clear () {
  335. Type = Invalid;
  336. IPAddress[0] = L'\0';
  337. SubnetMask[0] = L'\0';
  338. Adapter.Clear();
  339. }
  340. /*
  341. * Method:
  342. * Description:
  343. * Author: Created by shouse, 4.26.01
  344. * Notes:
  345. */
  346. bool NLB_IPAddress::GetIPAddressType (NLB_IPAddressType & eType) {
  347. eType = Type;
  348. return (Type != Invalid);
  349. }
  350. /*
  351. * Method:
  352. * Description:
  353. * Author: Created by shouse, 4.26.01
  354. * Notes:
  355. */
  356. bool NLB_IPAddress::GetIPAddress (PWCHAR pIPAddress, ULONG length) {
  357. NLB_ASSERT(pIPAddress);
  358. wcsncpy(pIPAddress, IPAddress, length - 1);
  359. pIPAddress[length - 1] = L'\0';
  360. return IsValid();
  361. }
  362. /*
  363. * Method:
  364. * Description:
  365. * Author: Created by shouse, 4.26.01
  366. * Notes:
  367. */
  368. bool NLB_IPAddress::GetSubnetMask (PWCHAR pSubnetMask, ULONG length) {
  369. NLB_ASSERT(pSubnetMask);
  370. if ((Type == Virtual) || (Type == Connection) || (Type == IGMP))
  371. return false;
  372. wcsncpy(pSubnetMask, SubnetMask, length - 1);
  373. pSubnetMask[length - 1] = L'\0';
  374. return IsValid();
  375. }
  376. /*
  377. * Method:
  378. * Description:
  379. * Author: Created by shouse, 4.26.01
  380. * Notes:
  381. */
  382. bool NLB_IPAddress::GetAdapterName (PWCHAR pName, ULONG length) {
  383. if (Type == Dedicated)
  384. return Adapter.GetName(pName, length);
  385. return false;
  386. }
  387. /*
  388. * Method:
  389. * Description:
  390. * Author: Created by shouse, 4.26.01
  391. * Notes:
  392. */
  393. bool NLB_IPAddress::GetAdapterGUID (PWCHAR pGUID, ULONG length) {
  394. if (Type == Dedicated)
  395. return Adapter.GetGUID(pGUID, length);
  396. return false;
  397. }
  398. /*
  399. * Method:
  400. * Description:
  401. * Author: Created by shouse, 4.26.01
  402. * Notes:
  403. */
  404. bool NLB_IPAddress::SetIPAddressType (NLB_IPAddressType eType) {
  405. switch (eType) {
  406. case Primary:
  407. case Secondary:
  408. case Virtual:
  409. case IGMP:
  410. case Dedicated:
  411. case Connection:
  412. Type = eType;
  413. break;
  414. default:
  415. return false;
  416. }
  417. return true;
  418. }
  419. /*
  420. * Method:
  421. * Description:
  422. * Author: Created by shouse, 4.26.01
  423. * Notes:
  424. */
  425. bool NLB_IPAddress::SetIPAddress (PWCHAR pIPAddress) {
  426. IN_ADDR dwIPAddr;
  427. CHAR * szIPAddr;
  428. NLB_ASSERT(pIPAddress);
  429. if (wcslen(pIPAddress) > NLB_MAX_IPADDRESS) return false;
  430. if (!(dwIPAddr.S_un.S_addr = IpAddressFromAbcdWsz(pIPAddress)))
  431. return false;
  432. if (!(szIPAddr = inet_ntoa(dwIPAddr)))
  433. return false;
  434. if (!MultiByteToWideChar(CP_ACP, 0, szIPAddr, -1, IPAddress, NLB_MAX_IPADDRESS + 1))
  435. return false;
  436. if (SubnetMask[0] == L'\0')
  437. {
  438. ParamsGenerateSubnetMask(IPAddress, SubnetMask, ASIZECCH(SubnetMask));
  439. }
  440. return true;
  441. }
  442. /*
  443. * Method:
  444. * Description:
  445. * Author: Created by shouse, 4.26.01
  446. * Notes:
  447. */
  448. bool NLB_IPAddress::SetSubnetMask (PWCHAR pSubnetMask) {
  449. IN_ADDR dwIPAddr;
  450. CHAR * szIPAddr;
  451. NLB_ASSERT(pSubnetMask);
  452. if ((Type == Virtual) || (Type == Connection) || (Type == IGMP))
  453. return false;
  454. if (wcslen(pSubnetMask) > NLB_MAX_SUBNETMASK) return false;
  455. if (!(dwIPAddr.S_un.S_addr = IpAddressFromAbcdWsz(pSubnetMask)))
  456. return false;
  457. if (!(szIPAddr = inet_ntoa(dwIPAddr)))
  458. return false;
  459. if (!MultiByteToWideChar(CP_ACP, 0, szIPAddr, -1, SubnetMask, NLB_MAX_IPADDRESS + 1))
  460. return false;
  461. return true;
  462. }
  463. /*
  464. * Method:
  465. * Description:
  466. * Author: Created by shouse, 4.26.01
  467. * Notes:
  468. */
  469. bool NLB_IPAddress::SetAdapterName (PWCHAR pName) {
  470. if (Type == Dedicated)
  471. return Adapter.SetName(pName);
  472. return false;
  473. }
  474. /*
  475. * Method:
  476. * Description:
  477. * Author: Created by shouse, 4.26.01
  478. * Notes:
  479. */
  480. bool NLB_IPAddress::SetAdapterGUID (PWCHAR pGUID) {
  481. if (Type == Dedicated)
  482. return Adapter.SetGUID(pGUID);
  483. return false;
  484. }
  485. /*************************************************
  486. * Class: NLB_ClusterMode *
  487. *************************************************/
  488. /*
  489. * Method:
  490. * Description:
  491. * Author: Created by shouse, 4.26.01
  492. * Notes:
  493. */
  494. NLB_ClusterMode::NLB_ClusterMode () {
  495. Mode = Invalid;
  496. }
  497. /*
  498. * Method:
  499. * Description:
  500. * Author: Created by shouse, 4.26.01
  501. * Notes:
  502. */
  503. NLB_ClusterMode::~NLB_ClusterMode () {
  504. }
  505. /*
  506. * Method:
  507. * Description:
  508. * Author: Created by shouse, 4.26.01
  509. * Notes:
  510. */
  511. bool NLB_ClusterMode::IsValid () {
  512. return (Mode != Invalid);
  513. }
  514. /*
  515. * Method:
  516. * Description:
  517. * Author: Created by shouse, 4.26.01
  518. * Notes:
  519. */
  520. void NLB_ClusterMode::Clear () {
  521. Mode = Invalid;
  522. }
  523. /*
  524. * Method:
  525. * Description:
  526. * Author: Created by shouse, 4.26.01
  527. * Notes:
  528. */
  529. bool NLB_ClusterMode::GetMode (NLB_ClusterModeType & eMode) {
  530. eMode = Mode;
  531. return IsValid();
  532. }
  533. /*
  534. * Method:
  535. * Description:
  536. * Author: Created by shouse, 4.26.01
  537. * Notes:
  538. */
  539. bool NLB_ClusterMode::SetMode (NLB_ClusterModeType eMode) {
  540. switch (eMode) {
  541. case Unicast:
  542. case Multicast:
  543. case IGMP:
  544. Mode = eMode;
  545. break;
  546. default:
  547. return false;
  548. }
  549. return true;
  550. }
  551. /*************************************************
  552. * Class: NLB_ClusterDomainName *
  553. *************************************************/
  554. /*
  555. * Method:
  556. * Description:
  557. * Author: Created by shouse, 4.26.01
  558. * Notes:
  559. */
  560. NLB_ClusterDomainName::NLB_ClusterDomainName () {
  561. Domain[0] = L'\0';
  562. }
  563. /*
  564. * Method:
  565. * Description:
  566. * Author: Created by shouse, 4.26.01
  567. * Notes:
  568. */
  569. NLB_ClusterDomainName::~NLB_ClusterDomainName () {
  570. }
  571. /*
  572. * Method:
  573. * Description:
  574. * Author: Created by shouse, 4.26.01
  575. * Notes:
  576. */
  577. bool NLB_ClusterDomainName::IsValid () {
  578. return (Domain[0] != L'\0');
  579. }
  580. /*
  581. * Method:
  582. * Description:
  583. * Author: Created by shouse, 4.26.01
  584. * Notes:
  585. */
  586. void NLB_ClusterDomainName::Clear () {
  587. Domain[0] = L'\0';
  588. }
  589. /*
  590. * Method:
  591. * Description:
  592. * Author: Created by shouse, 4.26.01
  593. * Notes:
  594. */
  595. bool NLB_ClusterDomainName::GetDomain (PWCHAR pDomain, ULONG length) {
  596. NLB_ASSERT(pDomain);
  597. wcsncpy(pDomain, Domain, length - 1);
  598. pDomain[length - 1] = L'\0';
  599. return IsValid();
  600. }
  601. /*
  602. * Method:
  603. * Description:
  604. * Author: Created by shouse, 4.26.01
  605. * Notes:
  606. */
  607. bool NLB_ClusterDomainName::SetDomain (PWCHAR pDomain) {
  608. NLB_ASSERT(pDomain);
  609. if (wcslen(Domain) > NLB_MAX_DOMAIN_NAME) return false;
  610. wcscpy(Domain, pDomain);
  611. return true;
  612. }
  613. /*************************************************
  614. * Class: NLB_ClusterNetworkAddress *
  615. *************************************************/
  616. /*
  617. * Method:
  618. * Description:
  619. * Author: Created by shouse, 4.26.01
  620. * Notes:
  621. */
  622. NLB_ClusterNetworkAddress::NLB_ClusterNetworkAddress () {
  623. Address[0] = L'\0';
  624. }
  625. /*
  626. * Method:
  627. * Description:
  628. * Author: Created by shouse, 4.26.01
  629. * Notes:
  630. */
  631. NLB_ClusterNetworkAddress::~NLB_ClusterNetworkAddress () {
  632. }
  633. /*
  634. * Method:
  635. * Description:
  636. * Author: Created by shouse, 4.26.01
  637. * Notes:
  638. */
  639. bool NLB_ClusterNetworkAddress::IsValid () {
  640. return (Address[0] != L'\0');
  641. }
  642. /*
  643. * Method:
  644. * Description:
  645. * Author: Created by shouse, 4.26.01
  646. * Notes:
  647. */
  648. void NLB_ClusterNetworkAddress::Clear () {
  649. Address[0] = L'\0';
  650. }
  651. /*
  652. * Method:
  653. * Description:
  654. * Author: Created by shouse, 4.26.01
  655. * Notes:
  656. */
  657. bool NLB_ClusterNetworkAddress::GetAddress (PWCHAR pAddress, ULONG length) {
  658. NLB_ASSERT(pAddress);
  659. wcsncpy(pAddress, Address, length - 1);
  660. pAddress[length - 1] = L'\0';
  661. return IsValid();
  662. }
  663. /*
  664. * Method:
  665. * Description:
  666. * Author: Created by shouse, 4.26.01
  667. * Notes:
  668. */
  669. bool NLB_ClusterNetworkAddress::SetAddress (PWCHAR pAddress) {
  670. WCHAR MACAddress[NLB_MAX_NETWORK_ADDRESS + 1];
  671. PWCHAR p1, p2;
  672. DWORD i, j;
  673. NLB_ASSERT(pAddress);
  674. if (wcslen(pAddress) > NLB_MAX_NETWORK_ADDRESS) return false;
  675. /* Make a copy of the MAC address. */
  676. wcscpy(MACAddress, pAddress);
  677. /* Point to the beginning of the MAC. */
  678. p2 = p1 = MACAddress;
  679. /* Loop through all six bytes. */
  680. for (i = 0 ; i < 6 ; i++) {
  681. /* If we are pointing at the end of the string, its invalid. */
  682. if (*p2 == L'\0') return false;
  683. /* Convert the hex characters into decimal. */
  684. j = wcstoul(p1, &p2, 16);
  685. /* If the number is greater than 255, then the format is bad. */
  686. if (j > 255) return false;
  687. /* If the NEXT character is neither a -, :, nor the NUL character, then the format is bad. */
  688. if (!((*p2 == L'-') || (*p2 == L':') || (*p2 == L'\0'))) return false;
  689. /* If the NEXT character is the end of the string, but we don't have enough bytes yet, bail out. */
  690. if ((*p2 == L'\0') && (i < 5)) return false;
  691. /* Repoint to the NEXT character. */
  692. p1 = p2 + 1;
  693. p2 = p1;
  694. }
  695. wcscpy(Address, pAddress);
  696. return true;
  697. }
  698. /*************************************************
  699. * Class: NLB_ClusterBDASupport *
  700. *************************************************/
  701. /*
  702. * Method:
  703. * Description:
  704. * Author: Created by shouse, 4.26.01
  705. * Notes:
  706. */
  707. NLB_ClusterBDASupport & NLB_ClusterBDASupport::operator= (const NLB_ClusterBDASupport & bda) {
  708. Master = bda.Master;
  709. ReverseHash = bda.ReverseHash;
  710. wcscpy(TeamID, bda.TeamID);
  711. return *this;
  712. }
  713. /*
  714. * Method:
  715. * Description:
  716. * Author: Created by shouse, 4.26.01
  717. * Notes:
  718. */
  719. NLB_ClusterBDASupport::NLB_ClusterBDASupport () {
  720. Master = false;
  721. ReverseHash = false;
  722. TeamID[0] = L'\0';
  723. }
  724. /*
  725. * Method:
  726. * Description:
  727. * Author: Created by shouse, 4.26.01
  728. * Notes:
  729. */
  730. NLB_ClusterBDASupport::~NLB_ClusterBDASupport () {
  731. }
  732. /*
  733. * Method:
  734. * Description:
  735. * Author: Created by shouse, 4.26.01
  736. * Notes:
  737. */
  738. bool NLB_ClusterBDASupport::IsValid () {
  739. return (TeamID[0] != L'\0');
  740. }
  741. /*
  742. * Method:
  743. * Description:
  744. * Author: Created by shouse, 4.26.01
  745. * Notes:
  746. */
  747. void NLB_ClusterBDASupport::Clear () {
  748. Master = false;
  749. ReverseHash = false;
  750. TeamID[0] = L'\0';
  751. }
  752. /*
  753. * Method:
  754. * Description:
  755. * Author: Created by shouse, 4.26.01
  756. * Notes:
  757. */
  758. bool NLB_ClusterBDASupport::GetMaster (bool & bMaster) {
  759. bMaster = Master;
  760. return IsValid();
  761. }
  762. /*
  763. * Method:
  764. * Description:
  765. * Author: Created by shouse, 4.26.01
  766. * Notes:
  767. */
  768. bool NLB_ClusterBDASupport::GetReverseHashing (bool & bReverse) {
  769. bReverse = ReverseHash;
  770. return IsValid();
  771. }
  772. /*
  773. * Method:
  774. * Description:
  775. * Author: Created by shouse, 4.26.01
  776. * Notes:
  777. */
  778. bool NLB_ClusterBDASupport::GetTeamID (PWCHAR pTeam, ULONG length) {
  779. NLB_ASSERT(pTeam);
  780. wcsncpy(pTeam, TeamID, length - 1);
  781. pTeam[length - 1] = L'\0';
  782. return IsValid();
  783. }
  784. /*
  785. * Method:
  786. * Description:
  787. * Author: Created by shouse, 4.26.01
  788. * Notes:
  789. */
  790. bool NLB_ClusterBDASupport::SetMaster (bool bMaster) {
  791. Master = bMaster;
  792. return true;
  793. }
  794. /*
  795. * Method:
  796. * Description:
  797. * Author: Created by shouse, 4.26.01
  798. * Notes:
  799. */
  800. bool NLB_ClusterBDASupport::SetReverseHashing (bool bReverse) {
  801. ReverseHash = bReverse;
  802. return true;
  803. }
  804. /*
  805. * Method:
  806. * Description:
  807. * Author: Created by shouse, 4.26.01
  808. * Notes:
  809. */
  810. bool NLB_ClusterBDASupport::SetTeamID (PWCHAR pTeam) {
  811. WCHAR wszString[NLB_MAX_BDA_TEAMID + 1];
  812. GUID UUID;
  813. HRESULT hr = S_OK;
  814. NLB_ASSERT(pTeam);
  815. if (wcslen(pTeam) > NLB_MAX_BDA_TEAMID) return false;
  816. if (pTeam[0] != L'{')
  817. wsprintf(wszString, L"{%ls}", pTeam);
  818. else
  819. wsprintf(wszString, L"%ls", pTeam);
  820. hr = CLSIDFromString(wszString, &UUID);
  821. if (hr != NOERROR) return false;
  822. wcscpy(TeamID, wszString);
  823. return true;
  824. }
  825. /*************************************************
  826. * Class: NLB_ClusterRemoteControl *
  827. *************************************************/
  828. /*
  829. * Method:
  830. * Description:
  831. * Author: Created by shouse, 4.26.01
  832. * Notes:
  833. */
  834. NLB_ClusterRemoteControl::NLB_ClusterRemoteControl () {
  835. Valid = false;
  836. Enabled = false;
  837. Password[0] = L'\0';
  838. }
  839. /*
  840. * Method:
  841. * Description:
  842. * Author: Created by shouse, 4.26.01
  843. * Notes:
  844. */
  845. NLB_ClusterRemoteControl::~NLB_ClusterRemoteControl () {
  846. }
  847. /*
  848. * Method:
  849. * Description:
  850. * Author: Created by shouse, 4.26.01
  851. * Notes:
  852. */
  853. bool NLB_ClusterRemoteControl::IsValid () {
  854. return (Password[0] != L'\0');
  855. }
  856. /*
  857. * Method:
  858. * Description:
  859. * Author: Created by shouse, 4.26.01
  860. * Notes:
  861. */
  862. void NLB_ClusterRemoteControl::Clear () {
  863. Valid = false;
  864. Enabled = false;
  865. Password[0] = L'\0';
  866. }
  867. /*
  868. * Method:
  869. * Description:
  870. * Author: Created by shouse, 4.26.01
  871. * Notes:
  872. */
  873. bool NLB_ClusterRemoteControl::GetEnabled (bool & bEnabled) {
  874. bEnabled = Enabled;
  875. return Valid;
  876. }
  877. /*
  878. * Method:
  879. * Description:
  880. * Author: Created by shouse, 4.26.01
  881. * Notes:
  882. */
  883. bool NLB_ClusterRemoteControl::GetPassword (PWCHAR pPassword, ULONG length) {
  884. NLB_ASSERT(pPassword);
  885. wcsncpy(pPassword, Password, length - 1);
  886. pPassword[length - 1] = L'\0';
  887. return IsValid();
  888. }
  889. /*
  890. * Method:
  891. * Description:
  892. * Author: Created by shouse, 4.26.01
  893. * Notes:
  894. */
  895. bool NLB_ClusterRemoteControl::SetEnabled (bool bEnabled) {
  896. Enabled = bEnabled;
  897. Valid = true;
  898. return true;
  899. }
  900. /*
  901. * Method:
  902. * Description:
  903. * Author: Created by shouse, 4.26.01
  904. * Notes:
  905. */
  906. bool NLB_ClusterRemoteControl::SetPassword (PWCHAR pPassword) {
  907. NLB_ASSERT(pPassword);
  908. if (wcslen(pPassword) > NLB_MAX_PASSWORD) return false;
  909. wcscpy(Password, pPassword);
  910. return true;
  911. }
  912. /*************************************************
  913. * Class: NLB_HostName *
  914. *************************************************/
  915. /*
  916. * Method:
  917. * Description:
  918. * Author: Created by shouse, 4.26.01
  919. * Notes:
  920. */
  921. NLB_HostName::NLB_HostName () {
  922. Name[0] = L'\0';
  923. }
  924. /*
  925. * Method:
  926. * Description:
  927. * Author: Created by shouse, 4.26.01
  928. * Notes:
  929. */
  930. NLB_HostName::~NLB_HostName () {
  931. }
  932. /*
  933. * Method:
  934. * Description:
  935. * Author: Created by shouse, 4.26.01
  936. * Notes:
  937. */
  938. bool NLB_HostName::IsValid () {
  939. return (Name[0] != L'\0');
  940. }
  941. /*
  942. * Method:
  943. * Description:
  944. * Author: Created by shouse, 4.26.01
  945. * Notes:
  946. */
  947. void NLB_HostName::Clear () {
  948. Name[0] = L'\0';
  949. }
  950. /*
  951. * Method:
  952. * Description:
  953. * Author: Created by shouse, 4.26.01
  954. * Notes:
  955. */
  956. bool NLB_HostName::GetName (PWCHAR pName, ULONG length) {
  957. NLB_ASSERT(pName);
  958. wcsncpy(pName, Name, length - 1);
  959. pName[length - 1] = L'\0';
  960. return IsValid();
  961. }
  962. /*
  963. * Method:
  964. * Description:
  965. * Author: Created by shouse, 4.26.01
  966. * Notes:
  967. */
  968. bool NLB_HostName::SetName (PWCHAR pName) {
  969. NLB_ASSERT(pName);
  970. if (wcslen(pName) > NLB_MAX_HOST_NAME) return false;
  971. wcscpy(Name, pName);
  972. return true;
  973. }
  974. /*************************************************
  975. * Class: NLB_HostID *
  976. *************************************************/
  977. /*
  978. * Method:
  979. * Description:
  980. * Author: Created by shouse, 4.26.01
  981. * Notes:
  982. */
  983. NLB_HostID::NLB_HostID () {
  984. HostID = NLB_MAX_HOST_ID + 1;
  985. }
  986. /*
  987. * Method:
  988. * Description:
  989. * Author: Created by shouse, 4.26.01
  990. * Notes:
  991. */
  992. NLB_HostID::~NLB_HostID () {
  993. }
  994. /*
  995. * Method:
  996. * Description:
  997. * Author: Created by shouse, 4.26.01
  998. * Notes:
  999. */
  1000. bool NLB_HostID::IsValid () {
  1001. return (HostID <= NLB_MAX_HOST_ID);
  1002. }
  1003. /*
  1004. * Method:
  1005. * Description:
  1006. * Author: Created by shouse, 4.26.01
  1007. * Notes:
  1008. */
  1009. void NLB_HostID::Clear () {
  1010. HostID = NLB_MAX_HOST_ID + 1;
  1011. }
  1012. /*
  1013. * Method:
  1014. * Description:
  1015. * Author: Created by shouse, 4.26.01
  1016. * Notes:
  1017. */
  1018. bool NLB_HostID::GetID (ULONG & ID) {
  1019. ID = HostID;
  1020. return IsValid();
  1021. }
  1022. /*
  1023. * Method:
  1024. * Description:
  1025. * Author: Created by shouse, 4.26.01
  1026. * Notes:
  1027. */
  1028. bool NLB_HostID::SetID (ULONG ID) {
  1029. if (ID > NLB_MAX_HOST_ID) return false;
  1030. HostID = ID;
  1031. return true;
  1032. }
  1033. /*************************************************
  1034. * Class: NLB_HostState *
  1035. *************************************************/
  1036. /*
  1037. * Method:
  1038. * Description:
  1039. * Author: Created by shouse, 4.26.01
  1040. * Notes:
  1041. */
  1042. NLB_HostState::NLB_HostState () {
  1043. State = Invalid;
  1044. PersistStarted = false;
  1045. PersistStopped = false;
  1046. PersistSuspended = false;
  1047. PersistStartedValid = false;
  1048. PersistStoppedValid = false;
  1049. PersistSuspendedValid = false;
  1050. }
  1051. /*
  1052. * Method:
  1053. * Description:
  1054. * Author: Created by shouse, 4.26.01
  1055. * Notes:
  1056. */
  1057. NLB_HostState::~NLB_HostState () {
  1058. }
  1059. /*
  1060. * Method:
  1061. * Description:
  1062. * Author: Created by shouse, 4.26.01
  1063. * Notes:
  1064. */
  1065. bool NLB_HostState::IsValid () {
  1066. return (State != Invalid);
  1067. }
  1068. /*
  1069. * Method:
  1070. * Description:
  1071. * Author: Created by shouse, 4.26.01
  1072. * Notes:
  1073. */
  1074. void NLB_HostState::Clear () {
  1075. State = Invalid;
  1076. PersistStarted = false;
  1077. PersistStopped = false;
  1078. PersistSuspended = false;
  1079. PersistStartedValid = false;
  1080. PersistStoppedValid = false;
  1081. PersistSuspendedValid = false;
  1082. }
  1083. /*
  1084. * Method:
  1085. * Description:
  1086. * Author: Created by shouse, 4.26.01
  1087. * Notes:
  1088. */
  1089. bool NLB_HostState::GetState (NLB_HostStateType & eState) {
  1090. eState = State;
  1091. return IsValid();
  1092. }
  1093. /*
  1094. * Method:
  1095. * Description:
  1096. * Author: Created by shouse, 4.26.01
  1097. * Notes:
  1098. */
  1099. bool NLB_HostState::GetPersistence (NLB_HostStateType eState, bool & bPersist) {
  1100. bool bValid = false;
  1101. switch (eState) {
  1102. case Started:
  1103. bPersist = PersistStarted;
  1104. bValid = PersistStartedValid;
  1105. break;
  1106. case Stopped:
  1107. bPersist = PersistStopped;
  1108. bValid = PersistStoppedValid;
  1109. break;
  1110. case Suspended:
  1111. bPersist = PersistSuspended;
  1112. bValid = PersistSuspendedValid;
  1113. break;
  1114. default:
  1115. return false;
  1116. }
  1117. return (IsValid() && bValid);
  1118. }
  1119. /*
  1120. * Method:
  1121. * Description:
  1122. * Author: Created by shouse, 4.26.01
  1123. * Notes:
  1124. */
  1125. bool NLB_HostState::SetState (NLB_HostStateType eState) {
  1126. switch (eState) {
  1127. case Started:
  1128. case Stopped:
  1129. case Suspended:
  1130. State = eState;
  1131. break;
  1132. default:
  1133. return false;
  1134. }
  1135. return true;
  1136. }
  1137. /*
  1138. * Method:
  1139. * Description:
  1140. * Author: Created by shouse, 4.26.01
  1141. * Notes:
  1142. */
  1143. bool NLB_HostState::SetPersistence (NLB_HostStateType eState, bool bPersist) {
  1144. switch (eState) {
  1145. case Started:
  1146. PersistStarted = bPersist;
  1147. PersistStartedValid = true;
  1148. break;
  1149. case Stopped:
  1150. PersistStopped = bPersist;
  1151. PersistStoppedValid = true;
  1152. break;
  1153. case Suspended:
  1154. PersistSuspended = bPersist;
  1155. PersistSuspendedValid = true;
  1156. break;
  1157. default:
  1158. return false;
  1159. }
  1160. return true;
  1161. }
  1162. /*************************************************
  1163. * Class: NLB_PortRulePortRange *
  1164. *************************************************/
  1165. /*
  1166. * Method:
  1167. * Description:
  1168. * Author: Created by shouse, 4.26.01
  1169. * Notes:
  1170. */
  1171. NLB_PortRulePortRange::NLB_PortRulePortRange () {
  1172. Start = NLB_MAX_PORT + 1;
  1173. End = NLB_MAX_PORT + 1;
  1174. }
  1175. /*
  1176. * Method:
  1177. * Description:
  1178. * Author: Created by shouse, 4.26.01
  1179. * Notes:
  1180. */
  1181. NLB_PortRulePortRange::~NLB_PortRulePortRange () {
  1182. }
  1183. /*
  1184. * Method:
  1185. * Description:
  1186. * Author: Created by shouse, 4.26.01
  1187. * Notes:
  1188. */
  1189. void NLB_PortRulePortRange::Clear () {
  1190. Start = NLB_MAX_PORT + 1;
  1191. End = NLB_MAX_PORT + 1;
  1192. }
  1193. /*
  1194. * Method:
  1195. * Description:
  1196. * Author: Created by shouse, 4.26.01
  1197. * Notes:
  1198. */
  1199. bool NLB_PortRulePortRange::IsValid () {
  1200. return ((Start <= NLB_MAX_PORT) && (End <= NLB_MAX_PORT) && (Start <= End));
  1201. }
  1202. /*
  1203. * Method:
  1204. * Description:
  1205. * Author: Created by shouse, 4.26.01
  1206. * Notes:
  1207. */
  1208. bool NLB_PortRulePortRange::GetPortRange (ULONG & start, ULONG & end) {
  1209. start = Start;
  1210. end = End;
  1211. return IsValid();
  1212. }
  1213. /*
  1214. * Method:
  1215. * Description:
  1216. * Author: Created by shouse, 4.26.01
  1217. * Notes:
  1218. */
  1219. bool NLB_PortRulePortRange::SetPortRange (ULONG start, ULONG end) {
  1220. if ((start > NLB_MAX_PORT) || (end > NLB_MAX_PORT) || (start > end)) return false;
  1221. Start = start;
  1222. End = end;
  1223. return true;
  1224. }
  1225. /*************************************************
  1226. * Class: NLB_PortRuleState *
  1227. *************************************************/
  1228. /*
  1229. * Method:
  1230. * Description:
  1231. * Author: Created by shouse, 4.26.01
  1232. * Notes:
  1233. */
  1234. NLB_PortRuleState::NLB_PortRuleState () {
  1235. State = Invalid;
  1236. }
  1237. /*
  1238. * Method:
  1239. * Description:
  1240. * Author: Created by shouse, 4.26.01
  1241. * Notes:
  1242. */
  1243. NLB_PortRuleState::~NLB_PortRuleState () {
  1244. }
  1245. /*
  1246. * Method:
  1247. * Description:
  1248. * Author: Created by shouse, 4.26.01
  1249. * Notes:
  1250. */
  1251. bool NLB_PortRuleState::IsValid () {
  1252. return (State != Invalid);
  1253. }
  1254. /*
  1255. * Method:
  1256. * Description:
  1257. * Author: Created by shouse, 4.26.01
  1258. * Notes:
  1259. */
  1260. void NLB_PortRuleState::Clear () {
  1261. State = Invalid;
  1262. }
  1263. /*
  1264. * Method:
  1265. * Description:
  1266. * Author: Created by shouse, 4.26.01
  1267. * Notes:
  1268. */
  1269. bool NLB_PortRuleState::GetState (NLB_PortRuleStateType & eState) {
  1270. eState = State;
  1271. return IsValid();
  1272. }
  1273. /*
  1274. * Method:
  1275. * Description:
  1276. * Author: Created by shouse, 4.26.01
  1277. * Notes:
  1278. */
  1279. bool NLB_PortRuleState::SetState (NLB_PortRuleStateType eState) {
  1280. switch (eState) {
  1281. case Enabled:
  1282. case Disabled:
  1283. case Draining:
  1284. State = eState;
  1285. break;
  1286. default:
  1287. return false;
  1288. }
  1289. return true;
  1290. }
  1291. /*************************************************
  1292. * Class: NLB_PortRuleProtocol *
  1293. *************************************************/
  1294. /*
  1295. * Method:
  1296. * Description:
  1297. * Author: Created by shouse, 4.26.01
  1298. * Notes:
  1299. */
  1300. NLB_PortRuleProtocol::NLB_PortRuleProtocol () {
  1301. Protocol = Invalid;
  1302. }
  1303. /*
  1304. * Method:
  1305. * Description:
  1306. * Author: Created by shouse, 4.26.01
  1307. * Notes:
  1308. */
  1309. NLB_PortRuleProtocol::~NLB_PortRuleProtocol () {
  1310. }
  1311. /*
  1312. * Method:
  1313. * Description:
  1314. * Author: Created by shouse, 4.26.01
  1315. * Notes:
  1316. */
  1317. bool NLB_PortRuleProtocol::IsValid () {
  1318. return (Protocol != Invalid);
  1319. }
  1320. /*
  1321. * Method:
  1322. * Description:
  1323. * Author: Created by shouse, 4.26.01
  1324. * Notes:
  1325. */
  1326. void NLB_PortRuleProtocol::Clear () {
  1327. Protocol = Invalid;
  1328. }
  1329. /*
  1330. * Method:
  1331. * Description:
  1332. * Author: Created by shouse, 4.26.01
  1333. * Notes:
  1334. */
  1335. bool NLB_PortRuleProtocol::GetProtocol (NLB_PortRuleProtocolType & eProtocol) {
  1336. eProtocol = Protocol;
  1337. return IsValid();
  1338. }
  1339. /*
  1340. * Method:
  1341. * Description:
  1342. * Author: Created by shouse, 4.26.01
  1343. * Notes:
  1344. */
  1345. bool NLB_PortRuleProtocol::SetProtocol (NLB_PortRuleProtocolType eProtocol) {
  1346. switch (eProtocol) {
  1347. case TCP:
  1348. case UDP:
  1349. case Both:
  1350. Protocol = eProtocol;
  1351. break;
  1352. default:
  1353. return false;
  1354. }
  1355. return true;
  1356. }
  1357. /*************************************************
  1358. * Class: NLB_PortRuleAffinity *
  1359. *************************************************/
  1360. /*
  1361. * Method:
  1362. * Description:
  1363. * Author: Created by shouse, 4.26.01
  1364. * Notes:
  1365. */
  1366. NLB_PortRuleAffinity::NLB_PortRuleAffinity () {
  1367. Affinity = Invalid;
  1368. }
  1369. /*
  1370. * Method:
  1371. * Description:
  1372. * Author: Created by shouse, 4.26.01
  1373. * Notes:
  1374. */
  1375. NLB_PortRuleAffinity::~NLB_PortRuleAffinity () {
  1376. }
  1377. /*
  1378. * Method:
  1379. * Description:
  1380. * Author: Created by shouse, 4.26.01
  1381. * Notes:
  1382. */
  1383. bool NLB_PortRuleAffinity::IsValid () {
  1384. return (Affinity != Invalid);
  1385. }
  1386. /*
  1387. * Method:
  1388. * Description:
  1389. * Author: Created by shouse, 4.26.01
  1390. * Notes:
  1391. */
  1392. void NLB_PortRuleAffinity::Clear () {
  1393. Affinity = Invalid;
  1394. }
  1395. /*
  1396. * Method:
  1397. * Description:
  1398. * Author: Created by shouse, 4.26.01
  1399. * Notes:
  1400. */
  1401. bool NLB_PortRuleAffinity::GetAffinity (NLB_PortRuleAffinityType & eAffinity) {
  1402. eAffinity = Affinity;
  1403. return IsValid();
  1404. }
  1405. /*
  1406. * Method:
  1407. * Description:
  1408. * Author: Created by shouse, 4.26.01
  1409. * Notes:
  1410. */
  1411. bool NLB_PortRuleAffinity::SetAffinity (NLB_PortRuleAffinityType eAffinity) {
  1412. switch (eAffinity) {
  1413. case None:
  1414. case Single:
  1415. case ClassC:
  1416. Affinity = eAffinity;
  1417. break;
  1418. default:
  1419. return false;
  1420. }
  1421. return true;
  1422. }
  1423. /*************************************************
  1424. * Class: NLB_PortRuleFilteringMode *
  1425. *************************************************/
  1426. /*
  1427. * Method:
  1428. * Description:
  1429. * Author: Created by shouse, 4.26.01
  1430. * Notes:
  1431. */
  1432. NLB_PortRuleFilteringMode::NLB_PortRuleFilteringMode () {
  1433. Mode = Invalid;
  1434. }
  1435. /*
  1436. * Method:
  1437. * Description:
  1438. * Author: Created by shouse, 4.26.01
  1439. * Notes:
  1440. */
  1441. NLB_PortRuleFilteringMode::~NLB_PortRuleFilteringMode () {
  1442. }
  1443. /*
  1444. * Method:
  1445. * Description:
  1446. * Author: Created by shouse, 4.26.01
  1447. * Notes:
  1448. */
  1449. bool NLB_PortRuleFilteringMode::IsValid () {
  1450. return (Mode != Invalid);
  1451. }
  1452. /*
  1453. * Method:
  1454. * Description:
  1455. * Author: Created by shouse, 4.26.01
  1456. * Notes:
  1457. */
  1458. void NLB_PortRuleFilteringMode::Clear () {
  1459. Mode = Invalid;
  1460. }
  1461. /*
  1462. * Method:
  1463. * Description:
  1464. * Author: Created by shouse, 4.26.01
  1465. * Notes:
  1466. */
  1467. bool NLB_PortRuleFilteringMode::GetMode (NLB_PortRuleFilteringModeType & eMode) {
  1468. eMode = Mode;
  1469. return IsValid();
  1470. }
  1471. /*
  1472. * Method:
  1473. * Description:
  1474. * Author: Created by shouse, 4.26.01
  1475. * Notes:
  1476. */
  1477. bool NLB_PortRuleFilteringMode::SetMode (NLB_PortRuleFilteringModeType eMode) {
  1478. switch (eMode) {
  1479. case Single:
  1480. case Multiple:
  1481. case Disabled:
  1482. Mode = eMode;
  1483. break;
  1484. default:
  1485. return false;
  1486. }
  1487. return true;
  1488. }
  1489. /*************************************************
  1490. * Class: NLB_PortRulePriority *
  1491. *************************************************/
  1492. /*
  1493. * Method:
  1494. * Description:
  1495. * Author: Created by shouse, 4.26.01
  1496. * Notes:
  1497. */
  1498. NLB_PortRulePriority::NLB_PortRulePriority () {
  1499. Priority = NLB_MAX_PRIORITY + 1;
  1500. }
  1501. /*
  1502. * Method:
  1503. * Description:
  1504. * Author: Created by shouse, 4.26.01
  1505. * Notes:
  1506. */
  1507. NLB_PortRulePriority::~NLB_PortRulePriority () {
  1508. }
  1509. /*
  1510. * Method:
  1511. * Description:
  1512. * Author: Created by shouse, 4.26.01
  1513. * Notes:
  1514. */
  1515. bool NLB_PortRulePriority::IsValid () {
  1516. return ((Priority <= NLB_MAX_PRIORITY) && (Priority >= NLB_MIN_PRIORITY));
  1517. }
  1518. /*
  1519. * Method:
  1520. * Description:
  1521. * Author: Created by shouse, 4.26.01
  1522. * Notes:
  1523. */
  1524. void NLB_PortRulePriority::Clear () {
  1525. Priority = NLB_MAX_PRIORITY + 1;
  1526. Host.Clear();
  1527. }
  1528. /*
  1529. * Method:
  1530. * Description:
  1531. * Author: Created by shouse, 4.26.01
  1532. * Notes:
  1533. */
  1534. bool NLB_PortRulePriority::GetPriority (ULONG & priority) {
  1535. priority = Priority;
  1536. return IsValid();
  1537. }
  1538. /*
  1539. * Method:
  1540. * Description:
  1541. * Author: Created by shouse, 4.26.01
  1542. * Notes:
  1543. */
  1544. bool NLB_PortRulePriority::GetHost (PWCHAR pName, ULONG length) {
  1545. return Host.GetName(pName, length);
  1546. }
  1547. /*
  1548. * Method:
  1549. * Description:
  1550. * Author: Created by shouse, 4.26.01
  1551. * Notes:
  1552. */
  1553. bool NLB_PortRulePriority::SetPriority (ULONG priority) {
  1554. if ((priority > NLB_MAX_PRIORITY) || (priority < NLB_MIN_PRIORITY)) return false;
  1555. Priority = priority;
  1556. return true;
  1557. }
  1558. /*
  1559. * Method:
  1560. * Description:
  1561. * Author: Created by shouse, 4.26.01
  1562. * Notes:
  1563. */
  1564. bool NLB_PortRulePriority::SetHost (PWCHAR pName) {
  1565. return Host.SetName(pName);
  1566. }
  1567. /*************************************************
  1568. * Class: NLB_PortRuleLoadWeight *
  1569. *************************************************/
  1570. /*
  1571. * Method:
  1572. * Description:
  1573. * Author: Created by shouse, 4.26.01
  1574. * Notes:
  1575. */
  1576. NLB_PortRuleLoadWeight::NLB_PortRuleLoadWeight () {
  1577. Weight = NLB_MAX_LOADWEIGHT + 1;
  1578. }
  1579. /*
  1580. * Method:
  1581. * Description:
  1582. * Author: Created by shouse, 4.26.01
  1583. * Notes:
  1584. */
  1585. NLB_PortRuleLoadWeight::~NLB_PortRuleLoadWeight () {
  1586. }
  1587. /*
  1588. * Method:
  1589. * Description:
  1590. * Author: Created by shouse, 4.26.01
  1591. * Notes:
  1592. */
  1593. bool NLB_PortRuleLoadWeight::IsValid () {
  1594. return (Weight <= NLB_MAX_LOADWEIGHT);
  1595. }
  1596. /*
  1597. * Method:
  1598. * Description:
  1599. * Author: Created by shouse, 4.26.01
  1600. * Notes:
  1601. */
  1602. void NLB_PortRuleLoadWeight::Clear () {
  1603. Weight = NLB_MAX_LOADWEIGHT + 1;
  1604. Host.Clear();
  1605. }
  1606. /*
  1607. * Method:
  1608. * Description:
  1609. * Author: Created by shouse, 4.26.01
  1610. * Notes:
  1611. */
  1612. bool NLB_PortRuleLoadWeight::GetWeight (ULONG & weight) {
  1613. weight = Weight;
  1614. return IsValid();
  1615. }
  1616. /*
  1617. * Method:
  1618. * Description:
  1619. * Author: Created by shouse, 4.26.01
  1620. * Notes:
  1621. */
  1622. bool NLB_PortRuleLoadWeight::GetHost (PWCHAR pName, ULONG length) {
  1623. return Host.GetName(pName, length);
  1624. }
  1625. /*
  1626. * Method:
  1627. * Description:
  1628. * Author: Created by shouse, 4.26.01
  1629. * Notes:
  1630. */
  1631. bool NLB_PortRuleLoadWeight::SetWeight (ULONG weight) {
  1632. if (weight > NLB_MAX_LOADWEIGHT) return false;
  1633. Weight = weight;
  1634. return true;
  1635. }
  1636. /*
  1637. * Method:
  1638. * Description:
  1639. * Author: Created by shouse, 4.26.01
  1640. * Notes:
  1641. */
  1642. bool NLB_PortRuleLoadWeight::SetHost (PWCHAR pName) {
  1643. return Host.SetName(pName);
  1644. }