reactos/drivers/net/afd/afd/afd.c (AfdDispatch): Correctly set

Irp->IoStatus.Information.
(AfdUnload): Make it STDCALL.
(DriverEntry): Don't cast function pointers.
reactos/drivers/net/afd/afd/dispatch.c (AfdDispGetName): New function, still
incomplete.
reactos/drivers/net/afd/include/afd.h (AfdDispGetName): Declare.
reactos/drivers/net/tcpip/tcpip/main.c (TiDispatchOpenClose):
Use STDCALL instead of STDCALL_FUNC.
(TiUnload): Make it STDCALL.
(DriverEntry): Don't cast function pointers.
reactos/drivers/net/tcpip/transport/tcp/tcp.c (TCPConnect):
Don't free the NDIS buffer, it's already done on another place and return
STATUS_PENDING to avoid completing the Irp two times.
reactos/lib/msafd/misc/stubs.c (WSPGetSockName, WSPGetPeerName):
Moved to ...
reactos/lib/msafd/misc/dllmain.c (WSPGetSockName, WSPGetPeerName):
... here, direct the calls to afd.sys.

svn path=/trunk/; revision=8132
This commit is contained in:
Filip Navara 2004-02-10 17:12:42 +00:00
parent f80022635e
commit 8ccf098ee6
8 changed files with 183 additions and 55 deletions

View file

