mirror of
https://github.com/reactos/reactos.git
synced 2025-04-26 00:20:34 +00:00
- Merge aicom-network-fixes up to r39995
svn path=/trunk/; revision=40004
This commit is contained in:
parent
8ae1a88a0b
commit
3f46303c0e
5 changed files with 105 additions and 130 deletions
|
@ -70,23 +70,20 @@ AfdGetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp, BOOLEAN Local ) {
|
PIO_STACK_LOCATION IrpSp ) {
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PAFD_FCB FCB = FileObject->FsContext;
|
PAFD_FCB FCB = FileObject->FsContext;
|
||||||
PMDL Mdl = NULL, SysMdl = NULL;
|
PMDL Mdl = NULL;
|
||||||
PTDI_CONNECTION_INFORMATION ConnInfo = NULL;
|
|
||||||
PTRANSPORT_ADDRESS TransAddr = NULL;
|
|
||||||
HANDLE ProcHandle = NULL;
|
|
||||||
BOOLEAN UnlockSysMdl = FALSE;
|
|
||||||
PVOID UserSpace = NULL;
|
|
||||||
ULONG Length, InOutLength;
|
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
|
|
||||||
|
|
||||||
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
|
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
|
||||||
|
|
||||||
|
if( FCB->AddressFile.Object == NULL && FCB->Connection.Object == NULL ) {
|
||||||
|
return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0,
|
||||||
|
NULL );
|
||||||
|
}
|
||||||
|
|
||||||
Mdl = IoAllocateMdl
|
Mdl = IoAllocateMdl
|
||||||
( Irp->UserBuffer,
|
( Irp->UserBuffer,
|
||||||
IrpSp->Parameters.DeviceIoControl.OutputBufferLength,
|
IrpSp->Parameters.DeviceIoControl.OutputBufferLength,
|
||||||
|
@ -103,124 +100,69 @@ AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
} _SEH2_END;
|
} _SEH2_END;
|
||||||
|
|
||||||
if( NT_SUCCESS(Status) ) {
|
if( NT_SUCCESS(Status) ) {
|
||||||
if( Local ) {
|
|
||||||
if( FCB->AddressFile.Object == NULL ) {
|
|
||||||
return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0,
|
|
||||||
NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = TdiQueryInformation
|
Status = TdiQueryInformation
|
||||||
( FCB->Connection.Object ?
|
( FCB->Connection.Object ? FCB->Connection.Object : FCB->AddressFile.Object,
|
||||||
FCB->Connection.Object : FCB->AddressFile.Object,
|
|
||||||
TDI_QUERY_ADDRESS_INFO,
|
TDI_QUERY_ADDRESS_INFO,
|
||||||
Mdl );
|
Mdl );
|
||||||
} else {
|
}
|
||||||
// what follows is fucked up shit.
|
} else
|
||||||
// i'm not sure how to avoid it
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
// sorry
|
|
||||||
// -- arty
|
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
|
||||||
|
}
|
||||||
if( FCB->Connection.Object == NULL || (FCB->State != SOCKET_STATE_BOUND && FCB->State != SOCKET_STATE_CONNECTED) ) {
|
|
||||||
return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0,
|
NTSTATUS NTAPI
|
||||||
NULL );
|
AfdGetPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
}
|
PIO_STACK_LOCATION IrpSp ) {
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
if( NT_SUCCESS
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
( Status = TdiBuildNullConnectionInfo
|
PAFD_FCB FCB = FileObject->FsContext;
|
||||||
( &ConnInfo,
|
PMDL Mdl = NULL;
|
||||||
FCB->RemoteAddress->Address[0].AddressType ) ) ) {
|
PTDI_CONNECTION_INFORMATION ConnInfo = NULL;
|
||||||
|
|
||||||
Length = TaLengthOfTransportAddress
|
|
||||||
(ConnInfo->RemoteAddress);
|
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (FCB->RemoteAddress == NULL || FCB->Connection.Object == NULL) {
|
||||||
Status = ObOpenObjectByPointer
|
return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0, NULL );
|
||||||
(PsGetCurrentProcess(),
|
}
|
||||||
0,
|
|
||||||
NULL,
|
if(NT_SUCCESS(Status = TdiBuildNullConnectionInfo
|
||||||
PROCESS_ALL_ACCESS,
|
(&ConnInfo,
|
||||||
PsProcessType,
|
FCB->RemoteAddress->Address[0].AddressType)))
|
||||||
KernelMode,
|
{
|
||||||
&ProcHandle);
|
Mdl = IoAllocateMdl(ConnInfo,
|
||||||
|
sizeof(TDI_CONNECTION_INFORMATION) +
|
||||||
if (NT_SUCCESS(Status))
|
TaLengthOfTransportAddress(ConnInfo->RemoteAddress),
|
||||||
{
|
FALSE,
|
||||||
InOutLength =
|
FALSE,
|
||||||
PAGE_ROUND_UP(sizeof(TDI_CONNECTION_INFO));
|
NULL);
|
||||||
|
|
||||||
Status = NtAllocateVirtualMemory
|
if (Mdl)
|
||||||
(ProcHandle,
|
{
|
||||||
(PVOID*)&UserSpace,
|
_SEH2_TRY {
|
||||||
PAGE_SHIFT,
|
MmProbeAndLockPages(Mdl, Irp->RequestorMode, IoModifyAccess);
|
||||||
&InOutLength,
|
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||||
MEM_COMMIT,
|
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
|
||||||
PAGE_READWRITE);
|
Status = _SEH2_GetExceptionCode();
|
||||||
}
|
} _SEH2_END;
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ExFreePool(ConnInfo);
|
Status = TdiQueryInformation(FCB->Connection.Object,
|
||||||
ConnInfo = (PTDI_CONNECTION_INFORMATION)UserSpace;
|
TDI_QUERY_CONNECTION_INFO,
|
||||||
|
Mdl);
|
||||||
SysMdl = IoAllocateMdl
|
|
||||||
( UserSpace, Length, FALSE, FALSE, NULL );
|
if (NT_SUCCESS(Status))
|
||||||
}
|
{
|
||||||
else
|
RtlCopyMemory(Irp->UserBuffer, ConnInfo->RemoteAddress, TaLengthOfTransportAddress
|
||||||
{
|
(ConnInfo->RemoteAddress));
|
||||||
ExFreePool(ConnInfo);
|
}
|
||||||
ConnInfo = NULL;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
ExFreePool(ConnInfo);
|
||||||
if( SysMdl ) {
|
}
|
||||||
_SEH2_TRY {
|
|
||||||
MmProbeAndLockPages( SysMdl, Irp->RequestorMode, IoModifyAccess );
|
|
||||||
UnlockSysMdl = TRUE;
|
|
||||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
|
||||||
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
|
|
||||||
Status = _SEH2_GetExceptionCode();
|
|
||||||
} _SEH2_END;
|
|
||||||
} else Status = STATUS_NO_MEMORY;
|
|
||||||
|
|
||||||
if( NT_SUCCESS(Status) ) {
|
|
||||||
Status = TdiQueryInformation
|
|
||||||
( FCB->Connection.Object,
|
|
||||||
TDI_QUERY_CONNECTION_INFO,
|
|
||||||
SysMdl );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( NT_SUCCESS(Status) ) {
|
|
||||||
TransAddr =
|
|
||||||
(PTRANSPORT_ADDRESS)MmGetSystemAddressForMdlSafe( Mdl, NormalPagePriority );
|
|
||||||
|
|
||||||
if( TransAddr )
|
|
||||||
RtlCopyMemory( TransAddr, ConnInfo->RemoteAddress,
|
|
||||||
TaLengthOfTransportAddress
|
|
||||||
( ConnInfo->RemoteAddress ) );
|
|
||||||
else Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UnlockSysMdl)
|
|
||||||
MmUnlockPages( SysMdl );
|
|
||||||
|
|
||||||
if( SysMdl ) IoFreeMdl( SysMdl );
|
|
||||||
if( ConnInfo )
|
|
||||||
NtFreeVirtualMemory
|
|
||||||
( ProcHandle,
|
|
||||||
(PVOID)ConnInfo,
|
|
||||||
&InOutLength,
|
|
||||||
MEM_RELEASE );
|
|
||||||
if( ProcHandle ) NtClose(ProcHandle);
|
|
||||||
if( TransAddr ) MmUnmapLockedPages( TransAddr, Mdl );
|
|
||||||
MmUnlockPages( Mdl );
|
|
||||||
IoFreeMdl( Mdl );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
|
|
||||||
|
|
||||||
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
|
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,10 +413,10 @@ AfdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
return AfdDisconnect( DeviceObject, Irp, IrpSp );
|
return AfdDisconnect( DeviceObject, Irp, IrpSp );
|
||||||
|
|
||||||
case IOCTL_AFD_GET_SOCK_NAME:
|
case IOCTL_AFD_GET_SOCK_NAME:
|
||||||
return AfdGetSockOrPeerName( DeviceObject, Irp, IrpSp, TRUE );
|
return AfdGetSockName( DeviceObject, Irp, IrpSp );
|
||||||
|
|
||||||
case IOCTL_AFD_GET_PEER_NAME:
|
case IOCTL_AFD_GET_PEER_NAME:
|
||||||
return AfdGetSockOrPeerName( DeviceObject, Irp, IrpSp, FALSE );
|
return AfdGetPeerName( DeviceObject, Irp, IrpSp );
|
||||||
|
|
||||||
case IOCTL_AFD_GET_TDI_HANDLES:
|
case IOCTL_AFD_GET_TDI_HANDLES:
|
||||||
AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_TDI_HANDLES\n"));
|
AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_TDI_HANDLES\n"));
|
||||||
|
|
|
@ -237,8 +237,12 @@ AfdGetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp );
|
PIO_STACK_LOCATION IrpSp );
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
PIO_STACK_LOCATION IrpSp, BOOLEAN Local );
|
PIO_STACK_LOCATION IrpSp );
|
||||||
|
|
||||||
|
NTSTATUS NTAPI
|
||||||
|
AfdGetPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
|
PIO_STACK_LOCATION IrpSp );
|
||||||
|
|
||||||
/* listen.c */
|
/* listen.c */
|
||||||
NTSTATUS AfdWaitForListen( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
NTSTATUS AfdWaitForListen( PDEVICE_OBJECT DeviceObject, PIRP Irp,
|
||||||
|
|
|
@ -830,6 +830,9 @@ MiniportInitialize(
|
||||||
PADAPTER Adapter = 0;
|
PADAPTER Adapter = 0;
|
||||||
NDIS_STATUS Status = NDIS_STATUS_FAILURE;
|
NDIS_STATUS Status = NDIS_STATUS_FAILURE;
|
||||||
BOOLEAN InterruptRegistered = FALSE;
|
BOOLEAN InterruptRegistered = FALSE;
|
||||||
|
NDIS_HANDLE ConfigurationHandle;
|
||||||
|
UINT *RegNetworkAddress = 0;
|
||||||
|
UINT RegNetworkAddressLength = 0;
|
||||||
|
|
||||||
ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
|
ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
|
||||||
|
|
||||||
|
@ -924,6 +927,25 @@ MiniportInitialize(
|
||||||
/* set up the initialization block */
|
/* set up the initialization block */
|
||||||
MiPrepareInitializationBlock(Adapter);
|
MiPrepareInitializationBlock(Adapter);
|
||||||
|
|
||||||
|
/* see if someone set a network address manually */
|
||||||
|
NdisOpenConfiguration(&Status, &ConfigurationHandle, WrapperConfigurationContext);
|
||||||
|
if (Status == NDIS_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
NdisReadNetworkAddress(&Status, (PVOID *)&RegNetworkAddress, &RegNetworkAddressLength, ConfigurationHandle);
|
||||||
|
if(Status == NDIS_STATUS_SUCCESS && RegNetworkAddressLength == 6)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
DPRINT("NdisReadNetworkAddress returned successfully, address %x:%x:%x:%x:%x:%x\n",
|
||||||
|
RegNetworkAddress[0], RegNetworkAddress[1], RegNetworkAddress[2], RegNetworkAddress[3],
|
||||||
|
RegNetworkAddress[4], RegNetworkAddress[5]);
|
||||||
|
|
||||||
|
for(i = 0; i < 6; i++)
|
||||||
|
Adapter->InitializationBlockVirt->PADR[i] = RegNetworkAddress[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
NdisCloseConfiguration(ConfigurationHandle);
|
||||||
|
}
|
||||||
|
|
||||||
DPRINT("Interrupt registered successfully\n");
|
DPRINT("Interrupt registered successfully\n");
|
||||||
|
|
||||||
/* Initialize and start the chip */
|
/* Initialize and start the chip */
|
||||||
|
|
|
@ -713,6 +713,13 @@ NdisReadNetworkAddress(
|
||||||
|
|
||||||
*NetworkAddressLength = (UINT)((j/2)+0.5);
|
*NetworkAddressLength = (UINT)((j/2)+0.5);
|
||||||
|
|
||||||
|
if (j == 0)
|
||||||
|
{
|
||||||
|
NDIS_DbgPrint(MIN_TRACE,("Empty NetworkAddress registry entry.\n"));
|
||||||
|
*Status = NDIS_STATUS_FAILURE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IntArray = ExAllocatePool(PagedPool, (*NetworkAddressLength)*sizeof(UINT));
|
IntArray = ExAllocatePool(PagedPool, (*NetworkAddressLength)*sizeof(UINT));
|
||||||
if(!IntArray)
|
if(!IntArray)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue