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.

268 lines
9.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: R A S D A T A . C P P
  7. //
  8. // Contents: Implementation of data structure persistence.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 13 Mar 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "bindobj.h"
  18. #include "ncreg.h"
  19. #include "ncutil.h"
  20. #include "rasdata.h"
  21. #include "mprapip.h"
  22. static const BOOL c_fDefAllowNetworkAccess = TRUE;
  23. static const BOOL c_fDefEnableIn = TRUE;
  24. //------------------------------------------------------------------------
  25. //
  26. // DATA_SRV_CFG
  27. //
  28. static const BOOL c_fDefMultilink = TRUE;
  29. static const DWORD c_fDefAuthLevel = 2;
  30. static const DWORD c_fDefDataEnc = FALSE;
  31. static const DWORD c_fDefStrongDataEnc = FALSE;
  32. static const DWORD c_fDefSecureVPN = 0;
  33. // server flags copied from routing\ras\inc\rasppp.h
  34. //
  35. #define PPPCFG_NegotiateSPAP 0x00000040
  36. #define PPPCFG_RequireEncryption 0x00000080
  37. #define PPPCFG_NegotiateMSCHAP 0x00000100
  38. #define PPPCFG_NegotiateMultilink 0x00000400
  39. #define PPPCFG_RequireStrongEncryption 0x00001000
  40. #define PPPCFG_NegotiatePAP 0x00010000
  41. #define PPPCFG_NegotiateMD5CHAP 0x00020000
  42. #define PPPCFG_NegotiateStrongMSCHAP 0x00800000
  43. #define PPPCFG_DisableEncryption 0x00080000
  44. VOID DATA_SRV_CFG::SaveToReg () const
  45. {
  46. HRESULT hr;
  47. HKEY hkey;
  48. DWORD dwServerFlags = 0;
  49. // Save off the router type
  50. //
  51. hr = HrRegOpenKeyEx (
  52. HKEY_LOCAL_MACHINE,
  53. L"System\\CurrentControlSet\\Services\\RemoteAccess\\Parameters",
  54. KEY_ALL_ACCESS,
  55. &hkey);
  56. if (SUCCEEDED(hr))
  57. {
  58. (VOID) HrRegSetDword (hkey, L"RouterType", dwRouterType);
  59. hr = HrRegQueryDword (hkey, L"ServerFlags", &dwServerFlags);
  60. if (SUCCEEDED(hr))
  61. {
  62. if (fMultilink)
  63. {
  64. dwServerFlags |= PPPCFG_NegotiateMultilink;
  65. }
  66. else
  67. {
  68. dwServerFlags &= ~PPPCFG_NegotiateMultilink;
  69. }
  70. dwServerFlags &= ~PPPCFG_RequireEncryption;
  71. dwServerFlags &= ~PPPCFG_RequireStrongEncryption;
  72. if (fDataEnc)
  73. {
  74. dwServerFlags |= PPPCFG_RequireEncryption;
  75. }
  76. if (fStrongDataEnc)
  77. {
  78. dwServerFlags |= PPPCFG_RequireStrongEncryption;
  79. }
  80. if (dwSecureVPN)
  81. {
  82. dwServerFlags |= PPPCFG_NegotiateStrongMSCHAP;
  83. dwServerFlags &= ~PPPCFG_NegotiateSPAP;
  84. dwServerFlags &= ~PPPCFG_NegotiateMSCHAP;
  85. dwServerFlags &= ~PPPCFG_NegotiatePAP;
  86. dwServerFlags &= ~PPPCFG_NegotiateMD5CHAP;
  87. }
  88. else
  89. {
  90. dwServerFlags |= PPPCFG_NegotiateMSCHAP;
  91. dwServerFlags |= PPPCFG_NegotiateStrongMSCHAP;
  92. dwServerFlags &= ~PPPCFG_NegotiateSPAP;
  93. dwServerFlags &= ~PPPCFG_NegotiatePAP;
  94. dwServerFlags &= ~PPPCFG_NegotiateMD5CHAP;
  95. if (dwAuthLevel < 2)
  96. {
  97. dwServerFlags |= PPPCFG_NegotiateSPAP;
  98. dwServerFlags |= PPPCFG_NegotiateMD5CHAP;
  99. }
  100. if (dwAuthLevel < 1)
  101. {
  102. dwServerFlags |= PPPCFG_NegotiatePAP;
  103. }
  104. }
  105. // pmay: 382389
  106. //
  107. // Part of the fix to this should be to clear the disable encryption
  108. // flag
  109. //
  110. dwServerFlags &= ~PPPCFG_DisableEncryption;
  111. (VOID) HrRegSetDword (hkey, L"ServerFlags", dwServerFlags);
  112. }
  113. RegCloseKey (hkey);
  114. }
  115. // Read in the
  116. }
  117. VOID DATA_SRV_CFG::CheckAndDefault ()
  118. {
  119. DATA_SRV_CFG def;
  120. def.GetDefault();
  121. if (dwRouterType >= RT_INVALID)
  122. {
  123. dwRouterType = def.dwRouterType;
  124. }
  125. }
  126. VOID DATA_SRV_CFG::GetDefault ()
  127. {
  128. dwRouterType = RT_RAS;
  129. fMultilink = c_fDefMultilink;
  130. dwAuthLevel = c_fDefAuthLevel;
  131. fDataEnc = c_fDefDataEnc;
  132. fStrongDataEnc = c_fDefStrongDataEnc;
  133. dwSecureVPN = c_fDefSecureVPN;
  134. }
  135. //------------------------------------------------------------------------
  136. //
  137. // DATA_SRV_IP
  138. //
  139. static const WCHAR c_szSubkeySrvIp [] = L"RemoteAccess\\Parameters\\Ip";
  140. static const WCHAR c_szSubkeySrvIpPool [] = L"RemoteAccess\\Parameters\\Ip\\StaticAddressPool\\0";
  141. static const BOOL c_fDefUseDhcp = TRUE;
  142. static const BOOL c_fDefAllowClientAddr = FALSE;
  143. static const DWORD c_dwDefIpAddr = 0;
  144. static const REGBATCH c_rbDataSrvIp [] =
  145. {
  146. { HKLM_SVCS, c_szSubkeySrvIp, L"EnableIn", REG_BOOL, offsetof(DATA_SRV_IP, fEnableIn), (BYTE*)&c_fDefEnableIn },
  147. { HKLM_SVCS, c_szSubkeySrvIp, L"AllowNetworkAccess", REG_BOOL, offsetof(DATA_SRV_IP, fAllowNetworkAccess), (BYTE*)&c_fDefAllowNetworkAccess },
  148. { HKLM_SVCS, c_szSubkeySrvIp, L"UseDhcpAddressing", REG_BOOL, offsetof(DATA_SRV_IP, fUseDhcp), (BYTE*)&c_fDefUseDhcp },
  149. { HKLM_SVCS, c_szSubkeySrvIp, L"AllowClientIpAddresses", REG_BOOL, offsetof(DATA_SRV_IP, fAllowClientAddr), (BYTE*)&c_fDefAllowClientAddr },
  150. { HKLM_SVCS, c_szSubkeySrvIpPool, L"From", REG_DWORD,offsetof(DATA_SRV_IP, dwIpStart), (BYTE*)&c_dwDefIpAddr },
  151. { HKLM_SVCS, c_szSubkeySrvIpPool, L"To", REG_DWORD,offsetof(DATA_SRV_IP, dwIpEnd), (BYTE*)&c_dwDefIpAddr },
  152. };
  153. VOID DATA_SRV_IP::SaveToReg () const
  154. {
  155. (VOID) HrRegWriteValues (celems(c_rbDataSrvIp), c_rbDataSrvIp,
  156. (const BYTE*)this,
  157. REG_OPTION_NON_VOLATILE, KEY_WRITE);
  158. }
  159. VOID DATA_SRV_IP::CheckAndDefault ()
  160. {
  161. }
  162. VOID DATA_SRV_IP::GetDefault ()
  163. {
  164. fEnableIn = c_fDefEnableIn;
  165. fAllowNetworkAccess = c_fDefAllowNetworkAccess;
  166. fUseDhcp = c_fDefUseDhcp;
  167. fAllowClientAddr = c_fDefAllowClientAddr;
  168. dwIpStart = 0;
  169. dwIpEnd = 0;
  170. };
  171. //------------------------------------------------------------------------
  172. //
  173. // DATA_SRV_IPX
  174. //
  175. static const WCHAR c_szSubkeySrvIpx [] = L"RemoteAccess\\Parameters\\Ipx";
  176. static const BOOL c_fDefUseAutoAddr = TRUE;
  177. static const BOOL c_fDefUseSameNetNum = TRUE;
  178. static const BOOL c_fDefAllowClientNetNum = TRUE;
  179. static const DWORD c_dwDefIpxNetFirst = 0;
  180. static const DWORD c_dwDefIpxWanPoolSize = 1000;
  181. static const REGBATCH c_rbDataSrvIpx [] =
  182. {
  183. { HKLM_SVCS, c_szSubkeySrvIpx, L"EnableIn", REG_BOOL, offsetof(DATA_SRV_IPX, fEnableIn), (BYTE*)&c_fDefEnableIn },
  184. { HKLM_SVCS, c_szSubkeySrvIpx, L"AllowNetworkAccess", REG_BOOL, offsetof(DATA_SRV_IPX, fAllowNetworkAccess), (BYTE*)&c_fDefAllowNetworkAccess },
  185. { HKLM_SVCS, c_szSubkeySrvIpx, L"AutoWanNetAllocation", REG_BOOL, offsetof(DATA_SRV_IPX, fUseAutoAddr), (BYTE*)&c_fDefUseAutoAddr },
  186. { HKLM_SVCS, c_szSubkeySrvIpx, L"GlobalWanNet", REG_BOOL, offsetof(DATA_SRV_IPX, fUseSameNetNum), (BYTE*)&c_fDefUseSameNetNum },
  187. { HKLM_SVCS, c_szSubkeySrvIpx, L"AcceptRemoteNodeNumber", REG_BOOL, offsetof(DATA_SRV_IPX, fAllowClientNetNum), (BYTE*)&c_fDefAllowClientNetNum },
  188. { HKLM_SVCS, c_szSubkeySrvIpx, L"FirstWanNet", REG_DWORD, offsetof(DATA_SRV_IPX, dwIpxNetFirst), (BYTE*)&c_dwDefIpxNetFirst },
  189. { HKLM_SVCS, c_szSubkeySrvIpx, L"WanNetPoolSize", REG_DWORD, offsetof(DATA_SRV_IPX, dwIpxWanPoolSize), (BYTE*)&c_dwDefIpxWanPoolSize },
  190. };
  191. VOID DATA_SRV_IPX::SaveToReg () const
  192. {
  193. (VOID) HrRegWriteValues (celems(c_rbDataSrvIpx), c_rbDataSrvIpx,
  194. (const BYTE*)this,
  195. REG_OPTION_NON_VOLATILE, KEY_WRITE);
  196. }
  197. VOID DATA_SRV_IPX::CheckAndDefault ()
  198. {
  199. }
  200. VOID DATA_SRV_IPX::GetDefault ()
  201. {
  202. fEnableIn = c_fDefEnableIn;
  203. fAllowNetworkAccess = c_fDefAllowNetworkAccess;
  204. fUseAutoAddr = c_fDefUseAutoAddr;
  205. fUseSameNetNum = c_fDefUseSameNetNum;
  206. fAllowClientNetNum = c_fDefAllowClientNetNum;
  207. dwIpxNetFirst = c_dwDefIpxNetFirst;
  208. dwIpxWanPoolSize = c_dwDefIpxWanPoolSize;
  209. };
  210. //------------------------------------------------------------------------
  211. //
  212. // DATA_SRV_NBF
  213. //
  214. static const WCHAR c_szSubkeySrvNbf [] = L"RemoteAccess\\Parameters\\Nbf";
  215. static const REGBATCH c_rbDataSrvNbf [] =
  216. {
  217. { HKLM_SVCS, c_szSubkeySrvNbf, L"EnableIn", REG_BOOL, offsetof(DATA_SRV_NBF, fEnableIn), (BYTE*)&c_fDefEnableIn },
  218. { HKLM_SVCS, c_szSubkeySrvNbf, L"AllowNetworkAccess", REG_BOOL, offsetof(DATA_SRV_NBF, fAllowNetworkAccess), (BYTE*)&c_fDefAllowNetworkAccess },
  219. };
  220. VOID DATA_SRV_NBF::SaveToReg () const
  221. {
  222. (VOID) HrRegWriteValues (celems(c_rbDataSrvNbf), c_rbDataSrvNbf,
  223. (const BYTE*)this,
  224. REG_OPTION_NON_VOLATILE, KEY_WRITE);
  225. }
  226. VOID DATA_SRV_NBF::CheckAndDefault ()
  227. {
  228. }
  229. VOID DATA_SRV_NBF::GetDefault ()
  230. {
  231. fEnableIn = c_fDefEnableIn;
  232. fAllowNetworkAccess = c_fDefAllowNetworkAccess;
  233. }