EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

NetworkPkg/Application/IpsecConfig/Match.c

Go to the documentation of this file.
00001 
00016 #include "IpSecConfig.h"
00017 #include "Indexer.h"
00018 #include "Match.h"
00019 
00029 BOOLEAN
00030 IsMemoryZero (
00031   IN VOID     *Memory,
00032   IN UINTN    Size
00033   )
00034 {
00035   UINTN    Index;
00036 
00037   for (Index = 0; Index < Size; Index++) {
00038     if (*((UINT8 *) Memory + Index) != 0) {
00039       return FALSE;
00040     }
00041   }
00042 
00043   return TRUE;
00044 }
00045 
00056 BOOLEAN
00057 MatchSpdEntry (
00058   IN EFI_IPSEC_SPD_SELECTOR    *Selector,
00059   IN EFI_IPSEC_SPD_DATA        *Data,
00060   IN SPD_ENTRY_INDEXER         *Indexer
00061   )
00062 {
00063   BOOLEAN    Match;
00064 
00065   Match = FALSE;
00066   if (Indexer->Name != NULL) {
00067     if ((Data->Name != NULL) && (AsciiStrCmp ((CHAR8 *) Indexer->Name, (CHAR8 *) Data->Name) == 0)) {
00068       Match = TRUE;
00069     }
00070   } else {
00071     if (Indexer->Index == 0) {
00072       Match = TRUE;
00073     }
00074 
00075     Indexer->Index--;
00076   }
00077 
00078   return Match;
00079 }
00080 
00091 BOOLEAN
00092 MatchSadEntry (
00093   IN EFI_IPSEC_SA_ID      *SaId,
00094   IN EFI_IPSEC_SA_DATA2   *Data,
00095   IN SAD_ENTRY_INDEXER    *Indexer
00096   )
00097 {
00098   BOOLEAN    Match;
00099 
00100   Match = FALSE;
00101   if (!IsMemoryZero (&Indexer->SaId, sizeof (EFI_IPSEC_SA_ID))) {
00102     Match = (BOOLEAN) (CompareMem (&Indexer->SaId, SaId, sizeof (EFI_IPSEC_SA_ID)) == 0);
00103   } else {
00104     if (Indexer->Index == 0) {
00105       Match = TRUE;
00106     }
00107     Indexer->Index--;
00108   }
00109 
00110   return Match;
00111 }
00112 
00123 BOOLEAN
00124 MatchPadEntry (
00125   IN EFI_IPSEC_PAD_ID      *PadId,
00126   IN EFI_IPSEC_PAD_DATA    *Data,
00127   IN PAD_ENTRY_INDEXER     *Indexer
00128   )
00129 {
00130   BOOLEAN                       Match;
00131 
00132   Match = FALSE;
00133   if (!IsMemoryZero (&Indexer->PadId, sizeof (EFI_IPSEC_PAD_ID))) {
00134     Match = (BOOLEAN) ((Indexer->PadId.PeerIdValid == PadId->PeerIdValid) &&
00135                        ((PadId->PeerIdValid &&
00136                          (StrCmp (
00137                             (CONST CHAR16 *) Indexer->PadId.Id.PeerId,
00138                             (CONST CHAR16 *) PadId->Id.PeerId
00139                             ) == 0)) ||
00140                         ((!PadId->PeerIdValid) &&
00141                          (Indexer->PadId.Id.IpAddress.PrefixLength == PadId->Id.IpAddress.PrefixLength) &&
00142                          (CompareMem (
00143                             &Indexer->PadId.Id.IpAddress.Address,
00144                             &PadId->Id.IpAddress.Address,
00145                             sizeof (EFI_IP_ADDRESS)
00146                             ) == 0))));
00147   } else {
00148     if (Indexer->Index == 0) {
00149       Match = TRUE;
00150     }
00151 
00152     Indexer->Index--;
00153   }
00154 
00155   return Match;
00156 }
00157 
00158 MATCH_POLICY_ENTRY mMatchPolicyEntry[] = {
00159   (MATCH_POLICY_ENTRY) MatchSpdEntry,
00160   (MATCH_POLICY_ENTRY) MatchSadEntry,
00161   (MATCH_POLICY_ENTRY) MatchPadEntry
00162 };
00163 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines