Author: cgutman
Date: Mon Aug 20 05:48:52 2012
New Revision: 57115
URL:
http://svn.reactos.org/svn/reactos?rev=57115&view=rev
Log:
[MSAFD]
- Add support for getting and setting SO_EXCLUSIVEADDRUSE
- Add support for setting SO_REUSEADDR
[AFD]
- Implement proper TDI way of indicating a reusable address file
- More work remains in TCP/IP to support this
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
trunk/reactos/drivers/network/afd/afd/bind.c
trunk/reactos/drivers/network/afd/afd/connect.c
trunk/reactos/drivers/network/afd/afd/tdi.c
trunk/reactos/drivers/network/afd/afd/write.c
trunk/reactos/drivers/network/afd/include/afd.h
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Mon Aug 20 05:48:52 2012
@@ -2140,6 +2140,12 @@
BufferSize = sizeof(BOOL);
break;
+ case SO_EXCLUSIVEADDRUSE:
+ BoolBuffer = (Socket->SharedData.ExclusiveAddressUse != 0);
+ Buffer = &BoolBuffer;
+ BufferSize = sizeof(BOOL);
+ break;
+
case SO_ERROR:
/* HACK: This needs to be properly tracked */
IntBuffer = 0;
@@ -2228,6 +2234,24 @@
return SOCKET_ERROR;
}
Socket->SharedData.LingerData.l_onoff = (*optval != 0) ? 0 : 1;
+ return 0;
+
+ case SO_REUSEADDR:
+ if (optlen < sizeof(BOOL))
+ {
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
+ Socket->SharedData.ReuseAddresses = (*optval != 0) ? 1 : 0;
+ return 0;
+
+ case SO_EXCLUSIVEADDRUSE:
+ if (optlen < sizeof(BOOL))
+ {
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
+ Socket->SharedData.ExclusiveAddressUse = (*optval != 0) ? 1 : 0;
return 0;
case SO_LINGER:
Modified: trunk/reactos/drivers/network/afd/afd/bind.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/bi…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/bind.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/bind.c [iso-8859-1] Mon Aug 20 05:48:52 2012
@@ -10,7 +10,7 @@
#include "afd.h"
-NTSTATUS WarmSocketForBind( PAFD_FCB FCB ) {
+NTSTATUS WarmSocketForBind( PAFD_FCB FCB, ULONG ShareType ) {
NTSTATUS Status;
AFD_DbgPrint(MID_TRACE,("Called (AF %d)\n",
@@ -27,6 +27,7 @@
Status = TdiOpenAddressFile(&FCB->TdiDeviceName,
FCB->LocalAddress,
+ ShareType,
&FCB->AddressFile.Handle,
&FCB->AddressFile.Object );
if (!NT_SUCCESS(Status))
@@ -92,7 +93,7 @@
FCB->LocalAddress );
if( NT_SUCCESS(Status) )
- Status = WarmSocketForBind( FCB );
+ Status = WarmSocketForBind( FCB, BindReq->ShareType );
AFD_DbgPrint(MID_TRACE,("FCB->Flags %x\n", FCB->Flags));
if (NT_SUCCESS(Status))
Modified: trunk/reactos/drivers/network/afd/afd/connect.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/co…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/connect.c [iso-8859-1] Mon Aug 20 05:48:52 2012
@@ -445,7 +445,7 @@
TaBuildNullTransportAddress(
ConnectReq->RemoteAddress.Address[0].AddressType );
if( FCB->LocalAddress ) {
- Status = WarmSocketForBind( FCB );
+ Status = WarmSocketForBind( FCB, AFD_SHARE_WILDCARD );
if( NT_SUCCESS(Status) )
FCB->State = SOCKET_STATE_BOUND;
Modified: trunk/reactos/drivers/network/afd/afd/tdi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/td…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/tdi.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/tdi.c [iso-8859-1] Mon Aug 20 05:48:52 2012
@@ -89,6 +89,7 @@
PUNICODE_STRING DeviceName,
ULONG EaLength,
PFILE_FULL_EA_INFORMATION EaInfo,
+ ULONG ShareType,
PHANDLE Handle,
PFILE_OBJECT *Object)
/*
@@ -106,8 +107,21 @@
OBJECT_ATTRIBUTES Attr;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
-
- AFD_DbgPrint(MAX_TRACE, ("Called. DeviceName (%wZ)\n", DeviceName));
+ ULONG ShareAccess;
+
+ AFD_DbgPrint(MAX_TRACE, ("Called. DeviceName (%wZ, %d)\n", DeviceName,
ShareType));
+
+ /* Determine the share access */
+ if (ShareType != AFD_SHARE_REUSE)
+ {
+ /* Exclusive access */
+ ShareAccess = 0;
+ }
+ else
+ {
+ /* Shared access */
+ ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ }
InitializeObjectAttributes(&Attr, /* Attribute buffer */
DeviceName, /* Device name */
@@ -122,7 +136,7 @@
&Iosb, /* IO status */
0, /* Initial allocation
size */
FILE_ATTRIBUTE_NORMAL, /* File attributes */
- 0, /* Share access */
+ ShareAccess, /* Share access */
FILE_OPEN_IF, /* Create disposition */
0, /* Create options */
EaInfo, /* EA buffer */
@@ -156,6 +170,7 @@
NTSTATUS TdiOpenAddressFile(
PUNICODE_STRING DeviceName,
PTRANSPORT_ADDRESS Name,
+ ULONG ShareType,
PHANDLE AddressHandle,
PFILE_OBJECT *AddressObject)
/*
@@ -199,6 +214,7 @@
Status = TdiOpenDevice(DeviceName,
EaLength,
EaInfo,
+ ShareType,
AddressHandle,
AddressObject);
ExFreePool(EaInfo);
@@ -300,6 +316,7 @@
Status = TdiOpenDevice(DeviceName,
EaLength,
EaInfo,
+ AFD_SHARE_UNIQUE,
ConnectionHandle,
ConnectionObject);
ExFreePool(EaInfo);
Modified: trunk/reactos/drivers/network/afd/afd/write.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/afd/afd/wr…
==============================================================================
--- trunk/reactos/drivers/network/afd/afd/write.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/afd/afd/write.c [iso-8859-1] Mon Aug 20 05:48:52 2012
@@ -527,7 +527,7 @@
Address[0].AddressType );
if( FCB->LocalAddress ) {
- Status = WarmSocketForBind( FCB );
+ Status = WarmSocketForBind( FCB, AFD_SHARE_WILDCARD );
if( NT_SUCCESS(Status) )
FCB->State = SOCKET_STATE_BOUND;
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] Mon Aug 20 05:48:52 2012
@@ -223,7 +223,7 @@
/* bind.c */
-NTSTATUS WarmSocketForBind( PAFD_FCB FCB );
+NTSTATUS WarmSocketForBind( PAFD_FCB FCB, ULONG ShareType );
NTSTATUS NTAPI
AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
PIO_STACK_LOCATION IrpSp);
@@ -367,6 +367,7 @@
NTSTATUS TdiOpenAddressFile(
PUNICODE_STRING DeviceName,
PTRANSPORT_ADDRESS Name,
+ ULONG ShareType,
PHANDLE AddressHandle,
PFILE_OBJECT *AddressObject);