]>
Commit | Line | Data |
---|---|---|
12618416 | 1 | /** @file\r |
2 | Implementation for EFI iSCSI Initiator Name Protocol.\r | |
6a690e23 | 3 | \r |
9fd6fde8 | 4 | Copyright (c) 2004 - 2008, Intel Corporation.<BR>\r |
7a444476 | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
6a690e23 | 12 | \r |
12618416 | 13 | **/\r |
6a690e23 | 14 | \r |
15 | #include "IScsiImpl.h"\r | |
16 | \r | |
17 | EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName = {\r | |
18 | IScsiGetInitiatorName,\r | |
19 | IScsiSetInitiatorName\r | |
20 | };\r | |
21 | \r | |
12618416 | 22 | /**\r |
9fd6fde8 | 23 | Retrieves the current set value of iSCSI Initiator Name.\r |
24 | \r | |
25 | @param[in] This Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.\r | |
26 | @param[in, out] BufferSize Size of the buffer in bytes pointed to by Buffer / Actual size of the\r | |
27 | variable data buffer.\r | |
28 | @param[out] Buffer Pointer to the buffer for data to be read.\r | |
29 | \r | |
30 | @retval EFI_SUCCESS Data was successfully retrieved into the provided buffer and the\r | |
31 | BufferSize was sufficient to handle the iSCSI initiator name\r | |
32 | @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the result.\r | |
33 | @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL.\r | |
34 | @retval EFI_DEVICE_ERROR The iSCSI initiator name could not be retrieved due to a hardware error.\r | |
35 | @retval Others Some unexpected error happened.\r | |
12618416 | 36 | **/\r |
6a690e23 | 37 | EFI_STATUS\r |
38 | EFIAPI\r | |
39 | IScsiGetInitiatorName (\r | |
40 | IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,\r | |
41 | IN OUT UINTN *BufferSize,\r | |
42 | OUT VOID *Buffer\r | |
43 | )\r | |
6a690e23 | 44 | {\r |
45 | EFI_STATUS Status;\r | |
46 | \r | |
47 | if ((BufferSize == NULL) || (Buffer == NULL)) {\r | |
48 | return EFI_INVALID_PARAMETER;\r | |
49 | }\r | |
50 | \r | |
51 | Status = gRT->GetVariable (\r | |
52 | ISCSI_INITIATOR_NAME_VAR_NAME,\r | |
53 | &gEfiIScsiInitiatorNameProtocolGuid,\r | |
54 | NULL,\r | |
55 | BufferSize,\r | |
56 | Buffer\r | |
57 | );\r | |
58 | \r | |
59 | return Status;\r | |
60 | }\r | |
61 | \r | |
12618416 | 62 | /**\r |
9fd6fde8 | 63 | Sets the iSCSI Initiator Name.\r |
12618416 | 64 | \r |
9fd6fde8 | 65 | @param[in] This Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.\r |
66 | @param[in, out] BufferSize Size of the buffer in bytes pointed to by Buffer.\r | |
67 | @param[in] Buffer Pointer to the buffer for data to be written.\r | |
12618416 | 68 | \r |
12618416 | 69 | @retval EFI_SUCCESS Data was successfully stored by the protocol.\r |
12618416 | 70 | @retval EFI_UNSUPPORTED Platform policies do not allow for data to be written.\r |
9fd6fde8 | 71 | Currently not implemented.\r |
72 | @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL, or BufferSize exceeds the maximum allowed limit.\r | |
12618416 | 73 | @retval EFI_DEVICE_ERROR The data could not be stored due to a hardware error.\r |
12618416 | 74 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the data.\r |
9fd6fde8 | 75 | @retval EFI_PROTOCOL_ERROR Input iSCSI initiator name does not adhere to RFC 3720\r |
76 | (and other related protocols)\r | |
77 | @retval Others Some unexpected error happened.\r | |
12618416 | 78 | **/\r |
79 | EFI_STATUS\r | |
80 | EFIAPI\r | |
81 | IScsiSetInitiatorName (\r | |
82 | IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,\r | |
83 | IN OUT UINTN *BufferSize,\r | |
9fd6fde8 | 84 | IN VOID *Buffer\r |
12618416 | 85 | )\r |
6a690e23 | 86 | {\r |
87 | EFI_STATUS Status;\r | |
88 | \r | |
89 | if ((BufferSize == NULL) || (Buffer == NULL)) {\r | |
90 | return EFI_INVALID_PARAMETER;\r | |
91 | }\r | |
92 | \r | |
93 | if (*BufferSize > ISCSI_NAME_MAX_SIZE) {\r | |
94 | *BufferSize = ISCSI_NAME_MAX_SIZE;\r | |
95 | return EFI_INVALID_PARAMETER;\r | |
96 | }\r | |
97 | //\r | |
98 | // only support iqn iSCSI names.\r | |
99 | //\r | |
100 | Status = IScsiNormalizeName ((CHAR8 *) Buffer, *BufferSize - 1);\r | |
101 | if (EFI_ERROR (Status)) {\r | |
102 | return Status;\r | |
103 | }\r | |
104 | \r | |
105 | Status = gRT->SetVariable (\r | |
106 | ISCSI_INITIATOR_NAME_VAR_NAME,\r | |
107 | &gEfiIScsiInitiatorNameProtocolGuid,\r | |
108 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
109 | *BufferSize,\r | |
110 | Buffer\r | |
111 | );\r | |
112 | \r | |
113 | return Status;\r | |
114 | }\r |