* UPDATE HISTORY:
* 20040708 Created
*/
+
#include "afd.h"
+static IO_COMPLETION_ROUTINE SendComplete;
static NTSTATUS NTAPI SendComplete
( PDEVICE_OBJECT DeviceObject,
PIRP Irp,
UINT SendLength, BytesCopied;
BOOLEAN HaltSendQueue;
+ UNREFERENCED_PARAMETER(DeviceObject);
+
/*
* The Irp parameter passed in is the IRP of the stream between AFD and
- * TDI driver. It's not very usefull to us. We need the IRPs of the stream
+ * TDI driver. It's not very useful to us. We need the IRPs of the stream
* between usermode and AFD. Those are chained from
* FCB->PendingIrpList[FUNCTION_SEND] and you'll see them in the code
* below as "NextIrp" ('cause they are the next usermode IRP to be
* processed).
*/
- AFD_DbgPrint(MID_TRACE,("Called, status %x, %d bytes used\n",
+ AFD_DbgPrint(MID_TRACE,("Called, status %x, %u bytes used\n",
Irp->IoStatus.Status,
Irp->IoStatus.Information));
SendReq = GetLockedData(NextIrp, NextIrpSp);
Map = (PAFD_MAPBUF)(SendReq->BufferArray + SendReq->BufferCount);
- AFD_DbgPrint(MID_TRACE,("SendReq @ %x\n", SendReq));
+ AFD_DbgPrint(MID_TRACE,("SendReq @ %p\n", SendReq));
SpaceAvail = FCB->Send.Size - FCB->Send.BytesUsed;
TotalBytesCopied = 0;
0,
FCB->Send.Window,
FCB->Send.BytesUsed,
- &FCB->SendIrp.Iosb,
SendComplete,
FCB );
}
return STATUS_SUCCESS;
}
+static IO_COMPLETION_ROUTINE PacketSocketSendComplete;
static NTSTATUS NTAPI PacketSocketSendComplete
( PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PIRP NextIrp;
PAFD_SEND_INFO SendReq;
- AFD_DbgPrint(MID_TRACE,("Called, status %x, %d bytes used\n",
+ UNREFERENCED_PARAMETER(DeviceObject);
+
+ AFD_DbgPrint(MID_TRACE,("Called, status %x, %u bytes used\n",
Irp->IoStatus.Status,
Irp->IoStatus.Information));
UINT TotalBytesCopied = 0, i, SpaceAvail = 0, BytesCopied, SendLength;
KPROCESSOR_MODE LockMode;
- AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
+ UNREFERENCED_PARAMETER(DeviceObject);
+ UNREFERENCED_PARAMETER(Short);
+
+ AFD_DbgPrint(MID_TRACE,("Called on %p\n", FCB));
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
Status = QueueUserModeIrp(FCB, Irp, FUNCTION_SEND);
if (Status == STATUS_PENDING)
{
- TdiSendDatagram(&FCB->SendIrp.InFlightRequest,
- FCB->AddressFile.Object,
- SendReq->BufferArray[0].buf,
- SendReq->BufferArray[0].len,
- TargetAddress,
- &FCB->SendIrp.Iosb,
- PacketSocketSendComplete,
- FCB);
+ Status = TdiSendDatagram(&FCB->SendIrp.InFlightRequest,
+ FCB->AddressFile.Object,
+ SendReq->BufferArray[0].buf,
+ SendReq->BufferArray[0].len,
+ TargetAddress,
+ PacketSocketSendComplete,
+ FCB);
+ if (Status != STATUS_PENDING)
+ {
+ NT_VERIFY(RemoveHeadList(&FCB->PendingIrpList[FUNCTION_SEND]) == &Irp->Tail.Overlay.ListEntry);
+ Irp->IoStatus.Status = Status;
+ Irp->IoStatus.Information = 0;
+ (void)IoSetCancelRoutine(Irp, NULL);
+ UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount, FALSE);
+ UnlockRequest(Irp, IoGetCurrentIrpStackLocation(Irp));
+ IoCompleteRequest(Irp, IO_NETWORK_INCREMENT);
+ }
}
- ExFreePool( TargetAddress );
+ ExFreePoolWithTag(TargetAddress, TAG_AFD_TDI_CONNECTION_INFORMATION);
SocketStateUnlock(FCB);
Irp, 0 );
}
- AFD_DbgPrint(MID_TRACE,("Socket state %d\n", FCB->State));
+ AFD_DbgPrint(MID_TRACE,("Socket state %u\n", FCB->State));
if( FCB->State != SOCKET_STATE_CONNECTED ) {
- if (!(SendReq->AfdFlags & AFD_OVERLAPPED) &&
- ((SendReq->AfdFlags & AFD_IMMEDIATE) || (FCB->NonBlocking))) {
- AFD_DbgPrint(MID_TRACE,("Nonblocking\n"));
- UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
- return UnlockAndMaybeComplete( FCB, STATUS_CANT_WAIT, Irp, 0 );
- } else {
- AFD_DbgPrint(MID_TRACE,("Queuing request\n"));
- return LeaveIrpUntilLater( FCB, Irp, FUNCTION_SEND );
- }
+ AFD_DbgPrint(MID_TRACE,("Socket not connected\n"));
+ UnlockBuffers( SendReq->BufferArray, SendReq->BufferCount, FALSE );
+ return UnlockAndMaybeComplete( FCB, STATUS_INVALID_CONNECTION, Irp, 0 );
}
- AFD_DbgPrint(MID_TRACE,("FCB->Send.BytesUsed = %d\n",
+ AFD_DbgPrint(MID_TRACE,("FCB->Send.BytesUsed = %u\n",
FCB->Send.BytesUsed));
SpaceAvail = FCB->Send.Size - FCB->Send.BytesUsed;
- AFD_DbgPrint(MID_TRACE,("We can accept %d bytes\n",
+ AFD_DbgPrint(MID_TRACE,("We can accept %u bytes\n",
SpaceAvail));
/* Count the total transfer size */
{
BytesCopied = MIN(SendReq->BufferArray[i].len, SpaceAvail);
- AFD_DbgPrint(MID_TRACE,("Copying Buffer %d, %x:%d to %x\n",
+ AFD_DbgPrint(MID_TRACE,("Copying Buffer %u, %p:%u to %p\n",
i,
SendReq->BufferArray[i].buf,
BytesCopied,
0,
FCB->Send.Window,
FCB->Send.BytesUsed,
- &FCB->SendIrp.Iosb,
SendComplete,
FCB);
}
PAFD_SEND_INFO_UDP SendReq;
KPROCESSOR_MODE LockMode;
- AFD_DbgPrint(MID_TRACE,("Called on %x\n", FCB));
+ UNREFERENCED_PARAMETER(DeviceObject);
+
+ AFD_DbgPrint(MID_TRACE,("Called on %p\n", FCB));
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
if (FCB->State == SOCKET_STATE_CREATED)
{
- if( FCB->LocalAddress ) ExFreePool( FCB->LocalAddress );
+ if (FCB->LocalAddress)
+ {
+ ExFreePoolWithTag(FCB->LocalAddress, TAG_AFD_TRANSPORT_ADDRESS);
+ }
+
FCB->LocalAddress =
TaBuildNullTransportAddress( ((PTRANSPORT_ADDRESS)SendReq->TdiConnection.RemoteAddress)->
Address[0].AddressType );
Irp, 0 );
AFD_DbgPrint
- (MID_TRACE,("RemoteAddress #%d Type %d\n",
+ (MID_TRACE,("RemoteAddress #%d Type %u\n",
((PTRANSPORT_ADDRESS)SendReq->TdiConnection.RemoteAddress)->
TAAddressCount,
((PTRANSPORT_ADDRESS)SendReq->TdiConnection.RemoteAddress)->
Status = QueueUserModeIrp(FCB, Irp, FUNCTION_SEND);
if (Status == STATUS_PENDING)
{
- TdiSendDatagram(&FCB->SendIrp.InFlightRequest,
- FCB->AddressFile.Object,
- SendReq->BufferArray[0].buf,
- SendReq->BufferArray[0].len,
- TargetAddress,
- &FCB->SendIrp.Iosb,
- PacketSocketSendComplete,
- FCB);
+ Status = TdiSendDatagram(&FCB->SendIrp.InFlightRequest,
+ FCB->AddressFile.Object,
+ SendReq->BufferArray[0].buf,
+ SendReq->BufferArray[0].len,
+ TargetAddress,
+ PacketSocketSendComplete,
+ FCB);
+ if (Status != STATUS_PENDING)
+ {
+ NT_VERIFY(RemoveHeadList(&FCB->PendingIrpList[FUNCTION_SEND]) == &Irp->Tail.Overlay.ListEntry);
+ Irp->IoStatus.Status = Status;
+ Irp->IoStatus.Information = 0;
+ (void)IoSetCancelRoutine(Irp, NULL);
+ UnlockBuffers(SendReq->BufferArray, SendReq->BufferCount, FALSE);
+ UnlockRequest(Irp, IoGetCurrentIrpStackLocation(Irp));
+ IoCompleteRequest(Irp, IO_NETWORK_INCREMENT);
+ }
}
- ExFreePool(TargetAddress);
+ ExFreePoolWithTag(TargetAddress, TAG_AFD_TDI_CONNECTION_INFORMATION);
SocketStateUnlock(FCB);
return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
}
}
-