]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IpSecDxe/IpSecConfigImpl.c
NetworkPkg: Clean up source files
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IpSecConfigImpl.c
index 4a51bff96f420bf2cbb7a95576f6051f6949a87c..8893d49a9fe37a2d53eff453a5afc83025d4355d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of IPSEC_CONFIG_PROTOCOL.\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 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
@@ -97,7 +97,7 @@ EFI_IPSEC_CONFIG_PROTOCOL mIpSecConfigInstance = {
   Get the all IPSec configuration variables and store those variables\r
   to the internal data structure.\r
 \r
-  This founction is called by IpSecConfigInitialize() that is to intialize the \r
+  This founction is called by IpSecConfigInitialize() that is to intialize the\r
   IPsecConfiguration Protocol.\r
 \r
   @param[in]  Private            Point to IPSEC_PRIVATE_DATA.\r
@@ -121,7 +121,7 @@ IpSecConfigRestore (
 \r
   @retval  TRUE    The specified AddressInfo is in the AddressInfoList.\r
   @retval  FALSE   The specified AddressInfo is not in the AddressInfoList.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 IsInAddressInfoList(\r
@@ -152,20 +152,20 @@ IsInAddressInfoList(
           AddressInfo,\r
           &AddressInfoList[Index].Address,\r
           sizeof (EFI_IP_ADDRESS)\r
-          ) == 0 && \r
+          ) == 0 &&\r
           AddressInfo->PrefixLength == AddressInfoList[Index].PrefixLength\r
-          ) { \r
+          ) {\r
        return TRUE;\r
      }\r
   }\r
   return FALSE;\r
 }\r
