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.

313 lines
7.6 KiB

  1. /*--Copyright (c) 1991 Microsoft Corporation
  2. Module Name:
  3. pnp.c
  4. Abstract:
  5. PnP specific code for TCP.
  6. Author:
  7. Munil Shah (munils) Mar 7, 1997
  8. Revision History:
  9. Notes:
  10. --*/
  11. #include "precomp.h"
  12. #include "addr.h"
  13. #include "tcp.h"
  14. #include "raw.h"
  15. #include "udp.h"
  16. #include "tcb.h"
  17. #include "tcpconn.h"
  18. NTSTATUS
  19. TCPQueryConnDeviceRelations(
  20. IN PIRP Irp,
  21. IN PIO_STACK_LOCATION IrpSp
  22. );
  23. NTSTATUS
  24. TCPQueryAddrDeviceRelations(
  25. IN PIRP Irp,
  26. IN PIO_STACK_LOCATION IrpSp
  27. );
  28. NTSTATUS
  29. TCPPnPReconfigRequest(
  30. IN void *ipContext,
  31. IN IPAddr ipAddr,
  32. IN NDIS_HANDLE handle,
  33. IN PIP_PNP_RECONFIG_REQUEST reconfigBuffer
  34. );
  35. NTSTATUS
  36. UDPPnPReconfigRequest(
  37. IN void *ipContext,
  38. IN IPAddr ipAddr,
  39. IN NDIS_HANDLE handle,
  40. IN PIP_PNP_RECONFIG_REQUEST reconfigBuffer
  41. );
  42. NTSTATUS
  43. RawPnPReconfigRequest(
  44. IN void *ipContext,
  45. IN IPAddr ipAddr,
  46. IN NDIS_HANDLE handle,
  47. IN PIP_PNP_RECONFIG_REQUEST reconfigBuffer
  48. );
  49. extern TDI_STATUS
  50. IPGetDeviceRelation(RouteCacheEntry * rce, PVOID * pnpDeviceContext);
  51. extern void
  52. DeleteProtocolSecurityFilter(IPAddr InterfaceAddress, ulong Protocol);
  53. extern void
  54. ControlSecurityFiltering(uint IsEnabled);
  55. extern void
  56. AddProtocolSecurityFilter(IPAddr InterfaceAddress, ulong Protocol,
  57. NDIS_HANDLE ConfigHandle);
  58. NTSTATUS
  59. TCPPnPPowerRequest(void *ipContext, IPAddr ipAddr, NDIS_HANDLE handle, PNET_PNP_EVENT netPnPEvent)
  60. {
  61. switch (netPnPEvent->NetEvent) {
  62. case NetEventReconfigure:{
  63. PIP_PNP_RECONFIG_REQUEST reconfigBuffer = (PIP_PNP_RECONFIG_REQUEST) netPnPEvent->Buffer;
  64. return TCPPnPReconfigRequest(
  65. ipContext,
  66. ipAddr,
  67. handle,
  68. reconfigBuffer
  69. );
  70. }
  71. default:
  72. break;
  73. }
  74. return STATUS_SUCCESS;
  75. }
  76. NTSTATUS
  77. UDPPnPPowerRequest(void *ipContext, IPAddr ipAddr, NDIS_HANDLE handle, PNET_PNP_EVENT netPnPEvent)
  78. {
  79. switch (netPnPEvent->NetEvent) {
  80. case NetEventReconfigure:{
  81. PIP_PNP_RECONFIG_REQUEST reconfigBuffer = (PIP_PNP_RECONFIG_REQUEST) netPnPEvent->Buffer;
  82. return UDPPnPReconfigRequest(
  83. ipContext,
  84. ipAddr,
  85. handle,
  86. reconfigBuffer
  87. );
  88. }
  89. default:
  90. break;
  91. }
  92. return STATUS_SUCCESS;
  93. }
  94. NTSTATUS
  95. RawPnPPowerRequest(void *ipContext, IPAddr ipAddr, NDIS_HANDLE handle, PNET_PNP_EVENT netPnPEvent)
  96. {
  97. switch (netPnPEvent->NetEvent) {
  98. case NetEventReconfigure:{
  99. PIP_PNP_RECONFIG_REQUEST reconfigBuffer = (PIP_PNP_RECONFIG_REQUEST) netPnPEvent->Buffer;
  100. return RawPnPReconfigRequest(
  101. ipContext,
  102. ipAddr,
  103. handle,
  104. reconfigBuffer
  105. );
  106. }
  107. default:
  108. break;
  109. }
  110. return STATUS_SUCCESS;
  111. }
  112. NTSTATUS
  113. TCPPnPReconfigRequest(void *ipContext, IPAddr ipAddr, NDIS_HANDLE handle, PIP_PNP_RECONFIG_REQUEST reconfigBuffer)
  114. {
  115. return STATUS_SUCCESS;
  116. }
  117. NTSTATUS
  118. UDPPnPReconfigRequest(void *ipContext, IPAddr ipAddr, NDIS_HANDLE handle, PIP_PNP_RECONFIG_REQUEST reconfigBuffer)
  119. {
  120. return STATUS_SUCCESS;
  121. }
  122. NTSTATUS
  123. RawPnPReconfigRequest(void *ipContext, IPAddr ipAddr, NDIS_HANDLE handle, PIP_PNP_RECONFIG_REQUEST reconfigBuffer)
  124. {
  125. return STATUS_SUCCESS;
  126. }
  127. NTSTATUS
  128. TCPDispatchPnPPower(
  129. IN PIRP irp,
  130. IN PIO_STACK_LOCATION irpSp
  131. )
  132. /*++
  133. Routine Description:
  134. Processes pnp power irps.
  135. Arguments:
  136. Irp - Pointer to I/O request packet
  137. IrpSp - Pointer to the current stack location in the Irp.
  138. Return Value:
  139. NTSTATUS -- Indicates whether the request was successful.
  140. Notes:
  141. --*/
  142. {
  143. NTSTATUS status;
  144. status = STATUS_INVALID_DEVICE_REQUEST;
  145. switch (irpSp->MinorFunction) {
  146. case IRP_MN_QUERY_DEVICE_RELATIONS:
  147. if (irpSp->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation) {
  148. if (PtrToUlong(irpSp->FileObject->FsContext2) == TDI_CONNECTION_FILE) {
  149. return TCPQueryConnDeviceRelations(irp, irpSp);
  150. } else if (PtrToUlong(irpSp->FileObject->FsContext2) == TDI_TRANSPORT_ADDRESS_FILE) {
  151. return TCPQueryAddrDeviceRelations(irp, irpSp);
  152. }
  153. }
  154. break;
  155. default:
  156. break;
  157. }
  158. return status;
  159. }
  160. NTSTATUS
  161. TCPQueryConnDeviceRelations(
  162. IN PIRP Irp,
  163. IN PIO_STACK_LOCATION IrpSp
  164. )
  165. /*++
  166. Routine Description:
  167. Processes pnp power irps.
  168. Arguments:
  169. Irp - Pointer to I/O request packet
  170. IrpSp - Pointer to the current stack location in the Irp.
  171. Return Value:
  172. NTSTATUS -- Indicates whether the request was successful.
  173. Notes:
  174. --*/
  175. {
  176. PTCP_CONTEXT tcpContext;
  177. CONNECTION_CONTEXT ConnectionContext;
  178. TCB *TCB;
  179. TCPConn *Conn;
  180. PVOID pnpDeviceContext;
  181. TDI_STATUS status;
  182. PDEVICE_RELATIONS deviceRelations = NULL;
  183. CTELockHandle ConnHandle;
  184. tcpContext = (PTCP_CONTEXT) IrpSp->FileObject->FsContext;
  185. ConnectionContext = tcpContext->Handle.ConnectionContext;
  186. // find connection.
  187. Conn = GetConnFromConnID(PtrToUlong(ConnectionContext), &ConnHandle);
  188. if (Conn != NULL) {
  189. // get the tcb for this connection.
  190. TCB = Conn->tc_tcb;
  191. if (TCB) {
  192. // get device relations from IP.
  193. status = IPGetDeviceRelation(TCB->tcb_rce, &pnpDeviceContext);
  194. if (status == TDI_SUCCESS) {
  195. deviceRelations = CTEAllocMem(sizeof(DEVICE_RELATIONS));
  196. if (deviceRelations) {
  197. //
  198. // TargetDeviceRelation allows exactly one PDO. fill it up.
  199. //
  200. deviceRelations->Count = 1;
  201. deviceRelations->Objects[0] = pnpDeviceContext;
  202. ObReferenceObject(pnpDeviceContext);
  203. } else {
  204. status = TDI_NO_RESOURCES;
  205. }
  206. }
  207. } else {
  208. status = TDI_INVALID_STATE;
  209. }
  210. CTEFreeLock(&(Conn->tc_ConnBlock->cb_lock), ConnHandle);
  211. } else {
  212. status = TDI_INVALID_CONNECTION;
  213. }
  214. //
  215. // invoker of this irp will free the information buffer.
  216. //
  217. Irp->IoStatus.Status = status;
  218. Irp->IoStatus.Information = (ULONG_PTR) deviceRelations;
  219. return status;
  220. }
  221. NTSTATUS
  222. TCPQueryAddrDeviceRelations(
  223. IN PIRP Irp,
  224. IN PIO_STACK_LOCATION IrpSp
  225. )
  226. /*++
  227. Routine Description:
  228. Processes pnp power irps.
  229. Arguments:
  230. Irp - Pointer to I/O request packet
  231. IrpSp - Pointer to the current stack location in the Irp.
  232. Return Value:
  233. NTSTATUS -- Indicates whether the request was successful.
  234. Notes:
  235. --*/
  236. {
  237. return STATUS_UNSUCCESSFUL;
  238. }