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.

1593 lines
42 KiB

  1. ////////////////////////////////////////////////////////////////////
  2. // Module: Static/StaticShowList.cpp
  3. //
  4. // Purpose: Static Module Implementation.
  5. //
  6. // Developers Name: Surya
  7. //
  8. // History:
  9. //
  10. // Date Author Comments
  11. // 10-8-2001 Surya Initial Version. SCM Base line 1.0
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #include "nshipsec.h"
  15. extern HINSTANCE g_hModule;
  16. extern STORAGELOCATION g_StorageLocation;
  17. ////////////////////////////////////////////////////////////////////
  18. //
  19. //Function: PrintPolicyList()
  20. //
  21. //Date of Creation: 21st Aug 2001
  22. //
  23. //Parameters:
  24. // IN PIPSEC_POLICY_DATA pPolicy,
  25. // IN BOOL bVerb,
  26. // IN BOOL bAssigned,
  27. // IN BOOL bWide
  28. //Return: DWORD
  29. //
  30. //Description:
  31. // This function prints out the Policy information.
  32. //
  33. //Revision History:
  34. //
  35. //Date Author Comments
  36. //
  37. ////////////////////////////////////////////////////////////////////
  38. DWORD
  39. PrintPolicyList(
  40. IN PIPSEC_POLICY_DATA pPolicy,
  41. IN BOOL bVerb,
  42. IN BOOL bAssigned,
  43. IN BOOL bWide
  44. )
  45. {
  46. _TCHAR pszGUIDStr[BUFFER_SIZE]={0};
  47. _TCHAR pszStrTime[BUFFER_SIZE]={0};
  48. _TCHAR pszStrTruncated[BUFFER_SIZE]={0};
  49. DWORD i=0,k=0,dwReturn = ERROR_SUCCESS;
  50. BOOL bDsPolAssigned = FALSE;
  51. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_NEWLINE);
  52. // print name
  53. if(pPolicy->pszIpsecName)
  54. {
  55. TruncateString(pPolicy->pszIpsecName,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  56. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_NAME_STR,pszStrTruncated);
  57. }
  58. // print desc
  59. if(pPolicy->pszDescription)
  60. {
  61. TruncateString(pPolicy->pszDescription,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  62. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_STR,pszStrTruncated);
  63. }
  64. else
  65. {
  66. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_NONE);
  67. }
  68. if (bVerb) // storage info
  69. {
  70. dwReturn = PrintStorageInfoList(FALSE);
  71. if(dwReturn == ERROR_OUTOFMEMORY)
  72. {
  73. BAIL_OUT;
  74. }
  75. }
  76. //last modified time
  77. FormatTime((time_t)pPolicy->dwWhenChanged, pszStrTime);
  78. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_LASTMODIFIED,pszStrTime);
  79. if(bVerb)
  80. {
  81. i=StringFromGUID2(pPolicy->PolicyIdentifier,pszGUIDStr,BUFFER_SIZE);
  82. if(i>0 && (_tcscmp(pszGUIDStr,_TEXT(""))!=0))
  83. {
  84. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_GUID,pszGUIDStr);
  85. }
  86. }
  87. //whether the policy is active
  88. if(g_StorageLocation.dwLocation !=IPSEC_DIRECTORY_PROVIDER)
  89. {
  90. if(bAssigned)
  91. {
  92. if (
  93. ERROR_SUCCESS == IPSecIsDomainPolicyAssigned(&bDsPolAssigned) &&
  94. g_StorageLocation.dwLocation != IPSEC_PERSISTENT_PROVIDER &&
  95. bDsPolAssigned
  96. )
  97. {
  98. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_ASSIGNED_AD);
  99. }
  100. else
  101. {
  102. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_ASSIGNED_YES_STR);
  103. }
  104. }
  105. else
  106. {
  107. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_ASSIGNED_NO_STR);
  108. }
  109. }
  110. if(!bVerb)
  111. {
  112. if(pPolicy->pIpsecISAKMPData->ISAKMPPolicy.PfsIdentityRequired)
  113. {
  114. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_MMPFS_YES_STR);
  115. }
  116. else
  117. {
  118. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_MMPFS_NO_STR);
  119. }
  120. }
  121. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POLL_INTERVAL, (pPolicy->dwPollingInterval)/60);
  122. if (bVerb) //verbose mode
  123. {
  124. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMP_MMLIFETIME_STR,(pPolicy->pIpsecISAKMPData->pSecurityMethods[0].Lifetime.Seconds)/60 ,pPolicy->pIpsecISAKMPData->pSecurityMethods[0].QuickModeLimit);
  125. if(pPolicy->pIpsecISAKMPData->ISAKMPPolicy.PfsIdentityRequired)
  126. {
  127. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_MMPFS_YES_STR);
  128. }
  129. else
  130. {
  131. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_MMPFS_NO_STR);
  132. }
  133. if(pPolicy->pIpsecISAKMPData) // print the ISAKMP data structure details
  134. {
  135. PrintISAKMPDataList(pPolicy->pIpsecISAKMPData);
  136. }
  137. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_RULE_COUNT, pPolicy->dwNumNFACount);
  138. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_RULE_DETAILS_TITLE);
  139. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_RULE_DETAILS_UNDERLINE);
  140. //print rule data structures
  141. for (DWORD j=0;j<pPolicy->dwNumNFACount;j++)
  142. {
  143. if(pPolicy->ppIpsecNFAData[j])
  144. {
  145. k=StringFromGUID2(pPolicy->ppIpsecNFAData[j]->NFAIdentifier,pszGUIDStr,BUFFER_SIZE);
  146. if(k>0 && (_tcscmp(pszGUIDStr,_TEXT(""))!=0))
  147. {
  148. PrintMessageFromModule(g_hModule,SHW_STATIC_RULE_RULE_ID_GUID,j+1,pszGUIDStr);
  149. }
  150. dwReturn = PrintRuleList(pPolicy->ppIpsecNFAData[j],bVerb,bWide);
  151. if(dwReturn == ERROR_OUTOFMEMORY)
  152. {
  153. BAIL_OUT;
  154. }
  155. }
  156. }
  157. }
  158. error:
  159. return dwReturn;
  160. }
  161. ////////////////////////////////////////////////////////////////////
  162. //
  163. //Function: PrintRuleList()
  164. //
  165. //Date of Creation: 21st Aug 2001
  166. //
  167. //Parameters:
  168. // IN PIPSEC_NFA_DATA pIpsecNFAData,
  169. // IN BOOL bVerb,
  170. // IN BOOL bWide
  171. //
  172. //Return: DWORD
  173. //
  174. //Description:
  175. // This function prints out the Rule information.
  176. //
  177. //Revision History:
  178. //
  179. //Date Author Comments
  180. //
  181. ////////////////////////////////////////////////////////////////////
  182. DWORD
  183. PrintRuleList(
  184. IN PIPSEC_NFA_DATA pIpsecNFAData,
  185. IN BOOL bVerb,
  186. IN BOOL bWide
  187. )
  188. {
  189. _TCHAR pszStrTime[BUFFER_SIZE]={0};
  190. _TCHAR pszStrTruncated[BUFFER_SIZE]={0};
  191. DWORD dwReturn = ERROR_SUCCESS;
  192. if(pIpsecNFAData->pszIpsecName)
  193. {
  194. TruncateString(pIpsecNFAData->pszIpsecName,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  195. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_RULE_NAME_STR,pszStrTruncated);
  196. }
  197. else
  198. {
  199. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_RULE_NAME_NONE);
  200. }
  201. if(bVerb)
  202. {
  203. if(pIpsecNFAData->pszDescription)
  204. {
  205. TruncateString(pIpsecNFAData->pszDescription,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  206. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_STR,pszStrTruncated);
  207. }
  208. else
  209. {
  210. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_NONE);
  211. }
  212. }
  213. //last modified time
  214. FormatTime((time_t)pIpsecNFAData->dwWhenChanged, pszStrTime);
  215. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_LASTMODIFIED,pszStrTime);
  216. if(pIpsecNFAData->dwActiveFlag)
  217. {
  218. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_ACTIVATED_YES_STR);
  219. }
  220. else
  221. {
  222. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_ACTIVATED_NO_STR);
  223. }
  224. if(!bVerb) //non verbose
  225. {
  226. if(pIpsecNFAData->pIpsecFilterData && pIpsecNFAData->pIpsecFilterData->pszIpsecName)
  227. {
  228. TruncateString(pIpsecNFAData->pIpsecFilterData->pszIpsecName,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  229. PrintMessageFromModule(g_hModule,SHW_STATIC_RULE_FL_NAME_STR,pszStrTruncated);
  230. }
  231. else
  232. PrintMessageFromModule(g_hModule,SHW_STATIC_RULE_FL_NAME_NONE);
  233. if(pIpsecNFAData->pIpsecNegPolData && pIpsecNFAData->pIpsecNegPolData->pszIpsecName)
  234. {
  235. TruncateString(pIpsecNFAData->pIpsecNegPolData->pszIpsecName,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  236. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_FA_NAME_STR,pszStrTruncated);
  237. }
  238. else
  239. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_FA_NAME_NONE);
  240. }
  241. if(pIpsecNFAData->dwTunnelIpAddr!=0)
  242. {
  243. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_TUNNEL_IP);
  244. PrintIPAddrList(pIpsecNFAData->dwTunnelIpAddr);
  245. }
  246. //interface type
  247. if(pIpsecNFAData->dwInterfaceType==(DWORD)PAS_INTERFACE_TYPE_ALL)
  248. {
  249. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_CONN_ALL_STR);
  250. }
  251. else if(pIpsecNFAData->dwInterfaceType==(DWORD)PAS_INTERFACE_TYPE_LAN)
  252. {
  253. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_CONN_LAN_STR);
  254. }
  255. else if(pIpsecNFAData->dwInterfaceType==(DWORD)PAS_INTERFACE_TYPE_DIALUP)
  256. {
  257. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_CONN_DIALUP_STR);
  258. }
  259. else
  260. {
  261. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_CONN_NONE_STR);
  262. }
  263. //auth count
  264. if ( pIpsecNFAData->dwAuthMethodCount)
  265. {
  266. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_AUTH_TITLE,pIpsecNFAData->dwAuthMethodCount);
  267. }
  268. for (DWORD j=0;j<(pIpsecNFAData->dwAuthMethodCount);j++)
  269. {
  270. // print auth methods details
  271. if(pIpsecNFAData->ppAuthMethods[j])
  272. {
  273. PrintAuthMethodsList(pIpsecNFAData->ppAuthMethods[j]);
  274. }
  275. }
  276. if(bVerb)
  277. {
  278. //print the filter data details
  279. if (pIpsecNFAData->pIpsecFilterData)
  280. {
  281. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_FL_DETAILS_TITLE);
  282. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_FL_DETAILS_UNDERLINE);
  283. if(pIpsecNFAData->pIpsecFilterData)
  284. {
  285. dwReturn = PrintFilterDataList(pIpsecNFAData->pIpsecFilterData,bVerb,FALSE,bWide);
  286. if(dwReturn == ERROR_OUTOFMEMORY)
  287. {
  288. BAIL_OUT;
  289. }
  290. }
  291. }
  292. else
  293. {
  294. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_NO_FL_FOR_DEF_RULE);
  295. }
  296. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_FA_DETAILS_TITLE);
  297. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTRULE_FA_TITLE_UNDERLINE);
  298. //print the filter action details
  299. if(pIpsecNFAData->pIpsecNegPolData)
  300. {
  301. PrintNegPolDataList(pIpsecNFAData->pIpsecNegPolData,bVerb,bWide);
  302. }
  303. }
  304. error:
  305. return dwReturn;
  306. }
  307. ////////////////////////////////////////////////////////////////////
  308. //
  309. //Function: PrintNegPolDataList()
  310. //
  311. //Date of Creation: 21st Aug 2001
  312. //
  313. //Parameters:
  314. // IN PIPSEC_NEGPOL_DATA pIpsecNegPolData,
  315. // IN BOOL bVerb,
  316. // IN BOOL bWide
  317. //
  318. //Return: VOID
  319. //
  320. //Description:
  321. // This function prints out the Negotiation Policy information.
  322. //
  323. //Revision History:
  324. //
  325. //Date Author Comments
  326. //
  327. ////////////////////////////////////////////////////////////////////
  328. VOID
  329. PrintNegPolDataList(
  330. IN PIPSEC_NEGPOL_DATA pIpsecNegPolData,
  331. IN BOOL bVerb,
  332. IN BOOL bWide
  333. )
  334. {
  335. BOOL bSoft=FALSE;
  336. _TCHAR pszGUIDStr[BUFFER_SIZE]={0};
  337. _TCHAR pszStrTime[BUFFER_SIZE]={0};
  338. _TCHAR pszStrTruncated[BUFFER_SIZE]={0};
  339. DWORD i=0;
  340. if(pIpsecNegPolData)
  341. {
  342. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_NEWLINE);
  343. //print filteraction name
  344. if(pIpsecNegPolData->pszIpsecName)
  345. {
  346. TruncateString(pIpsecNegPolData->pszIpsecName,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  347. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_FA_NAME_STR,pszStrTruncated);
  348. }
  349. else
  350. {
  351. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_FA_NAME_NONE);
  352. }
  353. if(pIpsecNegPolData->pszDescription)
  354. {
  355. TruncateString(pIpsecNegPolData->pszDescription,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  356. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_STR,pszStrTruncated);
  357. }
  358. else
  359. {
  360. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_NONE);
  361. }
  362. if(bVerb) //storage info
  363. {
  364. PrintStorageInfoList(FALSE);
  365. }
  366. //print action
  367. if (!(pIpsecNegPolData->NegPolType==GUID_NEGOTIATION_TYPE_DEFAULT))
  368. {
  369. if(pIpsecNegPolData->NegPolAction==GUID_NEGOTIATION_ACTION_NO_IPSEC)
  370. {
  371. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_ACTION_PERMIT);
  372. }
  373. else if(pIpsecNegPolData->NegPolAction==GUID_NEGOTIATION_ACTION_BLOCK)
  374. {
  375. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_ACTION_BLOCK);
  376. }
  377. else
  378. {
  379. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_ACTION_NEGOTIATE);
  380. }
  381. }
  382. for (DWORD cnt=0;cnt<pIpsecNegPolData->dwSecurityMethodCount;cnt++)
  383. {
  384. if (CheckSoft(pIpsecNegPolData->pIpsecSecurityMethods[cnt])) { bSoft=TRUE; break;}
  385. }
  386. //soft association
  387. if(bSoft)
  388. {
  389. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_SOFT_YES_STR);
  390. }
  391. else
  392. {
  393. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_SOFT_NO_STR);
  394. }
  395. if(pIpsecNegPolData->NegPolAction==GUID_NEGOTIATION_ACTION_INBOUND_PASSTHRU)
  396. {
  397. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_INPASS_YES_STR);
  398. }
  399. else
  400. {
  401. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_INPASS_NO_STR);
  402. }
  403. if(bVerb)
  404. {
  405. if (pIpsecNegPolData->dwSecurityMethodCount )
  406. {
  407. if(pIpsecNegPolData->pIpsecSecurityMethods && pIpsecNegPolData->pIpsecSecurityMethods[0].PfsQMRequired)
  408. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_QMPFS_YES_STR);
  409. else
  410. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTNEGPOL_QMPFS_NO_STR);
  411. }
  412. }
  413. //last modified time
  414. FormatTime((time_t)pIpsecNegPolData->dwWhenChanged, pszStrTime);
  415. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_LASTMODIFIED,pszStrTime);
  416. //print guid
  417. i=StringFromGUID2(pIpsecNegPolData->NegPolIdentifier,pszGUIDStr,BUFFER_SIZE);
  418. if(i>0 && (_tcscmp(pszGUIDStr,_TEXT(""))!=0))
  419. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_GUID,pszGUIDStr);
  420. if (bVerb)
  421. {
  422. //print security methods
  423. if (pIpsecNegPolData->dwSecurityMethodCount)
  424. {
  425. PrintMessageFromModule(g_hModule,SHW_STATIC_TAB_PRTNEGPOL_SEC_MTHD_TITLE);
  426. PrintMessageFromModule(g_hModule,SHW_STATIC_TAB_PRTNEGPOL_ALGO_TITLE);
  427. PrintMessageFromModule(g_hModule,SHW_STATIC_TAB_PRTNEGPOL_ALGO_UNDERLINE);
  428. }
  429. for (DWORD cnt=0;cnt<pIpsecNegPolData->dwSecurityMethodCount;cnt++)
  430. {
  431. if(pIpsecNegPolData->pIpsecSecurityMethods)
  432. {
  433. PrintSecurityMethodsTable(pIpsecNegPolData->pIpsecSecurityMethods[cnt]);
  434. }
  435. }
  436. }
  437. }
  438. }
  439. ////////////////////////////////////////////////////////////////////
  440. //
  441. //Function: PrintAuthMethodsList()
  442. //
  443. //Date of Creation: 21st Aug 2001
  444. //
  445. //Parameters:
  446. // IN PIPSEC_AUTH_METHOD pIpsecAuthData
  447. //
  448. //Return: VOID
  449. //
  450. //Description:
  451. // This function prints out Authentication details.
  452. //
  453. //Revision History:
  454. //
  455. //Date Author Comments
  456. //
  457. ////////////////////////////////////////////////////////////////////
  458. VOID
  459. PrintAuthMethodsList(
  460. IN PIPSEC_AUTH_METHOD pIpsecAuthData
  461. )
  462. {
  463. if(pIpsecAuthData)
  464. {
  465. PrintMessageFromModule(g_hModule, DYNAMIC_SHOW_MMF_NEWLINE_TAB);
  466. if(pIpsecAuthData->dwAuthType==IKE_SSPI) //kerb
  467. {
  468. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTAUTH_KERBEROS);
  469. }
  470. else if(pIpsecAuthData->dwAuthType==IKE_RSA_SIGNATURE && pIpsecAuthData->pszAuthMethod)
  471. {
  472. DisplayCertInfo(pIpsecAuthData->pszAuthMethod, pIpsecAuthData->dwAuthFlags);
  473. }
  474. else if (pIpsecAuthData->dwAuthType==IKE_PRESHARED_KEY && pIpsecAuthData->pszAuthMethod)
  475. {
  476. //preshared key
  477. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTAUTH_PRE_STR,pIpsecAuthData->pszAuthMethod);
  478. }
  479. else
  480. {
  481. //none
  482. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTAUTH_NONE_STR);
  483. }
  484. }
  485. }
  486. ////////////////////////////////////////////////////////////////////
  487. //
  488. //Function: PrintFilterDataList()
  489. //
  490. //Date of Creation: 21st Aug 2001
  491. //
  492. //Parameters:
  493. // IN PIPSEC_FILTER_DATA pIpsecFilterData,
  494. // IN BOOL bVerb,
  495. // IN BOOL bResolveDNS,
  496. // IN BOOL bWide
  497. //
  498. //Return: DWORD
  499. //
  500. //Description:
  501. // This function prints out Filter list details.
  502. //
  503. //Revision History:
  504. //
  505. //Date Author Comments
  506. //
  507. ////////////////////////////////////////////////////////////////////
  508. DWORD
  509. PrintFilterDataList(
  510. IN PIPSEC_FILTER_DATA pIpsecFilterData,
  511. IN BOOL bVerb,
  512. IN BOOL bResolveDNS,
  513. IN BOOL bWide
  514. )
  515. {
  516. _TCHAR pszGUIDStr[BUFFER_SIZE]={0};
  517. _TCHAR pszStrTime[BUFFER_SIZE]={0};
  518. _TCHAR pszStrTruncated[BUFFER_SIZE]={0};
  519. DWORD i=0 , dwReturn = ERROR_SUCCESS;
  520. if (pIpsecFilterData)
  521. {
  522. //name
  523. if(pIpsecFilterData->pszIpsecName)
  524. {
  525. TruncateString(pIpsecFilterData->pszIpsecName,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  526. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_NAME_STR,pszStrTruncated);
  527. }
  528. else
  529. {
  530. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_NAME_NONE);
  531. }
  532. //desc
  533. if(pIpsecFilterData->pszDescription)
  534. {
  535. TruncateString(pIpsecFilterData->pszDescription,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  536. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_STR,pszStrTruncated);
  537. }
  538. else
  539. {
  540. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_NONE);
  541. }
  542. if(bVerb) // storage info
  543. {
  544. PrintStorageInfoList(FALSE);
  545. }
  546. if(!bVerb)
  547. {
  548. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FILTERS_COUNT,pIpsecFilterData->dwNumFilterSpecs);
  549. }
  550. //last modified
  551. FormatTime((time_t)pIpsecFilterData->dwWhenChanged, pszStrTime);
  552. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_LASTMODIFIED,pszStrTime);
  553. //print guid
  554. i=StringFromGUID2(pIpsecFilterData->FilterIdentifier,pszGUIDStr,BUFFER_SIZE);
  555. if(i>0 && (_tcscmp(pszGUIDStr,_TEXT(""))!=0))
  556. {
  557. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FL_GUID,pszGUIDStr);
  558. }
  559. if(bVerb)
  560. {
  561. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FILTERS_COUNT,pIpsecFilterData->dwNumFilterSpecs);
  562. }
  563. if(bVerb)
  564. {
  565. //print filter specs
  566. if(pIpsecFilterData->dwNumFilterSpecs)
  567. {
  568. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FILTERS_TITLE);
  569. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTERDATA_FILTERS_TITLE_UNDERLINE);
  570. }
  571. for (DWORD k=0;k<pIpsecFilterData->dwNumFilterSpecs;k++)
  572. {
  573. dwReturn = PrintFilterSpecList(pIpsecFilterData->ppFilterSpecs[k],bResolveDNS,bWide);
  574. if(dwReturn == ERROR_OUTOFMEMORY)
  575. {
  576. BAIL_OUT;
  577. }
  578. }
  579. }
  580. }
  581. error:
  582. return dwReturn;
  583. }
  584. ////////////////////////////////////////////////////////////////////
  585. //
  586. //Function: PrintFilterSpecList()
  587. //
  588. //Date of Creation: 21st Aug 2001
  589. //
  590. //Parameters:
  591. // IN PIPSEC_FILTER_SPEC pIpsecFilterSpec,
  592. // IN BOOL bResolveDNS,
  593. // IN BOOL bWide
  594. //
  595. //Return: DWORD
  596. //
  597. //Description:
  598. // This function prints the Filter Spec details
  599. //
  600. //Revision History:
  601. //
  602. //Date Author Comments
  603. //
  604. ////////////////////////////////////////////////////////////////////
  605. DWORD
  606. PrintFilterSpecList(
  607. IN PIPSEC_FILTER_SPEC pIpsecFilterSpec,
  608. IN BOOL bResolveDNS,
  609. IN BOOL bWide
  610. )
  611. {
  612. DWORD dwReturn = ERROR_SUCCESS;
  613. _TCHAR pszStrTruncated[BUFFER_SIZE]={0};
  614. PFILTERDNS pFilterDNS= new FILTERDNS ;
  615. if(pFilterDNS==NULL)
  616. {
  617. dwReturn = ERROR_OUTOFMEMORY;
  618. BAIL_OUT;
  619. }
  620. GetFilterDNSDetails(pIpsecFilterSpec, pFilterDNS);
  621. if (pFilterDNS)
  622. {
  623. //desc
  624. if ( WcsCmp0(pIpsecFilterSpec->pszDescription,_TEXT(""))!=0)
  625. {
  626. TruncateString(pIpsecFilterSpec->pszDescription,pszStrTruncated,POL_TRUNC_LEN_TABLE_VER,bWide);
  627. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_STR, pszStrTruncated);
  628. }
  629. else
  630. {
  631. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTPOLICY_POL_DESC_NONE);
  632. }
  633. //mirrored
  634. if(pIpsecFilterSpec->dwMirrorFlag)
  635. {
  636. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_MIR_YES_STR);
  637. }
  638. else
  639. {
  640. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_MIR_NO_STR);
  641. }
  642. //special server and me
  643. if ((pFilterDNS->FilterSrcNameID==FILTER_MYADDRESS)&&(pIpsecFilterSpec->Filter.SrcAddr==0))
  644. {
  645. if((pIpsecFilterSpec->Filter.ExType == EXT_NORMAL)||((pIpsecFilterSpec->Filter.ExType & EXT_DEST)== EXT_DEST))
  646. {
  647. //me
  648. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCIP_ME);
  649. }
  650. else if((pIpsecFilterSpec->Filter.ExType & EXT_DEST) != EXT_DEST)
  651. {
  652. if((pIpsecFilterSpec->Filter.ExType & EXT_DEFAULT_GATEWAY)==EXT_DEFAULT_GATEWAY)
  653. {
  654. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCIP_DEFGATEWAY);
  655. }
  656. else if((pIpsecFilterSpec->Filter.ExType & EXT_DHCP_SERVER)==EXT_DHCP_SERVER)
  657. {
  658. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCIP_DHCPSERVER);
  659. }
  660. else if((pIpsecFilterSpec->Filter.ExType & EXT_WINS_SERVER)== EXT_WINS_SERVER)
  661. {
  662. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCIP_WINSSERVER);
  663. }
  664. else if((pIpsecFilterSpec->Filter.ExType & EXT_DNS_SERVER)==EXT_DNS_SERVER)
  665. {
  666. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCIP_DNSSERVER);
  667. }
  668. }
  669. }
  670. else if ((pFilterDNS->FilterSrcNameID==FILTER_ANYADDRESS)&&(pIpsecFilterSpec->Filter.SrcAddr==0))
  671. {
  672. //any
  673. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCIP_ANY);
  674. }
  675. else
  676. {
  677. //other IP address
  678. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCIP_STR);
  679. if(bResolveDNS && (WcsCmp0(pIpsecFilterSpec->pszSrcDNSName,_TEXT("")) != 0))
  680. {
  681. PrintIPAddrDNS(pIpsecFilterSpec->Filter.SrcAddr);
  682. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_RESOLVES,pIpsecFilterSpec->pszSrcDNSName);
  683. }
  684. else
  685. {
  686. PrintIPAddrList(pIpsecFilterSpec->Filter.SrcAddr);
  687. }
  688. }
  689. //mask
  690. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCIP_MASK);
  691. PrintIPAddrList(pIpsecFilterSpec->Filter.SrcMask);
  692. switch(pFilterDNS->FilterSrcNameID)
  693. {
  694. //dns name
  695. case FILTER_MYADDRESS :
  696. {
  697. if((pIpsecFilterSpec->Filter.ExType == EXT_NORMAL)||((pIpsecFilterSpec->Filter.ExType & EXT_DEST)== EXT_DEST))
  698. {
  699. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_ME);
  700. }
  701. else if((pIpsecFilterSpec->Filter.ExType & EXT_DEST) != EXT_DEST)
  702. {
  703. if((pIpsecFilterSpec->Filter.ExType & EXT_DEFAULT_GATEWAY)==EXT_DEFAULT_GATEWAY)
  704. {
  705. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_DEFGATEWAY);
  706. }
  707. else if((pIpsecFilterSpec->Filter.ExType & EXT_DHCP_SERVER)==EXT_DHCP_SERVER)
  708. {
  709. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_DHCPSERVER);
  710. }
  711. else if((pIpsecFilterSpec->Filter.ExType & EXT_WINS_SERVER)== EXT_WINS_SERVER)
  712. {
  713. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_WINSSERVER);
  714. }
  715. else if((pIpsecFilterSpec->Filter.ExType & EXT_DNS_SERVER)==EXT_DNS_SERVER)
  716. {
  717. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_DNSSERVER);
  718. }
  719. }
  720. }
  721. break;
  722. case FILTER_DNSADDRESS:
  723. {
  724. if(!bResolveDNS)
  725. {
  726. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_STR, pIpsecFilterSpec->pszSrcDNSName);
  727. }
  728. else
  729. {
  730. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_RESOLVE, pIpsecFilterSpec->pszSrcDNSName);
  731. dwReturn = PrintResolveDNS(pIpsecFilterSpec->pszSrcDNSName);
  732. if(dwReturn == ERROR_OUTOFMEMORY)
  733. {
  734. BAIL_OUT;
  735. }
  736. }
  737. }
  738. break;
  739. case FILTER_ANYADDRESS:
  740. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_ANY);
  741. break;
  742. case FILTER_IPADDRESS :
  743. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_SPECIFIC_IP);
  744. break;
  745. case FILTER_IPSUBNET :
  746. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_SPECIFIC_SUBNET);
  747. break;
  748. default:
  749. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SRCDNS_ANY);
  750. break;
  751. };
  752. //destination details
  753. if ((pFilterDNS->FilterDestNameID==FILTER_MYADDRESS)&&(pIpsecFilterSpec->Filter.DestAddr==0))
  754. {
  755. if((pIpsecFilterSpec->Filter.ExType == EXT_NORMAL)||((pIpsecFilterSpec->Filter.ExType & EXT_DEST) != EXT_DEST))
  756. {
  757. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTIP_ME);
  758. }
  759. else if((pIpsecFilterSpec->Filter.ExType & EXT_DEST) == EXT_DEST)
  760. {
  761. // server types
  762. if((pIpsecFilterSpec->Filter.ExType & EXT_DEFAULT_GATEWAY)==EXT_DEFAULT_GATEWAY)
  763. {
  764. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTIP_DEFGATEWAY);
  765. }
  766. else if((pIpsecFilterSpec->Filter.ExType & EXT_DHCP_SERVER)==EXT_DHCP_SERVER)
  767. {
  768. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTIP_DHCPSERVER);
  769. }
  770. else if((pIpsecFilterSpec->Filter.ExType & EXT_WINS_SERVER)==EXT_WINS_SERVER)
  771. {
  772. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTIP_WINSSERVER);
  773. }
  774. else if((pIpsecFilterSpec->Filter.ExType & EXT_DNS_SERVER)==EXT_DNS_SERVER)
  775. {
  776. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTIP_DNSSERVER);
  777. }
  778. }
  779. }
  780. else if ((pFilterDNS->FilterDestNameID==FILTER_ANYADDRESS)&&(pIpsecFilterSpec->Filter.DestAddr==0))
  781. {
  782. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTIP_ANY);
  783. }
  784. else
  785. {
  786. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTIP_STR);
  787. if(bResolveDNS && (WcsCmp0(pIpsecFilterSpec->pszDestDNSName,_TEXT("")) != 0))
  788. {
  789. PrintIPAddrDNS(pIpsecFilterSpec->Filter.DestAddr);
  790. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_RESOLVES,pIpsecFilterSpec->pszDestDNSName);
  791. }
  792. else
  793. {
  794. PrintIPAddrList(pIpsecFilterSpec->Filter.DestAddr);
  795. }
  796. }
  797. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTIP_MASK); PrintIPAddrList(pIpsecFilterSpec->Filter.DestMask);
  798. switch(pFilterDNS->FilterDestNameID)
  799. {
  800. case FILTER_MYADDRESS :
  801. {
  802. if((pIpsecFilterSpec->Filter.ExType == EXT_NORMAL)||((pIpsecFilterSpec->Filter.ExType & EXT_DEST) != EXT_DEST))
  803. {
  804. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_ME);
  805. }
  806. else if((pIpsecFilterSpec->Filter.ExType & EXT_DEST) == EXT_DEST)
  807. {
  808. if((pIpsecFilterSpec->Filter.ExType & EXT_DEFAULT_GATEWAY)==EXT_DEFAULT_GATEWAY)
  809. {
  810. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_DEFGATEWAY);
  811. }
  812. else if((pIpsecFilterSpec->Filter.ExType & EXT_DHCP_SERVER)==EXT_DHCP_SERVER)
  813. {
  814. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_DHCPSERVER);
  815. }
  816. else if((pIpsecFilterSpec->Filter.ExType & EXT_WINS_SERVER)==EXT_WINS_SERVER)
  817. {
  818. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_WINSSERVER);
  819. }
  820. else if((pIpsecFilterSpec->Filter.ExType & EXT_DNS_SERVER)==EXT_DNS_SERVER)
  821. {
  822. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_DNSSERVER);
  823. }
  824. }
  825. }
  826. break;
  827. case FILTER_DNSADDRESS:
  828. {
  829. if(!bResolveDNS)
  830. {
  831. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_STR, pIpsecFilterSpec->pszDestDNSName);
  832. }
  833. else // resolve DNS address
  834. {
  835. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DST_DNS_RESOLVE, pIpsecFilterSpec->pszDestDNSName);
  836. dwReturn = PrintResolveDNS(pIpsecFilterSpec->pszDestDNSName);
  837. if(dwReturn == ERROR_OUTOFMEMORY)
  838. {
  839. BAIL_OUT;
  840. }
  841. }
  842. }
  843. break;
  844. case FILTER_ANYADDRESS: //any
  845. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_ANY);
  846. break;
  847. case FILTER_IPADDRESS : //a specific IP
  848. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_SPECIFIC_IP);
  849. break;
  850. case FILTER_IPSUBNET : //a specific IP subnet
  851. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_SPECIFIC_SUBNET);
  852. break;
  853. default:
  854. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_DSTDNS_ANY);
  855. break;
  856. };
  857. //print protocol
  858. PrintProtocolNameList(pIpsecFilterSpec->Filter.Protocol);
  859. if(pIpsecFilterSpec->Filter.SrcPort)
  860. {
  861. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCPORT_STR,pIpsecFilterSpec->Filter.SrcPort);
  862. }
  863. else
  864. {
  865. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_SRCPORT_ANY);
  866. }
  867. if(pIpsecFilterSpec->Filter.DestPort)
  868. {
  869. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTPORT_STR,pIpsecFilterSpec->Filter.DestPort);
  870. }
  871. else
  872. {
  873. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DSTPORT_ANY);
  874. }
  875. delete pFilterDNS;
  876. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_NEWLINE);
  877. }
  878. error:
  879. return dwReturn;
  880. }
  881. ////////////////////////////////////////////////////////////////////
  882. //
  883. //Function: PrintProtocolNameList()
  884. //
  885. //Date of Creation: 21st Aug 2001
  886. //
  887. //Parameters:
  888. // DWORD dwProtocol
  889. //
  890. //Return: VOID
  891. //
  892. //Description:
  893. // This function prints protocol name corresponding to protocoll ID.
  894. //
  895. //Revision History:
  896. //
  897. //Date Author Comments
  898. //
  899. ////////////////////////////////////////////////////////////////////
  900. VOID
  901. PrintProtocolNameList(
  902. DWORD dwProtocol
  903. )
  904. {
  905. switch(dwProtocol)
  906. {
  907. case PROT_ID_ICMP :
  908. PrintMessageFromModule(g_hModule, SHW_STATIC_PRTPROTOCOL_ICMP);
  909. break;
  910. case PROT_ID_TCP :
  911. PrintMessageFromModule(g_hModule, SHW_STATIC_PRTPROTOCOL_TCP);
  912. break;
  913. case PROT_ID_UDP :
  914. PrintMessageFromModule(g_hModule, SHW_STATIC_PRTPROTOCOL_UDP);
  915. break;
  916. case PROT_ID_RAW :
  917. PrintMessageFromModule(g_hModule, SHW_STATIC_PRTPROTOCOL_RAW);
  918. break;
  919. case PROT_ID_ANY :
  920. PrintMessageFromModule(g_hModule, SHW_STATIC_PRTPROTOCOL_ANY);
  921. break;
  922. default:
  923. PrintMessageFromModule(g_hModule, SHW_STATIC_PRTPROTOCOL_OTHER, dwProtocol);
  924. break;
  925. };
  926. }
  927. ////////////////////////////////////////////////////////////////////
  928. //
  929. //Function: PrintISAKMPDataList()
  930. //
  931. //Date of Creation: 21st Aug 2001
  932. //
  933. //Parameters:
  934. // IN PIPSEC_ISAKMP_DATA pIpsecISAKMPData
  935. //
  936. //Return: VOID
  937. //
  938. //Description:
  939. // This function prints out the ISAKMP details.
  940. //
  941. //Revision History:
  942. //
  943. //Date Author Comments
  944. //
  945. ////////////////////////////////////////////////////////////////////
  946. VOID
  947. PrintISAKMPDataList(
  948. IN PIPSEC_ISAKMP_DATA pIpsecISAKMPData
  949. )
  950. {
  951. if(pIpsecISAKMPData)
  952. {
  953. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMP_MMSEC_ORDER_TITLE);
  954. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMP_ALGO_TITLE_STR);
  955. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMP_ALGO_TITLE_UNDERLINE);
  956. for (DWORD Loop=0;Loop<pIpsecISAKMPData->dwNumISAKMPSecurityMethods;Loop++)
  957. {
  958. // print mmsec details
  959. if(pIpsecISAKMPData->pSecurityMethods)
  960. {
  961. PrintISAKAMPSecurityMethodsList(pIpsecISAKMPData->pSecurityMethods[Loop]);
  962. }
  963. }
  964. }
  965. }
  966. ////////////////////////////////////////////////////////////////////
  967. //
  968. //Function: PrintISAKAMPSecurityMethodsList()
  969. //
  970. //Date of Creation: 21st Aug 2001
  971. //
  972. //Parameters:
  973. // IN CRYPTO_BUNDLE SecurityMethods
  974. //
  975. //Return: VOID
  976. //
  977. //Description:
  978. // This function prints out the ISAKMP SecurityMethods details.
  979. //
  980. //Revision History:
  981. //
  982. //Date Author Comments
  983. //
  984. ////////////////////////////////////////////////////////////////////
  985. VOID
  986. PrintISAKAMPSecurityMethodsList(
  987. IN CRYPTO_BUNDLE SecurityMethods
  988. )
  989. {
  990. // print encription detail
  991. if(SecurityMethods.EncryptionAlgorithm.AlgorithmIdentifier==CONF_ALGO_DES)
  992. {
  993. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMPSEC_DES_STR);
  994. }
  995. else
  996. {
  997. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMPSEC_3DES_STR);
  998. }
  999. // print hash detail
  1000. if(SecurityMethods.HashAlgorithm.AlgorithmIdentifier==AUTH_ALGO_SHA1)
  1001. {
  1002. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMPSEC_SHA1_STR);
  1003. }
  1004. else
  1005. {
  1006. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMPSEC_MD5_STR);
  1007. }
  1008. // print DH group detail
  1009. if(SecurityMethods.OakleyGroup==POTF_OAKLEY_GROUP1)
  1010. {
  1011. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMPSEC_DH_LOW_STR);
  1012. }
  1013. else if (SecurityMethods.OakleyGroup==POTF_OAKLEY_GROUP2)
  1014. {
  1015. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMPSEC_DH_MED_STR);
  1016. }
  1017. else
  1018. {
  1019. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTISAKMPSEC_DH_2048_STR);
  1020. }
  1021. }
  1022. ////////////////////////////////////////////////////////////////////
  1023. //
  1024. //Function: PrintGPOList()
  1025. //
  1026. //Date of Creation: 21st Aug 2001
  1027. //
  1028. //Parameters:
  1029. // IN PGPO pGPO,
  1030. // IN BOOL bVerb
  1031. //
  1032. //Return: VOID
  1033. //
  1034. //Description:
  1035. // This function prints the details of GPO .
  1036. //
  1037. //Revision History:
  1038. //
  1039. //Date Author Comments
  1040. //
  1041. ////////////////////////////////////////////////////////////////////
  1042. VOID
  1043. PrintGPOList(
  1044. IN PGPO pGPO
  1045. )
  1046. {
  1047. if(!pGPO)
  1048. {
  1049. BAIL_OUT;
  1050. }
  1051. if(_tcscmp(pGPO->pszLocalMachineName, _TEXT(""))!=0) //machine name
  1052. {
  1053. PrintMessageFromModule(g_hModule, SHW_STATIC_ASSIGNEDGPO_SRCMACHINE,pGPO->pszLocalMachineName);
  1054. }
  1055. else if(pGPO->pszDomainName) //domain name
  1056. {
  1057. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_SRCDOMAIN,pGPO->pszDomainName);
  1058. if (pGPO->pszDCName) //DC name
  1059. {
  1060. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_DC_NAME,pGPO->pszDCName);
  1061. }
  1062. }
  1063. if( pGPO->pszGPODisplayName ) // gpo name
  1064. {
  1065. if (pGPO->bDNPolicyOverrides && pGPO->pszGPODNName) //gpo DN
  1066. {
  1067. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_GPO_NAME_STR,pGPO->pszGPODNName);
  1068. }
  1069. else
  1070. {
  1071. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_GPO_NAME_STR,pGPO->pszGPODisplayName);
  1072. }
  1073. }
  1074. if(_tcscmp(pGPO->pszGPODisplayName,LocalGPOName)==0) // policy active - status
  1075. {
  1076. if(pGPO->bDNPolicyOverrides && (_tcscmp(pGPO->pszGPODisplayName,LocalGPOName)==0))
  1077. {
  1078. if(pGPO->pszLocalPolicyName) //local policy name
  1079. {
  1080. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_LOCAL_POL_NAME_STR,pGPO->pszLocalPolicyName);
  1081. }
  1082. else
  1083. {
  1084. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_LOC_POL_NAME_NONE);
  1085. }
  1086. if(pGPO->pszPolicyName)
  1087. {
  1088. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_AD_POL_NAME_STR,pGPO->pszPolicyName);
  1089. }
  1090. if(pGPO->pszPolicyDNName) // policy DN
  1091. {
  1092. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_AD_POL_DN_NAME,pGPO->pszPolicyDNName);
  1093. }
  1094. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_LOC_OPOL_ACTIVE_AD);
  1095. }
  1096. else if (_tcscmp(pGPO->pszGPODisplayName,LocalGPOName)==0)
  1097. {
  1098. if(pGPO->pszPolicyName)
  1099. {
  1100. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_LOCAL_POL_NAME_STR,pGPO->pszPolicyName);
  1101. }
  1102. if(pGPO->pszPolicyDNName) // policy DN
  1103. {
  1104. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_LOC_POL_ACTIVE_STR,pGPO->pszPolicyDNName);
  1105. }
  1106. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_AD_POL_NAME_NONE);
  1107. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_POL_ACTIVE_STR);
  1108. }
  1109. }
  1110. else // if domain policy is active
  1111. {
  1112. if(pGPO->pszGPODNName) //gpo DN
  1113. {
  1114. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_GPO_DN_NAME,pGPO->pszGPODNName);
  1115. }
  1116. if(pGPO->pszOULink) // OU link
  1117. {
  1118. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_GPO_OU_LINK,pGPO->pszOULink);
  1119. }
  1120. if(pGPO->pszPolicyName)
  1121. {
  1122. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_POL_NAME_STR,pGPO->pszPolicyName);
  1123. }
  1124. if(pGPO->pszPolicyDNName) //Policy DN
  1125. {
  1126. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_POL_DN_STR,pGPO->pszPolicyDNName);
  1127. }
  1128. PrintMessageFromModule(g_hModule,SHW_STATIC_ASSIGNEDGPO_POL_ACTIVE_STR);
  1129. }
  1130. error:
  1131. return;
  1132. }
  1133. ////////////////////////////////////////////////////////////////////
  1134. //
  1135. //Function: PrintIPAddrList()
  1136. //
  1137. //Date of Creation: 21st Aug 2001
  1138. //
  1139. //Parameters:
  1140. // IN DWORD dwAddr
  1141. //
  1142. //Return: VOID
  1143. //
  1144. //Description:
  1145. // This function prints out IP Address.
  1146. //
  1147. //Revision History:
  1148. //
  1149. //Date Author Comments
  1150. //
  1151. ////////////////////////////////////////////////////////////////////
  1152. VOID
  1153. PrintIPAddrList(
  1154. IN DWORD dwAddr
  1155. )
  1156. {
  1157. _TCHAR szIPAddr[20]= {0};
  1158. // not necessary to change to bounded printf
  1159. _stprintf(szIPAddr,_T("%d.%d.%d.%d"), (dwAddr & 0x000000FFL),((dwAddr & 0x0000FF00L) >> 8),((dwAddr & 0x00FF0000L) >> 16),((dwAddr & 0xFF000000L) >> 24) );
  1160. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_FORMAT_NEWLINE,szIPAddr);
  1161. }
  1162. ////////////////////////////////////////////////////////////////////
  1163. //
  1164. //Function: PrintStorageInfoList()
  1165. //
  1166. //Date of Creation: 21st Aug 2001
  1167. //
  1168. //Parameters:
  1169. // IN BOOL bDeleteAll
  1170. //
  1171. //Return: DWORD
  1172. //
  1173. //Description:
  1174. // This function prints out the the Security Methods information.
  1175. //
  1176. //Revision History:
  1177. //
  1178. //Date Author Comments
  1179. //
  1180. ////////////////////////////////////////////////////////////////////
  1181. DWORD
  1182. PrintStorageInfoList(
  1183. IN BOOL bDeleteAll
  1184. )
  1185. {
  1186. DWORD dwReturn = ERROR_SUCCESS , dwStrLength = 0, dwStoreId;
  1187. if(g_StorageLocation.dwLocation!=IPSEC_DIRECTORY_PROVIDER) // if it is local GPO
  1188. {
  1189. if(_tcscmp(g_StorageLocation.pszMachineName,_TEXT(""))!=0)
  1190. {
  1191. if(!bDeleteAll)
  1192. {
  1193. if (g_StorageLocation.dwLocation == IPSEC_REGISTRY_PROVIDER)
  1194. {
  1195. dwStoreId = SHW_STATIC_POLICY_STORE_RM_NAME_STR;
  1196. }
  1197. else
  1198. {
  1199. dwStoreId = SHW_STATIC_POLICY_STORE_RM_NAME_STRP;
  1200. }
  1201. PrintMessageFromModule(g_hModule,dwStoreId,g_StorageLocation.pszMachineName);
  1202. }
  1203. else
  1204. {
  1205. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_RM_STR,g_StorageLocation.pszMachineName);
  1206. }
  1207. }
  1208. else
  1209. {
  1210. _TCHAR pszLocalMachineName[MAXSTRLEN] = {0};
  1211. DWORD MaxStringLen=MAXSTRLEN;
  1212. // Get the computer name
  1213. GetComputerName(pszLocalMachineName,&MaxStringLen);
  1214. if(!bDeleteAll)
  1215. {
  1216. if(_tcscmp(pszLocalMachineName,_TEXT(""))!=0)
  1217. {
  1218. if (g_StorageLocation.dwLocation == IPSEC_REGISTRY_PROVIDER)
  1219. {
  1220. dwStoreId = SHW_STATIC_POLICY_STORE_LM_NAME_STR;
  1221. }
  1222. else
  1223. {
  1224. dwStoreId = SHW_STATIC_POLICY_STORE_LM_NAME_STRP;
  1225. }
  1226. PrintMessageFromModule(g_hModule,dwStoreId,pszLocalMachineName);
  1227. }
  1228. else
  1229. {
  1230. if (g_StorageLocation.dwLocation == IPSEC_REGISTRY_PROVIDER)
  1231. {
  1232. dwStoreId = SHW_STATIC_POLICY_STORE_LM_STR;
  1233. }
  1234. else
  1235. {
  1236. dwStoreId = SHW_STATIC_POLICY_STORE_LM_STRP;
  1237. }
  1238. PrintMessageFromModule(g_hModule,dwStoreId);
  1239. }
  1240. }
  1241. else
  1242. {
  1243. if(_tcscmp(pszLocalMachineName,_TEXT(""))!=0)
  1244. {
  1245. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_LM_STR,pszLocalMachineName);
  1246. }
  1247. else
  1248. {
  1249. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_LM);
  1250. }
  1251. }
  1252. }
  1253. }
  1254. else if(g_StorageLocation.dwLocation==IPSEC_DIRECTORY_PROVIDER) // if remote GPO
  1255. {
  1256. if(_tcscmp(g_StorageLocation.pszDomainName,_TEXT(""))!=0)
  1257. {
  1258. if(!bDeleteAll)
  1259. {
  1260. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_STORE_LD_NAME_STR,g_StorageLocation.pszDomainName);
  1261. }
  1262. else
  1263. {
  1264. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_RD_STR,g_StorageLocation.pszDomainName);
  1265. }
  1266. }
  1267. else
  1268. {
  1269. PDOMAIN_CONTROLLER_INFO pDomainControllerInfo = NULL;
  1270. LPTSTR pszDomainName = NULL;
  1271. DWORD Flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_RETURN_DNS_NAME | DS_FORCE_REDISCOVERY;
  1272. // get the domain name and DC name
  1273. dwReturn = DsGetDcName(NULL, //machine name
  1274. NULL,
  1275. NULL,
  1276. NULL,
  1277. Flags,
  1278. &pDomainControllerInfo
  1279. ) ;
  1280. if(dwReturn==NO_ERROR && pDomainControllerInfo && pDomainControllerInfo->DomainName)
  1281. {
  1282. dwStrLength = _tcslen(pDomainControllerInfo->DomainName);
  1283. pszDomainName= new _TCHAR[dwStrLength+1];
  1284. if(pszDomainName == NULL)
  1285. {
  1286. dwReturn = ERROR_OUTOFMEMORY;
  1287. BAIL_OUT;
  1288. }
  1289. _tcsncpy(pszDomainName,pDomainControllerInfo->DomainName,dwStrLength+1);
  1290. }
  1291. if (pDomainControllerInfo)
  1292. {
  1293. NetApiBufferFree(pDomainControllerInfo);
  1294. }
  1295. if(!bDeleteAll)
  1296. {
  1297. if(pszDomainName)
  1298. {
  1299. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_STORE_RD_NAME_STR,pszDomainName);
  1300. }
  1301. else
  1302. {
  1303. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_STORE_LD_STR);
  1304. }
  1305. }
  1306. else
  1307. {
  1308. if(pszDomainName)
  1309. {
  1310. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_LD_STR,pszDomainName);
  1311. }
  1312. else
  1313. {
  1314. PrintMessageFromModule(g_hModule,SHW_STATIC_POLICY_LD);
  1315. }
  1316. }
  1317. if(pszDomainName) delete [] pszDomainName;
  1318. }
  1319. }
  1320. error:
  1321. return dwReturn;
  1322. }
  1323. ////////////////////////////////////////////////////////////////////
  1324. //
  1325. //Function: PrintResolveDNS()
  1326. //
  1327. //Date of Creation: 21st Aug 2001
  1328. //
  1329. //Parameters:
  1330. // LPWSTR pszDNSName,
  1331. // IPAddr *pIpAddr
  1332. //
  1333. //Return: DWORD
  1334. //
  1335. //Description:
  1336. // This function prints DNS resolution details
  1337. //
  1338. //Revision History:
  1339. //
  1340. //Date Author Comments
  1341. //
  1342. ////////////////////////////////////////////////////////////////////
  1343. DWORD
  1344. PrintResolveDNS(
  1345. LPWSTR pszDNSName
  1346. )
  1347. {
  1348. DNSIPADDR *pAddress=NULL;
  1349. struct addrinfo *pAddrInfo = NULL,*pNext=NULL;
  1350. char szDNSName[MAX_STR_LEN] = {0};
  1351. DWORD dwBufferSize=MAX_STR_LEN;
  1352. int iReturn=ERROR_SUCCESS;
  1353. DWORD dwReturn = ERROR_SUCCESS;
  1354. if(pszDNSName && _tcscmp(pszDNSName,_TEXT(""))!=0)
  1355. {
  1356. pAddress=new DNSIPADDR;
  1357. if(pAddress==NULL)
  1358. {
  1359. dwReturn = ERROR_OUTOFMEMORY;
  1360. BAIL_OUT;
  1361. }
  1362. iReturn = WideCharToMultiByte(CP_THREAD_ACP, 0, pszDNSName, -1,
  1363. szDNSName,dwBufferSize,NULL,NULL);
  1364. if(iReturn == 0)
  1365. {
  1366. //conversion failed due to some error. dont proceed . dive out of the function
  1367. BAIL_OUT;
  1368. }
  1369. // call this to resolve DNS name
  1370. iReturn = getaddrinfo((const char*)szDNSName,NULL,NULL,&pAddrInfo);
  1371. if (iReturn == ERROR_SUCCESS)
  1372. {
  1373. pNext = pAddrInfo;
  1374. for(DWORD i=1;pNext=pNext->ai_next;i++);
  1375. pAddress->dwNumIpAddresses = i;
  1376. pAddress->puIpAddr = new ULONG[pAddress->dwNumIpAddresses];
  1377. if(pAddress->puIpAddr==NULL)
  1378. {
  1379. dwReturn = ERROR_OUTOFMEMORY;
  1380. BAIL_OUT;
  1381. }
  1382. // careful : the output of getaddrinfo is linked list not array of pointers
  1383. pNext = pAddrInfo;
  1384. for(DWORD n=0;pNext; n++)
  1385. {
  1386. memcpy(&(pAddress->puIpAddr[n]),(ULONG *) &(((sockaddr_in *)(pNext->ai_addr))->sin_addr.S_un.S_addr), sizeof(ULONG));
  1387. PrintIPAddrDNS(pAddress->puIpAddr[n]);
  1388. if(n<(i-1))
  1389. {
  1390. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_SPACE_COMMA);
  1391. }
  1392. else
  1393. {
  1394. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_NEWLINE);
  1395. }
  1396. pNext=pNext->ai_next;
  1397. }
  1398. // free pAddrInfo after usage
  1399. if (pAddrInfo)
  1400. {
  1401. freeaddrinfo(pAddrInfo);
  1402. }
  1403. }
  1404. else
  1405. {
  1406. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFILTER_DNS_FAILED);
  1407. }
  1408. error:
  1409. if(pAddress)
  1410. {
  1411. delete pAddress;
  1412. }
  1413. }
  1414. return dwReturn;
  1415. }
  1416. ////////////////////////////////////////////////////////////////////
  1417. //
  1418. //Function: PrintIPAddrDNS()
  1419. //
  1420. //Date of Creation: 21st Aug 2001
  1421. //
  1422. //Parameters:
  1423. // IN DWORD dwAddr
  1424. //
  1425. //Return: VOID
  1426. //
  1427. //Description:
  1428. // This function prints out IP Address.
  1429. //
  1430. //Revision History:
  1431. //
  1432. //Date Author Comments
  1433. //
  1434. ////////////////////////////////////////////////////////////////////
  1435. VOID
  1436. PrintIPAddrDNS(
  1437. IN DWORD dwAddr
  1438. )
  1439. {
  1440. _TCHAR szIPAddr[20]= {0};
  1441. // not necessary to change to bounded printf
  1442. _stprintf(szIPAddr,_T("%d.%d.%d.%d"), (dwAddr & 0x000000FFL),((dwAddr & 0x0000FF00L) >> 8),((dwAddr & 0x00FF0000L) >> 16),((dwAddr & 0xFF000000L) >> 24) );
  1443. PrintMessageFromModule(g_hModule,SHW_STATIC_PRTFSPEC_FORMAT_NO_NEWLINE,szIPAddr);
  1444. }