]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/IpSecDxe/IpSecConfigImpl.h
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IpSecConfigImpl.h
CommitLineData
a3bcde70
HT
1/** @file\r
2 Definitions related to IPSEC_CONFIG_PROTOCOL implementations.\r
3\r
76389e18 4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
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#ifndef _IPSEC_CONFIG_IMPL_H_\r
17#define _IPSEC_CONFIG_IMPL_H_\r
18\r
19#include <Protocol/IpSec.h>\r
20#include <Protocol/IpSecConfig.h>\r
21\r
22#include <Library/BaseLib.h>\r
23#include <Library/BaseMemoryLib.h>\r
24#include <Library/PrintLib.h>\r
25#include <Library/MemoryAllocationLib.h>\r
26#include <Library/UefiRuntimeServicesTableLib.h>\r
27#include <Library/UefiBootServicesTableLib.h>\r
28#include <Library/DebugLib.h>\r
29\r
30#include "IpSecImpl.h"\r
31\r
32#define EFI_IPSEC_ANY_PROTOCOL 0xFFFF\r
33#define EFI_IPSEC_ANY_PORT 0\r
34\r
35#define IPSEC_VAR_ITEM_HEADER_LOGO_BIT 0x80\r
36#define IPSEC_VAR_ITEM_HEADER_CONTENT_BIT 0x7F\r
37\r
38#define IPSECCONFIG_VARIABLE_NAME L"IpSecConfig"\r
39#define IPSECCONFIG_STATUS_NAME L"IpSecStatus"\r
40\r
41#define SIZE_OF_SPD_SELECTOR(x) (UINTN) (sizeof (EFI_IPSEC_SPD_SELECTOR) \\r
42 + sizeof (EFI_IP_ADDRESS_INFO) * ((x)->LocalAddressCount + (x)->RemoteAddressCount))\r
43\r
44#define FIX_REF_BUF_ADDR(addr, base) addr = (VOID *) ((UINTN) (addr) - (UINTN) (base))\r
45#define UNFIX_REF_BUF_ADDR(addr, base) addr = (VOID *) ((UINTN) (addr) + (UINTN) (base))\r
46\r
47//\r
48// The data structure used to store the genernall information of IPsec configuration.\r
49//\r
50typedef struct {\r
51 UINT32 VariableCount; // the total number of the IPsecConfig variables.\r
52 UINT32 VariableSize; // The total size of all IpsecConfig variables.\r
53 UINT32 SingleVariableSize; // The max size of single variable\r
54} IP_SEC_VARIABLE_INFO;\r
55\r
56typedef struct {\r
57 EFI_IPSEC_CONFIG_SELECTOR *Selector;\r
58 VOID *Data;\r
59 LIST_ENTRY List;\r
60} IPSEC_COMMON_POLICY_ENTRY;\r
61\r
62typedef struct {\r
63 UINT8 *Ptr;\r
64 UINTN Size;\r
65 UINTN Capacity;\r
66} IPSEC_VARIABLE_BUFFER;\r
67\r
68#pragma pack(1)\r
69typedef struct {\r
70 UINT8 Type;\r
71 UINT16 Size;\r
72} IPSEC_VAR_ITEM_HEADER;\r
73#pragma pack()\r
74\r
75/**\r
76 The prototype of Copy Source Selector to the Destination Selector.\r
77\r
76389e18 78 @param[in, out] DstSel Pointer of Destination Selector. It would be\r
a3bcde70
HT
79 SPD Selector, or SAD Selector or PAD Selector.\r
80 @param[in] SrcSel Pointer of Source Selector. It would be\r
81 SPD Selector, or SAD Selector or PAD Selector.\r
76389e18 82 @param[in, out] Size The size of the Destination Selector. If it\r
a3bcde70
HT
83 is not NULL and its value is less than the size of\r
84 Source Selector, the value of Source Selector's\r
85 size will be passed to the caller by this parameter.\r
86\r
87 @retval EFI_INVALID_PARAMETER If the Destination or Source Selector is NULL.\r
88 @retval EFI_BUFFER_TOO_SMALL If the input Size is less than size of Source Selector.\r
89 @retval EFI_SUCCESS Copy Source Selector to the Destination\r
90 Selector successfully.\r
91\r
92**/\r
93typedef\r
94EFI_STATUS\r
95(*IPSEC_DUPLICATE_SELECTOR) (\r
96 IN OUT EFI_IPSEC_CONFIG_SELECTOR *DstSel,\r
97 IN EFI_IPSEC_CONFIG_SELECTOR *SrcSel,\r
98 IN OUT UINTN *Size\r
99 );\r
100\r
101/**\r
102 It is prototype of compare two Selectors. The Selector would be SPD Selector,\r
103 or SAD Selector, or PAD selector.\r
104\r
105 @param[in] Selector1 Pointer of the first Selector.\r
106 @param[in] Selector2 Pointer of the second Selector.\r
107\r
108 @retval TRUE These two Selectors have the same value in certain fields.\r
109 @retval FALSE Not all fields have the same value in these two Selectors.\r
110\r
111**/\r
112typedef\r
113BOOLEAN\r
114(*IPSEC_COMPARE_SELECTOR) (\r
115 IN EFI_IPSEC_CONFIG_SELECTOR *Selector1,\r
116 IN EFI_IPSEC_CONFIG_SELECTOR *Selector2\r
117 );\r
118\r
119/**\r
120 The prototype of a function to check if the Selector is Zero by its certain fields.\r
121\r
122 @param[in] Selector Pointer of the Selector.\r
123\r
124 @retval TRUE If the Selector is Zero.\r
125 @retval FALSE If the Selector is not Zero.\r
126\r
127**/\r
128typedef\r
129BOOLEAN\r
130(*IPSEC_IS_ZERO_SELECTOR) (\r
131 IN EFI_IPSEC_CONFIG_SELECTOR *Selector\r
132 );\r
133\r
134/**\r
135 The prototype of a function to fix the value of particular members of the Selector.\r
136\r
137 @param[in] Selector Pointer of Selector.\r
138 @param[in] Data Pointer of Data.\r
139\r
140**/\r
141typedef\r
142VOID\r
143(*IPSEC_FIX_POLICY_ENTRY) (\r
144 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
145 IN VOID *Data\r
146 );\r
147\r
148/**\r
149 It is prototype function to define a routine function by the caller of IpSecVisitConfigData().\r
150\r
151 @param[in] Type A specified IPSEC_CONFIG_DATA_TYPE.\r
152 @param[in] Selector Points to EFI_IPSEC_CONFIG_SELECTOR to be copied\r
153 to the buffer.\r
154 @param[in] Data Points to data to be copied to the buffer. The\r
155 Data type is related to the Type.\r
156 @param[in] SelectorSize The size of the Selector.\r
157 @param[in] DataSize The size of the Data.\r
76389e18 158 @param[in, out] Buffer The buffer to store the Selector and Data.\r
a3bcde70
HT
159\r
160 @retval EFI_SUCCESS Copied the Selector and Data to a buffer successfully.\r
161 @retval EFI_OUT_OF_RESOURCES The required system resource could not be allocated.\r
162\r
163**/\r
164typedef\r
165EFI_STATUS\r
166(*IPSEC_COPY_POLICY_ENTRY) (\r
167 IN EFI_IPSEC_CONFIG_DATA_TYPE Type,\r
168 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
169 IN VOID *Data,\r
170 IN UINTN SelectorSize,\r
171 IN UINTN DataSize,\r
172 IN OUT VOID *Context\r
173 );\r
174\r
175/**\r
176 Set the security policy information for the EFI IPsec driver.\r
177\r
178 The IPsec configuration data has a unique selector/identifier separately to\r
179 identify a data entry.\r
180\r
181 @param[in] Selector Pointer to an entry selector on operated\r
182 configuration data specified by DataType.\r
183 A NULL Selector causes the entire specified-type\r
184 configuration information to be flushed.\r
185 @param[in] Data The data buffer to be set.\r
186 @param[in] Context Pointer to one entry selector that describes\r
187 the expected position the new data entry will\r
188 be added. If Context is NULL, the new entry will\r
189 be appended to the end of the database.\r
190\r
191 @retval EFI_INVALID_PARAMETER Certain Parameters are not correct. The Parameter\r
192 requiring a check depends on the Selector type.\r
193 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
194 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
195\r
196**/\r
197typedef\r
198EFI_STATUS\r
199(*IPSEC_SET_POLICY_ENTRY) (\r
200 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
201 IN VOID *Data,\r
202 IN VOID *Context OPTIONAL\r
203 );\r
204\r
205/**\r
206 A prototype function definition to lookup the data entry from IPsec. Return the configuration\r
207 value of the specified Entry.\r
208\r
209 @param[in] Selector Pointer to an entry selector that is an identifier\r
210 of the entry.\r
211 @param[in, out] DataSize On output, the size of data returned in Data.\r
212 @param[out] Data The buffer to return the contents of the IPsec\r
213 configuration data. The type of the data buffer\r
214 is associated with the DataType.\r
215\r
216 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
217 @retval EFI_INVALID_PARAMETER Data is NULL and *DataSize is not zero.\r
218 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
219 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
220 updated with the size needed to complete the request.\r
221\r
222**/\r
223typedef\r
224EFI_STATUS\r
225(*IPSEC_GET_POLICY_ENTRY) (\r
226 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
227 IN OUT UINTN *DataSize,\r
228 IN VOID *Data\r
229 );\r
230\r
231/**\r
232 Compare two SPD Selectors.\r
233\r
234 Compare two SPD Selector by the fields of LocalAddressCount/RemoteAddressCount/\r
235 NextLayerProtocol/LocalPort/LocalPortRange/RemotePort/RemotePortRange and the\r
236 Local Addresses and remote Addresses.\r
237\r
238 @param[in] Selector1 Pointer of the first SPD Selector.\r
239 @param[in] Selector2 Pointer of the second SPD Selector.\r
240\r
241 @retval TRUE These two Selectors have the same value in above fields.\r
242 @retval FALSE Not all of the above fields have the same value in these two Selectors.\r
243\r
244**/\r
245BOOLEAN\r
246CompareSpdSelector (\r
247 IN EFI_IPSEC_CONFIG_SELECTOR *Selector1,\r
248 IN EFI_IPSEC_CONFIG_SELECTOR *Selector2\r
249 );\r
250\r
251\r
252/**\r
253 Visit all IPsec Configurations of specified Type and call the caller defined\r
254 interface.\r
255\r
256 @param[in] DataType The specified IPsec Config Data Type.\r
257 @param[in] Routine The function caller defined.\r
258 @param[in] Context The data passed to the Routine.\r
259\r
260 @retval EFI_OUT_OF_RESOURCES The required system resource could not be allocated.\r
261 @retval EFI_SUCCESS This function complete successfully.\r
262\r
263**/\r
264EFI_STATUS\r
265IpSecVisitConfigData (\r
266 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
267 IN IPSEC_COPY_POLICY_ENTRY Routine,\r
268 IN VOID *Context\r
269 );\r
270\r
271\r
272/**\r
273 This function is the subfunction of the EFIIpSecConfigSetData.\r
274\r
275 This function call IpSecSetVaraible to set the IPsec Configuration into the firmware.\r
276\r
277 @retval EFI_OUT_OF_RESOURCES The required system resource could not be allocated.\r
278 @retval EFI_SUCCESS Saved the configration successfully.\r
279 @retval Others Other errors were found while obtaining the variable.\r
280\r
281**/\r
282EFI_STATUS\r
283IpSecConfigSave (\r
284 VOID\r
285 );\r
286\r
287/**\r
288 Initialize IPsecConfig protocol\r
289\r
290 @param[in, out] Private Pointer to IPSEC_PRIVATE_DATA. After this function finish,\r
291 the pointer of IPsecConfig Protocol implementation will copy\r
292 into its IPsecConfig member.\r
293\r
294 @retval EFI_SUCCESS Initialized the IPsecConfig Protocol successfully.\r
295 @retval Others Initializing the IPsecConfig Protocol failed.\r
296\r
297**/\r
298EFI_STATUS\r
299IpSecConfigInitialize (\r
300 IN OUT IPSEC_PRIVATE_DATA *Private\r
301 );\r
302\r
303/**\r
304 Calculate the entire size of EFI_IPSEC_SPD_DATA, which includes the buffer size pointed\r
305 by the pointer members.\r
306\r
307 @param[in] SpdData Pointer to a specified EFI_IPSEC_SPD_DATA.\r
308\r
309 @return The entire size of the specified EFI_IPSEC_SPD_DATA.\r
310\r
311**/\r
312UINTN\r
313IpSecGetSizeOfEfiSpdData (\r
314 IN EFI_IPSEC_SPD_DATA *SpdData\r
315 );\r
316\r
317/**\r
318 Calculate the a entire size of IPSEC_SPD_DATA, which includes the buffer size pointed\r
319 by the pointer members and the buffer size used by Sa List.\r
320\r
321 @param[in] SpdData Pointer to the specified IPSEC_SPD_DATA.\r
322\r
323 @return The entire size of IPSEC_SPD_DATA.\r
324\r
325**/\r
326UINTN\r
327IpSecGetSizeOfSpdData (\r
328 IN IPSEC_SPD_DATA *SpdData\r
329 );\r
330\r
331/**\r
332 Copy Source Process Policy to the Destination Process Policy.\r
333\r
334 @param[in] Dst Pointer to the Source Process Policy.\r
335 @param[in] Src Pointer to the Destination Process Policy.\r
336\r
337**/\r
338VOID\r
339IpSecDuplicateProcessPolicy (\r
340 IN EFI_IPSEC_PROCESS_POLICY *Dst,\r
341 IN EFI_IPSEC_PROCESS_POLICY *Src\r
342 );\r
343\r
344/**\r
9166f840 345 Find if the two SPD Selectors has subordinative.\r
a3bcde70
HT
346\r
347 Compare two SPD Selector by the fields of LocalAddressCount/RemoteAddressCount/\r
9166f840 348 NextLayerProtocol/LocalPort/LocalPortRange/RemotePort/RemotePortRange and the \r
a3bcde70
HT
349 Local Addresses and remote Addresses.\r
350\r
9166f840 351 @param[in] Selector1 Pointer of first SPD Selector.\r
352 @param[in] Selector2 Pointer of second SPD Selector.\r
a3bcde70 353\r
9166f840 354 @retval TRUE The first SPD Selector is subordinate Selector of second SPD Selector.\r
355 @retval FALSE The first SPD Selector is not subordinate Selector of second \r
356 SPD Selector.\r
357 \r
a3bcde70
HT
358**/\r
359BOOLEAN\r
9166f840 360IsSubSpdSelector (\r
a3bcde70
HT
361 IN EFI_IPSEC_CONFIG_SELECTOR *Selector1,\r
362 IN EFI_IPSEC_CONFIG_SELECTOR *Selector2\r
363 );\r
364\r
365/**\r
366 Compare two SA IDs.\r
367\r
368 @param[in] Selector1 Pointer of the first SA ID.\r
369 @param[in] Selector2 Pointer of the second SA ID.\r
370\r
371 @retval TRUE This two Selectors have the same SA ID.\r
372 @retval FALSE This two Selecotrs don't have the same SA ID.\r
373\r
374**/\r
375BOOLEAN\r
376CompareSaId (\r
377 IN EFI_IPSEC_CONFIG_SELECTOR *Selector1,\r
378 IN EFI_IPSEC_CONFIG_SELECTOR *Selector2\r
379 );\r
380\r
381/**\r
382 Compare two PAD IDs.\r
383\r
384 @param[in] Selector1 Pointer of the first PAD ID.\r
385 @param[in] Selector2 Pointer of the second PAD ID.\r
386\r
387 @retval TRUE This two Selectors have the same PAD ID.\r
388 @retval FALSE This two Selecotrs don't have the same PAD ID.\r
389\r
390**/\r
391BOOLEAN\r
392ComparePadId (\r
393 IN EFI_IPSEC_CONFIG_SELECTOR *Selector1,\r
394 IN EFI_IPSEC_CONFIG_SELECTOR *Selector2\r
395 );\r
396\r
397/**\r
398 Check if the SPD Selector is Zero by its LocalAddressCount and RemoteAddressCount\r
399 fields.\r
400\r
401 @param[in] Selector Pointer of the SPD Selector.\r
402\r
403 @retval TRUE If the SPD Selector is Zero.\r
404 @retval FALSE If the SPD Selector is not Zero.\r
405\r
406**/\r
407BOOLEAN\r
408IsZeroSpdSelector (\r
409 IN EFI_IPSEC_CONFIG_SELECTOR *Selector\r
410 );\r
411\r
412/**\r
413 Check if the SA ID is Zero by its DestAddress.\r
414\r
415 @param[in] Selector Pointer of the SA ID.\r
416\r
417 @retval TRUE If the SA ID is Zero.\r
418 @retval FALSE If the SA ID is not Zero.\r
419\r
420**/\r
421BOOLEAN\r
422IsZeroSaId (\r
423 IN EFI_IPSEC_CONFIG_SELECTOR *Selector\r
424 );\r
425\r
426/**\r
427 Check if the PAD ID is Zero.\r
428\r
429 @param[in] Selector Pointer of the PAD ID.\r
430\r
431 @retval TRUE If the PAD ID is Zero.\r
432 @retval FALSE If the PAD ID is not Zero.\r
433\r
434**/\r
435BOOLEAN\r
436IsZeroPadId (\r
437 IN EFI_IPSEC_CONFIG_SELECTOR *Selector\r
438 );\r
439\r
440/**\r
441 Copy Source SPD Selector to the Destination SPD Selector.\r
442\r
443 @param[in, out] DstSel Pointer of Destination SPD Selector.\r
444 @param[in] SrcSel Pointer of Source SPD Selector.\r
445 @param[in, out] Size The size of the Destination SPD Selector. If\r
446 it is not NULL and its value is less than the\r
447 size of Source SPD Selector, the value of\r
448 Source SPD Selector's size will be passed to\r
449 the caller by this parameter.\r
450\r
451 @retval EFI_INVALID_PARAMETER If the Destination or Source SPD Selector is NULL.\r
452 @retval EFI_BUFFER_TOO_SMALL If the input Size is less than size of Source SPD Selector.\r
453 @retval EFI_SUCCESS Copy Source SPD Selector to the Destination SPD\r
454 Selector successfully.\r
455\r
456**/\r
457EFI_STATUS\r
458DuplicateSpdSelector (\r
459 IN OUT EFI_IPSEC_CONFIG_SELECTOR *DstSel,\r
460 IN EFI_IPSEC_CONFIG_SELECTOR *SrcSel,\r
461 IN OUT UINTN *Size\r
462 );\r
463\r
464/**\r
465 Copy Source SA ID to the Destination SA ID.\r
466\r
467 @param[in, out] DstSel Pointer of the Destination SA ID.\r
468 @param[in] SrcSel Pointer of the Source SA ID.\r
469 @param[in, out] Size The size of the Destination SA ID. If it\r
470 not NULL, and its value is less than the size of\r
471 Source SA ID, the value of Source SA ID's size\r
472 will be passed to the caller by this parameter.\r
473\r
474 @retval EFI_INVALID_PARAMETER If the Destination or Source SA ID is NULL.\r
475 @retval EFI_BUFFER_TOO_SMALL If the input Size less than size of source SA ID.\r
476 @retval EFI_SUCCESS Copied Source SA ID to the Destination SA ID successfully.\r
477\r
478**/\r
479EFI_STATUS\r
480DuplicateSaId (\r
481 IN OUT EFI_IPSEC_CONFIG_SELECTOR *DstSel,\r
482 IN EFI_IPSEC_CONFIG_SELECTOR *SrcSel,\r
483 IN OUT UINTN *Size\r
484 );\r
485\r
486/**\r
487 Copy Source PAD ID to the Destination PAD ID.\r
488\r
489 @param[in, out] DstSel Pointer of Destination PAD ID.\r
490 @param[in] SrcSel Pointer of Source PAD ID.\r
491 @param[in, out] Size The size of the Destination PAD ID. If it\r
492 not NULL, and its value less than the size of\r
493 Source PAD ID, the value of Source PAD ID's size\r
494 will be passed to the caller by this parameter.\r
495\r
496 @retval EFI_INVALID_PARAMETER If the Destination or Source PAD ID is NULL.\r
497 @retval EFI_BUFFER_TOO_SMALL If the input Size less than size of source PAD ID.\r
498 @retval EFI_SUCCESS Copied Source PAD ID to the Destination PAD ID successfully.\r
499\r
500**/\r
501EFI_STATUS\r
502DuplicatePadId (\r
503 IN OUT EFI_IPSEC_CONFIG_SELECTOR *DstSel,\r
504 IN EFI_IPSEC_CONFIG_SELECTOR *SrcSel,\r
505 IN OUT UINTN *Size\r
506 );\r
507\r
508/**\r
509 Fix the value of some members of the SPD Selector.\r
510\r
511 This function is called by IpSecCopyPolicyEntry(), which copies the Policy\r
512 Entry into the Variable. Since some members in SPD Selector are pointers,\r
513 a physical address to relative address conversion is required before copying\r
514 this SPD entry into the variable.\r
515\r
516 @param[in] Selector Pointer of SPD Selector.\r
517 @param[in, out] Data Pointer of SPD Data.\r
518\r
519**/\r
520VOID\r
521FixSpdEntry (\r
522 IN EFI_IPSEC_SPD_SELECTOR *Selector,\r
523 IN OUT EFI_IPSEC_SPD_DATA *Data\r
524 );\r
525\r
526/**\r
527 Fix the value of some members of SA ID.\r
528\r
529 This function is called by IpSecCopyPolicyEntry(), which copies the Policy\r
530 Entry into the Variable. Since some members in SA ID are pointers,\r
531 a physical address to relative address conversion is required before copying\r
532 this SAD into the variable.\r
533\r
534 @param[in] SaId Pointer of SA ID.\r
535 @param[in, out] Data Pointer of SA Data.\r
536\r
537**/\r
538VOID\r
539FixSadEntry (\r
540 IN EFI_IPSEC_SA_ID *SaId,\r
9166f840 541 IN OUT EFI_IPSEC_SA_DATA2 *Data\r
a3bcde70
HT
542 );\r
543\r
544/**\r
545 Fix the value of some members of PAD ID.\r
546\r
547 This function is called by IpSecCopyPolicyEntry(), which copy the Policy\r
548 Entry into the Variable. Since some members in PAD ID are pointers,\r
549 a physical address to relative address conversion is required before copying\r
550 this PAD into the variable.\r
551\r
552 @param[in] PadId Pointer of PAD ID.\r
553 @param[in, out] Data Pointer of PAD Data.\r
554\r
555**/\r
556VOID\r
557FixPadEntry (\r
558 IN EFI_IPSEC_PAD_ID *PadId,\r
559 IN OUT EFI_IPSEC_PAD_DATA *Data\r
560 );\r
561\r
562/**\r
563 Recover the value of some members of SPD Selector.\r
564\r
565 This function is corresponding to FixSpdEntry(). It recovers the value of members\r
566 of SPD Selector which fix by the FixSpdEntry().\r
567\r
568 @param[in, out] Selector Pointer of SPD Selector.\r
569 @param[in, out] Data Pointer of SPD Data.\r
570\r
571**/\r
572VOID\r
573UnfixSpdEntry (\r
574 IN OUT EFI_IPSEC_SPD_SELECTOR *Selector,\r
575 IN OUT EFI_IPSEC_SPD_DATA *Data\r
576 );\r
577\r
578\r
579/**\r
580 Recover the value of some members of SA ID.\r
581\r
582 This function is corresponding to FixSadEntry(). It recovers the value of members\r
583 of SAD ID which fix by the FixSadEntry().\r
584\r
585 @param[in, out] SaId Pointer of SAD ID\r
586 @param[in, out] Data Pointer of SAD Data.\r
587\r
588**/\r
589VOID\r
590UnfixSadEntry (\r
591 IN OUT EFI_IPSEC_SA_ID *SaId,\r
9166f840 592 IN OUT EFI_IPSEC_SA_DATA2 *Data\r
a3bcde70
HT
593 );\r
594\r
595/**\r
596 Recover the value of some members of PAD ID.\r
597\r
598 This function is corresponding to FixPadEntry(). It recovers the value of members\r
599 of PAD ID which fix by the FixPadEntry().\r
600\r
601 @param[in] PadId Pointer of PAD ID\r
602 @param[in, out] Data Pointer of PAD Data.\r
603\r
604**/\r
605VOID\r
606UnfixPadEntry (\r
607 IN EFI_IPSEC_PAD_ID *PadId,\r
608 IN OUT EFI_IPSEC_PAD_DATA *Data\r
609 );\r
610\r
611/**\r
612 Set the security policy information for the EFI IPsec driver.\r
613\r
614 The IPsec configuration data has a unique selector/identifier separately to\r
615 identify a data entry.\r
616\r
617 @param[in] Selector Pointer to an entry selector on operated\r
618 configuration data specified by DataType.\r
619 A NULL Selector causes the entire specified-type\r
620 configuration information to be flushed.\r
621 @param[in] Data The data buffer to be set. The structure\r
622 of the data buffer should be EFI_IPSEC_SPD_DATA.\r
623 @param[in] Context Pointer to one entry selector that describes\r
624 the expected position the new data entry will\r
625 be added. If Context is NULL,the new entry will\r
626 be appended the end of database.\r
627\r
628 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
629 - Selector is not NULL and its LocalAddress\r
630 is NULL or its RemoteAddress is NULL.\r
631 - Data is not NULL, its Action is Protected,\r
632 and its policy is NULL.\r
633 - Data is not NULL and its Action is not protected\r
634 and its policy is not NULL.\r
635 - The Action of Data is Protected, its policy\r
636 mode is Tunnel, and its tunnel option is NULL.\r
637 - The Action of Data is protected, its policy\r
638 mode is not Tunnel, and it tunnel option is not NULL.\r
639 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
640 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
641\r
642**/\r
643EFI_STATUS\r
644SetSpdEntry (\r
645 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
646 IN VOID *Data,\r
647 IN VOID *Context OPTIONAL\r
648 );\r
649\r
650/**\r
651 Set the security association information for the EFI IPsec driver.\r
652\r
653 The IPsec configuration data has a unique selector/identifier separately to\r
654 identify a data entry.\r
655\r
656 @param[in] Selector Pointer to an entry selector on operated\r
657 configuration data specified by DataType.\r
658 A NULL Selector causes the entire specified-type\r
659 configuration information to be flushed.\r
660 @param[in] Data The data buffer to be set. The structure\r
661 of the data buffer should be EFI_IPSEC_SA_DATA.\r
662 @param[in] Context Pointer to one entry selector which describes\r
663 the expected position the new data entry will\r
664 be added. If Context is NULL,the new entry will\r
665 be appended to the end of database.\r
666\r
667 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
668 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
669\r
670**/\r
671EFI_STATUS\r
672SetSadEntry (\r
673 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
674 IN VOID *Data,\r
675 IN VOID *Context OPTIONAL\r
676 );\r
677\r
678/**\r
679 Set the peer authorization configuration information for the EFI IPsec driver.\r
680\r
681 The IPsec configuration data has a unique selector/identifier separately to\r
682 identify a data entry.\r
683\r
684 @param[in] Selector Pointer to an entry selector on operated\r
685 configuration data specified by DataType.\r
686 A NULL Selector causes the entire specified-type\r
687 configuration information to be flushed.\r
688 @param[in] Data The data buffer to be set. The structure\r
689 of the data buffer should be EFI_IPSEC_PAD_DATA.\r
690 @param[in] Context Pointer to one entry selector that describes\r
691 the expected position where the new data entry will\r
692 be added. If Context is NULL, the new entry will\r
693 be appended the end of database.\r
694\r
695 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
696 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
697\r
698**/\r
699EFI_STATUS\r
700SetPadEntry (\r
701 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
702 IN VOID *Data,\r
703 IN VOID *Context OPTIONAL\r
704 );\r
705\r
706/**\r
707 This function looks up the data entry from IPsec SPD, and returns the configuration\r
708 value of the specified SPD Entry.\r
709\r
710 @param[in] Selector Pointer to an entry selector which is an identifier\r
711 of the SPD entry.\r
712 @param[in, out] DataSize On output the size of data returned in Data.\r
713 @param[out] Data The buffer to return the contents of the IPsec\r
714 configuration data. The type of the data buffer\r
715 is associated with the DataType.\r
716\r
717 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
718 @retval EFI_INVALID_PARAMETER Data is NULL and *DataSize is not zero.\r
719 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
720 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
721 updated with the size needed to complete the request.\r
722\r
723**/\r
724EFI_STATUS\r
725GetSpdEntry (\r
726 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
727 IN OUT UINTN *DataSize,\r
728 OUT VOID *Data\r
729 );\r
730\r
731/**\r
732 This function looks up the data entry from IPsec SAD and returns the configuration\r
733 value of the specified SAD Entry.\r
734\r
735 @param[in] Selector Pointer to an entry selector that is an identifier\r
736 of the SAD entry.\r
737 @param[in, out] DataSize On output, the size of data returned in Data.\r
738 @param[out] Data The buffer to return the contents of the IPsec\r
739 configuration data. This type of the data buffer\r
740 is associated with the DataType.\r
741\r
742 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
743 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
744 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
745 updated with the size needed to complete the request.\r
746\r
747**/\r
748EFI_STATUS\r
749GetSadEntry (\r
750 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
751 IN OUT UINTN *DataSize,\r
752 OUT VOID *Data\r
753 );\r
754\r
755/**\r
756 This function looks up the data entry from IPsec PADand returns the configuration\r
757 value of the specified PAD Entry.\r
758\r
759 @param[in] Selector Pointer to an entry selector that is an identifier\r
760 of the PAD entry.\r
761 @param[in, out] DataSize On output the size of data returned in Data.\r
762 @param[out] Data The buffer to return the contents of the IPsec\r
763 configuration data. This type of the data buffer\r
764 is associated with the DataType.\r
765\r
766 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
767 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
768 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
769 updated with the size needed to complete the request.\r
770\r
771**/\r
772EFI_STATUS\r
773GetPadEntry (\r
774 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
775 IN OUT UINTN *DataSize,\r
776 OUT VOID *Data\r
777 );\r
778\r
779/**\r
780 Return the configuration value for the EFI IPsec driver.\r
781\r
782 This function lookup the data entry from IPsec database or IKEv2 configuration\r
783 information. The expected data type and unique identification are described in\r
784 DataType and Selector parameters.\r
785\r
786 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
787 @param[in] DataType The type of data to retrieve.\r
788 @param[in] Selector Pointer to an entry selector that is an identifier of the IPsec\r
789 configuration data entry.\r
790 @param[in, out] DataSize On output the size of data returned in Data.\r
791 @param[out] Data The buffer to return the contents of the IPsec configuration data.\r
792 The type of the data buffer is associated with the DataType.\r
793\r
794 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
795 @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:\r
796 - This is NULL.\r
797 - Selector is NULL.\r
798 - DataSize is NULL.\r
799 - Data is NULL and *DataSize is not zero\r
800 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
801 @retval EFI_UNSUPPORTED The specified DataType is not supported.\r
802 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
803 updated with the size needed to complete the request.\r
804\r
805**/\r
806EFI_STATUS\r
807EFIAPI\r
808EfiIpSecConfigGetData (\r
809 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
810 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
811 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
812 IN OUT UINTN *DataSize,\r
813 OUT VOID *Data\r
814 );\r
815\r
816/**\r
817 Set the security association, security policy and peer authorization configuration\r
818 information for the EFI IPsec driver.\r
819\r
820 This function is used to set the IPsec configuration information of type DataType for\r
821 the EFI IPsec driver.\r
822 The IPsec configuration data has a unique selector/identifier separately to identify\r
823 a data entry. The selector structure depends on DataType's definition.\r
824 Using SetData() with a Data of NULL causes the IPsec configuration data entry identified\r
825 by DataType and Selector to be deleted.\r
826\r
827 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
828 @param[in] DataType The type of data to be set.\r
829 @param[in] Selector Pointer to an entry selector on operated configuration data\r
830 specified by DataType. A NULL Selector causes the entire\r
831 specified-type configuration information to be flushed.\r
832 @param[in] Data The data buffer to be set. The structure of the data buffer is\r
833 associated with the DataType.\r
834 @param[in] InsertBefore Pointer to one entry selector which describes the expected\r
835 position the new data entry will be added. If InsertBefore is NULL,\r
836 the new entry will be appended the end of database.\r
837\r
838 @retval EFI_SUCCESS The specified configuration entry data was set successfully.\r
839 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
840 - This is NULL.\r
841 @retval EFI_UNSUPPORTED The specified DataType is not supported.\r
842 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
843\r
844**/\r
845EFI_STATUS\r
846EFIAPI\r
847EfiIpSecConfigSetData (\r
848 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
849 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
850 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
851 IN VOID *Data,\r
852 IN EFI_IPSEC_CONFIG_SELECTOR *InsertBefore OPTIONAL\r
853 );\r
854\r
855/**\r
856 Enumerates the current selector for IPsec configuration data entry.\r
857\r
858 This function is called multiple times to retrieve the entry Selector in IPsec\r
859 configuration database. On each call to GetNextSelector(), the next entry\r
860 Selector are retrieved into the output interface.\r
861\r
862 If the entire IPsec configuration database has been iterated, the error\r
863 EFI_NOT_FOUND is returned.\r
864 If the Selector buffer is too small for the next Selector copy, an\r
865 EFI_BUFFER_TOO_SMALL error is returned, and SelectorSize is updated to reflect\r
866 the size of buffer needed.\r
867\r
868 On the initial call to GetNextSelector() to start the IPsec configuration database\r
869 search, a pointer to the buffer with all zero value is passed in Selector. Calls\r
870 to SetData() between calls to GetNextSelector may produce unpredictable results.\r
871\r
872 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
873 @param[in] DataType The type of IPsec configuration data to retrieve.\r
874 @param[in, out] SelectorSize The size of the Selector buffer.\r
875 @param[in, out] Selector On input, supplies the pointer to last Selector that was\r
876 returned by GetNextSelector().\r
877 On output, returns one copy of the current entry Selector\r
878 of a given DataType.\r
879\r
880 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
881 @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:\r
882 - This is NULL.\r
883 - SelectorSize is NULL.\r
884 - Selector is NULL.\r
885 @retval EFI_NOT_FOUND The next configuration data entry was not found.\r
886 @retval EFI_UNSUPPORTED The specified DataType is not supported.\r
887 @retval EFI_BUFFER_TOO_SMALL The SelectorSize is too small for the result. This parameter\r
888 has been updated with the size needed to complete the search\r
889 request.\r
890\r
891**/\r
892EFI_STATUS\r
893EFIAPI\r
894EfiIpSecConfigGetNextSelector (\r
895 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
896 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
897 IN OUT UINTN *SelectorSize,\r
898 IN OUT EFI_IPSEC_CONFIG_SELECTOR *Selector\r
899 );\r
900\r
901/**\r
902 Register an event that is to be signaled whenever a configuration process on the\r
903 specified IPsec configuration information is done.\r
904\r
905 The register function is not surpport now and always returns EFI_UNSUPPORTED.\r
906\r
907 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
908 @param[in] DataType The type of data to be registered the event for.\r
909 @param[in] Event The event to be registered.\r
910\r
911 @retval EFI_SUCCESS The event is registered successfully.\r
912 @retval EFI_INVALID_PARAMETER This is NULL, or Event is NULL.\r
913 @retval EFI_ACCESS_DENIED The Event is already registered for the DataType.\r
914 @retval EFI_UNSUPPORTED The notify registration unsupported, or the specified\r
915 DataType is not supported.\r
916\r
917**/\r
918EFI_STATUS\r
919EFIAPI\r
920EfiIpSecConfigRegisterNotify (\r
921 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
922 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
923 IN EFI_EVENT Event\r
924 );\r
925\r
926\r
927/**\r
928 Remove the specified event that was previously registered on the specified IPsec\r
929 configuration data.\r
930\r
931 This function is not supported now and always returns EFI_UNSUPPORTED.\r
932\r
933 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
934 @param[in] DataType The configuration data type to remove the registered event for.\r
935 @param[in] Event The event to be unregistered.\r
936\r
937 @retval EFI_SUCCESS The event was removed successfully.\r
938 @retval EFI_NOT_FOUND The Event specified by DataType could not be found in the\r
939 database.\r
940 @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL.\r
941 @retval EFI_UNSUPPORTED The notify registration unsupported or the specified\r
942 DataType is not supported.\r
943\r
944**/\r
945EFI_STATUS\r
946EFIAPI\r
947EfiIpSecConfigUnregisterNotify (\r
948 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
949 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
950 IN EFI_EVENT Event\r
951 );\r
952\r
9166f840 953extern LIST_ENTRY mConfigData[IPsecConfigDataTypeMaximum];\r
954\r
a3bcde70 955#endif\r