]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IpSecDxe/IkePacket.c
NetworkPkg: Clean up source files
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IkePacket.c
index fa29d548768d2e02911f5039f480be2702449c14..acfe079855520085a817bb2c783df663e0465c77 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   IKE Packet related operation.\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2018, 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
@@ -36,7 +36,7 @@ IkePacketAlloc (
 \r
   IkePacket->RefCount = 1;\r
   InitializeListHead (&IkePacket->PayloadList);\r
-  \r
+\r
   IkePacket->Header = (IKE_HEADER *) AllocateZeroPool (sizeof (IKE_HEADER));\r
   if (IkePacket->Header == NULL) {\r
     FreePool (IkePacket);\r
@@ -94,11 +94,12 @@ IkePacketFree (
 \r
 /**\r
   Callback funtion of NetbufFromExt()\r
-  \r
-  @param[in]  Arg  The data passed from the NetBufFromExe(). \r
+\r
+  @param[in]  Arg  The data passed from the NetBufFromExe().\r
 \r
 **/\r
 VOID\r
+EFIAPI\r
 IkePacketNetbufFree (\r
   IN VOID  *Arg\r
   )\r
@@ -110,11 +111,11 @@ IkePacketNetbufFree (
 \r
 /**\r
   Copy the NetBuf into a IKE_PACKET sturcture.\r
-  \r
-  Create a IKE_PACKET and fill the received IKE header into the header of IKE_PACKET \r
+\r
+  Create a IKE_PACKET and fill the received IKE header into the header of IKE_PACKET\r
   and copy the recieved packet without IKE HEADER to the PayloadBuf of IKE_PACKET.\r
 \r
-  @param[in]  Netbuf      The pointer of the Netbuf which contains the whole received \r
+  @param[in]  Netbuf      The pointer of the Netbuf which contains the whole received\r
                           IKE packet.\r
 \r
   @return The pointer of the IKE_PACKET which contains the received packet.\r
@@ -173,12 +174,12 @@ Error:
 \r
   @param[in]  SessionCommon  Pointer of related IKE_COMMON_SESSION\r
   @param[in]  IkePacket      Pointer of IKE_PACKET to be copy to NetBuf\r
-  @param[in]  IkeType        The IKE type to pointer the packet is for which IKE \r
-                             phase. Now it supports IKE_SA_TYPE, IKE_CHILDSA_TYPE, \r
+  @param[in]  IkeType        The IKE type to pointer the packet is for which IKE\r
+                             phase. Now it supports IKE_SA_TYPE, IKE_CHILDSA_TYPE,\r
                              IKE_INFO_TYPE.\r
 \r
   @return a pointer of Netbuff which contains the IKE_PACKE in network order.\r
-  \r
+\r
 **/\r
 NET_BUF *\r
 IkeNetbufFromPacket (\r
@@ -194,6 +195,9 @@ IkeNetbufFromPacket (
   LIST_ENTRY    *PacketEntry;\r
   LIST_ENTRY    *Entry;\r
   IKE_PAYLOAD   *IkePayload;\r
+  EFI_STATUS    RetStatus;\r
+\r
+  RetStatus = EFI_SUCCESS;\r
 \r
   if (!IkePacket->IsEncoded) {\r
     IkePacket->IsEncoded = TRUE;\r
@@ -202,10 +206,14 @@ IkeNetbufFromPacket (
     // Encryption payloads if needed\r
     //\r
     if (((IKEV2_SESSION_COMMON *) SessionCommon)->IkeVer == 2) {\r
-      Ikev2EncodePacket ((IKEV2_SESSION_COMMON *) SessionCommon, IkePacket, IkeType);\r
+      RetStatus = Ikev2EncodePacket ((IKEV2_SESSION_COMMON *) SessionCommon, IkePacket, IkeType);\r
+      if (EFI_ERROR (RetStatus)) {\r
+        return NULL;\r
+      }\r
+\r
     } else {\r
       //\r
-      //If IKEv1 support, check it here.\r
+      // If IKEv1 support, check it here.\r
       //\r
       return NULL;\r
     }\r
@@ -216,7 +224,7 @@ IkeNetbufFromPacket (
   // Get the number of the payloads\r
   //\r
   NET_LIST_FOR_EACH (PacketEntry, &(IkePacket)->PayloadList) {\r
-  \r
+\r
     NumPayloads++;\r
   }\r
   //\r
@@ -250,7 +258,7 @@ IkeNetbufFromPacket (
              IkePacketNetbufFree,\r
              NULL\r
              );\r
-  \r
+\r
   FreePool (Fragments);\r
   return Netbuf;\r
 }\r