\r
+\r
 /**\r
   Compare two SPD Selectors.\r
 \r
   Compare two SPD Selector by the fields of LocalAddressCount/RemoteAddressCount/\r
-  NextLayerProtocol/LocalPort/LocalPortRange/RemotePort/RemotePortRange and the \r
+  NextLayerProtocol/LocalPort/LocalPortRange/RemotePort/RemotePortRange and the\r
   Local Addresses and remote Addresses.\r
 \r
   @param[in]   Selector1           Pointer of first SPD Selector.\r
@@ -173,7 +173,7 @@ IsInAddressInfoList(
 \r
   @retval  TRUE    This two Selector have the same value in above fields.\r
   @retval  FALSE   Not all above fields have the same value in these two Selectors.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 CompareSpdSelector (\r
@@ -193,7 +193,7 @@ CompareSpdSelector (
   //\r
   // Compare the LocalAddressCount/RemoteAddressCount/NextLayerProtocol/\r
   // LocalPort/LocalPortRange/RemotePort/RemotePortRange fields in the\r
-  // two Spdselectors. Since the SPD supports two directions, it needs to \r
+  // two Spdselectors. Since the SPD supports two directions, it needs to\r
   // compare two directions.\r
   //\r
   if ((SpdSel1->LocalAddressCount != SpdSel2->LocalAddressCount &&\r
@@ -209,10 +209,10 @@ CompareSpdSelector (
     IsMatch = FALSE;\r
     return IsMatch;\r
   }\r
-  \r
+\r
   //\r
   // Compare the all LocalAddress and RemoteAddress fields in the two Spdselectors.\r
-  // First, SpdSel1->LocalAddress to SpdSel2->LocalAddress && Compare \r
+  // First, SpdSel1->LocalAddress to SpdSel2->LocalAddress && Compare\r
   // SpdSel1->RemoteAddress to SpdSel2->RemoteAddress. If all match, return\r
   // TRUE.\r
   //\r
@@ -263,14 +263,14 @@ CompareSpdSelector (
     }\r
   }\r
   //\r
-  // Finish the one direction compare. If it is matched, return; otherwise, \r
+  // Finish the one direction compare. If it is matched, return; otherwise,\r
   // compare the other direction.\r
   //\r
   if (IsMatch) {\r
     return IsMatch;\r
   }\r
   //\r
-  // Secondly, the SpdSel1->LocalAddress doesn't equal to  SpdSel2->LocalAddress and \r
+  // Secondly, the SpdSel1->LocalAddress doesn't equal to  SpdSel2->LocalAddress and\r
   // SpdSel1->RemoteAddress doesn't equal to SpdSel2->RemoteAddress. Try to compare\r
   // the RemoteAddress to LocalAddress.\r
   //\r
@@ -328,16 +328,16 @@ CompareSpdSelector (
   Find if the two SPD Selectors has subordinative.\r
 \r
   Compare two SPD Selector by the fields of LocalAddressCount/RemoteAddressCount/\r
-  NextLayerProtocol/LocalPort/LocalPortRange/RemotePort/RemotePortRange and the \r
+  NextLayerProtocol/LocalPort/LocalPortRange/RemotePort/RemotePortRange and the\r
   Local Addresses and remote Addresses.\r
 \r
   @param[in]   Selector1           Pointer of first SPD Selector.\r
   @param[in]   Selector2           Pointer of second SPD Selector.\r
 \r
   @retval  TRUE    The first SPD Selector is subordinate Selector of second SPD Selector.\r
-  @retval  FALSE   The first SPD Selector is not subordinate Selector of second \r
+  @retval  FALSE   The first SPD Selector is not subordinate Selector of second\r
                    SPD Selector.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 IsSubSpdSelector (\r
@@ -357,7 +357,7 @@ IsSubSpdSelector (
   //\r
   // Compare the LocalAddressCount/RemoteAddressCount/NextLayerProtocol/\r
   // LocalPort/LocalPortRange/RemotePort/RemotePortRange fields in the\r
-  // two Spdselectors. Since the SPD supports two directions, it needs to \r
+  // two Spdselectors. Since the SPD supports two directions, it needs to\r
   // compare two directions.\r
   //\r
   if (SpdSel1->LocalAddressCount > SpdSel2->LocalAddressCount ||\r
@@ -370,10 +370,10 @@ IsSubSpdSelector (
       ) {\r
     IsMatch = FALSE;\r
   }\r
-  \r
+\r
   //\r
   // Compare the all LocalAddress and RemoteAddress fields in the two Spdselectors.\r
-  // First, SpdSel1->LocalAddress to SpdSel2->LocalAddress && Compare \r
+  // First, SpdSel1->LocalAddress to SpdSel2->LocalAddress && Compare\r
   // SpdSel1->RemoteAddress to SpdSel2->RemoteAddress. If all match, return\r
   // TRUE.\r
   //\r
@@ -405,14 +405,14 @@ IsSubSpdSelector (
   if (IsMatch) {\r
     return IsMatch;\r
   }\r
-  \r
+\r
   //\r
   //\r
   // The SPD selector in SPD entry is two way.\r
   //\r
   // Compare the LocalAddressCount/RemoteAddressCount/NextLayerProtocol/\r
   // LocalPort/LocalPortRange/RemotePort/RemotePortRange fields in the\r
-  // two Spdselectors. Since the SPD supports two directions, it needs to \r
+  // two Spdselectors. Since the SPD supports two directions, it needs to\r
   // compare two directions.\r
   //\r
   IsMatch = TRUE;\r
@@ -427,10 +427,10 @@ IsSubSpdSelector (
     IsMatch = FALSE;\r
     return IsMatch;\r
   }\r
-  \r
+\r
   //\r
   // Compare the all LocalAddress and RemoteAddress fields in the two Spdselectors.\r
-  // First, SpdSel1->LocalAddress to SpdSel2->RemoteAddress && Compare \r
+  // First, SpdSel1->LocalAddress to SpdSel2->RemoteAddress && Compare\r
   // SpdSel1->RemoteAddress to SpdSel2->LocalAddress. If all match, return\r
   // TRUE.\r
   //\r
@@ -458,7 +458,7 @@ IsSubSpdSelector (
     }\r
   }\r
   return IsMatch;\r
-  \r
+\r
 }\r
 \r
 /**\r
@@ -469,7 +469,7 @@ IsSubSpdSelector (
 \r
   @retval  TRUE    This two Selectors have the same SA ID.\r
   @retval  FALSE   This two Selecotrs don't have the same SA ID.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 CompareSaId (\r
@@ -500,7 +500,7 @@ CompareSaId (
 \r
   @retval  TRUE    This two Selectors have the same PAD ID.\r
   @retval  FALSE   This two Selecotrs don't have the same PAD ID.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 ComparePadId (\r
@@ -589,7 +589,7 @@ IsZeroSaId (
 {\r
   BOOLEAN                   IsZero;\r
   EFI_IPSEC_CONFIG_SELECTOR ZeroSelector;\r
-  \r
+\r
   IsZero    = FALSE;\r
 \r
   ZeroMem (&ZeroSelector, sizeof (EFI_IPSEC_CONFIG_SELECTOR));\r
@@ -636,14 +636,14 @@ IsZeroPadId (
 \r
   @param[in, out] DstSel             Pointer of Destination SPD Selector.\r
   @param[in]      SrcSel             Pointer of Source SPD Selector.\r
-  @param[in, out] Size               The size of the Destination SPD Selector. If it \r
-                                     not NULL and its value less than the size of \r
-                                     Source SPD Selector, the value of Source SPD \r
+  @param[in, out] Size               The size of the Destination SPD Selector. If it\r
+                                     not NULL and its value less than the size of\r
+                                     Source SPD Selector, the value of Source SPD\r
                                      Selector's size will be passed to caller by this\r
                                      parameter.\r
 \r
   @retval EFI_INVALID_PARAMETER  If the Destination or Source SPD Selector is NULL\r
-  @retval EFI_BUFFER_TOO_SMALL   If the input Size is less than size of the Source SPD Selector. \r
+  @retval EFI_BUFFER_TOO_SMALL   If the input Size is less than size of the Source SPD Selector.\r
   @retval EFI_SUCCESS            Copy Source SPD Selector to the Destination SPD\r
                                  Selector successfully.\r
 \r
@@ -702,13 +702,13 @@ DuplicateSpdSelector (
 \r
   @param[in, out] DstSel             Pointer of Destination SA ID.\r
   @param[in]      SrcSel             Pointer of Source SA ID.\r
-  @param[in, out] Size               The size of the Destination SA ID. If it \r
-                                     not NULL and its value less than the size of \r
-                                     Source SA ID, the value of Source SA ID's size \r
+  @param[in, out] Size               The size of the Destination SA ID. If it\r
+                                     not NULL and its value less than the size of\r
+                                     Source SA ID, the value of Source SA ID's size\r
                                      will be passed to caller by this parameter.\r
 \r
   @retval EFI_INVALID_PARAMETER  If the Destination or Source SA ID is NULL.\r
-  @retval EFI_BUFFER_TOO_SMALL   If the input Size less than size of source SA ID. \r
+  @retval EFI_BUFFER_TOO_SMALL   If the input Size less than size of source SA ID.\r
   @retval EFI_SUCCESS            Copy Source SA ID  to the Destination SA ID successfully.\r
 \r
 **/\r
