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