2 Implementation for EFI iSCSI Initiator Name Protocol.
4 Copyright (c) 2004 - 2008, Intel Corporation.<BR>
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.
15 #include "IScsiImpl.h"
17 EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName
= {
18 IScsiGetInitiatorName
,
23 Retrieves the current set value of iSCSI Initiator Name.
25 @param[in] This Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
26 @param[in, out] BufferSize Size of the buffer in bytes pointed to by Buffer / Actual size of the
28 @param[out] Buffer Pointer to the buffer for data to be read.
30 @retval EFI_SUCCESS Data was successfully retrieved into the provided buffer and the
31 BufferSize was sufficient to handle the iSCSI initiator name.
32 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the result.
33 @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL.
34 @retval EFI_DEVICE_ERROR The iSCSI initiator name could not be retrieved due to a hardware error.
35 @retval Others Other errors as indicated.
39 IScsiGetInitiatorName (
40 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
41 IN OUT UINTN
*BufferSize
,
47 if ((BufferSize
== NULL
) || (Buffer
== NULL
)) {
48 return EFI_INVALID_PARAMETER
;
51 Status
= gRT
->GetVariable (
52 ISCSI_INITIATOR_NAME_VAR_NAME
,
53 &gEfiIScsiInitiatorNameProtocolGuid
,
63 Sets the iSCSI Initiator Name.
65 @param[in] This Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
66 @param[in, out] BufferSize Size of the buffer in bytes pointed to by Buffer.
67 @param[in] Buffer Pointer to the buffer for data to be written.
69 @retval EFI_SUCCESS Data was successfully stored by the protocol.
70 @retval EFI_UNSUPPORTED Platform policies do not allow for data to be written.
71 Currently not implemented.
72 @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL, or BufferSize exceeds the maximum allowed limit.
73 @retval EFI_DEVICE_ERROR The data could not be stored due to a hardware error.
74 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the data.
75 @retval EFI_PROTOCOL_ERROR Input iSCSI initiator name does not adhere to RFC 3720
76 (and other related protocols).
77 @retval Others Other errors as indicated.
81 IScsiSetInitiatorName (
82 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
83 IN OUT UINTN
*BufferSize
,
89 if ((BufferSize
== NULL
) || (Buffer
== NULL
)) {
90 return EFI_INVALID_PARAMETER
;
93 if (*BufferSize
> ISCSI_NAME_MAX_SIZE
) {
94 *BufferSize
= ISCSI_NAME_MAX_SIZE
;
95 return EFI_INVALID_PARAMETER
;
98 // only support iqn iSCSI names.
100 Status
= IScsiNormalizeName ((CHAR8
*) Buffer
, *BufferSize
- 1);
101 if (EFI_ERROR (Status
)) {
105 Status
= gRT
->SetVariable (
106 ISCSI_INITIATOR_NAME_VAR_NAME
,
107 &gEfiIScsiInitiatorNameProtocolGuid
,
108 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,