35 UINT16 IScsiRootPathIdLen;
45 ConfigNvData = &ConfigData->SessionConfigData;
46 ConfigNvData->DnsMode =
FALSE;
50 IScsiRootPathIdLen = (UINT16)
AsciiStrLen (ISCSI_ROOT_PATH_ID);
52 if ((Length <= IScsiRootPathIdLen) ||
53 (
CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0))
61 RootPath = RootPath + IScsiRootPathIdLen;
62 Length = (UINT16)(Length - IScsiRootPathIdLen);
66 return EFI_OUT_OF_RESOURCES;
69 CopyMem (TmpStr, RootPath, Length);
70 TmpStr[Length] =
'\0';
74 ZeroMem (&Fields[0],
sizeof (Fields));
79 if (TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_START_DELIMITER) {
83 ConfigNvData->DnsMode =
TRUE;
88 Fields[RP_FIELD_IDX_SERVERNAME].Str = &TmpStr[Index];
90 if (!ConfigNvData->DnsMode) {
91 while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER) && (Index < Length)) {
101 while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) {
108 TmpStr[Index] =
'\0';
112 Fields[RP_FIELD_IDX_SERVERNAME].Len = (UINT8)
AsciiStrLen (Fields[RP_FIELD_IDX_SERVERNAME].Str);
117 for (FieldIndex = 1; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {
118 if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) {
119 Fields[FieldIndex].Str = &TmpStr[Index];
122 while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) {
126 if (TmpStr[Index] == ISCSI_ROOT_PATH_FIELD_DELIMITER) {
127 if (FieldIndex != RP_FIELD_IDX_TARGETNAME) {
128 TmpStr[Index] =
'\0';
132 if (Fields[FieldIndex].Str !=
NULL) {
133 Fields[FieldIndex].Len = (UINT8)
AsciiStrLen (Fields[FieldIndex].Str);
138 if (FieldIndex != RP_FIELD_IDX_MAX) {
139 Status = EFI_INVALID_PARAMETER;
143 if ((Fields[RP_FIELD_IDX_SERVERNAME].Str ==
NULL) ||
144 (Fields[RP_FIELD_IDX_TARGETNAME].Str ==
NULL) ||
145 (Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
148 Status = EFI_INVALID_PARAMETER;
155 Field = &Fields[RP_FIELD_IDX_SERVERNAME];
156 if (ConfigNvData->IpMode < IP_MODE_AUTOCONFIG) {
157 IpMode = ConfigNvData->IpMode;
159 IpMode = ConfigData->AutoConfigureMode;
165 if (ConfigNvData->DnsMode) {
166 if ((Field->Len + 2) >
sizeof (ConfigNvData->TargetUrl)) {
167 return EFI_INVALID_PARAMETER;
170 CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len);
171 ConfigNvData->TargetUrl[Field->Len + 1] =
'\0';
173 ZeroMem (&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl));
177 if (EFI_ERROR (Status)) {
185 Field = &Fields[RP_FIELD_IDX_PROTOCOL];
186 if ((Field->Str !=
NULL) && ((*(Field->Str) -
'0') != EFI_IP_PROTO_TCP)) {
187 Status = EFI_INVALID_PARAMETER;
194 Field = &Fields[RP_FIELD_IDX_PORT];
195 if (Field->Str !=
NULL) {
198 ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
204 Field = &Fields[RP_FIELD_IDX_LUN];
205 if (Field->Str !=
NULL) {
207 if (EFI_ERROR (Status)) {
211 ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));
217 Field = &Fields[RP_FIELD_IDX_TARGETNAME];
219 if (
AsciiStrLen (Field->Str) > ISCSI_NAME_MAX_SIZE - 1) {
220 Status = EFI_INVALID_PARAMETER;
228 if (EFI_ERROR (Status)) {
232 AsciiStrCpyS (ConfigNvData->TargetName, ISCSI_NAME_MAX_SIZE, Field->Str);
284 Status = This->Parse (This, Packet, &OptionCount,
NULL);
285 if (Status != EFI_BUFFER_TOO_SMALL) {
286 return EFI_NOT_READY;
290 if (OptionList ==
NULL) {
291 return EFI_NOT_READY;
294 Status = This->Parse (This, Packet, &OptionCount, OptionList);
295 if (EFI_ERROR (Status)) {
296 Status = EFI_NOT_READY;
302 for (Index = 0; Index < OptionCount; Index++) {
303 OptionList[Index]->
OpCode = NTOHS (OptionList[Index]->OpCode);
304 OptionList[Index]->
OpLen = NTOHS (OptionList[Index]->OpLen);
309 if (OptionList[Index]->OpCode == DHCP6_OPT_DNS_SERVERS) {
310 if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
311 Status = EFI_UNSUPPORTED;
320 if (OptionList[Index]->OpLen > 16) {
326 }
else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_URL) {
330 BootFileOpt = OptionList[Index];
331 }
else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_PARAM) {
335 if (OptionList[Index]->OpLen < 18) {
336 Status = EFI_UNSUPPORTED;
343 CopyMem (&ParaLen, &OptionList[Index]->Data[0],
sizeof (UINT16));
344 if (NTOHS (ParaLen) != 16) {
345 Status = EFI_UNSUPPORTED;
353 if (BootFileOpt ==
NULL) {
354 Status = EFI_UNSUPPORTED;
362 (CHAR8 *)BootFileOpt->
Data,
412 AsciiPrint (
"\n Error: Could not detect network connection.\n");
419 if (!ConfigData->SessionConfigData.TargetInfoFromDhcp) {
434 &gEfiDhcp6ServiceBindingProtocolGuid,
437 if (EFI_ERROR (Status)) {
441 Status =
gBS->OpenProtocol (
443 &gEfiDhcp6ProtocolGuid,
447 EFI_OPEN_PROTOCOL_BY_DRIVER
449 if (EFI_ERROR (Status)) {
455 Status = EFI_OUT_OF_RESOURCES;
463 Oro->
OpCode = HTONS (DHCP6_OPT_ORO);
464 Oro->
OpLen = HTONS (2 * 3);
465 Oro->
Data[1] = DHCP6_OPT_DNS_SERVERS;
466 Oro->
Data[3] = DHCP6_OPT_BOOT_FILE_URL;
467 Oro->
Data[5] = DHCP6_OPT_BOOT_FILE_PARAM;
469 InfoReqReXmit.
Irt = 4;
470 InfoReqReXmit.
Mrc = 1;
471 InfoReqReXmit.
Mrt = 10;
472 InfoReqReXmit.
Mrd = 30;
474 Status = Dhcp6->InfoRequest (
485 if (Status == EFI_NO_MAPPING) {
486 Status =
gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK,
NULL,
NULL, &Timer);
487 if (EFI_ERROR (Status)) {
491 Status =
gBS->SetTimer (
497 if (EFI_ERROR (Status)) {
502 TimerStatus =
gBS->CheckEvent (Timer);
504 if (!EFI_ERROR (TimerStatus)) {
505 Status = Dhcp6->InfoRequest (
517 }
while (TimerStatus == EFI_NOT_READY);
527 gBS->CloseEvent (Timer);
533 &gEfiDhcp6ProtocolGuid,
542 &gEfiDhcp6ServiceBindingProtocolGuid,
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
UINTN EFIAPI AsciiStrDecimalToUintn(IN CONST CHAR8 *String)
RETURN_STATUS EFIAPI AsciiStrCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI IScsiDhcp6ParseReply(IN EFI_DHCP6_PROTOCOL *This, IN VOID *Context, IN EFI_DHCP6_PACKET *Packet)
EFI_STATUS IScsiDhcp6ExtractRootPath(IN CHAR8 *RootPath, IN UINT16 Length, IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData)
EFI_STATUS IScsiDoDhcp6(IN EFI_HANDLE Image, IN EFI_HANDLE Controller, IN OUT ISCSI_ATTEMPT_CONFIG_NVDATA *ConfigData)
#define ISCSI_GET_MAPPING_TIMEOUT
EFI_STATUS IScsiAsciiStrToIp(IN CHAR8 *Str, IN UINT8 IpMode, OUT EFI_IP_ADDRESS *Ip)
EFI_STATUS IScsiAsciiStrToLun(IN CHAR8 *Str, OUT UINT8 *Lun)
EFI_STATUS IScsiNormalizeName(IN OUT CHAR8 *Name, IN UINTN Len)
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
EFI_STATUS EFIAPI NetLibDetectMediaWaitTimeout(IN EFI_HANDLE ServiceHandle, IN UINT64 Timeout, OUT EFI_STATUS *MediaState)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI Exit(IN EFI_STATUS Status)
UINTN EFIAPI AsciiPrint(IN CONST CHAR8 *Format,...)