/** @file\r
IP4 input process.\r
\r
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
Ip4NtohHead (*Head);\r
\r
if (EFI_ERROR (Status)) {\r
+ FreePool (OriginalFragmentTable);\r
goto ON_EXIT;\r
}\r
\r
if (OriginalFragmentTable == FragmentTable && OriginalFragmentCount == FragmentCount) {\r
+ //\r
+ // For ByPass Packet\r
+ //\r
+ FreePool (FragmentTable);\r
goto ON_EXIT;\r
+ } else {\r
+ //\r
+ // Free the FragmentTable which allocated before calling the IPsec.\r
+ //\r
+ FreePool (OriginalFragmentTable);\r
}\r
\r
if (Direction == EfiIPsecOutBound && TxWrap != NULL) {\r
TxWrap\r
);\r
if (TxWrap->Packet == NULL) {\r
+ //\r
+ // Recover the TxWrap->Packet, if meet a error, and the caller will free\r
+ // the TxWrap.\r
+ //\r
+ TxWrap->Packet = *Netbuf;\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
}\r
IpSecWrap = AllocateZeroPool (sizeof (IP4_IPSEC_WRAP));\r
\r
if (IpSecWrap == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ gBS->SignalEvent (RecycleEvent);\r
goto ON_EXIT;\r
}\r
\r
);\r
\r
if (Packet == NULL) {\r
+ Packet = IpSecWrap->Packet;\r
+ gBS->SignalEvent (RecycleEvent);\r
+ FreePool (IpSecWrap);\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
}\r
// and no need consider any other ahead ext headers.\r
//\r
Status = Ip4IpSecProcessPacket (\r
- IpSb, \r
- &Head, \r
- &Packet, \r
+ IpSb,\r
+ &Head,\r
+ &Packet,\r
&Option,\r
- &OptionLen, \r
+ &OptionLen,\r
EfiIPsecInBound,\r
NULL\r
);\r
//\r
Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);\r
Status = Ip4PreProcessPacket (\r
- IpSb, \r
- &Packet, \r
- Head, \r
+ IpSb,\r
+ &Packet,\r
+ Head,\r
Option,\r
- OptionLen, \r
+ OptionLen,\r
Flag\r
);\r
if (EFI_ERROR (Status)) {\r
/** @file\r
IP6 internal functions to process the incoming packets.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
Ip6NtohHead (*Head);\r
\r
if (EFI_ERROR (Status)) {\r
+ FreePool (OriginalFragmentTable);\r
goto ON_EXIT;\r
}\r
\r
//\r
// For ByPass Packet\r
//\r
+ FreePool (FragmentTable);\r
goto ON_EXIT;\r
+ } else {\r
+ //\r
+ // Free the FragmentTable which allocated before calling the IPsec.\r
+ //\r
+ FreePool (OriginalFragmentTable);\r
}\r
\r
if (Direction == EfiIPsecOutBound && TxWrap != NULL) {\r
TxWrap\r
);\r
if (TxWrap->Packet == NULL) {\r
+ TxWrap->Packet = *Netbuf;\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
}\r
IpSecWrap = AllocateZeroPool (sizeof (IP6_IPSEC_WRAP));\r
\r
if (IpSecWrap == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ gBS->SignalEvent (RecycleEvent);\r
goto ON_EXIT;\r
}\r
\r
);\r
\r
if (Packet == NULL) {\r
+ Packet = IpSecWrap->Packet;\r
+ gBS->SignalEvent (RecycleEvent);\r
+ FreePool (IpSecWrap);\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
}\r
NET_BUF_HEAD\r
);\r
if (PacketHead == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
+ *Netbuf = Packet;\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
}\r
\r
//\r
if (!SadData->Mode == EfiIPsecTunnel) {\r
if (IpVersion == IP_VERSION_4) {\r
- ((IP4_HEAD *) IpHead)->TotalLen = HTONS ((UINT16) (((IP4_HEAD *) IpHead)->HeadLen + PlainPayloadSize));\r
+ ((IP4_HEAD *) IpHead)->TotalLen = HTONS ((UINT16) ((((IP4_HEAD *) IpHead)->HeadLen << 2) + PlainPayloadSize));\r
} else {\r
IpSecHeadSize = IpSecGetPlainExtHeadSize (IpHead, LastHead);\r
((EFI_IP6_HEADER *) IpHead)->PayloadLength = HTONS ((UINT16)(IpSecHeadSize + PlainPayloadSize));\r