2 Implementation for EFI iSCSI Initiator Name Protocol.
4 Copyright (c) 2004 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Implementation for EFI iSCSI Initiator Name Protocol.
23 #include "IScsiImpl.h"
25 EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName
= {
26 IScsiGetInitiatorName
,
31 Retrieves the current set value of iSCSI Initiator Name.
33 @param This[in] Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
35 @param BufferSize[in][out] Size of the buffer in bytes pointed to by Buffer / Actual
36 size of the variable data buffer.
38 @param Buffer[out] Pointer to the buffer for data to be read.
40 @retval EFI_SUCCESS Data was successfully retrieved into the provided
41 buffer and the BufferSize was sufficient to handle the
43 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the result. BufferSize will
44 be updated with the size required to complete the request.
45 Buffer will not be affected.
47 @retval EFI_INVALID_PARAMETER BufferSize is NULL. BufferSize and Buffer will not be
50 @retval EFI_INVALID_PARAMETER Buffer is NULL. BufferSize and Buffer will not be
53 @retval EFI_DEVICE_ERROR The iSCSI initiator name could not be retrieved due to
59 IScsiGetInitiatorName (
60 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
61 IN OUT UINTN
*BufferSize
,
67 if ((BufferSize
== NULL
) || (Buffer
== NULL
)) {
68 return EFI_INVALID_PARAMETER
;
71 Status
= gRT
->GetVariable (
72 ISCSI_INITIATOR_NAME_VAR_NAME
,
73 &gEfiIScsiInitiatorNameProtocolGuid
,
83 Sets the iSCSI Initiator Name.
85 @param This[in] Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
87 @param BufferSize[in][out] Size of the buffer in bytes pointed to by Buffer.
89 @param Buffer[out] Pointer to the buffer for data to be written.
91 @retval EFI_SUCCESS Data was successfully stored by the protocol.
93 @retval EFI_UNSUPPORTED Platform policies do not allow for data to be written.
95 @retval EFI_INVALID_PARAMETER BufferSize exceeds the maximum allowed limit.
96 BufferSize will be updated with the maximum size
97 required to complete the request.
99 @retval EFI_INVALID_PARAMETER Buffersize is NULL. BufferSize and Buffer will not be
102 @retval EFI_INVALID_PARAMETER Buffer is NULL. BufferSize and Buffer will not be affected.
104 @retval EFI_DEVICE_ERROR The data could not be stored due to a hardware error.
106 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the data.
108 @retval EFI_PROTOCOL_ERROR Input iSCSI initiator name does not adhere to RFC 3720.
113 IScsiSetInitiatorName (
114 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
115 IN OUT UINTN
*BufferSize
,
121 if ((BufferSize
== NULL
) || (Buffer
== NULL
)) {
122 return EFI_INVALID_PARAMETER
;
125 if (*BufferSize
> ISCSI_NAME_MAX_SIZE
) {
126 *BufferSize
= ISCSI_NAME_MAX_SIZE
;
127 return EFI_INVALID_PARAMETER
;
130 // only support iqn iSCSI names.
132 Status
= IScsiNormalizeName ((CHAR8
*) Buffer
, *BufferSize
- 1);
133 if (EFI_ERROR (Status
)) {
137 Status
= gRT
->SetVariable (
138 ISCSI_INITIATOR_NAME_VAR_NAME
,
139 &gEfiIScsiInitiatorNameProtocolGuid
,
140 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,