]>
Commit | Line | Data |
---|---|---|
6a690e23 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2007 Intel Corporation. All rights reserved\r | |
4 | This software and associated documentation (if any) is furnished\r | |
5 | under a license and may only be used or copied in accordance\r | |
6 | with the terms of the license. Except as permitted by such\r | |
7 | license, no part of this software or documentation may be\r | |
8 | reproduced, stored in a retrieval system, or transmitted in any\r | |
9 | form or by any means without the express written consent of\r | |
10 | Intel Corporation.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | IScsiInitiatorName.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Implementation for EFI iSCSI Initiator Name Protocol.\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "IScsiImpl.h"\r | |
23 | \r | |
24 | EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName = {\r | |
25 | IScsiGetInitiatorName,\r | |
26 | IScsiSetInitiatorName\r | |
27 | };\r | |
28 | \r | |
29 | EFI_STATUS\r | |
30 | EFIAPI\r | |
31 | IScsiGetInitiatorName (\r | |
32 | IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,\r | |
33 | IN OUT UINTN *BufferSize,\r | |
34 | OUT VOID *Buffer\r | |
35 | )\r | |
36 | /*++\r | |
37 | \r | |
38 | Routine Description:\r | |
39 | \r | |
40 | Retrieves the current set value of iSCSI Initiator Name. \r | |
41 | \r | |
42 | Arguments:\r | |
43 | \r | |
44 | This - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.\r | |
45 | BufferSize - Size of the buffer in bytes pointed to by Buffer / Actual size of\r | |
46 | the variable data buffer.\r | |
47 | Buffer - Pointer to the buffer for data to be read.\r | |
48 | \r | |
49 | Returns:\r | |
50 | \r | |
51 | EFI_SUCCESS - Data was successfully retrieved into the provided \r | |
52 | buffer and the BufferSize was sufficient to handle the\r | |
53 | iSCSI initiator name.\r | |
54 | EFI_BUFFER_TOO_SMALL - BufferSize is too small for the result. BufferSize will\r | |
55 | be updated with the size required to complete the request.\r | |
56 | Buffer will not be affected.\r | |
57 | EFI_INVALID_PARAMETER - BufferSize is NULL. BufferSize and Buffer will not be\r | |
58 | affected.\r | |
59 | EFI_INVALID_PARAMETER - Buffer is NULL. BufferSize and Buffer will not be\r | |
60 | affected.\r | |
61 | EFI_DEVICE_ERROR - The iSCSI initiator name could not be retrieved due to\r | |
62 | a hardware error.\r | |
63 | \r | |
64 | --*/\r | |
65 | {\r | |
66 | EFI_STATUS Status;\r | |
67 | \r | |
68 | if ((BufferSize == NULL) || (Buffer == NULL)) {\r | |
69 | return EFI_INVALID_PARAMETER;\r | |
70 | }\r | |
71 | \r | |
72 | Status = gRT->GetVariable (\r | |
73 | ISCSI_INITIATOR_NAME_VAR_NAME,\r | |
74 | &gEfiIScsiInitiatorNameProtocolGuid,\r | |
75 | NULL,\r | |
76 | BufferSize,\r | |
77 | Buffer\r | |
78 | );\r | |
79 | \r | |
80 | return Status;\r | |
81 | }\r | |
82 | \r | |
83 | EFI_STATUS\r | |
84 | EFIAPI\r | |
85 | IScsiSetInitiatorName (\r | |
86 | IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,\r | |
87 | IN OUT UINTN *BufferSize,\r | |
88 | OUT VOID *Buffer\r | |
89 | )\r | |
90 | /*++\r | |
91 | \r | |
92 | Routine Description:\r | |
93 | \r | |
94 | Sets the iSSI Initiator Name. \r | |
95 | \r | |
96 | Arguments:\r | |
97 | \r | |
98 | This - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.\r | |
99 | BufferSize - Size of the buffer in bytes pointed to by Buffer.\r | |
100 | Buffer - Pointer to the buffer for data to be written.\r | |
101 | \r | |
102 | Returns:\r | |
103 | \r | |
104 | EFI_SUCCESS - Data was successfully stored by the protocol.\r | |
105 | EFI_UNSUPPORTED - Platform policies do not allow for data to be written.\r | |
106 | EFI_INVALID_PARAMETER - BufferSize exceeds the maximum allowed limit.\r | |
107 | BufferSize will be updated with the maximum size\r | |
108 | required to complete the request.\r | |
109 | EFI_INVALID_PARAMETER - Buffersize is NULL. BufferSize and Buffer will not be\r | |
110 | affected.\r | |
111 | EFI_INVALID_PARAMETER - Buffer is NULL. BufferSize and Buffer will not be affected.\r | |
112 | EFI_DEVICE_ERROR - The data could not be stored due to a hardware error.\r | |
113 | EFI_OUT_OF_RESOURCES - Not enough storage is available to hold the data\r | |
114 | EFI_PROTOCOL_ERROR - Input iSCSI initiator name does not adhere to RFC 3720\r | |
115 | \r | |
116 | --*/\r | |
117 | {\r | |
118 | EFI_STATUS Status;\r | |
119 | \r | |
120 | if ((BufferSize == NULL) || (Buffer == NULL)) {\r | |
121 | return EFI_INVALID_PARAMETER;\r | |
122 | }\r | |
123 | \r | |
124 | if (*BufferSize > ISCSI_NAME_MAX_SIZE) {\r | |
125 | *BufferSize = ISCSI_NAME_MAX_SIZE;\r | |
126 | return EFI_INVALID_PARAMETER;\r | |
127 | }\r | |
128 | //\r | |
129 | // only support iqn iSCSI names.\r | |
130 | //\r | |
131 | Status = IScsiNormalizeName ((CHAR8 *) Buffer, *BufferSize - 1);\r | |
132 | if (EFI_ERROR (Status)) {\r | |
133 | return Status;\r | |
134 | }\r | |
135 | \r | |
136 | Status = gRT->SetVariable (\r | |
137 | ISCSI_INITIATOR_NAME_VAR_NAME,\r | |
138 | &gEfiIScsiInitiatorNameProtocolGuid,\r | |
139 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
140 | *BufferSize,\r | |
141 | Buffer\r | |
142 | );\r | |
143 | \r | |
144 | return Status;\r | |
145 | }\r |