Author: cgutman
Date: Fri Mar 13 20:25:48 2009
New Revision: 40004
URL:
http://svn.reactos.org/svn/reactos?rev=40004&view=rev
Log:
- Merge aicom-network-fixes up to r39995
Modified:
trunk/reactos/drivers/network/afd/afd/info.c
trunk/reactos/drivers/network/afd/afd/main.c
trunk/reactos/drivers/network/afd/include/afd.h
trunk/reactos/drivers/network/dd/pcnet/pcnet.c
trunk/reactos/drivers/network/ndis/ndis/config.c
Modified: trunk/reactos/drivers/network/afd/afd/info.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/in…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/info.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/info.c [iso-8859-1] Fri Mar 13 20:25:48 2009
@@ -70,22 +70,19 @@
}
NTSTATUS NTAPI
-AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
- PIO_STACK_LOCATION IrpSp, BOOLEAN Local ) {
+AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp ) {
NTSTATUS Status = STATUS_SUCCESS;
PFILE_OBJECT FileObject = IrpSp->FileObject;
PAFD_FCB FCB = FileObject->FsContext;
- PMDL Mdl = NULL, SysMdl = 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));
+ PMDL Mdl = NULL;
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
( Irp->UserBuffer,
@@ -103,124 +100,69 @@
} _SEH2_END;
if( NT_SUCCESS(Status) ) {
- if( Local ) {
- if( FCB->AddressFile.Object == NULL ) {
- return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0,
- NULL );
- }
-
Status = TdiQueryInformation
- ( FCB->Connection.Object ?
- FCB->Connection.Object : FCB->AddressFile.Object,
+ ( FCB->Connection.Object ? FCB->Connection.Object :
FCB->AddressFile.Object,
TDI_QUERY_ADDRESS_INFO,
Mdl );
- } else {
- // what follows is fucked up shit.
- // i'm not sure how to avoid it
- // sorry
- // -- arty
-
- if( FCB->Connection.Object == NULL || (FCB->State !=
SOCKET_STATE_BOUND && FCB->State != SOCKET_STATE_CONNECTED) ) {
- return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0,
- NULL );
- }
-
- if( NT_SUCCESS
- ( Status = TdiBuildNullConnectionInfo
- ( &ConnInfo,
- FCB->RemoteAddress->Address[0].AddressType ) ) ) {
-
- Length = TaLengthOfTransportAddress
- (ConnInfo->RemoteAddress);
-
- if (NT_SUCCESS(Status))
- Status = ObOpenObjectByPointer
- (PsGetCurrentProcess(),
- 0,
- NULL,
- PROCESS_ALL_ACCESS,
- PsProcessType,
- KernelMode,
- &ProcHandle);
-
- if (NT_SUCCESS(Status))
- {
- InOutLength =
- PAGE_ROUND_UP(sizeof(TDI_CONNECTION_INFO));
-
- Status = NtAllocateVirtualMemory
- (ProcHandle,
- (PVOID*)&UserSpace,
- PAGE_SHIFT,
- &InOutLength,
- MEM_COMMIT,
- PAGE_READWRITE);
- }
-
- if (NT_SUCCESS(Status))
- {
- ExFreePool(ConnInfo);
- ConnInfo = (PTDI_CONNECTION_INFORMATION)UserSpace;
-
- SysMdl = IoAllocateMdl
- ( UserSpace, Length, FALSE, FALSE, NULL );
- }
- else
- {
- ExFreePool(ConnInfo);
- ConnInfo = NULL;
- }
- }
-
- 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));
+ }
+ } else
+ Status = STATUS_INSUFFICIENT_RESOURCES;
return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
}
+
+NTSTATUS NTAPI
+AfdGetPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp ) {
+ NTSTATUS Status = STATUS_SUCCESS;
+ PFILE_OBJECT FileObject = IrpSp->FileObject;
+ PAFD_FCB FCB = FileObject->FsContext;
+ PMDL Mdl = NULL;
+ PTDI_CONNECTION_INFORMATION ConnInfo = NULL;
+
+
+ if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
+
+ if (FCB->RemoteAddress == NULL || FCB->Connection.Object == NULL) {
+ return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0, NULL );
+ }
+
+ if(NT_SUCCESS(Status = TdiBuildNullConnectionInfo
+ (&ConnInfo,
+ FCB->RemoteAddress->Address[0].AddressType)))
+ {
+ Mdl = IoAllocateMdl(ConnInfo,
+ sizeof(TDI_CONNECTION_INFORMATION) +
+
TaLengthOfTransportAddress(ConnInfo->RemoteAddress),
+ FALSE,
+ FALSE,
+ NULL);
+
+ if (Mdl)
+ {
+ _SEH2_TRY {
+ MmProbeAndLockPages(Mdl, Irp->RequestorMode, IoModifyAccess);
+ } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
+ AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
+ Status = _SEH2_GetExceptionCode();
+ } _SEH2_END;
+
+ if (NT_SUCCESS(Status))
+ {
+ Status = TdiQueryInformation(FCB->Connection.Object,
+ TDI_QUERY_CONNECTION_INFO,
+ Mdl);
+
+ if (NT_SUCCESS(Status))
+ {
+ RtlCopyMemory(Irp->UserBuffer, ConnInfo->RemoteAddress,
TaLengthOfTransportAddress
+
(ConnInfo->RemoteAddress));
+ }
+ }
+ }
+
+ ExFreePool(ConnInfo);
+ }
+
+ return UnlockAndMaybeComplete( FCB, Status, Irp, 0, NULL );
+}
Modified: trunk/reactos/drivers/network/afd/afd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/ma…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/main.c [iso-8859-1] Fri Mar 13 20:25:48 2009
@@ -413,10 +413,10 @@
return AfdDisconnect( DeviceObject, Irp, IrpSp );
case IOCTL_AFD_GET_SOCK_NAME:
- return AfdGetSockOrPeerName( DeviceObject, Irp, IrpSp, TRUE );
+ return AfdGetSockName( DeviceObject, Irp, IrpSp );
case IOCTL_AFD_GET_PEER_NAME:
- return AfdGetSockOrPeerName( DeviceObject, Irp, IrpSp, FALSE );
+ return AfdGetPeerName( DeviceObject, Irp, IrpSp );
case IOCTL_AFD_GET_TDI_HANDLES:
AFD_DbgPrint(MIN_TRACE, ("IOCTL_AFD_GET_TDI_HANDLES\n"));
Modified: trunk/reactos/drivers/network/afd/include/afd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/includ…
==============================================================================
--- trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/include/afd.h [iso-8859-1] Fri Mar 13 20:25:48 2009
@@ -237,8 +237,12 @@
PIO_STACK_LOCATION IrpSp );
NTSTATUS NTAPI
-AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
- PIO_STACK_LOCATION IrpSp, BOOLEAN Local );
+AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp );
+
+NTSTATUS NTAPI
+AfdGetPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
+ PIO_STACK_LOCATION IrpSp );
/* listen.c */
NTSTATUS AfdWaitForListen( PDEVICE_OBJECT DeviceObject, PIRP Irp,
Modified: trunk/reactos/drivers/network/dd/pcnet/pcnet.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/dd/pcnet/p…
==============================================================================
--- trunk/reactos/drivers/network/dd/pcnet/pcnet.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/dd/pcnet/pcnet.c [iso-8859-1] Fri Mar 13 20:25:48 2009
@@ -830,6 +830,9 @@
PADAPTER Adapter = 0;
NDIS_STATUS Status = NDIS_STATUS_FAILURE;
BOOLEAN InterruptRegistered = FALSE;
+ NDIS_HANDLE ConfigurationHandle;
+ UINT *RegNetworkAddress = 0;
+ UINT RegNetworkAddressLength = 0;
ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
@@ -923,6 +926,25 @@
/* set up the initialization block */
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");
Modified: trunk/reactos/drivers/network/ndis/ndis/config.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] Fri Mar 13 20:25:48
2009
@@ -713,6 +713,13 @@
*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));
if(!IntArray)
{