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.

296 lines
8.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 2002 **/
  4. /**********************************************************************/
  5. /*
  6. Servpp.h
  7. Server properties implementation file
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "mmsapp.h"
  12. #include "spdutil.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. //
  20. // CMmSAProperties holder
  21. //
  22. /////////////////////////////////////////////////////////////////////////////
  23. CMmSAProperties::CMmSAProperties
  24. (
  25. ITFSNode * pNode,
  26. IComponentData * pComponentData,
  27. ITFSComponentData * pTFSCompData,
  28. CMmSA * pSA,
  29. ISpdInfo * pSpdInfo,
  30. LPCTSTR pszSheetName
  31. ) : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  32. {
  33. //ASSERT(pFolderNode == GetContainerNode());
  34. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  35. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  36. Assert(pTFSCompData != NULL);
  37. m_spTFSCompData.Set(pTFSCompData);
  38. m_spSpdInfo.Set(pSpdInfo);
  39. m_SA = *pSA;
  40. m_bTheme = TRUE;
  41. }
  42. CMmSAProperties::~CMmSAProperties()
  43. {
  44. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  45. }
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CMmSAGenProp property page
  48. IMPLEMENT_DYNCREATE(CMmSAGenProp, CPropertyPageBase)
  49. CMmSAGenProp::CMmSAGenProp() : CPropertyPageBase(CMmSAGenProp::IDD)
  50. {
  51. //{{AFX_DATA_INIT(CMmSAGenProp)
  52. // NOTE: the ClassWizard will add member initialization here
  53. //}}AFX_DATA_INIT
  54. }
  55. CMmSAGenProp::~CMmSAGenProp()
  56. {
  57. }
  58. void CMmSAGenProp::DoDataExchange(CDataExchange* pDX)
  59. {
  60. CPropertyPageBase::DoDataExchange(pDX);
  61. //{{AFX_DATA_MAP(CMmSAGenProp)
  62. DDX_Control(pDX, IDC_MMSA_LIST_QM, m_listQmSAs);
  63. //}}AFX_DATA_MAP
  64. }
  65. BEGIN_MESSAGE_MAP(CMmSAGenProp, CPropertyPageBase)
  66. //{{AFX_MSG_MAP(CMmSAGenProp)
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CMmSAGenProp message handlers
  71. BOOL CMmSAGenProp::OnInitDialog()
  72. {
  73. CPropertyPageBase::OnInitDialog();
  74. PopulateSAInfo();
  75. LoadQmSAs();
  76. SetDirty(FALSE);
  77. return TRUE; // return TRUE unless you set the focus to a control
  78. // EXCEPTION: OCX Property Pages should return FALSE
  79. }
  80. void CMmSAGenProp::PopulateSAInfo()
  81. {
  82. CString st;
  83. CMmSAProperties * pSAProp;
  84. CMmSA * pSA;
  85. CMmFilterInfo * pFltrInfo;
  86. pSAProp = (CMmSAProperties *) GetHolder();
  87. Assert(pSAProp);
  88. pSAProp->GetSAInfo(&pSA);
  89. AddressToString(pSA->m_MeAddr, &st);
  90. GetDlgItem(IDC_MMSA_ME)->SetWindowText(st);
  91. AddressToString(pSA->m_PeerAddr, &st);
  92. GetDlgItem(IDC_MMSA_PEER)->SetWindowText(st);
  93. MmAuthToString(pSA->m_Auth, &st);
  94. GetDlgItem(IDC_MMSA_AUTH)->SetWindowText(st);
  95. st = pSA->m_stPolicyName;
  96. if ( pSA->m_dwPolFlags & IPSEC_MM_POLICY_DEFAULT_POLICY )
  97. {
  98. AfxFormatString1(st, IDS_POL_DEFAULT, (LPCTSTR) pSA->m_stPolicyName);
  99. }
  100. GetDlgItem(IDC_MMSA_IKE_POL)->SetWindowText(st);
  101. DoiEspAlgorithmToString(pSA->m_SelectedOffer.m_EncryptionAlgorithm, &st);
  102. GetDlgItem(IDC_MMSA_CONF)->SetWindowText(st);
  103. DoiAuthAlgorithmToString(pSA->m_SelectedOffer.m_HashingAlgorithm, &st);
  104. GetDlgItem(IDC_MMSA_INTEG)->SetWindowText(st);
  105. DhGroupToString(pSA->m_SelectedOffer.m_dwDHGroup, &st);
  106. GetDlgItem(IDC_MMSA_DH_GRP)->SetWindowText(st);
  107. KeyLifetimeToString(pSA->m_SelectedOffer.m_Lifetime, &st);
  108. GetDlgItem(IDC_MMSA_KEYLIFE)->SetWindowText(st);
  109. }
  110. void CMmSAGenProp::LoadQmSAs()
  111. {
  112. int nWidth;
  113. CString st;
  114. st.LoadString(IDS_COL_QM_SA_SRC);
  115. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  116. m_listQmSAs.InsertColumn(0, st, LVCFMT_LEFT, nWidth);
  117. st.LoadString(IDS_COL_QM_SA_DEST);
  118. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  119. m_listQmSAs.InsertColumn(1, st, LVCFMT_LEFT, nWidth);
  120. st.LoadString(IDS_COL_QM_SA_SRC_PORT);
  121. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  122. m_listQmSAs.InsertColumn(2, st, LVCFMT_LEFT, nWidth);
  123. st.LoadString(IDS_COL_QM_SA_DES_PORT);
  124. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  125. m_listQmSAs.InsertColumn(3, st, LVCFMT_LEFT, nWidth);
  126. st.LoadString(IDS_COL_QM_SA_PROT);
  127. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  128. m_listQmSAs.InsertColumn(4, st, LVCFMT_LEFT, nWidth);
  129. st.LoadString(IDS_COL_QM_SA_POL);
  130. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  131. m_listQmSAs.InsertColumn(5, st, LVCFMT_LEFT, nWidth);
  132. st.LoadString(IDS_COL_QM_SA_AUTH);
  133. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  134. m_listQmSAs.InsertColumn(6, st, LVCFMT_LEFT, nWidth);
  135. st.LoadString(IDS_COL_QM_SA_CONF);
  136. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  137. m_listQmSAs.InsertColumn(7, st, LVCFMT_LEFT, nWidth);
  138. st.LoadString(IDS_COL_QM_SA_INTEGRITY);
  139. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  140. m_listQmSAs.InsertColumn(8, st, LVCFMT_LEFT, nWidth);
  141. st.LoadString(IDS_COL_QM_SA_MY_TNL);
  142. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  143. m_listQmSAs.InsertColumn(9, st, LVCFMT_LEFT, nWidth);
  144. st.LoadString(IDS_COL_QM_SA_PEER_TNL);
  145. nWidth = m_listQmSAs.GetStringWidth((LPCTSTR)st) + 20;
  146. m_listQmSAs.InsertColumn(10, st, LVCFMT_LEFT, nWidth);
  147. CMmSAProperties * pSAProp;
  148. CMmSA * pSA;
  149. pSAProp = (CMmSAProperties *) GetHolder();
  150. Assert(pSAProp);
  151. pSAProp->GetSAInfo(&pSA);
  152. SPISpdInfo spSpdInfo;
  153. pSAProp->GetSpdInfo(&spSpdInfo);
  154. CQmSAArray arrQmSAs;
  155. spSpdInfo->EnumQmSAsFromMmSA(*pSA, &arrQmSAs);
  156. int nRows = 0;
  157. for (int i = 0; i < arrQmSAs.GetSize(); i++)
  158. {
  159. nRows = m_listQmSAs.InsertItem(nRows, _T(""));
  160. if (-1 != nRows)
  161. {
  162. AddressToString(arrQmSAs[i]->m_QmDriverFilter.m_SrcAddr, &st);
  163. m_listQmSAs.SetItemText(nRows, 0, st);
  164. AddressToString(arrQmSAs[i]->m_QmDriverFilter.m_DesAddr, &st);
  165. m_listQmSAs.SetItemText(nRows, 1, st);
  166. PortToString(arrQmSAs[i]->m_QmDriverFilter.m_SrcPort, &st);
  167. m_listQmSAs.SetItemText(nRows, 2, st);
  168. PortToString(arrQmSAs[i]->m_QmDriverFilter.m_DesPort, &st);
  169. m_listQmSAs.SetItemText(nRows, 3, st);
  170. ProtocolToString(arrQmSAs[i]->m_QmDriverFilter.m_Protocol, &st);
  171. m_listQmSAs.SetItemText(nRows, 4, st);
  172. st = arrQmSAs[i]->m_stPolicyName;
  173. if ( arrQmSAs[i]->m_dwPolFlags & IPSEC_QM_POLICY_DEFAULT_POLICY )
  174. {
  175. AfxFormatString1(st, IDS_POL_DEFAULT_RESPONSE, (LPCTSTR) arrQmSAs[i]->m_stPolicyName);
  176. }
  177. m_listQmSAs.SetItemText(nRows, 5, st);
  178. QmAlgorithmToString(QM_ALGO_AUTH, &arrQmSAs[i]->m_SelectedOffer, &st);
  179. m_listQmSAs.SetItemText(nRows, 6, st);
  180. QmAlgorithmToString(QM_ALGO_ESP_CONF, &arrQmSAs[i]->m_SelectedOffer, &st);
  181. m_listQmSAs.SetItemText(nRows, 7, st);
  182. QmAlgorithmToString(QM_ALGO_ESP_INTEG, &arrQmSAs[i]->m_SelectedOffer, &st);
  183. m_listQmSAs.SetItemText(nRows, 8, st);
  184. TnlEpToString(arrQmSAs[i]->m_QmDriverFilter.m_Type,
  185. arrQmSAs[i]->m_QmDriverFilter.m_MyTunnelEndpt,
  186. &st);
  187. m_listQmSAs.SetItemText(nRows, 9, st);
  188. TnlEpToString(arrQmSAs[i]->m_QmDriverFilter.m_Type,
  189. arrQmSAs[i]->m_QmDriverFilter.m_PeerTunnelEndpt,
  190. &st);
  191. m_listQmSAs.SetItemText(nRows, 10, st);
  192. }
  193. nRows++;
  194. }
  195. if ( nRows > 0 )
  196. {
  197. //select the first item
  198. m_listQmSAs.SetFocus();
  199. m_listQmSAs.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
  200. }
  201. FreeItemsAndEmptyArray(arrQmSAs);
  202. }
  203. BOOL CMmSAGenProp::OnApply()
  204. {
  205. if (!IsDirty())
  206. return TRUE;
  207. UpdateData();
  208. //TODO
  209. //Do nothing at this time
  210. //CPropertyPageBase::OnApply();
  211. return TRUE;
  212. }
  213. BOOL CMmSAGenProp::OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask)
  214. {
  215. return FALSE;
  216. }