Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103761
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
-
Property svn:mergeinfo
set to (toggle deleted branches)
/vendor/edk2/current 103735-103757
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/ComponentName.c
r48674 r58459 2 2 UEFI Component Name(2) protocol implementation for Dhcp6 driver. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 173 173 }; 174 174 175 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gDhcp6ControllerNameTable = NULL; 176 177 CHAR16 *mDhcp6ControllerName[] = { 178 L"DHCPv6 (State=0, Init)", 179 L"DHCPv6 (State=1, Selecting)", 180 L"DHCPv6 (State=2, Requesting)", 181 L"DHCPv6 (State=3, Declining)", 182 L"DHCPv6 (State=4, Confirming)", 183 L"DHCPv6 (State=5, Releasing)", 184 L"DHCPv6 (State=6, Bound)", 185 L"DHCPv6 (State=7, Renewing)", 186 L"DHCPv6 (State=8, Rebinding)" 187 }; 175 188 176 189 /** … … 230 243 } 231 244 245 /** 246 Update the component name for the Dhcp6 child handle. 247 248 @param Dhcp6[in] A pointer to the EFI_DHCP6_PROTOCOL. 249 250 251 @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. 252 @retval EFI_INVALID_PARAMETER The input parameter is invalid. 253 254 **/ 255 EFI_STATUS 256 UpdateName ( 257 IN EFI_DHCP6_PROTOCOL *Dhcp6 258 ) 259 { 260 EFI_STATUS Status; 261 EFI_DHCP6_MODE_DATA Dhcp6ModeData; 262 CHAR16 *HandleName; 263 264 if (Dhcp6 == NULL) { 265 return EFI_INVALID_PARAMETER; 266 } 267 268 // 269 // Format the child name into the string buffer. 270 // 271 Status = Dhcp6->GetModeData (Dhcp6, &Dhcp6ModeData, NULL); 272 if (EFI_ERROR (Status)) { 273 return Status; 274 } 275 276 if (gDhcp6ControllerNameTable != NULL) { 277 FreeUnicodeStringTable (gDhcp6ControllerNameTable); 278 gDhcp6ControllerNameTable = NULL; 279 } 280 281 if (Dhcp6ModeData.Ia == NULL) { 282 HandleName = L"DHCPv6 (No configured IA)"; 283 } else { 284 if (Dhcp6ModeData.Ia->State > Dhcp6Rebinding) { 285 return EFI_DEVICE_ERROR; 286 } 287 HandleName = mDhcp6ControllerName[Dhcp6ModeData.Ia->State]; 288 } 289 290 Status = AddUnicodeString2 ( 291 "eng", 292 gDhcp6ComponentName.SupportedLanguages, 293 &gDhcp6ControllerNameTable, 294 HandleName, 295 TRUE 296 ); 297 if (EFI_ERROR (Status)) { 298 return Status; 299 } 300 301 return AddUnicodeString2 ( 302 "en", 303 gDhcp6ComponentName2.SupportedLanguages, 304 &gDhcp6ControllerNameTable, 305 HandleName, 306 FALSE 307 ); 308 } 232 309 233 310 /** … … 309 386 ) 310 387 { 311 return EFI_UNSUPPORTED; 388 EFI_STATUS Status; 389 EFI_DHCP6_PROTOCOL *Dhcp6; 390 391 // 392 // Only provide names for child handles. 393 // 394 if (ChildHandle == NULL) { 395 return EFI_UNSUPPORTED; 396 } 397 398 // 399 // Make sure this driver produced ChildHandle 400 // 401 Status = EfiTestChildHandle ( 402 ControllerHandle, 403 ChildHandle, 404 &gEfiUdp6ProtocolGuid 405 ); 406 if (EFI_ERROR (Status)) { 407 return Status; 408 } 409 410 // 411 // Retrieve an instance of a produced protocol from ChildHandle 412 // 413 Status = gBS->OpenProtocol ( 414 ChildHandle, 415 &gEfiDhcp6ProtocolGuid, 416 (VOID **)&Dhcp6, 417 NULL, 418 NULL, 419 EFI_OPEN_PROTOCOL_GET_PROTOCOL 420 ); 421 if (EFI_ERROR (Status)) { 422 return Status; 423 } 424 425 // 426 // Update the component name for this child handle. 427 // 428 Status = UpdateName (Dhcp6); 429 if (EFI_ERROR (Status)) { 430 return Status; 431 } 432 433 return LookupUnicodeString2 ( 434 Language, 435 This->SupportedLanguages, 436 gDhcp6ControllerNameTable, 437 ControllerName, 438 (BOOLEAN)(This == &gDhcp6ComponentName) 439 ); 312 440 } 441 -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
r48674 r58459 3 3 implementationfor for Dhcp6 Driver. 4 4 5 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 6 6 7 7 This program and the accompanying materials … … 32 32 }; 33 33 34 35 34 /** 36 35 Configure the default Udp6Io to receive all the DHCP6 traffic … … 83 82 84 83 /** 85 Dest ory the Dhcp6 service. The Dhcp6 service may be partly initialized,84 Destroy the Dhcp6 service. The Dhcp6 service may be partly initialized, 86 85 or partly destroyed. If a resource is destroyed, it is marked as such in 87 86 case the destroy failed and being called again later. … … 96 95 { 97 96 // 98 // All children instances should have been already dest oryed here.97 // All children instances should have been already destroyed here. 99 98 // 100 99 ASSERT (Service->NumOfChild == 0); … … 133 132 { 134 133 DHCP6_SERVICE *Dhcp6Srv; 134 EFI_STATUS Status; 135 135 136 136 *Service = NULL; … … 155 155 // 156 156 Dhcp6Srv->Signature = DHCP6_SERVICE_SIGNATURE; 157 Dhcp6Srv->InDestory = FALSE;158 157 Dhcp6Srv->Controller = Controller; 159 158 Dhcp6Srv->Image = ImageHandle; … … 165 164 sizeof (EFI_SERVICE_BINDING_PROTOCOL) 166 165 ); 166 167 // 168 // Locate Ip6->Ip6Config and store it for get IP6 Duplicate Address Detection transmits. 169 // 170 Status = gBS->HandleProtocol ( 171 Controller, 172 &gEfiIp6ConfigProtocolGuid, 173 (VOID **) &Dhcp6Srv->Ip6Cfg 174 ); 175 if (EFI_ERROR (Status)) { 176 FreePool (Dhcp6Srv); 177 return Status; 178 } 167 179 168 180 // … … 281 293 Dhcp6Ins->UdpSts = EFI_ALREADY_STARTED; 282 294 Dhcp6Ins->Service = Service; 283 Dhcp6Ins->InDest ory = FALSE;295 Dhcp6Ins->InDestroy = FALSE; 284 296 Dhcp6Ins->MediaPresent = TRUE; 285 297 … … 313 325 314 326 return EFI_SUCCESS; 327 } 328 329 /** 330 Callback function which provided by user to remove one node in NetDestroyLinkList process. 331 332 @param[in] Entry The entry to be removed. 333 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 334 335 @retval EFI_SUCCESS The entry has been removed successfully. 336 @retval Others Fail to remove the entry. 337 338 **/ 339 EFI_STATUS 340 EFIAPI 341 Dhcp6DestroyChildEntry ( 342 IN LIST_ENTRY *Entry, 343 IN VOID *Context 344 ) 345 { 346 DHCP6_INSTANCE *Instance; 347 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 348 349 if (Entry == NULL || Context == NULL) { 350 return EFI_INVALID_PARAMETER; 351 } 352 353 Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP6_INSTANCE, Link, DHCP6_INSTANCE_SIGNATURE); 354 ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; 355 356 return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 315 357 } 316 358 … … 485 527 { 486 528 EFI_STATUS Status; 487 EFI_TPL OldTpl;488 529 EFI_HANDLE NicHandle; 489 530 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 490 531 DHCP6_SERVICE *Service; 491 DHCP6_INSTANCE *Instance; 532 LIST_ENTRY *List; 533 UINTN ListLength; 492 534 493 535 // … … 497 539 498 540 if (NicHandle == NULL) { 499 return EFI_ DEVICE_ERROR;541 return EFI_SUCCESS; 500 542 } 501 543 … … 514 556 515 557 Service = DHCP6_SERVICE_FROM_THIS (ServiceBinding); 516 517 if (Service->InDestory) { 518 return EFI_SUCCESS; 519 } 520 521 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 522 523 if (NumberOfChildren == 0) { 558 if (!IsListEmpty (&Service->Child)) { 524 559 // 525 // Destory the service itself if no child instance left. 560 // Destroy all the children instances before destory the service. 561 // 562 List = &Service->Child; 563 Status = NetDestroyLinkList ( 564 List, 565 Dhcp6DestroyChildEntry, 566 ServiceBinding, 567 &ListLength 568 ); 569 if (EFI_ERROR (Status) || ListLength != 0) { 570 Status = EFI_DEVICE_ERROR; 571 } 572 } 573 574 if (NumberOfChildren == 0 && !IsListEmpty (&Service->Child)) { 575 Status = EFI_DEVICE_ERROR; 576 } 577 578 if (NumberOfChildren == 0 && IsListEmpty (&Service->Child)) { 526 579 // 527 Service->InDestory = TRUE;528 580 // Destroy the service itself if no child instance left. 581 // 529 582 Status = gBS->UninstallProtocolInterface ( 530 583 NicHandle, … … 532 585 ServiceBinding 533 586 ); 534 535 587 if (EFI_ERROR (Status)) { 536 Service->InDestory = FALSE;537 588 goto ON_EXIT; 538 589 } 539 590 540 591 Dhcp6DestroyService (Service); 541 542 } else { 543 // 544 // Destory all the children instances before destory the service. 545 // 546 while (!IsListEmpty (&Service->Child)) { 547 Instance = NET_LIST_HEAD (&Service->Child, DHCP6_INSTANCE, Link); 548 ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 549 } 550 // 551 // Any of child failed to be destroyed. 552 // 553 if (Service->NumOfChild != 0) { 554 Status = EFI_DEVICE_ERROR; 555 } 556 } 557 592 Status = EFI_SUCCESS; 593 } 594 558 595 ON_EXIT: 559 gBS->RestoreTPL (OldTpl);560 596 return Status; 561 597 } … … 734 770 } 735 771 736 if (Instance->InDest ory) {772 if (Instance->InDestroy) { 737 773 return EFI_SUCCESS; 738 774 } … … 740 776 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 741 777 742 Instance->InDest ory = TRUE;778 Instance->InDestroy = TRUE; 743 779 744 780 Status = gBS->CloseProtocol ( … … 750 786 751 787 if (EFI_ERROR (Status)) { 752 Instance->InDest ory = FALSE;788 Instance->InDestroy = FALSE; 753 789 gBS->RestoreTPL (OldTpl); 754 790 return Status; … … 758 794 // Uninstall the MTFTP6 protocol first to enable a top down destruction. 759 795 // 796 gBS->RestoreTPL (OldTpl); 760 797 Status = gBS->UninstallProtocolInterface ( 761 798 ChildHandle, … … 763 800 Dhcp6 764 801 ); 765 766 if (EFI_ERROR (Status)) { 767 Instance->InDest ory = FALSE;802 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 803 if (EFI_ERROR (Status)) { 804 Instance->InDestroy = FALSE; 768 805 gBS->RestoreTPL (OldTpl); 769 806 return Status; … … 776 813 Service->NumOfChild--; 777 814 815 gBS->RestoreTPL (OldTpl); 816 778 817 Dhcp6DestroyInstance (Instance); 779 780 gBS->RestoreTPL (OldTpl);781 782 818 return EFI_SUCCESS; 783 819 } -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.h
r48674 r58459 3 3 declaration for Dhcp6 Driver. 4 4 5 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 6 6 7 7 This program and the accompanying materials … … 22 22 extern EFI_COMPONENT_NAME_PROTOCOL gDhcp6ComponentName; 23 23 extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2; 24 extern EFI_UNICODE_STRING_TABLE *gDhcp6ControllerNameTable; 24 25 25 26 /** -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf
r48674 r58459 1 1 ## @file 2 # Component description file for Dhcp6 module. 2 # Client-side DHCPv6 services. 3 # 4 # This driver produces EFI DHCPv6 Protocol which is used to get IPv6 addresses 5 # and other configuration parameters from DHCPv6 servers. 3 6 # 4 # Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>7 # Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 8 # 6 9 # This program and the accompanying materials … … 22 25 ENTRY_POINT = Dhcp6DriverEntryPoint 23 26 UNLOAD_IMAGE = NetLibDefaultUnload 27 MODULE_UNI_FILE = Dhcp6Dxe.uni 28 24 29 # 25 30 # The following information is for reference only and not required by the build tools. … … 63 68 64 69 [Protocols] 65 gEfiUdp6ServiceBindingProtocolGuid 66 gEfiUdp6ProtocolGuid 67 gEfiDhcp6ServiceBindingProtocolGuid 68 gEfiDhcp6ProtocolGuid 70 gEfiUdp6ServiceBindingProtocolGuid ## TO_START 71 gEfiUdp6ProtocolGuid ## TO_START 72 gEfiDhcp6ServiceBindingProtocolGuid ## BY_START 73 gEfiDhcp6ProtocolGuid ## BY_START 74 gEfiIp6ConfigProtocolGuid ## TO_START 69 75 76 [UserExtensions.TianoCore."ExtraFiles"] 77 Dhcp6DxeExtra.uni -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c
r48674 r58459 2 2 This EFI_DHCP6_PROTOCOL interface implementation. 3 3 4 Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 105 105 106 106 // 107 // Need to clear initial time to make sure that elapsed-time108 // is set to 0 for first Solicit.109 //110 Instance->StartTime = 0;111 112 //113 107 // Send the solicit message to start S.A.R.R process. 114 108 // … … 201 195 202 196 // 203 // The instance has already been stopped.197 // No valid REPLY message received yet, cleanup this instance directly. 204 198 // 205 199 if (Instance->IaCb.Ia->State == Dhcp6Init || … … 207 201 Instance->IaCb.Ia->State == Dhcp6Requesting 208 202 ) { 209 return Status;203 goto ON_EXIT; 210 204 } 211 205 … … 216 210 217 211 Instance->UdpSts = EFI_ALREADY_STARTED; 218 Dhcp6SendReleaseMsg (Instance, Instance->IaCb.Ia); 219 212 Status = Dhcp6SendReleaseMsg (Instance, Instance->IaCb.Ia); 220 213 gBS->RestoreTPL (OldTpl); 214 if (EFI_ERROR (Status)) { 215 goto ON_EXIT; 216 } 221 217 222 218 // … … 230 226 Status = Instance->UdpSts; 231 227 } 232 228 229 ON_EXIT: 233 230 // 234 231 // Clean up the session data for the released Ia. … … 605 602 { 606 603 EFI_STATUS Status; 607 EFI_TPL OldTpl;608 604 DHCP6_INSTANCE *Instance; 609 605 DHCP6_SERVICE *Service; 610 DHCP6_INF_CB *InfCb;611 606 UINTN Index; 607 EFI_EVENT Timer; 608 EFI_STATUS TimerStatus; 609 UINTN GetMappingTimeOut; 612 610 613 611 if (This == NULL || OptionRequest == NULL || Retransmission == NULL || ReplyCallback == NULL) { … … 634 632 Service = Instance->Service; 635 633 636 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 637 Instance->UdpSts = EFI_ALREADY_STARTED; 638 639 // 640 // Create and initialize the control block for the info-request. 641 // 642 InfCb = AllocateZeroPool (sizeof(DHCP6_INF_CB)); 643 644 if (InfCb == NULL) { 645 gBS->RestoreTPL (OldTpl); 646 return EFI_OUT_OF_RESOURCES; 647 } 648 649 InfCb->ReplyCallback = ReplyCallback; 650 InfCb->CallbackContext = CallbackContext; 651 InfCb->TimeoutEvent = TimeoutEvent; 652 653 InsertTailList (&Instance->InfList, &InfCb->Link); 654 655 // 656 // Send the info-request message to start exchange process. 657 // 658 Status = Dhcp6SendInfoRequestMsg ( 634 Status = Dhcp6StartInfoRequest ( 659 635 Instance, 660 InfCb,661 636 SendClientId, 662 637 OptionRequest, 663 638 OptionCount, 664 639 OptionList, 665 Retransmission 640 Retransmission, 641 TimeoutEvent, 642 ReplyCallback, 643 CallbackContext 666 644 ); 667 645 if (Status == EFI_NO_MAPPING) { 646 // 647 // The link local address is not ready, wait for some time and restart 648 // the DHCP6 information request process. 649 // 650 Status = Dhcp6GetMappingTimeOut(Service->Ip6Cfg, &GetMappingTimeOut); 651 if (EFI_ERROR(Status)) { 652 return Status; 653 } 654 655 Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer); 656 if (EFI_ERROR (Status)) { 657 return Status; 658 } 659 660 // 661 // Start the timer, wait for link local address DAD to finish. 662 // 663 Status = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut); 664 if (EFI_ERROR (Status)) { 665 gBS->CloseEvent (Timer); 666 return Status; 667 } 668 669 do { 670 TimerStatus = gBS->CheckEvent (Timer); 671 if (!EFI_ERROR (TimerStatus)) { 672 Status = Dhcp6StartInfoRequest ( 673 Instance, 674 SendClientId, 675 OptionRequest, 676 OptionCount, 677 OptionList, 678 Retransmission, 679 TimeoutEvent, 680 ReplyCallback, 681 CallbackContext 682 ); 683 } 684 } while (TimerStatus == EFI_NOT_READY); 685 686 gBS->CloseEvent (Timer); 687 } 668 688 if (EFI_ERROR (Status)) { 669 goto ON_ERROR; 670 } 671 672 // 673 // Register receive callback for the stateless exchange process. 674 // 675 Status = UdpIoRecvDatagram( 676 Service->UdpIo, 677 Dhcp6ReceivePacket, 678 Service, 679 0 680 ); 681 682 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) { 683 goto ON_ERROR; 684 } 685 686 gBS->RestoreTPL (OldTpl); 689 return Status; 690 } 687 691 688 692 // … … 698 702 699 703 return EFI_SUCCESS; 700 701 ON_ERROR:702 703 RemoveEntryList (&InfCb->Link);704 FreePool (InfCb);705 gBS->RestoreTPL (OldTpl);706 707 return Status;708 704 } 709 705 -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
r48674 r58459 2 2 Dhcp6 internal data structure and definition declaration. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 22 22 #include <Protocol/Dhcp6.h> 23 23 #include <Protocol/Udp6.h> 24 #include <Protocol/Ip6Config.h> 24 25 #include <Protocol/ServiceBinding.h> 25 26 #include <Protocol/DriverBinding.h> … … 34 35 #include <Library/BaseLib.h> 35 36 #include <Library/NetLib.h> 37 #include <Library/PrintLib.h> 36 38 37 39 … … 245 247 UINT8 AdPref; 246 248 EFI_IPv6_ADDRESS *Unicast; 247 EFI_STATUSUdpSts;248 BOOLEAN InDest ory;249 volatile EFI_STATUS UdpSts; 250 BOOLEAN InDestroy; 249 251 BOOLEAN MediaPresent; 252 // 253 // StartTime is used to calculate the 'elapsed-time' option. Refer to RFC3315, 254 // the elapsed-time is amount of time since the client began its current DHCP transaction. 255 // 250 256 UINT64 StartTime; 251 257 }; … … 260 266 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; 261 267 EFI_SIMPLE_NETWORK_PROTOCOL *Snp; 268 EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; 262 269 EFI_DHCP6_DUID *ClientId; 263 270 UDP_IO *UdpIo; … … 265 272 LIST_ENTRY Child; 266 273 UINTN NumOfChild; 267 BOOLEAN InDestory;268 274 }; 269 275 -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
r48674 r58459 2 2 Dhcp6 internal functions implementation. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 53 53 54 54 // 55 // Save tx packet pointer, and it will be dest oryed when reply received.55 // Save tx packet pointer, and it will be destroyed when reply received. 56 56 // 57 57 TxCb->TxPacket = Packet; … … 364 364 } 365 365 366 /** 367 Check whether the TxCb is still a valid control block in the instance's retry list. 368 369 @param[in] Instance The pointer to DHCP6_INSTANCE. 370 @param[in] TxCb The control block for a transmitted message. 371 372 @retval TRUE The control block is in Instance's retry list. 373 @retval FALSE The control block is NOT in Instance's retry list. 374 375 **/ 376 BOOLEAN 377 Dhcp6IsValidTxCb ( 378 IN DHCP6_INSTANCE *Instance, 379 IN DHCP6_TX_CB *TxCb 380 ) 381 { 382 LIST_ENTRY *Entry; 383 384 NET_LIST_FOR_EACH (Entry, &Instance->TxList) { 385 if (TxCb == NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link)) { 386 return TRUE; 387 } 388 } 389 390 return FALSE; 391 } 366 392 367 393 /** … … 594 620 T1 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 8))); 595 621 T2 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 12))); 622 // 623 // Refer to RFC3155 Chapter 22.4. If a client receives an IA_NA with T1 greater than T2, 624 // and both T1 and T2 are greater than 0, the client discards the IA_NA option and processes 625 // the remainder of the message as though the server had not included the invalid IA_NA option. 626 // 627 if (T1 > T2 && T2 > 0) { 628 return EFI_DEVICE_ERROR; 629 } 596 630 IaInnerOpt = Option + 16; 597 631 IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 2))) - 12); … … 698 732 ); 699 733 if (*Option == NULL) { 700 return EFI_ DEVICE_ERROR;734 return EFI_SUCCESS; 701 735 } 702 736 … … 950 984 Instance->IaCb.Ia, 951 985 Instance->IaCb.T1, 952 Instance->IaCb.T2 986 Instance->IaCb.T2, 987 Packet->Dhcp6.Header.MessageType 953 988 ); 954 989 … … 988 1023 // 989 1024 Instance->IaCb.Ia->State = Dhcp6Selecting; 1025 // 1026 // Clear initial time for current transaction. 1027 // 1028 Instance->StartTime = 0; 990 1029 991 1030 Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); … … 1134 1173 Instance->IaCb.Ia, 1135 1174 Instance->IaCb.T1, 1136 Instance->IaCb.T2 1175 Instance->IaCb.T2, 1176 Packet->Dhcp6.Header.MessageType 1137 1177 ); 1138 1178 … … 1172 1212 // 1173 1213 Instance->IaCb.Ia->State = Dhcp6Requesting; 1214 // 1215 // Clear initial time for current transaction. 1216 // 1217 Instance->StartTime = 0; 1174 1218 1175 1219 Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); … … 1283 1327 ); 1284 1328 1285 Cursor = Dhcp6AppendIaOption (Cursor, DecIa, 0, 0 );1329 Cursor = Dhcp6AppendIaOption (Cursor, DecIa, 0, 0, Packet->Dhcp6.Header.MessageType); 1286 1330 1287 1331 // … … 1306 1350 // 1307 1351 Instance->IaCb.Ia->State = Dhcp6Declining; 1352 // 1353 // Clear initial time for current transaction. 1354 // 1355 Instance->StartTime = 0; 1308 1356 1309 1357 Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); … … 1416 1464 ); 1417 1465 1418 Cursor = Dhcp6AppendIaOption (Cursor, RelIa, 0, 0 );1466 Cursor = Dhcp6AppendIaOption (Cursor, RelIa, 0, 0, Packet->Dhcp6.Header.MessageType); 1419 1467 1420 1468 // … … 1541 1589 Instance->IaCb.Ia, 1542 1590 Instance->IaCb.T1, 1543 Instance->IaCb.T2 1591 Instance->IaCb.T2, 1592 Packet->Dhcp6.Header.MessageType 1544 1593 ); 1545 1594 … … 1613 1662 Instance->IaCb.Ia->State = State; 1614 1663 Instance->IaCb.LeaseTime = (RebindRequest) ? Instance->IaCb.T2 : Instance->IaCb.T1; 1664 // 1665 // Clear initial time for current transaction. 1666 // 1667 Instance->StartTime = 0; 1615 1668 1616 1669 Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); … … 1627 1680 } 1628 1681 1682 /** 1683 Start the information request process. 1684 1685 @param[in] Instance The pointer to the Dhcp6 instance. 1686 @param[in] SendClientId If TRUE, the client identifier option will be included in 1687 information request message. Otherwise, the client identifier 1688 option will not be included. 1689 @param[in] OptionRequest The pointer to the option request option. 1690 @param[in] OptionCount The number options in the OptionList. 1691 @param[in] OptionList The array pointers to the appended options. 1692 @param[in] Retransmission The pointer to the retransmission control. 1693 @param[in] TimeoutEvent The event of timeout. 1694 @param[in] ReplyCallback The callback function when the reply was received. 1695 @param[in] CallbackContext The pointer to the parameter passed to the callback. 1696 1697 @retval EFI_SUCCESS Start the info-request process successfully. 1698 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 1699 @retval EFI_NO_MAPPING No source address is available for use. 1700 @retval Others Failed to start the info-request process. 1701 1702 **/ 1703 EFI_STATUS 1704 Dhcp6StartInfoRequest ( 1705 IN DHCP6_INSTANCE *Instance, 1706 IN BOOLEAN SendClientId, 1707 IN EFI_DHCP6_PACKET_OPTION *OptionRequest, 1708 IN UINT32 OptionCount, 1709 IN EFI_DHCP6_PACKET_OPTION *OptionList[] OPTIONAL, 1710 IN EFI_DHCP6_RETRANSMISSION *Retransmission, 1711 IN EFI_EVENT TimeoutEvent OPTIONAL, 1712 IN EFI_DHCP6_INFO_CALLBACK ReplyCallback, 1713 IN VOID *CallbackContext OPTIONAL 1714 ) 1715 { 1716 EFI_STATUS Status; 1717 DHCP6_INF_CB *InfCb; 1718 DHCP6_SERVICE *Service; 1719 EFI_TPL OldTpl; 1720 1721 Service = Instance->Service; 1722 1723 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 1724 Instance->UdpSts = EFI_ALREADY_STARTED; 1725 // 1726 // Create and initialize the control block for the info-request. 1727 // 1728 InfCb = AllocateZeroPool (sizeof(DHCP6_INF_CB)); 1729 1730 if (InfCb == NULL) { 1731 gBS->RestoreTPL (OldTpl); 1732 return EFI_OUT_OF_RESOURCES; 1733 } 1734 1735 InfCb->ReplyCallback = ReplyCallback; 1736 InfCb->CallbackContext = CallbackContext; 1737 InfCb->TimeoutEvent = TimeoutEvent; 1738 1739 InsertTailList (&Instance->InfList, &InfCb->Link); 1740 1741 // 1742 // Send the info-request message to start exchange process. 1743 // 1744 Status = Dhcp6SendInfoRequestMsg ( 1745 Instance, 1746 InfCb, 1747 SendClientId, 1748 OptionRequest, 1749 OptionCount, 1750 OptionList, 1751 Retransmission 1752 ); 1753 1754 if (EFI_ERROR (Status)) { 1755 goto ON_ERROR; 1756 } 1757 1758 // 1759 // Register receive callback for the stateless exchange process. 1760 // 1761 Status = UdpIoRecvDatagram( 1762 Service->UdpIo, 1763 Dhcp6ReceivePacket, 1764 Service, 1765 0 1766 ); 1767 1768 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) { 1769 goto ON_ERROR; 1770 } 1771 1772 gBS->RestoreTPL (OldTpl); 1773 return EFI_SUCCESS; 1774 1775 ON_ERROR: 1776 gBS->RestoreTPL (OldTpl); 1777 RemoveEntryList (&InfCb->Link); 1778 FreePool (InfCb); 1779 1780 return Status; 1781 } 1629 1782 1630 1783 /** … … 1745 1898 Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); 1746 1899 ASSERT (Packet->Size > Packet->Length + 8); 1900 1901 // 1902 // Clear initial time for current transaction. 1903 // 1904 Instance->StartTime = 0; 1747 1905 1748 1906 // … … 1842 2000 Instance->IaCb.Ia, 1843 2001 Instance->IaCb.T1, 1844 Instance->IaCb.T2 2002 Instance->IaCb.T2, 2003 Packet->Dhcp6.Header.MessageType 1845 2004 ); 1846 2005 … … 1879 2038 // 1880 2039 Instance->IaCb.Ia->State = Dhcp6Confirming; 2040 // 2041 // Clear initial time for current transaction. 2042 // 2043 Instance->StartTime = 0; 1881 2044 1882 2045 Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); … … 1921 2084 ASSERT (Packet != NULL); 1922 2085 2086 Status = EFI_SUCCESS; 2087 1923 2088 if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) { 1924 2089 return EFI_DEVICE_ERROR; … … 1957 2122 ); 1958 2123 if (Option == NULL) { 1959 return EFI_ DEVICE_ERROR;2124 return EFI_SUCCESS; 1960 2125 } 1961 2126 } … … 1965 2130 // 1966 2131 Status = Dhcp6CallbackUser (Instance, Dhcp6RcvdReply, &Packet); 1967 1968 if (EFI_ERROR (Status)) {1969 return Status;1970 }1971 1972 //1973 // Dequeue the sent packet from retransmit list since reply received.1974 //1975 Status = Dhcp6DequeueRetry (1976 Instance,1977 Packet->Dhcp6.Header.TransactionId,1978 FALSE1979 );1980 2132 1981 2133 if (EFI_ERROR (Status)) { … … 2016 2168 Instance->StartTime = 0; 2017 2169 2018 return EFI_SUCCESS; 2170 Status = EFI_SUCCESS; 2171 goto ON_EXIT; 2019 2172 } 2020 2173 … … 2033 2186 if (!EFI_ERROR (Status)) { 2034 2187 // 2035 // Reset start time for next exchange.2036 //2037 Instance->StartTime = 0;2038 2039 //2040 2188 // No status code or no error status code means succeed to reply. 2041 2189 // 2042 2190 Status = Dhcp6UpdateIaInfo (Instance, Packet); 2043 2044 if (EFI_ERROR (Status)) { 2045 return Status; 2191 if (!EFI_ERROR (Status)) { 2192 // 2193 // Reset start time for next exchange. 2194 // 2195 Instance->StartTime = 0; 2196 2197 // 2198 // Set bound state and store the reply packet. 2199 // 2200 if (Instance->IaCb.Ia->ReplyPacket != NULL) { 2201 FreePool (Instance->IaCb.Ia->ReplyPacket); 2202 } 2203 2204 Instance->IaCb.Ia->ReplyPacket = AllocateZeroPool (Packet->Size); 2205 2206 if (Instance->IaCb.Ia->ReplyPacket == NULL) { 2207 Status = EFI_OUT_OF_RESOURCES; 2208 goto ON_EXIT; 2209 } 2210 2211 CopyMem (Instance->IaCb.Ia->ReplyPacket, Packet, Packet->Size); 2212 2213 Instance->IaCb.Ia->State = Dhcp6Bound; 2214 2215 // 2216 // For sync, set the success flag out of polling in start/renewrebind. 2217 // 2218 Instance->UdpSts = EFI_SUCCESS; 2219 2220 // 2221 // Maybe this is a new round DHCP process due to some reason, such as NotOnLink 2222 // ReplyMsg for ConfirmMsg should triger new round to acquire new address. In that 2223 // case, clear old address.ValidLifetime and append to new address. Therefore, DHCP 2224 // consumers can be notified to flush old address. 2225 // 2226 Dhcp6AppendCacheIa (Instance); 2227 2228 // 2229 // For async, signal the Ia event to inform Ia infomation update. 2230 // 2231 if (Instance->Config->IaInfoEvent != NULL) { 2232 gBS->SignalEvent (Instance->Config->IaInfoEvent); 2233 } 2234 } else if (Status == EFI_NOT_FOUND) { 2235 // 2236 // Refer to RFC3315 Chapter 18.1.8, for each IA in the original Renew or Rebind message, 2237 // the client sends a Renew or Rebind if the IA is not in the Reply message. 2238 // Return EFI_SUCCESS so we can continue to restart the Renew/Rebind process. 2239 // 2240 return EFI_SUCCESS; 2046 2241 } 2047 2048 // 2049 // Set bound state and store the reply packet. 2050 // 2051 if (Instance->IaCb.Ia->ReplyPacket != NULL) { 2052 FreePool (Instance->IaCb.Ia->ReplyPacket); 2053 } 2054 2055 Instance->IaCb.Ia->ReplyPacket = AllocateZeroPool (Packet->Size); 2056 2057 if (Instance->IaCb.Ia->ReplyPacket == NULL) { 2058 return EFI_OUT_OF_RESOURCES; 2059 } 2060 2061 CopyMem (Instance->IaCb.Ia->ReplyPacket, Packet, Packet->Size); 2062 2063 Instance->IaCb.Ia->State = Dhcp6Bound; 2064 2065 // 2066 // For sync, set the success flag out of polling in start/renewrebind. 2067 // 2068 Instance->UdpSts = EFI_SUCCESS; 2069 2070 // 2071 // Maybe this is a new round DHCP process due to some reason, such as NotOnLink 2072 // ReplyMsg for ConfirmMsg should triger new round to acquire new address. In that 2073 // case, clear old address.ValidLifetime and append to new address. Therefore, DHCP 2074 // consumers can be notified to flush old address. 2075 // 2076 Dhcp6AppendCacheIa (Instance); 2077 2078 // 2079 // For async, signal the Ia event to inform Ia infomation update. 2080 // 2081 if (Instance->Config->IaInfoEvent != NULL) { 2082 gBS->SignalEvent (Instance->Config->IaInfoEvent); 2083 } 2242 2243 goto ON_EXIT; 2244 2084 2245 } else if (Option != NULL) { 2085 2246 // … … 2127 2288 break; 2128 2289 2290 case Dhcp6StsNoBinding: 2291 if (Instance->IaCb.Ia->State == Dhcp6Renewing || Instance->IaCb.Ia->State == Dhcp6Rebinding) { 2292 // 2293 // Refer to RFC3315 Chapter 18.1.8, for each IA in the original Renew or Rebind message, the client 2294 // sends a Request message if the IA contained a Status Code option with the NoBinding status. 2295 // 2296 Status = Dhcp6SendRequestMsg(Instance); 2297 if (EFI_ERROR (Status)) { 2298 return Status; 2299 } 2300 } 2301 break; 2302 2129 2303 default: 2130 2304 // … … 2136 2310 2137 2311 return EFI_SUCCESS; 2312 2313 ON_EXIT: 2314 2315 if (!EFI_ERROR(Status)) { 2316 Status = Dhcp6DequeueRetry ( 2317 Instance, 2318 Packet->Dhcp6.Header.TransactionId, 2319 FALSE 2320 ); 2321 } 2322 2323 return Status; 2138 2324 } 2139 2325 … … 2279 2465 // See the details in the section-17.1.3 of rfc-3315. 2280 2466 // 2281 Option = Dhcp6SeekOption( 2282 Packet->Dhcp6.Option, 2283 Packet->Length - 4, 2284 Dhcp6OptStatusCode 2285 ); 2286 2287 if (Option != NULL) { 2288 StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 4))); 2289 if (StsCode != Dhcp6StsSuccess) { 2290 return EFI_DEVICE_ERROR; 2291 } 2467 Status = Dhcp6SeekStsOption ( 2468 Instance, 2469 Packet, 2470 &Option 2471 ); 2472 if (EFI_ERROR (Status)) { 2473 return EFI_DEVICE_ERROR; 2292 2474 } 2293 2475 … … 2411 2593 Status = EFI_SUCCESS; 2412 2594 2413 if (Instance-> InDestory || Instance->Config == NULL) {2595 if (Instance->Config == NULL) { 2414 2596 goto ON_CONTINUE; 2415 2597 } … … 2524 2706 IsMatched = FALSE; 2525 2707 InfCb = NULL; 2526 2527 if (Instance->InDestory) {2528 goto ON_EXIT;2529 }2530 2708 2531 2709 if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) { … … 2830 3008 // 2831 3009 Status = Dhcp6SelectAdvertiseMsg (Instance, Instance->AdSelect); 2832 if (EFI_ERROR (Status)) { 3010 if (Status == EFI_ABORTED) { 3011 goto ON_CLOSE; 3012 } else if (EFI_ERROR (Status)) { 2833 3013 TxCb->RetryCnt++; 2834 3014 } … … 2846 3026 // 2847 3027 if (TxCb->RetryCtl.Mrc != 0 && TxCb->RetryCtl.Mrc < TxCb->RetryCnt) { 3028 Status = EFI_NO_RESPONSE; 2848 3029 goto ON_CLOSE; 2849 3030 } … … 2853 3034 // 2854 3035 if (TxCb->RetryCtl.Mrd != 0 && TxCb->RetryCtl.Mrd <= TxCb->RetryLos) { 3036 Status = EFI_NO_RESPONSE; 2855 3037 goto ON_CLOSE; 2856 3038 } … … 2942 3124 ON_CLOSE: 2943 3125 2944 if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest || 3126 if (Dhcp6IsValidTxCb (Instance, TxCb) && 3127 TxCb->TxPacket != NULL && 3128 (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest || 2945 3129 TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew || 2946 TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm 3130 TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm) 2947 3131 ) { 2948 3132 // … … 2969 3153 // The failure of the others will terminate current state machine if timeout. 2970 3154 // 2971 Dhcp6CleanupSession (Instance, EFI_NO_RESPONSE);3155 Dhcp6CleanupSession (Instance, Status); 2972 3156 } 2973 3157 } -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Io.h
r48674 r58459 2 2 Dhcp6 internal functions declaration. 3 3 4 Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 128 128 IN DHCP6_INSTANCE *Instance, 129 129 IN EFI_DHCP6_IA *RelIa 130 ); 131 132 /** 133 Start the information request process. 134 135 @param[in] Instance The pointer to the Dhcp6 instance. 136 @param[in] SendClientId If TRUE, the client identifier option will be included in 137 information request message. Otherwise, the client identifier 138 option will not be included. 139 @param[in] OptionRequest The pointer to the option request option. 140 @param[in] OptionCount The number options in the OptionList. 141 @param[in] OptionList The array pointers to the appended options. 142 @param[in] Retransmission The pointer to the retransmission control. 143 @param[in] TimeoutEvent The event of timeout. 144 @param[in] ReplyCallback The callback function when the reply was received. 145 @param[in] CallbackContext The pointer to the parameter passed to the callback. 146 147 @retval EFI_SUCCESS Start the info-request process successfully. 148 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 149 @retval EFI_NO_MAPPING No source address is available for use. 150 @retval Others Failed to start the info-request process. 151 152 **/ 153 EFI_STATUS 154 Dhcp6StartInfoRequest ( 155 IN DHCP6_INSTANCE *Instance, 156 IN BOOLEAN SendClientId, 157 IN EFI_DHCP6_PACKET_OPTION *OptionRequest, 158 IN UINT32 OptionCount, 159 IN EFI_DHCP6_PACKET_OPTION *OptionList[] OPTIONAL, 160 IN EFI_DHCP6_RETRANSMISSION *Retransmission, 161 IN EFI_EVENT TimeoutEvent OPTIONAL, 162 IN EFI_DHCP6_INFO_CALLBACK ReplyCallback, 163 IN VOID *CallbackContext OPTIONAL 130 164 ); 131 165 -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
r48674 r58459 2 2 Dhcp6 support functions implementation. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 42 42 // See details in section-9 of rfc-3315. 43 43 // 44 Duid = GetVariable (L"ClientId", &gEfiDhcp6ServiceBindingProtocolGuid);44 GetVariable2 (L"ClientId", &gEfiDhcp6ServiceBindingProtocolGuid, (VOID**)&Duid, NULL); 45 45 if (Duid != NULL) { 46 46 return Duid; … … 144 144 // Set the Duid-type, hardware-type, time and copy the hardware address. 145 145 // 146 WriteUnaligned16 ((UINT16 *) ( Duid->Duid), HTONS (Dhcp6DuidTypeLlt));147 WriteUnaligned16 ((UINT16 *) ( Duid->Duid+ 2), HTONS (NET_IFTYPE_ETHERNET));148 WriteUnaligned32 ((UINT32 *) ( Duid->Duid+ 4), HTONL (Stamp));149 146 WriteUnaligned16 ((UINT16 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid)), HTONS (Dhcp6DuidTypeLlt)); 147 WriteUnaligned16 ((UINT16 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 2), HTONS (NET_IFTYPE_ETHERNET)); 148 WriteUnaligned32 ((UINT32 *) ((UINT8 *) Duid + OFFSET_OF (EFI_DHCP6_DUID, Duid) + 4), HTONL (Stamp)); 149 150 150 CopyMem (Duid->Duid + 8, &Mode->CurrentAddress, Mode->HwAddressSize); 151 151 } … … 158 158 (VOID *) Duid 159 159 ); 160 ASSERT_EFI_ERROR (Status); 160 if (EFI_ERROR (Status)) { 161 FreePool (Duid); 162 return NULL; 163 } 161 164 162 165 return Duid; … … 384 387 ) 385 388 { 386 EFI_DHCP6_IA_ADDRESS *IaAddr;387 389 UINT32 MinLt; 388 390 UINT32 MaxLt; … … 399 401 // 400 402 for (Index = 0; Index < IaCb->Ia->IaAddressCount; Index++) { 401 IaAddr = IaCb->Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS); 402 MinLt = MIN (MinLt, IaAddr->ValidLifetime); 403 MaxLt = MAX (MinLt, IaAddr->ValidLifetime); 403 MinLt = MIN (MinLt, IaCb->Ia->IaAddress[Index].ValidLifetime); 404 MaxLt = MAX (MinLt, IaCb->Ia->IaAddress[Index].ValidLifetime); 404 405 } 405 406 … … 648 649 } 649 650 651 /** 652 Append the appointed IA Address option to Buf, and move Buf to the end. 653 654 @param[in, out] Buf The pointer to the position to append. 655 @param[in] IaAddr The pointer to the IA Address. 656 @param[in] MessageType Message type of DHCP6 package. 657 658 @return Buf The position to append the next option. 659 660 **/ 661 UINT8 * 662 Dhcp6AppendIaAddrOption ( 663 IN OUT UINT8 *Buf, 664 IN EFI_DHCP6_IA_ADDRESS *IaAddr, 665 IN UINT32 MessageType 666 ) 667 { 668 669 // The format of the IA Address option is: 670 // 671 // 0 1 2 3 672 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 673 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 674 // | OPTION_IAADDR | option-len | 675 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 676 // | | 677 // | IPv6 address | 678 // | | 679 // | | 680 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 681 // | preferred-lifetime | 682 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 683 // | valid-lifetime | 684 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 685 // . . 686 // . IAaddr-options . 687 // . . 688 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 689 690 // 691 // Fill the value of Ia Address option type 692 // 693 WriteUnaligned16 ((UINT16 *) Buf, HTONS (Dhcp6OptIaAddr)); 694 Buf += 2; 695 696 WriteUnaligned16 ((UINT16 *) Buf, HTONS (sizeof (EFI_DHCP6_IA_ADDRESS))); 697 Buf += 2; 698 699 CopyMem (Buf, &IaAddr->IpAddress, sizeof(EFI_IPv6_ADDRESS)); 700 Buf += sizeof(EFI_IPv6_ADDRESS); 701 702 // 703 // Fill the value of preferred-lifetime and valid-lifetime. 704 // According to RFC3315 Chapter 18.1.2, the preferred-lifetime and valid-lifetime fields 705 // should set to 0 when initiate a Confirm message. 706 // 707 if (MessageType != Dhcp6MsgConfirm) { 708 WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->PreferredLifetime)); 709 } 710 Buf += 4; 711 712 if (MessageType != Dhcp6MsgConfirm) { 713 WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->ValidLifetime)); 714 } 715 Buf += 4; 716 717 return Buf; 718 } 719 650 720 651 721 /** … … 656 726 @param[in] T1 The time of T1. 657 727 @param[in] T2 The time of T2. 728 @param[in] MessageType Message type of DHCP6 package. 658 729 659 730 @return Buf The position to append the next Ia option. … … 665 736 IN EFI_DHCP6_IA *Ia, 666 737 IN UINT32 T1, 667 IN UINT32 T2 738 IN UINT32 T2, 739 IN UINT32 MessageType 668 740 ) 669 741 { … … 671 743 UINT16 *Len; 672 744 UINTN Index; 673 UINT16 Length;674 745 675 746 // … … 714 785 // 715 786 if (Ia->Descriptor.Type == Dhcp6OptIana) { 716 WriteUnaligned32 ((UINT32 *) Buf, ((T1 != 0) ? T1 : 0xffffffff));787 WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T1 != 0) ? T1 : 0xffffffff)); 717 788 Buf += 4; 718 WriteUnaligned32 ((UINT32 *) Buf, ((T2 != 0) ? T2 : 0xffffffff));789 WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T2 != 0) ? T2 : 0xffffffff)); 719 790 Buf += 4; 720 791 } … … 724 795 // 725 796 for (Index = 0; Index < Ia->IaAddressCount; Index++) { 726 727 AddrOpt = (UINT8 *) Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS); 728 Length = HTONS ((UINT16) sizeof (EFI_DHCP6_IA_ADDRESS)); 729 Buf = Dhcp6AppendOption ( 730 Buf, 731 HTONS (Dhcp6OptIaAddr), 732 Length, 733 AddrOpt 734 ); 797 AddrOpt = (UINT8 *) Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS); 798 Buf = Dhcp6AppendIaAddrOption (Buf, (EFI_DHCP6_IA_ADDRESS *) AddrOpt, MessageType); 735 799 } 736 800 … … 828 892 // 829 893 // Sentinel value of 0 means that this is the first DHCP packet that we are 830 // sending and that we need to initialize the value. First DHCP Solicit894 // sending and that we need to initialize the value. First DHCP message 831 895 // gets 0 elapsed-time. Otherwise, calculate based on StartTime. 832 896 // … … 935 999 } 936 1000 1001 /** 1002 Check whether the incoming IPv6 address in IaAddr is one of the maintained 1003 addresses in the IA control blcok. 1004 1005 @param[in] IaAddr The pointer to the IA Address to be checked. 1006 @param[in] CurrentIa The pointer to the IA in IA control block. 1007 1008 @retval TRUE Yes, this Address is already in IA control block. 1009 @retval FALSE No, this Address is NOT in IA control block. 1010 1011 **/ 1012 BOOLEAN 1013 Dhcp6AddrIsInCurrentIa ( 1014 IN EFI_DHCP6_IA_ADDRESS *IaAddr, 1015 IN EFI_DHCP6_IA *CurrentIa 1016 ) 1017 { 1018 UINT32 Index; 1019 1020 ASSERT (IaAddr != NULL && CurrentIa != NULL); 1021 1022 for (Index = 0; Index < CurrentIa->IaAddressCount; Index++) { 1023 if (EFI_IP6_EQUAL(&IaAddr->IpAddress, &CurrentIa->IaAddress[Index].IpAddress)) { 1024 return TRUE; 1025 } 1026 } 1027 return FALSE; 1028 } 937 1029 938 1030 /** 939 1031 Parse the address option and update the address infomation. 940 1032 1033 @param[in] CurrentIa The pointer to the Ia Address in control blcok. 941 1034 @param[in] IaInnerOpt The pointer to the buffer. 942 1035 @param[in] IaInnerLen The length to parse. … … 947 1040 VOID 948 1041 Dhcp6ParseAddrOption ( 1042 IN EFI_DHCP6_IA *CurrentIa, 949 1043 IN UINT8 *IaInnerOpt, 950 1044 IN UINT16 IaInnerLen, … … 957 1051 UINT16 OpCode; 958 1052 UINT32 ValidLt; 1053 UINT32 PreferredLt; 1054 EFI_DHCP6_IA_ADDRESS *IaAddr; 959 1055 960 1056 // … … 993 1089 while (Cursor < IaInnerOpt + IaInnerLen) { 994 1090 // 995 // Count the Ia address option with non-0 valid time. 1091 // Refer to RFC3315 Chapter 18.1.8, we need to update lifetimes for any addresses in the IA option 1092 // that the client already has recorded in the IA, and discard the Ia address option with 0 valid time. 996 1093 // 997 1094 OpCode = ReadUnaligned16 ((UINT16 *) Cursor); 998 ValidLt = ReadUnaligned32 ((UINT32 *) (Cursor + 24)); 999 if (OpCode == HTONS (Dhcp6OptIaAddr) && ValidLt != 0) { 1000 1095 PreferredLt = NTOHL (ReadUnaligned32 ((UINT32 *) (Cursor + 20))); 1096 ValidLt = NTOHL (ReadUnaligned32 ((UINT32 *) (Cursor + 24))); 1097 IaAddr = (EFI_DHCP6_IA_ADDRESS *) (Cursor + 4); 1098 if (OpCode == HTONS (Dhcp6OptIaAddr) && ValidLt >= PreferredLt && 1099 (Dhcp6AddrIsInCurrentIa(IaAddr, CurrentIa) || ValidLt !=0)) { 1001 1100 if (AddrBuf != NULL) { 1002 CopyMem (AddrBuf, Cursor + 4, sizeof (EFI_DHCP6_IA_ADDRESS));1003 AddrBuf->PreferredLifetime = NTOHL (AddrBuf->PreferredLifetime);1004 AddrBuf->ValidLifetime = NTOHL (AddrBuf->ValidLifetime);1101 CopyMem (AddrBuf, IaAddr, sizeof (EFI_DHCP6_IA_ADDRESS)); 1102 AddrBuf->PreferredLifetime = PreferredLt; 1103 AddrBuf->ValidLifetime = ValidLt; 1005 1104 AddrBuf = (EFI_DHCP6_IA_ADDRESS *) ((UINT8 *) AddrBuf + sizeof (EFI_DHCP6_IA_ADDRESS)); 1006 1105 } 1007 1008 1106 (*AddrNum)++; 1009 1107 } … … 1026 1124 @retval EFI_SUCCESS Create an IA control block successfully. 1027 1125 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 1126 @retval EFI_DEVICE_ERROR An unexpected error. 1028 1127 1029 1128 **/ … … 1042 1141 1043 1142 if (Instance->IaCb.Ia == NULL) { 1044 return EFI_ NOT_FOUND;1143 return EFI_DEVICE_ERROR; 1045 1144 } 1046 1145 … … 1049 1148 // the value 0 of valid lifetime. 1050 1149 // 1051 Dhcp6ParseAddrOption (I aInnerOpt, IaInnerLen, &AddrNum, NULL);1150 Dhcp6ParseAddrOption (Instance->IaCb.Ia, IaInnerOpt, IaInnerLen, &AddrNum, NULL); 1052 1151 1053 1152 if (AddrNum == 0) { … … 1071 1170 Ia->IaAddressCount = AddrNum; 1072 1171 CopyMem (&Ia->Descriptor, &Instance->Config->IaDescriptor, sizeof (EFI_DHCP6_IA_DESCRIPTOR)); 1073 Dhcp6ParseAddrOption (I aInnerOpt, IaInnerLen, &AddrNum, Ia->IaAddress);1172 Dhcp6ParseAddrOption (Instance->IaCb.Ia, IaInnerOpt, IaInnerLen, &AddrNum, Ia->IaAddress); 1074 1173 1075 1174 // … … 1190 1289 } 1191 1290 } 1291 1292 /** 1293 Calculate the Dhcp6 get mapping timeout by adding additinal delay to the IP6 DAD transmits count. 1294 1295 @param[in] Ip6Cfg The pointer to Ip6 config protocol. 1296 @param[out] TimeOut The time out value in 100ns units. 1297 1298 @retval EFI_INVALID_PARAMETER Input parameters are invalid. 1299 @retval EFI_SUCCESS Calculate the time out value successfully. 1300 **/ 1301 EFI_STATUS 1302 Dhcp6GetMappingTimeOut ( 1303 IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg, 1304 OUT UINTN *TimeOut 1305 ) 1306 { 1307 EFI_STATUS Status; 1308 UINTN DataSize; 1309 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits; 1310 1311 if (Ip6Cfg == NULL || TimeOut == NULL) { 1312 return EFI_INVALID_PARAMETER; 1313 } 1314 1315 DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS); 1316 Status = Ip6Cfg->GetData ( 1317 Ip6Cfg, 1318 Ip6ConfigDataTypeDupAddrDetectTransmits, 1319 &DataSize, 1320 &DadXmits 1321 ); 1322 if (EFI_ERROR (Status)) { 1323 return Status; 1324 } 1325 1326 *TimeOut = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + DHCP6_DAD_ADDITIONAL_DELAY; 1327 1328 return EFI_SUCCESS; 1329 } -
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h
r48674 r58459 2 2 Dhcp6 support functions declaration. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 18 18 19 19 20 #define DHCP6_10_BIT_MASK 0x3ff 20 #define DHCP6_10_BIT_MASK 0x3ff 21 #define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds 21 22 22 23 /** … … 192 193 @param[in] T1 The time of T1. 193 194 @param[in] T2 The time of T2. 195 @param[in] MessageType Message type of DHCP6 package. 194 196 195 197 @return Buf The position to append the next Ia option. … … 201 203 IN EFI_DHCP6_IA *Ia, 202 204 IN UINT32 T1, 203 IN UINT32 T2 205 IN UINT32 T2, 206 IN UINT32 MessageType 204 207 ); 205 208 … … 274 277 Parse the address option and update the address info. 275 278 279 @param[in] CurrentIa The pointer to the Ia Address in control blcok. 276 280 @param[in] IaInnerOpt The pointer to the buffer. 277 281 @param[in] IaInnerLen The length to parse. … … 282 286 VOID 283 287 Dhcp6ParseAddrOption ( 288 IN EFI_DHCP6_IA *CurrentIa, 284 289 IN UINT8 *IaInnerOpt, 285 290 IN UINT16 IaInnerLen, … … 300 305 @retval EFI_SUCCESS Create an IA control block successfully. 301 306 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 307 @retval EFI_DEVICE_ERROR An unexpected error. 302 308 303 309 **/ … … 338 344 ); 339 345 346 /** 347 Calculate the Dhcp6 get mapping timeout by adding additinal delay to the IP6 DAD transmits count. 348 349 @param[in] Ip6Cfg The pointer to Ip6 config protocol. 350 @param[out] TimeOut The time out value in 100ns units. 351 352 @retval EFI_INVALID_PARAMETER Input parameters are invalid. 353 @retval EFI_SUCCESS Calculate the time out value successfully. 354 **/ 355 EFI_STATUS 356 Dhcp6GetMappingTimeOut ( 357 IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg, 358 OUT UINTN *TimeOut 359 ); 340 360 #endif
Note:
See TracChangeset
for help on using the changeset viewer.