Author: jgardou
Date: Mon Nov 10 21:37:55 2014
New Revision: 65371
URL:
http://svn.reactos.org/svn/reactos?rev=65371&view=rev
Log:
[TCPIP]
- Implement setting the TTL for a socket.
- Stubplement setting the IP_DONTFRAGMENT flag.
- Properly set IoStatus.Information when receiving datagram.
- Properly skip the IP header when we're not receiving UDP datagrams
Modified:
branches/tcpip_revolution/drivers/network/tcpip/address.c
branches/tcpip_revolution/drivers/network/tcpip/address.h
branches/tcpip_revolution/drivers/network/tcpip/information.c
branches/tcpip_revolution/drivers/network/tcpip/precomp.h
Modified: branches/tcpip_revolution/drivers/network/tcpip/address.c
URL:
http://svn.reactos.org/svn/reactos/branches/tcpip_revolution/drivers/networ…
==============================================================================
--- branches/tcpip_revolution/drivers/network/tcpip/address.c [iso-8859-1] (original)
+++ branches/tcpip_revolution/drivers/network/tcpip/address.c [iso-8859-1] Mon Nov 10
21:37:55 2014
@@ -55,7 +55,8 @@
LIST_ENTRY* ListEntry;
RECEIVE_DATAGRAM_REQUEST* Request;
ip_addr_t RequestAddr;
- BOOLEAN Result = FALSE;
+
+ DPRINT1("Receiving datagram for addr 0x%08x on port %u.\n",
ip4_addr_get_u32(addr), port);
/* Block any cancellation that could occur */
IoAcquireCancelSpinLock(&OldIrql);
@@ -74,16 +75,26 @@
((Request->RemoteAddress.sin_port == port) || !port)))
{
PTA_IP_ADDRESS ReturnAddress;
+ PIRP Irp;
+
+ DPRINT1("Found a corresponding IRP.\n");
+
+ Irp = Request->Irp;
/* We found a request for this one */
- IoSetCancelRoutine(Request->Irp, NULL);
+ IoSetCancelRoutine(Irp, NULL);
RemoveEntryList(&Request->ListEntry);
KeReleaseSpinLockFromDpcLevel(&AddressFile->RequestLock);
IoReleaseCancelSpinLock(OldIrql);
- /* Return what we have to */
- pbuf_copy_partial(p, Request->Buffer, Request->BufferLength, 0);
+ /* In case of UDP, lwip provides a pbuf directly pointing to the data.
+ * In other case, we must skip the IP header */
+ Irp->IoStatus.Information = pbuf_copy_partial(
+ p,
+ Request->Buffer,
+ Request->BufferLength,
+ AddressFile->Protocol == IPPROTO_UDP ? 0 : IP_HLEN);
ReturnAddress = Request->ReturnInfo->RemoteAddress;
ReturnAddress->Address->AddressLength = TDI_ADDRESS_LENGTH_IP;
ReturnAddress->Address->AddressType = TDI_ADDRESS_TYPE_IP;
@@ -92,27 +103,22 @@
RtlZeroMemory(ReturnAddress->Address->Address->sin_zero,
sizeof(ReturnAddress->Address->Address->sin_zero));
- Request->Irp->IoStatus.Status = STATUS_SUCCESS;
-
- Result = TRUE;
-
- IoCompleteRequest(Request->Irp, IO_NETWORK_INCREMENT);
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NETWORK_INCREMENT);
ExFreePoolWithTag(Request, TAG_ADDRESS_FILE);
-
- /* Restart from the beginning of the list */
- IoAcquireCancelSpinLock(&OldIrql);
- KeAcquireSpinLockAtDpcLevel(&AddressFile->RequestLock);
- ListEntry = AddressFile->RequestListHead.Flink;
+ pbuf_free(p);
+
+ return TRUE;
}
}
KeReleaseSpinLockFromDpcLevel(&AddressFile->RequestLock);
IoReleaseCancelSpinLock(OldIrql);
- if (Result || MustFree)
+ if (MustFree)
pbuf_free(p);
- return Result;
+ return FALSE;
}
static
@@ -582,3 +588,54 @@
IoCompleteRequest(Irp, IO_NETWORK_INCREMENT);
return Status;
}
+
+NTSTATUS
+AddressSetIpDontFragment(
+ _In_ TDIEntityID ID,
+ _In_ PVOID InBuffer,
+ _In_ ULONG BufferSize)
+{
+ /* Silently ignore.
+ * lwip doesn't have such thing, and already tries to fragment data as less as
possible */
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+AddressSetTtl(
+ _In_ TDIEntityID ID,
+ _In_ PVOID InBuffer,
+ _In_ ULONG BufferSize)
+{
+ ADDRESS_FILE* AddressFile;
+ TCPIP_INSTANCE* Instance;
+ NTSTATUS Status;
+ ULONG Value;
+
+ if (BufferSize < sizeof(ULONG))
+ return STATUS_BUFFER_TOO_SMALL;
+
+ /* Get the address file */
+ Status = GetInstance(ID, &Instance);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ AddressFile = CONTAINING_RECORD(Instance, ADDRESS_FILE, Instance);
+
+ /* Get the value */
+ Value = *((ULONG*)InBuffer);
+
+ switch (AddressFile->Protocol)
+ {
+ case IPPROTO_TCP:
+ DPRINT1("TCP not supported yet.\n");
+ break;
+ case IPPROTO_UDP:
+ AddressFile->lwip_udp_pcb->ttl = Value;
+ break;
+ default:
+ AddressFile->lwip_raw_pcb->ttl = Value;
+ break;
+ }
+
+ return STATUS_SUCCESS;
+}
Modified: branches/tcpip_revolution/drivers/network/tcpip/address.h
URL:
http://svn.reactos.org/svn/reactos/branches/tcpip_revolution/drivers/networ…
==============================================================================
--- branches/tcpip_revolution/drivers/network/tcpip/address.h [iso-8859-1] (original)
+++ branches/tcpip_revolution/drivers/network/tcpip/address.h [iso-8859-1] Mon Nov 10
21:37:55 2014
@@ -39,3 +39,15 @@
NTSTATUS
TcpIpSendDatagram(
_Inout_ PIRP Irp);
+
+NTSTATUS
+AddressSetIpDontFragment(
+ _In_ TDIEntityID ID,
+ _In_ PVOID InBuffer,
+ _In_ ULONG BufferSize);
+
+NTSTATUS
+AddressSetTtl(
+ _In_ TDIEntityID ID,
+ _In_ PVOID InBuffer,
+ _In_ ULONG BufferSize);
Modified: branches/tcpip_revolution/drivers/network/tcpip/information.c
URL:
http://svn.reactos.org/svn/reactos/branches/tcpip_revolution/drivers/networ…
==============================================================================
--- branches/tcpip_revolution/drivers/network/tcpip/information.c [iso-8859-1] (original)
+++ branches/tcpip_revolution/drivers/network/tcpip/information.c [iso-8859-1] Mon Nov 10
21:37:55 2014
@@ -30,9 +30,11 @@
} InfoHandlers[] =
{
- { GENERIC_ENTITY, INFO_CLASS_GENERIC, INFO_TYPE_PROVIDER, ENTITY_LIST_ID,
QueryEntityList, NULL },
- { IF_ENTITY, INFO_CLASS_PROTOCOL, INFO_TYPE_PROVIDER, IP_MIB_STATS_ID,
QueryInterfaceEntry, NULL },
- { CL_NL_ENTITY, INFO_CLASS_PROTOCOL, INFO_TYPE_PROVIDER,
IP_MIB_ADDRTABLE_ENTRY_ID, QueryInterfaceAddrTable, NULL },
+ { GENERIC_ENTITY, INFO_CLASS_GENERIC, INFO_TYPE_PROVIDER,
ENTITY_LIST_ID, QueryEntityList, NULL },
+ { IF_ENTITY, INFO_CLASS_PROTOCOL, INFO_TYPE_PROVIDER,
IP_MIB_STATS_ID, QueryInterfaceEntry, NULL },
+ { CL_NL_ENTITY, INFO_CLASS_PROTOCOL, INFO_TYPE_PROVIDER,
IP_MIB_ADDRTABLE_ENTRY_ID, QueryInterfaceAddrTable, NULL },
+ { ER_ENTITY, INFO_CLASS_PROTOCOL, INFO_TYPE_ADDRESS_OBJECT,
AO_OPTION_TTL, NULL, AddressSetTtl },
+ { ER_ENTITY, INFO_CLASS_PROTOCOL, INFO_TYPE_ADDRESS_OBJECT,
AO_OPTION_IP_DONTFRAGMENT, NULL, AddressSetIpDontFragment },
{ (ULONG)-1, (ULONG)-1, (ULONG)-1, (ULONG)-1, NULL }
};
Modified: branches/tcpip_revolution/drivers/network/tcpip/precomp.h
URL:
http://svn.reactos.org/svn/reactos/branches/tcpip_revolution/drivers/networ…
==============================================================================
--- branches/tcpip_revolution/drivers/network/tcpip/precomp.h [iso-8859-1] (original)
+++ branches/tcpip_revolution/drivers/network/tcpip/precomp.h [iso-8859-1] Mon Nov 10
21:37:55 2014
@@ -18,6 +18,7 @@
#include <pseh/pseh2.h>
+#include <lwip/ip.h>
#include <lwip/tcpip.h>
#include <lwip/snmp.h>
#include <lwip/raw.h>