]>
Commit | Line | Data |
---|---|---|
a3bcde70 HT |
1 | /** @file\r |
2 | The implementation to go through each entry 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 "ForEach.h"\r | |
12 | \r | |
13 | \r | |
14 | /**\r | |
15 | Enumerate all entries in the database to execute specified operations according to datatype.\r | |
16 | \r | |
17 | @param[in] DataType The value of EFI_IPSEC_CONFIG_DATA_TYPE.\r | |
18 | @param[in] Routine The pointer to the function of a specified operation.\r | |
19 | @param[in] Context The pointer to the context of a function.\r | |
20 | \r | |
21 | @retval EFI_SUCCESS Execute specified operation successfully.\r | |
22 | **/\r | |
23 | EFI_STATUS\r | |
24 | ForeachPolicyEntry (\r | |
25 | IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r | |
26 | IN VISIT_POLICY_ENTRY Routine,\r | |
27 | IN VOID *Context\r | |
28 | )\r | |
29 | {\r | |
30 | EFI_STATUS GetNextStatus;\r | |
31 | EFI_STATUS GetDataStatus;\r | |
32 | EFI_IPSEC_CONFIG_SELECTOR *Selector;\r | |
33 | VOID *Data;\r | |
34 | UINTN SelectorSize;\r | |
35 | UINTN DataSize;\r | |
36 | BOOLEAN FirstGetNext;\r | |
37 | \r | |
38 | FirstGetNext = TRUE;\r | |
39 | SelectorSize = sizeof (EFI_IPSEC_CONFIG_SELECTOR);\r | |
40 | Selector = AllocateZeroPool (SelectorSize);\r | |
41 | \r | |
42 | DataSize = 0;\r | |
43 | Data = NULL;\r | |
44 | \r | |
45 | while (TRUE) {\r | |
46 | GetNextStatus = mIpSecConfig->GetNextSelector (\r | |
47 | mIpSecConfig,\r | |
48 | DataType,\r | |
49 | &SelectorSize,\r | |
50 | Selector\r | |
51 | );\r | |
52 | if (GetNextStatus == EFI_BUFFER_TOO_SMALL) {\r | |
53 | gBS->FreePool (Selector);\r | |
54 | Selector = FirstGetNext ? AllocateZeroPool (SelectorSize) : AllocatePool (SelectorSize);\r | |
55 | \r | |
56 | GetNextStatus = mIpSecConfig->GetNextSelector (\r | |
57 | mIpSecConfig,\r | |
58 | DataType,\r | |
59 | &SelectorSize,\r | |
60 | Selector\r | |
61 | );\r | |
62 | }\r | |
63 | \r | |
64 | if (EFI_ERROR (GetNextStatus)) {\r | |
65 | break;\r | |
66 | }\r | |
67 | \r | |
68 | FirstGetNext = FALSE;\r | |
69 | \r | |
70 | GetDataStatus = mIpSecConfig->GetData (\r | |
71 | mIpSecConfig,\r | |
72 | DataType,\r | |
73 | Selector,\r | |
74 | &DataSize,\r | |
75 | Data\r | |
76 | );\r | |
77 | if (GetDataStatus == EFI_BUFFER_TOO_SMALL) {\r | |
78 | if (Data != NULL) {\r | |
79 | gBS->FreePool (Data);\r | |
80 | }\r | |
81 | \r | |
82 | Data = AllocateZeroPool (DataSize);\r | |
83 | GetDataStatus = mIpSecConfig->GetData (\r | |
84 | mIpSecConfig,\r | |
85 | DataType,\r | |
86 | Selector,\r | |
87 | &DataSize,\r | |
88 | Data\r | |
89 | );\r | |
90 | }\r | |
91 | \r | |
92 | ASSERT_EFI_ERROR (GetDataStatus);\r | |
93 | \r | |
94 | if (EFI_ERROR (Routine (Selector, Data, Context))) {\r | |
95 | break;\r | |
96 | }\r | |
97 | }\r | |
98 | \r | |
99 | if (Data != NULL) {\r | |
100 | gBS->FreePool (Data);\r | |
101 | }\r | |
102 | \r | |
103 | if (Selector != NULL) {\r | |
104 | gBS->FreePool (Selector);\r | |
105 | }\r | |
106 | \r | |
107 | return EFI_SUCCESS;\r | |
108 | }\r | |
109 | \r |