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.

328 lines
10 KiB

  1. Issues
  2. ------
  3. WAN devices vs. LAN devices. Can we gen an indications of the "subclass"?
  4. Last protocol to be removed should cause something to happen with RAS.
  5. Can we reference count adapter installs? (Maybe for Beta2)
  6. RasCli, RasSrv, RasRtr NetworkInstall and Install
  7. -------------------------------------------------
  8. Install NdisWan
  9. NdisWan NetworkInstall and Install
  10. ----------------------------------
  11. Install PPTP
  12. RasCli QueryBindingInterface (NCN_LOWER)
  13. ----------------------------------------
  14. if (binding == "rasPortUse") // enable dial-out port
  15. {
  16. // if a component is being added, default the binding
  17. // to disabled on the server product.
  18. if (NCN_ADD && FProdServer)
  19. return NETCFG_DISABLEQUERY
  20. }
  21. RasSrv QueryBindingInterface (NCN_LOWER)
  22. ----------------------------------------
  23. if (binding == "rasPortUse") // enable dial-in port
  24. {
  25. // if a component is being added, default the binding
  26. // to disabled on the workstation product.
  27. if (NCN_ADD && FProdWorkstation)
  28. {
  29. return NETCG_S_DISABLE_QUERY
  30. }
  31. // if someone is trying to enable this binding on
  32. // the workstation product, veto it if we already have
  33. // at least one binding of this type enabled.
  34. if (NBF_ENABLED && FProdWorkstation)
  35. {
  36. Iterate our enabled binding paths
  37. Iterate the binding interfaces along this path
  38. if (GetName == "rasPortUse")
  39. return NETCFG_S_VETO_QUERY
  40. }
  41. }
  42. PPTP
  43. ----
  44. NetworkInstall and Install
  45. {
  46. AddVpnEndpoints(1)
  47. }
  48. ApplyProperties
  49. {
  50. dEndpoints = nEnpointsNew - nEndpointsCur;
  51. if (dEndpoints > 0)
  52. AddEndpoints(dEndpoints)
  53. else if (dEndpoints < 0)
  54. RemoveEndpoints(-dEndpoints)
  55. Write registry parameters
  56. }
  57. AddVpnEndpoints(n)
  58. {
  59. Add n components with device id of "VaPptpEndpoint"
  60. }
  61. RemoveVpnEndpoints(n)
  62. {
  63. Remove first n components with device id of "VaPptpEndpoint"
  64. }
  65. NdisWan
  66. -------
  67. Add Protocol -or- Enable binding over "rasTransUse" interface.
  68. (Handle this via SysNotifyBindingInterface(NCN_ENABLE) for "rasTransUse")
  69. {
  70. nDialOut = Get number of dial-out adapters bound below using "ndisWanAdapter"
  71. nDialIn = Get number of dial-in adapters bound below using "ndisWanAdapter"
  72. {
  73. Get RasCli component using INetCfg and INetCfgClass
  74. Get RasSrv component using INetCfg and INetCfgClass
  75. Iterate our enabled binding paths
  76. Iterate binding interfaces along this path
  77. if (GetName == "ndisWanAdapter")
  78. {
  79. GetLowerComponent // this is the adapter
  80. GetPortUsage(LowerComponent, &fDialOut, &fDialIn)
  81. if (fDialOut) nDialOut++
  82. if (fDialIn) nDialIn++
  83. }
  84. }
  85. Create WanWrap devices for protocol being added
  86. {
  87. if (protocol == "Ip")
  88. {
  89. AddComponentNTimes("WanwrapIpOut", nDialOut)
  90. if (nDialIn > 0)
  91. AddComponentRefCount("WanwrapIpIn", &m_cRefIpIn)
  92. }
  93. else if (protocol == "Ipx")
  94. {
  95. if ((nDialOut > 0) || (nDialIn > 0))
  96. AddComponentRefCount("WanwrapIpx", &m_cRefIpx)
  97. }
  98. else if (protocol == "Nbf")
  99. {
  100. AddComponentNTimes("WanwrapNbfOut", nDialOut)
  101. AddComponentNTimes("WanwrapNbfIn", nDialIn)
  102. }
  103. }
  104. }
  105. Remove Protocol -or- Disable binding over "rasTransUse" interface.
  106. (Handle this via SysNotifyBindingInterface(NCN_DISABLE) for "rasTransUse")
  107. {
  108. Get a pointer to the constant, static list of binding interfaces that
  109. involve this protocol.
  110. {
  111. if (protocol == "Ip")
  112. list = { WanwrapIpIn, WanwrapIpOut }
  113. else if (protocol == "Ipx")
  114. list = { WanwrapIpx }
  115. else if (protocol == "Nbf")
  116. list = { WanwrapNbfIn, WanwrapNbfOut }
  117. }
  118. Iterate our lower binding paths
  119. Iterate binding interfaces along this path
  120. if (GetName is in list)
  121. Remove the lower component
  122. }
  123. Add WAN Adapter
  124. (Handle this via NotifyBindingInterface(NCN_LOWER | NCN_ENABLE) for "ndisWanAdapter")
  125. {
  126. if (Component supports upper-edge interface of "rasPortUse")
  127. {
  128. return S_OK;
  129. // We'll pick up this change when we get a SysNotifyBindingInterface
  130. // for "rasPortUse". If we did it here as well, we'd be adding
  131. // wan wrappers twice and we don't want to do that.
  132. }
  133. // Otherwise, we're adding a port which cannot have its usage controlled.
  134. // Therefore, its both dial-in and dial-out.
  135. fDialOut = TRUE;
  136. fDialIn = TRUE;
  137. AddWanWrapperForAllProtocols(fDialOut, fDialIn)
  138. }
  139. Enable binding over "rasPortUse" interface.
  140. (Handle this via SysNotifyBindingInterface(NCN_ENABLE) for "rasPortUse")
  141. {
  142. GetPortUsage(Component, &fDialOut, &fDialIn)
  143. AddWanWrappersForAllProtocols(fDialOut, fDialIn);
  144. }
  145. Remove WAN Adapter
  146. (Handle this via NotifyBindingInterface(NCN_LOWER | NCN_DISABLE) for "ndisWanAdapter")
  147. {
  148. if (Component supports upper-edge interface of "rasPortUse")
  149. {
  150. return S_OK;
  151. // We'll pick up this change when we get a SysNotifyBindingInterface
  152. // for "rasPortUse". If we did it here as well, we'd be adding
  153. // wan wrappers twice and we don't want to do that.
  154. }
  155. // Otherwise, we're removing a port which cannot have its usage controlled.
  156. // Therefore, its both dial-in and dial-out.
  157. fDialOut = TRUE;
  158. fDialIn = TRUE;
  159. RemoveWanWrapperForAllProtocols(fDialOut, fDialIn)
  160. }
  161. Disable binding over "rasPortUse" interface.
  162. (Handle this via SysNotifyBindingInterface(NCN_DISABLE) for "rasPortUse")
  163. {
  164. GetPortUsage(Component, &fDialOut, &fDialIn)
  165. RemoveWanWrapperForAllProtocols(fDialOut, fDialIn);
  166. }
  167. Helper function: GetPortUsage(Component*, pfDialOut, pfDialIn)
  168. {
  169. if (Component does not support an upper-edge binding
  170. interface of "rasPortUse")
  171. {
  172. *pfDialOut = *pfDialIn = TRUE
  173. }
  174. else
  175. {
  176. if (LowerComponent->IsBoundTo(RasCli))
  177. *pfDialOut = TRUE
  178. if (LowerComponent->IsBoundTo(RasSrv))
  179. *pfDialIn = TRUE
  180. }
  181. }
  182. Helper function: AddWanWrapperForAllProtocols(fDialOut, fDialIn)
  183. {
  184. Get Ip component using INetCfg and INetCfgClass
  185. Get Ipx component using INetCfg and INetCfgClass
  186. Get Nbf component using INetCfg and INetCfgClass
  187. if (fDialOut)
  188. {
  189. if (Ip && Ip->IsBoundTo(RasCli))
  190. AddComponent("WanwrapIpOut") (no more than 64)
  191. if (Ipx && Ipx->IsBoundTo(RasCli))
  192. AddComponentRefCount("WanwrapIpx", &m_cRefIpx)
  193. if (Nbf && Nbf->IsBoundTo(RasCli))
  194. AddComponent("WanwrapNbfOut") (no more than 255)
  195. }
  196. if (fDialIn)
  197. {
  198. if (Ip && Ip->IsBoundTo(RasSrv))
  199. AddComponentRefCount("WanwrapIpIn", &m_cRefIpIn)
  200. if (Ipx && Ipx->IsBoundTo(RasSrv))
  201. AddComponentRefCount("WanwrapIpx", &m_cRefIpx)
  202. if (Nbf && Nbf->IsBoundTo(RasSrv))
  203. AddComponent("WanwrapNbfIn")
  204. }
  205. }
  206. Helper function: RemoveWanWrapperForAllProtocols(fDialOut, fDialIn)
  207. {
  208. Get Ip component using INetCfg and INetCfgClass
  209. Get Ipx component using INetCfg and INetCfgClass
  210. Get Nbf component using INetCfg and INetCfgClass
  211. if (fDialOut)
  212. {
  213. if (Ip && Ip->IsBoundTo(RasCli))
  214. RemoveComponent("WanwrapIpOut")
  215. if (Ipx && Ipx->IsBoundTo(RasCli))
  216. RemoveComponentRefCount("WanwrapIpx", &m_cRefIpx)
  217. if (Nbf && Nbf->IsBoundTo(RasCli))
  218. RemoveComponent("WanwrapNbfOut")
  219. }
  220. if (fDialIn)
  221. {
  222. if (Ip && Ip->IsBoundTo(RasSrv))
  223. RemoveComponentRefCount("WanwrapIpIn", &m_cRefIpIn)
  224. if (Ipx && Ipx->IsBoundTo(RasSrv))
  225. RemoveComponentRefCount("WanwrapIpx", &m_cRefIpx)
  226. if (Nbf && Nbf->IsBoundTo(RasSrv))
  227. RemoveComponent("WanwrapNbfIn")
  228. }
  229. }
  230. #ifdef NEVER
  231. //--------------------------------------------------------
  232. // Get the interface to enumerate our binding paths.
  233. IEnumNetCfgBindingPath* pebp;
  234. if (SUCCEEDED(hr = m_pnccMe->EnumBindingPaths(&pebp)))
  235. {
  236. CIEnumIter<IEnumNetCfgBindingPath, INetCfgBindingPath> ei(pebp);
  237. INetCfgBindingPath* pncbp;
  238. while (SUCCEEDED(hr = ei.HrNext(&pncbp)) && (S_FALSE != hr))
  239. {
  240. ReleaseObj(pncbp);
  241. }
  242. // Get the next batch of binding path interfaces.
  243. const ULONG c_celtBatch = 512;
  244. ULONG celtFetched;
  245. INetCfgBindingPath* apbp;
  246. do
  247. {
  248. if (SUCCEEDED(hr = pebp->Next(c_celtBatch, &apbp, &celtFetched)))
  249. {
  250. // Make sure the implementor of Next is obeying the rules.
  251. Assert(FImplies((S_OK == hr), (celtFetched == c_celtBatch)));
  252. // Iterate this batch of interfaces.
  253. INetCfgBindingPath* pncbp;
  254. for (pncbp = apbp; pncbp < apbp + celtFetched; pncbp++)
  255. {
  256. //--------------------------------------------------------
  257. // Get the interface to enumerate the interfaces along this path.
  258. ReleaseObj(pncbp);
  259. }
  260. // Free this batch of binding path interfaces;
  261. CoTaskMemFree(apbp);
  262. }
  263. }
  264. while (SUCCEEDED(hr) && (celtFetched >= c_celtBatch));
  265. // Release the binding path enumerator.
  266. ReleaseObj(pebp);
  267. }
  268. #endif