2 The implementation of match policy entry function in IpSecConfig application.
4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "IpSecConfig.h"
15 Private function to validate a buffer that should be filled with zero.
17 @param[in] Memory The pointer to the buffer.
18 @param[in] Size The size of the buffer.
20 @retval TRUE The memory is filled with zero.
21 @retval FALSE The memory isn't filled with zero.
31 for (Index
= 0; Index
< Size
; Index
++) {
32 if (*((UINT8
*) Memory
+ Index
) != 0) {
41 Find the matching SPD with Indexer.
43 @param[in] Selector The pointer to the EFI_IPSEC_SPD_SELECTOR structure.
44 @param[in] Data The pointer to the EFI_IPSEC_SPD_DATA structure.
45 @param[in] Indexer The pointer to the SPD_ENTRY_INDEXER structure.
47 @retval TRUE The matched SPD is found.
48 @retval FALSE The matched SPD is not found.
52 IN EFI_IPSEC_SPD_SELECTOR
*Selector
,
53 IN EFI_IPSEC_SPD_DATA
*Data
,
54 IN SPD_ENTRY_INDEXER
*Indexer
60 if (!IsMemoryZero (Indexer
->Name
, MAX_PEERID_LEN
)) {
61 if ((Data
->Name
!= NULL
) && (AsciiStrCmp ((CHAR8
*) Indexer
->Name
, (CHAR8
*) Data
->Name
) == 0)) {
65 if (Indexer
->Index
== 0) {
76 Find the matching SAD with Indexer.
78 @param[in] SaId The pointer to the EFI_IPSEC_SA_ID structure.
79 @param[in] Data The pointer to the EFI_IPSEC_SA_DATA2 structure.
80 @param[in] Indexer The pointer to the SPD_ENTRY_INDEXER structure.
82 @retval TRUE The matched SAD is found.
83 @retval FALSE The matched SAD is not found.
87 IN EFI_IPSEC_SA_ID
*SaId
,
88 IN EFI_IPSEC_SA_DATA2
*Data
,
89 IN SAD_ENTRY_INDEXER
*Indexer
95 if (!IsMemoryZero (&Indexer
->SaId
, sizeof (EFI_IPSEC_SA_ID
))) {
96 Match
= (BOOLEAN
) (CompareMem (&Indexer
->SaId
, SaId
, sizeof (EFI_IPSEC_SA_ID
)) == 0);
98 if (Indexer
->Index
== 0) {
108 Find the matching PAD with Indexer.
110 @param[in] PadId The pointer to the EFI_IPSEC_PAD_ID structure.
111 @param[in] Data The pointer to the EFI_IPSEC_PAD_DATA structure.
112 @param[in] Indexer The pointer to the SPD_ENTRY_INDEXER structure.
114 @retval TRUE The matched PAD is found.
115 @retval FALSE The matched PAD is not found.
119 IN EFI_IPSEC_PAD_ID
*PadId
,
120 IN EFI_IPSEC_PAD_DATA
*Data
,
121 IN PAD_ENTRY_INDEXER
*Indexer
127 if (!IsMemoryZero (&Indexer
->PadId
, sizeof (EFI_IPSEC_PAD_ID
))) {
128 Match
= (BOOLEAN
) ((Indexer
->PadId
.PeerIdValid
== PadId
->PeerIdValid
) &&
129 ((PadId
->PeerIdValid
&&
131 (CONST CHAR16
*) Indexer
->PadId
.Id
.PeerId
,
132 (CONST CHAR16
*) PadId
->Id
.PeerId
134 ((!PadId
->PeerIdValid
) &&
135 (Indexer
->PadId
.Id
.IpAddress
.PrefixLength
== PadId
->Id
.IpAddress
.PrefixLength
) &&
137 &Indexer
->PadId
.Id
.IpAddress
.Address
,
138 &PadId
->Id
.IpAddress
.Address
,
139 sizeof (EFI_IP_ADDRESS
)
142 if (Indexer
->Index
== 0) {
152 MATCH_POLICY_ENTRY mMatchPolicyEntry
[] = {
153 (MATCH_POLICY_ENTRY
) MatchSpdEntry
,
154 (MATCH_POLICY_ENTRY
) MatchSadEntry
,
155 (MATCH_POLICY_ENTRY
) MatchPadEntry