2 The implementation of delete policy entry function in IpSecConfig application.
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "IpSecConfig.h"
17 Private function to delete entry information in database.
19 @param[in] Selector The pointer to EFI_IPSEC_CONFIG_SELECTOR structure.
20 @param[in] Data The pointer to Data.
21 @param[in] Context The pointer to DELETE_POLICY_ENTRY_CONTEXT.
23 @retval EFI_ABORTED Abort the iteration.
24 @retval EFI_SUCCESS Continue the iteration.
28 IN EFI_IPSEC_CONFIG_SELECTOR
*Selector
,
30 IN DELETE_POLICY_ENTRY_CONTEXT
*Context
33 if (mMatchPolicyEntry
[Context
->DataType
] (Selector
, Data
, &Context
->Indexer
)) {
34 Context
->Status
= mIpSecConfig
->SetData (
42 // Abort the iteration after the insertion.
51 Flush or delete entry information in the database according to datatype.
53 @param[in] DataType The value of EFI_IPSEC_CONFIG_DATA_TYPE.
54 @param[in] ParamPackage The pointer to the ParamPackage list.
56 @retval EFI_SUCCESS Delete entry information successfully.
57 @retval EFI_NOT_FOUND Can't find the specified entry.
58 @retval Others Some mistaken case.
61 FlushOrDeletePolicyEntry (
62 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType
,
63 IN LIST_ENTRY
*ParamPackage
67 DELETE_POLICY_ENTRY_CONTEXT Context
;
68 CONST CHAR16
*ValueStr
;
71 // If user wants to remove all.
73 if (ShellCommandLineGetFlag (ParamPackage
, L
"-f")) {
74 Status
= mIpSecConfig
->SetData (
82 ValueStr
= ShellCommandLineGetValue (ParamPackage
, L
"-d");
83 if (ValueStr
== NULL
) {
84 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IPSEC_CONFIG_INDEX_NOT_SPECIFIED
), mHiiHandle
, mAppName
, ValueStr
);
88 Status
= mConstructPolicyEntryIndexer
[DataType
] (&Context
.Indexer
, ParamPackage
);
89 if (!EFI_ERROR (Status
)) {
90 Context
.DataType
= DataType
;
91 Context
.Status
= EFI_NOT_FOUND
;
92 ForeachPolicyEntry (DataType
, (VISIT_POLICY_ENTRY
) DeletePolicyEntry
, &Context
);
93 Status
= Context
.Status
;
95 if (Status
== EFI_NOT_FOUND
) {
96 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IPSEC_CONFIG_INDEX_NOT_FOUND
), mHiiHandle
, mAppName
, ValueStr
);
97 } else if (EFI_ERROR (Status
)) {
98 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_IPSEC_CONFIG_DELETE_FAILED
), mHiiHandle
, mAppName
);