3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Implementation for EFI iSCSI Initiator Name Protocol.
22 #include "IScsiImpl.h"
24 EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName
= {
25 IScsiGetInitiatorName
,
31 IScsiGetInitiatorName (
32 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
33 IN OUT UINTN
*BufferSize
,
40 Retrieves the current set value of iSCSI Initiator Name.
44 This - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
45 BufferSize - Size of the buffer in bytes pointed to by Buffer / Actual size of
46 the variable data buffer.
47 Buffer - Pointer to the buffer for data to be read.
51 EFI_SUCCESS - Data was successfully retrieved into the provided
52 buffer and the BufferSize was sufficient to handle the
54 EFI_BUFFER_TOO_SMALL - BufferSize is too small for the result. BufferSize will
55 be updated with the size required to complete the request.
56 Buffer will not be affected.
57 EFI_INVALID_PARAMETER - BufferSize is NULL. BufferSize and Buffer will not be
59 EFI_INVALID_PARAMETER - Buffer is NULL. BufferSize and Buffer will not be
61 EFI_DEVICE_ERROR - The iSCSI initiator name could not be retrieved due to
68 if ((BufferSize
== NULL
) || (Buffer
== NULL
)) {
69 return EFI_INVALID_PARAMETER
;
72 Status
= gRT
->GetVariable (
73 ISCSI_INITIATOR_NAME_VAR_NAME
,
74 &gEfiIScsiInitiatorNameProtocolGuid
,
85 IScsiSetInitiatorName (
86 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
87 IN OUT UINTN
*BufferSize
,
94 Sets the iSSI Initiator Name.
98 This - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
99 BufferSize - Size of the buffer in bytes pointed to by Buffer.
100 Buffer - Pointer to the buffer for data to be written.
104 EFI_SUCCESS - Data was successfully stored by the protocol.
105 EFI_UNSUPPORTED - Platform policies do not allow for data to be written.
106 EFI_INVALID_PARAMETER - BufferSize exceeds the maximum allowed limit.
107 BufferSize will be updated with the maximum size
108 required to complete the request.
109 EFI_INVALID_PARAMETER - Buffersize is NULL. BufferSize and Buffer will not be
111 EFI_INVALID_PARAMETER - Buffer is NULL. BufferSize and Buffer will not be affected.
112 EFI_DEVICE_ERROR - The data could not be stored due to a hardware error.
113 EFI_OUT_OF_RESOURCES - Not enough storage is available to hold the data
114 EFI_PROTOCOL_ERROR - Input iSCSI initiator name does not adhere to RFC 3720
120 if ((BufferSize
== NULL
) || (Buffer
== NULL
)) {
121 return EFI_INVALID_PARAMETER
;
124 if (*BufferSize
> ISCSI_NAME_MAX_SIZE
) {
125 *BufferSize
= ISCSI_NAME_MAX_SIZE
;
126 return EFI_INVALID_PARAMETER
;
129 // only support iqn iSCSI names.
131 Status
= IScsiNormalizeName ((CHAR8
*) Buffer
, *BufferSize
- 1);
132 if (EFI_ERROR (Status
)) {
136 Status
= gRT
->SetVariable (
137 ISCSI_INITIATOR_NAME_VAR_NAME
,
138 &gEfiIScsiInitiatorNameProtocolGuid
,
139 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,