]>
Commit | Line | Data |
---|---|---|
a3bcde70 HT |
1 | /** @file\r |
2 | The implementation of delete policy entry function in IpSecConfig application.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
ecf98fbc | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a3bcde70 HT |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include "IpSecConfig.h"\r | |
11 | #include "Indexer.h"\r | |
12 | #include "Delete.h"\r | |
13 | #include "Match.h"\r | |
14 | #include "ForEach.h"\r | |
15 | \r | |
16 | /**\r | |
17 | Private function to delete entry information in database.\r | |
18 | \r | |
19 | @param[in] Selector The pointer to EFI_IPSEC_CONFIG_SELECTOR structure.\r | |
20 | @param[in] Data The pointer to Data.\r | |
21 | @param[in] Context The pointer to DELETE_POLICY_ENTRY_CONTEXT.\r | |
22 | \r | |
23 | @retval EFI_ABORTED Abort the iteration.\r | |
24 | @retval EFI_SUCCESS Continue the iteration.\r | |
25 | **/\r | |
26 | EFI_STATUS\r | |
27 | DeletePolicyEntry (\r | |
28 | IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r | |
29 | IN VOID *Data,\r | |
30 | IN DELETE_POLICY_ENTRY_CONTEXT *Context\r | |
31 | )\r | |
32 | {\r | |
33 | if (mMatchPolicyEntry[Context->DataType] (Selector, Data, &Context->Indexer)) {\r | |
34 | Context->Status = mIpSecConfig->SetData (\r | |
35 | mIpSecConfig,\r | |
36 | Context->DataType,\r | |
37 | Selector,\r | |
38 | NULL,\r | |
39 | NULL\r | |
40 | );\r | |
41 | //\r | |
42 | // Abort the iteration after the insertion.\r | |
43 | //\r | |
44 | return EFI_ABORTED;\r | |
45 | }\r | |
46 | \r | |
47 | return EFI_SUCCESS;\r | |
48 | }\r | |
49 | \r | |
50 | /**\r | |
51 | Flush or delete entry information in the database according to datatype.\r | |
52 | \r | |
53 | @param[in] DataType The value of EFI_IPSEC_CONFIG_DATA_TYPE.\r | |
54 | @param[in] ParamPackage The pointer to the ParamPackage list.\r | |
55 | \r | |
56 | @retval EFI_SUCCESS Delete entry information successfully.\r | |
57 | @retval EFI_NOT_FOUND Can't find the specified entry.\r | |
58 | @retval Others Some mistaken case.\r | |
59 | **/\r | |
60 | EFI_STATUS\r | |
61 | FlushOrDeletePolicyEntry (\r | |
62 | IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r | |
63 | IN LIST_ENTRY *ParamPackage\r | |
64 | )\r | |
65 | {\r | |
66 | EFI_STATUS Status;\r | |
67 | DELETE_POLICY_ENTRY_CONTEXT Context;\r | |
68 | CONST CHAR16 *ValueStr;\r | |
69 | \r | |
70 | //\r | |
71 | // If user wants to remove all.\r | |
72 | //\r | |
73 | if (ShellCommandLineGetFlag (ParamPackage, L"-f")) {\r | |
74 | Status = mIpSecConfig->SetData (\r | |
75 | mIpSecConfig,\r | |
76 | DataType,\r | |
77 | NULL,\r | |
78 | NULL,\r | |
79 | NULL\r | |
80 | );\r | |
81 | } else {\r | |
82 | ValueStr = ShellCommandLineGetValue (ParamPackage, L"-d");\r | |
83 | if (ValueStr == NULL) {\r | |
84 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_INDEX_NOT_SPECIFIED), mHiiHandle, mAppName, ValueStr);\r | |
85 | return EFI_NOT_FOUND;\r | |
86 | }\r | |
87 | \r | |
88 | Status = mConstructPolicyEntryIndexer[DataType] (&Context.Indexer, ParamPackage);\r | |
89 | if (!EFI_ERROR (Status)) {\r | |
90 | Context.DataType = DataType;\r | |
91 | Context.Status = EFI_NOT_FOUND;\r | |
92 | ForeachPolicyEntry (DataType, (VISIT_POLICY_ENTRY) DeletePolicyEntry, &Context);\r | |
93 | Status = Context.Status;\r | |
94 | \r | |
95 | if (Status == EFI_NOT_FOUND) {\r | |
96 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_INDEX_NOT_FOUND), mHiiHandle, mAppName, ValueStr);\r | |
97 | } else if (EFI_ERROR (Status)) {\r | |
98 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_DELETE_FAILED), mHiiHandle, mAppName);\r | |
99 | }\r | |
100 | }\r | |
101 | }\r | |
102 | \r | |
103 | return Status;\r | |
104 | }\r |