[SDK][IP] Pass IP options to ReceiveDatagramHandler

This commit is contained in:
Victor Perevertkin 2019-12-20 23:19:41 +03:00 committed by Victor Perevertkin
parent 740a859e92
commit d5ad2057d7

View file

@ -74,8 +74,6 @@ DGDeliverData(
*/ */
{ {
KIRQL OldIrql; KIRQL OldIrql;
PTDI_IND_RECEIVE_DATAGRAM ReceiveHandler;
PVOID HandlerContext;
LONG AddressLength; LONG AddressLength;
PVOID SourceAddress; PVOID SourceAddress;
ULONG BytesTaken; ULONG BytesTaken;
@ -164,15 +162,22 @@ DGDeliverData(
} }
else if (AddrFile->RegisteredReceiveDatagramHandler) else if (AddrFile->RegisteredReceiveDatagramHandler)
{ {
TI_DbgPrint(MAX_TRACE, ("Calling receive event handler.\n")); PTDI_IND_RECEIVE_DATAGRAM ReceiveHandler = AddrFile->ReceiveDatagramHandler;
PVOID HandlerContext = AddrFile->ReceiveDatagramHandlerContext;
PVOID OptionsData = NULL;
INT32 OptionsSize = 0;
ReceiveHandler = AddrFile->ReceiveDatagramHandler; TI_DbgPrint(MAX_TRACE, ("Calling receive event handler.\n"));
HandlerContext = AddrFile->ReceiveDatagramHandlerContext;
if (SrcAddress->Type == IP_ADDRESS_V4) if (SrcAddress->Type == IP_ADDRESS_V4)
{ {
AddressLength = sizeof(IPv4_RAW_ADDRESS); AddressLength = sizeof(IPv4_RAW_ADDRESS);
SourceAddress = &SrcAddress->Address.IPv4Address; SourceAddress = &SrcAddress->Address.IPv4Address;
OptionsSize = IPPacket->HeaderSize - sizeof(IPv4_HEADER);
if (OptionsSize > 0)
{
OptionsData = (PUCHAR)IPPacket->Header + sizeof(IPv4_HEADER);
}
} }
else /* (Address->Type == IP_ADDRESS_V6) */ else /* (Address->Type == IP_ADDRESS_V6) */
{ {
@ -183,11 +188,13 @@ DGDeliverData(
ReferenceObject(AddrFile); ReferenceObject(AddrFile);
UnlockObject(AddrFile, OldIrql); UnlockObject(AddrFile, OldIrql);
TI_DbgPrint(MIN_TRACE, ("OptionsSize %d DataSize: %u\n", OptionsSize, DataSize));
Status = (*ReceiveHandler)(HandlerContext, Status = (*ReceiveHandler)(HandlerContext,
AddressLength, AddressLength,
SourceAddress, SourceAddress,
0, OptionsSize,
NULL, OptionsData,
TDI_RECEIVE_ENTIRE_MESSAGE, TDI_RECEIVE_ENTIRE_MESSAGE,
DataSize, DataSize,
DataSize, DataSize,
@ -209,7 +216,6 @@ DGDeliverData(
TI_DbgPrint(MAX_TRACE, ("Leaving.\n")); TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
} }
VOID DGReceiveComplete(PVOID Context, NTSTATUS Status, ULONG Count) { VOID DGReceiveComplete(PVOID Context, NTSTATUS Status, ULONG Count) {
PDATAGRAM_RECEIVE_REQUEST ReceiveRequest = PDATAGRAM_RECEIVE_REQUEST ReceiveRequest =
(PDATAGRAM_RECEIVE_REQUEST)Context; (PDATAGRAM_RECEIVE_REQUEST)Context;