@ -60,7 +60,7 @@ AfdDispatch(
AFD_DbgPrint(MAX_TRACE, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X), IrpSp->FileObject (0x%X).\n",
DeviceObject, Irp, IrpSp->FileObject));
Irp->IoStatus.Information = 0;
Irp->IoStatus.Information = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
case IOCTL_AFD_BIND:
@ -103,7 +103,12 @@ AfdDispatch(
Status = AfdDispConnect(Irp, IrpSp);
break;
case IOCTL_AFD_GETNAME:
Status = AfdDispGetName(Irp, IrpSp);
break;
default:
Irp->IoStatus.Information = 0;
AFD_DbgPrint(MIN_TRACE, ("Unknown IOCTL (0x%X).\n",
IrpSp->Parameters.DeviceIoControl.IoControlCode));
Status = STATUS_NOT_IMPLEMENTED;
@ -121,7 +126,7 @@ AfdDispatch(
}
VOID AfdUnload(
VOID STDCALL AfdUnload(
PDRIVER_OBJECT DriverObject)
/*
* FUNCTION: Unloads the driver
@ -169,15 +174,15 @@ DriverEntry(
KeInitializeSpinLock(&DeviceExt->FCBListLock);
InitializeListHead(&DeviceExt->FCBListHead);
DriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH)AfdCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH)AfdClose;
DriverObject->MajorFunction[IRP_MJ_READ] = (PDRIVER_DISPATCH)AfdRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = (PDRIVER_DISPATCH)AfdWrite;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = (PDRIVER_DISPATCH)AfdFileSystemControl;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = (PDRIVER_DISPATCH)AfdDispatch;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = (PDRIVER_DISPATCH)AfdClose;
DriverObject->MajorFunction[IRP_MJ_CREATE] = AfdCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = AfdClose;
DriverObject->MajorFunction[IRP_MJ_READ] = AfdRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = AfdWrite;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = AfdFileSystemControl;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = AfdDispatch;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = AfdClose;
DriverObject->DriverUnload = (PDRIVER_UNLOAD)AfdUnload;
DriverObject->DriverUnload = AfdUnload;
/* ExInitializeNPagedLookasideList(
&BufferLookasideList,

View file

@ -921,4 +921,61 @@ NTSTATUS AfdDispConnect(
return Status;
}
NTSTATUS AfdDispGetName(
PIRP Irp,
PIO_STACK_LOCATION IrpSp)
/*
* FUNCTION: Get socket name
* ARGUMENTS:
* Irp = Pointer to I/O request packet
* IrpSp = Pointer to current stack location of Irp
* RETURNS:
* Status of operation
*/
{
NTSTATUS Status;
UINT InputBufferLength;
UINT OutputBufferLength;
PFILE_REQUEST_GETNAME Request;
PFILE_REPLY_GETNAME Reply;
PAFDFCB FCB;
PFILE_OBJECT FileObject;
AFD_DbgPrint(MIN_TRACE, ("\n"));
InputBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
/* Validate parameters */
Status = STATUS_INVALID_PARAMETER;
if ((InputBufferLength >= sizeof(FILE_REQUEST_GETNAME)) &&
(OutputBufferLength >= sizeof(FILE_REPLY_GETNAME))) {
FCB = IrpSp->FileObject->FsContext;
Request = (PFILE_REQUEST_GETNAME)Irp->AssociatedIrp.SystemBuffer;
Reply = (PFILE_REPLY_GETNAME)Irp->AssociatedIrp.SystemBuffer;
AFD_DbgPrint(MIN_TRACE, ("\n"));
if (Request->Peer) {
if (FCB->State != SOCKET_STATE_CONNECTED) {
Reply->Status = WSAENOTCONN;
return STATUS_UNSUCCESSFUL;
}
FileObject = FCB->TdiConnectionObject;
} else {
FileObject = FCB->TdiAddressObject;
}
/* FIXME: Implement */
/* Make a TDI_QUERY_INFORMATION call to underlying TDI transport driver */
Status = STATUS_UNSUCCESSFUL;
}
AFD_DbgPrint(MAX_TRACE, ("Status (0x%X).\n", Status));
return Status;
}
/* EOF */

View file

@ -322,8 +322,7 @@ NTSTATUS TdiConnect(
DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
Status = TdiBuildConnectionInfo
(&RequestConnectionInfo, RemoteAddress);
Status = TdiBuildConnectionInfo(&RequestConnectionInfo, RemoteAddress);
if (!NT_SUCCESS(Status))
return Status;

View file

@ -258,6 +258,10 @@ NTSTATUS AfdDispConnect(
PIRP Irp,
PIO_STACK_LOCATION IrpSp);
NTSTATUS AfdDispGetName(
PIRP Irp,
PIO_STACK_LOCATION IrpSp);
/* Prototypes from event.c */
NTSTATUS AfdRegisterEventHandlers(

View file

@ -390,10 +390,7 @@ NTSTATUS TiCleanupFileObject(
}
NTSTATUS
#ifndef _MSC_VER
STDCALL_FUNC
#endif
NTSTATUS STDCALL
TiDispatchOpenClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
@ -625,7 +622,7 @@ TiDispatch(
}
VOID TiUnload(
VOID STDCALL TiUnload(
PDRIVER_OBJECT DriverObject)
/*
* FUNCTION: Unloads the driver
@ -835,13 +832,13 @@ DriverEntry(
TCPDeviceObject->Flags |= DO_DIRECT_IO;
/* Initialize the driver object with this driver's entry points */
DriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH)TiDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH)TiDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = (PDRIVER_DISPATCH)TiDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = (PDRIVER_DISPATCH)TiDispatchInternal;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = (PDRIVER_DISPATCH)TiDispatch;
DriverObject->MajorFunction[IRP_MJ_CREATE] = TiDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = TiDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = TiDispatchOpenClose;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = TiDispatchInternal;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = TiDispatch;
DriverObject->DriverUnload = (PDRIVER_UNLOAD)TiUnload;
DriverObject->DriverUnload = TiUnload;
return STATUS_SUCCESS;
}

View file

@ -408,12 +408,10 @@ NTSTATUS TCPConnect(
return Status;
}
/* Free the NDIS buffer */
NdisFreeBuffer(NdisBuffer);
ExFreePool(DataBuffer);
KeReleaseSpinLock(&Connection->Lock, OldIrql);
Status = STATUS_PENDING;
TI_DbgPrint(MAX_TRACE, ("Leaving. Status (0x%X)\n", Status));
return Status;

View file

@ -632,6 +632,102 @@ WSPConnect(
}
INT
WSPAPI
WSPGetSockName(
IN SOCKET s,
OUT LPSOCKADDR name,
IN OUT LPINT namelen,
OUT LPINT lpErrno)
{
FILE_REQUEST_GETNAME Request;
FILE_REPLY_GETNAME Reply;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
AFD_DbgPrint(MAX_TRACE, ("s (0x%X).\n", s));
Request.Peer = FALSE;
Status = NtDeviceIoControlFile(
(HANDLE)s,
NULL,
NULL,
NULL,
&Iosb,
IOCTL_AFD_GETNAME,
&Request,
sizeof(FILE_REQUEST_GETNAME),
&Reply,
sizeof(FILE_REPLY_GETNAME));
if (Status == STATUS_PENDING) {
AFD_DbgPrint(MAX_TRACE, ("Waiting on transport.\n"));
/* FIXME: Wait only for blocking sockets */
Status = NtWaitForSingleObject((HANDLE)s, FALSE, NULL);
}
if (!NT_SUCCESS(Status)) {
*lpErrno = Reply.Status;
return INVALID_SOCKET;
}
else
{
*namelen = min(*namelen, Reply.NameSize);
RtlCopyMemory(name, &Reply.Name, *namelen);
}
return 0;
}
INT
WSPAPI
WSPGetPeerName(
IN SOCKET s,
OUT LPSOCKADDR name,
IN OUT LPINT namelen,
OUT LPINT lpErrno)
{
FILE_REQUEST_GETNAME Request;
FILE_REPLY_GETNAME Reply;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
AFD_DbgPrint(MAX_TRACE, ("s (0x%X).\n", s));
Request.Peer = TRUE;
Status = NtDeviceIoControlFile(
(HANDLE)s,
NULL,
NULL,
NULL,
&Iosb,
IOCTL_AFD_GETNAME,
&Request,
sizeof(FILE_REQUEST_GETNAME),
&Reply,
sizeof(FILE_REPLY_GETNAME));
if (Status == STATUS_PENDING) {
AFD_DbgPrint(MAX_TRACE, ("Waiting on transport.\n"));
/* FIXME: Wait only for blocking sockets */
Status = NtWaitForSingleObject((HANDLE)s, FALSE, NULL);
}
if (!NT_SUCCESS(Status)) {
*lpErrno = Reply.Status;
return INVALID_SOCKET;
}
else
{
*namelen = min(*namelen, Reply.NameSize);
RtlCopyMemory(name, &Reply.Name, *namelen);
}
return 0;
}
NTSTATUS OpenCommandChannel(
VOID)
/*

View file

@ -67,20 +67,6 @@ WSPGetOverlappedResult(
}
INT
WSPAPI
WSPGetPeerName(
IN SOCKET s,
OUT LPSOCKADDR name,
IN OUT LPINT namelen,
OUT LPINT lpErrno)
{
UNIMPLEMENTED
return 0;
}
BOOL
WSPAPI
WSPGetQOSByName(
@ -95,20 +81,6 @@ WSPGetQOSByName(
}
INT
WSPAPI
WSPGetSockName(
IN SOCKET s,
OUT LPSOCKADDR name,
IN OUT LPINT namelen,
OUT LPINT lpErrno)
{
UNIMPLEMENTED
return 0;
}
INT
WSPAPI
WSPGetSockOpt(