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.

302 lines
8.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: B I N D O B J . H
  7. //
  8. // Contents: Declaration of base class for RAS binding objects.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 11 Jun 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <ncxbase.h>
  17. #include <notifval.h>
  18. #include "resource.h"
  19. #include "rasaf.h"
  20. #include "rasdata.h"
  21. #include "ncutil.h"
  22. enum RAS_BINDING_ID
  23. {
  24. RBID_INVALID = 0,
  25. RBID_NDISATM,
  26. RBID_NDISCOWAN,
  27. RBID_NDISWAN,
  28. RBID_NDISWANASYNC,
  29. };
  30. enum RAS_PROTOCOL_IDS
  31. {
  32. RPI_IP = 0x00000001,
  33. RPI_IPX = 0x00000002,
  34. RPI_NBF = 0x00000004,
  35. RPI_ATALK = 0x00000008,
  36. RPI_NETMON = 0x00000010,
  37. RPI_ALL = 0xFFFFFFFF,
  38. };
  39. struct RAS_ENDPOINT_INFO
  40. {
  41. UINT cDialIn;
  42. UINT cDialOut;
  43. UINT cEndpoints;
  44. };
  45. class CRasBindObject
  46. {
  47. public:
  48. // Make these members public for now. Since this object
  49. // is instantiated from the modem class installer. We
  50. // need to set the INetCfg member.
  51. //
  52. INetCfg* m_pnc;
  53. CRasBindObject ();
  54. ~CRasBindObject ()
  55. {
  56. ReleaseObj (m_pnc);
  57. }
  58. // You must call ReleaseOtherComponents after calling this.
  59. HRESULT HrFindOtherComponents ();
  60. // You can only call this once per call to HrFindOtherComponents.
  61. NOTHROW VOID ReleaseOtherComponents ();
  62. HRESULT HrProcessEndpointChange ();
  63. NOTHROW INetCfgComponent* PnccNdisWan ();
  64. protected:
  65. // We keep an array of INetCfgComponent pointers. This enum
  66. // defines the indicies of the array. The static arrays of
  67. // class guids and component ids identify the respecitive components.
  68. // HrFindOtherComonents initializes the array of component pointers
  69. // and ReleaseOtherComponents releases them. Note, however, that this
  70. // action is refcounted. This is because we are re-entrant.
  71. // HrFindOtherComponents only finds the components if the refcount is
  72. // zero. After every call, it increments the refcount.
  73. // ReleaseOtherComponents always decrements the refcount and only
  74. // releases the components if the refcount is zero.
  75. //
  76. enum OTHER_COMPONENTS
  77. {
  78. c_ipnccRasCli = 0,
  79. c_ipnccRasSrv,
  80. c_ipnccIp,
  81. c_ipnccIpx,
  82. c_ipnccNbf,
  83. c_ipnccAtalk,
  84. c_ipnccNetMon,
  85. c_ipnccNdisWan,
  86. c_ipnccIpAdapter,
  87. c_cOtherComponents,
  88. };
  89. static const GUID* c_apguidComponentClasses [c_cOtherComponents];
  90. static const PCWSTR c_apszComponentIds [c_cOtherComponents];
  91. INetCfgComponent* m_apnccOther [c_cOtherComponents];
  92. ULONG m_ulOtherComponents;
  93. protected:
  94. BOOL FIsRasBindingInterface (INetCfgBindingInterface* pncbi,
  95. RAS_BINDING_ID* pRasBindId);
  96. HRESULT HrCountInstalledMiniports (UINT* pcIpOut,
  97. UINT* pcNbfIn,
  98. UINT* pcNbfOut);
  99. HRESULT HrCountWanAdapterEndpoints (INetCfgComponent* pncc,
  100. RAS_BINDING_ID RasBindId,
  101. UINT* pcEndpoints);
  102. HRESULT HrAddOrRemoveAtalkInOut (DWORD dwFlags);
  103. HRESULT HrAddOrRemoveIpAdapter (DWORD dwFlags);
  104. HRESULT HrAddOrRemoveIpOut (INT nInstances);
  105. HRESULT HrAddOrRemoveIpxInOut (DWORD dwFlags);
  106. HRESULT HrAddOrRemoveNbfIn (INT nInstances);
  107. HRESULT HrAddOrRemoveNbfOut (INT nInstances);
  108. HRESULT HrAddOrRemoveNetMonInOut(DWORD dwFlags);
  109. HRESULT HrAddOrRemovePti (DWORD dwFlags);
  110. NOTHROW INetCfgComponent* PnccRasCli ();
  111. NOTHROW INetCfgComponent* PnccRasSrv ();
  112. NOTHROW INetCfgComponent* PnccRasRtr ();
  113. NOTHROW INetCfgComponent* PnccIp ();
  114. NOTHROW INetCfgComponent* PnccIpx ();
  115. NOTHROW INetCfgComponent* PnccNbf ();
  116. NOTHROW INetCfgComponent* PnccAtalk ();
  117. NOTHROW INetCfgComponent* PnccNetMon ();
  118. NOTHROW INetCfgComponent* PnccIpAdapter ();
  119. };
  120. extern const WCHAR c_szInfId_MS_NdisWanAtalk[];
  121. extern const WCHAR c_szInfId_MS_NdisWanIp[];
  122. extern const WCHAR c_szInfId_MS_NdisWanIpx[];
  123. extern const WCHAR c_szInfId_MS_NdisWanNbfIn[];
  124. extern const WCHAR c_szInfId_MS_NdisWanNbfOut[];
  125. extern const WCHAR c_szInfId_MS_NdisWanBh[];
  126. extern const WCHAR c_szInfId_MS_PtiMiniport[];
  127. inline
  128. HRESULT
  129. CRasBindObject::HrAddOrRemoveAtalkInOut (
  130. DWORD dwFlags)
  131. {
  132. return HrEnsureZeroOrOneAdapter (m_pnc, c_szInfId_MS_NdisWanAtalk, dwFlags);
  133. }
  134. inline
  135. HRESULT
  136. CRasBindObject::HrAddOrRemoveIpAdapter (
  137. DWORD dwFlags)
  138. {
  139. return HrEnsureZeroOrOneAdapter (m_pnc, c_szInfId_MS_NdisWanIp, dwFlags);
  140. }
  141. inline
  142. HRESULT
  143. CRasBindObject::HrAddOrRemoveIpxInOut (
  144. DWORD dwFlags)
  145. {
  146. return HrEnsureZeroOrOneAdapter (m_pnc, c_szInfId_MS_NdisWanIpx, dwFlags);
  147. }
  148. inline
  149. HRESULT
  150. CRasBindObject::HrAddOrRemoveNbfIn (
  151. INT nInstances)
  152. {
  153. DWORD dwFlags = (nInstances > 0) ? ARA_ADD : ARA_REMOVE;
  154. UINT cInstances = (nInstances > 0) ? nInstances : 0 - nInstances;
  155. TraceTag (ttidRasCfg, "%s %d %S adapters",
  156. (nInstances > 0) ? "Adding" : "Removing",
  157. cInstances,
  158. c_szInfId_MS_NdisWanNbfIn);
  159. return HrAddOrRemoveAdapter (m_pnc, c_szInfId_MS_NdisWanNbfIn,
  160. dwFlags, NULL, cInstances, NULL);
  161. }
  162. inline
  163. HRESULT
  164. CRasBindObject::HrAddOrRemoveNbfOut (
  165. INT nInstances)
  166. {
  167. DWORD dwFlags = (nInstances > 0) ? ARA_ADD : ARA_REMOVE;
  168. UINT cInstances = (nInstances > 0) ? nInstances : 0 - nInstances;
  169. TraceTag (ttidRasCfg, "%s %d %S adapters",
  170. (nInstances > 0) ? "Adding" : "Removing",
  171. cInstances,
  172. c_szInfId_MS_NdisWanNbfOut);
  173. return HrAddOrRemoveAdapter (m_pnc, c_szInfId_MS_NdisWanNbfOut,
  174. dwFlags, NULL, cInstances, NULL);
  175. }
  176. inline
  177. HRESULT
  178. CRasBindObject::HrAddOrRemoveNetMonInOut (
  179. DWORD dwFlags)
  180. {
  181. return HrEnsureZeroOrOneAdapter (m_pnc, c_szInfId_MS_NdisWanBh, dwFlags);
  182. }
  183. inline
  184. HRESULT
  185. CRasBindObject::HrAddOrRemovePti (
  186. DWORD dwFlags)
  187. {
  188. return HrEnsureZeroOrOneAdapter (m_pnc, c_szInfId_MS_PtiMiniport, dwFlags);
  189. }
  190. inline
  191. NOTHROW
  192. INetCfgComponent*
  193. CRasBindObject::PnccRasCli ()
  194. {
  195. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  196. return m_apnccOther [c_ipnccRasCli];
  197. }
  198. inline
  199. NOTHROW
  200. INetCfgComponent*
  201. CRasBindObject::PnccRasSrv ()
  202. {
  203. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  204. return m_apnccOther [c_ipnccRasSrv];
  205. }
  206. inline
  207. NOTHROW
  208. INetCfgComponent*
  209. CRasBindObject::PnccIp ()
  210. {
  211. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  212. return m_apnccOther [c_ipnccIp];
  213. }
  214. inline
  215. NOTHROW
  216. INetCfgComponent*
  217. CRasBindObject::PnccIpx ()
  218. {
  219. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  220. return m_apnccOther [c_ipnccIpx];
  221. }
  222. inline
  223. NOTHROW
  224. INetCfgComponent*
  225. CRasBindObject::PnccNbf ()
  226. {
  227. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  228. return m_apnccOther [c_ipnccNbf];
  229. }
  230. inline
  231. NOTHROW
  232. INetCfgComponent*
  233. CRasBindObject::PnccAtalk ()
  234. {
  235. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  236. return m_apnccOther [c_ipnccAtalk];
  237. }
  238. inline
  239. NOTHROW
  240. INetCfgComponent*
  241. CRasBindObject::PnccNetMon ()
  242. {
  243. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  244. return m_apnccOther [c_ipnccNetMon];
  245. }
  246. inline
  247. NOTHROW
  248. INetCfgComponent*
  249. CRasBindObject::PnccIpAdapter ()
  250. {
  251. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  252. return m_apnccOther [c_ipnccIpAdapter];
  253. }
  254. inline
  255. NOTHROW
  256. INetCfgComponent*
  257. CRasBindObject::PnccNdisWan ()
  258. {
  259. AssertSzH (m_ulOtherComponents, "You have not called HrFindOtherComponents yet.");
  260. //AssertSzH (m_apnccOther [c_ipnccNdisWan], "The NdisWan component was not found, but we installed it!");
  261. return m_apnccOther [c_ipnccNdisWan];
  262. }