https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cf3ab9d15a2dc792e0b05…
commit cf3ab9d15a2dc792e0b059892cd3b163ca10cd78
Author: Victor Perevertkin <victor.perevertkin(a)reactos.org>
AuthorDate: Fri Nov 22 22:04:56 2019 +0300
Commit: Victor Perevertkin <victor(a)perevertkin.ru>
CommitDate: Tue Apr 7 05:32:40 2020 +0300
[SDK][IP] Fix formatting
---
sdk/lib/drivers/ip/transport/datagram/datagram.c | 224 ++++++++++++-----------
1 file changed, 113 insertions(+), 111 deletions(-)
diff --git a/sdk/lib/drivers/ip/transport/datagram/datagram.c
b/sdk/lib/drivers/ip/transport/datagram/datagram.c
index 7c043997bfe..c910ed6c386 100644
--- a/sdk/lib/drivers/ip/transport/datagram/datagram.c
+++ b/sdk/lib/drivers/ip/transport/datagram/datagram.c
@@ -49,14 +49,15 @@ BOOLEAN DGRemoveIRP(
return Found;
}
-VOID DGDeliverData(
- PADDRESS_FILE AddrFile,
- PIP_ADDRESS SrcAddress,
- PIP_ADDRESS DstAddress,
- USHORT SrcPort,
- USHORT DstPort,
- PIP_PACKET IPPacket,
- UINT DataSize)
+VOID
+DGDeliverData(
+ PADDRESS_FILE AddrFile,
+ PIP_ADDRESS SrcAddress,
+ PIP_ADDRESS DstAddress,
+ USHORT SrcPort,
+ USHORT DstPort,
+ PIP_PACKET IPPacket,
+ UINT DataSize)
/*
* FUNCTION: Delivers datagram data to a user
* ARGUMENTS:
@@ -72,139 +73,140 @@ VOID DGDeliverData(
* handler if it exists, otherwise we drop the packet.
*/
{
- KIRQL OldIrql;
- PTDI_IND_RECEIVE_DATAGRAM ReceiveHandler;
- PVOID HandlerContext;
- LONG AddressLength;
- PVOID SourceAddress;
- ULONG BytesTaken;
- NTSTATUS Status;
- PVOID DataBuffer;
+ KIRQL OldIrql;
+ PTDI_IND_RECEIVE_DATAGRAM ReceiveHandler;
+ PVOID HandlerContext;
+ LONG AddressLength;
+ PVOID SourceAddress;
+ ULONG BytesTaken;
+ NTSTATUS Status;
+ PVOID DataBuffer;
- TI_DbgPrint(MAX_TRACE, ("Called.\n"));
+ TI_DbgPrint(MIN_TRACE, ("Called.\n"));
- LockObject(AddrFile, &OldIrql);
+ LockObject(AddrFile, &OldIrql);
- if (AddrFile->Protocol == IPPROTO_UDP)
+ if (AddrFile->Protocol == IPPROTO_UDP)
{
- DataBuffer = IPPacket->Data;
+ DataBuffer = IPPacket->Data;
}
- else
+ else if (AddrFile->HeaderIncl)
+ {
+ DataBuffer = IPPacket->Header;
+ }
+ else
{
- if (AddrFile->HeaderIncl)
- DataBuffer = IPPacket->Header;
- else
- {
- DataBuffer = IPPacket->Data;
- DataSize -= IPPacket->HeaderSize;
- }
+ DataBuffer = IPPacket->Data;
+ DataSize -= IPPacket->HeaderSize;
}
- if (!IsListEmpty(&AddrFile->ReceiveQueue))
+ if (!IsListEmpty(&AddrFile->ReceiveQueue))
{
- PLIST_ENTRY CurrentEntry;
- PDATAGRAM_RECEIVE_REQUEST Current = NULL;
- PTA_IP_ADDRESS RTAIPAddress;
+ PLIST_ENTRY CurrentEntry;
+ PDATAGRAM_RECEIVE_REQUEST Current = NULL;
+ PTA_IP_ADDRESS RTAIPAddress;
- TI_DbgPrint(MAX_TRACE, ("There is a receive request.\n"));
+ TI_DbgPrint(MAX_TRACE, ("There is a receive request.\n"));
- /* Search receive request list to find a match */
- CurrentEntry = AddrFile->ReceiveQueue.Flink;
- while(CurrentEntry != &AddrFile->ReceiveQueue) {
- Current = CONTAINING_RECORD(CurrentEntry, DATAGRAM_RECEIVE_REQUEST,
ListEntry);
- CurrentEntry = CurrentEntry->Flink;
- if( DstPort == AddrFile->Port &&
- (AddrIsEqual(DstAddress, &AddrFile->Address) ||
- AddrIsUnspecified(&AddrFile->Address) ||
- AddrIsUnspecified(DstAddress))) {
+ /* Search receive request list to find a match */
+ CurrentEntry = AddrFile->ReceiveQueue.Flink;
+ while (CurrentEntry != &AddrFile->ReceiveQueue)
+ {
+ Current = CONTAINING_RECORD(CurrentEntry, DATAGRAM_RECEIVE_REQUEST,
ListEntry);
+ CurrentEntry = CurrentEntry->Flink;
+ if (DstPort == AddrFile->Port &&
+ (AddrIsEqual(DstAddress, &AddrFile->Address) ||
+ AddrIsUnspecified(&AddrFile->Address) ||
+ AddrIsUnspecified(DstAddress)))
+ {
- /* Remove the request from the queue */
- RemoveEntryList(&Current->ListEntry);
+ /* Remove the request from the queue */
+ RemoveEntryList(&Current->ListEntry);
- TI_DbgPrint(MAX_TRACE, ("Suitable receive request found.\n"));
+ TI_DbgPrint(MAX_TRACE, ("Suitable receive request found.\n"));
- TI_DbgPrint(MAX_TRACE,
+ TI_DbgPrint(MAX_TRACE,
("Target Buffer: %x, Source Buffer: %x, Size %d\n",
Current->Buffer, DataBuffer, DataSize));
- /* Copy the data into buffer provided by the user */
- RtlCopyMemory( Current->Buffer,
- DataBuffer,
- MIN(Current->BufferSize, DataSize) );
-
- RTAIPAddress = (PTA_IP_ADDRESS)Current->ReturnInfo->RemoteAddress;
- RTAIPAddress->TAAddressCount = 1;
- RTAIPAddress->Address->AddressType = TDI_ADDRESS_TYPE_IP;
- RTAIPAddress->Address->AddressLength = TDI_ADDRESS_LENGTH_IP;
- RTAIPAddress->Address->Address->sin_port = SrcPort;
- RTAIPAddress->Address->Address->in_addr =
SrcAddress->Address.IPv4Address;
- RtlZeroMemory(RTAIPAddress->Address->Address->sin_zero, 8);
-
- TI_DbgPrint(MAX_TRACE, ("(A: %08x) Addr %08x Port %04x\n",
- RTAIPAddress,
- SrcAddress->Address.IPv4Address, SrcPort));
-
- ReferenceObject(AddrFile);
- UnlockObject(AddrFile, OldIrql);
-
- /* Complete the receive request */
- if (Current->BufferSize < DataSize)
- Current->Complete(Current->Context, STATUS_BUFFER_OVERFLOW,
Current->BufferSize);
- else
- Current->Complete(Current->Context, STATUS_SUCCESS, DataSize);
-
- LockObject(AddrFile, &OldIrql);
- DereferenceObject(AddrFile);
- }
- }
-
- UnlockObject(AddrFile, OldIrql);
+ /* Copy the data into buffer provided by the user */
+ RtlCopyMemory(Current->Buffer,
+ DataBuffer,
+ MIN(Current->BufferSize, DataSize));
+
+ RTAIPAddress = (PTA_IP_ADDRESS)Current->ReturnInfo->RemoteAddress;
+ RTAIPAddress->TAAddressCount = 1;
+ RTAIPAddress->Address->AddressType = TDI_ADDRESS_TYPE_IP;
+ RTAIPAddress->Address->AddressLength = TDI_ADDRESS_LENGTH_IP;
+ RTAIPAddress->Address->Address->sin_port = SrcPort;
+ RTAIPAddress->Address->Address->in_addr =
SrcAddress->Address.IPv4Address;
+ RtlZeroMemory(RTAIPAddress->Address->Address->sin_zero, 8);
+
+ TI_DbgPrint(MAX_TRACE, ("(A: %08x) Addr %08x Port %04x\n",
+ RTAIPAddress,
+ SrcAddress->Address.IPv4Address, SrcPort));
+
+ ReferenceObject(AddrFile);
+ UnlockObject(AddrFile, OldIrql);
+
+ /* Complete the receive request */
+ if (Current->BufferSize < DataSize)
+ Current->Complete(Current->Context, STATUS_BUFFER_OVERFLOW,
Current->BufferSize);
+ else
+ Current->Complete(Current->Context, STATUS_SUCCESS, DataSize);
+
+ LockObject(AddrFile, &OldIrql);
+ DereferenceObject(AddrFile);
+ }
+ }
+
+ UnlockObject(AddrFile, OldIrql);
}
- else if (AddrFile->RegisteredReceiveDatagramHandler)
+ else if (AddrFile->RegisteredReceiveDatagramHandler)
{
- TI_DbgPrint(MAX_TRACE, ("Calling receive event handler.\n"));
+ TI_DbgPrint(MAX_TRACE, ("Calling receive event handler.\n"));
- ReceiveHandler = AddrFile->ReceiveDatagramHandler;
- HandlerContext = AddrFile->ReceiveDatagramHandlerContext;
+ ReceiveHandler = AddrFile->ReceiveDatagramHandler;
+ HandlerContext = AddrFile->ReceiveDatagramHandlerContext;
- if (SrcAddress->Type == IP_ADDRESS_V4)
+ if (SrcAddress->Type == IP_ADDRESS_V4)
{
- AddressLength = sizeof(IPv4_RAW_ADDRESS);
- SourceAddress = &SrcAddress->Address.IPv4Address;
+ AddressLength = sizeof(IPv4_RAW_ADDRESS);
+ SourceAddress = &SrcAddress->Address.IPv4Address;
}
- else /* (Address->Type == IP_ADDRESS_V6) */
+ else /* (Address->Type == IP_ADDRESS_V6) */
{
- AddressLength = sizeof(IPv6_RAW_ADDRESS);
- SourceAddress = SrcAddress->Address.IPv6Address;
+ AddressLength = sizeof(IPv6_RAW_ADDRESS);
+ SourceAddress = SrcAddress->Address.IPv6Address;
}
- ReferenceObject(AddrFile);
- UnlockObject(AddrFile, OldIrql);
-
- Status = (*ReceiveHandler)(HandlerContext,
- AddressLength,
- SourceAddress,
- 0,
- NULL,
- TDI_RECEIVE_ENTIRE_MESSAGE,
- DataSize,
- DataSize,
- &BytesTaken,
- DataBuffer,
- NULL);
-
- if (STATUS_SUCCESS != Status)
- TI_DbgPrint(MAX_TRACE, ("receive handler signaled failure with Status
0x%x\n", Status));
-
- DereferenceObject(AddrFile);
+ ReferenceObject(AddrFile);
+ UnlockObject(AddrFile, OldIrql);
+
+ Status = (*ReceiveHandler)(HandlerContext,
+ AddressLength,
+ SourceAddress,
+ 0,
+ NULL,
+ TDI_RECEIVE_ENTIRE_MESSAGE,
+ DataSize,
+ DataSize,
+ &BytesTaken,
+ DataBuffer,
+ NULL);
+
+ if (STATUS_SUCCESS != Status)
+ TI_DbgPrint(MAX_TRACE, ("receive handler signaled failure with Status
0x%x\n", Status));
+
+ DereferenceObject(AddrFile);
}
- else
+ else
{
- UnlockObject(AddrFile, OldIrql);
- TI_DbgPrint(MAX_TRACE, ("Discarding datagram.\n"));
+ UnlockObject(AddrFile, OldIrql);
+ TI_DbgPrint(MAX_TRACE, ("Discarding datagram.\n"));
}
- TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
+ TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
}