@@ -744,9 +744,9 @@ DuplicateSaId (
 \r
   @param[in, out] DstSel             Pointer of Destination PAD ID.\r
   @param[in]      SrcSel             Pointer of Source PAD ID.\r
-  @param[in, out] Size               The size of the Destination PAD ID. If it \r
-                                     not NULL and its value less than the size of \r
-                                     Source PAD ID, the value of Source PAD ID's size \r
+  @param[in, out] Size               The size of the Destination PAD ID. If it\r
+                                     not NULL and its value less than the size of\r
+                                     Source PAD ID, the value of Source PAD ID's size\r
                                      will be passed to caller by this parameter.\r
 \r
   @retval EFI_INVALID_PARAMETER  If the Destination or Source PAD ID is NULL.\r
@@ -782,11 +782,11 @@ DuplicatePadId (
 }\r
 \r
 /**\r
-  Fix the value of some members of SPD Selector. \r
+  Fix the value of some members of SPD Selector.\r
 \r
-  This function is called by IpSecCopyPolicyEntry()which copy the Policy \r
-  Entry into the Variable. Since some members in SPD Selector are pointers, \r
-  a physical address to relative address convertion is required before copying \r
+  This function is called by IpSecCopyPolicyEntry()which copy the Policy\r
+  Entry into the Variable. Since some members in SPD Selector are pointers,\r
+  a physical address to relative address convertion is required before copying\r
   this SPD entry into the variable.\r
 \r
   @param[in]       Selector              Pointer of SPD Selector.\r
@@ -817,11 +817,11 @@ FixSpdEntry (
 }\r
 \r
 /**\r
-  Fix the value of some members of SA ID. \r
+  Fix the value of some members of SA ID.\r
 \r
-  This function is called by IpSecCopyPolicyEntry()which copy the Policy \r
-  Entry into the Variable. Since some members in SA ID are pointers, \r
-  a physical address to relative address conversion is required before copying \r
+  This function is called by IpSecCopyPolicyEntry()which copy the Policy\r
+  Entry into the Variable. Since some members in SA ID are pointers,\r
+  a physical address to relative address conversion is required before copying\r
   this SAD into the variable.\r
 \r
   @param[in]       SaId                  Pointer of SA ID\r
@@ -858,10 +858,10 @@ FixSadEntry (
 }\r
 \r
 /**\r
-  Fix the value of some members of PAD ID. \r
+  Fix the value of some members of PAD ID.\r
 \r
-  This function is called by IpSecCopyPolicyEntry()which copy the Policy \r
-  Entry into the Variable. Since some members in PAD ID are pointers, \r
+  This function is called by IpSecCopyPolicyEntry()which copy the Policy\r
+  Entry into the Variable. Since some members in PAD ID are pointers,\r
   a physical address to relative address conversion is required before copying\r
   this PAD into the variable.\r
 \r
@@ -890,7 +890,7 @@ FixPadEntry (
 }\r
 \r
 /**\r
-  Recover the value of some members of SPD Selector. \r
+  Recover the value of some members of SPD Selector.\r
 \r
   This function is corresponding to FixSpdEntry(). It recovers the value of members\r
   of SPD Selector that are fixed by FixSpdEntry().\r
@@ -918,11 +918,11 @@ UnfixSpdEntry (
       UNFIX_REF_BUF_ADDR (Data->ProcessingPolicy->TunnelOption, Data);\r
     }\r
   }\r
-  \r
+\r
 }\r
 \r
 /**\r
-  Recover the value of some members of SA ID. \r
+  Recover the value of some members of SA ID.\r
 \r
   This function is corresponding to FixSadEntry(). It recovers the value of members\r
   of SAD ID that are fixed by FixSadEntry().\r
@@ -961,7 +961,7 @@ UnfixSadEntry (
 }\r
 \r
 /**\r
-  Recover the value of some members of PAD ID. \r
+  Recover the value of some members of PAD ID.\r
 \r
   This function is corresponding to FixPadEntry(). It recovers the value of members\r
   of PAD ID that are fixed by FixPadEntry().\r
@@ -993,32 +993,32 @@ UnfixPadEntry (
 /**\r
   Set the security policy information for the EFI IPsec driver.\r
 \r
-  The IPsec configuration data has a unique selector/identifier separately to \r
+  The IPsec configuration data has a unique selector/identifier separately to\r
   identify a data entry.\r
 \r
-  @param[in]  Selector           Pointer to an entry selector on operated \r
-                                 configuration data specified by DataType. \r
-                                 A NULL Selector causes the entire specified-type \r
+  @param[in]  Selector           Pointer to an entry selector on operated\r
+                                 configuration data specified by DataType.\r
+                                 A NULL Selector causes the entire specified-type\r
                                  configuration information to be flushed.\r
-  @param[in]  Data               The data buffer to be set. The structure \r
+  @param[in]  Data               The data buffer to be set. The structure\r
                                  of the data buffer should be EFI_IPSEC_SPD_DATA.\r
-  @param[in]  Context            Pointer to one entry selector that describes \r
-                                 the expected position the new data entry will \r
+  @param[in]  Context            Pointer to one entry selector that describes\r
+                                 the expected position the new data entry will\r
                                  be added. If Context is NULL, the new entry will\r
                                  be appended the end of database.\r
 \r
   @retval EFI_INVALID_PARAMETER  One or more of the following are TRUE:\r
-                                   - Selector is not NULL and its LocalAddress \r
+                                   - Selector is not NULL and its LocalAddress\r
                                      is NULL or its RemoteAddress is NULL.\r
-                                   - Data is not NULL and its Action is Protected \r
+                                   - Data is not NULL and its Action is Protected\r
                                      and its plolicy is NULL.\r
                                    - Data is not NULL, its Action is not protected,\r
                                      and its policy is not NULL.\r
-                                   - The Action of Data is Protected, its policy \r
+                                   - The Action of Data is Protected, its policy\r
                                      mode is Tunnel, and its tunnel option is NULL.\r
-                                   - The Action of Data is protected and its policy \r
+                                   - The Action of Data is protected and its policy\r
                                      mode is not Tunnel and it tunnel option is not NULL.\r
-                                   - SadEntry requied to be set into new SpdEntry's Sas has \r
+                                   - SadEntry requied to be set into new SpdEntry's Sas has\r
                                      been found but it is invalid.\r
   @retval EFI_OUT_OF_RESOURCED  The required system resource could not be allocated.\r
   @retval EFI_SUCCESS           The specified configuration data was obtained successfully.\r
@@ -1085,7 +1085,7 @@ SetSpdEntry (
 \r
     SpdEntry = IPSEC_SPD_ENTRY_FROM_LIST (Entry);\r
 \r
-    if (SpdSel == NULL || \r
+    if (SpdSel == NULL ||\r
         CompareSpdSelector ((EFI_IPSEC_CONFIG_SELECTOR *) SpdEntry->Selector, (EFI_IPSEC_CONFIG_SELECTOR *) SpdSel)\r
         ) {\r
       //\r
@@ -1098,26 +1098,26 @@ SetSpdEntry (
       // Update the reverse ref of SAD entry in the SPD.sas list.\r
       //\r
       SpdSas = &SpdEntry->Data->Sas;\r
-      \r
+\r
       //\r
-      // Remove the related SAs from Sas(SadEntry->BySpd). If the SA entry is established by \r
-      // IKE, remove from mConfigData list(SadEntry->List) and then free it directly since its \r
+      // Remove the related SAs from Sas(SadEntry->BySpd). If the SA entry is established by\r
+      // IKE, remove from mConfigData list(SadEntry->List) and then free it directly since its\r
       // SpdEntry will be freed later.\r
       //\r
       NET_LIST_FOR_EACH_SAFE (Entry2, NextEntry2, SpdSas) {\r
         SadEntry = IPSEC_SAD_ENTRY_FROM_SPD (Entry2);\r
-        \r
+\r
         if (SadEntry->Data->SpdEntry != NULL) {\r
           RemoveEntryList (&SadEntry->BySpd);\r
           SadEntry->Data->SpdEntry = NULL;\r
         }\r
-        \r
+\r
         if (!(SadEntry->Data->ManualSet)) {\r
           RemoveEntryList (&SadEntry->List);\r
           FreePool (SadEntry);\r
         }\r
       }\r
-      \r
+\r
       //\r
       // Free the existed SPD entry\r
       //\r
@@ -1184,7 +1184,7 @@ SetSpdEntry (
   SpdEntry->Data->PackageFlag      = SpdData->PackageFlag;\r
   SpdEntry->Data->TrafficDirection = SpdData->TrafficDirection;\r
   SpdEntry->Data->Action           = SpdData->Action;\r
-  \r
+\r
   //\r
   // Fix the address of ProcessingPolicy and copy it if need, which is continous\r
   // memory and close to the base structure of SAD data.\r
@@ -1229,9 +1229,9 @@ SetSpdEntry (
             return EFI_INVALID_PARAMETER;\r
           }\r
         }\r
-      }      \r
+      }\r
   }\r
-  \r
+\r
   //\r
   // Insert the new SPD entry.\r
   //\r
@@ -1243,17 +1243,17 @@ SetSpdEntry (
 /**\r
   Set the security association information for the EFI IPsec driver.\r
 \r
-  The IPsec configuration data has a unique selector/identifier separately to \r
+  The IPsec configuration data has a unique selector/identifier separately to\r
   identify a data entry.\r
 \r
-  @param[in]  Selector           Pointer to an entry selector on operated \r
-                                 configuration data specified by DataType. \r
-                                 A NULL Selector causes the entire specified-type \r
+  @param[in]  Selector           Pointer to an entry selector on operated\r
+                                 configuration data specified by DataType.\r
+                                 A NULL Selector causes the entire specified-type\r
                                  configuration information to be flushed.\r
-  @param[in]  Data               The data buffer to be set. The structure \r
+  @param[in]  Data               The data buffer to be set. The structure\r
                                  of the data buffer should be EFI_IPSEC_SA_DATA.\r
-  @param[in]  Context            Pointer to one entry selector which describes \r
-                                 the expected position the new data entry will \r
+  @param[in]  Context            Pointer to one entry selector which describes\r
+                                 the expected position the new data entry will\r
                                  be added. If Context is NULL,the new entry will\r
                                  be appended the end of database.\r
 \r
@@ -1279,7 +1279,7 @@ SetSadEntry (
   EFI_IPSEC_SA_ID   *InsertBefore;\r
   LIST_ENTRY        *EntryInsertBefore;\r
   UINTN             SadEntrySize;\r
-  \r
+\r
   SaId          = (Selector == NULL) ? NULL : &Selector->SaId;\r
   SaData        = (Data == NULL) ? NULL : (EFI_IPSEC_SA_DATA2 *) Data;\r
   InsertBefore  = (Context == NULL) ? NULL : &((EFI_IPSEC_CONFIG_SELECTOR *) Context)->SaId;\r
@@ -1297,7 +1297,7 @@ SetSadEntry (
 \r
     SadEntry = IPSEC_SAD_ENTRY_FROM_LIST (Entry);\r
 \r
-    if (SaId == NULL || \r
+    if (SaId == NULL ||\r
         CompareSaId (\r
           (EFI_IPSEC_CONFIG_SELECTOR *) SadEntry->Id,\r
           (EFI_IPSEC_CONFIG_SELECTOR *) SaId\r
@@ -1348,7 +1348,7 @@ SetSadEntry (
   SadEntrySize  = ALIGN_VARIABLE (sizeof (IPSEC_SAD_ENTRY));\r
   SadEntrySize  = ALIGN_VARIABLE (SadEntrySize + sizeof (EFI_IPSEC_SA_ID));\r
   SadEntrySize  = ALIGN_VARIABLE (SadEntrySize + sizeof (IPSEC_SAD_DATA));\r
-  \r
+\r
   if (SaId->Proto == EfiIPsecAH) {\r
     SadEntrySize += SaData->AlgoInfo.AhAlgoInfo.AuthKeyLength;\r
   } else {\r
@@ -1405,7 +1405,7 @@ SetSadEntry (
 \r
     if (SadEntry->Data->AlgoInfo.EspAlgoInfo.EncKeyLength != 0) {\r
       SadEntry->Data->AlgoInfo.EspAlgoInfo.EncKey = (VOID *) ALIGN_POINTER (\r
-                                                               ((UINT8 *) (SadEntry->Data + 1) + \r
+                                                               ((UINT8 *) (SadEntry->Data + 1) +\r
                                                                  SadEntry->Data->AlgoInfo.EspAlgoInfo.AuthKeyLength),\r
                                                                  sizeof (UINTN)\r
                                                                  );\r
@@ -1479,17 +1479,17 @@ SetSadEntry (
 /**\r
   Set the peer authorization configuration information for the EFI IPsec driver.\r
 \r
-  The IPsec configuration data has a unique selector/identifier separately to \r
+  The IPsec configuration data has a unique selector/identifier separately to\r
   identify a data entry.\r
 \r
-  @param[in]  Selector           Pointer to an entry selector on operated \r
-                                 configuration data specified by DataType. \r
-                                 A NULL Selector causes the entire specified-type \r
+  @param[in]  Selector           Pointer to an entry selector on operated\r
+                                 configuration data specified by DataType.\r
+                                 A NULL Selector causes the entire specified-type\r
                                  configuration information to be flushed.\r
-  @param[in]  Data               The data buffer to be set. The structure \r
+  @param[in]  Data               The data buffer to be set. The structure\r
                                  of the data buffer should be EFI_IPSEC_PAD_DATA.\r
-  @param[in]  Context            Pointer to one entry selector that describes \r
-                                 the expected position the new data entry will \r
+  @param[in]  Context            Pointer to one entry selector that describes\r
+                                 the expected position the new data entry will\r
                                  be added. If Context is NULL, the new entry will\r
                                  be appended the end of database.\r
 \r
@@ -1513,7 +1513,7 @@ SetPadEntry (
   EFI_IPSEC_PAD_ID    *InsertBefore;\r
   LIST_ENTRY          *EntryInsertBefore;\r
   UINTN               PadEntrySize;\r
-   \r
+\r
   PadId         = (Selector == NULL) ? NULL : &Selector->PadId;\r
   PadData       = (Data == NULL) ? NULL : (EFI_IPSEC_PAD_DATA *) Data;\r
   InsertBefore  = (Context == NULL) ? NULL : &((EFI_IPSEC_CONFIG_SELECTOR *) Context)->PadId;\r
@@ -1531,7 +1531,7 @@ SetPadEntry (
 \r
     PadEntry = IPSEC_PAD_ENTRY_FROM_LIST (Entry);\r
 \r
-    if (PadId == NULL || \r
+    if (PadId == NULL ||\r
         ComparePadId ((EFI_IPSEC_CONFIG_SELECTOR *) PadEntry->Id, (EFI_IPSEC_CONFIG_SELECTOR *) PadId)\r
         ) {\r
       //\r
@@ -1631,16 +1631,16 @@ SetPadEntry (
 }\r
 \r
 /**\r
-  This function lookup the data entry from IPsec SPD. Return the configuration \r
+  This function lookup the data entry from IPsec SPD. Return the configuration\r
   value of the specified SPD Entry.\r
 \r
-  @param[in]      Selector      Pointer to an entry selector which is an identifier \r
+  @param[in]      Selector      Pointer to an entry selector which is an identifier\r
                                 of the SPD entry.\r
   @param[in, out] DataSize      On output the size of data returned in Data.\r
-  @param[out]     Data          The buffer to return the contents of the IPsec \r
-                                configuration data. The type of the data buffer \r
-                                is associated with the DataType. \r
\r
+  @param[out]     Data          The buffer to return the contents of the IPsec\r
+                                configuration data. The type of the data buffer\r
+                                is associated with the DataType.\r
+\r
   @retval EFI_SUCCESS           The specified configuration data was obtained successfully.\r
   @retval EFI_INVALID_PARAMETER Data is NULL and *DataSize is not zero.\r
   @retval EFI_NOT_FOUND         The configuration data specified by Selector is not found.\r
@@ -1713,7 +1713,7 @@ GetSpdEntry (
       SpdData->PackageFlag      = SpdEntry->Data->PackageFlag;\r
       SpdData->TrafficDirection = SpdEntry->Data->TrafficDirection;\r
       SpdData->Action           = SpdEntry->Data->Action;\r
-      \r
+\r
       if (SpdData->Action != EfiIPsecActionProtect) {\r
         SpdData->ProcessingPolicy = NULL;\r
       } else {\r
@@ -1733,16 +1733,16 @@ GetSpdEntry (
 }\r
 \r
 /**\r
-  This function lookup the data entry from IPsec SAD. Return the configuration \r
+  This function lookup the data entry from IPsec SAD. Return the configuration\r
   value of the specified SAD Entry.\r
 \r
-  @param[in]      Selector      Pointer to an entry selector which is an identifier \r
+  @param[in]      Selector      Pointer to an entry selector which is an identifier\r
                                 of the SAD entry.\r
   @param[in, out] DataSize      On output, the size of data returned in Data.\r
-  @param[out]     Data          The buffer to return the contents of the IPsec \r
-                                configuration data. The type of the data buffer \r
-                                is associated with the DataType. \r
\r
+  @param[out]     Data          The buffer to return the contents of the IPsec\r
+                                configuration data. The type of the data buffer\r
+                                is associated with the DataType.\r
+\r
   @retval EFI_SUCCESS           The specified configuration data was obtained successfully.\r
   @retval EFI_NOT_FOUND         The configuration data specified by Selector is not found.\r
   @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the result. DataSize has been\r
@@ -1783,8 +1783,8 @@ GetSadEntry (
       // |EFI_IPSEC_SA_DATA\r
       // |AuthKey\r
       // |EncryptKey  (Optional)\r
-      // |SpdSelector (Optional)     \r
-      // \r
+      // |SpdSelector (Optional)\r
+      //\r
       RequiredSize  = ALIGN_VARIABLE (sizeof (EFI_IPSEC_SA_DATA2));\r
 \r
       if (SaId->Proto == EfiIPsecAH) {\r
@@ -1797,12 +1797,12 @@ GetSadEntry (
       if (SadEntry->Data->SpdSelector != NULL) {\r
         RequiredSize += SIZE_OF_SPD_SELECTOR (SadEntry->Data->SpdSelector);\r
       }\r
-      \r
+\r
       if (*DataSize < RequiredSize) {\r
         *DataSize = RequiredSize;\r
         return EFI_BUFFER_TOO_SMALL;\r
       }\r
-      \r
+\r
       //\r
       // Fill the data fields of SAD entry.\r
       //\r
@@ -1895,7 +1895,7 @@ GetSadEntry (
                                 RequiredSize -\r
                                 SIZE_OF_SPD_SELECTOR (SadEntry->Data->SpdSelector)\r
                                 );\r
-       \r
+\r
         DuplicateSpdSelector (\r
           (EFI_IPSEC_CONFIG_SELECTOR *) SaData->SpdSelector,\r
           (EFI_IPSEC_CONFIG_SELECTOR *) SadEntry->Data->SpdSelector,\r
@@ -1917,16 +1917,16 @@ GetSadEntry (
 }\r
 \r
 /**\r
-  This function lookup the data entry from IPsec PAD. Return the configuration \r
+  This function lookup the data entry from IPsec PAD. Return the configuration\r
   value of the specified PAD Entry.\r
 \r
-  @param[in]      Selector      Pointer to an entry selector which is an identifier \r
+  @param[in]      Selector      Pointer to an entry selector which is an identifier\r
                                 of the PAD entry.\r
   @param[in, out] DataSize      On output the size of data returned in Data.\r
-  @param[out]     Data          The buffer to return the contents of the IPsec \r
-                                configuration data. The type of the data buffer \r
-                                is associated with the DataType. \r
\r
+  @param[out]     Data          The buffer to return the contents of the IPsec\r
+                                configuration data. The type of the data buffer\r
+                                is associated with the DataType.\r
+\r
   @retval EFI_SUCCESS           The specified configuration data was obtained successfully.\r
   @retval EFI_NOT_FOUND         The configuration data specified by Selector is not found.\r
   @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the result. DataSize has been\r
@@ -2089,7 +2089,7 @@ IpSecGetSizeOfEfiSpdData (
 \r
 /**\r
   Calculate the a whole size of IPSEC_SPD_DATA which includes the buffer size pointed\r
-  to by the pointer members and the buffer size used by the Sa List. \r
+  to by the pointer members and the buffer size used by the Sa List.\r
 \r
   @param[in]  SpdData       Pointer to the specified IPSEC_SPD_DATA.\r
 \r
@@ -2125,25 +2125,25 @@ IpSecGetSizeOfSpdData (
   Get the IPsec Variable.\r
 \r
   Get the all variables which start with the string contained in VaraiableName.\r
-  Since all IPsec related variable store in continual space, those kinds of \r
-  variable can be searched by the EfiGetNextVariableName. Those variables also are \r
+  Since all IPsec related variable store in continual space, those kinds of\r
+  variable can be searched by the EfiGetNextVariableName. Those variables also are\r
   returned in a continual buffer.\r
-  \r
+\r
   @param[in]      VariableName          Pointer to a specified Variable Name.\r
   @param[in]      VendorGuid            Pointer to a specified Vendor Guid.\r
-  @param[in]      Attributes            Point to memory location to return the attributes \r
-                                        of variable. If the point is NULL, the parameter \r
+  @param[in]      Attributes            Point to memory location to return the attributes\r
+                                        of variable. If the point is NULL, the parameter\r
                                         would be ignored.\r
-  @param[in, out] DataSize              As input, point to the maximum size of return \r
-                                        Data-Buffer. As output, point to the actual \r
+  @param[in, out] DataSize              As input, point to the maximum size of return\r
+                                        Data-Buffer. As output, point to the actual\r
                                         size of the returned Data-Buffer.\r
   @param[in]      Data                  Point to return Data-Buffer.\r
-        \r
+\r
   @retval  EFI_ABORTED           If the Variable size which contained in the variable\r
-                                 structure doesn't match the variable size obtained \r
+                                 structure doesn't match the variable size obtained\r
                                  from the EFIGetVariable.\r
   @retval  EFI_BUFFER_TOO_SMALL  The DataSize is too small for the result. DataSize has\r
-                                 been updated with the size needed to complete the request.   \r
+                                 been updated with the size needed to complete the request.\r
   @retval  EFI_SUCCESS           The function completed successfully.\r
   @retval  others                Other errors found during the variable getting.\r
 **/\r
@@ -2179,7 +2179,7 @@ IpSecGetVariable (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto ON_EXIT;\r
   }\r
-  \r
+\r
   //\r
   // Construct the varible name of ipsecconfig meta data.\r
   //\r
@@ -2318,14 +2318,14 @@ ON_EXIT:
   @param[in]  VariableName  The name of the vendor's variable. It is a\r
                             Null-Terminated Unicode String.\r
   @param[in]  VendorGuid    Unify identifier for vendor.\r
-  @param[in]  Attributes    Point to memory location to return the attributes of \r
+  @param[in]  Attributes    Point to memory location to return the attributes of\r
                             variable. If the point is NULL, the parameter would be ignored.\r
   @param[in]  DataSize      The size in bytes of Data-Buffer.\r
   @param[in]  Data          Points to the content of the variable.\r
 \r
   @retval  EFI_SUCCESS      The firmware successfully stored the variable and its data, as\r
                             defined by the Attributes.\r
-  @retval  others           Storing the variables failed.      \r
+  @retval  others           Storing the variables failed.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -2355,7 +2355,7 @@ IpSecSetVariable (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   //\r
   // "VariableName + Info/0001/0002/... + NULL"\r
   //\r
@@ -2372,7 +2372,7 @@ IpSecSetVariable (
   //\r
   UnicodeSPrint (VariableNameI, VariableNameSize, L"%s%s", VariableName, L"Info");\r
   MaximumVariableSize -= VariableNameSize;\r
-  \r
+\r
   IpSecVariableInfo.VariableCount       = (UINT32) ((DataSize + (UINTN) MaximumVariableSize - 1) / (UINTN) MaximumVariableSize);\r
   IpSecVariableInfo.VariableSize        = (UINT32) DataSize;\r
   IpSecVariableInfo.SingleVariableSize  = (UINT32) MaximumVariableSize;\r
@@ -2397,7 +2397,7 @@ IpSecSetVariable (
     // Construct and set the variable of ipsecconfig data one by one.\r
     // The index of variable name begin from 0001, and the varaible name\r
     // likes "VariableName0001", "VaraiableName0002"....\r
-    // \r
+    //\r
     UnicodeSPrint (VariableNameI, VariableNameSize, L"%s%04d", VariableName, VariableIndex + 1);\r
     Status = gRT->SetVariable (\r
                     VariableNameI,\r
@@ -2424,20 +2424,20 @@ ON_EXIT:
 }\r
 \r
 /**\r
-  Return the configuration value for the EFI IPsec driver. \r
+  Return the configuration value for the EFI IPsec driver.\r
 \r
   This function lookup the data entry from IPsec database or IKEv2 configuration\r
   information. The expected data type and unique identification are described in\r
-  DataType and Selector parameters.        \r
+  DataType and Selector parameters.\r
 \r
   @param[in]      This          Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
   @param[in]      DataType      The type of data to retrieve.\r
-  @param[in]      Selector      Pointer to an entry selector that is an identifier of the IPsec \r
+  @param[in]      Selector      Pointer to an entry selector that is an identifier of the IPsec\r
                                 configuration data entry.\r
   @param[in, out] DataSize      On output the size of data returned in Data.\r
-  @param[out]     Data          The buffer to return the contents of the IPsec configuration data. \r
-                                The type of the data buffer associated with the DataType. \r
\r
+  @param[out]     Data          The buffer to return the contents of the IPsec configuration data.\r
+                                The type of the data buffer associated with the DataType.\r
+\r
   @retval EFI_SUCCESS           The specified configuration data was obtained successfully.\r
   @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:\r
                                 - This is NULL.\r
@@ -2477,26 +2477,26 @@ EfiIpSecConfigGetData (
 \r
 /**\r
   Set the security association, security policy and peer authorization configuration\r
-  information for the EFI IPsec driver. \r
+  information for the EFI IPsec driver.\r
 \r
   This function is used to set the IPsec configuration information of type DataType for\r
   the EFI IPsec driver.\r
   The IPsec configuration data has a unique selector/identifier separately to identify\r
   a data entry. The selector structure depends on DataType's definition.\r
   Using SetData() with a Data of NULL causes the IPsec configuration data entry identified\r
-  by DataType and Selector to be deleted.        \r
+  by DataType and Selector to be deleted.\r
 \r
   @param[in] This               Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
   @param[in] DataType           The type of data to be set.\r
-  @param[in] Selector           Pointer to an entry selector on operated configuration data \r
-                                specified by DataType. A NULL Selector causes the entire \r
+  @param[in] Selector           Pointer to an entry selector on operated configuration data\r
+                                specified by DataType. A NULL Selector causes the entire\r
                                 specified-type configuration information to be flushed.\r
-  @param[in] Data               The data buffer to be set. The structure of the data buffer is \r
+  @param[in] Data               The data buffer to be set. The structure of the data buffer is\r
                                 associated with the DataType.\r
   @param[in] InsertBefore       Pointer to one entry selector which describes the expected\r
                                 position the new data entry will be added. If InsertBefore is NULL,\r
                                 the new entry will be appended to the end of the database.\r
\r
+\r
   @retval EFI_SUCCESS           The specified configuration entry data was set successfully.\r
   @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
                                 - This is NULL.\r
@@ -2523,7 +2523,7 @@ EfiIpSecConfigSetData (
   if (DataType >= IPsecConfigDataTypeMaximum) {\r
     return EFI_UNSUPPORTED;\r
   }\r
-  \r
+\r
   Status = mSetPolicyEntry[DataType](Selector, Data, InsertBefore);\r
 \r
   if (!EFI_ERROR (Status) && !mSetBySelf) {\r
@@ -2537,30 +2537,30 @@ EfiIpSecConfigSetData (
 }\r
 \r
 /**\r
-  Enumerates the current selector for IPsec configuration data entry. \r
+  Enumerates the current selector for IPsec configuration data entry.\r
 \r
   This function is called multiple times to retrieve the entry Selector in IPsec\r
-  configuration database. On each call to GetNextSelector(), the next entry \r
+  configuration database. On each call to GetNextSelector(), the next entry\r
   Selector are retrieved into the output interface.\r
\r
-  If the entire IPsec configuration database has been iterated, the error \r
+\r
+  If the entire IPsec configuration database has been iterated, the error\r
   EFI_NOT_FOUND is returned.\r
-  If the Selector buffer is too small for the next Selector copy, an \r
-  EFI_BUFFER_TOO_SMALL error is returned, and SelectorSize is updated to reflect \r
+  If the Selector buffer is too small for the next Selector copy, an\r
+  EFI_BUFFER_TOO_SMALL error is returned, and SelectorSize is updated to reflect\r
   the size of buffer needed.\r
 \r
   On the initial call to GetNextSelector() to start the IPsec configuration database\r
-  search, a pointer to the buffer with all zero value is passed in Selector. Calls \r
-  to SetData() between calls to GetNextSelector may produce unpredictable results.         \r
+  search, a pointer to the buffer with all zero value is passed in Selector. Calls\r
+  to SetData() between calls to GetNextSelector may produce unpredictable results.\r
 \r
   @param[in]      This          Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
   @param[in]      DataType      The type of IPsec configuration data to retrieve.\r
   @param[in, out] SelectorSize  The size of the Selector buffer.\r
-  @param[in, out] Selector      On input, supplies the pointer to last Selector that was \r
+  @param[in, out] Selector      On input, supplies the pointer to last Selector that was\r
                                 returned by GetNextSelector().\r
                                 On output, returns one copy of the current entry Selector\r
-                                of a given DataType. \r
\r
+                                of a given DataType.\r
+\r
   @retval EFI_SUCCESS           The specified configuration data was obtained successfully.\r
   @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:\r
                                 - This is NULL.\r
@@ -2569,7 +2569,7 @@ EfiIpSecConfigSetData (
   @retval EFI_NOT_FOUND         The next configuration data entry was not found.\r
   @retval EFI_UNSUPPORTED       The specified DataType is not supported.\r
   @retval EFI_BUFFER_TOO_SMALL  The SelectorSize is too small for the result. This parameter\r
-                                has been updated with the size needed to complete the search \r
+                                has been updated with the size needed to complete the search\r
                                 request.\r
 \r
 **/\r
@@ -2618,14 +2618,14 @@ EfiIpSecConfigGetNextSelector (
 \r
 /**\r
   Register an event that is to be signaled whenever a configuration process on the\r
-  specified IPsec configuration information is done. \r
+  specified IPsec configuration information is done.\r
 \r
   The register function is not surpport now and always returns EFI_UNSUPPORTED.\r
-  \r
+\r
   @param[in] This               Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
   @param[in] DataType           The type of data to be registered the event for.\r
   @param[in] Event              The event to be registered.\r
\r
+\r
   @retval EFI_SUCCESS           The event is registered successfully.\r
   @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL.\r
   @retval EFI_ACCESS_DENIED     The Event is already registered for the DataType.\r
@@ -2646,16 +2646,16 @@ EfiIpSecConfigRegisterNotify (
 \r
 /**\r
   Remove the specified event that was previously registered on the specified IPsec\r
-  configuration data. \r
+  configuration data.\r
 \r
   This function is not support now and alwasy return EFI_UNSUPPORTED.\r
 \r
   @param[in] This               Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
   @param[in] DataType           The configuration data type to remove the registered event for.\r
   @param[in] Event              The event to be unregistered.\r
\r
+\r
   @retval EFI_SUCCESS           The event was removed successfully.\r
-  @retval EFI_NOT_FOUND         The Event specified by DataType could not be found in the \r
+  @retval EFI_NOT_FOUND         The Event specified by DataType could not be found in the\r
                                 database.\r
   @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL.\r
   @retval EFI_UNSUPPORTED       The notify registration is unsupported, or the specified\r
@@ -2677,10 +2677,10 @@ EfiIpSecConfigUnregisterNotify (
   Copy whole data in specified EFI_SIPEC_CONFIG_SELECTOR and the Data to a buffer.\r
 \r
   This function is a caller defined function, and it is called by the IpSecVisitConfigData().\r
-  The orignal caller is IpSecConfigSave(), which calls the IpsecVisitConfigData() to \r
+  The orignal caller is IpSecConfigSave(), which calls the IpsecVisitConfigData() to\r
   copy all types of IPsec Config datas into one buffer and store this buffer into firmware in\r
   the form of several variables.\r
-  \r
+\r
   @param[in]      Type              A specified IPSEC_CONFIG_DATA_TYPE.\r
   @param[in]      Selector          Points to a EFI_IPSEC_CONFIG_SELECTOR to be copied\r
                                     to the buffer.\r
@@ -2708,7 +2708,7 @@ IpSecCopyPolicyEntry (
   IPSEC_VAR_ITEM_HEADER DataHeader;\r
   UINTN                 EntrySize;\r
   UINT8                 *TempPoint;\r
-  \r
+\r
   if (Type == IPsecConfigDataTypeSad) {\r
     //\r
     // Don't save automatically-generated SA entry into variable.\r
@@ -2724,7 +2724,7 @@ IpSecCopyPolicyEntry (
   EntrySize  = ALIGN_VARIABLE (EntrySize + SelectorSize);\r
   EntrySize  = ALIGN_VARIABLE (EntrySize + sizeof (SelectorHeader));\r
   EntrySize  = ALIGN_VARIABLE (EntrySize + DataSize);\r
-  \r
+\r
   //EntrySize = SelectorSize + DataSize + 2 * sizeof (SelectorHeader);\r
   if (Buffer->Capacity - Buffer->Size < EntrySize) {\r
     //\r
@@ -2732,7 +2732,7 @@ IpSecCopyPolicyEntry (
     //\r
     Buffer->Capacity += EntrySize;\r
     TempPoint         = AllocatePool (Buffer->Capacity);\r
-    \r
+\r
     if (TempPoint == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
@@ -2741,8 +2741,8 @@ IpSecCopyPolicyEntry (
     //\r
     CopyMem (TempPoint, Buffer->Ptr, Buffer->Size);\r
     FreePool (Buffer->Ptr);\r
-    \r
-    Buffer->Ptr       =  TempPoint;    \r
+\r
+    Buffer->Ptr       =  TempPoint;\r
   }\r
 \r
   mFixPolicyEntry[Type](Selector, Data);\r
@@ -2759,7 +2759,7 @@ IpSecCopyPolicyEntry (
     sizeof (SelectorHeader)\r
     );\r
   Buffer->Size  = ALIGN_VARIABLE (Buffer->Size + sizeof (SelectorHeader));\r
-  \r
+\r
   //\r
   // Copy the selector into buffer.\r
   //\r
@@ -2791,7 +2791,7 @@ IpSecCopyPolicyEntry (
     DataSize\r
     );\r
   Buffer->Size  = ALIGN_VARIABLE (Buffer->Size + DataSize);\r
-  \r
+\r
   mUnfixPolicyEntry[Type](Selector, Data);\r
 \r
   return EFI_SUCCESS;\r
@@ -3002,7 +3002,7 @@ IpSecConfigSave (
   Get the all IPSec configuration variables and store those variables\r
   to the internal data structure.\r
 \r
-  This founction is called by IpSecConfigInitialize() which is to intialize the \r
+  This founction is called by IpSecConfigInitialize() which is to intialize the\r
   IPsecConfiguration Protocol.\r
 \r
   @param[in]  Private            Point to IPSEC_PRIVATE_DATA.\r
@@ -3080,10 +3080,10 @@ IpSecConfigRestore (
       Header  = (IPSEC_VAR_ITEM_HEADER *) Ptr;\r
       Type    = (EFI_IPSEC_CONFIG_DATA_TYPE) (Header->Type & IPSEC_VAR_ITEM_HEADER_CONTENT_BIT);\r
       ASSERT (((Header->Type & 0x80) == IPSEC_VAR_ITEM_HEADER_LOGO_BIT) && (Type < IPsecConfigDataTypeMaximum));\r
-      \r
+\r
       Selector  = (EFI_IPSEC_CONFIG_SELECTOR *) ALIGN_POINTER (Header + 1, sizeof (UINTN));\r
       Header    = (IPSEC_VAR_ITEM_HEADER *) ALIGN_POINTER (\r
-                                              (UINT8 *) Selector + Header->Size, \r
+                                              (UINT8 *) Selector + Header->Size,\r
                                               sizeof (UINTN)\r
                                               );\r
       ASSERT (Header->Type == Type);\r