]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/IpSecDxe/IpSecConfigImpl.h
Add NetworkPkg (P.UDK2010.UP3.Network.P1)
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IpSecConfigImpl.h
CommitLineData
a3bcde70
HT
1/** @file\r
2 Definitions related to IPSEC_CONFIG_PROTOCOL implementations.\r
3\r
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#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
78 @param[in out] DstSel Pointer of Destination Selector. It would be\r
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
82 @param[in out] Size The size of the Destination Selector. If it\r
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
158 @param[in out] Buffer The buffer to store the Selector and Data.\r
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
345 Compare two SPD Selectors.\r
346\r
347 Compare two SPD Selector by the fields of LocalAddressCount/RemoteAddressCount/\r
348 NextLayerProtocol/LocalPort/LocalPortRange/RemotePort/RemotePortRange and the\r
349 Local Addresses and remote Addresses.\r
350\r
351 @param[in] Selector1 Pointer of the first SPD Selector.\r
352 @param[in] Selector2 Pointer of the second SPD Selector.\r
353\r
354 @retval TRUE This two Selector have the same value in above fields.\r
355 @retval FALSE Not all of the above fields have the same value in these two Selectors.\r
356\r
357**/\r
358BOOLEAN\r
359CompareSpdSelector (\r
360 IN EFI_IPSEC_CONFIG_SELECTOR *Selector1,\r
361 IN EFI_IPSEC_CONFIG_SELECTOR *Selector2\r
362 );\r
363\r
364/**\r
365 Compare two SA IDs.\r
366\r
367 @param[in] Selector1 Pointer of the first SA ID.\r
368 @param[in] Selector2 Pointer of the second SA ID.\r
369\r
370 @retval TRUE This two Selectors have the same SA ID.\r
371 @retval FALSE This two Selecotrs don't have the same SA ID.\r
372\r
373**/\r
374BOOLEAN\r
375CompareSaId (\r
376 IN EFI_IPSEC_CONFIG_SELECTOR *Selector1,\r
377 IN EFI_IPSEC_CONFIG_SELECTOR *Selector2\r
378 );\r
379\r
380/**\r
381 Compare two PAD IDs.\r
382\r
383 @param[in] Selector1 Pointer of the first PAD ID.\r
384 @param[in] Selector2 Pointer of the second PAD ID.\r
385\r
386 @retval TRUE This two Selectors have the same PAD ID.\r
387 @retval FALSE This two Selecotrs don't have the same PAD ID.\r
388\r
389**/\r
390BOOLEAN\r
391ComparePadId (\r
392 IN EFI_IPSEC_CONFIG_SELECTOR *Selector1,\r
393 IN EFI_IPSEC_CONFIG_SELECTOR *Selector2\r
394 );\r
395\r
396/**\r
397 Check if the SPD Selector is Zero by its LocalAddressCount and RemoteAddressCount\r
398 fields.\r
399\r
400 @param[in] Selector Pointer of the SPD Selector.\r
401\r
402 @retval TRUE If the SPD Selector is Zero.\r
403 @retval FALSE If the SPD Selector is not Zero.\r
404\r
405**/\r
406BOOLEAN\r
407IsZeroSpdSelector (\r
408 IN EFI_IPSEC_CONFIG_SELECTOR *Selector\r
409 );\r
410\r
411/**\r
412 Check if the SA ID is Zero by its DestAddress.\r
413\r
414 @param[in] Selector Pointer of the SA ID.\r
415\r
416 @retval TRUE If the SA ID is Zero.\r
417 @retval FALSE If the SA ID is not Zero.\r
418\r
419**/\r
420BOOLEAN\r
421IsZeroSaId (\r
422 IN EFI_IPSEC_CONFIG_SELECTOR *Selector\r
423 );\r
424\r
425/**\r
426 Check if the PAD ID is Zero.\r
427\r
428 @param[in] Selector Pointer of the PAD ID.\r
429\r
430 @retval TRUE If the PAD ID is Zero.\r
431 @retval FALSE If the PAD ID is not Zero.\r
432\r
433**/\r
434BOOLEAN\r
435IsZeroPadId (\r
436 IN EFI_IPSEC_CONFIG_SELECTOR *Selector\r
437 );\r
438\r
439/**\r
440 Copy Source SPD Selector to the Destination SPD Selector.\r
441\r
442 @param[in, out] DstSel Pointer of Destination SPD Selector.\r
443 @param[in] SrcSel Pointer of Source SPD Selector.\r
444 @param[in, out] Size The size of the Destination SPD Selector. If\r
445 it is not NULL and its value is less than the\r
446 size of Source SPD Selector, the value of\r
447 Source SPD Selector's size will be passed to\r
448 the caller by this parameter.\r
449\r
450 @retval EFI_INVALID_PARAMETER If the Destination or Source SPD Selector is NULL.\r
451 @retval EFI_BUFFER_TOO_SMALL If the input Size is less than size of Source SPD Selector.\r
452 @retval EFI_SUCCESS Copy Source SPD Selector to the Destination SPD\r
453 Selector successfully.\r
454\r
455**/\r
456EFI_STATUS\r
457DuplicateSpdSelector (\r
458 IN OUT EFI_IPSEC_CONFIG_SELECTOR *DstSel,\r
459 IN EFI_IPSEC_CONFIG_SELECTOR *SrcSel,\r
460 IN OUT UINTN *Size\r
461 );\r
462\r
463/**\r
464 Copy Source SA ID to the Destination SA ID.\r
465\r
466 @param[in, out] DstSel Pointer of the Destination SA ID.\r
467 @param[in] SrcSel Pointer of the Source SA ID.\r
468 @param[in, out] Size The size of the Destination SA ID. If it\r
469 not NULL, and its value is less than the size of\r
470 Source SA ID, the value of Source SA ID's size\r
471 will be passed to the caller by this parameter.\r
472\r
473 @retval EFI_INVALID_PARAMETER If the Destination or Source SA ID is NULL.\r
474 @retval EFI_BUFFER_TOO_SMALL If the input Size less than size of source SA ID.\r
475 @retval EFI_SUCCESS Copied Source SA ID to the Destination SA ID successfully.\r
476\r
477**/\r
478EFI_STATUS\r
479DuplicateSaId (\r
480 IN OUT EFI_IPSEC_CONFIG_SELECTOR *DstSel,\r
481 IN EFI_IPSEC_CONFIG_SELECTOR *SrcSel,\r
482 IN OUT UINTN *Size\r
483 );\r
484\r
485/**\r
486 Copy Source PAD ID to the Destination PAD ID.\r
487\r
488 @param[in, out] DstSel Pointer of Destination PAD ID.\r
489 @param[in] SrcSel Pointer of Source PAD ID.\r
490 @param[in, out] Size The size of the Destination PAD ID. If it\r
491 not NULL, and its value less than the size of\r
492 Source PAD ID, the value of Source PAD ID's size\r
493 will be passed to the caller by this parameter.\r
494\r
495 @retval EFI_INVALID_PARAMETER If the Destination or Source PAD ID is NULL.\r
496 @retval EFI_BUFFER_TOO_SMALL If the input Size less than size of source PAD ID.\r
497 @retval EFI_SUCCESS Copied Source PAD ID to the Destination PAD ID successfully.\r
498\r
499**/\r
500EFI_STATUS\r
501DuplicatePadId (\r
502 IN OUT EFI_IPSEC_CONFIG_SELECTOR *DstSel,\r
503 IN EFI_IPSEC_CONFIG_SELECTOR *SrcSel,\r
504 IN OUT UINTN *Size\r
505 );\r
506\r
507/**\r
508 Fix the value of some members of the SPD Selector.\r
509\r
510 This function is called by IpSecCopyPolicyEntry(), which copies the Policy\r
511 Entry into the Variable. Since some members in SPD Selector are pointers,\r
512 a physical address to relative address conversion is required before copying\r
513 this SPD entry into the variable.\r
514\r
515 @param[in] Selector Pointer of SPD Selector.\r
516 @param[in, out] Data Pointer of SPD Data.\r
517\r
518**/\r
519VOID\r
520FixSpdEntry (\r
521 IN EFI_IPSEC_SPD_SELECTOR *Selector,\r
522 IN OUT EFI_IPSEC_SPD_DATA *Data\r
523 );\r
524\r
525/**\r
526 Fix the value of some members of SA ID.\r
527\r
528 This function is called by IpSecCopyPolicyEntry(), which copies the Policy\r
529 Entry into the Variable. Since some members in SA ID are pointers,\r
530 a physical address to relative address conversion is required before copying\r
531 this SAD into the variable.\r
532\r
533 @param[in] SaId Pointer of SA ID.\r
534 @param[in, out] Data Pointer of SA Data.\r
535\r
536**/\r
537VOID\r
538FixSadEntry (\r
539 IN EFI_IPSEC_SA_ID *SaId,\r
540 IN OUT EFI_IPSEC_SA_DATA *Data\r
541 );\r
542\r
543/**\r
544 Fix the value of some members of PAD ID.\r
545\r
546 This function is called by IpSecCopyPolicyEntry(), which copy the Policy\r
547 Entry into the Variable. Since some members in PAD ID are pointers,\r
548 a physical address to relative address conversion is required before copying\r
549 this PAD into the variable.\r
550\r
551 @param[in] PadId Pointer of PAD ID.\r
552 @param[in, out] Data Pointer of PAD Data.\r
553\r
554**/\r
555VOID\r
556FixPadEntry (\r
557 IN EFI_IPSEC_PAD_ID *PadId,\r
558 IN OUT EFI_IPSEC_PAD_DATA *Data\r
559 );\r
560\r
561/**\r
562 Recover the value of some members of SPD Selector.\r
563\r
564 This function is corresponding to FixSpdEntry(). It recovers the value of members\r
565 of SPD Selector which fix by the FixSpdEntry().\r
566\r
567 @param[in, out] Selector Pointer of SPD Selector.\r
568 @param[in, out] Data Pointer of SPD Data.\r
569\r
570**/\r
571VOID\r
572UnfixSpdEntry (\r
573 IN OUT EFI_IPSEC_SPD_SELECTOR *Selector,\r
574 IN OUT EFI_IPSEC_SPD_DATA *Data\r
575 );\r
576\r
577\r
578/**\r
579 Recover the value of some members of SA ID.\r
580\r
581 This function is corresponding to FixSadEntry(). It recovers the value of members\r
582 of SAD ID which fix by the FixSadEntry().\r
583\r
584 @param[in, out] SaId Pointer of SAD ID\r
585 @param[in, out] Data Pointer of SAD Data.\r
586\r
587**/\r
588VOID\r
589UnfixSadEntry (\r
590 IN OUT EFI_IPSEC_SA_ID *SaId,\r
591 IN OUT EFI_IPSEC_SA_DATA *Data\r
592 );\r
593\r
594/**\r
595 Recover the value of some members of PAD ID.\r
596\r
597 This function is corresponding to FixPadEntry(). It recovers the value of members\r
598 of PAD ID which fix by the FixPadEntry().\r
599\r
600 @param[in] PadId Pointer of PAD ID\r
601 @param[in, out] Data Pointer of PAD Data.\r
602\r
603**/\r
604VOID\r
605UnfixPadEntry (\r
606 IN EFI_IPSEC_PAD_ID *PadId,\r
607 IN OUT EFI_IPSEC_PAD_DATA *Data\r
608 );\r
609\r
610/**\r
611 Set the security policy information for the EFI IPsec driver.\r
612\r
613 The IPsec configuration data has a unique selector/identifier separately to\r
614 identify a data entry.\r
615\r
616 @param[in] Selector Pointer to an entry selector on operated\r
617 configuration data specified by DataType.\r
618 A NULL Selector causes the entire specified-type\r
619 configuration information to be flushed.\r
620 @param[in] Data The data buffer to be set. The structure\r
621 of the data buffer should be EFI_IPSEC_SPD_DATA.\r
622 @param[in] Context Pointer to one entry selector that describes\r
623 the expected position the new data entry will\r
624 be added. If Context is NULL,the new entry will\r
625 be appended the end of database.\r
626\r
627 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
628 - Selector is not NULL and its LocalAddress\r
629 is NULL or its RemoteAddress is NULL.\r
630 - Data is not NULL, its Action is Protected,\r
631 and its policy is NULL.\r
632 - Data is not NULL and its Action is not protected\r
633 and its policy is not NULL.\r
634 - The Action of Data is Protected, its policy\r
635 mode is Tunnel, and its tunnel option is NULL.\r
636 - The Action of Data is protected, its policy\r
637 mode is not Tunnel, and it tunnel option is not NULL.\r
638 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
639 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
640\r
641**/\r
642EFI_STATUS\r
643SetSpdEntry (\r
644 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
645 IN VOID *Data,\r
646 IN VOID *Context OPTIONAL\r
647 );\r
648\r
649/**\r
650 Set the security association information for the EFI IPsec driver.\r
651\r
652 The IPsec configuration data has a unique selector/identifier separately to\r
653 identify a data entry.\r
654\r
655 @param[in] Selector Pointer to an entry selector on operated\r
656 configuration data specified by DataType.\r
657 A NULL Selector causes the entire specified-type\r
658 configuration information to be flushed.\r
659 @param[in] Data The data buffer to be set. The structure\r
660 of the data buffer should be EFI_IPSEC_SA_DATA.\r
661 @param[in] Context Pointer to one entry selector which describes\r
662 the expected position the new data entry will\r
663 be added. If Context is NULL,the new entry will\r
664 be appended to the end of database.\r
665\r
666 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
667 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
668\r
669**/\r
670EFI_STATUS\r
671SetSadEntry (\r
672 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
673 IN VOID *Data,\r
674 IN VOID *Context OPTIONAL\r
675 );\r
676\r
677/**\r
678 Set the peer authorization configuration information for the EFI IPsec driver.\r
679\r
680 The IPsec configuration data has a unique selector/identifier separately to\r
681 identify a data entry.\r
682\r
683 @param[in] Selector Pointer to an entry selector on operated\r
684 configuration data specified by DataType.\r
685 A NULL Selector causes the entire specified-type\r
686 configuration information to be flushed.\r
687 @param[in] Data The data buffer to be set. The structure\r
688 of the data buffer should be EFI_IPSEC_PAD_DATA.\r
689 @param[in] Context Pointer to one entry selector that describes\r
690 the expected position where the new data entry will\r
691 be added. If Context is NULL, the new entry will\r
692 be appended the end of database.\r
693\r
694 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
695 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
696\r
697**/\r
698EFI_STATUS\r
699SetPadEntry (\r
700 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
701 IN VOID *Data,\r
702 IN VOID *Context OPTIONAL\r
703 );\r
704\r
705/**\r
706 This function looks up the data entry from IPsec SPD, and returns the configuration\r
707 value of the specified SPD Entry.\r
708\r
709 @param[in] Selector Pointer to an entry selector which is an identifier\r
710 of the SPD entry.\r
711 @param[in, out] DataSize On output the size of data returned in Data.\r
712 @param[out] Data The buffer to return the contents of the IPsec\r
713 configuration data. The type of the data buffer\r
714 is associated with the DataType.\r
715\r
716 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
717 @retval EFI_INVALID_PARAMETER Data is NULL and *DataSize is not zero.\r
718 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
719 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
720 updated with the size needed to complete the request.\r
721\r
722**/\r
723EFI_STATUS\r
724GetSpdEntry (\r
725 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
726 IN OUT UINTN *DataSize,\r
727 OUT VOID *Data\r
728 );\r
729\r
730/**\r
731 This function looks up the data entry from IPsec SAD and returns the configuration\r
732 value of the specified SAD Entry.\r
733\r
734 @param[in] Selector Pointer to an entry selector that is an identifier\r
735 of the SAD entry.\r
736 @param[in, out] DataSize On output, the size of data returned in Data.\r
737 @param[out] Data The buffer to return the contents of the IPsec\r
738 configuration data. This type of the data buffer\r
739 is associated with the DataType.\r
740\r
741 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
742 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
743 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
744 updated with the size needed to complete the request.\r
745\r
746**/\r
747EFI_STATUS\r
748GetSadEntry (\r
749 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
750 IN OUT UINTN *DataSize,\r
751 OUT VOID *Data\r
752 );\r
753\r
754/**\r
755 This function looks up the data entry from IPsec PADand returns the configuration\r
756 value of the specified PAD Entry.\r
757\r
758 @param[in] Selector Pointer to an entry selector that is an identifier\r
759 of the PAD entry.\r
760 @param[in, out] DataSize On output the size of data returned in Data.\r
761 @param[out] Data The buffer to return the contents of the IPsec\r
762 configuration data. This type of the data buffer\r
763 is associated with the DataType.\r
764\r
765 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
766 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
767 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
768 updated with the size needed to complete the request.\r
769\r
770**/\r
771EFI_STATUS\r
772GetPadEntry (\r
773 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
774 IN OUT UINTN *DataSize,\r
775 OUT VOID *Data\r
776 );\r
777\r
778/**\r
779 Return the configuration value for the EFI IPsec driver.\r
780\r
781 This function lookup the data entry from IPsec database or IKEv2 configuration\r
782 information. The expected data type and unique identification are described in\r
783 DataType and Selector parameters.\r
784\r
785 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
786 @param[in] DataType The type of data to retrieve.\r
787 @param[in] Selector Pointer to an entry selector that is an identifier of the IPsec\r
788 configuration data entry.\r
789 @param[in, out] DataSize On output the size of data returned in Data.\r
790 @param[out] Data The buffer to return the contents of the IPsec configuration data.\r
791 The type of the data buffer is associated with the DataType.\r
792\r
793 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
794 @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:\r
795 - This is NULL.\r
796 - Selector is NULL.\r
797 - DataSize is NULL.\r
798 - Data is NULL and *DataSize is not zero\r
799 @retval EFI_NOT_FOUND The configuration data specified by Selector is not found.\r
800 @retval EFI_UNSUPPORTED The specified DataType is not supported.\r
801 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has been\r
802 updated with the size needed to complete the request.\r
803\r
804**/\r
805EFI_STATUS\r
806EFIAPI\r
807EfiIpSecConfigGetData (\r
808 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
809 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
810 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
811 IN OUT UINTN *DataSize,\r
812 OUT VOID *Data\r
813 );\r
814\r
815/**\r
816 Set the security association, security policy and peer authorization configuration\r
817 information for the EFI IPsec driver.\r
818\r
819 This function is used to set the IPsec configuration information of type DataType for\r
820 the EFI IPsec driver.\r
821 The IPsec configuration data has a unique selector/identifier separately to identify\r
822 a data entry. The selector structure depends on DataType's definition.\r
823 Using SetData() with a Data of NULL causes the IPsec configuration data entry identified\r
824 by DataType and Selector to be deleted.\r
825\r
826 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
827 @param[in] DataType The type of data to be set.\r
828 @param[in] Selector Pointer to an entry selector on operated configuration data\r
829 specified by DataType. A NULL Selector causes the entire\r
830 specified-type configuration information to be flushed.\r
831 @param[in] Data The data buffer to be set. The structure of the data buffer is\r
832 associated with the DataType.\r
833 @param[in] InsertBefore Pointer to one entry selector which describes the expected\r
834 position the new data entry will be added. If InsertBefore is NULL,\r
835 the new entry will be appended the end of database.\r
836\r
837 @retval EFI_SUCCESS The specified configuration entry data was set successfully.\r
838 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
839 - This is NULL.\r
840 @retval EFI_UNSUPPORTED The specified DataType is not supported.\r
841 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated.\r
842\r
843**/\r
844EFI_STATUS\r
845EFIAPI\r
846EfiIpSecConfigSetData (\r
847 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
848 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
849 IN EFI_IPSEC_CONFIG_SELECTOR *Selector,\r
850 IN VOID *Data,\r
851 IN EFI_IPSEC_CONFIG_SELECTOR *InsertBefore OPTIONAL\r
852 );\r
853\r
854/**\r
855 Enumerates the current selector for IPsec configuration data entry.\r
856\r
857 This function is called multiple times to retrieve the entry Selector in IPsec\r
858 configuration database. On each call to GetNextSelector(), the next entry\r
859 Selector are retrieved into the output interface.\r
860\r
861 If the entire IPsec configuration database has been iterated, the error\r
862 EFI_NOT_FOUND is returned.\r
863 If the Selector buffer is too small for the next Selector copy, an\r
864 EFI_BUFFER_TOO_SMALL error is returned, and SelectorSize is updated to reflect\r
865 the size of buffer needed.\r
866\r
867 On the initial call to GetNextSelector() to start the IPsec configuration database\r
868 search, a pointer to the buffer with all zero value is passed in Selector. Calls\r
869 to SetData() between calls to GetNextSelector may produce unpredictable results.\r
870\r
871 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
872 @param[in] DataType The type of IPsec configuration data to retrieve.\r
873 @param[in, out] SelectorSize The size of the Selector buffer.\r
874 @param[in, out] Selector On input, supplies the pointer to last Selector that was\r
875 returned by GetNextSelector().\r
876 On output, returns one copy of the current entry Selector\r
877 of a given DataType.\r
878\r
879 @retval EFI_SUCCESS The specified configuration data was obtained successfully.\r
880 @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:\r
881 - This is NULL.\r
882 - SelectorSize is NULL.\r
883 - Selector is NULL.\r
884 @retval EFI_NOT_FOUND The next configuration data entry was not found.\r
885 @retval EFI_UNSUPPORTED The specified DataType is not supported.\r
886 @retval EFI_BUFFER_TOO_SMALL The SelectorSize is too small for the result. This parameter\r
887 has been updated with the size needed to complete the search\r
888 request.\r
889\r
890**/\r
891EFI_STATUS\r
892EFIAPI\r
893EfiIpSecConfigGetNextSelector (\r
894 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
895 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
896 IN OUT UINTN *SelectorSize,\r
897 IN OUT EFI_IPSEC_CONFIG_SELECTOR *Selector\r
898 );\r
899\r
900/**\r
901 Register an event that is to be signaled whenever a configuration process on the\r
902 specified IPsec configuration information is done.\r
903\r
904 The register function is not surpport now and always returns EFI_UNSUPPORTED.\r
905\r
906 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
907 @param[in] DataType The type of data to be registered the event for.\r
908 @param[in] Event The event to be registered.\r
909\r
910 @retval EFI_SUCCESS The event is registered successfully.\r
911 @retval EFI_INVALID_PARAMETER This is NULL, or Event is NULL.\r
912 @retval EFI_ACCESS_DENIED The Event is already registered for the DataType.\r
913 @retval EFI_UNSUPPORTED The notify registration unsupported, or the specified\r
914 DataType is not supported.\r
915\r
916**/\r
917EFI_STATUS\r
918EFIAPI\r
919EfiIpSecConfigRegisterNotify (\r
920 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
921 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
922 IN EFI_EVENT Event\r
923 );\r
924\r
925\r
926/**\r
927 Remove the specified event that was previously registered on the specified IPsec\r
928 configuration data.\r
929\r
930 This function is not supported now and always returns EFI_UNSUPPORTED.\r
931\r
932 @param[in] This Pointer to the EFI_IPSEC_CONFIG_PROTOCOL instance.\r
933 @param[in] DataType The configuration data type to remove the registered event for.\r
934 @param[in] Event The event to be unregistered.\r
935\r
936 @retval EFI_SUCCESS The event was removed successfully.\r
937 @retval EFI_NOT_FOUND The Event specified by DataType could not be found in the\r
938 database.\r
939 @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL.\r
940 @retval EFI_UNSUPPORTED The notify registration unsupported or the specified\r
941 DataType is not supported.\r
942\r
943**/\r
944EFI_STATUS\r
945EFIAPI\r
946EfiIpSecConfigUnregisterNotify (\r
947 IN EFI_IPSEC_CONFIG_PROTOCOL *This,\r
948 IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r
949 IN EFI_EVENT Event\r
950 );\r
951\r
952#endif\r