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.

173 lines
5.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. addrpool.h
  7. FILE HISTORY:
  8. */
  9. #if !defined _ADDRPOOL_H_
  10. #define _ADDRPOOL_H_
  11. #if _MSC_VER >= 1000
  12. #pragma once
  13. #endif // _MSC_VER >= 1000
  14. #include "listctrl.h"
  15. #include "dialog.h"
  16. #include "ipctrl.h"
  17. /*---------------------------------------------------------------------------
  18. Class: AddressPoolInfo
  19. This class holds the information pertaining to the address pool.
  20. Basically, it holds the start and end addresses (in NETWORK order).
  21. ---------------------------------------------------------------------------*/
  22. class AddressPoolInfo
  23. {
  24. public:
  25. AddressPoolInfo() :
  26. m_netStart(0),
  27. m_netEnd(0),
  28. m_netAddress(0),
  29. m_netMask(0),
  30. m_dwKey(0) {};
  31. DWORD m_netStart;
  32. DWORD m_netEnd;
  33. DWORD m_netAddress;
  34. DWORD m_netMask;
  35. DWORD m_dwKey;
  36. DWORD GetNumberOfAddresses()
  37. { return ntohl(m_netEnd) - ntohl(m_netStart) + 1; }
  38. // Calculate the address and the mask from the start/end address
  39. BOOL Calc(DWORD *pdwAddress, DWORD *pdwMask);
  40. DWORD GetNewKey();
  41. // This is the back door provided for compatibility until the
  42. // service is fixed. You can set the address and mask and
  43. // add an entry (I will backfill the start/end address).
  44. // dwAddress and dwMask are in NETWORK order.
  45. void SetAddressAndMask(DWORD dwAddress, DWORD dwMask);
  46. void SetStartAndEnd(DWORD dwStart, DWORD dwEnd);
  47. };
  48. typedef CList<AddressPoolInfo, AddressPoolInfo &> AddressPoolListBase;
  49. class AddressPoolList : public AddressPoolListBase
  50. {
  51. public:
  52. AddressPoolList()
  53. : m_fMultipleAddressPools(FALSE)
  54. {
  55. }
  56. // This function checks to see if there are any conflicts
  57. // with any other address pools (we don't allow overlaps).
  58. // Returns S_OK if it is ok.
  59. // Else if is a success code, it is a string id of an error
  60. // Else if is a failure code, it is an error code
  61. HRESULT HrIsValidAddressPool(AddressPoolInfo *pInfo);
  62. // This will return TRUE if address pools are supported.
  63. // This will return FALSE if the old style, single address
  64. // pools are used.
  65. // This will not be set correctly until LoadFromReg() is called.
  66. BOOL FUsesMultipleAddressPools();
  67. // Load the information from the regsitry. If the StaticAddressPool
  68. // key does not exist, read from the old address/mask keys.
  69. HRESULT LoadFromReg(HKEY hkeyRasIP, DWORD dwBuildNo);
  70. // Save the information to the registry. If the StaticAddressPool
  71. // key does not exist, write out the first address in the address pool
  72. // to the old address/mask keys.
  73. HRESULT SaveToReg(HKEY hkeyRasIP, DWORD dwBuildNo);
  74. protected:
  75. BOOL m_fMultipleAddressPools;
  76. };
  77. // Displays the long version of the address pool control. This
  78. // will show the start/stop/count/address/mask columns.
  79. // The short version shows the start/stop/count columns. The short
  80. // version is intended for the wizard pages.
  81. #define ADDRPOOL_LONG 0x01
  82. HRESULT InitializeAddressPoolListControl(CListCtrl *pListCtrl,
  83. LPARAM flags,
  84. AddressPoolList *pList);
  85. void OnNewAddressPool(HWND hWnd,
  86. CListCtrl *pList,
  87. LPARAM flags,
  88. AddressPoolList *pPoolList);
  89. void OnEditAddressPool(HWND hWnd,
  90. CListCtrl *pList,
  91. LPARAM flags,
  92. AddressPoolList *pPoolList);
  93. void OnDeleteAddressPool(HWND hWnd,
  94. CListCtrl *pList,
  95. LPARAM flags,
  96. AddressPoolList *pPoolList);
  97. class CAddressPoolDialog : public CBaseDialog
  98. {
  99. public:
  100. CAddressPoolDialog(AddressPoolInfo *pPool,
  101. AddressPoolList *pPoolList,
  102. BOOL fCreate);
  103. protected:
  104. virtual VOID DoDataExchange(CDataExchange *pDX);
  105. virtual BOOL OnInitDialog();
  106. virtual void OnOK();
  107. afx_msg void OnChangeStartAddress();
  108. afx_msg void OnChangeEndAddress();
  109. afx_msg void OnChangeRange();
  110. afx_msg void OnKillFocusStartAddress();
  111. afx_msg void OnKillFocusEndAddress();
  112. void GenerateRange();
  113. BOOL m_fCreate;
  114. BOOL m_fReady;
  115. AddressPoolInfo * m_pPool;
  116. AddressPoolList * m_pPoolList;
  117. IPControl m_ipStartAddress;
  118. IPControl m_ipEndAddress;
  119. DECLARE_MESSAGE_MAP()
  120. };
  121. /*---------------------------------------------------------------------------
  122. This enum defines the columns for Address pool controls.
  123. ---------------------------------------------------------------------------*/
  124. enum
  125. {
  126. IPPOOLCOL_START = 0,
  127. IPPOOLCOL_END,
  128. IPPOOLCOL_RANGE,
  129. IPPOOLCOL_IPADDRESS,
  130. IPPOOLCOL_MASK,
  131. IPPOOLCOL_COUNT,
  132. };
  133. #endif // !defined _ADDRPOOL_H_