2 Implementation for EFI iSCSI Initiator Name Protocol.
4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
5 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.
15 #include "IScsiImpl.h"
17 EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName
= {
18 IScsiGetInitiatorName
,
24 Retrieves the current set value of iSCSI Initiator Name.
26 @param[in] This Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL
28 @param[in, out] BufferSize Size of the buffer in bytes pointed to by Buffer /
29 Actual size of the variable data buffer.
30 @param[out] Buffer Pointer to the buffer for data to be read.
31 The data is a null-terminated UTF-8 encoded string.
32 The maximum length is 223 characters, including the null-terminator.
34 @retval EFI_SUCCESS Data was successfully retrieved into the provided
35 buffer and the BufferSize was sufficient to handle
36 the iSCSI initiator name.
37 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the result. BufferSize
38 will be updated with the size required to complete
39 the request. Buffer will not be affected.
40 @retval EFI_INVALID_PARAMETER BufferSize is NULL. BufferSize and Buffer will not
42 @retval EFI_INVALID_PARAMETER Buffer is NULL. BufferSize and Buffer will not be
44 @retval EFI_DEVICE_ERROR The iSCSI initiator name could not be retrieved
45 due to a hardware error.
50 IScsiGetInitiatorName (
51 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
52 IN OUT UINTN
*BufferSize
,
58 if ((BufferSize
== NULL
) || (Buffer
== NULL
)) {
59 return EFI_INVALID_PARAMETER
;
62 Status
= gRT
->GetVariable (
63 ISCSI_INITIATOR_NAME_VAR_NAME
,
64 &gEfiIScsiInitiatorNameProtocolGuid
,
75 Sets the iSSI Initiator Name.
77 @param[in] This Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL
79 @param[in, out] BufferSize Size of the buffer in bytes pointed to by Buffer.
80 @param[in] Buffer Pointer to the buffer for data to be written.
81 The data is a null-terminated UTF-8 encoded string.
82 The maximum length is 223 characters, including the null-terminator.
84 @retval EFI_SUCCESS Data was successfully stored by the protocol.
85 @retval EFI_UNSUPPORTED Platform policies do not allow for data to be
87 @retval EFI_INVALID_PARAMETER BufferSize exceeds the maximum allowed limit.
88 BufferSize will be updated with the maximum size
89 required to complete the request.
90 @retval EFI_INVALID_PARAMETER Buffersize is NULL. BufferSize and Buffer will not
92 @retval EFI_INVALID_PARAMETER Buffer is NULL. BufferSize and Buffer will not be
94 @retval EFI_DEVICE_ERROR The data could not be stored due to a hardware
96 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the data
97 @retval EFI_PROTOCOL_ERROR Input iSCSI initiator name does not adhere to RFC
103 IScsiSetInitiatorName (
104 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
105 IN OUT UINTN
*BufferSize
,
111 if ((BufferSize
== NULL
) || (Buffer
== NULL
)) {
112 return EFI_INVALID_PARAMETER
;
115 if (*BufferSize
> ISCSI_NAME_MAX_SIZE
) {
116 *BufferSize
= ISCSI_NAME_MAX_SIZE
;
117 return EFI_INVALID_PARAMETER
;
120 // Only support iqn iSCSI names.
122 Status
= IScsiNormalizeName ((CHAR8
*) Buffer
, *BufferSize
- 1);
123 if (EFI_ERROR (Status
)) {
127 Status
= gRT
->SetVariable (
128 ISCSI_INITIATOR_NAME_VAR_NAME
,
129 &gEfiIScsiInitiatorNameProtocolGuid
,
130 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,