]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiInitiatorName.c
CommitLineData
12618416 1/** @file\r
2 Implementation for EFI iSCSI Initiator Name Protocol.\r
6a690e23 3\r
e5eed7d3
HT
4Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
7a444476 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
6a690e23 12\r
12618416 13**/\r
6a690e23 14\r
15#include "IScsiImpl.h"\r
16\r
17EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName = {\r
18 IScsiGetInitiatorName,\r
19 IScsiSetInitiatorName\r
20};\r
21\r
12618416 22/**\r
9fd6fde8 23 Retrieves the current set value of iSCSI Initiator Name.\r
24\r
25 @param[in] This Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.\r
26 @param[in, out] BufferSize Size of the buffer in bytes pointed to by Buffer / Actual size of the\r
27 variable data buffer.\r
28 @param[out] Buffer Pointer to the buffer for data to be read.\r
29\r
30 @retval EFI_SUCCESS Data was successfully retrieved into the provided buffer and the\r
55a64ae0 31 BufferSize was sufficient to handle the iSCSI initiator name.\r
9fd6fde8 32 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the result.\r
33 @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL.\r
34 @retval EFI_DEVICE_ERROR The iSCSI initiator name could not be retrieved due to a hardware error.\r
963dbb30 35 @retval Others Other errors as indicated.\r
12618416 36**/\r
6a690e23 37EFI_STATUS\r
38EFIAPI\r
39IScsiGetInitiatorName (\r
40 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,\r
41 IN OUT UINTN *BufferSize,\r
42 OUT VOID *Buffer\r
43 )\r
6a690e23 44{\r
45 EFI_STATUS Status;\r
46\r
47 if ((BufferSize == NULL) || (Buffer == NULL)) {\r
48 return EFI_INVALID_PARAMETER;\r
49 }\r
50\r
51 Status = gRT->GetVariable (\r
52 ISCSI_INITIATOR_NAME_VAR_NAME,\r
53 &gEfiIScsiInitiatorNameProtocolGuid,\r
54 NULL,\r
55 BufferSize,\r
56 Buffer\r
57 );\r
58\r
59 return Status;\r
60}\r
61\r
12618416 62/**\r
9fd6fde8 63 Sets the iSCSI Initiator Name.\r
12618416 64\r
9fd6fde8 65 @param[in] This Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.\r
66 @param[in, out] BufferSize Size of the buffer in bytes pointed to by Buffer.\r
67 @param[in] Buffer Pointer to the buffer for data to be written.\r
12618416 68\r
12618416 69 @retval EFI_SUCCESS Data was successfully stored by the protocol.\r
12618416 70 @retval EFI_UNSUPPORTED Platform policies do not allow for data to be written.\r
9fd6fde8 71 Currently not implemented.\r
72 @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL, or BufferSize exceeds the maximum allowed limit.\r
12618416 73 @retval EFI_DEVICE_ERROR The data could not be stored due to a hardware error.\r
12618416 74 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the data.\r
9fd6fde8 75 @retval EFI_PROTOCOL_ERROR Input iSCSI initiator name does not adhere to RFC 3720\r
55a64ae0 76 (and other related protocols).\r
963dbb30 77 @retval Others Other errors as indicated.\r
12618416 78**/\r
79EFI_STATUS\r
80EFIAPI\r
81IScsiSetInitiatorName (\r
82 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,\r
83 IN OUT UINTN *BufferSize,\r
9fd6fde8 84 IN VOID *Buffer\r
12618416 85 )\r
6a690e23 86{\r
87 EFI_STATUS Status;\r
88\r
89 if ((BufferSize == NULL) || (Buffer == NULL)) {\r
90 return EFI_INVALID_PARAMETER;\r
91 }\r
92\r
93 if (*BufferSize > ISCSI_NAME_MAX_SIZE) {\r
94 *BufferSize = ISCSI_NAME_MAX_SIZE;\r
95 return EFI_INVALID_PARAMETER;\r
96 }\r
97 //\r
98 // only support iqn iSCSI names.\r
99 //\r
100 Status = IScsiNormalizeName ((CHAR8 *) Buffer, *BufferSize - 1);\r
101 if (EFI_ERROR (Status)) {\r
102 return Status;\r
103 }\r
104\r
105 Status = gRT->SetVariable (\r
106 ISCSI_INITIATOR_NAME_VAR_NAME,\r
107 &gEfiIScsiInitiatorNameProtocolGuid,\r
108 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
109 *BufferSize,\r
110 Buffer\r
111 );\r
112\r
113 return Status;\r
114}\r