mirror of
https://github.com/reactos/reactos.git
synced 2024-06-24 06:51:47 +00:00
2004-04-04 Filip Navara <xnavara@volny.cz>
* drivers/net/afd/afd/dispatch.c (AfdDispGetName): Implement. * drivers/net/afd/include/afd.h (TdiQueryInformation): Declare. * drivers/net/tcpip/tcpip/dispatch.c (DispTdiQueryInformation): Partially implement for TDI_QUERY_ADDRESS_INFO request. * drivers/net/tcpip/transport/tcp/tcp.c (TCPiBuildPacket): Don't use variable name NdisBuffer, because it causes conficts. svn path=/trunk/; revision=8543
This commit is contained in:
parent
7963bf3535
commit
1f2169eb29
|
@ -969,6 +969,9 @@ NTSTATUS AfdDispGetName(
|
|||
PFILE_REPLY_GETNAME Reply;
|
||||
PAFDFCB FCB;
|
||||
PFILE_OBJECT FileObject;
|
||||
PMDL Mdl;
|
||||
PTDI_ADDRESS_INFO AddressInfoBuffer;
|
||||
ULONG AddressInfoSize;
|
||||
|
||||
AFD_DbgPrint(MIN_TRACE, ("\n"));
|
||||
|
||||
|
@ -996,9 +999,42 @@ NTSTATUS AfdDispGetName(
|
|||
FileObject = FCB->TdiAddressObject;
|
||||
}
|
||||
|
||||
/* FIXME: Implement */
|
||||
/* Make a TDI_QUERY_INFORMATION call to underlying TDI transport driver */
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
AddressInfoSize = sizeof(TDI_ADDRESS_INFO) + sizeof(TDI_ADDRESS_IP);
|
||||
AddressInfoBuffer = ExAllocatePool(NonPagedPool, AddressInfoSize);
|
||||
|
||||
Mdl = IoAllocateMdl(
|
||||
AddressInfoBuffer, /* Virtual address of buffer */
|
||||
AddressInfoSize, /* Length of buffer */
|
||||
FALSE, /* Not secondary */
|
||||
FALSE, /* Don't charge quota */
|
||||
NULL); /* Don't use IRP */
|
||||
|
||||
if (!Mdl) {
|
||||
ExFreePool(AddressInfoBuffer);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
MmBuildMdlForNonPagedPool(Mdl);
|
||||
|
||||
Status = TdiQueryInformation(
|
||||
FileObject,
|
||||
TDI_QUERY_ADDRESS_INFO,
|
||||
Mdl);
|
||||
|
||||
if (NT_SUCCESS(Status)) {
|
||||
Reply->Name.sa_family = AddressInfoBuffer->Address.Address[0].AddressType;
|
||||
|
||||
RtlCopyMemory(
|
||||
Reply->Name.sa_data,
|
||||
AddressInfoBuffer->Address.Address[0].Address,
|
||||
sizeof(Reply->Name.sa_data));
|
||||
|
||||
Reply->NameSize = sizeof(Reply->Name.sa_family) +
|
||||
AddressInfoBuffer->Address.Address[0].AddressLength;
|
||||
}
|
||||
|
||||
IoFreeMdl(Mdl);
|
||||
ExFreePool(AddressInfoBuffer);
|
||||
}
|
||||
|
||||
AFD_DbgPrint(MAX_TRACE, ("Status (0x%X).\n", Status));
|
||||
|
|
|
@ -375,6 +375,11 @@ NTSTATUS TdiSetEventHandler(
|
|||
PVOID Handler,
|
||||
PVOID Context);
|
||||
|
||||
NTSTATUS TdiQueryInformation(
|
||||
PFILE_OBJECT FileObject,
|
||||
LONG QueryType,
|
||||
PMDL MdlBuffer);
|
||||
|
||||
NTSTATUS TdiQueryDeviceControl(
|
||||
PFILE_OBJECT FileObject,
|
||||
ULONG IoControlCode,
|
||||
|
|
|
@ -602,9 +602,74 @@ NTSTATUS DispTdiQueryInformation(
|
|||
* Status of operation
|
||||
*/
|
||||
{
|
||||
PTDI_REQUEST_KERNEL_QUERY_INFORMATION Parameters;
|
||||
PTRANSPORT_CONTEXT TranContext;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
|
||||
TI_DbgPrint(DEBUG_IRP, ("Called.\n"));
|
||||
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
Parameters = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)&IrpSp->Parameters;
|
||||
|
||||
TranContext = IrpSp->FileObject->FsContext;
|
||||
if (!TranContext) {
|
||||
TI_DbgPrint(MID_TRACE, ("Bad transport context.\n"));
|
||||
return STATUS_INVALID_CONNECTION;
|
||||
}
|
||||
|
||||
switch (Parameters->QueryType)
|
||||
{
|
||||
case TDI_QUERY_ADDRESS_INFO:
|
||||
{
|
||||
PTDI_ADDRESS_INFO AddressInfo;
|
||||
PADDRESS_FILE AddrFile;
|
||||
PTA_IP_ADDRESS Address;
|
||||
|
||||
AddressInfo = (PTDI_ADDRESS_INFO)MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||
|
||||
switch ((ULONG)IrpSp->FileObject->FsContext2) {
|
||||
case TDI_TRANSPORT_ADDRESS_FILE:
|
||||
AddrFile = (PADDRESS_FILE)TranContext->Handle.AddressHandle;
|
||||
break;
|
||||
|
||||
case TDI_CONNECTION_FILE:
|
||||
AddrFile = ((PCONNECTION_ENDPOINT)TranContext->Handle.ConnectionContext)->AddressFile;
|
||||
break;
|
||||
|
||||
default:
|
||||
TI_DbgPrint(MIN_TRACE, ("Invalid transport context\n"));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!AddrFile) {
|
||||
TI_DbgPrint(MID_TRACE, ("No address file object.\n"));
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (MmGetMdlByteCount(Irp->MdlAddress) <
|
||||
(sizeof(TDI_ADDRESS_INFO) + sizeof(TDI_ADDRESS_IP))) {
|
||||
TI_DbgPrint(MID_TRACE, ("MDL buffer too small.\n"));
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
/* FIXME: Is this count really the one we should return? */
|
||||
AddressInfo->ActivityCount = AddrFile->RefCount;
|
||||
|
||||
Address = (PTA_IP_ADDRESS)&AddressInfo->Address;
|
||||
Address->TAAddressCount = 1;
|
||||
Address->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
|
||||
Address->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
|
||||
Address->Address[0].Address[0].sin_port = AddrFile->Port;
|
||||
Address->Address[0].Address[0].in_addr = AddrFile->ADE->Address->Address.IPv4Address;
|
||||
RtlZeroMemory(
|
||||
&Address->Address[0].Address[0].sin_zero,
|
||||
sizeof(Address->Address[0].Address[0].sin_zero));
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -329,16 +329,22 @@ NTSTATUS TCPiBuildPacket(
|
|||
{
|
||||
PVOID Data;
|
||||
UINT Size;
|
||||
PNDIS_BUFFER NdisBuffer = SendRequest->Buffer;
|
||||
NdisChainBufferAtBack(Packet->NdisPacket, NdisBuffer);
|
||||
/*
|
||||
* NOTE:
|
||||
* Don't name the variable NdisBuffer, because that's internal name
|
||||
* used by the NdisChainBufferAtBack macro and it's the easiest way
|
||||
* how to achieve an elegant crash.
|
||||
*/
|
||||
PNDIS_BUFFER _NdisBuffer = SendRequest->Buffer;
|
||||
NdisChainBufferAtBack(Packet->NdisPacket, _NdisBuffer);
|
||||
/* Add checksum for segment data */
|
||||
/* FIXME: Verify that there is no problem for chained buffers with an odd length */
|
||||
while (NdisBuffer != NULL)
|
||||
while (_NdisBuffer != NULL)
|
||||
{
|
||||
NdisQueryBuffer(NdisBuffer, &Data, &Size);
|
||||
NdisQueryBuffer(_NdisBuffer, &Data, &Size);
|
||||
DbgPrint("Checksum7:(%d bytes)\n", Size);
|
||||
Checksum = TCPv4Checksum(Data, Size, ~Checksum);
|
||||
NdisGetNextBuffer(NdisBuffer, &NdisBuffer);
|
||||
NdisGetNextBuffer(_NdisBuffer, &_NdisBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue