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.

304 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. GpcCM.c
  5. Abstract:
  6. Handlers called by GPC for the ClassMap address family.
  7. Author:
  8. Rajesh Sundaram (rajeshsu) 1st Aug, 1998.
  9. Environment:
  10. Kernel Mode
  11. Revision History:
  12. --*/
  13. #include "psched.h"
  14. #pragma hdrstop
  15. #if CBQ
  16. /*++
  17. Routine Description:
  18. A new CF_INFO has been added to the GPC database.
  19. Arguments:
  20. ClientContext - Client context supplied to GpcRegisterClient
  21. GpcCfInfoHandle - GPC's handle to CF_INFO
  22. CfInfoPtr - Pointer to the CF_INFO structure
  23. ClientCfInfoContext - Location in which to return PS's context for
  24. CF_INFO
  25. Return Value:
  26. Status
  27. --*/
  28. GPC_STATUS
  29. ClassMapAddCfInfoNotify(
  30. IN GPC_CLIENT_HANDLE ClientContext,
  31. IN GPC_HANDLE GpcCfInfoHandle,
  32. IN ULONG CfInfoSize,
  33. IN PVOID CfInfoPtr,
  34. IN PGPC_CLIENT_HANDLE ClientCfInfoContext
  35. )
  36. {
  37. #if 0
  38. PCF_INFO_CLASS_MAP CfInfo;
  39. PADAPTER Adapter;
  40. PGPC_CLIENT_VC Vc;
  41. NDIS_STATUS Status;
  42. PPS_WAN_LINK WanLink = 0;
  43. PCLASS_MAP_CONTEXT_BLK pClBlk;
  44. PPS_CLASS_MAP_CONTEXT ClassMapContext, PrevContext;
  45. PPSI_INFO PsComponent, aPsComponent;
  46. PPS_PIPE_CONTEXT PipeContext, aPipeContext;
  47. CfInfo = (PCF_INFO_CLASS_MAP)CfInfoPtr;
  48. //
  49. // Verify that the TcObjectsLength is consistent with the
  50. // CfInfoSize. The CfInfoSize must have been verified during
  51. // the user/kernel transition. The TcObjectsLength has not.
  52. // We could bugcheck if we try to search beyond the buffer
  53. // passed in.
  54. //
  55. if(CfInfoSize < (FIELD_OFFSET(CF_INFO_CLASS_MAP, ClassMapInfo) +
  56. FIELD_OFFSET(TC_CLASS_MAP_FLOW, Objects) +
  57. CfInfo->ClassMapInfo.ObjectsLength)){
  58. return(ERROR_TC_OBJECT_LENGTH_INVALID);
  59. }
  60. Adapter = FindAdapterByWmiInstanceName((USHORT) CfInfo->InstanceNameLength,
  61. (PWSTR) &CfInfo->InstanceName[0],
  62. &WanLink,
  63. TRUE);
  64. if(!Adapter) {
  65. return GPC_STATUS_IGNORED;
  66. }
  67. PS_LOCK(&Adapter->Lock);
  68. if(Adapter->PsMpState != AdapterStateRunning) {
  69. PS_UNLOCK(&Adapter->Lock);
  70. return NDIS_STATUS_FAILURE;
  71. }
  72. PS_UNLOCK(&Adapter->Lock);
  73. //
  74. // Create a context which will be passed back to the GPC. We should be using Lookaside Lists if
  75. // we port CBQ and if this becomes a frequent operation. This will probably not be as frequent
  76. // as creating VCs so we should be fine.
  77. //
  78. PsAllocatePool(pClBlk,
  79. sizeof(CLASS_MAP_CONTEXT_BLK),
  80. PsMiscTag);
  81. if(!pClBlk)
  82. {
  83. return NDIS_STATUS_RESOURCES;
  84. }
  85. pClBlk->Adapter = Adapter;
  86. *ClientCfInfoContext = pClBlk;
  87. if(WanLink)
  88. {
  89. PsAssert(Adapter->MediaType == NdisMediumWan);
  90. PipeContext = aPipeContext = WanLink->PsPipeContext;
  91. PsComponent = aPsComponent = WanLink->PsComponent;
  92. pClBlk->WanLink = WanLink;
  93. }
  94. else
  95. {
  96. PipeContext = aPipeContext = Adapter->PsPipeContext;
  97. PsComponent = aPsComponent = Adapter->PsComponent;
  98. pClBlk->WanLink = 0;
  99. }
  100. //
  101. // Allocate space for the component's context (class map context)
  102. // The length of the class map context buffer for this pipe was
  103. // calculated when the pipe was initialized.
  104. //
  105. PsAllocatePool(pClBlk->ComponentContext,
  106. Adapter->ClassMapContextLength,
  107. ClassMapContextTag );
  108. if ( pClBlk->ComponentContext == NULL ) {
  109. ClientCfInfoContext = 0;
  110. PsFreePool(pClBlk);
  111. return NDIS_STATUS_RESOURCES;
  112. }
  113. //
  114. // Set up the context buffer
  115. //
  116. ClassMapContext = (PPS_CLASS_MAP_CONTEXT)pClBlk->ComponentContext;
  117. PrevContext = NULL;
  118. while (PsComponent != NULL) {
  119. ClassMapContext->NextComponentContext = (PPS_CLASS_MAP_CONTEXT)
  120. ((UINT_PTR)ClassMapContext + PsComponent->ClassMapContextLength);
  121. ClassMapContext->PrevComponentContext = PrevContext;
  122. PsComponent = PipeContext->NextComponent;
  123. PipeContext = PipeContext->NextComponentContext;
  124. PrevContext = ClassMapContext;
  125. ClassMapContext = ClassMapContext->NextComponentContext;
  126. }
  127. Status = (*aPsComponent->CreateClassMap)
  128. (aPipeContext,
  129. ClientContext,
  130. &CfInfo->ClassMapInfo,
  131. pClBlk->ComponentContext);
  132. if(Status == NDIS_STATUS_SUCCESS)
  133. {
  134. if(Adapter->MediaType == NdisMediumWan)
  135. {
  136. //
  137. // To optimize send path
  138. //
  139. InterlockedIncrement(&WanLink->CfInfosInstalled);
  140. }
  141. else
  142. {
  143. //
  144. // To optimize send path
  145. //
  146. InterlockedIncrement(&Adapter->CfInfosInstalled);
  147. }
  148. }
  149. return Status;
  150. #endif
  151. return GPC_STATUS_FAILURE;
  152. }
  153. GPC_STATUS
  154. ClassMapModifyCfInfoNotify(
  155. IN GPC_CLIENT_HANDLE ClientContext,
  156. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  157. IN ULONG CfInfoSize,
  158. IN PVOID NewCfInfoPtr
  159. )
  160. {
  161. return GPC_STATUS_FAILURE;
  162. }
  163. GPC_STATUS
  164. ClassMapRemoveCfInfoNotify(
  165. IN GPC_CLIENT_HANDLE ClientContext,
  166. IN GPC_CLIENT_HANDLE ClientCfInfoContext
  167. )
  168. {
  169. #if 0
  170. PADAPTER Adapter;
  171. NDIS_STATUS Status;
  172. PCLASS_MAP_CONTEXT_BLK pCmBlk = ClientCfInfoContext;
  173. Adapter = pCmBlk->Adapter;
  174. if(Adapter->MediaType == NdisMediumWan)
  175. {
  176. //
  177. // To optimize send path
  178. //
  179. InterlockedDecrement(&WanLink->CfInfosInstalled);
  180. Status = (*pCmBlk->WanLink->PsComponent->DeleteClassMap)
  181. (pCmBlk->WanLink->PsPipeContext,
  182. pCmBlk->ComponentContext);
  183. }
  184. else
  185. {
  186. //
  187. // To Optimize send path
  188. //
  189. InterlockedDecrement(&Adapter->CfInfosInstalled);
  190. Status = (*Adapter->PsComponent->DeleteClassMap)
  191. (Adapter->PsPipeContext,
  192. pCmBlk->ComponentContext);
  193. }
  194. PsFreePool(pCmBlk->ComponentContext);
  195. PsFreePool(pCmBlk);
  196. return Status;
  197. #endif
  198. return GPC_STATUS_FAILURE;
  199. }
  200. VOID
  201. ClassMapAddCfInfoComplete(
  202. IN GPC_CLIENT_HANDLE ClientContext,
  203. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  204. IN GPC_STATUS Status
  205. )
  206. {
  207. //
  208. // The PS never adds CF_INFO's so this routine should never be called
  209. //
  210. DEBUGCHK;
  211. }
  212. VOID
  213. ClassMapModifyCfInfoComplete(
  214. IN GPC_CLIENT_HANDLE ClientContext,
  215. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  216. IN GPC_STATUS Status
  217. )
  218. {
  219. }
  220. VOID
  221. ClassMapRemoveCfInfoComplete(
  222. IN GPC_CLIENT_HANDLE ClientContext,
  223. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  224. IN GPC_STATUS Status
  225. )
  226. {
  227. }
  228. GPC_STATUS
  229. ClassMapClGetCfInfoName(
  230. IN GPC_CLIENT_HANDLE ClientContext,
  231. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  232. OUT PNDIS_STRING InstanceName
  233. )
  234. {
  235. InstanceName->Length = 0;
  236. return(NDIS_STATUS_SUCCESS);
  237. }
  238. #endif