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.

321 lines
9.9 KiB

  1. //-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: D L G O P T. H
  7. //
  8. // Contents: Declaration for CTcpOptionsPage, CIpSecDialog
  9. //
  10. // Notes: CTcpOptionsPage is the Tcpip options page,
  11. // The other classes are pop-up dislogs for each option
  12. // on this page.
  13. //
  14. // Author: tongl 29 Nov 1997
  15. //-----------------------------------------------------------------------
  16. #pragma once
  17. #include <ncxbase.h>
  18. #include <ncatlps.h>
  19. #include "ipctrl.h"
  20. #define FILTER_ADD_LIMIT 5
  21. struct OPTION_ITEM_DATA
  22. {
  23. INT iOptionId;
  24. PWSTR szName;
  25. PWSTR szDesc;
  26. };
  27. // The options page
  28. class CTcpOptionsPage : public CPropSheetPage
  29. {
  30. public:
  31. // Declare the message map
  32. BEGIN_MSG_MAP(CTcpOptionsPage)
  33. // Initialize dialog
  34. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  35. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
  36. MESSAGE_HANDLER(WM_HELP, OnHelp)
  37. // Property page notification message handlers
  38. NOTIFY_CODE_HANDLER(PSN_APPLY, OnApply)
  39. NOTIFY_CODE_HANDLER(PSN_KILLACTIVE, OnKillActive)
  40. NOTIFY_CODE_HANDLER(PSN_SETACTIVE, OnActive)
  41. NOTIFY_CODE_HANDLER(PSN_RESET, OnCancel)
  42. NOTIFY_CODE_HANDLER(PSN_QUERYCANCEL, OnQueryCancel)
  43. // Control message handlers
  44. COMMAND_ID_HANDLER(IDC_OPT_PROPERTIES, OnProperties)
  45. NOTIFY_CODE_HANDLER(LVN_ITEMCHANGED, OnItemChanged)
  46. NOTIFY_CODE_HANDLER(NM_DBLCLK, OnDbClick)
  47. END_MSG_MAP()
  48. // Constructors/Destructors
  49. CTcpOptionsPage(CTcpAddrPage * pTcpAddrPage,
  50. ADAPTER_INFO * pAdapterDlg,
  51. GLOBAL_INFO * pGlbDlg,
  52. const DWORD * adwHelpIDs = NULL);
  53. ~CTcpOptionsPage();
  54. // Interface
  55. public:
  56. // message map functions
  57. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  58. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  59. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  60. // notify handlers for the property page
  61. LRESULT OnApply(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  62. LRESULT OnKillActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  63. LRESULT OnActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  64. LRESULT OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  65. LRESULT OnQueryCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  66. // command and notification handlers
  67. LRESULT OnProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  68. LRESULT OnItemChanged(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  69. LRESULT OnDbClick(int idCtrl, LPNMHDR pnmh, BOOL& fHandled);
  70. // Declare friend class
  71. friend class CIpSecDialog;
  72. friend class CFilterDialog;
  73. // Implementation
  74. private:
  75. // Inlines
  76. BOOL IsModified() {return m_fModified;}
  77. void SetModifiedTo(BOOL bState) {m_fModified = bState;}
  78. void PageModified() { m_fModified = TRUE; PropSheet_Changed(GetParent(), m_hWnd);}
  79. void LvProperties(HWND hwndList);
  80. // data members
  81. CTcpipcfg * m_ptcpip;
  82. CTcpAddrPage * m_pParentDlg;
  83. ADAPTER_INFO * m_pAdapterInfo;
  84. GLOBAL_INFO * m_pGlbInfo;
  85. const DWORD* m_adwHelpIDs;
  86. BOOL m_fModified;
  87. // Has any of the property dialogs been modified ?
  88. BOOL m_fPropDlgModified;
  89. BOOL m_fIpsecPolicySet;
  90. };
  91. /* IP Security dialog is removed
  92. // The IP Security dialog
  93. class CIpSecDialog : public CDialogImpl<CIpSecDialog>
  94. {
  95. public:
  96. enum { IDD = IDD_IPSEC };
  97. BEGIN_MSG_MAP(CIpSecDialog)
  98. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  99. MESSAGE_HANDLER(WM_DESTROY, OnDestroyDialog);
  100. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  101. MESSAGE_HANDLER(WM_HELP, OnHelp);
  102. COMMAND_ID_HANDLER(IDOK, OnOk);
  103. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  104. // command handlers
  105. COMMAND_ID_HANDLER(IDC_RAD_IPSEC_NOIPSEC, OnNoIpsec);
  106. COMMAND_ID_HANDLER(IDC_RAD_IPSEC_CUSTOM, OnUseCustomPolicy);
  107. COMMAND_ID_HANDLER(IDC_CMB_IPSEC_POLICY_LIST, OnSelectCustomPolicy);
  108. END_MSG_MAP()
  109. //
  110. public:
  111. CIpSecDialog( CTcpOptionsPage * pOptionsPage,
  112. GLOBAL_INFO * pGlbDlg,
  113. const DWORD* pamhidsHelp = NULL);
  114. ~CIpSecDialog();
  115. // Dialog creation overides
  116. public:
  117. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  118. LRESULT OnDestroyDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  119. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  120. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  121. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  122. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  123. LRESULT OnNoIpsec(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  124. LRESULT OnUseCustomPolicy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  125. LRESULT OnSelectCustomPolicy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  126. private:
  127. HRESULT HrGetDomainIpsecPolicy(BOOL * pfHasDomainIpsecPolicy,
  128. tstring * pszDomainIpsecPolicyName);
  129. HRESULT HrShowDomainIpsecPolicy(PCWSTR szDomainIpsecPolicyName);
  130. HRESULT HrShowLocalIpsecPolicy();
  131. HRESULT HrSelectActivePolicy(GUID * guidIpsecPol);
  132. BOOL m_fInInitDialog;
  133. CTcpOptionsPage * m_pParentDlg;
  134. GLOBAL_INFO * m_pGlobalInfo;
  135. const DWORD * m_adwHelpIDs;
  136. };
  137. */
  138. // Tcpip security (Trajon) dialogs
  139. class CFilterDialog;
  140. class CAddFilterDialog : public CDialogImpl<CAddFilterDialog>
  141. {
  142. public:
  143. enum { IDD = IDD_FILTER_ADD };
  144. BEGIN_MSG_MAP(CAddFilterDialog)
  145. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  146. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu);
  147. MESSAGE_HANDLER(WM_HELP, OnHelp);
  148. COMMAND_ID_HANDLER(IDOK, OnOk);
  149. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  150. COMMAND_ID_HANDLER(IDC_FILTERING_ADD_EDIT, OnFilterAddEdit);
  151. END_MSG_MAP()
  152. //
  153. public:
  154. CAddFilterDialog(CFilterDialog* pParentDlg, int ID, const DWORD* adwHelpIDs = NULL);
  155. ~CAddFilterDialog();
  156. // Dialog creation overides
  157. public:
  158. // Command Handlers
  159. public:
  160. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  161. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  162. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  163. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  164. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  165. LRESULT OnFilterAddEdit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  166. private:
  167. CFilterDialog* m_pParentDlg;
  168. int m_nId;
  169. HWND m_hList;
  170. const DWORD* m_adwHelpIDs;
  171. };
  172. class CFilterDialog : public CDialogImpl<CFilterDialog>
  173. {
  174. public:
  175. enum { IDD = IDD_FILTER };
  176. BEGIN_MSG_MAP(CFilterDialog)
  177. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
  178. MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
  179. MESSAGE_HANDLER(WM_HELP, OnHelp)
  180. COMMAND_ID_HANDLER(IDOK, OnOk);
  181. COMMAND_ID_HANDLER(IDCANCEL, OnCancel);
  182. // Enable Filtering checkbox
  183. COMMAND_ID_HANDLER(IDC_FILTERING_ENABLE, OnEnableFiltering);
  184. // The TCP ports radio buttons
  185. COMMAND_ID_HANDLER(IDC_FILTERING_FILTER_TCP, OnTcpPermit);
  186. COMMAND_ID_HANDLER(IDC_FILTERING_FILTER_TCP_SEL, OnTcpPermit);
  187. // The UDP ports radio buttons
  188. COMMAND_ID_HANDLER(IDC_FILTERING_FILTER_UDP, OnUdpPermit);
  189. COMMAND_ID_HANDLER(IDC_FILTERING_FILTER_UDP_SEL, OnUdpPermit);
  190. // The IP Protocols radio buttons
  191. COMMAND_ID_HANDLER(IDC_FILTERING_FILTER_IP, OnIpPermit);
  192. COMMAND_ID_HANDLER(IDC_FILTERING_FILTER_IP_SEL, OnIpPermit);
  193. // Add buttons for TCP, UDP and IP
  194. COMMAND_ID_HANDLER(IDC_FILTERING_TCP_ADD, OnAdd);
  195. COMMAND_ID_HANDLER(IDC_FILTERING_UDP_ADD, OnAdd);
  196. COMMAND_ID_HANDLER(IDC_FILTERING_IP_ADD, OnAdd);
  197. // Remove buttons for TCP, UDP and IP
  198. COMMAND_ID_HANDLER(IDC_FILTERING_TCP_REMOVE, OnRemove);
  199. COMMAND_ID_HANDLER(IDC_FILTERING_UDP_REMOVE, OnRemove);
  200. COMMAND_ID_HANDLER(IDC_FILTERING_IP_REMOVE, OnRemove);
  201. END_MSG_MAP()
  202. friend class CAddFilterDialog;
  203. public:
  204. CFilterDialog( CTcpOptionsPage * pOptionsPage,
  205. GLOBAL_INFO * pGlbDlg,
  206. ADAPTER_INFO * pAdapterDlg,
  207. const DWORD* pamhidsHelp = NULL);
  208. ~CFilterDialog();
  209. // Dialog creation overrides
  210. public:
  211. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  212. LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  213. LRESULT OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled);
  214. LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  215. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  216. LRESULT OnEnableFiltering(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  217. LRESULT OnTcpPermit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  218. LRESULT OnUdpPermit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  219. LRESULT OnIpPermit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  220. LRESULT OnAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  221. LRESULT OnRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled);
  222. private:
  223. // help functions
  224. void SetInfo();
  225. void UpdateInfo();
  226. void EnableGroup(int nId, BOOL state);
  227. void SetButtons();
  228. // data members
  229. GLOBAL_INFO * m_pGlobalInfo;
  230. ADAPTER_INFO * m_pAdapterInfo;
  231. CTcpOptionsPage * m_pParentDlg;
  232. BOOL m_fModified;
  233. const DWORD * m_adwHelpIDs;
  234. HWND m_hlistTcp;
  235. HWND m_hlistUdp;
  236. HWND m_hlistIp;
  237. };