3 Copyright (c) 2007 Intel Corporation. All rights reserved
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
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
,