Author: cgutman
Date: Sat Apr 4 04:23:09 2009
New Revision: 40355
URL:
http://svn.reactos.org/svn/reactos?rev=40355&view=rev
Log:
- Initialize packets before using them
- Make PrepareICMPPacket return BOOLEAN
- Call the packet's free function to free it
- Remove unnecessary NULL checks
- Part 1 of 2
Modified:
trunk/reactos/lib/drivers/ip/network/arp.c
trunk/reactos/lib/drivers/ip/network/icmp.c
trunk/reactos/lib/drivers/ip/network/loopback.c
trunk/reactos/lib/drivers/ip/network/receive.c
trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c
trunk/reactos/lib/drivers/ip/transport/udp/udp.c
Modified: trunk/reactos/lib/drivers/ip/network/arp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/arp…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] Sat Apr 4 04:23:09 2009
@@ -253,6 +253,8 @@
SenderHWAddress,
LAN_PROTO_ARP);
}
+
+ Packet->Free(Packet);
}
/* EOF */
Modified: trunk/reactos/lib/drivers/ip/network/icmp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/icm…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/icmp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/icmp.c [iso-8859-1] Sat Apr 4 04:23:09 2009
@@ -34,7 +34,7 @@
}
-PIP_PACKET PrepareICMPPacket(
+BOOLEAN PrepareICMPPacket(
PIP_INTERFACE Interface,
PIP_PACKET IPPacket,
PIP_ADDRESS Destination,
@@ -57,6 +57,8 @@
TI_DbgPrint(DEBUG_ICMP, ("Called. DataSize (%d).\n", DataSize));
+ IPInitializePacket(IPPacket, IP_ADDRESS_V4);
+
/* No special flags */
IPPacket->Flags = 0;
@@ -65,7 +67,7 @@
/* Allocate NDIS packet */
NdisStatus = AllocatePacketWithBuffer( &NdisPacket, NULL, Size );
- if( !NT_SUCCESS(NdisStatus) ) return NULL;
+ if( !NT_SUCCESS(NdisStatus) ) return FALSE;
IPPacket->NdisPacket = NdisPacket;
@@ -114,7 +116,7 @@
TI_DbgPrint(MID_TRACE,("Leaving\n"));
- return IPPacket;
+ return TRUE;
}
Modified: trunk/reactos/lib/drivers/ip/network/loopback.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/loo…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/loopback.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/loopback.c [iso-8859-1] Sat Apr 4 04:23:09 2009
@@ -45,6 +45,9 @@
(PC(NdisPacket)->DLComplete)( PC(NdisPacket)->Context, NdisPacket,
NdisStatus );
return;
}
+
+ /* FIXME: IPv4 only */
+ IPInitializePacket(&IPPacket, IP_ADDRESS_V4);
NdisGetFirstBufferFromPacket(XmitPacket,
&NdisBuffer,
Modified: trunk/reactos/lib/drivers/ip/network/receive.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/rec…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/receive.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/receive.c [iso-8859-1] Sat Apr 4 04:23:09 2009
@@ -608,11 +608,13 @@
case 6:
IPPacket->Type = IP_ADDRESS_V6;
TI_DbgPrint(MAX_TRACE, ("Datagram of type IPv6 discarded.\n"));
- return;
+ break;
default:
TI_DbgPrint(MIN_TRACE, ("Datagram has an unsupported IP version %d.\n",
Version));
- return;
- }
+ break;
+ }
+
+ IPPacket->Free(IPPacket);
}
/* EOF */
Modified: trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/r…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] Sat Apr 4 04:23:09
2009
@@ -107,8 +107,6 @@
/* FIXME: Assumes IPv4 */
IPInitializePacket(Packet, IP_ADDRESS_V4);
- if (!Packet)
- return STATUS_INSUFFICIENT_RESOURCES;
Packet->TotalSize = sizeof(IPv4_HEADER) + DataLen;
Modified: trunk/reactos/lib/drivers/ip/transport/udp/udp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/u…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] Sat Apr 4 04:23:09
2009
@@ -88,8 +88,6 @@
/* FIXME: Assumes IPv4 */
IPInitializePacket(Packet, IP_ADDRESS_V4);
- if (!Packet)
- return STATUS_INSUFFICIENT_RESOURCES;
Packet->TotalSize = sizeof(IPv4_HEADER) + sizeof(UDP_HEADER) + DataLen;