2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/net/afd/afd/info.c
5 * PURPOSE: Ancillary functions driver
6 * PROGRAMMER: Art Yerkes (ayerkes@speakeasy.net)
11 #include "tdi_proto.h"
14 #include "pseh/pseh.h"
17 AfdGetInfo( PDEVICE_OBJECT DeviceObject
, PIRP Irp
,
18 PIO_STACK_LOCATION IrpSp
) {
19 NTSTATUS Status
= STATUS_SUCCESS
;
20 PAFD_INFO InfoReq
= IrpSp
->Parameters
.DeviceIoControl
.Type3InputBuffer
;
21 PFILE_OBJECT FileObject
= IrpSp
->FileObject
;
22 PAFD_FCB FCB
= FileObject
->FsContext
;
24 AFD_DbgPrint(MID_TRACE
,("Called %x %x\n", InfoReq
,
25 InfoReq
? InfoReq
->InformationClass
: 0));
27 if( !SocketAcquireStateLock( FCB
) ) return LostSocket( Irp
);
30 switch( InfoReq
->InformationClass
) {
31 case AFD_INFO_RECEIVE_WINDOW_SIZE
:
32 InfoReq
->Information
.Ulong
= FCB
->Recv
.Size
;
35 case AFD_INFO_SEND_WINDOW_SIZE
:
36 InfoReq
->Information
.Ulong
= FCB
->Send
.Size
;
37 AFD_DbgPrint(MID_TRACE
,("Send window size %d\n", FCB
->Send
.Size
));
40 case AFD_INFO_GROUP_ID_TYPE
:
41 InfoReq
->Information
.Ulong
= 0; /* What is group id */
44 case AFD_INFO_BLOCKING_MODE
:
45 InfoReq
->Information
.Ulong
= 0;
48 case AFD_INFO_RECEIVE_CONTENT_SIZE
:
49 /* Only touch InfoReq if a socket has been set up.
50 Behaviour was verified under WinXP SP2. */
51 if(FCB
->AddressFile
.Object
)
52 InfoReq
->Information
.Ulong
= FCB
->Recv
.Content
- FCB
->Recv
.BytesUsed
;
57 AFD_DbgPrint(MID_TRACE
,("Unknown info id %x\n",
58 InfoReq
->InformationClass
));
59 Status
= STATUS_INVALID_PARAMETER
;
63 AFD_DbgPrint(MID_TRACE
,("Exception executing GetInfo\n"));
64 Status
= STATUS_INVALID_PARAMETER
;
67 AFD_DbgPrint(MID_TRACE
,("Returning %x\n", Status
));
69 return UnlockAndMaybeComplete( FCB
, Status
, Irp
, 0, NULL
);
73 AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject
, PIRP Irp
,
74 PIO_STACK_LOCATION IrpSp
, BOOLEAN Local
) {
75 NTSTATUS Status
= STATUS_SUCCESS
;
76 PFILE_OBJECT FileObject
= IrpSp
->FileObject
;
77 PAFD_FCB FCB
= FileObject
->FsContext
;
78 PMDL Mdl
= NULL
, SysMdl
= NULL
;
79 PTDI_CONNECTION_INFORMATION ConnInfo
= NULL
;
80 PTRANSPORT_ADDRESS TransAddr
= NULL
;
82 AFD_DbgPrint(MID_TRACE
,("Called on %x\n", FCB
));
84 if( !SocketAcquireStateLock( FCB
) ) return LostSocket( Irp
);
88 IrpSp
->Parameters
.DeviceIoControl
.OutputBufferLength
,
95 MmProbeAndLockPages( Mdl
, Irp
->RequestorMode
, IoModifyAccess
);
97 AFD_DbgPrint(MIN_TRACE
, ("MmProbeAndLockPages() failed.\n"));
98 Status
= _SEH_GetExceptionCode();
101 if( NT_SUCCESS(Status
) ) {
103 if( FCB
->AddressFile
.Object
== NULL
) {
104 return UnlockAndMaybeComplete( FCB
, STATUS_INVALID_PARAMETER
, Irp
, 0,
108 Status
= TdiQueryInformation
109 ( FCB
->AddressFile
.Object
,
110 TDI_QUERY_ADDRESS_INFO
,
113 if( FCB
->Connection
.Object
== NULL
) {
114 return UnlockAndMaybeComplete( FCB
, STATUS_INVALID_PARAMETER
, Irp
, 0,
119 ( Status
= TdiBuildNullConnectionInfo
121 FCB
->LocalAddress
->Address
[0].AddressType
) ) ) {
122 SysMdl
= IoAllocateMdl
124 sizeof( TDI_CONNECTION_INFORMATION
) +
125 TaLengthOfTransportAddress
126 ( ConnInfo
->RemoteAddress
),
134 MmProbeAndLockPages( SysMdl
, Irp
->RequestorMode
, IoModifyAccess
);
136 AFD_DbgPrint(MIN_TRACE
, ("MmProbeAndLockPages() failed.\n"));
137 Status
= _SEH_GetExceptionCode();
139 } else Status
= STATUS_NO_MEMORY
;
141 if( NT_SUCCESS(Status
) ) {
142 Status
= TdiQueryInformation
143 ( FCB
->Connection
.Object
,
144 TDI_QUERY_CONNECTION_INFO
,
148 if( NT_SUCCESS(Status
) ) {
150 (PTRANSPORT_ADDRESS
)MmGetSystemAddressForMdlSafe( Mdl
, NormalPagePriority
);
153 RtlCopyMemory( TransAddr
, ConnInfo
->RemoteAddress
,
154 TaLengthOfTransportAddress
155 ( ConnInfo
->RemoteAddress
) );
156 else Status
= STATUS_INSUFFICIENT_RESOURCES
;
159 if( ConnInfo
) ExFreePool( ConnInfo
);
160 if( SysMdl
) IoFreeMdl( SysMdl
);
161 if( TransAddr
) MmUnmapLockedPages( TransAddr
, Mdl
);
162 MmUnlockPages( Mdl
);
167 Status
= STATUS_INSUFFICIENT_RESOURCES
;
170 AFD_DbgPrint(MID_TRACE
,("Returning %x\n", Status
));
172 return UnlockAndMaybeComplete( FCB
, Status
, Irp
, 0, NULL
);