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));
28 if( !SocketAcquireStateLock( FCB
) ) {
29 Status
= LostSocket( Irp
, TRUE
);
30 _SEH_YIELD(return Status
);
33 switch( InfoReq
->InformationClass
) {
34 case AFD_INFO_RECEIVE_WINDOW_SIZE
:
35 InfoReq
->Information
.Ulong
= FCB
->Recv
.Size
;
38 case AFD_INFO_SEND_WINDOW_SIZE
:
39 InfoReq
->Information
.Ulong
= FCB
->Send
.Size
;
40 AFD_DbgPrint(MID_TRACE
,("Send window size %d\n", FCB
->Send
.Size
));
43 case AFD_INFO_GROUP_ID_TYPE
:
44 InfoReq
->Information
.Ulong
= 0; /* What is group id */
47 case AFD_INFO_BLOCKING_MODE
:
48 InfoReq
->Information
.Ulong
= 0;
52 AFD_DbgPrint(MID_TRACE
,("Unknown info id %x\n",
53 InfoReq
->InformationClass
));
54 Status
= STATUS_INVALID_PARAMETER
;
58 AFD_DbgPrint(MID_TRACE
,("Exception executing GetInfo\n"));
59 Status
= STATUS_INVALID_PARAMETER
;
62 AFD_DbgPrint(MID_TRACE
,("Returning %x\n", Status
));
64 return UnlockAndMaybeComplete( FCB
, Status
, Irp
, 0, NULL
, FALSE
);
68 AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject
, PIRP Irp
,
69 PIO_STACK_LOCATION IrpSp
, BOOLEAN Local
) {
70 NTSTATUS Status
= STATUS_SUCCESS
;
71 PFILE_OBJECT FileObject
= IrpSp
->FileObject
;
72 PAFD_FCB FCB
= FileObject
->FsContext
;
73 PMDL Mdl
= NULL
, SysMdl
= NULL
;
74 PTDI_CONNECTION_INFORMATION ConnInfo
= NULL
;
75 PTRANSPORT_ADDRESS TransAddr
= NULL
;
77 AFD_DbgPrint(MID_TRACE
,("Called on %x\n", FCB
));
79 if( !SocketAcquireStateLock( FCB
) ) return LostSocket( Irp
, FALSE
);
81 if( FCB
->AddressFile
.Object
== NULL
) {
82 return UnlockAndMaybeComplete( FCB
, STATUS_UNSUCCESSFUL
, Irp
, 0,
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 Status
= TdiQueryInformation
104 ( FCB
->AddressFile
.Object
,
105 TDI_QUERY_ADDRESS_INFO
,
109 ( Status
= TdiBuildNullConnectionInfo
111 FCB
->LocalAddress
->Address
[0].AddressType
) ) ) {
112 SysMdl
= IoAllocateMdl
114 sizeof( TDI_CONNECTION_INFORMATION
) +
115 TaLengthOfTransportAddress
116 ( ConnInfo
->RemoteAddress
),
123 MmBuildMdlForNonPagedPool( SysMdl
);
124 Status
= TdiQueryInformation
125 ( FCB
->AddressFile
.Object
,
126 TDI_QUERY_CONNECTION_INFO
,
128 } else Status
= STATUS_NO_MEMORY
;
130 if( NT_SUCCESS(Status
) ) {
132 (PTRANSPORT_ADDRESS
)MmMapLockedPages
133 ( Mdl
, IoModifyAccess
);
137 RtlCopyMemory( TransAddr
, ConnInfo
->RemoteAddress
,
138 TaLengthOfTransportAddress
139 ( ConnInfo
->RemoteAddress
) );
141 if( ConnInfo
) ExFreePool( ConnInfo
);
142 if( SysMdl
) IoFreeMdl( SysMdl
);
146 /* MmUnlockPages( Mdl ); */
147 /* IoFreeMdl( Mdl ); */
149 Status
= STATUS_INSUFFICIENT_RESOURCES
;
152 AFD_DbgPrint(MID_TRACE
,("Returning %x\n", Status
));
154 return UnlockAndMaybeComplete( FCB
, Status
, Irp
, 0, NULL
, FALSE
);