]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Application/IpsecConfig/Delete.c
NetworkPkg/IpsecConfig: remove module-local ARRAY_SIZE macro
[mirror_edk2.git] / NetworkPkg / Application / IpsecConfig / Delete.c
CommitLineData
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
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "IpSecConfig.h"\r
17#include "Indexer.h"\r
18#include "Delete.h"\r
19#include "Match.h"\r
20#include "ForEach.h"\r
21\r
22/**\r
23 Private function to delete entry information in database.\r
24\r
25 @param[in] Selector The pointer to EFI_IPSEC_CONFIG_SELECTOR structure.\r
26 @param[in] Data The pointer to Data.\r
27 @param[in] Context The pointer to DELETE_POLICY_ENTRY_CONTEXT.\r
28\r
29 @retval EFI_ABORTED Abort the iteration.\r
30 @retval EFI_SUCCESS Continue the iteration.\r
31**/\r
32EFI_STATUS\r
33DeletePolicyEntry (\r
34 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
35 IN VOID *Data,\r
36 IN DELETE_POLICY_ENTRY_CONTEXT *Context\r
37 )\r
38{\r
39 if (mMatchPolicyEntry[Context->DataType] (Selector, Data, &Context->Indexer)) {\r
40 Context->Status = mIpSecConfig->SetData (\r
41 mIpSecConfig,\r
42 Context->DataType,\r
43 Selector,\r
44 NULL,\r
45 NULL\r
46 );\r
47 //\r
48 // Abort the iteration after the insertion.\r
49 //\r
50 return EFI_ABORTED;\r
51 }\r
52\r
53 return EFI_SUCCESS;\r
54}\r
55\r
56/**\r
57 Flush or delete entry information in the database according to datatype.\r
58\r
59 @param[in] DataType The value of EFI_IPSEC_CONFIG_DATA_TYPE.\r
60 @param[in] ParamPackage The pointer to the ParamPackage list.\r
61\r
62 @retval EFI_SUCCESS Delete entry information successfully.\r
63 @retval EFI_NOT_FOUND Can't find the specified entry.\r
64 @retval Others Some mistaken case.\r
65**/\r
66EFI_STATUS\r
67FlushOrDeletePolicyEntry (\r
68 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
69 IN LIST_ENTRY *ParamPackage\r
70 )\r
71{\r
72 EFI_STATUS Status;\r
73 DELETE_POLICY_ENTRY_CONTEXT Context;\r
74 CONST CHAR16 *ValueStr;\r
75\r
76 //\r
77 // If user wants to remove all.\r
78 //\r
79 if (ShellCommandLineGetFlag (ParamPackage, L"-f")) {\r
80 Status = mIpSecConfig->SetData (\r
81 mIpSecConfig,\r
82 DataType,\r
83 NULL,\r
84 NULL,\r
85 NULL\r
86 );\r
87 } else {\r
88 ValueStr = ShellCommandLineGetValue (ParamPackage, L"-d");\r
89 if (ValueStr == NULL) {\r
90 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_INDEX_NOT_SPECIFIED), mHiiHandle, mAppName, ValueStr);\r
91 return EFI_NOT_FOUND;\r
92 }\r
93\r
94 Status = mConstructPolicyEntryIndexer[DataType] (&Context.Indexer, ParamPackage);\r
95 if (!EFI_ERROR (Status)) {\r
96 Context.DataType = DataType;\r
97 Context.Status = EFI_NOT_FOUND;\r
98 ForeachPolicyEntry (DataType, (VISIT_POLICY_ENTRY) DeletePolicyEntry, &Context);\r
99 Status = Context.Status;\r
100\r
101 if (Status == EFI_NOT_FOUND) {\r
102 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_INDEX_NOT_FOUND), mHiiHandle, mAppName, ValueStr);\r
103 } else if (EFI_ERROR (Status)) {\r
104 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_DELETE_FAILED), mHiiHandle, mAppName);\r
105 }\r
106 }\r
107 }\r
108\r
109 return Status;\r
110}\r