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