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.

442 lines
7.6 KiB

  1. ////////////////////////////////////////////////////////////////////////
  2. //
  3. // Module: Dynamic/Dyanamicshow.h
  4. //
  5. // Purpose : Dynamic Show commands for IPSec
  6. //
  7. //
  8. // Developers Name : Bharat/Radhika
  9. //
  10. //
  11. // History :
  12. //
  13. // Date Author Comments
  14. // 09-23-2001 Bharat Initial Version. V1.0
  15. // 11-21-2001 Bharat Initial Version. V1.1
  16. //
  17. ////////////////////////////////////////////////////////////////////////
  18. #ifndef _DYNAMICSHOW_H_
  19. #define _DYNAMICSHOW_H_
  20. #include "Nsu.h"
  21. //Registry keys path for IPSec
  22. #define REGKEY_GLOBAL _TEXT("System\\CurrentControlSet\\Services\\IPSEC")
  23. //Registry keys default values
  24. #define IPSEC_DIAG_DEFAULT 0
  25. #define IKE_LOG_DEFAULT 0
  26. #define STRONG_CRL_DEFAULT 0
  27. #define ENABLE_LOGINT_DEFAULT 3600
  28. #define ENABLE_EXEMPT_DEFAULT 0
  29. #define MY_ENCODING_TYPE (X509_ASN_ENCODING)
  30. #define SHA_LENGTH 21 //Thumbprint string length + Null
  31. typedef struct _QM_FILTER_VALUE_BOOL{
  32. BOOL bSrcPort;
  33. BOOL bDstPort;
  34. BOOL bProtocol;
  35. BOOL bActionInbound ;
  36. BOOL bActionOutbound;
  37. DWORD dwSrcPort;
  38. DWORD dwDstPort;
  39. DWORD dwProtocol;
  40. DWORD dwActionInbound;
  41. DWORD dwActionOutbound;
  42. } QM_FILTER_VALUE_BOOL, * PQM_FILTER_VALUE_BOOL;
  43. #ifdef __cplusplus
  44. class NshHashTable;
  45. DWORD
  46. ShowMMPolicy(
  47. IN LPTSTR pszShowPolicyName
  48. );
  49. VOID
  50. PrintMMPolicy(
  51. IN IPSEC_MM_POLICY mmPolicy
  52. );
  53. VOID
  54. PrintMMOffer(
  55. IN IPSEC_MM_OFFER mmOffer
  56. );
  57. DWORD
  58. ShowQMPolicy(
  59. IN LPTSTR pszShowPolicyName
  60. );
  61. VOID
  62. PrintQMOffer(
  63. IN IPSEC_QM_OFFER mmOffer
  64. );
  65. VOID
  66. PrintFilterAction(
  67. IN IPSEC_QM_POLICY qmPolicy
  68. );
  69. DWORD
  70. ShowMMFilters(
  71. IN LPTSTR pszShowFilterName,
  72. IN BOOL bType,
  73. IN ADDR SrcAddr,
  74. IN ADDR DstAddr,
  75. IN NshHashTable& addressHash,
  76. IN BOOL bResolveDNS,
  77. IN BOOL bSrcMask,
  78. IN BOOL bDstMask
  79. );
  80. DWORD
  81. PrintMainmodeFilter(
  82. IN MM_FILTER MMFltr,
  83. IN IPSEC_MM_POLICY MMPol,
  84. IN NshHashTable& addressHash,
  85. IN BOOL bResolveDNS,
  86. IN BOOL bType
  87. );
  88. DWORD
  89. ShowQMFilters(
  90. IN LPTSTR pszShowFilterName,
  91. IN BOOL bType,
  92. IN ADDR SrcAddr,
  93. IN ADDR DstAddr,
  94. IN NshHashTable& addressHash,
  95. IN BOOL bResolveDNS,
  96. IN BOOL bSrcMask,
  97. IN BOOL bDstMask,
  98. IN QM_FILTER_VALUE_BOOL QMBoolValue
  99. );
  100. DWORD
  101. ShowTunnelFilters(
  102. IN LPTSTR pszShowFilterName,
  103. IN BOOL bType,
  104. IN ADDR SrcAddr,
  105. IN ADDR DstAddr,
  106. IN NshHashTable& addressHash,
  107. IN BOOL bResolveDNS,
  108. IN BOOL bSrcMask,
  109. IN BOOL bDstMask,
  110. IN QM_FILTER_VALUE_BOOL QMBoolValue,
  111. IN OUT BOOL& bNameFin
  112. );
  113. DWORD
  114. PrintQuickmodeFilter(
  115. IN TRANSPORT_FILTER TransF,
  116. IN LPWSTR pszQMName,
  117. IN NshHashTable& addressHash,
  118. IN BOOL bResolveDNS,
  119. IN BOOL bType,
  120. IN DWORD dwActionFlag
  121. );
  122. DWORD
  123. PrintQuickmodeFilter(
  124. IN TUNNEL_FILTER TunnelF,
  125. IN LPWSTR pszQMName,
  126. IN NshHashTable& addressHash,
  127. IN BOOL bResolveDNS,
  128. IN BOOL bType,
  129. IN DWORD dwActionFlag
  130. );
  131. VOID
  132. PrintMYID(
  133. VOID
  134. );
  135. VOID
  136. PrintMMSas(
  137. IN IPSEC_MM_SA MMsas,
  138. IN BOOL bFormat,
  139. IN NshHashTable& addressHash,
  140. IN BOOL bResolveDNS
  141. );
  142. VOID
  143. PrintSACertInfo(
  144. IN IPSEC_MM_SA& MMsas
  145. );
  146. DWORD
  147. PrintIkeStats(
  148. VOID
  149. );
  150. DWORD
  151. PrintIpsecStats(
  152. VOID
  153. );
  154. DWORD
  155. GetNameAudit(
  156. IN CRYPT_DATA_BLOB *NameBlob,
  157. IN OUT LPTSTR Name,
  158. IN DWORD NameBufferSize
  159. );
  160. DWORD
  161. CertGetSHAHash(
  162. IN PCCERT_CONTEXT pCertContext,
  163. IN OUT BYTE* OutHash
  164. );
  165. VOID
  166. print_vpi(
  167. IN unsigned char *vpi,
  168. IN int vpi_len,
  169. IN OUT char *msg
  170. );
  171. VOID
  172. GetSubjectAndThumbprint(
  173. IN PCCERT_CONTEXT pCertContext,
  174. IN LPTSTR pszSubjectName,
  175. IN LPSTR pszThumbPrint
  176. );
  177. VOID
  178. PrintMask(
  179. IN ADDR addr
  180. );
  181. BOOL
  182. IsDefaultMMOffers(
  183. IN IPSEC_MM_POLICY MMPol
  184. );
  185. VOID
  186. PrintMMFilterOffer(
  187. IN IPSEC_MM_OFFER MMOffer
  188. );
  189. VOID
  190. PrintAddrStr(
  191. IN PADDR pResolveAddress,
  192. IN NshHashTable& addressHash,
  193. IN UINT uiFormat = DYNAMIC_SHOW_ADDR_STR
  194. );
  195. DWORD
  196. CheckMMFilter(
  197. IN MM_FILTER MMFltr,
  198. IN ADDR SrcAddr,
  199. IN ADDR DstAddr,
  200. IN BOOL bDstMask,
  201. IN BOOL bSrcMask,
  202. IN LPWSTR pszShowFilterName
  203. );
  204. DWORD
  205. CheckQMFilter(
  206. IN TUNNEL_FILTER TunnelF,
  207. IN ADDR SrcAddr,
  208. IN ADDR DstAddr,
  209. IN BOOL bDstMask,
  210. IN BOOL bSrcMask,
  211. IN QM_FILTER_VALUE_BOOL QMBoolValue,
  212. IN LPWSTR pszShowFilterName
  213. );
  214. DWORD
  215. CheckQMFilter(
  216. IN TRANSPORT_FILTER TransF,
  217. IN ADDR SrcAddr,
  218. IN ADDR DstAddr,
  219. IN BOOL bDstMask,
  220. IN BOOL bSrcMask,
  221. IN QM_FILTER_VALUE_BOOL QMBoolValue,
  222. IN LPWSTR pszShowFilterName
  223. );
  224. DWORD
  225. PrintTransportRuleFilter(
  226. IN PMM_FILTER pMMFltr,
  227. IN PIPSEC_MM_POLICY pMMPol,
  228. IN TRANSPORT_FILTER TransF,
  229. IN LPWSTR pszQMName,
  230. IN NshHashTable& addressHash,
  231. IN BOOL bResolveDNS
  232. );
  233. DWORD
  234. PrintTunnelRuleFilter(
  235. IN PMM_FILTER pMMFltr,
  236. IN PIPSEC_MM_POLICY pMMPol,
  237. IN TUNNEL_FILTER TunnelF,
  238. IN LPWSTR pszQMName,
  239. IN NshHashTable& addressHash,
  240. IN BOOL bResolveDNS
  241. );
  242. DWORD
  243. ShowMMSas(
  244. IN ADDR Source,
  245. IN ADDR Destination,
  246. IN BOOL bFormat,
  247. IN NshHashTable& addressHash,
  248. IN BOOL bResolveDNS
  249. );
  250. DWORD
  251. ShowQMSas(
  252. IN ADDR Source,
  253. IN ADDR Destination,
  254. IN DWORD dwProtocol,
  255. IN NshHashTable& addressHash,
  256. IN BOOL bResolveDNS
  257. );
  258. VOID
  259. PrintQMSas(
  260. IN IPSEC_QM_OFFER QMOffer,
  261. IN BOOL bResolveDNS
  262. );
  263. DWORD
  264. PrintQMSAFilter(
  265. IN IPSEC_QM_SA QMsa,
  266. IN NshHashTable& addressHash,
  267. IN BOOL bResolveDNS
  268. );
  269. DWORD
  270. ShowRule(
  271. IN DWORD dwType,
  272. IN ADDR SrcAddr,
  273. IN ADDR DesAddr,
  274. IN NshHashTable& addressHash,
  275. IN BOOL bResolveDNS,
  276. IN BOOL bSrcMask,
  277. IN BOOL bDstMask,
  278. IN QM_FILTER_VALUE_BOOL QmBoolValue
  279. );
  280. DWORD
  281. ShowTunnelRule(
  282. IN DWORD dwType,
  283. IN ADDR SrcAddr,
  284. IN ADDR DstAddr,
  285. IN NshHashTable& addressHash,
  286. IN BOOL bResolveDNS,
  287. IN BOOL bSrcMask,
  288. IN BOOL bDstMask,
  289. IN QM_FILTER_VALUE_BOOL QMBoolValue,
  290. IN OUT BOOL& bNameFin
  291. );
  292. DWORD
  293. ShowStats(
  294. IN DWORD dwShow
  295. );
  296. DWORD
  297. ShowRegKeys(
  298. VOID
  299. );
  300. VOID
  301. PrintAddr(
  302. IN ADDR addr,
  303. IN NshHashTable& addressHash,
  304. IN BOOL bResolveDNS
  305. );
  306. DWORD
  307. AscAddUint(
  308. IN LPSTR cSum,
  309. IN LPSTR cA,
  310. IN LPSTR cB
  311. );
  312. DWORD
  313. AscMultUint(
  314. IN LPSTR cProduct,
  315. IN LPSTR cA,
  316. IN LPSTR cB
  317. );
  318. LPSTR
  319. LongLongToString(
  320. IN DWORD dwHigh,
  321. IN DWORD dwLow,
  322. IN int iPrintCommas
  323. );
  324. #define NSHHASHTABLESIZE 101
  325. class NshHashTable
  326. {
  327. public:
  328. NshHashTable() throw ();
  329. ~NshHashTable() throw ();
  330. // insert key, data pair into table
  331. // failure cases (return value):
  332. // key already exists (ERROR_DUPLICATE_TAG)
  333. // can't allocate new item in hash table (ERROR_NOT_ENOUGH_MEMORY)
  334. DWORD Insert(UINT uiNewKey, const char* const szNewData) throw ();
  335. // clear the HashTable
  336. void Clear() throw ();
  337. // find data from key
  338. // return NULL if key doesn�t exist in table
  339. const char* Find(UINT uiKey) const throw ();
  340. private:
  341. NSU_LIST table[NSHHASHTABLESIZE];
  342. // allows us to pass in a good hash value rather than recompute it several times
  343. const char* Find(UINT uiKey, size_t hash) const throw ();
  344. size_t Hash(UINT uiKey) const throw ();
  345. class HashEntry;
  346. const HashEntry* FindEntry(UINT uiKey, size_t hash) const throw ();
  347. // not implemented
  348. NshHashTable(const NshHashTable&) throw ();
  349. NshHashTable& operator=(const NshHashTable&) throw ();
  350. class HashEntry
  351. {
  352. public:
  353. HashEntry(
  354. PNSU_LIST pList,
  355. const UINT uiNewKey,
  356. const char* szNewData
  357. ) throw ();
  358. ~HashEntry() throw ();
  359. static const HashEntry* Get(PNSU_LIST pList) throw ();
  360. UINT Key() const throw ();
  361. const char* Data() const throw ();
  362. private:
  363. NSU_LIST_ENTRY listEntry;
  364. const UINT key;
  365. const char* data;
  366. // not implemented
  367. HashEntry& operator=(const HashEntry&) throw ();
  368. };
  369. };
  370. #endif // __cplusplus
  371. #endif //_DYNAMICSHOW_H_