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.

311 lines
7.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. wanarp\adapter.h
  5. Abstract:
  6. Header for adapter.c
  7. Revision History:
  8. AmritanR
  9. --*/
  10. #ifndef __WANARP_ADAPTER_H__
  11. #define __WANARP_ADAPTER_H__
  12. //
  13. // Reader writer locks to protect the lists of interfaces and adapters
  14. //
  15. RW_LOCK g_rwlIfLock;
  16. RW_LOCK g_rwlAdapterLock;
  17. //
  18. // List of interfaces. Protected by g_rwlIfLock
  19. //
  20. LIST_ENTRY g_leIfList;
  21. //
  22. // List of adapters that are bound to wanarp but not added to IP.
  23. // Protected by g_rwlAdapterLock. Adapters are put on this list when
  24. // they are created (with a state of AS_FREE) and again when on an APC they
  25. // are deleted from IP.
  26. //
  27. LIST_ENTRY g_leFreeAdapterList;
  28. ULONG g_ulNumFreeAdapters;
  29. //
  30. // List of adapters added to IP but not mapped. Protected by g_rwlAdapterLock.
  31. // Adapters are put on this list when they are unmapped
  32. // Adapters are removed from this list by the CloseAdapter callback which
  33. // is invoked when we delete the adapter from IP on an APC
  34. // Adapters on this list have a state of AS_ADDED
  35. //
  36. LIST_ENTRY g_leAddedAdapterList;
  37. ULONG g_ulNumAddedAdapters;
  38. //
  39. // List of adapters added to IP and mapped to an interface. Protected
  40. // by g_rwlAdapterLock.
  41. // Adapters are put on this list when they are mapped to an interface.
  42. // This happens for DU_CALLOUT on LinkUp in which case they can be moved
  43. // directly from the free list when there are no added adapters present.
  44. // For DU_ROUTER this can happen on LinkUp or on DemandDialRequest.
  45. // Since DemandDialRequest can occur at DPC, we can only map added
  46. // adapters in that call.
  47. // Adapters are removed when they are unmapped (on LinkDown or
  48. // ProcessConnectionFailure). An adapter on this list can not be deleted
  49. // Adapters on this list have a state of AS_MAPPED or AS_MAPPING
  50. //
  51. LIST_ENTRY g_leMappedAdapterList;
  52. ULONG g_ulNumMappedAdapters;
  53. ULONG g_ulNumDialOutInterfaces;
  54. //
  55. // List of adapters whose state is changing. Protected by g_rwlAdapterLock.
  56. //
  57. LIST_ENTRY g_leChangeAdapterList;
  58. //
  59. // The total number of adapters. Only changed via Interlocked operations.
  60. //
  61. ULONG g_ulNumAdapters;
  62. //
  63. // Stuff needed to maintain state. Only modified via InterlockedXxx
  64. //
  65. LONG g_lBindRcvd;
  66. //
  67. // NdisWan binding related info. All are read-only after initialization
  68. //
  69. UNICODE_STRING g_usNdiswanBindName;
  70. #if DBG
  71. ANSI_STRING g_asNdiswanDebugBindName;
  72. #endif
  73. NDIS_STRING g_nsSystemSpecific1;
  74. NDIS_HANDLE g_nhNdiswanBinding;
  75. //
  76. // The description string for our interfaces
  77. //
  78. #define VENDOR_DESCRIPTION_STRING "WAN (PPP/SLIP) Interface"
  79. #define VENDOR_DESCRIPTION_STRING_LEN (strlen(VENDOR_DESCRIPTION_STRING))
  80. INT
  81. WanIpBindAdapter(
  82. IN PNDIS_STATUS pnsRetStatus,
  83. IN NDIS_HANDLE nhBindContext,
  84. IN PNDIS_STRING pnsAdapterName,
  85. IN PVOID pvSS1,
  86. IN PVOID pvSS2
  87. );
  88. NDIS_STATUS
  89. WanpOpenNdisWan(
  90. PNDIS_STRING pnsAdapterName,
  91. PNDIS_STRING pnsSystemSpecific1
  92. );
  93. VOID
  94. WanNdisOpenAdapterComplete(
  95. NDIS_HANDLE nhHandle,
  96. NDIS_STATUS nsStatus,
  97. NDIS_STATUS nsErrorStatus
  98. );
  99. VOID
  100. WanpSetProtocolTypeComplete(
  101. NDIS_HANDLE nhHandle,
  102. struct _WANARP_NDIS_REQUEST_CONTEXT *pRequestContext,
  103. NDIS_STATUS nsStatus
  104. );
  105. VOID
  106. WanpSetLookaheadComplete(
  107. NDIS_HANDLE nhHandle,
  108. struct _WANARP_NDIS_REQUEST_CONTEXT *pRequestContext,
  109. NDIS_STATUS nsStatus
  110. );
  111. VOID
  112. WanpSetPacketFilterComplete(
  113. NDIS_HANDLE nhHandle,
  114. struct _WANARP_NDIS_REQUEST_CONTEXT *pRequestContext,
  115. NDIS_STATUS nsStatus
  116. );
  117. VOID
  118. WanpLastOidComplete(
  119. NDIS_HANDLE nhHandle,
  120. struct _WANARP_NDIS_REQUEST_CONTEXT *pRequestContext,
  121. NDIS_STATUS nsStatus
  122. );
  123. NTSTATUS
  124. WanpInitializeAdapters(
  125. PVOID pvContext
  126. );
  127. NTSTATUS
  128. WanpCreateAdapter(
  129. IN GUID *pAdapterGuid,
  130. IN PUNICODE_STRING pusConfigName,
  131. IN PUNICODE_STRING pusDeviceName,
  132. OUT ADAPTER **ppNewAdapter
  133. );
  134. PADAPTER
  135. WanpFindAdapterToMap(
  136. IN DIAL_USAGE duUsage,
  137. OUT PKIRQL pkiIrql,
  138. IN DWORD dwAdapterIndex, OPTIONAL
  139. IN PUNICODE_STRING pusNewIfName OPTIONAL
  140. );
  141. NTSTATUS
  142. WanpAddAdapterToIp(
  143. IN PADAPTER pAdapter,
  144. IN BOOLEAN bServerAdapter,
  145. IN DWORD dwAdapterIndex, OPTIONAL
  146. IN PUNICODE_STRING pusNewIfName, OPTIONAL
  147. IN DWORD dwMediaType,
  148. IN BYTE byAccessType,
  149. IN BYTE byConnectionType
  150. );
  151. VOID
  152. WanpUnmapAdapter(
  153. PADAPTER pAdapter
  154. );
  155. VOID
  156. WanIpOpenAdapter(
  157. IN PVOID pvContext
  158. );
  159. VOID
  160. WanIpCloseAdapter(
  161. IN PVOID pvContext
  162. );
  163. VOID
  164. WanNdisCloseAdapterComplete(
  165. NDIS_HANDLE nhBindHandle,
  166. NDIS_STATUS nsStatus
  167. );
  168. VOID
  169. WanpFreeBindResourcesAndReleaseLock(
  170. VOID
  171. );
  172. INT
  173. WanIpDynamicRegister(
  174. IN PNDIS_STRING InterfaceName,
  175. IN PVOID pvIpInterfaceContext,
  176. IN struct _IP_HANDLERS * IpHandlers,
  177. IN struct LLIPBindInfo * ARPBindInfo,
  178. IN UINT uiInterfaceNumber
  179. );
  180. NDIS_STATUS
  181. WanpDoNdisRequest(
  182. IN NDIS_REQUEST_TYPE RequestType,
  183. IN NDIS_OID Oid,
  184. IN PVOID pvInfo,
  185. IN UINT uiInBufferLen,
  186. IN PWANARP_NDIS_REQUEST_CONTEXT pRequestContext,
  187. IN PFNWANARP_REQUEST_COMPLETION_HANDLER pfnCompletionHandler OPTIONAL
  188. );
  189. VOID
  190. WanNdisRequestComplete(
  191. IN NDIS_HANDLE nhHandle,
  192. IN PNDIS_REQUEST pRequest,
  193. IN NDIS_STATUS nsStatus
  194. );
  195. PUMODE_INTERFACE
  196. WanpFindInterfaceGivenIndex(
  197. DWORD dwIfIndex
  198. );
  199. VOID
  200. WanpRemoveSomeAddedAdaptersFromIp(
  201. PVOID pvContext
  202. );
  203. VOID
  204. WanpRemoveAllAdaptersFromIp(
  205. VOID
  206. );
  207. VOID
  208. WanpRemoveAllAdapters(
  209. VOID
  210. );
  211. VOID
  212. WanpDeleteAdapter(
  213. IN PADAPTER pAdapter
  214. );
  215. NDIS_STATUS
  216. WanNdisPnPEvent(
  217. NDIS_HANDLE nhProtocolBindingContext,
  218. PNET_PNP_EVENT pNetPnPEvent
  219. );
  220. VOID
  221. WanNdisResetComplete(
  222. NDIS_HANDLE nhHandle,
  223. NDIS_STATUS nsStatus
  224. );
  225. VOID
  226. WanNdisBindAdapter(
  227. PNDIS_STATUS pnsRetStatus,
  228. NDIS_HANDLE nhBindContext,
  229. PNDIS_STRING nsAdapterName,
  230. PVOID pvSystemSpecific1,
  231. PVOID pvSystemSpecific2
  232. );
  233. VOID
  234. WanNdisUnbindAdapter(
  235. PNDIS_STATUS pnsRetStatus,
  236. NDIS_HANDLE nhProtocolContext,
  237. NDIS_HANDLE nhUnbindContext
  238. );
  239. VOID
  240. WanpCloseNdisWan(
  241. PVOID pvContext
  242. );
  243. #endif // __WANARP_ADAPTER_H__